/* ===== unfold — Canine Development "Fjeld" design system (docs/DESIGN.md) =====
   Token sheet (§12) shared verbatim with watchdog. No hex literals below the token blocks.
   Landing/public register: light by default (§11); the dark theme block ships for the toggle. */

/* ---- faces (§4.1, self-hosted, no CDN) ---- */
@font-face {
    font-family: "Schibsted Grotesk";
    src: url("/fonts/schibsted-var.woff2") format("woff2");
    font-weight: 400 900;
    font-display: swap;
}
@font-face {
    font-family: "JetBrains Mono";
    src: url("/fonts/jetbrains-var.woff2") format("woff2");
    font-weight: 400 800;
    font-display: swap;
}

/* ---- token sheet (§12) ---- */
:root {
    /* neutrals — light */
    --bg:#FCFCFD; --surface:#F5F7F9; --surface-2:#EDF0F3;
    --border:#E1E6EB; --border-strong:#CBD3DA;
    --ink:#1C2126; --ink-soft:#434B54; --muted:#616B76; --heading:#14181D;
    /* steel */
    --accent:#4682B4; --accent-ink:#2F5D85; --accent-wash:#EAF1F7; --accent-strong:#264B6B;
    --on-accent:#FFFFFF;
    /* bands: strong / wash / on-wash */
    --band-exemplary:#1E6B47; --band-exemplary-wash:#DCEDE4; --band-exemplary-ink:#0E2A1C;
    --band-healthy:#55966B;  --band-healthy-wash:#E2F0E7;  --band-healthy-ink:#16331F;
    --band-fair:#B58A1F;     --band-fair-wash:#F6ECD4;     --band-fair-ink:#3D2E08;
    --band-poor:#B5563A;     --band-poor-wash:#F6E0D7;     --band-poor-ink:#3E1D11;
    --band-critical:#AD3A34; --band-critical-wash:#F5DAD7; --band-critical-ink:#3A1210;
    --band-exemplary-solid-ink:#FCFCFD; --band-healthy-solid-ink:#14181D; --band-fair-solid-ink:#14181D;
    --band-poor-solid-ink:#FCFCFD; --band-critical-solid-ink:#FCFCFD;
    /* data series */
    --s-headline:#4682B4; --s-codehealth:#55966B; --s-architecture:#7D6FAE;
    --s-maturity:#4E93A0; --s-readiness:#B58A1F; --s-security:#AD3A34;
    --s-domain:#B26A8C; --s-eventdriven:#A98A4A; --s-eventsourcing:#3E8E7E; --s-loc:#76828E;
    /* shape & depth */
    --r-sm:6px; --r-md:10px; --r-lg:14px; --r-full:999px;
    --shadow-overlay:0 4px 16px rgb(20 25 30 / .10);
    --shadow-modal:0 16px 48px rgb(20 25 30 / .16);
    /* type */
    --font-ui:"Schibsted Grotesk",system-ui,sans-serif;
    --font-mono:"JetBrains Mono",ui-monospace,monospace;
    --fs-2xs:11px; --fs-xs:12px; --fs-sm:13px; --fs-md:14px; --fs-lg:16px;
    --fs-xl:20px; --fs-2xl:25px; --fs-3xl:31px; --fs-4xl:39px; --fs-num:56px;
    --maxw: 1080px;
    font-synthesis: none;
}
:root[data-theme="dark"] {
    --bg:#15191E; --surface:#1C2127; --surface-2:#232A31;
    --border:#2D353E; --border-strong:#3A444F;
    --ink:#E4E9ED; --ink-soft:#B9C2CB; --muted:#8694A1; --heading:#F2F5F8;
    --accent:#7FAACE; --accent-ink:#9BBEDB; --accent-wash:#1E2C39; --accent-strong:#B7D2E8;
    --on-accent:#15191E;
    --band-exemplary:#4D9B74; --band-exemplary-wash:#16352A; --band-exemplary-ink:#A9D9C2;
    --band-healthy:#6FAE85;  --band-healthy-wash:#1A3326;  --band-healthy-ink:#B5DCC4;
    --band-fair:#CFA53C;     --band-fair-wash:#393012;     --band-fair-ink:#E8D49A;
    --band-poor:#CF7858;     --band-poor-wash:#3A2118;     --band-poor-ink:#EFC4B4;
    --band-critical:#D86A60; --band-critical-wash:#3A1A18; --band-critical-ink:#F0BFBA;
    --band-exemplary-solid-ink:#14181D; --band-healthy-solid-ink:#14181D; --band-fair-solid-ink:#14181D;
    --band-poor-solid-ink:#14181D; --band-critical-solid-ink:#14181D;
    --shadow-overlay:0 4px 16px rgb(0 0 0 / .35);
    --shadow-modal:0 16px 48px rgb(0 0 0 / .5);
}
.num, td.num, .t-num { font-variant-numeric: tabular-nums lining-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- base ---- */
* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-ui);
    font-size: var(--fs-md);
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; min-height: 100vh; }
main { flex: 1; }

