/* CNT Ritual manuals — one stylesheet for the web pages and the printed PDFs.
   Layout: a booklet. A white masthead band, a title block, then a contents rail
   beside a reading column; screenshots sit in frames that may run wider than the
   text. In print the title block becomes a cover and each section starts a page.
   Colors and faces are the app's own (lib/design-tokens.ts). */

:root {
  --page: #f4f6fa;
  --card: #ffffff;
  --sunken: #e9edf4;
  --ink: #101e3c;
  --text: #2e3650;
  --muted: #5b6378;
  --line: #e4e6ec;
  --line-strong: #e4e6ec;
  --brand: #101e3c;
  --brand-fg: #ffffff;
  --gold: #0b5371;
  --flame: #e0b854;
  --tip-bg: #fbefc4;
  --tip-edge: #e0b854;
  --tip-ink: #101e3c;
  --shot-shadow: 0 1px 2px rgba(16, 30, 60, .06), 0 8px 24px rgba(16, 30, 60, .08);

  --font-display: "Caladea", Cambria, Georgia, "Times New Roman", serif;
  --font-body: "Carlito", Calibri, "Segoe UI", Arial, Helvetica, sans-serif;
  --font-mono: "IBM Plex Mono", Menlo, Consolas, "Courier New", monospace;

  --measure: 42rem;
  --wide: 60rem;
  --rail: 15rem;

  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0b1530;
    --card: #131f3e;
    --sunken: #1b2a4e;
    --ink: #faf7ee;
    --text: #e6e2d6;
    --muted: #a8b2c8;
    --line: #2a3a60;
    --line-strong: #2a3a60;
    --brand: #e0b854;
    --brand-fg: #101e3c;
    --gold: #e0b854;
    --flame: #e0b854;
    --tip-bg: #3a2a12;
    --tip-edge: #7a5a25;
    --tip-ink: #ffe7c2;
    --shot-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --page: #0b1530;
  --card: #131f3e;
  --sunken: #1b2a4e;
  --ink: #faf7ee;
  --text: #e6e2d6;
  --muted: #a8b2c8;
  --line: #2a3a60;
  --line-strong: #2a3a60;
  --brand: #e0b854;
  --brand-fg: #101e3c;
  --gold: #e0b854;
  --flame: #e0b854;
  --tip-bg: #3a2a12;
  --tip-edge: #7a5a25;
  --tip-ink: #ffe7c2;
  --shot-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  overflow-x: clip;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--brand); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 3px; }
strong { color: var(--ink); font-weight: 600; }

.gutter {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* ── Masthead ─────────────────────────────────────────── */
.masthead { background: var(--card); border-bottom: 1px solid var(--line); }
.masthead-inner {
  max-width: 78rem; margin: 0 auto; padding-block: .75rem;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1.5rem;
}
.brand { display: flex; align-items: center; gap: .6rem; color: var(--ink); text-decoration: none; }
.brand svg { color: var(--flame); flex: none; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 1.25rem; line-height: 1.1; display: block; }
.brand-sub { font-size: .8rem; color: var(--muted); display: block; }
.masthead nav { display: flex; flex-wrap: wrap; gap: .25rem .25rem; }
.masthead nav a {
  font-size: .875rem; font-weight: 500; color: var(--text); text-decoration: none;
  padding: .35rem .65rem; border-radius: 6px;
}
.masthead nav a:hover { background: var(--sunken); }
.masthead nav a[aria-current="page"] { background: var(--sunken); color: var(--brand); font-weight: 600; }

/* ── Title block ──────────────────────────────────────── */
.title-block { border-bottom: 1px solid var(--line); }
.title-inner { max-width: 78rem; margin: 0 auto; padding-block: 2.75rem 2.25rem; }
.eyebrow {
  font-size: .75rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--gold);
  margin: 0 0 .6rem;
}
.title-block h1 {
  font-family: var(--font-display); font-weight: 600; color: var(--ink);
  font-size: clamp(2.25rem, 1.6rem + 2.6vw, 3.4rem); line-height: 1.04; letter-spacing: -.015em;
  margin: 0; text-wrap: balance;
}
.lead { font-size: 1.15rem; line-height: 1.55; max-width: 38rem; margin: 1rem 0 0; color: var(--text); text-wrap: pretty; }
.meta { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; margin: 1.5rem 0 0; padding: 0; list-style: none; font-size: .875rem; color: var(--muted); }
.meta li { display: flex; align-items: center; gap: .45rem; }
.url { white-space: nowrap; font-family: var(--font-mono); font-size: .85rem; color: var(--ink); background: var(--sunken); border: 1px solid var(--line); border-radius: 6px; padding: .15rem .5rem; }
.print-only { display: none; }

