/* ==========================================================================
   FAILSAFE — instrument-panel design system
   OLED black · Chivo Mono · guilloché · half-tone · one red accent
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --fs-black: #000000;            /* page canvas */
  --fs-surface: #0E0E0E;          /* raised card */
  --fs-surface-raised: #171717;   /* nested card */
  --fs-text: #F2F2ED;             /* primary near-white, slightly warm */
  --fs-dim: #858585;              /* secondary text */
  --fs-faint: #4D4D4D;            /* tertiary / disabled */
  --fs-line: rgba(255, 255, 255, 0.10); /* hairline strokes */
  --fs-red: #FF3326;              /* the ONLY accent — critical / alert */

  --font-mono: "Chivo Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    system-ui, sans-serif;

  --pad: 20px;        /* base padding */
  --radius: 14px;     /* card radius */
  --measure: 680px;   /* legal-page reading measure */
}

/* ---------- Reset / base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  background: var(--fs-black);
  color: var(--fs-text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--fs-text);
  text-decoration: none;
}

::selection {
  background: var(--fs-red);
  color: var(--fs-black);
}

/* Keyboard focus — visible instrument outline */
:focus-visible {
  outline: 1px solid var(--fs-text);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 10px 16px;
  background: var(--fs-surface-raised);
  border: 1px solid var(--fs-line);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
}
.skip-link:focus-visible {
  left: 20px;
  top: 20px;
}

/* ---------- Typography ---------- */

/* Signature micro-label: instrument etiquette */
.lbl {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--fs-dim);
}

.lbl--faint { color: var(--fs-faint); }
.lbl--bright { color: var(--fs-text); }
.lbl--red { color: var(--fs-red); }

h1, h2, h3 {
  font-family: var(--font-mono);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.prose p {
  color: var(--fs-dim);
  max-width: 62ch;
}
.prose strong {
  color: var(--fs-text);
  font-weight: 600;
}

/* ---------- Layout primitives ---------- */
.wrap {
  width: 100%;
  max-width: 1160px;
  margin-inline: auto;
  padding-inline: var(--pad);
}

.card {
  background: var(--fs-surface);
  border: 1px solid var(--fs-line);
  border-radius: var(--radius);
  padding: var(--pad);
}

.card--raised {
  background: var(--fs-surface-raised);
}

/* Corner registration marks (camera framing ticks) */
.reg {
  position: relative;
}
.reg::before,
.reg::after,
.reg > .reg-b::before,
.reg > .reg-b::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 0 solid var(--fs-faint);
  pointer-events: none;
}
.reg::before        { top: 0;    left: 0;   border-top-width: 1px; border-left-width: 1px; }
.reg::after         { top: 0;    right: 0;  border-top-width: 1px; border-right-width: 1px; }
.reg > .reg-b::before { bottom: 0; left: 0;  border-bottom-width: 1px; border-left-width: 1px; }
.reg > .reg-b::after  { bottom: 0; right: 0; border-bottom-width: 1px; border-right-width: 1px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.82);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--fs-line);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--pad);
  height: 60px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--fs-text);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 22px;
}

.site-nav a {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--fs-dim);
  transition: color 0.2s ease;
}
.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--fs-text);
}

@media (max-width: 560px) {
  .site-nav .nav-anchor { display: none; } /* keep only page links on small screens */
}

/* ---------- LED status dot ---------- */
.led {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--fs-red);
  box-shadow: 0 0 10px rgba(255, 51, 38, 0.8);
}
.led--grey {
  background: var(--fs-faint);
  box-shadow: none;
}

.status-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 14px 26px;
  border: 1px solid var(--fs-text);
  border-radius: 8px;
  background: var(--fs-text);
  color: var(--fs-black);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.12s ease;
}
.btn:hover {
  background: transparent;
  color: var(--fs-text);
}

.btn--ghost {
  background: transparent;
  color: var(--fs-dim);
  border-color: var(--fs-line);
}
.btn--ghost:hover {
  color: var(--fs-text);
  border-color: var(--fs-dim);
}

/* Press-scale on all interactive elements */
.btn:active,
.site-nav a:active,
.footer-nav a:active,
.text-link:active {
  transform: scale(0.96);
}

