/*
 * EB Studio site — built on ThisLife's "Warm Chronicle" design system.
 * Tokens are copied from century-life/src/constants/palette.json and the rules
 * from century-life/docs/DESIGN.md (section numbers cited as DESIGN §n).
 * Light only, like the app (DESIGN §2.8). Section map:
 *   1 tokens · 2 base · 3 header · 4 type · 5 components · 6 pages · 7 footer
 */

/* ---- 1. Tokens ------------------------------------------------------------ */
:root {
  color-scheme: light;

  /* Surfaces, back to front (DESIGN §2.1, §6) */
  --canvas: #F5EFE6;
  --card: #FFFFFF;
  --card-parchment: #FAF7F2;
  --well: #F0E8DC;
  --well-soft: #F4EFE8;
  --button-soft: #EDE6DC;
  --border: #EAE2D5;
  --border-strong: #E2D7C7;

  /* Ink (DESIGN §2.2). ink-muted is for uppercase bold labels only. */
  --ink: #2E2B28;
  --ink-secondary: #5C5752;
  --ink-muted: #857E77;
  --ink-inverse: #FFFFFF;

  /* The one orange (DESIGN §2.3) */
  --accent: #FF7A45;
  --accent-pressed: #E8652F;
  --accent-tint: #FFF1EA;

  /* Semantic, used for meaning only (DESIGN §2.4) */
  --gain-ink: #1F7A4D;
  --gain-tint: #E8F5EE;
  --info-ink: #1E7268;
  --info-tint: #E6F4F2;
  --cost: #D9534F;

  /* The historical layer (DESIGN §2.6) */
  --hist-bg: #FDF6E8;
  --hist-border: #D4AF37;
  --hist-ink: #9C7A1E;
  --hist-from: #E89A0C;
  --hist-to: #C26A00;

  /* Category tints for icon plates (DESIGN §2.7) */
  --tint-peach: #FFE3D3;
  --tint-sand: #FBE8C8;
  --tint-mint: #CFF5EC;
  --tint-sky: #E3EEFB;
  --tint-lemon: #FDF3CF;
  --tint-neutral: #F3EDE4;

  /* Elevation: warm brown, never neutral black (DESIGN §7) */
  --shadow-card: 0 1px 8px 0 rgba(68, 53, 38, 0.05);
  --shadow-raised: 0 4px 16px -2px rgba(68, 53, 38, 0.08);
  --shadow-cta: 0 4px 12px 0 rgba(200, 85, 35, 0.30);
  --shadow-hist: 0 16px 36px -10px rgba(78, 52, 16, 0.45);

  /* Shape (DESIGN §5) */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-2xl: 28px;
  --r-full: 9999px;

  /* Families (DESIGN §3.1): sans for chrome, serif for story */
  --sans: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Merriweather", Georgia, "Times New Roman", serif;

  --page-max: 760px;
  --wide-max: 960px;
}

/* ---- 2. Base -------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 96px; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  color: var(--ink);
  font: 500 15px/22px var(--sans);
  -webkit-font-smoothing: antialiased;
}

main { flex: 1; width: 100%; }

img { max-width: 100%; height: auto; }

/* Orange text fails contrast (DESIGN §2.3), so links stay ink and carry the
   orange as an underline instead, the way prose bullets do. */
a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
a:hover { text-decoration-thickness: 3px; }
a:focus-visible, summary:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.wrap {
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 16px;
}
.wrap-wide { max-width: var(--wide-max); }

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus { left: 16px; top: 16px; z-index: 10; background: var(--card); padding: 8px 12px; }

/* ---- 3. Header: a floating pill bar, like the app's bottom nav (DESIGN §9.10) */
.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 12px 0 0;
  background: linear-gradient(var(--canvas) 70%, rgba(245, 239, 230, 0));
}
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 6px 6px 8px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-raised);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding-right: 6px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.2px;
  white-space: nowrap;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--r-full);
  background: var(--ink);
  color: var(--ink-inverse);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.tabs {
  display: flex;
  gap: 2px;
}
.tabs a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--r-full);
  color: var(--ink-secondary);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.tabs a:hover { background: var(--well-soft); color: var(--ink); }
/* The active tab is the orange pill (DESIGN §9.10). */
.tabs a[aria-current="page"] {
  background: var(--accent);
  color: var(--ink-inverse);
  font-weight: 700;
}

@media (max-width: 600px) {
  /* Two rows of header would cover a fifth of a phone screen, so it scrolls away. */
  .site-header { position: static; background: none; }
  .bar {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 6px;
    border-radius: var(--r-xl);
  }
  .brand { padding: 0 6px; }
  .tabs a { flex: 1; padding: 0 6px; font-size: 13px; }
}

/* ---- 4. Type (DESIGN §3.2) ------------------------------------------------ */
h1, h2, h3 { margin: 0; color: var(--ink); }

.display { font-size: 34px; line-height: 40px; font-weight: 800; letter-spacing: -0.5px; }
.title-lg, .page-head h1 { font-size: 28px; line-height: 34px; font-weight: 800; letter-spacing: -0.3px; }
.title-md { font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: -0.2px; }
.title-sm { font-size: 18px; line-height: 24px; font-weight: 700; }

