/* Shared components for the app screens. Reads tokens.css only.
   Round 2 look: "The Reading Room" (decisions M9). The landing page (index.html)
   carries its own styles so it also works when opened as a single file. */

@font-face { font-family: "Manrope"; font-style: normal; font-display: swap; font-weight: 200 800;
  src: url(../fonts/manrope-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Manrope"; font-style: normal; font-display: swap; font-weight: 200 800;
  src: url(../fonts/manrope-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--step-0) / var(--leading) var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; min-width: 0; }
img, svg { max-width: 100%; display: block; }
em, i { font-style: normal; }
h1, h2, h3 { font-family: var(--font); font-weight: 600; margin: 0 0 var(--space-3); text-wrap: balance; }
h1 { font-size: var(--step-4); line-height: 48px; letter-spacing: -0.025em; }   /* Heading 2 */
h2 { font-size: var(--step-2); line-height: 36px; letter-spacing: -0.015em; }   /* Heading 4 */
h3 { font-size: var(--step-1); line-height: 28px; }                             /* Heading 6 */
@media (max-width: 40rem) { h1 { font-size: var(--step-3); line-height: 40px; } }
p { margin: 0 0 var(--space-4); max-width: var(--measure); text-wrap: pretty; }
li, dd { text-wrap: pretty; }
a { color: inherit; text-underline-offset: 0.2em; }
small, .muted { color: var(--text-muted); }
small { font-size: var(--step--1); line-height: 20px; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--space-6) 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.skip { position: absolute; left: -999px; top: 0; background: var(--brass); color: var(--brass-text); padding: var(--space-2) var(--space-3); border-radius: var(--radius); z-index: 60; }
.skip:focus { left: var(--space-4); top: var(--space-4); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* layout */
.container { width: 100%; max-width: var(--page); margin-inline: auto; padding-inline: var(--gutter); }
.narrow { max-width: 40rem; }
.section { padding-block: var(--space-7); }
@media (min-width: 48rem) { .section { padding-block: 64px; } }
.section + .section { border-top: 1px solid var(--line); }
.section--tint { background: var(--bg-subtle); }
.stack > * + * { margin-top: var(--space-4); }
.row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.row--between { justify-content: space-between; }
.grid { display: grid; gap: var(--space-5); }
@media (min-width: 48rem) {
  .grid--2 { grid-template-columns: repeat(2, 1fr); }
  .grid--3 { grid-template-columns: repeat(3, 1fr); }
}
.eyebrow { font-size: 12px; line-height: 16px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.18em; color: var(--accent); margin-bottom: var(--space-2); }
.lede { font-size: 18px; line-height: 28px; color: var(--text-muted); }

/* header: a compact bar that floats off the top edge (skill B7) */
.site-header { position: sticky; top: 0; z-index: 30; padding: var(--space-4) var(--gutter) 0; }
.site-header .container {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-4);
  max-width: calc(var(--page) - 2 * var(--gutter)); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  background: var(--header); -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
@media (max-width: 40rem) { .site-header { position: static; } }
.brand { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 600; font-size: 18px; line-height: 28px; text-decoration: none; letter-spacing: -0.01em; }
.brand-mark { height: 22px; width: auto; flex: none; }
.nav { display: flex; flex-wrap: wrap; gap: var(--space-1); align-items: center; font-size: var(--step--1); line-height: 20px; font-weight: 600; }
.nav a { text-decoration: none; padding: var(--space-2) var(--space-3); border-radius: var(--radius-full); color: var(--text-muted); transition: background-color .3s var(--ease), color .3s var(--ease); }
.nav a:hover { background: var(--bg-subtle); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent); color: var(--accent-text); }
.nav a.balance { border: 1px solid color-mix(in srgb, var(--brass) 70%, transparent); background: color-mix(in srgb, var(--brass) 22%, transparent); color: var(--text); margin-left: var(--space-1); }
.nav a.balance:hover { background: color-mix(in srgb, var(--brass) 38%, transparent); }

/* footer */
.site-footer { background: var(--footer); color: var(--footer-text); padding-block: var(--space-5); font-size: var(--step--1); line-height: 20px; margin-top: var(--space-7); }
.site-footer .container { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-5); justify-content: space-between; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }

/* controls (skill B2, B7, B9) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 40px; padding: var(--space-2) var(--space-3);
  border: 1px solid var(--accent); border-radius: var(--radius);
  background: var(--accent); color: var(--accent-text);
  font: inherit; font-size: var(--step-0); line-height: 24px; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background-color .3s var(--ease), border-color .3s var(--ease), transform .5s var(--ease);
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); transform: translateY(-1px); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn--brass { background: var(--brass); border-color: var(--brass); color: var(--brass-text); }
.btn--brass:hover { background: var(--brass-hover); border-color: var(--brass-hover); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn--ghost:hover { background: var(--bg-subtle); border-color: var(--line-strong); }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; color: inherit; }

.field { display: grid; gap: var(--space-2); margin-bottom: var(--space-4); }
.field label { font-weight: 600; font-size: var(--step--1); line-height: 20px; }
.field input, .field select {
  min-height: 44px; padding: var(--space-2) var(--space-3); font: inherit;
  border: 2px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); width: 100%;
  transition: border-color .3s var(--ease);
}
.field input:hover, .field select:hover { border-color: var(--text-muted); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field .hint, .card > .hint { color: var(--text-muted); font-size: var(--step--1); line-height: 20px; }
/* sign in: the methods offered on the hosted WorkOS page */
.methods { list-style: none; padding: 0; margin: 0 0 var(--space-5); display: grid; gap: var(--space-2); }
.methods li { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-2) var(--space-3); background: var(--bg); display: flex; align-items: center; gap: var(--space-3); }
.methods .method-logo { width: 20px; height: 20px; flex: none; }
.field .error { color: var(--danger); font-size: var(--step--1); line-height: 20px; font-weight: 600; }

/* legal pages */
.legal h2 { font-size: var(--step-1); line-height: 28px; margin-top: var(--space-6); }
.legal ul { padding-left: var(--space-5); margin: 0 0 var(--space-4); max-width: var(--measure); }
.legal li { margin-bottom: var(--space-2); }

/* surfaces */
.card { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-5); background: var(--surface); box-shadow: var(--shadow); }
.card--muted { background: var(--bg-subtle); box-shadow: none; }
.card h2, .card h3 { margin-top: 0; }
/* notices: border all the way round (skill B4), colour comes from the tint */
.notice { border: 1px solid var(--line-strong); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); background: var(--bg-subtle); }
.notice p:last-child { margin-bottom: 0; }
.notice strong:first-child { display: block; }
.notice--warn { border-color: var(--warn); background: var(--warn-soft); }
.notice--danger { border-color: var(--danger); background: var(--danger-soft); }
.notice--ok { border-color: var(--ok); background: var(--accent-soft); }
.badge { display: inline-block; border: 1px solid var(--line-strong); border-radius: var(--radius-full); padding: 0 var(--space-2); font-size: 12px; line-height: 20px; font-weight: 600; white-space: nowrap; background: var(--surface); }
.badge--solid { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* placeholders and skeletons (skill B9: skeletons, not spinners) */
.ph {
  display: grid; place-items: center; text-align: center; min-height: 10rem;
  border: 2px dashed var(--line-strong); border-radius: var(--radius); background: var(--bg-subtle);
  color: var(--text-muted); padding: var(--space-4); font-size: var(--step--1); line-height: 20px;
}
.ph--tall { min-height: 22rem; }
.lines { display: grid; gap: var(--space-2); }
.lines i { display: block; height: 8px; background: var(--bg-inset); border-radius: var(--radius-full); }
.lines i:nth-child(3n) { width: 82%; }
.lines i:nth-child(5n) { width: 64%; }
.lines b { display: block; height: 16px; width: 55%; background: var(--line); border-radius: var(--radius-full); margin-bottom: var(--space-2); }

/* upload */
.dropzone {
  display: grid; gap: var(--space-3); justify-items: center; text-align: center;
  border: 2px dashed var(--line-strong); border-radius: var(--radius-lg); background: var(--surface);
  padding: var(--space-7) var(--space-5);
  transition: border-color .3s var(--ease), background-color .3s var(--ease);
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-2) var(--space-5); margin: 0; }
.facts dt { color: var(--text-muted); }
.facts dd { margin: 0; font-weight: 600; }
@media (max-width: 40rem) {
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dt { font-size: var(--step--1); line-height: 20px; }
  .facts dd { margin-bottom: var(--space-3); }
}
.total { font-size: var(--step-2); line-height: 36px; font-weight: 600; letter-spacing: -0.015em; color: var(--accent); }