.text-link {
  display: inline-block;
  color: var(--fs-text);
  border-bottom: 1px solid var(--fs-faint);
  transition: border-color 0.2s ease;
}
.text-link:hover {
  border-color: var(--fs-text);
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: 96px 0 110px;
  overflow: hidden;
  border-bottom: 1px solid var(--fs-line);
}

/* Guilloché canvas sits behind hero content */
.guilloche {
  position: absolute;
  inset: -10% -5%;
  width: 110%;
  height: 120%;
  opacity: 0.9;
  pointer-events: none;
}

/* Radial falloff so the engraving fades into black at the edges */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 75% 65% at 50% 42%,
    transparent 30%,
    var(--fs-black) 95%
  );
  pointer-events: none;
}

.hero .wrap {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
  padding: 8px 16px;
  border: 1px solid var(--fs-line);
  border-radius: 100px;
  background: rgba(14, 14, 14, 0.6);
}

.hero-title {
  font-family: "Archivo Black", var(--font-sans);
  font-size: clamp(52px, 11vw, 128px);
  font-weight: 400; /* Archivo Black is already a heavy single weight */
  letter-spacing: 0.02em;
  text-indent: 0.02em; /* optically re-center tracked caps */
}

.hero-tag {
  margin-top: 22px;
  font-family: var(--font-mono);
  font-size: clamp(14px, 2.4vw, 19px);
  font-weight: 300;
  color: var(--fs-dim);
  letter-spacing: 0.04em;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 44px;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px 34px;
  margin-top: 64px;
}

/* ---------- Half-tone fields ---------- */

/* CSS dot texture: two layered dot sizes, masked dense→sparse */
.halftone-css {
  position: absolute;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.34) 1.4px, transparent 1.9px),
    radial-gradient(circle, rgba(255, 255, 255, 0.18) 0.9px, transparent 1.4px);
  background-size: 14px 14px, 14px 14px;
  background-position: 0 0, 7px 7px;
}

/* Corner bleed, top-right */
.halftone-css--corner {
  top: 0;
  right: 0;
  width: min(46vw, 520px);
  height: 380px;
  -webkit-mask-image: radial-gradient(ellipse at 100% 0%, black 0%, transparent 72%);
  mask-image: radial-gradient(ellipse at 100% 0%, black 0%, transparent 72%);
}

/* Corner bleed, bottom-left */
.halftone-css--corner-bl {
  bottom: 0;
  left: 0;
  width: min(40vw, 440px);
  height: 320px;
  -webkit-mask-image: radial-gradient(ellipse at 0% 100%, black 0%, transparent 70%);
  mask-image: radial-gradient(ellipse at 0% 100%, black 0%, transparent 70%);
}

/* Section divider: a thin band of dots fading at both ends */
.divider-dots {
  height: 46px;
  margin: 0 auto;
  max-width: 1160px;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.25) 1px, transparent 1.5px);
  background-size: 11px 11px;
  background-position: center;
  -webkit-mask-image: linear-gradient(90deg, transparent, black 35%, black 65%, transparent);
  mask-image: linear-gradient(90deg, transparent, black 35%, black 65%, transparent);
}

/* SVG half-tone (radius-graded, generated by app.js) */
.halftone-svg {
  position: absolute;
  pointer-events: none;
}

/* ---------- Sections ---------- */
.section {
  position: relative;
  padding: 100px 0;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin-bottom: 12px;
}
.section-head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--fs-line);
  align-self: center;
}

.section-title {
  font-size: clamp(26px, 4.4vw, 40px);
  font-weight: 600;
  margin: 10px 0 18px;
}

.section-sub {
  color: var(--fs-dim);
  max-width: 60ch;
  margin-bottom: 54px;
}

/* ---------- Ladder (L0–L5 instrument rows) ---------- */
.ladder {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--fs-line);
  border-radius: var(--radius);
  background: var(--fs-surface);
  overflow: hidden;
}

.rung {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: var(--pad);
  align-items: center;
  padding: 26px var(--pad);
  border-bottom: 1px solid var(--fs-line);
}
.rung:last-child {
  border-bottom: none;
}

.rung-digit {
  display: flex;
  align-items: center;
  gap: 12px;
}
.rung-digit .lbl--faint {
  writing-mode: vertical-rl;
  letter-spacing: 3px;
  font-size: 10px;
}