/* Uppercase is for labels only (DESIGN §3.3). */
.label {
  margin: 0;
  font-size: 12px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.label-hist { color: var(--hist-ink); }

/* Story voice: things that happened to you are serif (DESIGN §1.2). */
.story-lead {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 17px;
  line-height: 28px;
  color: var(--ink-secondary);
}
.footnote {
  margin: 24px 0 0;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 300;
  font-size: 13px;
  line-height: 20px;
  color: var(--ink-secondary);
}

@media (min-width: 720px) {
  .display { font-size: 48px; line-height: 54px; letter-spacing: -1px; }
  .page-head h1 { font-size: 34px; line-height: 40px; letter-spacing: -0.5px; }
}

/* ---- 5. Components -------------------------------------------------------- */

/* Card (DESIGN §9.6): white paper on cream, one subject per card. */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-card);
  padding: 20px;
}
.well {
  background: var(--well-soft);
  border-radius: var(--r-lg);
  padding: 16px;
}
.section-label { margin: 32px 4px 8px; }

/* Buttons (DESIGN §9.1, §9.2) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  padding: 0 28px;
  border: 0;
  border-radius: var(--r-full);
  font: 800 17px/22px var(--sans);
  text-decoration: none;
  cursor: pointer;
  transition: transform 100ms ease-out, box-shadow 100ms ease-out;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--ink-inverse); box-shadow: var(--shadow-cta); }
.btn-primary:hover { background: var(--accent-pressed); }
.btn-dark { background: var(--ink); color: var(--ink-inverse); }
.btn-block { display: flex; width: 100%; }

/* Chips (DESIGN §9.3) */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  background: var(--well);
  color: var(--ink-secondary);
  font-size: 10px;
  line-height: 14px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  white-space: nowrap;
}
.chip-hist { background: transparent; border: 1px solid var(--hist-border); color: var(--hist-ink); }
.chip-gain { background: var(--gain-tint); color: var(--gain-ink); }

/* Icon plate: emoji on a tinted rounded square (DESIGN §8 tier 1) */
.plate {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--r-md);
  background: var(--tint-neutral);
  font-size: 24px;
  line-height: 1;
}
.plate-lg { width: 64px; height: 64px; border-radius: 18px; font-size: 32px; }
.plate-hist { background: linear-gradient(135deg, var(--hist-from), var(--hist-to)); }
.tint-peach { background: var(--tint-peach); }
.tint-sand { background: var(--tint-sand); }
.tint-mint { background: var(--tint-mint); }
.tint-sky { background: var(--tint-sky); }
.tint-lemon { background: var(--tint-lemon); }
.tint-neutral { background: var(--tint-neutral); }

/* Grouped list (DESIGN §9.7): one card, rows split by hairlines. */
.list {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.list > li + li { border-top: 1px solid var(--border); }
.row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 14px 16px;
  color: var(--ink);
  text-decoration: none;
}
a.row:hover, summary.row:hover { background: var(--well-soft); }
.row-body { flex: 1; min-width: 0; }
.row-title { display: block; font-size: 16px; line-height: 22px; font-weight: 600; }
.row-sub { display: block; margin-top: 2px; font-size: 13px; line-height: 18px; color: var(--ink-secondary); }
.row-emoji { flex: none; width: 24px; font-size: 20px; line-height: 22px; text-align: center; align-self: flex-start; }
.chev { flex: none; color: var(--ink-muted); font-size: 22px; line-height: 1; }

/* FAQ: rows that open in place. On the web an answer is short enough to
   expand inline; the app's "groups are sub-screens" rule is about navigation. */
.faq summary { list-style: none; cursor: pointer; }
.faq summary::-webkit-details-marker { display: none; }
.faq details[open] .chev { transform: rotate(90deg); }
.faq .chev { transition: transform 200ms ease-out; }
.faq .answer { padding: 0 16px 16px 54px; color: var(--ink-secondary); }
.faq .answer p { margin: 0 0 10px; }
.faq .answer p:last-child { margin-bottom: 0; }
.faq .answer strong { color: var(--ink); font-weight: 700; }

/* Timeline feed (DESIGN §9.9): serif entries with round bullets. */
.feed { margin: 0; padding: 0; list-style: none; }
.feed .marker { margin: 20px 0 8px; }
.feed .marker:first-child { margin-top: 0; }
.feed .entry {
  position: relative;
  margin: 0 0 12px;
  padding-left: 20px;
  font-family: var(--serif);
  font-size: 15px;
  line-height: 24px;
  color: var(--ink);
}
.feed .entry::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 9px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-muted);
}
.feed .entry-hist::before { background: var(--hist-border); }
.feed .entry-hist { color: var(--hist-ink); }

/* ---- 6. Pages ------------------------------------------------------------- */

