/*
  m29.css — 29 Signals custom page layouts
  ----------------------------------------
  Ports the Shipixen/Next.js layouts from the original 29signals.org repo
  into this Ghost theme:
    · .m29-grid / .m29-card       → CSGridLayout case-study card grid
    · .m29-list / .m29-sidebar    → ListLayoutWithTags (projects archive)
    · .m29-post-*                 → PostLayout / PostSimple detail layouts
    · .m29-fancy-heading/-overlay → gradient heading + ambient page wash
  Palette: salt-blue (slate primary / stone secondary), same slate scale
  as overrides.css. Hand-written — not managed by Fantasma.
*/

/* ---------- tokens ---------- */
:root {
  --m29-primary-300: #cbd5e1;
  --m29-primary-500: #64748b;
  --m29-primary-600: #475569;
  --m29-primary-700: #334155;
  --m29-card-bg: #e5e7eb;
  --m29-card-bg-hover: #ffffff;
  --m29-badge-bg: #d1d5db;
  --m29-badge2-border: #a8a29e;
  --m29-badge2-bg: rgb(214 211 209 / 0.4);
  --m29-muted: #6b7280;
  --m29-rule: #e5e7eb;
  --m29-ink: #111827;
}
.dark {
  --m29-primary-300: #475569;
  --m29-primary-500: #94a3b8;
  --m29-primary-600: #cbd5e1;
  --m29-primary-700: #e2e8f0;
  --m29-card-bg: #111827;
  --m29-card-bg-hover: #1e293b;
  --m29-badge-bg: rgb(203 213 225 / 0.9);
  --m29-badge2-border: #57534e;
  --m29-badge2-bg: rgb(68 64 60 / 0.6);
  --m29-muted: #9ca3af;
  --m29-rule: #374151;
  --m29-ink: #f3f4f6;
}

/* ---------- containers ---------- */
.m29-wide { width: 100%; max-width: 72rem; margin-inline: auto; padding: 1.5rem; }
.m29-ultrawide { width: 100%; max-width: 80rem; margin-inline: auto; padding: 1.5rem; }

/* ---------- fancy heading (gradient-clipped text) ---------- */
.m29-fancy-heading {
  background-image: linear-gradient(rgb(10 10 10) 10%, rgb(10 10 10 / 0.68));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  width: fit-content;
}
.dark .m29-fancy-heading {
  background-image: linear-gradient(rgb(245 245 245) 10%, rgb(245 245 245 / 0.68));
}

/* ---------- archive headers ---------- */
.m29-archive-header h1 {
  font-size: clamp(2.25rem, 5vw, 3.75rem);
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: -0.025em;
}
.m29-archive-header .m29-intro { margin-top: 1.5rem; font-size: 1.125rem; }
.m29-archive-header .m29-intro-sub { color: var(--m29-muted); margin-top: 0.5rem; margin-bottom: 1.5rem; }

/* ---------- case-study card grid (CSGridLayout) ---------- */
.m29-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
  margin-top: 1.5rem;
}
@media (min-width: 768px) { .m29-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .m29-grid { grid-template-columns: repeat(3, 1fr); } }

.m29-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--m29-card-bg);
  border-radius: 0.375rem;
  overflow: hidden;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  transition: box-shadow 0.2s ease, background-color 0.2s ease;
}
.m29-card:hover {
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  background: var(--m29-card-bg-hover);
}
.m29-card-image { display: block; }
.m29-card-image img {
  width: 100%;
  height: 12rem;
  object-fit: cover;
  object-position: center;
  border-radius: 0.5rem 0.5rem 0 0;
  display: block;
}
.m29-card-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem 1rem 4rem;
  flex: 1;
}
.m29-card-title {
  font-size: 1.4rem;
  line-height: 1.35;
  letter-spacing: -0.015em;
  font-weight: 600;
  text-transform: capitalize;
  margin: 0;
  color: var(--m29-ink);
}
.m29-card-title a { color: inherit; text-decoration: none; }
/* full-card overlay link */
.m29-card-overlay { position: absolute; inset: 0; z-index: 1; }
.m29-card-overlay span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.m29-card .m29-badges { position: relative; z-index: 2; width: fit-content; }
.m29-card-summary { color: var(--m29-muted); font-size: 0.95rem; line-height: 1.6; margin: 0; }
.m29-learn-more {
  position: absolute;
  bottom: 1.25rem;
  right: 1.5rem;
  font-weight: 500;
  color: var(--m29-primary-500);
  text-decoration: none;
  z-index: 2;
}
.m29-learn-more:hover { color: var(--m29-primary-600); }

