/* ==========================================================================
   idirnet hero — static (no-framework) build
   Ported from the SCSS modules in idir-www-dev. CSS-module hashed class names
   translated to the plain DOM-contract class names. Self-contained: fonts are
   same-origin @font-face, no external imports/CDNs.
   ========================================================================== */

/* --- Fonts (same-origin, self-hosted) ----------------------------------- */
@font-face {
  font-family: 'Inter';
  src: url('/hero-assets/fonts/inter.woff2') format('woff2');
  font-weight: 300 600;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/hero-assets/fonts/jetbrains-mono.woff2') format('woff2');
  font-weight: 400 600;
  font-display: swap;
}

/* --- Root tokens (JS sets --fg/--muted at runtime; these are defaults) --- */
:root {
  --bg: #000000;
  --fg-rgb: 255, 255, 255;
  --fg: rgb(var(--fg-rgb));
  --muted: #737378;
  --dim: #3a3a3f;
  --subtle: #222225;
  --link: #00d4aa;
  --link-blue: #4cc4e3;
  --link-orange: #ff8a3a;
}

/* --- Reset (from globals.scss) ------------------------------------------ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: 2px;
}

button:focus-visible,
input:focus-visible {
  outline-offset: 3px;
}

html {
  height: 100%;
  /* Stop iOS/Android from re-scaling text on orientation change, and make the
     16px input floor below authoritative (otherwise WebKit may inflate it). */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* --- Canvas field (RippleField .field → canvas#field) -------------------
   Sits over the page content as a water surface; pointer-events:none so it
   never swallows input/clicks. Contract: fixed, inset 0, full viewport,
   z-index 1, width/height 100%. */
canvas#field {
  position: fixed;
  inset: 0;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

/* --- Page wrapper (page.module .page) ----------------------------------- */
.page {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Hero grid (Hero .hero) --------------------------------------------- */
.hero {
  flex: 1;
  display: grid;
  grid-template-rows: 1fr auto auto 1fr;
  align-items: center;
  justify-items: center;
  padding: clamp(1rem, 4vw, 3rem) clamp(1rem, 4vw, 4rem);
  gap: clamp(0.5rem, 1.5vh, 1.25rem);
  width: 100%;
  text-align: center;
}

/* --- Brand wordmark (Hero .heroWord → .hero-word) ----------------------- */
.hero-word {
  grid-row: 2;
  font-size: clamp(3.5rem, 11vw, 7rem);
  font-weight: 300;
  letter-spacing: 0.15em;
  line-height: 1;
  /* Negative right margin cancels the trailing letter-spacing after the last
     glyph, keeping the visible centre true. */
  margin: 0 -0.15em 0 0;
  text-align: center;
  position: relative;
  isolation: isolate;
  /* Glow tracks the live --fg (warms with the night palette) instead of a fixed
     white. Under the night red `mix-blend-mode: multiply` gel a white glow can
     only darken — it brightens the glyph rims while the warmed fill darkens,
     reading as hollow/outlined letters. Matching the glow to --fg keeps the bloom
     and the solid fill in both day and night. */
  text-shadow:
    0 0 18px rgba(var(--fg-rgb), 0.10),
    0 0 38px rgba(var(--fg-rgb), 0.05);
  /* Fade in over φs (1.618s), then settle into the breathing pulse. */
  animation: heroFadeIn 1.618s ease both, brandBreathe 6s ease-in-out infinite 1.618s;
  will-change: opacity, text-shadow;
}

/* Fine film-grain shimmer clipped to the glyphs. */
.hero-word::after {
  content: 'idirnet';
  position: absolute;
  inset: 0;
  letter-spacing: inherit;
  line-height: inherit;
  text-align: inherit;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  mix-blend-mode: overlay;
  opacity: 0.08;
  pointer-events: none;
  animation: heroGrainShimmer 7s steps(8, end) infinite;
}

@keyframes heroFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes brandBreathe {
  0%, 100% {
    opacity: 1;
    text-shadow:
      0 0 18px rgba(var(--fg-rgb), 0.10),
      0 0 38px rgba(var(--fg-rgb), 0.05);
  }
  50% {
    opacity: 0.88;
    text-shadow:
      0 0 18px rgba(var(--fg-rgb), 0.12),
      0 0 38px rgba(var(--fg-rgb), 0.07),
      0 0 24px rgba(var(--fg-rgb), 0.12);
  }
}

@keyframes heroGrainShimmer {
  0% { background-position: 0 0; }
  100% { background-position: 160px 96px; }
}

@media (max-width: 380px) {
  .hero-word {
    font-size: clamp(2.5rem, 13vw, 3.25rem);
    letter-spacing: 0.09em;
  }
  .hero {
    padding: clamp(1rem, 3vw, 2rem) clamp(0.75rem, 3vw, 1.5rem);
  }
}

/* --- Tagline (Stream1Line .line → .tagline) -----------------------------
   Desaturated neutral grey (#bdbdbd) — the warmth lives only in the molten
   email line. */
.tagline {
  /* Sit in grid-row 3, directly under the wordmark (row 2) — mirrors the
     original .taglineSlot placement. Without this it auto-places into row 1
     (the top 1fr) and floats above the wordmark. */
  grid-row: 3;
  justify-self: center;
  /* Reserve a fixed TWO-LINE slot and centre the line(s) inside it, so the
     wordmark above NEVER moves whether the current tagline is one line or wraps
     to two. (Mirrors the original .taglineSlot min-height.) */
  min-height: 4rem;
  display: flex;
  /* Top-anchor the line(s): the first line always sits at the same place and a
     second line flows BENEATH it — the top line never jumps up when it wraps. */
  align-items: flex-start;
  justify-content: center;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: clamp(1.05rem, 2.1vw, 1.3rem);
  font-weight: 400;
  color: var(--fg);
  letter-spacing: 0;
  will-change: transform;
  line-height: 1.5;
  text-align: center;
  max-width: min(32ch, 80vw);
  text-wrap: balance;
  margin: 0;
  /* φ-scale cross-fade: 1.618s, matched to FADE_MS in the JS driver. */
  transition: opacity 1.618s ease;
}

/* Typewriter caret — a thin vertical bar that ticks at the line's end, and
   keeps blinking while the line rests fully typed (Matrix/terminal feel).
   Shows on an empty line too, so it sits and waits between taglines. */
.tagline-text::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 0.14em;
  background: currentColor;
  vertical-align: -0.12em;
  animation: tagline-blink 1.05s step-end infinite;
}
@keyframes tagline-blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .tagline-text::after { animation: none; }
}

