/* smie.ai site shell (WP2, Phase D). Self-contained, zero external requests.
   Tokens per C2 v1.2 F7. Accents only on verification states. */

/* --- Typography (WP7 gate PASSED): self-hosted variable woff2, SIL OFL 1.1.
   Schibsted Grotesk is the UI family (display 700 / heading 600 / body 400-500 /
   utility 400); JetBrains Mono is used ONLY inside proof/artifact fragments.
   Provenance-verified assets; OFL license files ship alongside in assets/fonts/. --- */
@font-face {
  font-family: "Schibsted Grotesk";
  src: url("/assets/fonts/schibsted-grotesk-variable.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  font-style: normal;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/jetbrains-mono-variable.woff2") format("woff2");
  font-weight: 400 500;
  font-display: swap;
  font-style: normal;
}

:root {
  /* Colour tokens */
  --paper: #FAF8F4;
  --ink: #1A1A18;
  --ink-2: #57534E;
  --line: #E5E0D8;
  --verify: #1D6E4C;
  --fail: #A8322B;
  --pending: #8A6D1F;

  --sans: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", "Segoe UI Mono", Consolas, monospace;
  /* Font stacks: self-hosted family first, retained fallback stack behind. */

  /* Type scale, 1.25 ratio */
  --t-14: 0.875rem;
  --t-16: 1rem;
  --t-20: 1.25rem;
  --t-25: 1.5625rem;
  --t-31: 1.9375rem;
  --t-39: 2.4375rem;
  --t-49: 3.0625rem;

  /* Grid */
  --maxw: 1200px;
  --gutter: 24px;
  --pad: 24px;

  /* Motion */
  --motion: 180ms;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--t-16);
  line-height: 1.55;
  font-feature-settings: "liga" 1;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }

/* The hidden attribute must always win over element display rules (e.g. .btn,
   act-state toggles, the withdraw control before a grant, the contact notice). */
[hidden] { display: none !important; }

/* Multi-line act artifact values (e.g. one security finding per line) stay readable. */
.artifact-list .art-val { white-space: pre-line; }

a { color: var(--ink); text-underline-offset: 0.15em; }
a:hover { color: var(--verify); }

h1, h2, h3 { line-height: 1.15; font-weight: 700; margin: 0 0 0.4em; letter-spacing: -0.01em; }
h1 { font-size: var(--t-39); }
h2 { font-size: var(--t-25); font-weight: 600; }
h3 { font-size: var(--t-20); font-weight: 600; }
p { margin: 0 0 1rem; max-width: 62ch; }

/* --- Focus: always visible, never suppressed --- */
:focus-visible {
  outline: 3px solid var(--verify);
  outline-offset: 2px;
  border-radius: 2px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 0.6em 1em;
  z-index: 100;
}
.skip:focus { left: 0; color: var(--paper); }

/* --- Layout --- */
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad); }
main { display: block; }
section { padding: clamp(2.5rem, 6vw, 5rem) 0; border-top: 1px solid var(--line); }
section:first-child { border-top: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--gutter);
}

/* --- Header / nav --- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem var(--pad);
  max-width: var(--maxw);
  margin: 0 auto;
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: var(--t-20); text-decoration: none; letter-spacing: -0.02em; }
.site-nav { display: flex; gap: 1.1rem; flex-wrap: wrap; align-items: center; }
.nav-routes { display: flex; gap: 1.1rem; flex-wrap: wrap; align-items: center; list-style: none; margin: 0; padding: 0; }
.nav-routes li { display: inline-flex; }
.site-nav a { text-decoration: none; font-size: var(--t-16); }
.site-nav a:hover, .site-nav a:focus-visible { text-decoration: underline; }
/* System-lane link: mechanically and visually distinct from the route group. */
.nav-system[data-nav-lane="system"] { font-weight: 700; border: 1px solid var(--line); border-radius: 4px; padding: 0.2em 0.6em; color: var(--ink); }
/* Sole current-destination state (semantic aria-current + visible marker). */
.site-nav a[aria-current="page"] { font-weight: 600; text-decoration: underline; text-underline-offset: 0.3em; }
.header-actions { display: flex; align-items: center; gap: 0.75rem; }
.lang { text-decoration: none; font-size: var(--t-14); border: 1px solid var(--line); padding: 0.35em 0.7em; border-radius: 4px; }
.nav-toggle { display: none; }

