/*
  The Bindle site's one stylesheet. Tokens mirror the app's
  (apple/Shared/Design/ColorTokens.swift, apple/Shared/Views/Theme.swift, and
  the reader's apple/Shared/Reader/Resources/reader.css), so the site reads
  like the app's serif "Editorial" look: warm paper, New York (ui-serif) on
  Apple devices with Libron as the fallback, small-caps bylines, italic
  section heads over a rule, and the brick accent. SPEC 15, Marketing site
  decisions.
*/

@font-face { font-family: "Libron"; src: url("../fonts/Libron-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Libron"; src: url("../fonts/Libron-Italic.ttf") format("truetype"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Libron"; src: url("../fonts/Libron-Bold.ttf") format("truetype"); font-weight: 600 700; font-display: swap; }

:root {
  color-scheme: light dark;

  /* Theme (ColorTokens.swift), light. */
  --ground: #FBF8F3;        /* listGround */
  --surface: #FFFFFF;
  --ink: #1C1B1A;           /* reader fg */
  --quiet: #55504B;         /* quietText */
  --rule: #E2DBD1;          /* listRule */
  --accent: #A8473C;
  --on-accent: #FFFFFF;
  --accent-tint: rgba(168, 71, 60, 0.12);
  --control: #E6E2DE;       /* controlFill */
  --star: #C9962F;

  /* Theme.Cover: the ink book cover a picture-less card becomes. */
  --cover: #1F1B17;
  --cover-ink: #F4EEE4;
  --cover-accent: #E3907E;

  /* Theme.Radius and Theme.Spacing. */
  --r-chip: 6px;
  --r-card: 12px;
  --r-tile: 16px;
  --r-player: 28px;
  --s-xs: 4px; --s-s: 6px; --s-m: 8px; --s-l: 12px; --s-xl: 16px; --s-xxl: 20px;

  --serif: ui-serif, "New York", "Libron", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --measure: 34rem;
  --page: 72rem;
  --gutter: clamp(16px, 4vw, 40px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #141210;
    --surface: #1B1A19;
    --ink: #E8E4DF;
    --quiet: #A39C95;
    --rule: #34302B;
    --accent: #D9806F;
    --on-accent: #1A0F0B;
    --accent-tint: rgba(217, 128, 111, 0.18);
    --control: #2C2C2E;
    --star: #E0B04A;
    --cover: #27231F;
    --cover-ink: #F1ECE4;
  }
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

a { color: var(--accent); text-underline-offset: 0.15em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

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

.skip {
  position: absolute; left: var(--s-xl); top: -100px;
  background: var(--accent); color: var(--on-accent);
  padding: var(--s-m) var(--s-xl); border-radius: 999px;
  font-family: var(--sans); font-weight: 600; z-index: 10;
}
.skip:focus { top: var(--s-xl); }

.wrap { max-width: var(--page); margin: 0 auto; padding: 0 var(--gutter); }

/* Small caps, like the app's bylines and the reader's site name. */
.kicker {
  font-family: var(--sans);
  font-weight: 600;
  font-variant-caps: all-small-caps;
  font-size: 1rem;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin: 0 0 var(--s-m);
}

/* The app's section heading: italic serif over a 1 pt rule. */
.section-head {
  font-style: italic;
  font-weight: 500;
  font-size: 1.375rem;
  margin: 0 0 var(--s-xxl);
  padding-top: var(--s-l);
  border-top: 1px solid var(--ink);
}

h1, h2, h3 { font-family: var(--serif); line-height: 1.15; text-wrap: balance; }
h2 { font-size: clamp(1.75rem, 3.2vw, 2.5rem); font-weight: 600; margin: 0 0 var(--s-l); }
h3 { font-size: 1.25rem; font-weight: 600; margin: 0 0 var(--s-s); }
p { margin: 0 0 var(--s-xl); }

.lede { font-style: italic; font-size: 1.25rem; color: var(--quiet); }

/* Header. */
.site-header { border-bottom: 1px solid var(--rule); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: var(--s-xl); min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: var(--s-m); color: var(--ink); text-decoration: none; font-weight: 600; font-size: 1.25rem; }
.brand img { width: 32px; height: 32px; border-radius: 7px; }
.site-nav { display: flex; gap: var(--s-xxl); font-family: var(--sans); font-size: 0.9375rem; }
.site-nav a { color: var(--ink); text-decoration: none; padding: var(--s-m) 0; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--accent); }
@media (max-width: 560px) { .site-nav .optional { display: none; } .site-nav { gap: var(--s-xl); } }

/* Buttons: the app's Listen and Read capsules. */
.actions { display: flex; flex-wrap: wrap; gap: var(--s-l); align-items: center; margin: var(--s-xxl) 0 0; }
.pill {
  display: inline-flex; align-items: center; gap: var(--s-m);
  min-height: 48px; padding: 0 var(--s-xxl);
  border-radius: 999px;
  font-family: var(--sans); font-size: 1rem; font-weight: 600;
  text-decoration: none;
}
.pill--solid { background: var(--accent); color: var(--on-accent); }
.pill--tint { background: var(--accent-tint); color: var(--accent); }
.pill svg { width: 20px; height: 20px; flex: none; }

/* The story: one iPhone stays in place while the sections scroll past it (SPEC 15, Marketing site decisions). */
.story { padding-bottom: clamp(32px, 6vw, 72px); }
.story .wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 340px); gap: clamp(40px, 7vw, 112px); }
.story__steps { min-width: 0; }
.step { min-height: 88vh; padding: clamp(48px, 8vw, 96px) 0; box-sizing: border-box; display: flex; flex-direction: column; justify-content: center; max-width: var(--measure); border-top: 1px solid var(--rule); }
.step--hero { border-top: 0; max-width: 40rem; }
.step h1 { font-size: clamp(2.75rem, 7vw, 5.5rem); font-weight: 700; line-height: 0.98; letter-spacing: -0.015em; margin: 0 0 var(--s-xxl); }
.step h2 { font-size: clamp(2rem, 4.4vw, 3.25rem); line-height: 1.04; }
.step .lede { font-size: clamp(1.25rem, 2vw, 1.4rem); line-height: 1.4; margin-bottom: var(--s-xxl); }
.step--hero .lede { max-width: 34rem; }
.step .actions { margin: 0; }

.story__phone { position: sticky; top: 24px; align-self: start; height: calc(100vh - 48px); max-height: 900px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-xl); }
.phone { width: 100%; max-width: 320px; max-height: calc(100% - 64px); aspect-ratio: 1206 / 2622; box-sizing: border-box; border: 11px solid var(--cover); border-radius: 52px; background: var(--surface); box-shadow: 0 30px 60px rgba(0, 0, 0, 0.2); overflow: hidden; }
.phone__screens { position: relative; width: 100%; height: 100%; }
.phone .shot--layer { position: absolute; inset: 0; opacity: 0; }
.phone .shot--layer.is-active { opacity: 1; }
.phone .shot--layer .shot__screen { width: 100%; height: 100%; }
.phone__steps { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; }
.phone__steps a { width: 22px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 6px; }
.phone__steps a::before { content: ""; width: 7px; height: 7px; border-radius: 999px; background: var(--rule); }
.phone__steps a:hover::before { background: var(--quiet); }
.phone__steps a[aria-current="true"]::before { width: 18px; background: var(--accent); }
.phone__label { margin: 0; font-family: var(--sans); font-size: 0.875rem; font-weight: 600; font-variant-caps: all-small-caps; letter-spacing: 0.04em; color: var(--accent); }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Each section's own screenshot, shown instead of the phone on narrow screens. */
.shot--inline { display: none; }
@media (max-width: 900px) {
  .story .wrap { grid-template-columns: minmax(0, 1fr); }
  .story__phone { display: none; }
  .step { min-height: 0; max-width: none; }
  .step .shot--inline { display: block; margin-top: clamp(32px, 6vw, 48px); }
}
@media (prefers-reduced-motion: no-preference) {
  .phone .shot--layer { transition: opacity 280ms ease; }
  .phone__steps a::before { transition: width 200ms ease, background-color 200ms ease; }
}

/* Device frames: drawn, not Apple's bezel artwork. */
.shot { margin: 0; position: relative; width: 100%; }
.shot__screen { position: relative; overflow: hidden; background: var(--surface); }
.shot__screen img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.shot--iphone { max-width: 300px; }
.shot--iphone .shot__screen { aspect-ratio: 1206 / 2622; border-radius: 13% / 6%; border: 10px solid var(--cover); box-shadow: 0 24px 48px rgba(0, 0, 0, 0.18); }
.shot--ipad .shot__screen { aspect-ratio: 2064 / 2752; border-radius: 6% / 4.5%; border: 12px solid var(--cover); box-shadow: 0 24px 48px rgba(0, 0, 0, 0.18); }
.shot--mac .shot__screen { aspect-ratio: 16 / 10; border-radius: var(--r-card); border: 1px solid var(--rule); box-shadow: 0 30px 60px rgba(0, 0, 0, 0.2); }
/* A small panel (Quick Add), shown at its own size and shape. */
.shot--panel { max-width: 440px; }
.shot--panel .shot__screen { aspect-ratio: 440 / 284; }

/* A screenshot that hasn't been captured yet (site.js marks it). */
.shot__placeholder { display: none; }
.shot--missing .shot__screen picture { display: none; }
.shot--missing .shot__placeholder {
  position: absolute; inset: var(--s-l);
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: var(--s-m);
  text-align: center; padding: var(--s-xl);
  border: 2px dashed var(--rule); border-radius: var(--r-card);
  color: var(--quiet); font-family: var(--sans); font-size: 0.875rem; line-height: 1.4;
}
.shot__placeholder code { font-size: 0.8125rem; color: var(--accent); background: var(--accent-tint); padding: 2px 6px; border-radius: var(--r-chip); }

/* iPad and the Mac. */
.band__lede { margin-bottom: clamp(32px, 5vw, 56px); }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: clamp(24px, 5vw, 64px); align-items: center; margin-bottom: clamp(48px, 8vw, 96px); }
.pair__shots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(16px, 3vw, 40px); }
.pair__text { display: flex; flex-direction: column; gap: var(--s-l); }
.pair__text p { margin: 0 0 var(--s-l); }
.shot--wide { margin-bottom: clamp(32px, 5vw, 56px); }
.mac-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(24px, 5vw, 64px); }
.mac-grid__item { display: flex; flex-direction: column; gap: var(--s-l); }
.mac-grid__item p { margin: 0 0 var(--s-l); }
@media (max-width: 760px) { .pair, .mac-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 420px) { .pair__shots { grid-template-columns: minmax(0, 1fr); } }