/* ── Body layout ──────────────────────────────────────── */
.layout { max-width: 78rem; margin: 0 auto; padding-block: 2.5rem 4rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2.5rem; }
@media (min-width: 1080px) {
  .layout { grid-template-columns: var(--rail) minmax(0, 1fr); gap: 3.5rem; }
}

.toc { min-width: 0; }
.toc-inner { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 1rem 1.1rem; }
@media (min-width: 1080px) {
  .toc-inner { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 1.25rem); border: 0; background: none; padding: 0; }
}
.toc-title { font-size: .75rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 .5rem; }
.toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: .1rem; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc a {
  display: grid; grid-template-columns: 1.6rem minmax(0, 1fr); align-items: baseline;
  padding: .3rem .4rem; border-radius: 6px; color: var(--text); text-decoration: none; font-size: .9rem; line-height: 1.35;
}
.toc a::before { content: counter(toc); font-family: var(--font-mono); font-size: .78rem; color: var(--gold); font-variant-numeric: tabular-nums; }
.toc a:hover { background: var(--sunken); color: var(--ink); }

/* ── Article ──────────────────────────────────────────── */
article { min-width: 0; max-width: var(--wide); }
article > section { padding-top: .5rem; margin-bottom: 3.5rem; scroll-margin-top: 1rem; }
article > section > :not(figure):not(.table-wrap):not(.tip) { max-width: var(--measure); }

.sec-num {
  display: block; font-family: var(--font-mono); font-size: .8rem; font-weight: 500; color: var(--gold);
  letter-spacing: .06em; margin-bottom: .35rem;
}
h2 {
  font-family: var(--font-display); font-weight: 600; color: var(--ink);
  font-size: clamp(1.7rem, 1.4rem + 1vw, 2.1rem); line-height: 1.12; letter-spacing: -.01em;
  margin: 0 0 1rem; padding-bottom: .85rem; border-bottom: 1px solid var(--line); text-wrap: balance;
}
h3[id] { scroll-margin-top: 1rem; }
h3 { font-family: var(--font-body); font-weight: 600; color: var(--ink); font-size: 1.1rem; line-height: 1.3; margin: 2rem 0 .6rem; }
p { margin: 0 0 1rem; text-wrap: pretty; }
article ul { padding-left: 1.2rem; margin: 0 0 1.1rem; }
article ul li { margin: .3rem 0; }
article ul li::marker { color: var(--gold); }

/* Numbered steps: real sequences only. */
ol.steps { list-style: none; counter-reset: step; padding: 0; margin: 0 0 1.4rem; display: grid; gap: .8rem; }
ol.steps > li {
  counter-increment: step; position: relative; padding-left: 2.8rem; min-height: 1.85rem; padding-top: .1rem;
}
ol.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0; width: 1.85rem; height: 1.85rem; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand); color: var(--brand-fg); font-weight: 600; font-size: .9rem; font-variant-numeric: tabular-nums;
}
ol.steps > li > :first-child { margin-top: 0; }
ol.steps ul { margin: .4rem 0 0; }

/* Good to know */
.tip {
  background: var(--tip-bg); border: 1px solid var(--tip-edge); border-radius: 10px;
  padding: 1rem 1.2rem 1rem 1.15rem; margin: 1.5rem 0 1.75rem; max-width: var(--measure); color: var(--text);
}
.tip-label { display: flex; align-items: center; gap: .45rem; font-size: .75rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--tip-ink); margin: 0 0 .5rem; }
.tip-label svg { color: var(--flame); }
.tip ul { margin: 0; padding-left: 1.1rem; }
.tip li { margin: .3rem 0; }
.tip li::marker { color: var(--tip-ink); }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 0 1.5rem; border: 1px solid var(--line); border-radius: 10px; background: var(--card); max-width: var(--wide); }
table { border-collapse: collapse; width: 100%; font-size: .93rem; line-height: 1.45; }
th, td { text-align: left; vertical-align: top; padding: .65rem .9rem; border-bottom: 1px solid var(--line); }
th { font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); background: var(--sunken); }
tr:last-child td { border-bottom: 0; }
td:first-child { color: var(--ink); font-weight: 500; min-width: 11rem; }