/* --- Buttons / CTAs --- */
.btn {
  display: inline-block;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  padding: 0.7em 1.2em;
  border-radius: 4px;
  font-weight: 600;
  border: 1px solid var(--ink);
  transition: transform var(--motion) ease, opacity var(--motion) ease;
}
.btn:hover { color: var(--paper); transform: translateY(-1px); }
.btn--ghost { background: transparent; color: var(--ink); }
.btn--ghost:hover { color: var(--ink); }

/* --- Hero --- */
.hero { padding-top: clamp(2.5rem, 7vw, 5.5rem); }
.hero h1 { font-size: clamp(var(--t-31), 4.5vw, var(--t-49)); max-width: 20ch; }
.hero .sub { font-size: var(--t-20); color: var(--ink-2); max-width: 40ch; }

/* --- Situation picker --- */
.picker { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gutter); }
.picker__card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.5rem;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.picker__tag { font-size: var(--t-14); color: var(--ink-2); font-weight: 600; }
.picker__card p { margin: 0; }
.picker__card .btn { align-self: flex-start; margin-top: auto; }
.picker__neutral { color: var(--ink-2); margin-top: 1rem; }

/* --- Proof strip --- */
.proof { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: var(--gutter); align-items: start; }
.proof__aside { display: flex; flex-direction: column; gap: 1rem; }
.operator { display: flex; gap: 1rem; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 1rem; background: #fff; }
.operator img { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }
.operator .name { font-weight: 700; }
.operator .role { color: var(--ink-2); font-size: var(--t-14); margin: 0; }
.prices-line { display: flex; flex-direction: column; gap: 0.4rem; border: 1px solid var(--line); border-radius: 8px; padding: 1rem; background: #fff; }

/* --- bevismarg: the single signature component --- */
/* A functional claim/proof margin. Every material claim is bound to a method,
   condition or evidence state rendered in the margin rail. Condition tables,
   certificate cards and artifact fragments are content formats WITHIN it. */
.bevismarg {
  display: grid;
  grid-template-columns: minmax(150px, 0.32fr) 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
.bevismarg__rail {
  border-right: 1px solid var(--line);
  background: var(--paper);
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  font-size: var(--t-14);
}
.bevismarg__rail dt { color: var(--ink-2); font-weight: 600; }
.bevismarg__rail dd { margin: 0 0 0.5rem; }
.bevismarg__body { padding: 1.25rem; }
.bevismarg__body > :last-child { margin-bottom: 0; }

/* Evidence-state chip: colour plus a text label plus a shape (never colour alone). */
.state { display: inline-flex; align-items: center; gap: 0.4em; font-weight: 600; font-size: var(--t-14); }
.state::before { content: ""; width: 0.7em; height: 0.7em; border-radius: 2px; display: inline-block; }
.state--verify { color: var(--verify); }
.state--verify::before { background: var(--verify); }
.state--fail { color: var(--fail); }
.state--fail::before { background: var(--fail); transform: rotate(45deg); }
.state--pending { color: var(--pending); }
.state--pending::before { background: var(--pending); border-radius: 50%; }

/* Condition table content format */
.cond-table { width: 100%; border-collapse: collapse; font-size: var(--t-16); }
.cond-table caption { text-align: left; font-weight: 600; padding-bottom: 0.6rem; }
.cond-table th, .cond-table td { text-align: left; vertical-align: top; padding: 0.55rem 0.8rem 0.55rem 0; border-bottom: 1px solid var(--line); }
.cond-table th { color: var(--ink-2); font-weight: 600; width: 34%; white-space: nowrap; }
.cond-table tr:last-child th, .cond-table tr:last-child td { border-bottom: 0; }

/* Certificate card content format */
.cert__title { font-weight: 700; font-size: var(--t-20); margin: 0 0 0.75rem; }
.cert__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.cert__list li { display: grid; grid-template-columns: 1.6em 1fr; gap: 0.5rem; align-items: baseline; }
.cert__n { font-weight: 700; color: var(--verify); }
.cert__name { font-weight: 600; }

/* Artifact fragment content format: mono ONLY here */
.artifact { }
.artifact pre {
  font-family: var(--mono);
  font-size: var(--t-14);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1rem;
  margin: 0 0 0.5rem;
  overflow-x: auto;
  line-height: 1.5;
}
.artifact figcaption { color: var(--ink-2); font-size: var(--t-14); }

/* --- Route grid --- */
.route-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gutter); }
.route-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.25rem;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--ink);
  transition: transform var(--motion) ease;
}
.route-card:hover { color: var(--ink); transform: translateY(-2px); }
.route-card .act { font-weight: 700; }
.route-card .free { color: var(--ink-2); font-size: var(--t-14); margin: 0; }

