/*
  thepancakestack.dev: the one stylesheet for every page.

  Theme: Direction 1a, "Warm paper". Every color, font, radius and layout
  size is a token on :root, and components only read tokens. A new theme
  (dark mode, or an app's own accent) overrides tokens and nothing else:

    [data-theme="dark"] { --paper: …; --ink: …; }   on <html>
    body.app-crossword  { --accent: …; --accent-ink: …; }

  Pages load the fonts themselves (see any page's <head>).
*/

/* ---------- Tokens ---------- */

:root {
  /* Light only until a dark token set exists. When adding one, change this
     to "light dark" and add the overrides below. */
  color-scheme: light;

  /* surfaces */
  --paper:         #f7f4ee;  /* page background */
  --paper-raised:  #fffdf9;  /* cards */
  --paper-sunk:    #efe9df;  /* alternate section band */
  --stack-1:       #efe9df;  /* stacked-card layer 1 */
  --stack-2:       #f3eee6;  /* stacked-card layer 2 */
  --placeholder-a: #f1ece3;  /* striped placeholders */
  --placeholder-b: #ebe5da;
  --icon-ph-a:     #e9e2d5;
  --icon-ph-b:     #ddd5c6;

  /* ink */
  --ink:   #1d1a16;  /* headings, primary text, strong rules */
  --ink-2: #5f584e;  /* body copy, nav links */
  --ink-3: #8b8478;  /* captions, footer, mono meta */

  /* lines */
  --rule:        #e4ded3;  /* hairlines, card borders */
  --rule-strong: #cfc6b6;  /* rules on sunk bands, outline pills */

  /* accent (syrup) */
  --accent:      #c98a2e;  /* fills: logo bar, underlines, hover borders */
  --accent-ink:  #8a6324;  /* accent text on paper */
  --accent-em:   #a8701f;  /* italic emphasis in display headings */
  --accent-tint: #f6e2c0;  /* active crossword entry, callouts */

  /* type */
  --font-display: "Instrument Serif", Georgia, serif;
  --font-body:    "Hanken Grotesk", system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, monospace;

  --fs-display:     clamp(48px, 9vw, 96px);
  --fs-display-app: clamp(48px, 8vw, 88px);
  --fs-cta:         clamp(40px, 6vw, 64px);
  --fs-h2-feature:  clamp(34px, 4.5vw, 48px);
  --fs-h2:          clamp(32px, 4vw, 40px);

  /* radii */
  --r-sm:   11px;
  --r-md:   14px;
  --r-lg:   16px;
  --r-xl:   20px;
  --r-icon: 22px;
  --r-pill: 999px;

  /* layout */
  --page-max: 1280px;
  --gutter:   72px;
  --prose-max: 720px;
  --section-y: 96px;
  --ease: 150ms ease;
}

@media (max-width: 900px) {
  :root {
    --gutter: 24px;
    --section-y: 64px;
  }
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- Layout ---------- */

/* Centers content at the page width with the side gutter. */
.wrap {
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section { padding-block: var(--section-y); }
.section--band { background: var(--paper-sunk); }
.section--tight-top { padding-top: 0; }
.section--lg { padding-block: 112px; }
@media (max-width: 900px) { .section--lg { padding-block: var(--section-y); } }

.stack { display: flex; flex-direction: column; gap: var(--stack-gap, 28px); }

/* Equal columns that collapse to one below 900px. Set --cols (and --grid-gap) on the element. */
.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
  gap: var(--grid-gap, 32px);
}

@media (max-width: 900px) {
  .grid { grid-template-columns: minmax(0, 1fr); }

  /* A row of tall items (screenshots) scrolls sideways instead of stacking. */
  .grid--scroll {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: min(70%, 280px);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 8px;
  }
  .grid--scroll > * { scroll-snap-align: start; }
}

/* ---------- Header ---------- */

.site-header { border-bottom: 1px solid var(--rule); }
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-block: 28px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* Three stacked bars: the top one syrup, the others ink. */
.logo-mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.logo-mark i {
  display: block;
  height: 5px;
  border-radius: 3px;
  background: var(--ink);
}
.logo-mark i:nth-child(1) { width: 18px; background: var(--accent); }
.logo-mark i:nth-child(2) { width: 24px; }
.logo-mark i:nth-child(3) { width: 20px; }

.nav, .footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 36px;
  font-size: 15px;
  color: var(--ink-2);
}
.nav a, .footer-links a { transition: color var(--ease); }
.nav a:hover, .footer-links a:hover,
.nav [aria-current] { color: var(--ink); }

.nav { align-items: center; }

@media (max-width: 600px) {
  .site-header .wrap { flex-wrap: wrap; gap: 12px 16px; }
  .nav { gap: 8px 16px; }
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--rule);
  font-size: 14px;
  color: var(--ink-3);
}
.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 28px;
  padding-block: 28px;
}
.footer-links { gap: 8px 28px; font-size: inherit; color: inherit; }

