/* ---------------------------------------------------------------------------
   Design tokens. The complete light palette lives on bare :root; the dark
   blocks only ever override. Two dark blocks on purpose: the media query for
   readers on "system", the attribute selector for an explicit choice.
   --------------------------------------------------------------------------- */

/* Archivo, the Report URI heading face. The only piece of borrowed brand on the
   site: a family resemblance for anyone who knows it, invisible to anyone who
   does not. Variable weight, one file, self-hosted — a site about controlling
   what your pages load does not fetch fonts from someone else's origin. */
@font-face {
  font-family: Archivo;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/archivo-v25-latin.woff2") format("woff2");
}

:root {
  /* Report URI brand, used sparingly: navy carries the structure, orange
     appears exactly once (the sponsor line in the footer). */
  --brand-navy:   #1d253c;
  --brand-orange: #e8521a;

  --bg:            #FCFCFD;
  --bg-subtle:     #F4F4F6;
  --bg-code:       #F1F1F4;
  --fg:            #17171C;
  --fg-muted:      #5B5B67;
  --border:        #E1E1E6;
  --border-strong: #C9C9D2;

  --accent:        #2A3F6B;
  --accent-hover:  #1d253c;
  --focus:         #4B6BA8;

  --academy:       #1A5FBF;

  --fail:          #B4232E;
  --fail-bg:       #FDF1F1;
  --fail-border:   #E9B3B6;
  --win:           #1B6E3C;
  --win-bg:        #F0F8F2;
  --win-border:    #A9D3B8;
  --warn:          #8A5A00;
  --warn-bg:       #FDF6E7;
  --warn-border:   #E5CE9A;

  --radius:    6px;
  --radius-lg: 10px;
  --maxw:      70ch;
  --maxw-wide: 1080px;

  --font-display: Archivo, "Inter var", Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter var", Inter, system-ui, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo,
               Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #0F0F13;
    --bg-subtle:     #17171D;
    --bg-code:       #1B1B22;
    --fg:            #EDEDF2;
    --fg-muted:      #A0A0AE;
    --border:        #2A2A34;
    --border-strong: #3C3C48;

    --accent:        #8FAEE8;
    --accent-hover:  #AEC6F2;
    --focus:         #8FAEE8;
    --brand-navy:    #C3D0EA;

    --academy:       #7FA8F0;

    --fail:          #FF8A8A;
    --fail-bg:       #26161A;
    --fail-border:   #5C2B32;
    --win:           #7BD69C;
    --win-bg:        #13221A;
    --win-border:    #2C5138;
    --warn:          #E8C583;
    --warn-bg:       #241E10;
    --warn-border:   #55492A;
  }
}

:root[data-theme="dark"] {
  --bg:            #0F0F13;
  --bg-subtle:     #17171D;
  --bg-code:       #1B1B22;
  --fg:            #EDEDF2;
  --fg-muted:      #A0A0AE;
  --border:        #2A2A34;
  --border-strong: #3C3C48;

  --accent:        #8FAEE8;
  --accent-hover:  #AEC6F2;
  --focus:         #8FAEE8;
  --brand-navy:    #C3D0EA;

  --academy:       #7FA8F0;

  --fail:          #FF8A8A;
  --fail-bg:       #26161A;
  --fail-border:   #5C2B32;
  --win:           #7BD69C;
  --win-bg:        #13221A;
  --win-border:    #2C5138;
  --warn:          #E8C583;
  --warn-bg:       #241E10;
  --warn-border:   #55492A;
}

/* --------------------------------------------------------------------------- */

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: var(--maxw-wide); margin: 0 auto; padding: 0 1.25rem; }
main.wrap { padding-top: 2.5rem; padding-bottom: 4rem; }
main > * { max-width: var(--maxw); }
main > .full, main > .tool, main > .grid, main > .findings { max-width: none; }

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

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

.skip {
  position: absolute; left: -9999px;
  background: var(--bg); padding: .6rem 1rem; border: 1px solid var(--border-strong);
}
.skip:focus { left: 1rem; top: .5rem; z-index: 50; }