/* --- Staircase --- */
.stair { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gutter); counter-reset: none; }
.stair__step { border: 1px solid var(--line); border-radius: 8px; padding: 1.1rem; background: #fff; }
.stair__name { font-weight: 700; }
.stair__price { color: var(--ink-2); }
.stair__step p { margin: 0.4rem 0 0; font-size: var(--t-14); }

/* --- Price list --- */
.price-list { display: grid; gap: 0.75rem; }
.price-row { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem 1rem; border-bottom: 1px solid var(--line); padding-bottom: 0.75rem; align-items: baseline; }
.price-row .pname { font-weight: 700; }
.price-row .pval { font-weight: 600; text-align: right; }
.price-row .pnote { grid-column: 1 / -1; color: var(--ink-2); font-size: var(--t-14); margin: 0; }
.proposed-tag { display: inline-block; font-size: var(--t-14); color: var(--pending); font-weight: 600; margin-left: 0.5em; }

/* --- Route capabilities (named beneath the outcome, never a leading tool list) --- */
.caps-intro { color: var(--ink-2); font-weight: 600; margin-bottom: 0.4rem; }
.caps { list-style: none; margin: 0 0 1.5rem; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; max-width: none; }
.caps li { border: 1px solid var(--line); border-radius: 999px; padding: 0.3em 0.85em; font-size: var(--t-14); background: #fff; }

/* --- Free-act widget: visible state surface (WP4 wires behaviour) --- */
.act-widget {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 1.25rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
}
.act-form, .act-form .fields, .act-form .field { min-width: 0; }
.act-form :where(input, select, textarea) { width: 100%; max-width: 100%; }
.act-form .field[hidden] { display: none; }
.act-state { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
/* Only the empty state is shown by default; WP4 toggles [hidden] as the act runs.
   Higher specificity than .act-state so the hidden attribute is honoured. */
.act-state[hidden] { display: none; }
.act-state p { margin: 0; }
.act-state[data-act-state="empty"] { color: var(--ink); }
.act-state[data-act-state="success"] { border-left: 3px solid var(--verify); padding-left: 0.75rem; }
.act-state[data-act-state="blocked"], .act-state[data-act-state="failure"] { color: var(--ink-2); }
.act-never { color: var(--ink-2); font-size: var(--t-14); }
.continuation { font-weight: 600; }

/* --- Condition matrices (route + system), rendered within bevismarg / cards --- */
.matrix-list { display: grid; gap: var(--gutter); }
.matrix { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 1.1rem; }
.matrix .proposal-label { display: inline-block; font-size: var(--t-14); color: var(--pending); font-weight: 600; margin-bottom: 0.5rem; }
.matrix-table { width: 100%; border-collapse: collapse; font-size: var(--t-16); }
.matrix-table caption { text-align: left; font-weight: 700; padding-bottom: 0.6rem; }
.matrix-table th, .matrix-table td { text-align: left; vertical-align: top; padding: 0.5rem 0.8rem 0.5rem 0; border-bottom: 1px solid var(--line); }
.matrix-table th { color: var(--ink-2); font-weight: 600; width: 30%; }
.matrix-table tr:last-child th, .matrix-table tr:last-child td { border-bottom: 0; }
.ladder-note { margin-top: 1rem; color: var(--ink-2); font-size: var(--t-14); font-weight: 600; }
.proposal-label { color: var(--pending); font-weight: 600; }

/* --- Artifact fields (proof decision/evidence/limitations) --- */
.artifact-fields { list-style: none; margin: 0.75rem 0 0; padding: 0; display: grid; gap: 0.35rem; font-size: var(--t-14); }
.artifact-fields li { padding-left: 1rem; position: relative; }
.artifact-fields li::before { content: ""; position: absolute; left: 0; top: 0.55em; width: 0.4em; height: 0.4em; background: var(--verify); border-radius: 2px; }

/* --- Font proof page --- */
.fp-list { display: grid; gap: 1rem; }
.fp-row { border-bottom: 1px solid var(--line); padding-bottom: 1rem; }
.fp-label { display: block; font-size: var(--t-14); color: var(--ink-2); font-weight: 600; margin-bottom: 0.3rem; }
.fp-sample { margin: 0; max-width: none; }

/* --- WP3 slots (structured stubs) --- */
.slot {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 1.5rem;
  background: #fff;
}
.slot__label { font-weight: 600; }
.slot__note { color: var(--ink-2); font-size: var(--t-14); margin: 0.4rem 0 0; }
.wp3-note { color: var(--ink-2); font-size: var(--t-14); }

/* --- Contact block --- */
.contact-block { display: grid; gap: 0.6rem; font-size: var(--t-20); }
.contact-block a { font-weight: 600; }

/* --- Footer --- */
.site-footer { border-top: 1px solid var(--line); padding: 2.5rem 0; margin-top: 2rem; }
.site-footer .wrap { display: grid; gap: 1rem; }
.footer-contact { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; }
.footer-contact a, .footer-contact span { font-size: var(--t-16); }
.footer-meta { color: var(--ink-2); font-size: var(--t-14); display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; }

.lead { font-size: var(--t-20); color: var(--ink-2); max-width: 46ch; }
.tag { font-size: var(--t-14); color: var(--ink-2); font-weight: 600; }
.stack { display: grid; gap: 1.5rem; }
.mt { margin-top: 1.5rem; }

/* --- Mobile: 4-col, 16px gutter --- */
@media (max-width: 720px) {
  :root { --gutter: 16px; --pad: 16px; }
  .grid { grid-template-columns: repeat(4, 1fr); }
  .picker { grid-template-columns: 1fr; }
  .proof { grid-template-columns: 1fr; }
  .route-grid { grid-template-columns: 1fr; }
  .stair { grid-template-columns: 1fr; }
  .bevismarg { grid-template-columns: 1fr; }
  .bevismarg__rail { border-right: 0; border-bottom: 1px solid var(--line); }
  /* Progressive enhancement: without JS the nav stays a visible, usable wrapped
     block below the brand row and NO toggle shows. The collapsed drawer + toggle
     are scoped to .js (added by site.js) so no-JS mobile keeps full navigation. */
  .site-header { flex-wrap: wrap; }
  .site-nav { width: 100%; gap: 0.6rem 1.1rem; }
  .nav-routes { gap: 0.6rem 1.1rem; }
  .js .site-nav {
    width: auto;
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem var(--pad);
    gap: 0.75rem;
    z-index: 40;
  }
  .js .site-nav.open { display: flex; }
  .js .site-nav .nav-routes { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .js .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 4px;
    cursor: pointer;
    color: var(--ink);
    font-size: var(--t-16);
  }
  h1 { font-size: var(--t-31); }
  /* Accepted global mobile rhythm (unchanged from the pre-fold-fix baseline). Applies to
     EVERY route/proof/system/contact page so their mobile vertical rhythm is untouched. */
  section { padding: 1.5rem 0; }
  .hero { padding-top: 1.25rem; }
  .stack { gap: 1rem; }
  .picker__card { padding: 1.1rem; gap: 0.5rem; }
  .picker__neutral { margin-top: 0.6rem; }
  /* Homepage-ONLY real-page fold compression (G-085 boundary 2; resolved on the REAL page
     per G-101/G-104; scope-corrected per G-107). Scoped to the home document via
     data-page="home" (emitted by build.py on both the NO and EN home) so NO other page's
     mobile rhythm changes. Whitespace-only: no type token reduced, no content hidden/
     truncated/clipped, viewport unchanged, accepted desktop layout untouched (all inside
     this mobile media query). Goal: header + complete hero + BOTH complete picker cards
     (incl. CTAs) fit 390x844 at scrollY=0 on the real page, robust across both scrollbar
     surfaces (390 overlay + 375 classic-scrollbar). */
  [data-page="home"] section { padding: 0.5rem 0; }
  [data-page="home"] .hero { padding-top: 0.3rem; }
  [data-page="home"] .hero h1 { max-width: none; }     /* full-measure headline: fewer wrap lines, type unchanged */
  [data-page="home"] .hero .sub { margin-bottom: 0; }  /* remove trailing hero whitespace above the picker */
  [data-page="home"] .stack { gap: 0.4rem; }
  [data-page="home"] .stack > h2 { margin-bottom: 0; } /* stack gap already spaces the heading; drop double margin */
  [data-page="home"] .picker { gap: 7px; }
  [data-page="home"] .picker__card { padding: 0.6rem; gap: 0.25rem; }
  [data-page="home"] .picker__neutral { margin-top: 0.5rem; }
}

/* --- Motion law: opacity/transform only; reduced-motion is instant --- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
