/* =============================================================================
   OnSiteSafety TrustID — Field Document design layer
   Source of truth: design/01-design-language.md (do not substitute hexes).
   "A security-printed BC construction credential, read in daylight."
   Steel-and-ink neutrals · one hi-vis orange · functional safety-status colour
   · passport-MRZ monospace. Borders over shadows; exactly one shadow exists.
   ========================================================================== */

/* ---- 1. Tokens -------------------------------------------------------------
   Mirrors the Field Document exactly. Kadence theme.json presets are also set,
   but these :root vars are what the components below consume. */
:root {
  /* Document neutrals + brand */
  --paper:       #FFFFFF;
  --paper-sunk:  #F4F6F8;
  --ink:         #1F2933;
  --steel:       #5B6670;
  --brand:       #FFA212;
  --brand-2:     #FD9E34;
  --brand-deep:  #ED8F0C;
  --brand-text:  #B5700A;  /* AA as text on white */
  --carbon:      #1F2933;  /* inversion surface: footer MRZ band, "the gate" */

  /* Functional safety-status — information, never decoration */
  --verified:     #1F7A4D;
  --checking:      #B25E00;
  --expired:     #B42318;

  /* Hairlines (borders over shadows) */
  --hair:        rgba(31, 41, 51, 0.20);
  --hair-soft:   rgba(31, 41, 51, 0.12);

  /* Type roles */
  --font-display: Nunito, ui-rounded, "Segoe UI", system-ui, sans-serif;
  --font-body:    Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  /* Geometry — 4px base grid */
  --radius-card:    4px;   /* generic cards */
  --radius-input:   2px;   /* inputs */
  --radius-strip:   0;     /* data strips */
  --radius-trustid: 10px;  /* RESERVED for the credential card only */
  --space-section:  clamp(4rem, 8vw, 8rem);   /* 64px mobile → 128px desktop */

  /* The one shadow in the system (TrustID card only) */
  --shadow-card: 0 2px 0 var(--hair), 0 18px 36px -18px rgba(31, 41, 51, 0.45);

  /* Motion */
  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
}

/* ---- 2. Base type ---------------------------------------------------------- */
body {
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6,
.oss-display {
  font-family: var(--font-display);
  color: var(--ink);
  line-height: 1.12;
}

.oss-display { font-weight: 900; font-size: clamp(2.6rem, 5.4vw, 4.6rem); letter-spacing: -0.02em; }
h1 { font-weight: 800; font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -0.02em; }
h2 { font-weight: 800; font-size: 1.75rem; letter-spacing: -0.01em; }
h3 { font-weight: 700; font-size: 1.25rem; }

.oss-body-l { font-size: 1.125rem; line-height: 1.6; }

.oss-label {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--steel);
}

/* Mono / data voiceprint — codes, tiers, SAL, MRZ */
.mono,
.oss-data {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.9375rem;
  letter-spacing: 0.02em;
  font-variant-ligatures: none;
}

/* ---- 3. Links & buttons ---------------------------------------------------- */
a {
  color: var(--brand-text);
  text-decoration: none;
  background-image: linear-gradient(var(--brand), var(--brand));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 2px;            /* hi-vis underline grows from the left */
  transition: background-size 160ms var(--ease);
}
a:hover,
a:focus-visible { background-size: 100% 2px; }

.oss-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
  padding: 0.8rem 1.25rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--brand);
  color: var(--ink);               /* AA on orange */
  cursor: pointer;
  transition: background-color 140ms var(--ease), transform 80ms var(--ease);
}
.oss-btn:hover { background: var(--brand-deep); }
.oss-btn:active { transform: translateY(1px); }   /* depress 1px */
.oss-btn--ghost {
  background: transparent;
  border-color: var(--hair);
  color: var(--ink);
}
.oss-btn--ghost:hover { background: var(--paper-sunk); }

:where(input, select, textarea) { border-radius: var(--radius-input); }

/* ---- 4. Surfaces, hairlines, crop marks ------------------------------------ */
.oss-panel {
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: var(--radius-card);
  padding: clamp(1.25rem, 3vw, 2rem);
}
.oss-panel--sunk { background: var(--paper-sunk); }

/* Corner ticks / crop marks — the printed-form motif on key panels */
.oss-cropmarks { position: relative; }
.oss-cropmarks::before,
.oss-cropmarks::after {
  content: "";
  position: absolute;
  width: 10px; height: 10px;
  border: 1px solid var(--steel);
  opacity: 0.55;
}
.oss-cropmarks::before { top: 6px; left: 6px; border-right: 0; border-bottom: 0; }
.oss-cropmarks::after  { bottom: 6px; right: 6px; border-left: 0; border-top: 0; }

