/* ==========================================================================
   DAVID_OS · Front Gate (public landing page) — v0.1
   Zone 2 · Hospitality · Guardian: Stag · Archetype: Edwardian park-pavilion
   gateway. Authority pairing (Lion + Dragon) per invariant 16.

   Conforms to DAVID_OS Visual Constitution v1.1 LOCKED.
   No raw hex in this file — every colour comes from tokens.css.
   No external requests: no web fonts, no CDNs, no trackers.
   ========================================================================== */

/* --- 1 · Shell ---------------------------------------------------------- */

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

:root {
  --shell:        var(--stag-parchment);
  --shell-raised: var(--lion-ivory);
  --text:         var(--ink-deep);
  --text-muted:   var(--ink-mid);
  --rule:         var(--rule-hair);
  --accent:       var(--stag-emerald);
  /* Invariant 6 governs this choice. Stag Bronze (the zone's natural warm hue)
     measures 3.01:1 on parchment — below the 4.5:1 floor for text. The
     Constitution's own remedy is to fall back to another locked hue rather than
     invent one, so text-bearing warm marks use Beaver Walnut (8.27:1) in light
     mode. Bronze returns in dark mode, where it measures 4.95:1 and passes. */
  --accent-warm:  var(--beaver-walnut);

  --measure: 34rem;
  --gutter: clamp(1.25rem, 5vw, 4rem);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua",
           Georgia, "Times New Roman", serif;
  --sans:  "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono:  "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;

  color-scheme: light dark;
}

/* Invariant 7 — dark mode inverts the SHELL. Guardian hues never change. */
@media (prefers-color-scheme: dark) {
  :root {
    --shell:        var(--ink-deep);
    --shell-raised: var(--beaver-ink);
    --text:         var(--stag-parchment);
    --text-muted:   var(--swan-pewter);
    --rule:         var(--beaver-walnut);
    --accent:       var(--bear-honey);
    --accent-warm:  var(--stag-bronze);
  }
}

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

body {
  margin: 0;
  background: var(--shell);
  color: var(--text);
  font-family: var(--serif);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
  line-height: 1.65;
  /* Invariant 11 — texture supports hue. A woven grain, not an image file. */
  background-image:
    repeating-linear-gradient(90deg,  color-mix(in srgb, var(--text) 2.5%, transparent) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(0deg,   color-mix(in srgb, var(--text) 2%,   transparent) 0 1px, transparent 1px 4px);
}

.wrap { max-width: 78rem; margin: 0 auto; padding: 0 var(--gutter); }
.prose { max-width: var(--measure); }

/* --- 2 · Type ----------------------------------------------------------- */

h1, h2, h3, h4 { font-weight: 600; line-height: 1.15; text-wrap: balance; margin: 0; }
p { text-wrap: pretty; }

.eyebrow {
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.9rem;
}

.lede { font-size: 1.22em; line-height: 1.5; color: var(--text); }
.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; line-height: 1.55; }
.mono { font-family: var(--mono); font-size: 0.82em; letter-spacing: -0.01em; }

a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);   /* Invariant 10 — focus = accent */
  outline-offset: 3px;
  border-radius: 2px;
}

/* --- 3 · Masthead (the Front Gate) -------------------------------------- */

.masthead {
  padding: clamp(3rem, 9vh, 6.5rem) 0 clamp(2rem, 6vh, 4rem);
  border-bottom: 1px solid var(--rule);
}

.seal {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 2.25rem;
}

/* Authority pairing · invariant 16 — Lion and Dragon are never shown alone
   in an external pitch. These are typographic seals, NOT the commissioned
   notification avatars (LD-002): the avatar artwork is not yet produced. */
.seal-mark {
  width: 2.6rem; height: 2.6rem; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--sans);
  font-size: 0.95rem; font-weight: 700; letter-spacing: 0.02em;
}
.seal-mark--lion   { background: var(--lion-ivory);     color: var(--lion-burgundy);   box-shadow: inset 0 0 0 2px var(--lion-gold); }
.seal-mark--dragon { background: var(--dragon-burgundy); color: var(--dragon-gold);    box-shadow: inset 0 0 0 2px var(--dragon-gold); }
.seal-text { font-family: var(--sans); font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); }