/* Why: the principles as ink book covers. */
.covers { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: var(--s-xl); }
.cover-card {
  background: var(--cover); color: var(--cover-ink);
  border-radius: var(--r-card);
  padding: var(--s-xxl);
  min-height: 200px;
  display: flex; flex-direction: column; gap: var(--s-l);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}
.cover-card h3 { font-size: 1.375rem; margin: 0; }
.cover-card h3::after { content: ""; display: block; width: 32px; height: 2px; background: var(--cover-accent); margin-top: var(--s-l); }
.cover-card p { margin: 0; font-size: 0.9375rem; line-height: 1.45; opacity: 0.88; }

/* Hairline-ruled lists, like the app's rows. */
.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.rows li { padding: var(--s-l) 0; border-bottom: 1px solid var(--rule); font-size: 1rem; line-height: 1.45; }
.rows li strong { font-weight: 600; }

/* Private by design, and switching. */
.band { padding: clamp(48px, 8vw, 96px) 0; border-top: 1px solid var(--rule); }
.band--end h2 { font-size: clamp(2rem, 4.4vw, 3.25rem); }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: clamp(32px, 5vw, 64px); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s-m); list-style: none; padding: 0; margin: var(--s-xl) 0; }
.chips li { background: var(--control); border-radius: var(--r-chip); padding: var(--s-xs) var(--s-l); font-family: var(--sans); font-size: 0.9375rem; }