a { color: var(--accent-ink); text-decoration: none; transition: color 120ms ease-out; }
a:hover { text-decoration: underline; }

code, pre, .mono { font-family: var(--font-mono); font-variant-ligatures: none; }

h1, h2, h3, h4 { color: var(--heading); line-height: 1.3; margin: 0 0 .5em; }
h1 { font-size: var(--fs-3xl); font-weight: 700; letter-spacing: -0.015em; }
h2 { font-size: var(--fs-2xl); font-weight: 600; }
h3 { font-size: var(--fs-xl); font-weight: 600; }
h4 { font-size: var(--fs-lg); font-weight: 600; }
p { margin: 0 0 1rem; color: var(--ink-soft); }
.muted { color: var(--muted); }

/* ---- nav (borders first — no blur, no dark slab) ---- */
.site-nav {
    position: sticky; top: 0; z-index: 50;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.nav-inner {
    max-width: var(--maxw); margin: 0 auto; padding: 12px 24px;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
}

/* Brand lockup (§2.2): flat Canine badge (currentColor via mask) + capitalized wordmark + by-line —
   rendered ONLY by the shared BrandLockup component (Components/Shared/BrandLockup.razor): badge spanning
   two rows, wordmark top-right, "by Canine Development" beneath. */
.brand {
    position: relative;
    display: inline-grid; grid-template-columns: auto auto; column-gap: 8px; align-items: center;
    color: var(--heading);
}
.brand:hover { text-decoration: none; }
.badge {
    grid-row: 1 / 3;
    display: inline-block; width: 20px; height: 22px; flex: 0 0 auto;
    background: currentColor;
    -webkit-mask: url("/brand/canine-badge-flat.svg") no-repeat center / contain;
    mask: url("/brand/canine-badge-flat.svg") no-repeat center / contain;
}
.wordmark { grid-column: 2; grid-row: 1; align-self: end; font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.01em; color: var(--heading); line-height: 1.05; }
.byline { grid-column: 2; grid-row: 2; align-self: start; font-size: 0.6rem; font-weight: 400; color: var(--muted); line-height: 1.2; white-space: nowrap; }

.nav-links { display: flex; align-items: center; gap: 24px; }
.nav-links a { color: var(--muted); font-size: var(--fs-md); font-weight: 500; }
.nav-links a:hover { color: var(--ink); text-decoration: none; }

/* ---- icons (§6: Lucide — 2px stroke, round caps, currentColor, never filled) ---- */
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Theme switch: light shows the moon (switch to dark), dark shows the sun. */
.theme-toggle { padding: 6px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---- buttons — ONE system (§7.1) ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 8px 14px; border-radius: var(--r-sm);
    font-family: var(--font-ui); font-size: var(--fs-md); font-weight: 500; line-height: 1.5;
    cursor: pointer; border: 1px solid transparent;
    transition: background 120ms ease-out, color 120ms ease-out, border-color 120ms ease-out;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent-strong); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-ink); color: var(--on-accent); }
.btn-secondary { background: transparent; border-color: var(--border-strong); color: var(--ink); }
.btn-secondary:hover { background: var(--surface-2); color: var(--ink); }
.btn-quiet { background: transparent; color: var(--muted); }
.btn-quiet:hover { color: var(--ink); }
.btn-danger { background: transparent; border-color: var(--band-critical); color: var(--band-critical); }
.btn-danger:hover { background: var(--band-critical-wash); }
.btn-sm { padding: 6px 10px; font-size: var(--fs-sm); }
.btn-lg { padding: 12px 20px; font-size: var(--fs-lg); }
.btn-block { display: flex; width: 100%; margin: 8px 0; }

