/* ==========================================================================
   core.css — tokens, reset, typography, layout primitives.
   Design language: engineering drawing meets glass cockpit. Hairline rules,
   monospaced micro-labels, real numbers, restrained accent colour.
   ========================================================================== */

:root {
  /* surfaces */
  --bg-void:   #04060a;
  --bg-deep:   #070a10;
  --bg-panel:  #0b1018;
  --bg-raise:  #101724;
  --bg-glass:  rgba(11, 16, 24, 0.72);

  /* rules */
  --line:      rgba(120, 160, 200, 0.13);
  --line-soft: rgba(120, 160, 200, 0.07);
  --line-hot:  rgba(90, 220, 255, 0.35);

  /* ink — every value that carries TEXT clears 4.5:1 against --bg-void.
     Measured: hi 17.6 · txt 10.0 · dim 6.4 · faint 5.2. --ink-rule is the only
     one below the bar and is reserved for hairlines and tick marks, never text. */
  --txt-hi:    #e8f0f8;
  --txt:       #a8b8c8;
  --txt-dim:   #7d93a8;
  --txt-faint: #6f8497;
  --ink-rule:  #4a5c6e;

  /* signal */
  --accent:    #37e0ff;
  --accent-2:  #ffb340;
  --accent-3:  #7cffb2;
  --danger:    #ff5a52;
  --accent-ink: #062733;

  /* type */
  --f-display: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
  --f-body:    'Inter', 'Segoe UI', system-ui, sans-serif;
  --f-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;

  /* geometry */
  --gutter: clamp(20px, 5vw, 88px);
  --maxw: 1560px;
  --rail: 56px;

  /* motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-io:  cubic-bezier(0.65, 0, 0.35, 1);
  --dur: 620ms;
}

/* --------------------------------------------------------------------- */

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

html {
  background: var(--bg-void);
  color-scheme: dark;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--txt);
  background: var(--bg-void);
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Several components set `display` on the same element they toggle `hidden`
   on; without this the attribute silently loses and the overlay stays up. */
[hidden] { display: none !important; }

img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}
:focus:not(:focus-visible) { outline: none; }

::selection { background: var(--accent); color: var(--accent-ink); }

/* thin, technical scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-void); }
::-webkit-scrollbar-thumb {
  background: #1b2735;
  border: 3px solid var(--bg-void);
  border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover { background: #2a3d52; }

/* ==========================================================================
   typography
   ========================================================================== */

h1, h2, h3, h4 {
  font-family: var(--f-display);
  color: var(--txt-hi);
  font-weight: 600;
  letter-spacing: -0.022em;
  line-height: 1.05;
  margin: 0;
  text-wrap: balance;
}

.t-display {
  font-size: clamp(3.2rem, 11.5vw, 11rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 0.88;
}

.t-h2 { font-size: clamp(2rem, 4.6vw, 3.9rem); letter-spacing: -0.03em; }
.t-h3 { font-size: clamp(1.25rem, 2vw, 1.7rem); letter-spacing: -0.02em; }

.t-lead {
  font-size: clamp(1.02rem, 1.35vw, 1.24rem);
  line-height: 1.62;
  color: var(--txt);
  max-width: 62ch;
  text-wrap: pretty;
}

/* the workhorse micro-label: uppercase mono, wide tracking */
.t-label {
  font-family: var(--f-mono);
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--txt-dim);
  font-weight: 500;
}

.t-mono { font-family: var(--f-mono); font-size: 0.8rem; letter-spacing: 0.01em; }
.t-num  { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }

.t-hi   { color: var(--txt-hi); }
.t-dim  { color: var(--txt-dim); }
.t-acc  { color: var(--accent); }
.t-amb  { color: var(--accent-2); }

/* ==========================================================================
   layout primitives
   ========================================================================== */

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  position: relative;
  padding-block: clamp(88px, 11vw, 180px);
  border-top: 1px solid var(--line);
}

/* the inspection bay is the centre of gravity — spend the vertical budget on
   the viewport, not on the heading above it */
.work { padding-block: clamp(64px, 7vw, 108px); }
.work .sec-head { margin-bottom: clamp(28px, 3.2vw, 48px); }

.section--flush { padding-block: 0; border-top: 0; }

/* drafting-style section header: index number, rule, title */
.sec-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: clamp(18px, 3vw, 46px);
  align-items: start;
  margin-bottom: clamp(38px, 5vw, 72px);
}