/* --- Notify footer (NotifyFooter .notifyFooter → .notify) --------------- */
.notify {
  /* Lifted off the bottom (was a flush footer). Fixed so the wordmark stays
     centred while the input sits a fifth up on desktop and ~a quarter up on
     mobile, clear of the meta-bar. The molten .email-line tracks it via JS. */
  position: fixed;
  left: 0;
  right: 0;
  bottom: 14vh;
  z-index: 6;
  display: flex;
  justify-content: center;
  padding: 0 clamp(1rem, 4vw, 2rem);
}
@media (max-width: 540px) {
  /* 16vh clears iOS Safari bottom bar on all screen sizes without
     floating too high on tall viewports (was 22vh — too much on 812px+). */
  .notify { bottom: 16vh; }
}

/* Borderless single-field row (.signupRow → .signup). The ⏎ glyph sits at the
   end of the input, visible only once the user has typed. */
.signup {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: min(420px, 100%);
  min-width: 0;
}

/* Signup status ("you're a mesher now" / errors). Absolutely placed just below
   the input row so it never disrupts the flex layout. */
.signup-status {
  position: absolute;
  top: calc(100% + 0.65rem);
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: clamp(0.8rem, 1.3vw, 0.92rem);
  letter-spacing: 0.02em;
  color: #d4d4d4;
  pointer-events: none;
  animation: statusIn 0.45s ease both;
}

@keyframes statusIn {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: none; }
}

/* (.signupInput → .signup-input). No visible border — the molten .email-line
   is the underline. Fixed light grey so Warp's evening warmth never tints it. */
.signup-input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 2rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  color: #d4d4d4;
  /* Centre the typed text + placeholder, so the underline (which tracks the
     text width) stays centred under whatever is showing. */
  text-align: center;
  /* Same face as the subheading/tagline — JetBrains Mono. */
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  /* 1rem floor (=16px): below 16px iOS Safari force-zooms the page on focus and
     never zooms back, wrecking the layout. clamp keeps the desktop scale-up. */
  font-size: clamp(1rem, 1.6vw, 1.1rem);
  outline: none;
  transition: border-color 0.3s;
  animation: emailPulse 4.5s ease-in-out infinite;
  caret-color: var(--fg);
}