h1, h2, h3, .brand-name, .verdict .grade { font-family: var(--font-display); }

h1 { font-size: clamp(1.75rem, 1.2rem + 2vw, 2.25rem); line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.02em; }
h2 { font-size: 1.35rem; line-height: 1.3; margin: 2.5rem 0 .6rem; letter-spacing: -.01em; }
h3 { font-size: 1.075rem; margin: 1.75rem 0 .4rem; }
p  { margin: 0 0 1rem; }
.lead { font-size: 1.15rem; color: var(--fg-muted); margin-bottom: 2rem; }
.muted { color: var(--fg-muted); }
.small { font-size: .9rem; }

/* Topbar ------------------------------------------------------------------- */

.topbar { border-bottom: 1px solid var(--border); background: var(--bg); position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 3.5rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--fg); font-weight: 650; }
.brand-mark { display: block; width: 1.75rem; height: 1.75rem; color: var(--academy); flex: none; }
.brand-mark svg { display: block; width: 100%; height: 100%; }
[data-site="fail"] .brand-mark { color: var(--fail); }
[data-site="win"]  .brand-mark { color: var(--win); }
.brand-name { font-weight: 700; font-size: 1.1rem; letter-spacing: -.015em; }
.topnav { display: flex; align-items: center; gap: 1.1rem; }
.topnav a { color: var(--fg-muted); text-decoration: none; font-size: .95rem; font-weight: 550; }
.topnav a:hover, .topnav a[aria-current="page"] { color: var(--fg); }

.theme-toggle {
  display: grid; place-items: center;
  width: 2.1rem; height: 2.1rem; padding: 0; cursor: pointer;
  color: var(--fg-muted); background: var(--bg-subtle);
  border: 1px solid var(--border); border-radius: 50%;
}
.theme-toggle:hover { color: var(--fg); border-color: var(--border-strong); }
.theme-toggle svg { display: none; width: 1.1rem; height: 1.1rem; }
.theme-toggle[data-mode="system"] .icon-system,
.theme-toggle[data-mode="light"]  .icon-light,
.theme-toggle[data-mode="dark"]   .icon-dark { display: block; }

/* Code and policies -------------------------------------------------------- */

code { font-family: var(--font-mono); font-size: .92em; background: var(--bg-code); padding: .12em .35em; border-radius: 4px; }

.policy, pre {
  font-family: var(--font-mono);
  font-size: .95rem;
  line-height: 1.6;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  margin: 0 0 1rem;
}
pre code { background: none; padding: 0; }

.policy-wrap { position: relative; margin-bottom: 1rem; }
.policy-wrap .policy { margin-bottom: 0; }
.copy-btn {
  position: absolute; top: .5rem; right: .5rem;
  font: inherit; font-size: .78rem; cursor: pointer;
  background: var(--bg); color: var(--fg-muted);
  border: 1px solid var(--border-strong); border-radius: 4px; padding: .2rem .55rem;
}
.copy-btn:hover { color: var(--fg); }

/* Tools -------------------------------------------------------------------- */

.tool { margin: 0 0 2.5rem; }
.tool textarea {
  width: 100%; min-height: 8.5rem; resize: vertical;
  font-family: var(--font-mono); font-size: .95rem; line-height: 1.6;
  color: var(--fg); background: var(--bg-subtle);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: .9rem 1rem;
}
.tool textarea:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
.tool-actions { display: flex; gap: .75rem; align-items: center; margin-top: .85rem; flex-wrap: wrap; }

.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  background: var(--accent); color: #fff;
  border: 1px solid transparent; border-radius: var(--radius);
  padding: .55rem 1.1rem;
}
.btn:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; color: var(--fg-muted); border-color: var(--border-strong); }
.btn.ghost:hover { color: var(--fg); background: var(--bg-subtle); }

/* Findings ----------------------------------------------------------------- */