/* Dot-matrix numeral (SVG injected by app.js; text fallback if no JS) */
.matrix {
  font-family: var(--font-mono);
  font-size: 44px;
  font-weight: 300;
  line-height: 1;
  color: var(--fs-text);
  min-width: 52px;
}
.matrix svg {
  width: 46px;
  height: auto;
}
.matrix--red { color: var(--fs-red); }
.matrix--lg svg { width: 76px; }

.rung-name {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.rung-desc {
  color: var(--fs-dim);
  font-size: 15px;
  max-width: 58ch;
}

.rung-status {
  justify-self: end;
  text-align: right;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

/* Critical rungs (L4/L5): red carries meaning here only */
.rung--critical {
  background: linear-gradient(90deg, rgba(255, 51, 38, 0.05), transparent 55%);
}
.rung--critical .rung-name { color: var(--fs-text); }

@media (max-width: 720px) {
  .rung {
    grid-template-columns: 72px 1fr;
    padding: 22px 16px;
  }
  .rung-status {
    grid-column: 2;
    justify-self: start;
    margin-top: 8px;
  }
  .rung-digit .lbl--faint { display: none; }
  .matrix svg { width: 38px; }
}

/* ---------- Backstop section ---------- */
.backstop {
  position: relative;
  overflow: hidden;
}

.backstop-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: calc(var(--pad) * 2);
  align-items: center;
}
@media (max-width: 860px) {
  .backstop-grid { grid-template-columns: 1fr; }
}

.backstop-points {
  list-style: none;
  margin-top: 34px;
  display: flex;
  flex-direction: column;
}
.backstop-points li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 16px;
  padding: 18px 0;
  border-top: 1px solid var(--fs-line);
}
.backstop-points li:last-child {
  border-bottom: 1px solid var(--fs-line);
}
.backstop-points svg {
  width: 18px;
  height: 18px;
  margin-top: 4px;
  color: var(--fs-faint);
}
.backstop-points strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.backstop-points p {
  color: var(--fs-dim);
  font-size: 15px;
}

/* Pulse-ring instrument panel */
.pulse-panel {
  position: relative;
  aspect-ratio: 1;
  max-width: 440px;
  margin-inline: auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pulse-panel svg {
  width: 100%;
  height: 100%;
}

.ring-pulse {
  transform-origin: center;
  transform-box: fill-box;
}

/* ---------- Trust strip ---------- */
.trust-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--pad);
}
@media (max-width: 980px) {
  .trust-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 540px) {
  .trust-grid { grid-template-columns: 1fr; }
}

.trust-card h3 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  margin: 18px 0 10px;
}
.trust-card p {
  color: var(--fs-dim);
  font-size: 14px;
}
.trust-card svg {
  width: 22px;
  height: 22px;
  color: var(--fs-faint);
}

/* ---------- Final CTA band ---------- */
.cta-band {
  position: relative;
  text-align: center;
  padding: 110px 0;
  border-top: 1px solid var(--fs-line);
  overflow: hidden;
}
.cta-band .matrix--lg {
  display: flex;
  justify-content: center;
  margin-bottom: 26px;
}
.cta-band h2 {
  font-size: clamp(24px, 4vw, 36px);
  margin-bottom: 14px;
}
.cta-band p {
  color: var(--fs-dim);
  margin-bottom: 38px;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--fs-line);
  padding: 54px 0 40px;
}

.footer-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 34px var(--pad);
  margin-bottom: 44px;
}

.footer-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.footer-nav a,
.footer-nav span {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--fs-dim);
  transition: color 0.2s ease;
}
.footer-nav a:hover { color: var(--fs-text); }

.footer-base {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: var(--pad);
  border-top: 1px solid var(--fs-line);
}

/* ---------- Legal pages ---------- */
.legal-main {
  padding: 80px 0 100px;
}

.legal-doc {
  max-width: var(--measure);
  margin-inline: auto;
}

.legal-doc header {
  margin-bottom: 56px;
}

.legal-doc h1 {
  font-size: clamp(30px, 5.5vw, 44px);
  margin: 14px 0 18px;
}

.legal-doc h2 {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--fs-text);
  margin: 56px 0 16px;
  padding-top: 24px;
  border-top: 1px solid var(--fs-line);
  display: flex;
  gap: 14px;
}
.legal-doc h2 .h-index {
  color: var(--fs-faint);
}

