/* ====================================================================
   SIGNAL — base layer
   Reset · type · buttons · cards/HUD · badges · tables · forms ·
   stats · rings · tickers · utilities.  Shared by marketing + portal.
   ==================================================================== */

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

html { scroll-behavior: smooth; }

body {
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-head);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  /* clip (not hidden): kills sideways pan from off-canvas nav without
     creating a scroll container, so position:sticky keeps working */
  overflow-x: clip;
}

img, svg, video { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; }

h1, h2, h3, h4 {
  font-family: var(--font-head);
  font-weight: 700;
  line-height: 1.12;
  text-transform: uppercase;
  letter-spacing: 0.015em;
  text-wrap: balance;
}

/* Display type — huge condensed headlines */
.display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.005em;
  line-height: 0.94;
  text-transform: uppercase;
}

/* display-face section headings (split layouts + values heads) */
.h-display {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.2rem, 4.5vw, 3.6rem);
  line-height: 0.96;
  margin-top: 14px;
}
.h-display--lg { font-size: clamp(2.3rem, 5vw, 3.9rem); }

p { max-width: 64ch; }

/* ------------------------------------------------------------------ */
/* Layout                                                              */
/* ------------------------------------------------------------------ */

.wrap { width: min(1180px, 100% - 48px); margin-inline: auto; }
.wrap--wide { width: min(1340px, 100% - 48px); }

.section { padding-block: clamp(64px, 9vw, 120px); }
.section--tight { padding-block: clamp(44px, 6vw, 76px); }
.section--flush-top { padding-top: 0; }
.section--line-top { border-top: 1px solid var(--line); }

.section-head { margin-bottom: clamp(36px, 5vw, 64px); }
.section-head h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.3rem, 5vw, 3.9rem);
  line-height: 0.96;
  margin-top: 14px;
}
.section-head .lede { margin-top: 16px; color: var(--ink-2); font-size: 1.02rem; }

/* Fine grid-line background */
.grid-bg {
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 48px 48px;
}

/* Subtle scanline texture (apply to position:relative containers) */
.scan { position: relative; }
/* scanlines are photo/surface texture — copy rides above them so display
   type never shows banding (the ::after sits at z-index 3) */
.scan > .wrap { position: relative; z-index: 4; }
.scan::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    var(--scan) 0px,
    var(--scan) 1px,
    transparent 1px,
    transparent 4px
  );
  opacity: 0.07;
  z-index: 3;
}

/* ------------------------------------------------------------------ */
/* Eyebrow labels (Aldrich — the brand thread)                         */
/* ------------------------------------------------------------------ */

.eyebrow {
  font-family: var(--font-nav);
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-2);
  display: flex;
  align-items: flex-start; /* markers lock to line 1 when the label wraps */
  gap: 0.85em;
}
.eyebrow::before {
  content: "";
  width: 24px;
  height: 2px;
  margin-top: 0.5em;
  background: var(--signal);
  flex: none;
}
.eyebrow .dot { margin-top: 0.3em; }
.eyebrow--bare::before { display: none; }

/* ------------------------------------------------------------------ */
/* Status dots                                                         */
/* ------------------------------------------------------------------ */

.dot {
  display: inline-block;
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-3);
  flex: none;
}
.dot--ok   { background: var(--ok); }
.dot--warn { background: var(--warn); }
.dot--bad  { background: var(--bad); }
.dot--red  { background: var(--signal); }
/* pulse halo on its own layer — transform/opacity only */
.dot--live::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--ok);
  opacity: 0;
  animation: dot-pulse 2s ease-in-out infinite;
}
@keyframes dot-pulse {
  0%, 100% { transform: scale(1);   opacity: 0; }
  50%      { transform: scale(2.5); opacity: 0.22; }
}

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */

.btn {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  padding: 0.9em 1.7em;
  min-height: 44px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease,
              color 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
  clip-path: polygon(
    0 0, 100% 0,
    100% calc(100% - var(--notch)),
    calc(100% - var(--notch)) 100%,
    0 100%
  );
}
.btn:hover { border-color: var(--signal); color: var(--signal); }
.btn:active { transform: translateY(1px); }
/* inset ring: the notch clip-path swallows anything drawn outside the box */
.btn:focus-visible {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: inset 0 0 0 2px var(--signal);
}

.btn--primary {
  background: var(--red);
  border-color: var(--red);
  color: var(--signal-ink);
}
.btn--primary:hover {
  background: var(--red);
  border-color: var(--signal);
  color: #ffffff;
  box-shadow: var(--signal-glow);
}
.btn--primary:focus-visible { box-shadow: inset 0 0 0 2px var(--signal-ink); }

.btn--ghost { background: transparent; }