/* Footer. */
.site-footer { border-top: 1px solid var(--ink); margin-top: clamp(32px, 6vw, 72px); padding: var(--s-xxl) 0 48px; font-family: var(--sans); font-size: 0.875rem; color: var(--quiet); }
.site-footer .wrap { display: grid; gap: var(--s-l); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: var(--s-xxl); }
.site-footer a { color: var(--ink); }
.site-footer p { margin: 0; }

/* Long reading: the help book and the privacy policy, set like the reader. */
.doc { padding: clamp(32px, 6vw, 72px) 0; }
.doc .wrap { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 40rem); gap: clamp(32px, 5vw, 72px); justify-content: center; }
.doc--single .wrap { grid-template-columns: minmax(0, 40rem); }
@media (max-width: 900px) { .doc .wrap { grid-template-columns: minmax(0, 40rem); } .toc { order: 2; } }
.prose { min-width: 0; }
.prose h1 { font-size: clamp(2.25rem, 5vw, 3rem); font-weight: 700; margin: 0 0 var(--s-xxl); }
.prose h2 { font-size: 1.625rem; margin: 2.2em 0 0.6em; }
.prose h3 { font-size: 1.25rem; margin: 1.8em 0 0.5em; }
.prose > h1 + p::first-letter { float: left; font-size: 4.3em; line-height: 0.82; font-weight: 600; color: var(--accent); padding: 0.06em 0.08em 0 0; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 var(--s-xl); }
.prose li { margin: 0 0 var(--s-s); }
.prose code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.875em; background: var(--control); padding: 1px 5px; border-radius: 4px; }
.prose pre { background: var(--control); padding: var(--s-xl); border-radius: var(--r-card); overflow-x: auto; font-size: 0.875rem; }
.prose pre code { background: none; padding: 0; }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 var(--s-xxl); font-size: 0.9375rem; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; vertical-align: top; padding: var(--s-m) var(--s-l) var(--s-m) 0; border-bottom: 1px solid var(--rule); }
.prose th { font-family: var(--sans); font-weight: 600; font-size: 0.875rem; }
.prose blockquote { margin: 0 0 var(--s-xl); padding: var(--s-l) var(--s-xl); border-left: 3px solid var(--rule); color: var(--quiet); }
.prose .try { margin: 0 0 var(--s-xxl); padding: var(--s-xl) var(--s-xxl); background: var(--accent-tint); border-radius: var(--r-card); }
.prose .try > :last-child { margin-bottom: 0; }
.prose .try__label { font-family: var(--sans); font-weight: 600; font-variant-caps: all-small-caps; letter-spacing: 0.04em; color: var(--accent); margin-bottom: var(--s-s); }
.prose sup a { text-decoration: none; }
.prose aside[role="doc-footnote"] { font-size: 0.9375rem; color: var(--quiet); border-top: 1px solid var(--rule); padding-top: var(--s-m); }
.prose .meta { font-style: italic; color: var(--quiet); }

.toc { font-family: var(--sans); font-size: 0.9375rem; }
.toc h2 { font-family: var(--serif); font-style: italic; font-weight: 500; font-size: 1.125rem; border-top: 1px solid var(--ink); padding-top: var(--s-m); margin: 0 0 var(--s-l); }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li { border-bottom: 1px solid var(--rule); }
.toc a { display: block; padding: var(--s-m) 0; color: var(--ink); text-decoration: none; }
.toc a:hover, .toc a[aria-current="page"] { color: var(--accent); }
.toc a[aria-current="page"] { font-weight: 600; }
@media (min-width: 901px) { .toc nav { position: sticky; top: var(--s-xxl); max-height: calc(100vh - 40px); overflow-y: auto; } }

.pager { display: flex; justify-content: space-between; gap: var(--s-xl); margin-top: 48px; padding-top: var(--s-xl); border-top: 1px solid var(--rule); font-family: var(--sans); font-size: 0.9375rem; }
.pager a { text-decoration: none; }
.pager .next { margin-left: auto; text-align: right; }
.pager small { display: block; color: var(--quiet); }

.help-cover { max-width: 240px; border-radius: 4px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); margin: 0 0 var(--s-xxl); }
