/* Masthead V4 — "rain of words".
   Loaded only by v4/index.html.

   The existing WebGL fluid keeps running underneath as the weather; the glyph
   canvas draws thousands of instanced characters in falling columns, each
   column a phrase of contract language read top to bottom. */

/* The water: dimmed and desaturated so the letters carry the colour. */
.hero--v4 .hero-fluid-canvas {
  z-index: 0;
  filter: saturate(.62) contrast(1.06) brightness(calc(.36 * var(--water-brightness, 1)));
  transition: opacity 1.2s ease, filter .4s ease;
}

.hero--v4.is-water-hidden .hero-fluid-canvas {
  opacity: .12;
  filter: saturate(.2) brightness(.3);
}

/* Another background is picked in the configurator: the fluid canvas goes
   away entirely and microsite.js pauses its loop (.is-fluid-paused). The
   shader backgrounds are drawn into the glyph canvas instead. */
.hero--v4.is-water-off .hero-fluid-canvas { display: none; }

.hero--v4 .hero-glyph-canvas {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: screen;
  transition: opacity 1.1s ease;
  will-change: opacity;
}

.hero--v4.is-glyph-ready .hero-glyph-canvas { opacity: 1; }

/* Keep the text block readable: the JS also thins the field behind the H1
   (leftGuard), this gradient is the belt to those braces. */
.hero--v4 .hero-atmosphere::after {
  background:
    linear-gradient(to right,
      color-mix(in oklab, var(--bg) 52%, transparent) 0%,
      color-mix(in oklab, var(--bg) 40%, transparent) 30%,
      color-mix(in oklab, var(--bg) 18%, transparent) 54%,
      color-mix(in oklab, var(--bg) 4%, transparent) 78%,
      transparent 100%),
    linear-gradient(to bottom,
      color-mix(in oklab, var(--bg) 26%, transparent),
      transparent 28%,
      color-mix(in oklab, var(--bg) 22%, transparent));
}

/* Light mode: screen blending is invisible on a light ground, so the letters
   darken the page instead. masthead-v4.js flips the ink palette to match. */
:root[data-theme="light"] .hero--v4 .hero-glyph-canvas { mix-blend-mode: multiply; }
:root[data-theme="light"] .hero--v4 .hero-fluid-canvas { filter: saturate(.6) brightness(calc(1.04 * var(--water-brightness, 1))); }

@media (max-width: 768px), (pointer: coarse) {
  .hero--v4 .hero-glyph-canvas { mix-blend-mode: normal; }
  .hero--v4.is-glyph-ready .hero-glyph-canvas { opacity: .55; }
}

@media (prefers-reduced-motion: reduce) {
  .hero--v4 .hero-glyph-canvas { mix-blend-mode: normal; }
  .hero--v4.is-glyph-ready .hero-glyph-canvas { opacity: .5; }
}

/* ───────── tuning panel (dev only — delete this block and the panel code
   in masthead-v4.js once the numbers are locked in) ───────── */

.glyph-tuner {
  position: fixed;
  z-index: 90;
  top: calc(var(--nav-h, 64px) + 14px);
  right: 14px;
  width: 268px;
  max-height: calc(100vh - var(--nav-h, 64px) - 28px);
  padding: 12px 14px 14px;
  border-radius: 12px;
  border: 1px solid color-mix(in oklab, var(--text-primary) 16%, transparent);
  background: color-mix(in oklab, #0a0a0c 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .55);
  font-family: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 10px;
  line-height: 1.4;
  color: var(--text-secondary);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.glyph-tuner-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid color-mix(in oklab, var(--text-primary) 12%, transparent);
}

.glyph-tuner-title {
  color: var(--text-primary);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.glyph-tuner-fps { color: var(--accent); font-variant-numeric: tabular-nums; }

.glyph-tuner-group {
  margin: 10px 0 6px;
  color: color-mix(in oklab, var(--text-secondary) 70%, transparent);
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.glyph-tuner-row { margin-bottom: 9px; }

.glyph-tuner-row label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
  cursor: default;
}

.glyph-tuner-row output {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.glyph-tuner input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 3px;
  margin: 0;
  border-radius: 3px;
  background: color-mix(in oklab, var(--text-primary) 20%, transparent);
  cursor: ew-resize;
}

.glyph-tuner input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
}

.glyph-tuner input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
}