/* ---- chips — ONE system (§7.3) ---- */
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    border-radius: var(--r-full); padding: 2px 10px;
    font-size: var(--fs-xs); font-weight: 600; line-height: 1.5;
}
.chip-neutral { background: var(--surface-2); color: var(--muted); }
.chip-accent { background: var(--accent-wash); color: var(--accent-ink); }
.chip-fair { background: var(--band-fair-wash); color: var(--band-fair-ink); }
.chip-critical-solid { background: var(--band-critical); color: var(--band-critical-solid-ink); }

/* ---- hero (landing register, light — §11) ---- */
.hero { background: var(--surface); border-bottom: 1px solid var(--border); }
.hero-inner { max-width: var(--maxw); margin: 0 auto; padding: 88px 24px 80px; }
.eyebrow {
    color: var(--accent-ink); font-size: var(--fs-xs); font-weight: 600;
    letter-spacing: .04em; text-transform: uppercase; margin: 0 0 16px;
}
.hero h1 { font-size: var(--fs-4xl); font-weight: 700; letter-spacing: -0.015em; max-width: 18ch; }
.hero .accent { color: var(--accent-ink); }
.lede { font-size: var(--fs-lg); color: var(--ink-soft); max-width: 60ch; margin-top: 16px; }
.cta-row { display: flex; gap: 12px; margin: 24px 0 16px; flex-wrap: wrap; }
.cta-row.center { justify-content: center; }
.hero-note {
    color: var(--muted); max-width: 64ch; margin-top: 16px; font-size: var(--fs-md);
    border-left: 2px solid var(--accent); padding-left: 16px;
}
.hero-note strong { color: var(--ink); }

/* ---- bands ---- */
.band { background: var(--bg); }
.band-alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.band-inner { max-width: var(--maxw); margin: 0 auto; padding: 64px 24px; }
.band-inner.center { text-align: center; }
.section-lede { font-size: var(--fs-lg); color: var(--muted); max-width: 64ch; margin: 0 0 32px; }
.band-inner.center .section-lede { margin-left: auto; margin-right: auto; }

/* ---- cards (§7.4: surface + 1px border, no shadow) ---- */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.cards-3 { grid-template-columns: repeat(3, 1fr); }
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
    padding: 24px;
}
.card h3 { font-size: var(--fs-lg); margin-bottom: 6px; }
.card p { color: var(--muted); margin: 0; font-size: var(--fs-md); }

/* ---- steps ---- */
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px 32px; }
.steps-compact { grid-template-columns: 1fr; gap: 16px; margin-top: 24px; }
.steps li { display: flex; gap: 16px; align-items: flex-start; }
.step-n {
    flex: 0 0 auto; width: 32px; height: 32px; border-radius: var(--r-full);
    background: var(--accent-wash); color: var(--accent-ink); font-weight: 600;
    display: grid; place-items: center; font-size: var(--fs-md);
    font-variant-numeric: tabular-nums lining-nums;
}
.steps h2, .steps h3 { font-size: var(--fs-lg); font-weight: 600; margin-bottom: 2px; }
.steps p { color: var(--muted); margin: 0; font-size: var(--fs-md); }

/* ---- "not for" band (Fair band — semantic caution, §3.4) ---- */
.band-warn { background: var(--band-fair-wash); border-top: 1px solid var(--band-fair); border-bottom: 1px solid var(--band-fair); }
.band-warn h2 .accent-warn { color: var(--band-fair-ink); }
.not-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; max-width: 78ch; }
.not-list li {
    background: var(--bg); border: 1px solid var(--border); border-left: 3px solid var(--band-fair);
    border-radius: var(--r-md); padding: 16px 20px; color: var(--ink-soft);
}
.not-list strong { display: block; margin-bottom: 2px; color: var(--ink); }
.not-foot { margin-top: 24px; max-width: 70ch; }

/* ---- final CTA ---- */
.band-cta { background: var(--surface); border-top: 1px solid var(--border); }

/* ---- footer ---- */
.site-footer { background: var(--surface); color: var(--muted); border-top: 1px solid var(--border); }
.footer-inner { max-width: var(--maxw); margin: 0 auto; padding: 32px 24px; display: flex; justify-content: space-between; gap: 32px; flex-wrap: wrap; }
.footer-inner .muted { margin: 4px 0 0; }
.footer-inner .copyright { font-size: var(--fs-xs); }
.footer-meta { display: flex; flex-flow: row wrap; gap: 6px 18px; justify-content: flex-end; align-items: baseline; text-align: right; font-size: var(--fs-sm); }

