/* CFOT Prep site — colors follow the app's fiber palette (lib/core/theme/tokens.dart). */
:root {
  --bg: #F4F5F3; --surface: #FFFFFF; --surface2: #ECEEE9;
  --ink: #1A1E1C; --muted: #5B6560; --line: #D8DCD4;
  --accent: #C2410C; --on-accent: #FFFFFF; --accent-soft: #FDEEE3;
  --teal: #0F766E; --teal-soft: #E0F2EF;
  --good: #15803D; --good-soft: #E6F4EA;
  --bad: #B91C1C; --bad-soft: #FDECEC;
  --warn: #92400E; --warn-soft: #FDF3E0;
  --hero-a: #9A3412; --hero-b: #0F766E;
  --radius: 14px; --card-radius: 18px;
  --max: 1080px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131614; --surface: #1C201D; --surface2: #252A26;
    --ink: #EEF1ED; --muted: #A7B0A8; --line: #333A34;
    --accent: #FB923C; --on-accent: #1A1E1C; --accent-soft: #3A2415;
    --teal: #2DD4BF; --teal-soft: #11302D;
    --good: #4ADE80; --good-soft: #12301E;
    --bad: #F87171; --bad-soft: #3A1717;
    --warn: #FBBF24; --warn-soft: #3A2A10;
    --hero-a: #6B2410; --hero-b: #0B4F4A;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; height: auto; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 5vw, 3.1rem); font-weight: 800; margin: 0 0 .5em; }
h2 { font-size: clamp(1.45rem, 3vw, 1.9rem); font-weight: 800; margin: 2.2em 0 .6em; }
h3 { font-size: 1.15rem; margin: 1.6em 0 .4em; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 760px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }

/* ---------- header / footer */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top .wrap { display: flex; align-items: center; gap: 18px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--ink); text-decoration: none; font-size: 1.05rem; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.nav { display: flex; gap: 4px 16px; flex-wrap: wrap; margin-left: auto; font-size: .95rem; }
.nav a { color: var(--muted); text-decoration: none; font-weight: 600; padding: 4px 0; }
.nav a:hover, .nav a[aria-current] { color: var(--accent); }
@media (max-width: 720px) {
  .top { position: static; }
  .top .wrap { padding-top: 10px; padding-bottom: 10px; gap: 8px; }
  .nav { margin-left: 0; width: 100%; font-size: .9rem; }
}

footer { margin-top: 72px; background: var(--surface); border-top: 1px solid var(--line); padding: 40px 0 48px; font-size: .92rem; color: var(--muted); }
.foot-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 24px; }
footer h4 { color: var(--ink); margin: 0 0 8px; font-size: .95rem; }
footer ul { list-style: none; padding: 0; margin: 0; }
footer li { margin: 4px 0; }
footer a { color: var(--muted); }
.disclaimer { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); font-size: .85rem; }