/* Inversion surface — "the gate" / carbon sections; guilloché wash <4% */
.oss-carbon {
  background-color: var(--carbon);
  color: var(--paper);
  background-image:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.035) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 9px);
}
.oss-carbon h1, .oss-carbon h2, .oss-carbon h3 { color: var(--paper); }

/* ---- 5. Safety-status chips (functional colour ONLY) ----------------------- */
.oss-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.3em 0.6em;
  border-radius: 999px;
  color: #fff;
}
.oss-chip::before { content: ""; width: 0.5em; height: 0.5em; border-radius: 50%; background: currentColor; opacity: 0.9; }
.oss-chip--verified { background: var(--verified); }
.oss-chip--checking  { background: var(--checking); }
.oss-chip--expired { background: var(--expired); }

/* ---- 6. The signature element: TrustID card + MRZ -------------------------- */
.oss-trustid {
  --pad: clamp(1rem, 3vw, 1.5rem);
  position: relative;
  max-width: 380px;
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: var(--radius-trustid);   /* 10px — a card always reads as a credential */
  box-shadow: var(--shadow-card);         /* the ONLY shadow in the whole system */
  overflow: hidden;
}
.oss-trustid__body { padding: var(--pad); display: grid; gap: 0.85rem; }
.oss-trustid__top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.oss-trustid__brand { font-family: var(--font-display); font-weight: 800; font-size: 0.95rem; letter-spacing: 0.01em; }
.oss-trustid__name { font-family: var(--font-display); font-weight: 900; font-size: 1.6rem; letter-spacing: -0.01em; line-height: 1; }
.oss-trustid__meta { display: flex; align-items: center; gap: 0.75rem; }
.oss-trustid__code { font-family: var(--font-mono); font-weight: 500; font-size: 0.95rem; letter-spacing: 0.04em; color: var(--ink); }
.oss-trustid__sal  { font-family: var(--font-mono); font-weight: 500; font-size: 0.8rem; color: var(--steel); }
.oss-trustid__qr {
  width: 64px; height: 64px;
  border: 1px solid var(--hair);
  border-radius: 4px;
  background:
    repeating-conic-gradient(var(--ink) 0% 25%, var(--paper) 0% 50%) 50% / 12px 12px;  /* placeholder QR texture */
}

/* MRZ strip — ONLY framed as the bottom edge of a passport/credential.
   Outside this frame, use clean " · " separators (design rule). */
.oss-mrz {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.8125rem;
  letter-spacing: 0.06em;
  color: var(--paper);
  background: var(--carbon);
  border-radius: var(--radius-strip);
  padding: 0.6rem var(--pad, 1rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}
.oss-trustid .oss-mrz { border-top: 1px solid rgba(255,255,255,0.10); }

/* ---- 7. Motion: the one orchestrated moment + quiet assists ---------------- */
/* Scroll reveal: 12px rise + fade, 240ms, staggered ≤60ms (set --i per item). */
.oss-reveal { opacity: 0; transform: translateY(12px); }
.oss-reveal.is-in {
  opacity: 1; transform: none;
  transition: opacity 240ms var(--ease), transform 240ms var(--ease);
  transition-delay: calc(var(--i, 0) * 60ms);
}

/* Hero signature: card stamps in, scan-line sweeps, chip flips CHECKING→VERIFIED.
   Triggered by adding .is-live to .oss-trustid--hero (JS on load, Phase 3). */
.oss-trustid--hero { animation: oss-stamp 420ms var(--ease) both; }
@keyframes oss-stamp {
  0%   { opacity: 0; transform: translateY(8px) scale(0.985); }
  100% { opacity: 1; transform: none; }
}
.oss-trustid--hero .oss-scanline {
  position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  animation: oss-scan 1400ms var(--ease) 320ms 1 both;
}
@keyframes oss-scan { 0% { top: 0; opacity: 0; } 12% { opacity: 1; } 100% { top: 100%; opacity: 0; } }

/* Chip flip: amber CHECKING → green VERIFIED, once, on load. */
.oss-trustid--hero .oss-chip {
  animation: oss-flip 320ms var(--ease) 1500ms both;
  background: var(--checking);
}
@keyframes oss-flip {
  0%   { background: var(--checking); }
  100% { background: var(--verified); }
}

@media (prefers-reduced-motion: reduce) {
  .oss-reveal,
  .oss-reveal.is-in { opacity: 1; transform: none; transition: none; }
  .oss-trustid--hero,
  .oss-trustid--hero .oss-scanline,
  .oss-trustid--hero .oss-chip { animation: none; }
  .oss-trustid--hero .oss-chip { background: var(--verified); }
  .oss-trustid--hero .oss-scanline { display: none; }
  a { transition: none; }
}