.wordmark {
  font-family: var(--sans);
  font-weight: 300;
  font-size: clamp(2.7rem, 9vw, 5.75rem);
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 1.5rem;
}
.wordmark b { font-weight: 700; }
.wordmark .u { color: var(--accent-warm); font-weight: 300; }

.masthead .lede { max-width: 42rem; }

.gate-note {
  margin-top: 2.5rem;
  padding: 1rem 1.25rem;
  border-left: 3px solid var(--stag-emerald);
  background: color-mix(in srgb, var(--shell-raised) 55%, transparent);
  max-width: 42rem;
}

/* --- 4 · Sections ------------------------------------------------------- */

section { padding: clamp(3rem, 8vh, 5.5rem) 0; border-bottom: 1px solid var(--rule); }
section:last-of-type { border-bottom: 0; }

.sec-head { display: flex; gap: 1.25rem; align-items: baseline; margin-bottom: 2rem; }
.sec-num {
  font-family: var(--mono); font-size: 0.8rem; color: var(--accent-warm);
  flex: none; padding-top: 0.35rem;
}
.sec-head h2 { font-size: clamp(1.5rem, 3.4vw, 2.15rem); }
.sec-head .sub { font-family: var(--sans); font-size: 0.85rem; color: var(--text-muted); margin-top: 0.35rem; }

/* --- 5 · Cards & grids -------------------------------------------------- */

/* Cells carry their own hairline via box-shadow rather than the container
   showing through a 1px gap — otherwise a row with leftover columns renders
   as a solid slab of rule colour. */
.grid { display: grid; gap: 1px; background: var(--shell); border: 1px solid var(--rule); }
.grid > * { background: var(--shell); padding: 1.4rem 1.5rem; box-shadow: 0 0 0 1px var(--rule); }

/* Explicit column counts so item counts divide evenly (4 → 2×2, 6 → 2×3,
   8 → 2×4) instead of leaving ragged tails. */
.grid--2 { grid-template-columns: 1fr; }
.grid--3 { grid-template-columns: 1fr; }
.grid--4 { grid-template-columns: 1fr; }

@media (min-width: 40rem) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 62rem) {
  .grid--3 { grid-template-columns: repeat(3, 1fr); }
  .grid--4 { grid-template-columns: repeat(4, 1fr); }
}

.card-title { font-family: var(--sans); font-size: 0.95rem; font-weight: 600; margin-bottom: 0.5rem; }
.card p { margin: 0.5rem 0 0; font-size: 0.92rem; line-height: 1.55; }

/* --- 6 · The Four Layers (interactive) ---------------------------------- */

.layers { border: 1px solid var(--rule); }
.layer {
  border-bottom: 1px solid var(--rule);
  background: var(--shell);
}
.layer:last-child { border-bottom: 0; }

.layer > summary {
  display: grid;
  grid-template-columns: 3.2rem 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 1.15rem 1.4rem;
  cursor: pointer;
  list-style: none;
  transition: background 120ms ease;
}
.layer > summary::-webkit-details-marker { display: none; }
.layer > summary:hover { background: color-mix(in srgb, var(--shell-raised) 60%, transparent); }

.layer-id { font-family: var(--mono); font-size: 0.78rem; color: var(--accent-warm); }
.layer-name { font-family: var(--sans); font-weight: 600; font-size: 1.02rem; }
.layer-claim { font-size: 0.88rem; color: var(--text-muted); font-style: italic; }
.layer-open { font-family: var(--mono); font-size: 0.95rem; color: var(--text-muted); }
.layer[open] .layer-open { transform: rotate(45deg); }
.layer-open { display: inline-block; transition: transform 160ms ease; }

.layer-body { padding: 0 1.4rem 1.5rem 5.6rem; }
.layer-body p { margin: 0 0 0.75rem; max-width: var(--measure); }
.layer-body dl { margin: 1rem 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1.1rem; font-size: 0.88rem; }
.layer-body dt { font-family: var(--sans); font-weight: 600; color: var(--text-muted); }
.layer-body dd { margin: 0; }

@media (max-width: 34rem) {
  .layer > summary { grid-template-columns: 1fr auto; }
  .layer-id { display: none; }
  .layer-body { padding-left: 1.4rem; }
}

/* --- 7 · Truth Stack table ---------------------------------------------- */