/* ---------- Type ---------- */

.eyebrow {
  font: 13px/1.4 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-ink);
}

.display {
  font: 400 var(--fs-display)/0.98 var(--font-display);
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.display em { color: var(--accent-em); }
.display--app { font-size: var(--fs-display-app); }

.h2 {
  font: 400 var(--fs-h2)/1.1 var(--font-display);
  text-wrap: balance;
}
.h2--feature { font-size: var(--fs-h2-feature); line-height: 1.05; max-width: 640px; }
.h2--cta { font-size: var(--fs-cta); line-height: 1; letter-spacing: -0.01em; max-width: 760px; }

.lede {
  font-size: 18px;
  color: var(--ink-2);
  text-wrap: pretty;
}
.lede--app { font-size: 21px; line-height: 1.5; max-width: 520px; }

.meta {
  font: 13px/1.4 var(--font-mono);
  color: var(--ink-3);
}
.meta a:hover { color: var(--ink); }

/* Email address as a call to action. */
.stack > .cta-link { align-self: flex-start; }
.cta-link {
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 4px;
  overflow-wrap: anywhere;
}

/* Inline links in accent ink, e.g. "View app →" or Support / Privacy. */
.text-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-ink);
}

/* ---------- Heroes ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--hero-aside, 300px);
  gap: var(--hero-gap, 72px);
  align-items: end;
  padding-block: 112px 96px;
}
.hero--app {
  --hero-aside: 400px;
  --hero-gap: 80px;
  align-items: center;
  padding-block: 88px 96px;
}

@media (max-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 40px; padding-block: 64px; }
}

/* ---------- Section header: rule + title + count ---------- */

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  border-top: 1px solid var(--ink);
  padding-top: 20px;
  margin-bottom: 40px;
}
.section-head .meta { font-size: 13px; }

/* Two-up: heading column beside content (home "How the studio works"). */
.split {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 72px;
}
@media (max-width: 900px) {
  .split { grid-template-columns: minmax(0, 1fr); gap: 40px; }
}

/* ---------- Stacked-card edge: the "pancake stack" motif ----------
   Two offset layers under the card. Hero-level cards only. */

.stacked {
  --stack-y: 6px;
  box-shadow:
    0 var(--stack-y) 0 -1px var(--stack-1),
    0 var(--stack-y) 0 0 var(--rule),
    0 calc(var(--stack-y) * 2) 0 -1px var(--stack-2),
    0 calc(var(--stack-y) * 2) 0 0 var(--rule);
}

.surface {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
}

/* ---------- App icons (striped until real icons exist) ---------- */

.app-icon {
  --size: 44px;
  flex: none;
  width: var(--size);
  height: var(--size);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font: 11px var(--font-mono);
  color: var(--ink-3);
  background: repeating-linear-gradient(135deg, var(--icon-ph-a) 0 6px, var(--icon-ph-b) 6px 12px);
}
.app-icon--lg {
  --size: 88px;
  border-radius: var(--r-icon);
  background: repeating-linear-gradient(135deg, var(--icon-ph-a) 0 8px, var(--icon-ph-b) 8px 16px);
}

/* ---------- App card ---------- */

.app-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--ease);
}
.app-card:hover { transform: translateY(-2px); }
.app-card-media {
  height: 280px;
  overflow: hidden;
  background: var(--paper-sunk);
  border-bottom: 1px solid var(--rule);
}
/* A wide screenshot fills the frame from its top-left corner. */
.app-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top left;
}
/* A phone screenshot peeks up from the bottom edge. */
.app-card-media--phone { display: flex; justify-content: center; padding-top: 32px; }
.app-card-media--phone img {
  width: 200px;
  height: auto;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: 0 0 0 1px var(--rule);
}
.app-card-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px 32px 32px;
}
.app-card-title {
  display: flex;
  align-items: center;
  gap: 14px;
}
.app-card h3 { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.app-card p:not(.text-links) { color: var(--ink-2); }
/* Lets the whole card act as one link to its app page. */
.app-card-link::after { content: ""; position: absolute; inset: 0; }
.app-card { position: relative; }

@media (max-width: 600px) {
  .app-card-media { height: 220px; }
  .app-card-body { padding: 24px; }
}

/* ---------- Screenshots ----------
   Real app screenshots, framed like the placeholders they replace. */

.shot {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  border-radius: var(--r-xl);
  background: var(--paper-raised);
}

/* A single phone screenshot in an app page's hero column. */
.hero-shot {
  --stack-y: 8px;
  max-width: 280px;
  justify-self: end;
}
@media (max-width: 900px) {
  .hero-shot { justify-self: start; max-width: 240px; }
}

/* ---------- Numbered / feature columns ---------- */

.col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid var(--rule);
  padding-top: 20px;
}
.section--band .col { border-top-color: var(--rule-strong); }
.col .meta { color: var(--accent-ink); }
.col h3 { font-size: 19px; font-weight: 600; }
.col p { font-size: 15px; color: var(--ink-2); }

