/* ===========================================
   HYPHENBOX SITE, SHARED STYLES
   Inherits the deck's Wire Protocol system
   =========================================== */

:root {
  color-scheme: light;

  --bg-primary: #f7f5f0;
  --bg-alt: #f0ede6;
  --bg-ink: #1a1a1a;
  --text-primary: #1a1a1a;
  --text-secondary: rgba(26, 26, 26, 0.75);
  --text-tertiary: rgba(26, 26, 26, 0.45);
  --text-quaternary: rgba(26, 26, 26, 0.28);
  --accent: #d62828;
  --accent-light: rgba(214, 40, 40, 0.07);
  --accent-border: rgba(214, 40, 40, 0.25);
  --border: rgba(26, 26, 26, 0.1);
  --border-strong: rgba(26, 26, 26, 0.2);
  --dot-color: rgba(26, 26, 26, 0.09);
  --grid-color: rgba(0, 0, 0, 0.02);
  --shadow-soft: 0 30px 60px -20px rgba(0, 0, 0, 0.25);

  --font-display: 'General Sans', sans-serif;
  --font-body: 'General Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);

  --max-w: 1280px;
  --gutter: clamp(1.25rem, 4vw, 3rem);
}

/* ===========================================
   DARK MODE
   - Light is the default. Dark only activates when user toggles via nav.
   - No prefers-color-scheme auto-switch — explicit opt-in only.
   =========================================== */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-primary: #0d0d11;
  --bg-alt: #17171c;
  --bg-ink: #f7f5f0;
  --text-primary: #f7f5f0;
  --text-secondary: rgba(247, 245, 240, 0.76);
  --text-tertiary: rgba(247, 245, 240, 0.48);
  --text-quaternary: rgba(247, 245, 240, 0.30);
  --accent: #e8483e;
  --accent-light: rgba(232, 72, 62, 0.14);
  --accent-border: rgba(232, 72, 62, 0.34);
  --border: rgba(247, 245, 240, 0.12);
  --border-strong: rgba(247, 245, 240, 0.22);
  --dot-color: rgba(247, 245, 240, 0.10);
  --grid-color: rgba(255, 255, 255, 0.025);
  --shadow-soft: 0 30px 60px -20px rgba(0, 0, 0, 0.65);
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg-primary);
  font-family: var(--font-body);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "ss02";
  line-height: 1.5;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

/* ===========================================
   NAV
   =========================================== */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(0.9rem, 1.8vw, 1.4rem) var(--gutter);
  background: rgba(247, 245, 240, 0.72);
  backdrop-filter: saturate(1.2) blur(10px);
  -webkit-backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s ease;
}
.nav.scrolled { border-bottom-color: var(--border); }

.nav-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.nav-logo {
  height: 32px;
  width: auto;
  opacity: 0.9;
}
.nav-divider {
  width: 1px;
  height: 16px;
  background: var(--border-strong);
}
.nav-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-meta .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.35; transform: scale(0.7); }
}

.nav-right {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2.5vw, 2rem);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.nav-link {
  color: var(--text-secondary);
  transition: color 0.25s ease;
  position: relative;
  padding: 4px 0;
}
.nav-link:hover { color: var(--accent); }
.nav-link[aria-current="page"] { color: var(--text-primary); }
.nav-link[aria-current="page"]::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: var(--accent);
}

.nav-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  transition: all 0.25s ease;
}
.nav-cta:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}
.nav-cta .arr { transition: transform 0.25s var(--ease-out-expo); }
.nav-cta:hover .arr { transform: translate(2px, -2px); }

@media (max-width: 720px) {
  .nav-meta { display: none; }
  .nav-right { gap: 14px; }
  .nav-cta { padding: 6px 10px; }
}

/* ===========================================
   LAYOUT PRIMITIVES
   =========================================== */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--gutter);
  position: relative;
}

section {
  position: relative;
  padding: clamp(4rem, 10vw, 9rem) 0;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: clamp(2rem, 4vw, 3.5rem);
}
.section-head .tag {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
  padding: 3px 8px;
  border: 1px solid var(--accent-border);
  background: var(--accent-light);
  border-radius: 2px;
  flex-shrink: 0;
}
.section-head .rule {
  flex: 1;
  height: 1px;
  background: var(--border);
}
.section-head .count {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* ===========================================
   TYPOGRAPHY
   =========================================== */
.display-xl {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 6.5vw, 5.6rem);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.035em;
  color: var(--text-primary);
  text-wrap: balance;
}
.display-lg {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.8vw, 3.8rem);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  text-wrap: balance;
}
.display-md {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.8vw, 2.2rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--text-primary);
  text-wrap: balance;
}