/* Figures */
figure { margin: 1.5rem 0 2rem; }
.shots { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-start; }
.shot { margin: 0; display: grid; gap: .55rem; min-width: 0; }
.shot img { border: 1px solid var(--line-strong); background: var(--card); box-shadow: var(--shot-shadow); }
.fig--phone .shot { width: min(17rem, 100%); }
.fig--phone .shot img { border-radius: 22px; width: 100%; }
.fig--desktop .shots { flex-direction: column; }
.fig--desktop .shot { width: 100%; }
.fig--desktop .shot img { border-radius: 10px; width: 100%; }
.fig--small .shot { width: auto; }
.fig--small .shots { flex-direction: row; }
.fig--small .shot img { width: auto; max-width: 100%; border-radius: 10px; }
.shot-label { font-size: .85rem; font-weight: 600; color: var(--ink); display: flex; gap: .45rem; align-items: baseline; }
.shot-label b { font-family: var(--font-mono); font-size: .75rem; font-weight: 500; color: var(--gold); }
figcaption { font-size: .85rem; color: var(--muted); margin-top: .75rem; max-width: var(--measure); }

/* Video */
.fig--video .video-row { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: center; }
.fig--video video {
  width: min(15rem, 100%); aspect-ratio: 430 / 932; height: auto; border-radius: 22px; background: var(--brand);
  border: 1px solid var(--line-strong); box-shadow: var(--shot-shadow); display: block;
}
.video-note { max-width: 20rem; min-width: 0; }
.video-note p { margin: 0 0 .5rem; }
.video-note .len { font-family: var(--font-mono); font-size: .8rem; color: var(--gold); }

/* Footer */
.foot { border-top: 1px solid var(--line); background: var(--card); }
.foot-inner { max-width: 78rem; margin: 0 auto; padding-block: 1.75rem; display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: space-between; font-size: .9rem; color: var(--muted); }
.foot strong { color: var(--ink); }
.foot .addr { font-family: var(--font-mono); font-size: .85rem; color: var(--ink); user-select: all; }