.findings { margin: 2rem 0; }
.finding {
  border: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  padding: .9rem 1.1rem;
  margin-bottom: .85rem;
}
.finding h3 { margin: 0 0 .3rem; font-size: 1rem; }
.finding p:last-child { margin-bottom: 0; }
.finding .tag {
  display: inline-block; font-size: .7rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; padding: .1rem .45rem; border-radius: 3px; margin-right: .5rem;
  vertical-align: .1em;
}

.finding.high   { border-left-color: var(--fail); background: var(--fail-bg); }
.finding.high   .tag { color: var(--fail); border: 1px solid var(--fail-border); }
.finding.medium { border-left-color: var(--warn); background: var(--warn-bg); }
.finding.medium .tag { color: var(--warn); border: 1px solid var(--warn-border); }
.finding.good   { border-left-color: var(--win); background: var(--win-bg); }
.finding.good   .tag { color: var(--win); border: 1px solid var(--win-border); }
.finding.info   .tag { color: var(--fg-muted); border: 1px solid var(--border-strong); }

/* Verdict band ------------------------------------------------------------- */

.verdict {
  display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap;
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  padding: 1rem 1.2rem; margin: 1.5rem 0;
  background: var(--bg-subtle);
}
.verdict .grade { font-size: 1.6rem; font-weight: 750; letter-spacing: -.03em; }
.verdict.is-fail { background: var(--fail-bg); border-color: var(--fail-border); }
.verdict.is-fail .grade { color: var(--fail); }
.verdict.is-warn { background: var(--warn-bg); border-color: var(--warn-border); }
.verdict.is-warn .grade { color: var(--warn); }
.verdict.is-win  { background: var(--win-bg);  border-color: var(--win-border); }
.verdict.is-win  .grade { color: var(--win); }

/* Callouts ----------------------------------------------------------------- */

.callout {
  border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--radius); background: var(--bg-subtle);
  padding: .9rem 1.1rem; margin: 1.5rem 0;
}
.callout p:last-child { margin-bottom: 0; }
.callout h3 { margin-top: 0; }

/* Cards / grids ------------------------------------------------------------ */

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; margin: 1.5rem 0 2rem; }
.card {
  display: block; text-decoration: none; color: inherit;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--bg-subtle); padding: 1.1rem 1.2rem;
}
.card:hover { border-color: var(--border-strong); }
.card h3 { margin: 0 0 .3rem; font-size: 1.05rem; color: var(--fg); }
.card p { margin: 0; color: var(--fg-muted); font-size: .95rem; }

.steps { list-style: none; padding: 0; margin: 1.5rem 0; counter-reset: step; }
.steps li { counter-increment: step; border-top: 1px solid var(--border); padding: .85rem 0 .85rem 2.75rem; position: relative; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: .95rem;
  width: 1.75rem; height: 1.75rem; border-radius: 50%;
  background: var(--bg-subtle); border: 1px solid var(--border-strong);
  color: var(--fg-muted); font-size: .82rem; font-weight: 650;
  display: grid; place-items: center;
}
.steps li:last-child { border-bottom: 1px solid var(--border); }
.steps a { font-weight: 600; text-decoration: none; }
.steps a:hover { text-decoration: underline; }
.steps .mins { color: var(--fg-muted); font-size: .85rem; margin-left: .5rem; }

/* Footer ------------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 4rem; padding: 2rem 0 3rem;
  color: var(--fg-muted); font-size: .9rem;
}
.site-footer p { margin: 0 0 .4rem; }
.footer-links a { color: var(--fg-muted); text-decoration: none; }
.footer-links a:hover { color: var(--fg); text-decoration: underline; }
.footer-sponsor a { color: var(--fg); text-decoration: none; border-bottom: 2px solid var(--brand-orange); }
.footer-sponsor a:hover { color: var(--brand-orange); }
.footer-note { font-size: .85rem; }

.hidden { display: none !important; }

/* Design scratch page (/marks) — delete with the page before launch. */
.mark-row { display: flex; align-items: flex-end; gap: 1.25rem; flex-wrap: wrap; margin-bottom: .5rem; }
.mark { display: inline-block; }
.mark svg { display: block; width: 100%; height: 100%; }
.mark-academy { color: var(--academy); }
.mark-fail    { color: var(--fail); }
.mark-win     { color: var(--win); }
.s16  { width: 16px;  height: 16px; }
.s20  { width: 20px;  height: 20px; }
.s28  { width: 28px;  height: 28px; }
.s48  { width: 48px;  height: 48px; }
.s96  { width: 96px;  height: 96px; }
.s160 { width: 160px; height: 160px; }

