/* Inner pages, screenshots, tables, references. Tokens come from styles.css. */
:root { --n1: #fff4b8; --n2: #ffd7a6; --n3: #f7b4b4; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --n1: #4a4214; --n2: #573516; --n3: #5c2125; } }
:root[data-theme="dark"] { --n1: #4a4214; --n2: #573516; --n3: #5c2125; }

/* ---------- Page header ---------- */
.page-hero { padding-block: 56px 40px; border-bottom: 1px solid var(--line); background: var(--surface); }
.page-hero .wrap { display: grid; gap: 14px; }
.crumbs { font-size: var(--fs-xs); color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--blue); }
.page-hero h1 { font-size: var(--fs-2xl); max-width: 24ch; }
.page-hero .lead { font-size: 1.125rem; }
.hero-facts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.fact { display: inline-flex; gap: 6px; align-items: baseline; padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: var(--fs-xs); color: var(--muted); background: var(--paper); }
.fact b { color: var(--ink); font-size: var(--fs-sm); }

/* ---------- Document layout with table of contents ---------- */
.doc { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 56px; padding-block: 56px 88px; align-items: start; }
.toc { position: sticky; top: calc(env(safe-area-inset-top, 0px) + var(--header-h) + 24px); display: grid; gap: 2px; font-size: var(--fs-sm); }
.toc strong { font-size: var(--fs-xs); color: var(--muted); margin-bottom: 6px; }
.toc a { color: var(--muted); text-decoration: none; padding: 5px 12px; border-inline-start: 2px solid var(--line); line-height: 1.6; }
.toc a:hover { color: var(--blue); }
.toc a.active { color: var(--blue); border-inline-start-color: var(--blue); font-weight: 700; }
@media (max-width: 960px) {
  .doc { grid-template-columns: minmax(0, 1fr); gap: 24px; padding-block: 32px 64px; }
  .toc { position: static; display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
  .toc strong { width: 100%; margin: 0; }
  .toc a { border: 1px solid var(--line); border-radius: 999px; padding: 2px 12px; font-size: var(--fs-xs); }
}

.prose { display: grid; gap: 18px; min-width: 0; }
.prose > section { padding: 0; display: grid; gap: 18px; scroll-margin-top: calc(var(--header-h) + 24px); }
.prose > section + section { padding-top: 40px; margin-top: 24px; border-top: 1px solid var(--line); }
.prose h2 { font-size: var(--fs-xl); }
.prose h3 { font-size: var(--fs-lg); margin-top: 8px; }
.prose h4 { font-size: var(--fs-md); }
.prose p, .prose li { max-width: 72ch; }
.prose .muted { color: var(--muted); }
.prose ul, .prose ol { margin: 0; padding-inline-start: 1.4em; display: grid; gap: 8px; }
.prose li::marker { color: var(--red); }
.prose code, .prose kbd { font-family: var(--font-mono); font-size: 0.86em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; direction: ltr; unicode-bidi: isolate; }
.en { direction: ltr; unicode-bidi: isolate; }
th.en, td.en { text-align: left; }
.prose .steps { padding: 0; gap: 18px; }
.prose .steps li { max-width: none; }

/* ---------- Screenshots ---------- */
.shot { margin: 0; display: grid; gap: 10px; min-width: 0; }
.shot-btn { display: block; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); cursor: zoom-in; width: 100%; }
.shot-btn img { display: block; width: 100%; height: auto; }
.shot-btn:hover { border-color: var(--blue); }
.shot figcaption { font-size: var(--fs-sm); color: var(--muted); line-height: 1.8; max-width: 80ch; }
.shot figcaption b { color: var(--ink); }
.shot-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
@media (max-width: 760px) { .shot-pair { grid-template-columns: minmax(0, 1fr); } }
.sample-note { display: inline-flex; gap: 6px; align-items: center; font-size: var(--fs-xs); color: var(--muted); }
.sample-note::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--blue); }