.glyph-tuner-toggles {
  display: grid;
  gap: 2px;
  margin: 4px 0 8px;
}

.glyph-tuner-toggles label {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  /* The row is the hit area, not the 13px box inside it. WCAG 2.2 asks for a
     24x24 target; the checkbox alone was 13x13 and failed. min-height plus the
     label wrapping the input gets there without making the box look bigger. */
  min-height: 24px;
}

.glyph-tuner-toggles input {
  accent-color: var(--accent);
  margin: 0;
  /* Was the browser default, ~13px square, which failed the same 24px rule.
     Sizing the control itself is the one approach Chrome renders reliably —
     border and padding are ignored on a native checkbox. */
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
}

.glyph-tuner-actions { display: flex; gap: 6px; margin-top: 12px; }

.glyph-tuner-actions button,
.glyph-preset-tools button {
  flex: 1;
  padding: 6px 4px;
  border-radius: 6px;
  border: 1px solid color-mix(in oklab, var(--text-primary) 22%, transparent);
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

.glyph-tuner-actions button:hover,
.glyph-preset-tools button:hover {
  background: color-mix(in oklab, var(--text-primary) 12%, transparent);
  border-color: var(--text-primary);
}

/* ── tabs ── */

.glyph-tuner-tabs {
  display: flex;
  gap: 2px;
  margin: -2px 0 8px;
  border-bottom: 1px solid color-mix(in oklab, var(--text-primary) 12%, transparent);
}

.glyph-tuner-tab {
  flex: 1;
  padding: 6px 4px 7px;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}

.glyph-tuner-tab:hover { color: var(--text-primary); }
.glyph-tuner-tab.is-active { color: var(--text-primary); border-bottom-color: var(--accent); }

/* ── background dropdown ── */

.glyph-tuner-select {
  display: block;
  width: 100%;
  margin: 2px 0 6px;
  padding: 5px 6px;
  border-radius: 6px;
  border: 1px solid color-mix(in oklab, var(--text-primary) 22%, transparent);
  background: color-mix(in oklab, #0a0a0c 70%, transparent);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
}

.glyph-tuner-select:hover { border-color: var(--text-primary); }
.glyph-tuner-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ── presets ── */

.glyph-tuner-presets { display: grid; gap: 2px; }

.glyph-tuner-empty {
  margin: 6px 0 10px;
  color: color-mix(in oklab, var(--text-secondary) 80%, transparent);
  line-height: 1.5;
}

.glyph-preset {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 4px 8px;
  padding: 7px 0 8px 8px;
  border-left: 2px solid transparent;
  border-bottom: 1px solid color-mix(in oklab, var(--text-primary) 8%, transparent);
  transition: border-color .15s ease, background .15s ease;
}

.glyph-preset.is-active {
  border-left-color: var(--accent);
  background: color-mix(in oklab, var(--accent) 7%, transparent);
}

.glyph-preset-name {
  min-width: 0;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 11px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.glyph-preset-name:hover { color: var(--accent); }

.glyph-preset-meta {
  color: color-mix(in oklab, var(--text-secondary) 70%, transparent);
  font-size: 9px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.glyph-preset-input {
  grid-column: 1;
  min-width: 0;
  padding: 2px 4px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: color-mix(in oklab, var(--text-primary) 8%, transparent);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 11px;
  outline: none;
}

.glyph-preset-tools {
  grid-column: 1 / -1;
  display: flex;
  gap: 4px;
}

.glyph-preset-tools button {
  flex: 0 0 auto;
  padding: 3px 7px;
  font-size: 9px;
}

.glyph-preset-delete.is-armed {
  border-color: var(--accent);
  color: var(--accent);
}

.glyph-tuner-hint {
  margin-top: 9px;
  color: color-mix(in oklab, var(--text-secondary) 70%, transparent);
  font-size: 9px;
}

/* .glyph-tuner-toggle (the "C" pill) was removed: the configurator is
   keyboard-only now. See the note in masthead-v4.js. */

@media (max-width: 900px) {
  .glyph-tuner { display: none !important; }
}