/* "See it happen" demo blocks, linking to the Report URI demo site. */
.demo-callout { border-left-color: var(--fg-muted); }
.demo-links { display: flex; flex-wrap: wrap; gap: .6rem; margin: .9rem 0 .6rem; }
.demo-link {
  display: inline-block; text-decoration: none; font-weight: 600; font-size: .95rem;
  padding: .45rem .9rem; border-radius: var(--radius); border: 1px solid;
}
.demo-link-off { color: var(--fail); border-color: var(--fail-border); background: var(--fail-bg); }
.demo-link-off:hover { color: var(--fail); border-color: var(--fail); }
.demo-link-on { color: var(--win); border-color: var(--win-border); background: var(--win-bg); }
.demo-link-on:hover { color: var(--win); border-color: var(--win); }

/* ---------------------------------------------------------------------------
   Visual polish. Everything here is CSS or inline SVG we already ship — no
   images, no external assets, nothing that would need a looser style-src.
   --------------------------------------------------------------------------- */

/* Hero: the site mark, huge and faint, behind the opening lines. */
.hero {
  position: relative;
  max-width: none;
  margin: -.5rem 0 2.5rem;
  padding: 2.25rem 0 1.75rem;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.hero > * { position: relative; z-index: 1; max-width: var(--maxw); }
.hero h1 { margin-bottom: .65rem; }
.hero .lead { margin-bottom: 0; }
.hero-mark {
  position: absolute; top: 50%; right: 1rem; z-index: 0;
  width: 15rem; height: 15rem; transform: translateY(-50%);
  opacity: .07; pointer-events: none;
}
.hero-mark svg { display: block; width: 100%; height: 100%; }
[data-site="academy"] .hero-mark { color: var(--academy); }
[data-site="fail"]    .hero-mark { color: var(--fail); }
[data-site="win"]     .hero-mark { color: var(--win); }
@media (max-width: 700px) { .hero-mark { display: none; } }

/* A hairline of site colour under the topbar, so the three feel distinct. */
.topbar { border-bottom-width: 1px; box-shadow: inset 0 -3px 0 -1px var(--academy); }
[data-site="fail"] .topbar { box-shadow: inset 0 -3px 0 -1px var(--fail); }
[data-site="win"]  .topbar { box-shadow: inset 0 -3px 0 -1px var(--win); }

/* Cards lift slightly and their arrow steps forward. */
.card {
  transition: transform .12s ease, border-color .12s ease, background-color .12s ease;
}
.card:hover { transform: translateY(-2px); background: var(--bg); }
.card h3 { transition: color .12s ease; }
.card:hover h3 { color: var(--accent); }

/* Policy blocks get a gutter tick in the site colour. */
.policy { border-left: 3px solid var(--border-strong); }
[data-site="academy"] .policy { border-left-color: var(--academy); }
[data-site="fail"]    .policy { border-left-color: var(--fail); }
[data-site="win"]     .policy { border-left-color: var(--win); }

/* CSP syntax highlighting, applied by site.js. Colour carries meaning here:
   anything that weakens a policy is the same red the rest of the site uses
   for failure, and the tokens that make a policy strong are the win green. */
.tok-directive { color: var(--fg); font-weight: 650; }
.tok-safe      { color: var(--win); }
.tok-unsafe    { color: var(--fail); font-weight: 600; }
.tok-keyword   { color: var(--accent); }
.tok-host      { color: var(--fg-muted); }
.tok-punct     { color: var(--border-strong); }

/* Course step rail: position without state. */
.step-rail { display: flex; gap: .3rem; align-items: center; margin: 0 0 1.5rem; padding: 0; list-style: none; }
.step-rail li { flex: 1; height: 4px; border-radius: 2px; background: var(--border); }
.step-rail li.done { background: var(--academy); opacity: .45; }
.step-rail li.here { background: var(--academy); opacity: 1; }

/* Prev/next at the foot of a step. */
.step-nav { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 3rem; max-width: none; }
.step-nav a {
  flex: 1 1 14rem; text-decoration: none; color: inherit;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: .9rem 1.1rem; background: var(--bg-subtle);
  transition: transform .12s ease, border-color .12s ease;
}
.step-nav a:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.step-nav .dir { display: block; font-size: .8rem; color: var(--fg-muted); margin-bottom: .1rem; }
.step-nav .name { font-weight: 650; }
.step-nav .next { text-align: right; }

/* --- Second polish pass: text detail ------------------------------------- */

/* Selection picks up the site colour. */
::selection { background: color-mix(in srgb, var(--academy) 22%, transparent); }
[data-site="fail"] ::selection { background: color-mix(in srgb, var(--fail) 22%, transparent); }
[data-site="win"]  ::selection { background: color-mix(in srgb, var(--win) 22%, transparent); }

/* Underlines that sit off the baseline rather than through the descenders. */
main p a, main li a { text-decoration-thickness: 1px; text-underline-offset: 3px; }
main p a:hover, main li a:hover { text-decoration-thickness: 2px; }

/* Numbered lists carry a lot of the course. Give the numerals the site colour. */
main ol { counter-reset: item; list-style: none; padding-left: 0; }
main ol > li { counter-increment: item; position: relative; padding-left: 2.1rem; margin-bottom: .6rem; }
main ol > li::before {
  content: counter(item) ".";
  position: absolute; left: 0; top: 0;
  font-family: var(--font-display); font-weight: 700; font-size: .95rem;
  color: var(--academy);
}
[data-site="fail"] main ol > li::before { color: var(--fail); }
[data-site="win"]  main ol > li::before { color: var(--win); }
main ol.step-rail { counter-reset: none; padding-left: 0; }
main ol.steps { counter-reset: step; padding-left: 0; }
main ol.step-rail > li, main ol.steps > li { padding-left: 0; margin-bottom: 0; }
main ol.step-rail > li::before { content: none; }
main ol.steps > li { padding-left: 2.75rem; }
main ol.steps > li::before { content: counter(step); font-size: .82rem; }

/* Unordered lists get a small square in the site colour instead of a bullet. */
main > ul, .callout ul { list-style: none; padding-left: 0; }
main > ul > li, .callout ul > li { position: relative; padding-left: 1.4rem; margin-bottom: .5rem; }
main > ul > li::before, .callout ul > li::before {
  content: ""; position: absolute; left: .15rem; top: .72em;
  width: .38rem; height: .38rem; border-radius: 1px; background: var(--academy); opacity: .75;
}
[data-site="fail"] main > ul > li::before, [data-site="fail"] .callout ul > li::before { background: var(--fail); }
[data-site="win"]  main > ul > li::before, [data-site="win"]  .callout ul > li::before { background: var(--win); }

/* Heading anchors, added by site.js. Sticky topbar means anchors need room. */
h2[id], h3[id] { scroll-margin-top: 5rem; }
.anchor {
  margin-left: .4rem; text-decoration: none; color: var(--fg-muted);
  opacity: 0; transition: opacity .12s ease; font-weight: 400;
}
h2:hover > .anchor, h3:hover > .anchor, .anchor:focus-visible { opacity: .6; }
.anchor:hover { opacity: 1; color: var(--accent); }

/* Copy button stays out of the way until you want it. */
.copy-btn { opacity: 0; transition: opacity .12s ease; }
.policy-wrap:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
@media (hover: none) { .copy-btn { opacity: 1; } }