.signup-input::placeholder {
  color: #c4c4c4;
  transition: color 0.3s;
  text-align: center;
}

.signup-input:focus {
  border-bottom-color: transparent;
}

.signup-input:focus::placeholder {
  /* Keep the prompt legible while the empty field is focused — it was var(--dim)
     (#3a3a3f), near-invisible on black, exactly when the user is reading what to
     type. The placeholder vanishes the moment a value is entered, so a dimmed
     focused-empty state only hid the ask. */
  color: #8f8f8f;
}

.signup-input:disabled {
  opacity: 0.6;
}

/* Narrow phones: the long placeholders ("input email here to get looped in",
   "what should we call you? (optional)") used to be shrunk below 16px to fit the
   field — but a sub-16px input makes iOS Safari force-zoom on focus and break the
   layout. So we HOLD the 16px floor and instead trim horizontal padding to the
   minimum so the placeholder still fits. The ⏎/→ glyph only appears once there's
   typed text, so the tighter right padding is safe. */
@media (max-width: 540px) {
  .signup-input {
    padding: 0.5rem 0.4rem;
    font-size: 16px;
  }
}

@keyframes emailPulse {
  0%, 100% { text-shadow: 0 0 0 rgba(255, 255, 255, 0); }
  50% { text-shadow: 0 0 9px rgba(255, 255, 255, 0.22); }
}

/* Enter glyph (.enter) — hidden by default, fades in when input has content. */
.enter {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 1.5rem;
  height: 1.5rem;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, color 0.3s ease;
  padding: 0;
  line-height: 1;
}

.enter.visible {
  opacity: 1;
  pointer-events: auto;
}

.enter.visible:hover {
  color: var(--fg);
}

.enter.sent {
  color: var(--fg);
  pointer-events: none;
}

/* --- Mode toggle — a single day/night icon (sun by day, moon at night).
   BOTTOM-LEFT, just above the footer's time readout. Above the red filter so it
   stays legible at night. */
.mode-toggle {
  position: fixed;
  bottom: 3rem;
  left: clamp(1rem, 3vw, 1.75rem);
  z-index: 10002;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.62);
  cursor: pointer;
  /* Soft white glow + slow breathe, mirroring the wordmark + link mark. */
  animation: toggleGlow 6s ease-in-out infinite;
  transition: color 0.3s ease;
}

@keyframes toggleGlow {
  0%, 100% {
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.30)) drop-shadow(0 0 12px rgba(255, 255, 255, 0.14));
  }
  50% {
    filter: drop-shadow(0 0 7px rgba(255, 255, 255, 0.45)) drop-shadow(0 0 18px rgba(255, 255, 255, 0.20));
  }
}

.mode-toggle:hover { color: rgba(255, 255, 255, 0.92); }
.mode-toggle:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.4);
  outline-offset: 3px;
}
.mode-toggle svg { display: block; width: 24px; height: 24px; }

/* --- Warp night gels (Warp .desaturate/.redFilter) ----------------------
   Two stacked full-viewport gels driven by the local hour in JS:
   1) desaturate the whole site, 2) multiply red over the result. */
.warp-desaturate {
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  background: #808080;
  mix-blend-mode: saturation;
  opacity: 0;
  transition: opacity 4s ease;
  will-change: opacity;
}

.warp-red {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  /* A safelight, not a flat gel: warm at the centre, deepening to the edges like
     a real bulb thrown into a dark room. Stays this side of pure red so warm
     tones still read. */
  background: radial-gradient(125% 95% at 50% 42%, #ff2a16 0%, #e60d00 54%, #a30000 100%);
  mix-blend-mode: multiply;
  opacity: 0;
  transition: opacity 4s ease;
  will-change: opacity, filter;
  animation: redBulbBreath 6.5s ease-in-out infinite;
}

@keyframes redBulbBreath {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(0.92); }
}

/* The email prompt's underline (Warp .emailLine → .email-line). Painted above
   the red gel (z 10000 > 9999) so multiply can never tint it — stays white.
   Un-gated: visible in both day and night, so default opacity 1 (JS may still
   set it). The flicker animates filter/background-position only, never opacity. */