/* ---- auth / preview ---- */
.auth-wrap { min-height: calc(100vh - 200px); display: grid; place-items: center; padding: 48px 24px; background: var(--bg); }
.auth-card {
    width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-md); padding: 32px; text-align: center;
}
.auth-card.wide { max-width: 560px; text-align: left; }
.auth-card h1 { font-size: var(--fs-2xl); margin: 8px 0 6px; }
.brand-center { justify-content: center; display: inline-flex; margin-bottom: 6px; }
.auth-card.wide .brand-center { justify-content: flex-start; }
.auth-note { font-size: var(--fs-sm); margin-top: 16px; }

/* ---- describe (the live reflect-back screen) ---- */
.describe { background: var(--bg); min-height: calc(100vh - 200px); }
.describe-inner { max-width: 820px; margin: 0 auto; padding: 48px 24px 64px; }
.describe .back { color: var(--muted); font-size: var(--fs-sm); }
.describe h1 { margin: 8px 0 6px; }
.describe .muted { max-width: 64ch; }
.prose {
    width: 100%; margin: 24px 0 16px; padding: 12px 16px;
    border: 1px solid var(--border-strong); border-radius: var(--r-sm);
    font-family: var(--font-ui); font-size: var(--fs-lg); line-height: 1.5; color: var(--ink);
    resize: vertical; background: var(--bg);
}
.prose::placeholder { color: var(--muted); }
.map-wrap { margin-top: 32px; }
.map-frame { width: 100%; min-height: 620px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--bg); }

/* Couldn't-parse / build-failed notices — Fair band (caution, recoverable). */
.reject {
    margin-top: 32px; background: var(--band-fair-wash);
    border: 1px solid var(--band-fair); border-left: 3px solid var(--band-fair);
    border-radius: var(--r-md); padding: 16px 20px;
}
.reject h2 { font-size: var(--fs-lg); margin: 0 0 8px; color: var(--band-fair-ink); }
.reject ul { margin: 0 0 12px; padding-left: 20px; color: var(--ink-soft); }
.reject li { margin-bottom: 4px; }

/* ---- confirm step (rules-by-example cards + seam gates) ---- */
.describe h2 { font-size: var(--fs-xl); margin: 32px 0 12px; }
.confirm-card {
    border: 1px solid var(--border); border-radius: var(--r-md);
    padding: 16px 20px; margin: 0 0 12px; background: var(--surface);
}
.confirm-card.high { border-color: var(--band-critical); border-left: 3px solid var(--band-critical); background: var(--band-critical-wash); }
.confirm-card legend { font-weight: 600; color: var(--heading); padding: 0; line-height: 1.4; }
.confirm-card .why { color: var(--muted); font-size: var(--fs-sm); margin: 6px 0 10px; }
.confirm-card .opts { display: flex; flex-wrap: wrap; gap: 16px; }

/* Project list (the /board projects home) — each project is a card row matching .confirm-card. */
.project-list { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 10px; }
.project-list li {
    display: flex; align-items: center; gap: 14px;
    border: 1px solid var(--border); border-radius: var(--r-md);
    padding: 12px 16px; background: var(--surface);
}
.project-list .project-name { font-weight: 600; color: var(--heading); }
.paste-fallback { margin: 16px 0; }
.paste-fallback summary { color: var(--muted); cursor: pointer; font-size: var(--fs-sm); }