/* ---------- Link card ---------- */

.link-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 28px;
  border-radius: var(--r-md);
  transition: border-color var(--ease);
}
.link-card:hover { border-color: var(--accent); }
.link-card strong { font-size: 19px; font-weight: 600; }
.link-card span { font-size: 15px; color: var(--ink-2); }

/* ---------- Pills ---------- */

.pills { display: flex; flex-wrap: wrap; align-items: center; gap: var(--pills-gap, 12px); }
.pill {
  display: inline-block;
  padding: 12px 20px;
  border-radius: var(--r-pill);
  font-size: 15px;
  border: 1px solid var(--rule-strong);
  color: var(--ink-2);
  transition: border-color var(--ease), background-color var(--ease);
}
a.pill:hover { border-color: var(--accent); }
.pill--solid {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
  font-weight: 600;
}

/* ---------- Crossword grid ----------
   Plain HTML so any puzzle app page can reuse it. Cells: .xw-cell, plus
   .is-black or .is-active; a clue number goes in <sup>. */

.xw-panel {
  --stack-y: 8px;
  margin: 0;
  width: 100%;
  max-width: 400px;
  padding: 28px;
  border-radius: var(--r-xl);
}
.xw {
  display: grid;
  grid-template-columns: repeat(var(--xw-size, 5), 1fr);
  border: 2px solid var(--ink);
  background: var(--paper-raised);
}
.xw-cell {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--rule-strong);
  font-size: clamp(20px, 6vw, 30px);
  font-weight: 600;
}
.xw-cell sup {
  position: absolute;
  top: 3px;
  left: 5px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  color: var(--ink-2);
}
.xw-cell.is-black { background: var(--ink); }
.xw-cell.is-active { background: var(--accent-tint); }
.xw-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
  font-size: 12px;
}

@media (max-width: 900px) {
  .xw-panel { justify-self: start; }
}

/* ---------- Document pages: support, privacy, terms ---------- */

.doc {
  max-width: calc(var(--prose-max) + 2 * var(--gutter));
  padding-block: 72px var(--section-y);
  color: var(--ink-2);
}
.doc > .meta:first-child { margin-bottom: 20px; }
.doc h1 {
  font: 400 var(--fs-h2-feature)/1.05 var(--font-display);
  color: var(--ink);
  text-wrap: balance;
  margin-bottom: 12px;
}
.doc h2 {
  font: 400 28px/1.2 var(--font-display);
  color: var(--ink);
  margin: 48px 0 12px;
}
.doc h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin: 28px 0 4px;
}
.doc p { margin: 12px 0; }
.doc ul, .doc ol { margin: 12px 0; padding-left: 22px; }
.doc li { margin: 6px 0; }
.doc strong, .doc th { color: var(--ink); font-weight: 600; }
.doc code { font: 0.9em var(--font-mono); color: var(--ink); }
.doc a {
  color: var(--accent-ink);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}
.doc a:hover { color: var(--ink); }
.doc .meta a { text-decoration: none; color: inherit; }

.doc .updated {
  font: 13px/1.4 var(--font-mono);
  color: var(--ink-3);
  margin: 0 0 32px;
}

.doc .email {
  display: inline-block;
  margin: 12px 0 8px;
  text-decoration: none;
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 4px;
}

.doc .callout {
  margin: 24px 0;
  padding: 8px 24px;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
}

/* Contents list: two columns of mono-numbered links. */
.doc .toc {
  margin: 32px 0;
  padding: 20px 0 8px;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--rule);
}
.doc .toc ol { columns: 2; column-gap: 32px; margin: 0; }
.doc .toc li { margin: 0 0 10px; break-inside: avoid; }
.doc .toc li::marker { font: 12px var(--font-mono); color: var(--ink-3); }
.doc .toc a { text-decoration: none; color: var(--ink-2); }
.doc .toc a:hover { color: var(--accent-ink); }
@media (max-width: 600px) {
  .doc .toc ol { columns: 1; }
}

.doc .table-wrap { overflow-x: auto; margin: 16px 0; }
.doc table { width: 100%; border-collapse: collapse; font-size: 15px; }
.doc caption {
  text-align: left;
  font: 12px/1.4 var(--font-mono);
  color: var(--ink-3);
  padding-bottom: 8px;
}
.doc th, .doc td {
  text-align: left;
  vertical-align: top;
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule);
}
.doc thead th {
  border-bottom: 1px solid var(--ink);
  font-size: 14px;
}
.doc th:first-child, .doc td:first-child { padding-left: 0; }

/* Links to the app's other policy pages, closing a document. */
.doc .related {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
  font-size: 15px;
  font-weight: 600;
}
.doc .related a { text-decoration: none; }

@media (max-width: 900px) {
  .doc { padding-block: 48px var(--section-y); }
}