/* ---------- badges + tag links ---------- */
.m29-badges { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; text-transform: uppercase; }
.m29-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid var(--m29-primary-300);
  background: var(--m29-badge-bg);
  border-radius: 999px;
  padding: 0.125rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}
.dark .m29-badge { color: #111827; }
.m29-badge a { color: var(--m29-primary-700); text-decoration: none; }
.dark .m29-badge a { color: #1e293b; }
.m29-badge a:hover { color: var(--m29-primary-500); }
.m29-badge--secondary {
  border: 1px solid var(--m29-badge2-border);
  background: var(--m29-badge2-bg);
  color: var(--m29-ink);
  font-weight: 550;
}
.m29-tag-link {
  margin-right: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--m29-primary-500);
  text-decoration: none;
}
.m29-tag-link:hover { color: var(--m29-primary-700); }

/* "See all →" row under grids */
.m29-see-all { display: flex; justify-content: flex-end; margin-top: 1.25rem; font-weight: 500; }
.m29-see-all a { color: var(--m29-primary-500); text-decoration: none; }
.m29-see-all a:hover { color: var(--m29-primary-600); }

/* ---------- vertical list + sidebar (ListLayoutWithTags) ---------- */
.m29-list-wrap { display: flex; gap: 3rem; }
.m29-list-main { width: 100%; min-width: 0; }
.m29-list { display: flex; flex-direction: column; gap: 1rem; list-style: none; margin: 0; padding: 0; }
.m29-row {
  position: relative;
  display: flex;
  border-radius: 0.375rem;
  overflow: hidden;
  transition: box-shadow 0.2s ease, background-color 0.2s ease;
}
@media (min-width: 768px) {
  .m29-row { background: #ffffff; box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); }
  .m29-row:hover { box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1); }
  .dark .m29-row { background: #000000; }
  .dark .m29-row:hover { background: #1e293b; }
}
.m29-row-thumb { display: none; }
@media (min-width: 1024px) {
  .m29-row-thumb { display: block; position: relative; width: 13rem; flex-shrink: 0; }
  .m29-row-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
}
.m29-row-body { display: flex; flex-direction: column; gap: 0.75rem; padding: 1.25rem; }
@media (min-width: 768px) { .m29-row-body { padding: 2rem; } }
.m29-row-title { font-size: 1.6rem; line-height: 1.3; letter-spacing: -0.015em; font-weight: 600; margin: 0; color: var(--m29-ink); }
.m29-row-date { font-size: 1rem; font-weight: 500; color: var(--m29-muted); }
.m29-row-summary { color: var(--m29-muted); margin: 0; }
.m29-row .m29-badges, .m29-row .m29-tags { position: relative; z-index: 2; width: fit-content; }

.m29-sidebar { display: none; }
@media (min-width: 640px) {
  .m29-sidebar {
    display: block;
    min-width: 280px;
    max-width: 280px;
    max-height: 100vh;
    overflow: auto;
  }
  .m29-sidebar h2 { font-size: 1rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.03em; }
  .m29-sidebar ul { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1rem; list-style: none; padding: 0; }
  .m29-sidebar a { text-decoration: none; }
  .m29-sidebar .m29-count { margin-left: 0.25rem; font-size: 0.85rem; font-weight: 650; text-transform: uppercase; color: var(--m29-muted); }
}

/* pagination */
.m29-pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 2.5rem; font-weight: 500; }
.m29-pagination a { color: var(--m29-primary-500); text-decoration: none; }
.m29-pagination a:hover { color: var(--m29-primary-600); }
.m29-pagination .m29-page-info { color: var(--m29-muted); font-size: 0.95rem; }
.m29-pagination span[aria-disabled] { color: var(--m29-rule); }

/* ---------- post detail: shared header ---------- */
.m29-post-header { padding-top: 1.5rem; text-align: center; }
.m29-post-header time {
  display: block;
  font-size: 1rem;
  font-weight: 500;
  color: var(--m29-muted);
  margin-bottom: 1rem;
}
.m29-post-title {
  font-size: clamp(1.875rem, 4.5vw, 3rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.025em;
  margin: 0;
  text-wrap: balance;
}
.m29-post-header--ruled { border-bottom: 1px solid var(--m29-rule); padding-bottom: 2.5rem; }

/* lifecycle + workflow chips (project pages) */
.m29-chips { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.25rem; }
.m29-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--m29-primary-300);
  padding: 0.2rem 0.8rem;
  font-size: 0.75rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--m29-primary-600);
}
.m29-chip--flow { border-style: dashed; color: var(--m29-muted); text-transform: none; letter-spacing: 0; }