.lightbox { border: 0; padding: 0; max-width: min(1500px, 96vw); width: 100%; background: transparent; color: #ffffff; }
.lightbox::backdrop { background: rgba(5, 12, 24, 0.86); }
.lightbox img { display: block; width: 100%; max-height: 84vh; object-fit: contain; border-radius: 8px; background: #ffffff; }
.lightbox p { margin-top: 10px; font-size: var(--fs-sm); text-align: center; color: #e5edf8; }
.lightbox form { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.lightbox-close { width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.14); color: #ffffff; font-size: 1.5rem; cursor: pointer; }

/* ---------- Pipeline diagram ---------- */
.pipeline { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; counter-reset: p; }
.prose .pipeline { padding: 0; }
.pipeline li { counter-increment: p; display: grid; gap: 4px; align-content: start; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; min-width: 0; max-width: none; }
.pipeline li::before { content: counter(p, persian); font-weight: 700; color: var(--blue); font-size: var(--fs-sm); }
.pipeline b { font-size: var(--fs-sm); }
.pipeline span { font-size: var(--fs-xs); color: var(--muted); line-height: 1.7; }
.pipeline .tag { font-family: var(--font-mono); font-size: 11px; color: var(--red); direction: ltr; text-align: left; }
.pipeline li.ours { border-color: var(--blue); }
.pipeline li.up { border-style: dashed; border-color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: var(--fs-xs); color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 18px; height: 12px; border-radius: 3px; border: 1px solid var(--blue); }
.legend i.up { border: 1px dashed var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); min-width: 520px; }
.data-table th, .data-table td { padding: 10px 14px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: top; line-height: 1.7; }
.data-table thead th { background: var(--surface-2); font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.data-table tbody tr:last-child td, .data-table tbody tr:last-child th { border-bottom: 0; }
.data-table .num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-note { font-size: var(--fs-xs); color: var(--muted); max-width: 80ch; }

/* NEWS2: the RCP observation chart's score bands */
.news2 { min-width: 640px; }
.news2 td { text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }
.news2 tbody th { white-space: nowrap; }
.s1 { background: var(--n1); }
.s2 { background: var(--n2); }
.s3 { background: var(--n3); }
.news2-key { display: flex; flex-wrap: wrap; gap: 12px; font-size: var(--fs-xs); color: var(--muted); }
.news2-key span { display: inline-flex; gap: 6px; align-items: center; }
.news2-key i { width: 16px; height: 12px; border: 1px solid var(--line); border-radius: 2px; }

/* ---------- Callouts and figures ---------- */
.callout { display: grid; gap: 6px; padding: 16px 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); font-size: var(--fs-sm); line-height: 1.85; max-width: 80ch; }
.callout.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.callout.warn > b:first-child { color: var(--warn); }
.callout.info { background: var(--blue-soft); border-color: color-mix(in srgb, var(--blue) 30%, transparent); }
.callout.info > b:first-child { color: var(--blue); }

.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.kv div { padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); display: grid; gap: 2px; align-content: start; }
.kv span { font-size: var(--fs-xs); color: var(--muted); }
.kv b { font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }
.kv small { font-size: var(--fs-xs); color: var(--muted); line-height: 1.6; }

/* ---------- References ---------- */
.refs { list-style: none; margin: 0; padding: 0; display: grid; counter-reset: r; }
.prose .refs { padding: 0; gap: 0; }
.refs li { counter-increment: r; display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 8px; padding: 14px 0; border-bottom: 1px solid var(--line); max-width: none; }
.refs li::before { content: "[" counter(r) "]"; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); padding-top: 3px; direction: ltr; }
.refs .cite { direction: ltr; text-align: left; font-size: var(--fs-sm); line-height: 1.7; unicode-bidi: isolate; }
.refs .use { font-size: var(--fs-xs); color: var(--muted); margin-top: 4px; }
.refs a { word-break: break-all; }

/* ---------- Module cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.mod-card { display: grid; grid-template-rows: auto 1fr; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; transition: border-color 0.15s; }
.mod-card:hover { border-color: var(--blue); }
.mod-card img { display: block; width: 100%; max-width: 100%; aspect-ratio: 16 / 9; object-fit: cover; object-position: top right; border-bottom: 1px solid var(--line); }
.mod-card .body { padding: 22px 24px 24px; display: grid; gap: 8px; align-content: start; }
.mod-card h3 { font-size: var(--fs-lg); }
.mod-card p { color: var(--muted); font-size: var(--fs-sm); }
.mod-card .more { color: var(--blue); font-weight: 700; font-size: var(--fs-sm); margin-top: 4px; }
@media (max-width: 760px) { .card-grid { grid-template-columns: minmax(0, 1fr); } }

.cta-band { background: var(--ink); color: var(--paper); padding-block: 56px; }
.cta-band .wrap { display: flex; flex-wrap: wrap; gap: 24px; align-items: center; justify-content: space-between; }
.cta-band .cta-copy { display: grid; gap: 8px; }
.cta-band h2 { font-size: var(--fs-xl); color: var(--paper); }
.cta-band p { color: color-mix(in srgb, var(--paper) 75%, transparent); max-width: 60ch; }
.cta-band .hero-actions .btn-ghost { color: var(--paper); border-color: color-mix(in srgb, var(--paper) 40%, transparent); }
.cta-band .hero-actions .btn-ghost:hover { border-color: var(--paper); }
.cta-band .hero-actions .btn-primary { background: var(--paper); color: var(--ink); }

.footer-about { margin-top: 12px; max-width: 44ch; }
.site-footer .footer-grid { grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr)); }
@media (max-width: 860px) { .site-footer .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .site-footer .footer-grid { grid-template-columns: minmax(0, 1fr); } }

.tour-section { display: grid; gap: 28px; }
.tour-section + .tour-section { padding-top: 56px; margin-top: 56px; border-top: 1px solid var(--line); }
.tour-section > h2 { font-size: var(--fs-xl); }
.tour-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 24px; align-items: start; }
@media (max-width: 760px) { .tour-grid { grid-template-columns: minmax(0, 1fr); } }

.home-shot { padding-block: 0 24px; }