/* ── Index page ───────────────────────────────────────── */
.home-hero { max-width: 78rem; margin: 0 auto; padding-block: 3rem 2rem; display: grid; gap: 2rem; align-items: center; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .home-hero { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); } }
.home-hero h1 { font-family: var(--font-display); font-weight: 600; color: var(--ink); font-size: clamp(2.4rem, 1.7rem + 3vw, 3.8rem); line-height: 1.02; letter-spacing: -.02em; margin: 0; text-wrap: balance; }
.guides { max-width: 78rem; margin: 0 auto; padding-block: .5rem 3rem; display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) { .guides { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.guide {
  display: grid; grid-template-rows: auto auto 1fr auto; gap: .5rem; padding: 1.4rem 1.5rem 1.3rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; color: inherit; text-decoration: none;
  transition: border-color .15s ease, transform .15s ease;
}
.guide:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.guide .eyebrow { margin: 0; }
.guide h2 { border: 0; padding: 0; margin: 0; font-size: 1.65rem; }
.guide ul { margin: .25rem 0 0; padding-left: 1.1rem; font-size: .95rem; }
.guide li { margin: .2rem 0; }
.guide li::marker { color: var(--gold); }
.guide .go { font-weight: 600; color: var(--brand); font-size: .95rem; margin-top: .5rem; }
.watch { max-width: 78rem; margin: 0 auto; padding-block: 0 3.5rem; }
.watch-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.5rem; display: flex; flex-wrap: wrap; gap: 1.75rem; align-items: center; }
.watch-card h2 { border: 0; padding: 0; margin: 0 0 .5rem; font-size: 1.65rem; }
.watch-card .video-note { max-width: 26rem; }

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

/* ── Print ────────────────────────────────────────────── */
@page { size: letter; }

@media print {
  :root {
    --page: #ffffff; --card: #ffffff; --sunken: #e9edf4; --ink: #101e3c; --text: #2e3650; --muted: #5b6378;
    --line: #e4e6ec; --line-strong: #e4e6ec; --brand: #101e3c; --brand-fg: #ffffff; --gold: #0b5371;
    --tip-bg: #fbefc4; --tip-edge: #e0b854; --tip-ink: #101e3c; --shot-shadow: none;
    color-scheme: light; padding: 0;
  }
  body { font-size: 10.5pt; line-height: 1.5; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .masthead, .foot, .no-print, .toc { display: none !important; }
  .print-only { display: block; }

  .title-block { break-after: page; border: 0; position: relative; height: 238mm; overflow: hidden; background: var(--page); }
  .title-inner { padding: 0 6mm; height: 100%; display: flex; flex-direction: column; justify-content: flex-start; max-width: none; }
  .cover-logo { height: 40mm; width: auto; margin: 14mm 0 24mm; }
  .title-block .eyebrow { font-size: 10pt; }
  .title-block h1 { font-size: 42pt; }
  .lead { font-size: 13pt; max-width: 125mm; }
  .meta { font-size: 10pt; display: grid; gap: 2mm; }
  .cover-band { position: absolute; left: 0; right: 0; bottom: 0; height: 9mm; background: var(--brand); border-radius: 2px; }
  .cover-foot { position: absolute; left: 6mm; right: 6mm; bottom: 16mm; font-size: 9pt; color: var(--muted); display: flex; justify-content: space-between; gap: 8mm; }

  .print-toc { break-after: page; padding-top: 4mm; }
  .print-toc h2 { font-size: 22pt; }
  .print-toc ol { list-style: none; padding: 0; margin: 0; counter-reset: ptoc; }
  .print-toc li { counter-increment: ptoc; display: grid; grid-template-columns: 12mm 1fr; padding: 2.6mm 0; border-bottom: 1px solid var(--line); font-size: 12pt; color: var(--ink); }
  .print-toc li::before { content: counter(ptoc); font-family: var(--font-mono); color: var(--gold); font-size: 10pt; }
  .print-toc .who { font-size: 10.5pt; color: var(--text); margin: 0 0 6mm; max-width: 130mm; }

  .layout { display: block; padding: 0; max-width: none; }
  article { max-width: none; }
  article > section { break-before: page; margin: 0; padding: 0; }
  article > section > :not(figure):not(.table-wrap):not(.tip) { max-width: none; }
  h2 { font-size: 22pt; }
  h3 { font-size: 12.5pt; break-after: avoid; margin-top: 7mm; }
  h2, h3 { break-after: avoid; }
  p, li { orphans: 3; widows: 3; }
  ol.steps > li, .tip, tr, figure { break-inside: avoid; }
  .table-wrap { overflow: visible; }
  figure { margin: 5mm 0 7mm; }
  .fig--phone .shot { width: 50mm; }
  .fig--phone .shot img { border-radius: 14px; max-height: 105mm; object-fit: cover; object-position: top; }
  .fig--desktop .shot img { max-height: 150mm; object-fit: contain; object-position: left top; }
  .fig--desktop .shot img { border-radius: 6px; }
  .fig--desktop .shots { gap: 5mm; }
  .fig--small .shot img { max-width: 90mm; }
  a { color: inherit; text-decoration: none; }
  .fig--video video, .video-note { display: none; }
  .video-strip { display: block; }
  .video-strip .frames { display: flex; gap: 4mm; }
  .video-strip img { width: 34mm; border-radius: 8px; border: 1px solid var(--line-strong); }
  .video-strip p { margin-top: 3mm; font-size: 10pt; }
}
.watch-card video {
  width: min(15rem, 100%); aspect-ratio: 430 / 932; height: auto; border-radius: 22px; display: block;
  border: 1px solid var(--line-strong); background: var(--brand); box-shadow: var(--shot-shadow);
}