.stack { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.stack th, .stack td { text-align: left; padding: 0.85rem 1rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.stack th { font-family: var(--sans); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
.stack tbody tr:last-child td { border-bottom: 0; }
.stack .layer-cell { font-family: var(--sans); font-weight: 600; white-space: nowrap; }

.table-scroll { overflow-x: auto; border: 1px solid var(--rule); }
.table-scroll table { min-width: 42rem; }

/* --- 8 · Status badges -------------------------------------------------- */

.status {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-family: var(--sans); font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.22rem 0.55rem; border-radius: 2px;
  white-space: nowrap;
  border: 1px solid currentColor;
}
.status::before { content: ""; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: currentColor; }

.status--live       { color: var(--stag-emerald); }
.status--qualified  { color: var(--dolphin-sea); }
.status--build      { color: var(--beaver-walnut); }  /* brass fails AA on parchment */
.status--designed   { color: var(--owl-violet); }
.status--planned    { color: var(--text-muted); }
.status--private    { color: var(--wolf-charcoal); }
.status--published  { color: var(--peacock-plumage); }

@media (prefers-color-scheme: dark) {
  .status--live      { color: var(--bear-honey); }
  .status--qualified { color: var(--dolphin-turquoise); }
  /* Walnut is unreadable on an ink shell — brass is the dark-mode equivalent. */
  .status--build     { color: var(--badger-brass); }
  .status--private   { color: var(--swan-pewter); }
  .status--designed  { color: var(--robin-wheat); }
  .status--published { color: var(--dolphin-pearl); }
}

/* --- 9 · Embassy zone map ----------------------------------------------- */

/* Zone hues live here, not in the markup — colour never appears in HTML, and a
   strict Content-Security-Policy needs no inline style attribute to allow. */
.zone--authority    { --zone-hue: var(--lion-gold); }
.zone--hospitality  { --zone-hue: var(--stag-emerald); }
.zone--trust        { --zone-hue: var(--swan-pewter); }
.zone--knowledge    { --zone-hue: var(--owl-indigo); }
.zone--connection   { --zone-hue: var(--robin-cardinal); }
.zone--creation     { --zone-hue: var(--peacock-eye); }
.zone--performance  { --zone-hue: var(--wolf-steel); }
.zone--stewardship  { --zone-hue: var(--tortoise-bronze); }

.zone { position: relative; padding-left: 1.5rem; }
.zone::before {
  content: ""; position: absolute; left: 0; top: 1.45rem; bottom: 1.4rem;
  width: 4px; border-radius: 2px; background: var(--zone-hue, var(--rule));
}
.zone .zone-n { font-family: var(--mono); font-size: 0.72rem; color: var(--text-muted); }
.zone h3 { font-family: var(--sans); font-size: 0.98rem; margin: 0.25rem 0 0.55rem; }
.zone .rooms { margin: 0.7rem 0 0; padding: 0; list-style: none; font-size: 0.86rem; }
.zone .rooms li { padding: 0.28rem 0; border-top: 1px dotted var(--rule); display: flex; justify-content: space-between; gap: 0.75rem; }
.zone .rooms li:first-child { border-top: 0; }
.zone .rooms .rm { color: var(--text); }
.zone .rooms .st { font-family: var(--sans); font-size: 0.66rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; padding-top: 0.18rem; }

/* --- 10 · Spine (DNSL stages) ------------------------------------------- */

.spine { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 1.5rem 0 0; padding: 0; list-style: none; }
.spine li {
  font-family: var(--mono); font-size: 0.74rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--rule);
  background: var(--shell-raised);
  color: var(--text);
}
.spine li b { color: var(--accent-warm); font-weight: 600; }

/* --- 11 · Maturity ladder ----------------------------------------------- */

.ladder { list-style: none; margin: 0; padding: 0; counter-reset: rung; }
.ladder li {
  display: grid; grid-template-columns: 2.4rem 1fr; gap: 1.1rem;
  padding: 1.05rem 0; border-top: 1px solid var(--rule);
}
.ladder li:first-child { border-top: 0; }
.rung {
  font-family: var(--mono); font-size: 0.78rem;
  width: 2.4rem; height: 2.4rem; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--rule); color: var(--text-muted);
}
.ladder li[data-here] .rung { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.ladder h4 { font-family: var(--sans); font-size: 0.95rem; margin-bottom: 0.3rem; }
.ladder .here-tag {
  font-family: var(--sans); font-size: 0.64rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--accent); margin-left: 0.6rem;
}
.ladder ul { margin: 0.5rem 0 0; padding-left: 1.1rem; font-size: 0.87rem; color: var(--text-muted); }

/* --- 12 · Register ------------------------------------------------------ */

.reg { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.reg th, .reg td { text-align: left; padding: 0.8rem 1rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.reg th { font-family: var(--sans); font-size: 0.7rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
.reg tbody tr:last-child td { border-bottom: 0; }
.reg .sys { font-family: var(--sans); font-weight: 600; white-space: nowrap; }
.reg .ev { color: var(--text-muted); font-size: 0.84rem; }

/* --- 13 · Entrances ----------------------------------------------------- */

.doors { display: grid; gap: 1px; background: var(--shell); border: 1px solid var(--rule); grid-template-columns: 1fr; }
@media (min-width: 52rem) { .doors { grid-template-columns: repeat(3, 1fr); } }
.door { background: var(--shell); padding: 1.6rem 1.5rem; display: flex; flex-direction: column; gap: 0.6rem; box-shadow: 0 0 0 1px var(--rule); }
.door h3 { font-family: var(--sans); font-size: 1rem; }
.door p { margin: 0; font-size: 0.9rem; color: var(--text-muted); flex: 1; }
.door .act { font-family: var(--sans); font-size: 0.84rem; font-weight: 600; color: var(--accent); }
.door .act[data-shut] { color: var(--text-muted); font-weight: 400; font-style: italic; }

/* --- 14 · Roadmap ------------------------------------------------------- */

.road { list-style: none; margin: 0; padding: 0; }
.road li { display: grid; grid-template-columns: 4.5rem 1fr; gap: 1.2rem; padding: 0.9rem 0; border-top: 1px solid var(--rule); align-items: baseline; }
.road li:first-child { border-top: 0; }
.road .v { font-family: var(--mono); font-size: 0.85rem; color: var(--accent-warm); }
.road b { font-family: var(--sans); font-size: 0.94rem; display: block; margin-bottom: 0.2rem; }
.road span { font-size: 0.88rem; color: var(--text-muted); }
.road li[data-now] .v { color: var(--accent); font-weight: 700; }

/* --- 15 · Non-claims ---------------------------------------------------- */

.disclaim {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--wolf-red);
  padding: 1.4rem 1.6rem;
  background: var(--shell-raised);
}
.disclaim ul { margin: 0.8rem 0 0; padding-left: 1.15rem; font-size: 0.9rem; }
.disclaim li { margin-bottom: 0.45rem; }

/* --- 16 · Colophon ------------------------------------------------------ */

.colophon { padding: 3rem 0 4rem; font-size: 0.84rem; color: var(--text-muted); }
.colophon dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.45rem 1.4rem; margin: 1.2rem 0 0; }
.colophon dt { font-family: var(--sans); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; }
.colophon dd { margin: 0; }
.colophon .rule { height: 1px; background: var(--rule); margin: 0 0 2rem; }

/* --- 17 · Flow utilities ------------------------------------------------
   Every one of these replaced an inline style attribute. The page now carries
   zero `style="…"` in its markup, so the deployed Content-Security-Policy can
   set `style-src 'self'` with no 'unsafe-inline' escape hatch. */

.flush      { margin: 0; }
.follow     { margin: 1.1rem 0 0; }
.after-sm   { margin: 1rem 0 0; }
.after-xs   { margin: 1.25rem 0 0; }
.after      { margin: 1.75rem 0 0; }
.after-md   { margin: 2rem 0 0; }
.after-lg   { margin: 2.5rem 0 0; }

.lead-in        { margin: 0 0 2rem; }      /* section-opening paragraph */
.lead-in--sm    { margin-bottom: 1.5rem; }
.lead-in--xs    { margin-bottom: 1.25rem; }

.sub-head        { font-family: var(--sans); font-size: 1rem; margin: 3rem 0 0.35rem; }
.sub-head--near  { margin-top: 2.5rem; }

.colophon-name   { margin: 0 0 0.4rem; }
.colophon-intro  { max-width: 44rem; }
.colophon-tail   { margin: 1.6rem 0 0; font-size: 0.8rem; }

/* --- 18 · Print --------------------------------------------------------- */

@media print {
  body { background: #fff; color: #000; background-image: none; }
  .layer-body { display: block !important; }
  section { break-inside: avoid; }
}

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