.body-lg {
  font-size: clamp(1.05rem, 1.5vw, 1.2rem);
  line-height: 1.6;
  color: var(--text-secondary);
  font-weight: 400;
  max-width: 58ch;
  text-wrap: pretty;
}
.body-md {
  font-size: clamp(0.98rem, 1.2vw, 1.05rem);
  line-height: 1.65;
  color: var(--text-secondary);
  text-wrap: pretty;
}
.body-sm {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-weight: 500;
}
.label.accent { color: var(--accent); }

.accent { color: var(--accent); }

/* ===========================================
   UTILITY: CORNER CROSSHAIRS + ACCENT BAR
   =========================================== */
.crosshair {
  position: absolute;
  width: 14px; height: 14px;
  border-color: var(--border-strong);
  opacity: 0.5;
  pointer-events: none;
}
.crosshair.tl { top: 0; left: 0; border-top: 1px solid; border-left: 1px solid; }
.crosshair.tr { top: 0; right: 0; border-top: 1px solid; border-right: 1px solid; }
.crosshair.bl { bottom: 0; left: 0; border-bottom: 1px solid; border-left: 1px solid; }
.crosshair.br { bottom: 0; right: 0; border-bottom: 1px solid; border-right: 1px solid; }

/* ===========================================
   REVEAL ON SCROLL
   =========================================== */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.9s var(--ease-out-expo), transform 0.9s var(--ease-out-expo);
}
.reveal.in { opacity: 1; transform: none; }
.reveal[data-delay="1"] { transition-delay: 0.08s; }
.reveal[data-delay="2"] { transition-delay: 0.16s; }
.reveal[data-delay="3"] { transition-delay: 0.24s; }
.reveal[data-delay="4"] { transition-delay: 0.32s; }
.reveal[data-delay="5"] { transition-delay: 0.4s; }

/* ===========================================
   HORIZONTAL RULE (hairline w/ tick marks)
   =========================================== */
.rule-tick {
  position: relative;
  height: 1px;
  background: var(--border);
  margin: clamp(3rem, 6vw, 5rem) 0;
}
.rule-tick::before,
.rule-tick::after {
  content: '';
  position: absolute;
  top: -4px;
  width: 1px;
  height: 9px;
  background: var(--border-strong);
}
.rule-tick::before { left: 0; }
.rule-tick::after { right: 0; }

/* ===========================================
   BUTTONS
   =========================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: translateY(100%);
  transition: transform 0.4s var(--ease-out-expo);
  z-index: -1;
}
.btn:hover { color: #fff; border-color: var(--accent); }
.btn:hover::after { transform: translateY(0); }
.btn .arr { transition: transform 0.3s var(--ease-out-expo); }
.btn:hover .arr { transform: translate(3px, -3px); }

.btn-primary {
  background: var(--bg-ink);
  color: var(--bg-primary);
  border-color: var(--bg-ink);
}
.btn-primary::after { background: var(--accent); }
.btn-primary:hover { border-color: var(--accent); color: #fff; }

/* ===========================================
   FOOTER
   =========================================== */
.footer {
  border-top: 1px solid var(--border);
  padding: clamp(3rem, 6vw, 4.5rem) 0 clamp(1.5rem, 3vw, 2rem);
  margin-top: clamp(3rem, 6vw, 5rem);
  position: relative;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr 1fr;
  gap: clamp(1.5rem, 3vw, 3rem);
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
}
.footer-col h4 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-weight: 500;
  margin-bottom: 18px;
}
.footer-col ul { list-style: none; }
.footer-col li {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.footer-col a { transition: color 0.2s ease; }
.footer-col a:hover { color: var(--accent); }
.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.footer-brand img {
  height: 28px;
  width: auto;
  align-self: flex-start;
}
.footer-brand p {
  font-size: 0.92rem;
  color: var(--text-secondary);
  max-width: 30ch;
  line-height: 1.55;
}
.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-top: clamp(1rem, 2vw, 1.5rem);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  flex-wrap: wrap;
}
.footer-bottom .addr {
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  text-transform: none;
  font-size: 11px;
}
@media (max-width: 720px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
  .footer-brand { grid-column: 1 / -1; }
}