/* ---------- case-study detail: PostLayout 4-col grid ---------- */
.m29-cs-grid { padding-bottom: 2rem; }
@media (min-width: 1280px) {
  .m29-cs-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: auto 1fr;
    column-gap: 1.5rem;
  }
  .m29-cs-content { grid-column: span 3; grid-row: span 2; }
  .m29-cs-meta { grid-column: 1; grid-row: 2; }
}
.m29-authors {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem 0 2.5rem;
  border-bottom: 1px solid var(--m29-rule);
  list-style: none;
  margin: 0;
}
@media (min-width: 1280px) {
  .m29-authors { display: block; padding-top: 2.75rem; }
}
.m29-author { display: flex; align-items: center; gap: 0.5rem; }
.m29-author img { width: 2.5rem; height: 2.5rem; border-radius: 999px; object-fit: cover; }
.m29-author-name { font-size: 0.875rem; font-weight: 500; color: var(--m29-ink); }
.m29-author-link { font-size: 0.8rem; }
.m29-author-link a { color: var(--m29-primary-500); text-decoration: none; }

.m29-cs-content { padding: 2.5rem 0 2rem; }
@media (min-width: 1024px) {
  .m29-cs-content {
    background: #ffffff;
    padding: 1rem 2.5rem 2rem;
    border-radius: 0.375rem;
  }
  .dark .m29-cs-content { background: #0f172a; }
}

.m29-cs-meta { font-size: 0.875rem; font-weight: 500; }
.m29-cs-meta > div { padding: 1rem 0; }
@media (min-width: 1280px) {
  .m29-cs-meta > div { padding: 2rem 0; border-bottom: 1px solid var(--m29-rule); }
  .m29-cs-meta > div:last-child { border-bottom: 0; }
}
.m29-meta-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--m29-muted);
  font-weight: 600;
  margin: 0 0 0.5rem;
}
.m29-meta-tags { display: flex; flex-wrap: wrap; }
.m29-prevnext { display: flex; justify-content: space-between; gap: 1rem; }
@media (min-width: 1280px) { .m29-prevnext { display: block; } .m29-prevnext > div + div { margin-top: 2rem; } }
.m29-prevnext a { color: var(--m29-primary-500); text-decoration: none; }
.m29-prevnext a:hover { color: var(--m29-primary-600); }
.m29-more-link a { color: var(--m29-primary-500); text-decoration: none; font-weight: 500; }

/* ---------- project detail: PostSimple ---------- */
.m29-simple-content { padding: 2.5rem 0 2rem; }
.m29-simple-footer {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--m29-rule);
  font-weight: 500;
  font-size: 0.95rem;
}
@media (min-width: 640px) {
  .m29-simple-footer { flex-direction: row; justify-content: space-between; font-size: 1rem; }
}
.m29-simple-footer a { color: var(--m29-primary-500); text-decoration: none; }
.m29-simple-footer a:hover { color: var(--m29-primary-600); }

/* content width for detail bodies (theme's gh-content is width-managed by
   its own section normally; here we manage it) */
.m29-detail-body .gh-content { max-width: 48rem; margin-inline: auto; }
@media (min-width: 1280px) {
  .m29-cs-content .gh-content { max-width: none; margin-inline: 0; }
}