.btn--inverse {
  background: #ffffff;
  border-color: #ffffff;
  color: #0c0e11;
}
.btn--inverse:hover { background: #0c0e11; border-color: #0c0e11; color: #ffffff; }
.btn--inverse:focus-visible { box-shadow: inset 0 0 0 2px var(--red); }

.btn--sm { padding: 0.6em 1.1em; font-size: 0.72rem; min-height: 38px; }
.btn--lg { padding: 1.05em 2.2em; font-size: 0.9rem; }
.btn--block { width: 100%; }

.btn:disabled,
.btn:disabled:hover,
.btn:disabled:active {
  opacity: 0.55;
  cursor: not-allowed;
  border-color: var(--line-2);
  color: var(--ink-2);
  transform: none;
  box-shadow: none;
}
.btn--primary:disabled,
.btn--primary:disabled:hover {
  background: var(--red);
  border-color: var(--red);
  color: var(--signal-ink);
}
.btn[aria-busy="true"] { pointer-events: none; opacity: 0.65; }

/* in-flight: blinking block cursor — terminal register */
.btn.is-loading { pointer-events: none; }
.btn.is-loading::after {
  content: "";
  width: 8px;
  height: 8px;
  flex: none;
  background: currentColor;
  animation: btn-busy 0.8s steps(2, jump-none) infinite;
}
@keyframes btn-busy { from { opacity: 1; } to { opacity: 0.15; } }

@media (pointer: coarse) {
  .btn--sm { min-height: 44px; }
}

/* ------------------------------------------------------------------ */
/* Cards + HUD corner brackets                                         */
/* ------------------------------------------------------------------ */

.card {
  background-color: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(20px, 3vw, 30px);
  position: relative;
}
.card--pad-lg { padding: clamp(28px, 4vw, 44px); }

/* HUD corner brackets — 8 gradient bars, 2 per corner.
   Add .hud to any element (works on .card; uses background-image only,
   so always set surface color with background-COLOR, not shorthand). */
.hud {
  --hud-s: 16px;   /* arm length */
  --hud-w: 2px;    /* arm thickness */
  background-repeat: no-repeat;
  background-image:
    linear-gradient(var(--hud-c), var(--hud-c)),
    linear-gradient(var(--hud-c), var(--hud-c)),
    linear-gradient(var(--hud-c), var(--hud-c)),
    linear-gradient(var(--hud-c), var(--hud-c)),
    linear-gradient(var(--hud-c), var(--hud-c)),
    linear-gradient(var(--hud-c), var(--hud-c)),
    linear-gradient(var(--hud-c), var(--hud-c)),
    linear-gradient(var(--hud-c), var(--hud-c));
  background-size:
    var(--hud-s) var(--hud-w), var(--hud-w) var(--hud-s),
    var(--hud-s) var(--hud-w), var(--hud-w) var(--hud-s),
    var(--hud-s) var(--hud-w), var(--hud-w) var(--hud-s),
    var(--hud-s) var(--hud-w), var(--hud-w) var(--hud-s);
  background-position:
    top left, top left,
    top right, top right,
    bottom left, bottom left,
    bottom right, bottom right;
  transition: background-image 0.2s ease;
}
.hud--red { --hud-c: var(--signal); }
.hud-hover:hover { --hud-c: var(--signal); }

/* ------------------------------------------------------------------ */
/* Badges                                                              */
/* ------------------------------------------------------------------ */

.badge {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  padding: 0.4em 0.8em;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--bg-2);
  color: var(--ink-2);
  white-space: nowrap;
}
.badge--ok   { color: var(--ok);     border-color: var(--ok);     background: var(--ok-dim); }
.badge--warn { color: var(--warn);   border-color: var(--warn);   background: var(--warn-dim); }
.badge--bad  { color: var(--bad);    border-color: var(--bad);    background: var(--bad-dim); }
.badge--red  { color: var(--signal-text); border-color: var(--signal); background: var(--signal-dim); }

/* ------------------------------------------------------------------ */
/* Tables                                                              */
/* ------------------------------------------------------------------ */

.table-wrap {
  position: relative; /* contain absolute children (.sr-only) inside the scroll clip */
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background-color: var(--bg-3);
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) var(--bg-2);
}
/* scrolling edge shades: the shades sit on the box, the bg-3 covers ride
   the content and park over them at either end — so the fade only shows
   where columns continue off-screen. (.hud owns background-image.) */
.table-wrap:not(.hud) {
  background-image:
    linear-gradient(90deg,  var(--bg-3) 38%, transparent),
    linear-gradient(270deg, var(--bg-3) 38%, transparent),
    linear-gradient(90deg,  var(--scroll-shade), transparent),
    linear-gradient(270deg, var(--scroll-shade), transparent);
  background-position: left center, right center, left center, right center;
  background-size: 40px 100%, 40px 100%, 18px 100%, 18px 100%;
  background-repeat: no-repeat;
  background-attachment: local, local, scroll, scroll;
}
.table-wrap::-webkit-scrollbar { height: 8px; }
.table-wrap::-webkit-scrollbar-track { background: var(--bg-2); }
.table-wrap::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 640px; }
.table th {
  font-family: var(--font-nav);
  font-weight: 400;
  font-size: 0.64rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: left;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line-2);
  background: var(--bg-2);
  white-space: nowrap;
}
.table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  vertical-align: top;
}
.table td:first-child, .table th:first-child { padding-left: 22px; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-2); }
.table .num, .table td.mono { font-family: var(--font-mono); font-size: 0.84rem; }
.table strong { color: var(--ink); }