.legal-doc h3 {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--fs-dim);
  margin: 28px 0 10px;
}

.legal-doc p,
.legal-doc li {
  color: var(--fs-dim);
  margin-bottom: 14px;
}
.legal-doc strong {
  color: var(--fs-text);
  font-weight: 600;
}
.legal-doc ul,
.legal-doc ol {
  padding-left: 22px;
  margin-bottom: 14px;
}
.legal-doc li { margin-bottom: 8px; }
.legal-doc a:not(.btn) {
  color: var(--fs-text);
  border-bottom: 1px solid var(--fs-faint);
}
.legal-doc a:not(.btn):hover { border-color: var(--fs-text); }

/* Highlighted commitment / notice blocks */
.legal-callout {
  background: var(--fs-surface);
  border: 1px solid var(--fs-line);
  border-radius: var(--radius);
  padding: var(--pad);
  margin: 22px 0;
}
.legal-callout--critical {
  border-color: rgba(255, 51, 38, 0.45);
  background: linear-gradient(135deg, rgba(255, 51, 38, 0.06), var(--fs-surface) 60%);
}
.legal-callout .lbl { display: block; margin-bottom: 10px; }
.legal-callout p:last-child { margin-bottom: 0; }

/* Top-of-page template notice on terms */
.doc-notice {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.6px;
  color: var(--fs-faint);
  border: 1px dashed var(--fs-line);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 40px;
}

/* ---------- Reveal motion (frost-in / stagger) ---------- */
/* Hidden state only applies when JS is running (html.js) so content is
   always visible without JavaScript. All motion opts out for
   prefers-reduced-motion. */
@media (prefers-reduced-motion: no-preference) {
  html.js .reveal {
    opacity: 0;
    transform: translateY(12px);
    filter: blur(6px);
    transition:
      opacity 0.75s cubic-bezier(0.22, 1, 0.36, 1),
      transform 0.75s cubic-bezier(0.22, 1, 0.36, 1),
      filter 0.75s cubic-bezier(0.22, 1, 0.36, 1);
    transition-delay: var(--d, 0ms);
  }
  html.js .in-view .reveal,
  html.js .reveal.in-view {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }

  /* Stagger children ~80ms apart */
  .stagger > .reveal:nth-child(1) { --d: 0ms; }
  .stagger > .reveal:nth-child(2) { --d: 80ms; }
  .stagger > .reveal:nth-child(3) { --d: 160ms; }
  .stagger > .reveal:nth-child(4) { --d: 240ms; }
  .stagger > .reveal:nth-child(5) { --d: 320ms; }
  .stagger > .reveal:nth-child(6) { --d: 400ms; }
  .stagger > .reveal:nth-child(7) { --d: 480ms; }
  .stagger > .reveal:nth-child(8) { --d: 560ms; }

  /* LED blink — soft, watchful */
  .led:not(.led--grey) {
    animation: led-blink 2.2s ease-in-out infinite;
  }
  @keyframes led-blink {
    0%, 100% { opacity: 1; box-shadow: 0 0 10px rgba(255, 51, 38, 0.8); }
    50%      { opacity: 0.35; box-shadow: 0 0 3px rgba(255, 51, 38, 0.3); }
  }

  /* Concentric ring pulse */
  .ring-pulse {
    animation: ring-pulse 4s cubic-bezier(0.2, 0.6, 0.35, 1) infinite;
  }
  .ring-pulse--late { animation-delay: 2s; }
  @keyframes ring-pulse {
    0%   { transform: scale(0.55); opacity: 0; }
    18%  { opacity: 0.5; }
    100% { transform: scale(1.15); opacity: 0; }
  }

  /* Slow ambient drift on the guilloché engraving */
  .guilloche {
    animation: guilloche-drift 46s ease-in-out infinite alternate;
  }
  @keyframes guilloche-drift {
    from { transform: translate3d(0, -1.4%, 0); }
    to   { transform: translate3d(0, 1.4%, 0); }
  }
}

/* Reduced motion: everything static and fully legible */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; filter: none; }
  .ring-pulse { opacity: 0.25; }
}

/* ---------- Small-screen tuning ---------- */
@media (max-width: 560px) {
  .section { padding: 72px 0; }
  .hero { padding: 72px 0 84px; }
  .hero-meta { gap: 12px 20px; }
}