/* side by side */
.compare { display: grid; gap: var(--space-4); }
@media (min-width: 48rem) { .compare { grid-template-columns: 1fr 1fr; } .compare--3 { grid-template-columns: repeat(3, 1fr); } }
.compare figure { margin: 0; display: grid; gap: var(--space-2); align-content: start; }
.compare figcaption { font-weight: 600; }
.pager { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.page-image { width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }


/* packs */
.packs { display: grid; gap: var(--space-4); }
@media (min-width: 48rem) { .packs { grid-template-columns: repeat(3, 1fr); } }
.pack { display: grid; gap: var(--space-2); align-content: start; }
.pack--best { border: 2px solid var(--accent); background: var(--accent-soft); }
.pack .price { font-size: var(--step-3); line-height: 40px; font-weight: 600; letter-spacing: -0.025em; }
.pack ul { margin: 0; padding-left: var(--space-5); }

/* progress */
.stages { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); counter-reset: s; }
.stages li { display: flex; gap: var(--space-3); align-items: center; padding: var(--space-2) var(--space-3); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.stages li::before { counter-increment: s; content: counter(s); display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line-strong); font-size: 12px; font-weight: 600; flex: none; }
.stages li[aria-current="step"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 600; }
.stages li[data-state="done"]::before { content: "\2713"; background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.stages li[data-state="failed"]::before { content: "!"; border-color: var(--danger); color: var(--danger); }
.stages .when { margin-left: auto; color: var(--text-muted); font-weight: 400; font-size: var(--step--1); }
progress { width: 100%; height: 12px; accent-color: var(--accent); }

/* tables */
.table-wrap { overflow-x: auto; position: relative; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); } /* relative: keeps visually-hidden cells from escaping the scroller */
table { border-collapse: collapse; width: 100%; font-size: var(--step--1); line-height: 20px; }
caption { text-align: left; padding: var(--space-3) var(--space-4); color: var(--text-muted); }
th, td { text-align: left; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
thead th { font-size: 12px; line-height: 16px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-muted); }
th { font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.link-button { background: none; border: 0; padding: 0; margin-left: var(--space-2); font: inherit; color: var(--text-muted); text-decoration: underline; text-underline-offset: 0.2em; cursor: pointer; }
.link-button:hover { color: inherit; }

/* faq */
details { border-bottom: 1px solid var(--line); padding-block: var(--space-3); }
summary { cursor: pointer; font-weight: 600; }
details p { margin-top: var(--space-3); }

/* steps */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-5); counter-reset: n; }
@media (min-width: 48rem) { .steps { grid-template-columns: repeat(3, 1fr); } }
.steps li::before { counter-increment: n; content: counter(n); display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--leather); color: var(--brass); font-weight: 600; margin-bottom: var(--space-3); }

/* error pages */
.error-page { text-align: center; padding-block: var(--space-7); }
.error-page p { margin-inline: auto; }
.code { font-size: 60px; line-height: 60px; font-weight: 600; letter-spacing: -0.025em; color: var(--accent); margin-bottom: var(--space-2); }

/* mockup index only */
.screen-list { display: grid; gap: var(--space-3); padding: 0; list-style: none; }
.screen-list li { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); background: var(--surface); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } .btn:hover, .btn:active { transform: none; } }