/* ------------------------------------------------------------------ */
/* Forms                                                               */
/* ------------------------------------------------------------------ */

.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.field > label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.field .req { color: var(--signal); }

.input {
  width: 100%;
  font-family: var(--font-head);
  font-size: 1rem; /* ≥16px — iOS Safari won't auto-zoom the viewport on focus */
  color: var(--ink);
  background-color: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 11px 14px;
  min-height: 46px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea.input { min-height: 130px; resize: vertical; }
.input::placeholder { color: var(--ink-3); }
.input:focus {
  outline: none;
  border-color: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-dim);
}
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: calc(100% - 19px) 50%, calc(100% - 14px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }

.field--error .input { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-dim); }
.field-msg {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: var(--bad);
  display: none;
}
.field--error .field-msg { display: block; }

.form-alert {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  border: 1px solid var(--bad);
  background: var(--bad-dim);
  color: var(--bad);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 18px;
}

/* ------------------------------------------------------------------ */
/* Stat blocks — big mono numerals                                     */
/* ------------------------------------------------------------------ */

.stat { display: flex; flex-direction: column; gap: 6px; }
.stat__value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: clamp(2rem, 3.6vw, 3rem);
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.03em;
  white-space: nowrap;
}
.stat__value .unit {
  font-size: 0.42em;
  color: var(--signal);
  letter-spacing: 0.06em;
  vertical-align: 0.16em;
  margin-left: 0.18em;
}
.stat__label {
  font-family: var(--font-nav);
  font-size: 0.64rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.stat__sub { font-family: var(--font-mono); font-size: 0.72rem; color: var(--ink-2); }

/* ------------------------------------------------------------------ */
/* SVG progress ring (r=44 in a 100×100 viewBox; set --p 0..1)          */
/* ------------------------------------------------------------------ */

.ring { width: 84px; height: 84px; }
.ring circle { fill: none; stroke-width: 6; }
.ring__track { stroke: var(--line); }
.ring__bar {
  stroke: var(--signal);
  stroke-dasharray: calc(276.46px * var(--p, 0.75)) 276.46px;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

/* ------------------------------------------------------------------ */
/* Ticker strips                                                       */
/* ------------------------------------------------------------------ */

.ticker {
  overflow: hidden;
  border-block: 1px solid var(--line);
  background-color: var(--bg-2);
  user-select: none;
}
.ticker__track {
  display: flex;
  width: max-content;
  animation: ticker-roll 38s linear infinite;
}
.ticker__track > span {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding: 13px 1.4em;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 1.4em;
}
.ticker__track b { color: var(--signal); font-weight: 500; }
.ticker__track .sep { color: var(--signal); }
@keyframes ticker-roll { to { transform: translateX(-50%); } }
/* WCAG 2.2.2 — the marquee can be paused (hover, or tap via motion.js
   .ticker--hold), and motion.js parks it while scrolled offscreen
   (.ticker--off) to save compositor work */
.ticker:hover .ticker__track,
.ticker--hold .ticker__track,
.ticker--off .ticker__track { animation-play-state: paused; }

/* ------------------------------------------------------------------ */
/* Photo treatment                                                     */
/* ------------------------------------------------------------------ */

.ph { position: relative; overflow: hidden; background: #0c0e11; border-radius: var(--radius); }
.ph img {
  width: 100%; height: 100%; object-fit: cover;
  filter: var(--photo-filter);
}
.ph::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(12,14,17,0) 46%, var(--photo-fade) 100%);
  pointer-events: none;
}
.ph__tag {
  position: absolute;
  left: 12px; bottom: 12px;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #e8ecf2;
  background-color: rgba(12, 14, 17, 0.78);
  /* mini HUD brackets, top-left + bottom-right */
  background-image:
    linear-gradient(var(--signal), var(--signal)),
    linear-gradient(var(--signal), var(--signal)),
    linear-gradient(var(--signal), var(--signal)),
    linear-gradient(var(--signal), var(--signal));
  background-size: 9px 2px, 2px 9px, 9px 2px, 2px 9px;
  background-position: top left, top left, bottom right, bottom right;
  background-repeat: no-repeat;
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 6px 10px;
}

/* ------------------------------------------------------------------ */
/* Utilities                                                           */
/* ------------------------------------------------------------------ */

.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.red { color: var(--signal); }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.upper { text-transform: uppercase; }
.center { text-align: center; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -48px;
  z-index: 100;
  background: var(--red); color: #fff;
  font-family: var(--font-mono); font-size: 0.75rem;
  padding: 10px 16px; text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 12px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ticker__track { animation: none; }
  /* static ticker reads as a wrapped fact line, not clipped text */
  .ticker__track { flex-wrap: wrap; }
  .ticker__track > span:nth-child(n + 7) { display: none; }
  .dot--live::after { animation: none; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