/* Hero (DESIGN §9.20): a soft wash with a white plate in the middle. */
.hero {
  margin: 20px 0 0;
  padding: 40px 20px 32px;
  border-radius: var(--r-2xl);
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0) 60%),
    linear-gradient(160deg, var(--tint-peach), var(--tint-sand) 55%, var(--canvas));
  box-shadow: var(--shadow-raised);
  text-align: center;
}
.hero-plate {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  margin: 0 auto 20px;
  border-radius: var(--r-2xl);
  background: var(--card);
  box-shadow: var(--shadow-raised);
  font-size: 48px;
  line-height: 1;
}
.hero .label { margin-bottom: 8px; }
.hero .story-lead { max-width: 30em; margin: 12px auto 0; }
.hero-quiet { background: none; box-shadow: none; padding: 48px 4px 8px; text-align: left; }
.hero-quiet .story-lead { margin-left: 0; }

/* Era cards (DESIGN §9.19) */
.eras {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.era {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.era .title-sm { margin: 0; }
.era-years { display: block; margin-top: 2px; font-size: 13px; line-height: 18px; color: var(--ink-secondary); font-variant-numeric: tabular-nums; }
.era-desc { margin: 8px 0 10px; font-size: 13px; line-height: 18px; color: var(--ink-secondary); }
@media (min-width: 720px) {
  .eras { grid-template-columns: repeat(5, 1fr); }
  .era { flex-direction: column; padding: 16px; }
  .era > div { flex: 1; display: flex; flex-direction: column; align-items: flex-start; }
  .era-desc { flex: 1; }
  .era .title-sm { font-size: 16px; line-height: 22px; }
}

/* "How it plays" beside "A life, abridged" on wide screens */
@media (min-width: 860px) {
  .landing-split { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; align-items: start; }
}

/* Legal and support pages */
.page { padding-bottom: 48px; }
.page-head { padding: 40px 4px 20px; }
.page-head .label { margin-bottom: 8px; }
.page-head .meta { margin: 8px 0 0; color: var(--ink-secondary); font-size: 13px; line-height: 18px; }

/* A well is for inside a card (DESIGN §6); on the canvas the summary is a
   card with the quote bar from DESIGN §9.18. */
.summary {
  margin: 0;
  padding: 16px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}
.summary p { margin: 0; color: var(--ink-secondary); }
.summary strong { color: var(--ink); }

.toc { margin-top: 12px; }
.toc .label { margin-bottom: 8px; }
.toc ol { margin: 0; padding-left: 22px; columns: 2 220px; column-gap: 24px; }
.toc li { margin: 0; padding: 4px 0; break-inside: avoid; font-size: 14px; line-height: 20px; font-weight: 600; }
.toc li::marker { color: var(--ink-muted); font-size: 12px; }
.toc a { text-decoration-color: var(--border-strong); }
.toc a:hover { text-decoration-color: var(--accent); }

/* Long-form text sits on one sheet of paper. */
.doc { margin-top: 12px; padding: 8px 20px 20px; }
@media (min-width: 720px) { .doc { padding: 12px 36px 32px; } }
.doc section + section { border-top: 1px solid var(--border); }
.doc h2 { padding-top: 24px; margin-bottom: 8px; font-size: 18px; line-height: 24px; font-weight: 700; }
.doc h3 { margin: 20px 0 6px; font-size: 16px; line-height: 22px; font-weight: 700; }
.doc p, .doc li { color: var(--ink-secondary); }
.doc p { margin: 0 0 12px; }
.doc strong { color: var(--ink); font-weight: 700; }
.doc ul { margin: 0 0 12px; padding-left: 20px; }
.doc li { margin: 6px 0; padding-left: 4px; }
.doc li::marker { color: var(--accent); }

.table-wrap { overflow-x: auto; margin: 4px 0 16px; border: 1px solid var(--border); border-radius: var(--r-lg); }
.doc table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; }
.doc th, .doc td { padding: 12px 14px; text-align: left; vertical-align: top; }
.doc th { background: var(--well-soft); color: var(--ink); font-weight: 700; }
.doc td { color: var(--ink-secondary); border-top: 1px solid var(--border); }

.contact .title-sm { margin: 0 0 4px; }
.contact p { margin: 0 0 16px; color: var(--ink-secondary); }
.contact .contact-hint { margin: 16px 0 0; font-size: 13px; line-height: 18px; }
.contact ul { margin: 6px 0 0; font-size: 13px; line-height: 20px; padding-left: 20px; color: var(--ink-secondary); }
.contact li { margin: 4px 0; }
.contact li::marker { color: var(--accent); }

/* 404 */
.notfound { padding: 72px 16px; text-align: center; }
.notfound .story-lead { margin: 12px auto 28px; }

/* ---- 7. Footer ------------------------------------------------------------ */
.site-footer { padding: 24px 0 32px; }
.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 20px;
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
}
.footer-links a { color: var(--ink-secondary); text-decoration-color: var(--border-strong); }
.footer-links a:hover { color: var(--ink); text-decoration-color: var(--accent); }
.copyright { margin: 12px 0 0; text-align: center; font-size: 12px; color: var(--ink-secondary); }
.site-footer .footnote { margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