/* reader text (preview screen) */
.verdict { margin: 0; padding-left: var(--space-5); font-size: var(--step--1); color: var(--text-muted); }
.verdict li + li { margin-top: var(--space-1); }
.compare .is-ours .reader { border: 2px solid var(--accent); background: var(--accent-soft); }
.reader { font-size: var(--step--1); line-height: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4); min-height: 21rem; }
.reader p { margin: 0 0 var(--space-1); padding-left: 1.1em; text-indent: -1.1em; }
.reader--pending { display: grid; place-items: center; text-align: center; color: var(--text-muted); border-style: dashed; }
/* the converted page in the preview: book text, not the mockup's placeholder lines */
.reader.reader--book { font-size: var(--step-0); line-height: 1.6; overflow-wrap: anywhere; }
.reader.reader--book p { padding-left: 0; text-indent: 0; margin: 0 0 var(--space-3); }
.reader.reader--book h2, .reader.reader--book h3, .reader.reader--book h4 { font-size: var(--step-1); line-height: 1.3; margin: var(--space-4) 0 var(--space-2); }
.reader.reader--book img { max-width: 100%; height: auto; }
.reader.reader--book figure { margin: var(--space-3) 0; }
.reader.reader--book .footnote { font-size: var(--step--1); color: var(--text-muted); }
.reader.reader--book .table { overflow-x: auto; }
.source { margin: var(--space-6) 0 0; display: grid; gap: var(--space-2); justify-items: start; }
.source img { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; height: auto; }
.source figcaption { color: var(--text-muted); font-size: var(--step--1); }

/* ---------- Round 3: states ---------- */
/* skeletons pulse with opacity only (skill B7, B9) */
.skeleton { display: grid; gap: var(--space-2); }
.skeleton i { display: block; height: 12px; border-radius: var(--radius-full); background: var(--bg-inset); animation: pulse 1.6s var(--ease) infinite alternate; }
.skeleton i.w60 { width: 60%; } .skeleton i.w40 { width: 40%; } .skeleton i.w80 { width: 80%; }
.skeleton i.tall { height: 36px; width: 30%; }
@keyframes pulse { from { opacity: 1; } to { opacity: .45; } }

/* htmx request feedback: the triggering button dims and shows its busy label */
.btn .busy { display: none; }
.htmx-request .btn .idle, .btn.htmx-request .idle { display: none; }
.htmx-request .btn .busy, .btn.htmx-request .busy { display: inline; }
.htmx-request.btn, .htmx-request .btn[type="submit"] { opacity: .7; pointer-events: none; }
.htmx-added { opacity: 0; }
.htmx-settling, [data-swap-fade] { transition: opacity .3s var(--ease); }

.empty { text-align: center; padding: var(--space-7) var(--space-5); border: 2px dashed var(--line-strong); border-radius: var(--radius-lg); background: var(--surface); }
.empty .icon { width: 48px; height: 48px; margin: 0 auto var(--space-4); border-radius: var(--radius-lg); display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.empty .icon svg { width: 24px; height: 24px; fill: currentColor; }
.empty p { margin-inline: auto; }
.inline-error { color: var(--danger); font-size: var(--step--1); line-height: 20px; font-weight: 600; margin: var(--space-2) 0 0; }

/* review sheet: mockup only, removed in Phase 4 */
.states-sheet { margin-top: var(--space-8); padding-top: var(--space-7); border-top: 2px dashed var(--line-strong); }
.states-sheet > .container > p { color: var(--text-muted); }
.states { display: grid; gap: var(--space-6); margin-top: var(--space-5); }
@media (min-width: 64rem) { .states--2 { grid-template-columns: 1fr 1fr; align-items: start; } }
.state { margin: 0; display: grid; gap: var(--space-3); align-content: start; }
.state > figcaption { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); font-size: var(--step--1); line-height: 20px; color: var(--text-muted); }
.state-chip { display: inline-block; padding: 0 var(--space-2); border-radius: var(--radius-full); background: var(--leather); color: var(--brass); font-size: 12px; line-height: 20px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
@media (prefers-color-scheme: dark) { .state-chip { background: var(--bg-inset); } }
.route { font-family: var(--font-mono); font-size: 12px; line-height: 16px; background: var(--bg-subtle); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 var(--space-2); color: var(--text); }
/* htmx indicators take no space until a request runs */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: block; }
/* interaction map */
.map td code { white-space: normal; overflow-wrap: anywhere; }
.map td, .map th { white-space: normal; }