.sec-head__idx {
  font-family: var(--f-mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  color: var(--accent);
  padding-top: 0.65em;
  white-space: nowrap;
}

.sec-head__idx::after {
  content: '';
  display: block;
  height: 1px;
  width: clamp(28px, 5vw, 90px);
  margin-top: 0.9em;
  background: linear-gradient(90deg, var(--line-hot), transparent);
}

.sec-head__intro {
  margin-top: 1.1em;
  color: var(--txt-dim);
  max-width: 58ch;
  font-size: 0.97rem;
  text-wrap: pretty;
}

/* ==========================================================================
   panels — the recurring "instrument bezel" container
   ========================================================================== */

.panel {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--line);
}

/* corner ticks, drawing-frame style */
.panel--ticks::before,
.panel--ticks::after {
  content: '';
  position: absolute;
  width: 9px; height: 9px;
  border: 1px solid var(--line-hot);
  pointer-events: none;
}
.panel--ticks::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.panel--ticks::after  { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

.panel__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.015);
  min-height: 38px;
}

/* ==========================================================================
   controls
   ========================================================================== */

.btn {
  --btn-bd: var(--line);
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 10px 17px;
  background: transparent;
  border: 1px solid var(--btn-bd);
  color: var(--txt);
  font-family: var(--f-mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 220ms, border-color 220ms, background 220ms, transform 220ms var(--ease-out);
  white-space: nowrap;
}

.btn:hover { color: var(--txt-hi); --btn-bd: var(--line-hot); background: rgba(55, 224, 255, 0.05); }
.btn:active { transform: translateY(1px); }

.btn[aria-pressed='true'], .btn.is-on {
  color: var(--accent);
  --btn-bd: var(--line-hot);
  background: rgba(55, 224, 255, 0.08);
}

.btn--solid {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 600;
}
.btn--solid:hover { background: #6aeaff; border-color: #6aeaff; color: var(--accent-ink); }

.btn--ghost { border-color: transparent; padding-inline: 10px; }
.btn--ghost:hover { border-color: var(--line); background: transparent; }

.btn__key {
  font-size: 0.62rem;
  padding: 1px 5px;
  border: 1px solid var(--line);
  color: var(--txt-faint);
  border-radius: 2px;
}

/* range input styled as an engineering slider */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: ew-resize;
}
.slider::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(90deg, var(--accent) var(--fill, 0%), var(--line) var(--fill, 0%));
}
.slider::-moz-range-track { height: 2px; background: var(--line); }
.slider::-moz-range-progress { height: 2px; background: var(--accent); }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 3px; height: 16px;
  margin-top: -7px;
  background: var(--accent);
  border: 0; border-radius: 0;
  box-shadow: 0 0 0 4px rgba(55, 224, 255, 0.16);
}
.slider::-moz-range-thumb {
  width: 3px; height: 16px;
  background: var(--accent);
  border: 0; border-radius: 0;
}

/* ==========================================================================
   data readouts
   ========================================================================== */

.readout { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.readout__k {
  font-family: var(--f-mono);
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--txt-faint);
}

.readout__v {
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
  color: var(--txt-hi);
  white-space: nowrap;
}

.readout__v small { color: var(--txt-dim); font-size: 0.7em; margin-left: 2px; }

/* ==========================================================================
   scroll-reveal (progressive enhancement — visible by default)
   ========================================================================== */

.reveal { --rd: 0ms; }

@media (prefers-reduced-motion: no-preference) {
  html.js .reveal {
    opacity: 0;
    transform: translateY(22px);
    transition: opacity 900ms var(--ease-out) var(--rd),
                transform 900ms var(--ease-out) var(--rd);
    will-change: opacity, transform;
  }
  html.js .reveal.is-in { opacity: 1; transform: none; }
}

/* a hairline that draws itself in */
.rule-draw {
  height: 1px;
  background: var(--line);
  transform-origin: left;
}
@media (prefers-reduced-motion: no-preference) {
  html.js .rule-draw { transform: scaleX(0); transition: transform 1100ms var(--ease-out); }
  html.js .rule-draw.is-in { transform: scaleX(1); }
}

/* ==========================================================================
   utility
   ========================================================================== */

.vh {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 10px; left: 10px;
  z-index: 9999;
  padding: 12px 20px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--f-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transform: translateY(-200%);
  transition: transform 200ms;
}
.skip-link:focus { transform: none; }

.noise {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: var(--noise-img);
  background-size: 180px 180px;
}

/* faint blueprint grid behind everything */
.gridbg {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 96px 96px;
  mask-image: radial-gradient(ellipse 120% 90% at 50% 0%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 120% 90% at 50% 0%, #000 0%, transparent 78%);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