/* ===========================================
   TWEAKS PANEL
   =========================================== */
#tweaks-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 280px;
  background: var(--bg-primary);
  border: 1px solid var(--border-strong);
  box-shadow: 0 30px 60px -20px rgba(0,0,0,0.25);
  z-index: 200;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  display: none;
}
#tweaks-panel.active { display: block; }
#tweaks-panel .tp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}
#tweaks-panel .tp-title {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-primary);
}
#tweaks-panel .tp-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2.4s ease-in-out infinite;
}
#tweaks-panel .tp-body { padding: 14px; }
#tweaks-panel .tp-group { margin-bottom: 14px; }
#tweaks-panel .tp-group:last-child { margin-bottom: 0; }
#tweaks-panel .tp-label {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  font-size: 10px;
}
#tweaks-panel .tp-options {
  display: flex;
  gap: 4px;
  flex-direction: column;
}
#tweaks-panel .tp-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-align: left;
}
#tweaks-panel .tp-opt:hover { border-color: var(--border-strong); color: var(--text-primary); }
#tweaks-panel .tp-opt.active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}
#tweaks-panel .tp-opt .idx {
  font-size: 9px;
  color: var(--text-tertiary);
  letter-spacing: 0.15em;
}
#tweaks-panel .tp-opt.active .idx { color: var(--accent); }

/* ===========================================
   MOTION: nav section meta, scroll progress, tilt, magnet
   =========================================== */

.nav-section-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1;
}
.nav-section-meta .si {
  color: var(--accent);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.nav-section-meta .sep { color: var(--text-quaternary); }
.nav-section-meta .sn { color: var(--text-secondary); letter-spacing: 0.12em; }
.nav-section-meta, .nav-divider {
  transition: opacity 0.35s ease;
}
.nav-section-meta.hb-hidden, .nav-divider.hb-hidden {
  opacity: 0;
  pointer-events: none;
}
@media (max-width: 720px) {
  .nav-section-meta, .nav-divider { display: none; }
}

.nav-progress {
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  height: 2px;
  background: transparent;
  pointer-events: none;
}
.nav-progress-fill {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 0.1s linear;
  transform-origin: left center;
}

/* Magnetic CTA: keep transform responsive while hovered, smooth release after */
.btn-primary { transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease, transform 0.45s cubic-bezier(0.16, 1, 0.3, 1); }
.btn-primary.hb-magnet-active { transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease, transform 0.1s ease-out; }

/* Keep the hero title sized so the longest cycling phrase fits on line 2 */
.hero-title {
  font-size: clamp(2.2rem, 5.4vw, 4.6rem);
  text-wrap: pretty;        /* override display-xl's 'balance' so typing doesn't re-flow the h1 */
  text-align: left;
}
@media (max-width: 720px) {
  .hero-title { font-size: clamp(1.75rem, 6.2vw, 3rem); }
}
@media (max-width: 480px) {
  .hero-title { font-size: clamp(1.5rem, 6vw, 2.2rem); }
  .hero-cycle, .hero-cycle-ghost, .hero-cycle-live { white-space: normal; }
}

/* Hero cycling phrase: typewriter with blinking caret.
   Ghost reserves the widest phrase's width so the layout never shifts. */
.hero-cycle {
  position: relative;
  display: inline-block;
  white-space: nowrap;
  vertical-align: baseline;
}
.hero-cycle-ghost {
  visibility: hidden;
  pointer-events: none;
  user-select: none;
}
.hero-cycle-live {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
}
.hero-cycle-live::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 0.9em;
  background: currentColor;
  margin-left: 0.08em;
  vertical-align: -0.14em;
  animation: hb-caret-blink 1s steps(1, end) infinite;
}
.hero-cycle.hb-typing .hero-cycle-live::after { animation: none; opacity: 1; }
@keyframes hb-caret-blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

/* Capability card tilt: needs perspective on the grid + overridable transition */
.caps-grid { perspective: 1200px; }
.cap { will-change: transform; }
.cap { transition: background 0.4s ease, transform 0.45s cubic-bezier(0.16, 1, 0.3, 1); }
.cap.hb-tilt-active { transition: background 0.4s ease, transform 0.08s ease-out; }

@media (prefers-reduced-motion: reduce) {
  .nav-progress-fill { transition: none; }
  .btn-primary, .cap { transition: none; }
}