/* ---------- buttons / badges */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 12px 20px; border-radius: 999px; font-weight: 700; text-decoration: none; border: 2px solid transparent; font-size: 1rem; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-ghost { border-color: currentColor; color: var(--accent); background: transparent; }
.btn-light { background: #fff; color: #7C2D12; }
.btn-outline-light { border-color: rgba(255,255,255,.8); color: #fff; }
.btn[aria-disabled="true"] { cursor: default; opacity: .9; }
.btn svg { width: 20px; height: 20px; flex: none; }
.cta-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.small { font-size: .88rem; }
.muted { color: var(--muted); }

/* ---------- hero */
.hero { background: linear-gradient(135deg, var(--hero-a), var(--hero-b)); color: #fff; padding: 56px 0 64px; }
.hero .wrap { display: grid; grid-template-columns: 1.15fr .85fr; gap: 40px; align-items: center; }
.hero p.lead { font-size: 1.18rem; opacity: .95; margin: 0 0 1.4em; max-width: 34em; }
.hero .small { opacity: .85; margin-top: 14px; }
.hero.page-hero { padding: 40px 0 44px; }
.hero.page-hero .wrap { display: block; }
.hero.page-hero h1 { font-size: clamp(1.8rem, 4.2vw, 2.6rem); }
.hero a:not(.btn) { color: #fff; }
.crumbs { font-size: .88rem; opacity: .85; margin-bottom: 10px; }
.crumbs ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs li + li::before { content: "›"; margin-right: 6px; }
@media (max-width: 820px) { .hero .wrap { grid-template-columns: 1fr; } .phone { display: none; } }

/* phone mockup */
.phone { justify-self: center; width: 280px; background: #0d1720; border-radius: 40px; padding: 12px; box-shadow: 0 30px 60px rgba(0,0,0,.35); }
.screen { background: #F4F5F3; color: #1A1E1C; border-radius: 30px; padding: 22px 16px 18px; font-size: .82rem; line-height: 1.4; }
.screen .tag { display: inline-block; background: #FDEEE3; color: #C2410C; font-weight: 700; border-radius: 999px; padding: 2px 10px; font-size: .72rem; }
.screen .qq { font-weight: 700; margin: 12px 0; font-size: .92rem; }
.screen .op { background: #fff; border: 1.5px solid #D4DBE2; border-radius: 12px; padding: 9px 11px; margin: 7px 0; }
.screen .op.ok { border-color: #15803D; background: #E6F4EA; font-weight: 700; }
.screen .ex { background: #fff; border-radius: 12px; padding: 10px 11px; margin-top: 12px; color: #55626F; }
.screen .ex b { color: #15803D; }

/* ---------- sections */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: -32px; position: relative; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--card-radius); padding: 18px; text-align: center; }
.stat b { display: block; font-size: 1.7rem; color: var(--accent); line-height: 1.1; }
.stat span { color: var(--muted); font-size: .9rem; }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
@media (max-width: 380px) { .grid-2 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--card-radius); padding: 22px; }
.card h3 { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }
.card .ico { font-size: 1.6rem; line-height: 1; margin-bottom: 10px; display: block; }
a.card { color: var(--ink); text-decoration: none; display: block; transition: border-color .15s, transform .15s; }
a.card:hover { border-color: var(--accent); transform: translateY(-2px); }
a.card .more { color: var(--accent); font-weight: 700; }
@media (prefers-reduced-motion: reduce) { a.card { transition: none; } a.card:hover { transform: none; } }

.weights { list-style: none; padding: 0; margin: 12px 0 0; }
.weights li { margin: 10px 0; }
.weights .row { display: flex; justify-content: space-between; gap: 12px; font-size: .95rem; }
.weights .bar { height: 8px; background: var(--surface2); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.weights .bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.weights a { color: var(--ink); }

.callout { background: var(--accent-soft); border-radius: var(--radius); padding: 16px 18px; margin: 18px 0; }
.callout.teal { background: var(--teal-soft); }
.callout.warn { background: var(--warn-soft); }
.callout p { margin: .3em 0; }
.callout strong:first-child { color: var(--accent); }
.callout.teal strong:first-child { color: var(--teal); }
.callout.warn strong:first-child { color: var(--warn); }

.price { text-align: center; }
.price .amt { font-size: 2.2rem; font-weight: 800; color: var(--ink); display: block; margin: 6px 0; }
.price.best { border: 2px solid var(--accent); }
.price ul { text-align: left; padding-left: 1.2em; margin: 14px 0 0; }

.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin: 10px 0; }
.faq summary { font-weight: 700; cursor: pointer; }
.faq details p { margin: .7em 0 0; }

.band { background: linear-gradient(135deg, var(--hero-a), var(--hero-b)); color: #fff; border-radius: var(--card-radius); padding: 32px; margin-top: 56px; }
.band h2 { margin-top: 0; }
.band p { opacity: .95; }

/* ---------- prose / docs */
.prose { max-width: 760px; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: .3em 0; }
table { border-collapse: collapse; width: 100%; background: var(--surface); border-radius: var(--radius); overflow: hidden; font-size: .95rem; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface2); font-weight: 700; }
tr:last-child td { border-bottom: 0; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.table-scroll table { border-radius: 0; }
.sheet h2 { scroll-margin-top: 80px; }
.toc { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; }
.toc a { display: inline-block; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; text-decoration: none; font-weight: 600; font-size: .92rem; }

/* worked example */
.example { background: var(--surface); border: 1px solid var(--line); border-radius: var(--card-radius); padding: 22px; margin: 18px 0; }
.example h3 { margin-top: 0; }
.example .formula { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--surface2); border-radius: 10px; padding: 10px 14px; display: block; overflow-x: auto; font-size: .95rem; }
.example ol { padding-left: 1.3em; }
.example .ans { font-weight: 800; color: var(--good); }

/* concept cards */
.concept { background: var(--surface); border: 1px solid var(--line); border-radius: var(--card-radius); padding: 22px; margin: 16px 0; }
.concept h3 { margin-top: 0; }
.concept .take { background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; font-weight: 600; }
.concept .plant { background: var(--teal-soft); border-radius: 10px; padding: 10px 14px; margin-top: 10px; }
.concept .plant b { color: var(--teal); }

/* ---------- practice questions */
.quiz-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.score { font-weight: 700; color: var(--muted); }
.q { background: var(--surface); border: 1px solid var(--line); border-radius: var(--card-radius); padding: 20px; margin: 14px 0; }
.q-meta { font-size: .8rem; font-weight: 700; color: var(--teal); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 6px; }
.q-text { font-weight: 700; margin: 0 0 12px; font-size: 1.05rem; }
.opts { list-style: none; padding: 0; margin: 0; counter-reset: opt; }
.opts li { counter-increment: opt; margin: 8px 0; }
.opts button {
  width: 100%; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--bg); border: 1.5px solid var(--line); border-radius: 12px;
  padding: 11px 14px 11px 46px; position: relative; line-height: 1.45;
}
.opts button::before {
  content: counter(opt, upper-alpha); position: absolute; left: 12px; top: 10px;
  width: 24px; height: 24px; border-radius: 50%; background: var(--surface2);
  display: grid; place-items: center; font-weight: 800; font-size: .8rem;
}
.opts button:hover:not(:disabled) { border-color: var(--accent); }
.opts button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.opts button:disabled { cursor: default; }
.opts button.right { border-color: var(--good); background: var(--good-soft); font-weight: 700; }
.opts button.right::before { background: var(--good); color: #fff; }
.opts button.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opts button.wrong::before { background: var(--bad); color: #fff; }
.why { margin-top: 12px; }
.why summary { cursor: pointer; font-weight: 700; color: var(--accent); }
.why p { margin: .6em 0 0; }
.why .verdict { font-weight: 800; }
.verdict.ok { color: var(--good); }
.verdict.no { color: var(--bad); }

/* OTDR trace diagram */
.trace { background: #0E110F; border-radius: var(--card-radius); padding: 14px; margin: 18px 0; color: #9FB8AC; }
.trace svg { width: 100%; height: auto; display: block; }
.trace figcaption { font-size: .85rem; margin-top: 8px; color: #A7B0A8; }