.email-line {
  position: fixed;
  left: 50%;
  bottom: clamp(4.5rem, 10vw, 8rem);
  transform: translateX(-50%);
  width: min(168px, 46vw);
  height: 1px;
  background: linear-gradient(
    90deg,
    #ffffff 0%,
    #eaeaea 12%,
    #ffffff 26%,
    #808080 34%,
    #ffffff 48%,
    #fbfbfb 60%,
    #6c6c6c 71%,
    #ffffff 84%,
    #cfcfcf 93%,
    #ffffff 100%
  );
  background-size: 220% 100%;
  z-index: 10000;
  pointer-events: none;
  opacity: 1;
  transition: opacity 4s ease;
  animation:
    emberFlow 7s linear infinite,
    emberFlicker 1.9s ease-in-out infinite;
  will-change: opacity, filter, background-position;
}

@keyframes emberFlow {
  from { background-position: 0 0; }
  to { background-position: -220% 0; }
}

@keyframes emberFlicker {
  0%,
  100% {
    filter: brightness(1) drop-shadow(0 0 2px rgba(255, 200, 150, 0.45));
  }
  50% {
    filter: brightness(0.8) drop-shadow(0 0 3px rgba(255, 160, 120, 0.55));
  }
}

/* --- Reduced motion (mirrors all source @media blocks) ------------------ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  canvas#field {
    opacity: 0.35;
  }
  .hero-word,
  .hero-word::after {
    animation: none;
  }
  .mode-toggle {
    transition: none;
  }
  .email-line {
    animation: none;
  }
}

/* --- Ambient meta-bar -----------------------------------------------------
   Fixed strip at the very bottom. Contact email sits bottom-left, paired
   with the red-bulb above it. Tiny mono, muted; above the warp gels so
   it stays legible at night. Only the email is clickable. */
.meta-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1rem;
  padding: 0.9rem clamp(1rem, 3vw, 1.75rem);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.86rem;
  letter-spacing: 0.02em;
  color: rgba(var(--fg-rgb), 0.6);
  pointer-events: none;
}
.meta-bar > * {
  pointer-events: auto;
}
.meta-time {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.meta-signals {
  flex: 1;
  min-width: 0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.meta-signals.show {
  opacity: 1;
}
.meta-contact {
  color: rgba(var(--fg-rgb), 0.66);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.3s ease;
  /* It's a <button> now (copies the address on click) — strip the chrome so it
     reads as text. */
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}
.meta-contact:hover {
  color: rgba(var(--fg-rgb), 0.9);
}

/* --- Red bulb (bottom-left): a minimal vertical slider over a bulb symbol.
   Top = full red, bottom = off. Hollow-circle thumb. The bulb glass fills with
   --red-level (set by JS) and falls to a hollow outline when off; tap the bulb
   to toggle it like a switch. No text label. */
.red-bulb {
  position: fixed;
  bottom: 3rem;
  left: clamp(1rem, 3vw, 1.75rem);
  z-index: 10002;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.red-bulb-slider {
  -webkit-appearance: none;
  appearance: none;
  writing-mode: vertical-lr;
  direction: rtl;
  width: 16px;
  height: 66px;
  background: transparent;
  outline: none;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.red-bulb-slider.slider-visible {
  opacity: 1;
  pointer-events: auto;
}
.red-bulb-slider::-webkit-slider-runnable-track {
  width: 2px;
  height: 66px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 2px;
}
.red-bulb-slider::-moz-range-track {
  width: 2px;
  height: 66px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 2px;
}
.red-bulb-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  margin-left: -5px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid #ff5a44;
  box-shadow: 0 0 4px rgba(255, 59, 47, 0.45);
  cursor: pointer;
}
.red-bulb-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid #ff5a44;
  box-shadow: 0 0 4px rgba(255, 59, 47, 0.45);
  cursor: pointer;
}
.red-bulb-symbol {
  display: inline-flex;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: rgb(var(--bulb-rgb, 255, 255, 255));
  cursor: pointer;
  transition: color 1.2s ease;
}
.red-bulb-symbol svg { display: block; width: 18px; height: 18px; overflow: visible; }
.red-bulb-glass {
  fill: rgb(var(--bulb-rgb, 255, 255, 255));
  fill-opacity: var(--red-level, 0);
  stroke: currentColor;
  stroke-width: 1.4;
  transition: fill-opacity 1.2s ease, fill 1.2s ease, filter 1.2s ease;
}
.red-bulb.is-lit .red-bulb-glass {
  filter: drop-shadow(0 0 5px rgba(var(--bulb-rgb, 255, 80, 60), 0.6));
}
@media (max-width: 540px) {
  .meta-bar {
    font-size: 0.75rem;
  }
  .meta-signals {
    display: none;
  }
}