/* ===========================================
   MOBILE OPTIMIZATIONS
   =========================================== */

/* Tighter nav on phones */
@media (max-width: 560px) {
  .nav { padding: 0.8rem var(--gutter); }
  .nav-logo { height: 26px; }
  .nav-cta {
    padding: 6px 10px;
    font-size: 10px;
    letter-spacing: 0.08em;
  }
  .nav-cta .arr { margin-left: 2px; }
}

/* Section heads: let tag + count breathe on narrow, hide the hairline rule */
@media (max-width: 560px) {
  .section-head {
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
  }
  .section-head .rule { display: none; }
  .section-head .count { font-size: 10px; }
}

/* Bigger tap targets for form chips */
@media (max-width: 720px) {
  .chip {
    padding: 10px 14px;
    font-size: 12px;
    min-height: 40px;
  }
}

/* Buttons: scale down on tablets and phones so they don't dwarf the headline */
@media (max-width: 720px) {
  .btn {
    padding: 11px 16px;
    font-size: 11px;
    gap: 8px;
  }
}
@media (max-width: 480px) {
  .btn {
    padding: 9px 14px;
    font-size: 10.5px;
    letter-spacing: 0.1em;
    gap: 6px;
  }
}

/* Footer: stack the bottom row */
@media (max-width: 520px) {
  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .footer-col h4 { margin-bottom: 12px; }
  .footer-col li { margin-bottom: 8px; }
}

/* Prevent long words from causing horizontal scroll */
@media (max-width: 480px) {
  .display-xl, .display-lg, .display-md {
    overflow-wrap: break-word;
  }
}

/* ===========================================
   DARK-MODE SURFACE OVERRIDES
   Targets styles that use hardcoded light-mode values
   =========================================== */

/* Nav surface: glassier tint to match the dark page */
:root[data-theme="dark"] .nav {
  background: rgba(13, 13, 17, 0.72);
}

/* Invert the wordmark logo to stay visible on dark */
:root[data-theme="dark"] .nav-logo,
:root[data-theme="dark"] .footer-brand img {
  filter: invert(1) hue-rotate(180deg);
}

/* Theme toggle button — tiny mono control tucked into the nav */
.nav-theme {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  line-height: 1;
  border-radius: 0;
}
.nav-theme:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-light);
}
.nav-theme .tg-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid currentColor;
  background: transparent;
  position: relative;
  transition: background 0.25s ease;
}
:root[data-theme="dark"] .nav-theme .tg-dot {
  background: currentColor;
}
@media (max-width: 560px) {
  .nav-theme { padding: 5px 8px; gap: 6px; }
  .nav-theme .tg-label { display: none; }
}

/* Partners section: always the "inverted band" — scope its palette so it
   stays ink/cream regardless of page theme, then nudge the bg slightly
   darker in dark mode for continued section contrast. */
.partners {
  --bg-primary: #f7f5f0;
  --bg-ink: #1a1a1a;
  --text-primary: #f7f5f0;
  --text-secondary: rgba(247, 245, 240, 0.75);
  --text-tertiary: rgba(247, 245, 240, 0.45);
  --text-quaternary: rgba(247, 245, 240, 0.30);
  --border: rgba(247, 245, 240, 0.15);
  --border-strong: rgba(247, 245, 240, 0.22);
  --accent-light: rgba(214, 40, 40, 0.14);
  --accent-border: rgba(214, 40, 40, 0.32);
  --grid-color: rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
}
:root[data-theme="dark"] .partners { background: #050507; }

/* Capability visual "screen" stays dark in both modes — slightly deeper black in dark mode */
:root[data-theme="dark"] .cap-visual { background: #050507; }

/* Form inputs: ensure readable contrast in dark mode */
:root[data-theme="dark"] .input,
:root[data-theme="dark"] .textarea {
  background: var(--bg-alt);
  color: var(--text-primary);
  border-color: var(--border);
}
:root[data-theme="dark"] .input::placeholder,
:root[data-theme="dark"] .textarea::placeholder {
  color: var(--text-tertiary);
}

/* Smooth cross-fade on theme change (opt-in to avoid transitioning every property) */
html {
  transition: background-color 0.3s ease, color 0.3s ease;
}
body, .nav, section, .cap, .shift, .partners, .cta-band, .footer, .btn, .btn-primary, .chip, .multiplier, .shift-note, .pipe-stage {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