/* Live progress (Working.razor) — calm, honest streaming status; replaces the frozen overlay. */
.working-live { display: flex; align-items: center; gap: 14px; margin: 16px 0; padding: 14px 18px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.working-live .working-msg { margin: 0; color: var(--heading); font-weight: 500; }
.working-live .working-phase { margin: 4px 0 0; font-size: var(--fs-sm); }
.working-live .charcount { margin: 0; }
.spinner { flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: unfold-spin 0.8s linear infinite; }
@@keyframes unfold-spin { to { transform: rotate(360deg); } }
@@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
.charcount { font-size: var(--fs-sm); margin-top: 4px; }

/* ---- Interactive board canvas (BoardCanvas.razor + board.js) ---- */
.board-toolbar { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.board-toolbar .board-hint { margin-right: auto; font-size: var(--fs-sm); }
.board-viewport {
    position: relative; overflow: hidden; height: 68vh; min-height: 420px;
    border: 1px solid var(--border); border-radius: var(--r-md);
    background: var(--surface);
    background-image: radial-gradient(circle, color-mix(in srgb, var(--border) 70%, transparent) 1px, transparent 1px);
    background-size: 22px 22px; touch-action: none; cursor: grab;
}
.board-viewport:fullscreen { height: 100vh; border-radius: 0; }
.board-surface { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }
.board-surface .sticky {
    position: absolute; padding: 9px 12px; border-radius: 6px; font-size: var(--fs-sm);
    box-shadow: 0 1px 3px rgba(0,0,0,.12); overflow: hidden;
}
.board-surface .sticky b { display: block; font-size: var(--fs-md); margin-bottom: 2px; line-height: 1.25; }
.board-surface .sticky small { opacity: .75; font-size: var(--fs-xs); }
.board-surface .board-area { position: absolute; font-size: var(--fs-xl); font-weight: 600; color: var(--heading); }
/* EventStorming colours (carried from BoardRenderer) */
.stk-thing { background: #F3D34A; color: #3D3206; }
.stk-do { background: #5B9BD5; color: #fff; }
.stk-recorded { background: #E8924A; color: #fff; }
.stk-rule, .stk-gate { background: #B58Fd6; color: #fff; }
.stk-list { background: #7FB77E; color: #fff; }
.board-surface .sticky.added { outline: 3px solid #2fb344; outline-offset: 1px; }
.board-surface .sticky.ghost { opacity: .45; filter: grayscale(.6); border: 1px dashed currentColor; }
.board-surface .sticky.ghost b { text-decoration: line-through; }
.confirm-card .opts label { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-md); color: var(--ink-soft); cursor: pointer; }
.confirm-card input[type="radio"] { accent-color: var(--accent-strong); }

.blueprint { list-style: none; margin: 4px 0 24px; padding: 0; }
.blueprint li {
    border-left: 3px solid var(--accent); background: var(--surface);
    border-radius: var(--r-sm); padding: 8px 12px; margin-bottom: 6px; color: var(--ink-soft);
}
.blueprint li.flagged { border-left-color: var(--band-fair); background: var(--band-fair-wash); }
.blueprint li strong { color: var(--ink); }

.repo-label { display: block; font-weight: 600; color: var(--ink); margin: 20px 0 4px; }
.repo-input {
    width: 100%; margin: 4px 0 16px; padding: 8px 12px;
    border: 1px solid var(--border-strong); border-radius: var(--r-sm);
    font-family: var(--font-ui); font-size: var(--fs-md); color: var(--ink); background: var(--bg);
}
.repo-check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--ink-soft); margin: 0 0 16px; }
.repo-check input { width: auto; accent-color: var(--accent-strong); }
.fill-opt {
    align-items: flex-start; gap: 8px; padding: 12px 16px; margin: 0 0 20px;
    border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); line-height: 1.5;
}
.fill-opt input { margin-top: 3px; }
.fill-opt strong { color: var(--ink); }

/* ---- responsive ---- */
@media (max-width: 900px) {
    .cards, .cards-3 { grid-template-columns: repeat(2, 1fr); }
    .steps { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    .cards, .cards-3 { grid-template-columns: 1fr; }
    .nav-links a:not(.btn) { display: none; }
    .footer-meta { text-align: left; justify-content: flex-start; }
    .hero h1 { font-size: var(--fs-3xl); }
}

/* ---- motion (§5) ---- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* keep the framework error boundary readable */
.blazor-error-boundary { background: var(--band-critical); color: var(--band-critical-solid-ink); padding: 16px; }
.blazor-error-boundary::after { content: "An error has occurred."; }
h1:focus { outline: none; }

/* ---- the "I'm working" overlay (working.js sets data-working on <html> at form submit; Blazor's
   enhanced-nav attribute merge strips it when the response lands — self-dismissing). ---- */
html[data-working]::before {
  content: ""; position: fixed; inset: 0; z-index: 9998; pointer-events: auto;
  background: color-mix(in srgb, var(--bg) 72%, transparent); backdrop-filter: blur(2px);
}
html[data-working]::after {
  content: attr(data-working); position: fixed; z-index: 9999;
  top: 38%; left: 50%; transform: translateX(-50%);
  max-width: 30rem; padding: 18px 26px 18px 56px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md, 10px);
  color: var(--ink); font-size: var(--fs-lg, 16px); line-height: 1.5;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .18);
  border-left: 3px solid var(--accent);
  padding-left: 26px;
  animation: unfold-working-pulse 1.6s ease-in-out infinite;
}
@keyframes unfold-working-pulse {
  0%, 100% { border-left-color: var(--accent); }
  50% { border-left-color: var(--border); }
}
