/* ==========================================================================
   joidb Landing Page — Custom Stylesheet
   The Midnight Index aesthetic.
   Colors, fonts, and motion per BRANDING.md & CREATIVE_BRIEF.md.

   Palette:
   --bg-primary:    #08080C    page background (near-black, 2% warm)
   --bg-surface:    #12121A    cards, search bar, elevated surfaces
   --bg-elevated:   #1A1A26    dropdowns, tooltips, hover states
   --text-primary:  #EEE8DF    body copy, headlines (warm off-white)
   --text-secondary:#8A8694    supporting copy, metadata (muted gray-violet)
   --text-tertiary: #504D58    placeholder text, disabled, subtle dividers
   --accent-crimson:#D6495A    primary CTAs, active filters, search focus
   --accent-amber:  #E8855A    hover states, badges, loading pulse
   --accent-violet: #7B4DAE    taxonomy badges, network nodes
   --border-default:#262233    card borders, input borders, dividers
   --border-active: #D6495A    focused inputs, active filter borders
   --success:       #4A9E6B    confirmation messages

   Fonts: Space Grotesk (headings), Inter (body), JetBrains Mono (mono/data)
   ========================================================================== */

/* --- Google Fonts Import --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,400;14..32,500;14..32,700&family=JetBrains+Mono:wght@400;700&family=Space+Grotesk:wght@500;700&display=swap');

/* --- CSS Custom Properties --- */
:root {
  --bg-primary: #08080C;
  --bg-surface: #12121A;
  --bg-elevated: #1A1A26;
  --text-primary: #EEE8DF;
  --text-secondary: #8A8694;
  --text-tertiary: #504D58;
  --accent-crimson: #D6495A;
  --accent-amber: #E8855A;
  --accent-violet: #7B4DAE;
  --border-default: #262233;
  --border-active: #D6495A;
  --success: #4A9E6B;
  --font-heading: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --section-pad-y: 120px;
  --section-pad-x: 24px;
  --content-max: 1200px;
  --copy-max: 680px;
  --search-max: 880px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --ease-out: 150ms ease-out;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  overflow-x: hidden;
}

:focus-visible {
  outline: 2px solid var(--accent-crimson);
  outline-offset: 2px;
}

::selection {
  background-color: var(--accent-crimson);
  color: var(--text-primary);
}

a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--ease-out);
}

a:hover { color: var(--accent-crimson); }

/* ==========================================================================
   Background Textures — The Midnight Index
   ========================================================================== */

/* Archive grid — subtle, like catalog paper grid lines */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--border-default) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-default) 1px, transparent 1px);
  background-size: 64px 64px;
  opacity: 0.25;
  mask-image: radial-gradient(ellipse 60% 50% at 50% 40%, black 30%, transparent 70%);
}

/* Film grain — barely perceptible texture */
.bg-grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* ==========================================================================
   Utility: Section rule
   ========================================================================== */
.section-rule {
  max-width: var(--content-max);
  margin: 0 auto;
  height: 1px;
  background-color: var(--border-default);
  padding: 0 var(--section-pad-x);
}

/* --- Scroll-triggered fade-in --- */
.fade-section {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 400ms ease-out, transform 400ms ease-out;
}

.fade-section.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   Navigation
   ========================================================================== */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 16px 24px;
  background-color: rgba(8, 8, 12, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.nav-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
}

.nav-lockup:hover { color: var(--text-primary); }

.nav-mark { flex-shrink: 0; }

.nav-wordmark {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.01em;
}

/* ==========================================================================
   Hero Section
   ========================================================================== */
.hero {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 120px var(--section-pad-x) 80px;
  text-align: center;
}

/* Server rack archive illustration */
.hero-illustration {
  margin-bottom: 48px;
  opacity: 0.5;
}

.hero-illustration svg {
  width: 100%;
  max-width: 480px;
  height: auto;
}

.hero-headline {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 3.25rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  max-width: var(--copy-max);
  margin-bottom: 48px;
}

.hero-search-wrap {
  width: 100%;
  max-width: var(--search-max);
  display: flex;
  gap: 0;
  margin-bottom: 32px;
}

.hero-search {
  flex: 1;
  height: 52px;
  padding: 12px 20px;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text-primary);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-right: none;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  transition: border-color var(--ease-out), padding var(--ease-out);
  outline: none;
}

.hero-search::placeholder {
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 0.9375rem;
}

.hero-search:focus {
  border-color: var(--accent-crimson);
  padding-top: 16px;
  padding-bottom: 16px;
}

.hero-search-cta {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  height: 52px;
  padding: 0 28px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 1rem;
  color: var(--text-primary);
  background-color: var(--accent-crimson);
  border: 1px solid var(--accent-crimson);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  cursor: pointer;
  transition: background-color var(--ease-out), border-color var(--ease-out), color var(--ease-out);
}

.hero-search-cta:hover {
  background-color: var(--accent-amber);
  border-color: var(--accent-amber);
  color: var(--text-primary);
}

.hero-subhead {
  font-size: 1.25rem;
  line-height: 1.5;
  color: var(--text-secondary);
  max-width: var(--copy-max);
}

.hero-soon {
  display: inline-block;
  margin-left: 0.35em;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--accent-amber);
  letter-spacing: 0.04em;
}

/* ==========================================================================
   Section Shared
   ========================================================================== */
.section-headline {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 2rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin-bottom: 40px;
}

section {
  position: relative;
  z-index: 2;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--section-pad-y) var(--section-pad-x);
}

/* ==========================================================================
   What It Does
   ========================================================================== */
.what { background-color: var(--bg-primary); }

.what-body {
  max-width: var(--copy-max);
  margin-bottom: 48px;
}

.what-body p { margin-bottom: 20px; }
.what-body p:last-child { margin-bottom: 0; }

.what-body em {
  font-style: normal;
  font-weight: 500;
  color: var(--text-primary);
}

/* Inline taxonomy */
.taxonomy {
  max-width: var(--copy-max);
  margin-bottom: 40px;
}

.taxonomy-group {
  margin-bottom: 16px;
  line-height: 1.7;
}

.taxonomy-label {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.0625rem;
  color: var(--text-primary);
}

.taxonomy-terms { color: var(--text-secondary); }

.taxonomy-sep {
  color: var(--text-tertiary);
  margin: 0 4px;
}

.cta-link {
  display: inline-block;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 1rem;
  color: var(--accent-crimson);
  transition: color var(--ease-out), transform var(--ease-out);
}

.cta-link:hover {
  color: var(--accent-amber);
  transform: translateX(4px);
}

/* ==========================================================================
   How It Works
   ========================================================================== */
.how { background-color: var(--bg-surface); }

.how-steps {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  margin-bottom: 48px;
}

.how-step {
  position: relative;
  padding: 40px 32px;
  border-right: 1px solid var(--border-default);
}

.how-step:last-child { border-right: none; }

.how-step-num {
  position: absolute;
  top: 16px;
  left: 32px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 4.5rem;
  line-height: 1;
  color: var(--bg-elevated);
  pointer-events: none;
  z-index: 0;
}

.how-step-title {
  position: relative;
  z-index: 1;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 1.25rem;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.how-step-desc {
  position: relative;
  z-index: 1;
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* Step 1: filter chips */
.how-step-visual-filters {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.how-chip {
  display: inline-block;
  padding: 4px 12px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent-crimson);
  background-color: rgba(214, 73, 90, 0.12);
  border: 1px solid var(--accent-crimson);
  border-radius: var(--radius-sm);
}

/* Step 2: miniature result card */
.how-card {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 12px;
  padding: 12px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}

.how-card-thumb {
  width: 80px;
  height: 56px;
  flex-shrink: 0;
  background-color: var(--bg-surface);
  border-radius: var(--radius-sm);
  filter: blur(8px);
}

.how-card-body { min-width: 0; }

.how-card-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.how-card-chips { display: flex; gap: 4px; margin-bottom: 6px; }

.how-card-chip {
  display: inline-block;
  padding: 1px 8px;
  font-size: 0.6875rem;
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
}

.how-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.how-card-dur { font-family: var(--font-mono); }

/* Step 3: refine link */
.how-refine-link {
  position: relative;
  z-index: 1;
  font-size: 1rem;
  color: var(--accent-crimson);
}

.how-note {
  max-width: var(--copy-max);
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ==========================================================================
   Key Features (3x2 grid)
   ========================================================================== */
.features { background-color: var(--bg-primary); }

.features-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1px;
  background-color: var(--border-default);
}

.feature-cell {
  padding: 36px 32px;
  background-color: var(--bg-surface);
  transition: background-color var(--ease-out);
}

.feature-cell:hover {
  background-color: var(--bg-elevated);
}

.feature-icon {
  margin-bottom: 16px;
  opacity: 0.7;
}

.feature-icon svg {
  display: block;
}

.feature-label {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.feature-desc {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* ==========================================================================
   Waitlist Section — The Terminal
   ========================================================================== */
.waitlist {
  background-color: var(--bg-surface);
  text-align: center;
  padding-top: 140px;
  padding-bottom: 140px;
}

.waitlist .section-headline {
  max-width: var(--copy-max);
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 20px;
}

/* Database cylinder mark — red stamp, no animation */
.waitlist-mark {
  margin-bottom: 36px;
  opacity: 0.8;
}

.waitlist-mark svg {
  display: block;
  margin: 0 auto;
}

/* Live stat — database heartbeat in mono */
.waitlist-stat {
  margin-bottom: 36px;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.waitlist-stat-num {
  font-weight: 700;
  font-size: 1.375rem;
  color: var(--accent-crimson);
  margin-right: 0.3em;
}

.waitlist-stat-label {
  opacity: 0.65;
}

.waitlist-body {
  max-width: var(--copy-max);
  margin: 0 auto 40px;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.waitlist-form {
  max-width: var(--search-max);
  margin: 0 auto 20px;
}

.waitlist-input-row { display: flex; gap: 0; }

.waitlist-input {
  flex: 1;
  height: 52px;
  padding: 12px 20px;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-right: none;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  outline: none;
  transition: border-color var(--ease-out);
}

.waitlist-input::placeholder {
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 0.9375rem;
}

.waitlist-input:focus { border-color: var(--accent-crimson); }

.waitlist-cta {
  flex-shrink: 0;
  height: 52px;
  padding: 0 32px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 1rem;
  color: var(--text-primary);
  background-color: var(--accent-crimson);
  border: 1px solid var(--accent-crimson);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  cursor: pointer;
  transition: background-color var(--ease-out), border-color var(--ease-out);
}

.waitlist-cta:hover {
  background-color: var(--accent-amber);
  border-color: var(--accent-amber);
}

.waitlist-cta:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.waitlist-status {
  font-size: 0.875rem;
  margin-top: 14px;
  min-height: 22px;
}

.waitlist-status.success { color: var(--success); }
.waitlist-status.error { color: var(--accent-crimson); }

/* Privacy note — terminal prompt style */
.waitlist-privacy {
  max-width: var(--search-max);
  margin: 0 auto;
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  line-height: 1.6;
}

.waitlist-privacy-mono {
  font-family: var(--font-mono);
  color: var(--accent-crimson);
  margin-right: 0.4em;
}

/* ==========================================================================
   Helper Accordion — The Catalog Request Slip
   ========================================================================== */
.helper {
  margin-top: 64px;
  max-width: var(--search-max);
  margin-left: auto;
  margin-right: auto;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  text-align: left;
  overflow: hidden;
}

/* Toggle — full-width tab with crimson accent bar */
.helper-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 18px 24px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 1rem;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  transition: color var(--ease-out), background-color var(--ease-out);
}

.helper-toggle:hover {
  color: var(--text-primary);
  background-color: rgba(214, 73, 90, 0.04);
}

.helper-toggle[aria-expanded="true"] {
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-default);
}

/* Crimson accent bar — strengthens on expand */
.helper-toggle-bar {
  width: 3px;
  height: 18px;
  background-color: var(--accent-crimson);
  border-radius: 1.5px;
  opacity: 0.45;
  transition: opacity var(--ease-out), height 200ms ease-out;
  flex-shrink: 0;
}

.helper-toggle[aria-expanded="true"] .helper-toggle-bar {
  opacity: 1;
  height: 24px;
}

.helper-toggle-text {
  flex: 1;
  text-align: left;
}

.helper-toggle-icon {
  flex-shrink: 0;
  transition: transform 200ms ease-out;
}

.helper-toggle[aria-expanded="true"] .helper-toggle-icon {
  transform: rotate(45deg);
}

/* Panel — slides open with padding transition */
.helper-panel {
  overflow: hidden;
  transition: max-height 350ms ease-out, opacity 250ms ease-out, padding 250ms ease-out;
  max-height: 0;
  opacity: 0;
  padding: 0 24px;
}

.helper-panel.open {
  max-height: 750px;
  opacity: 1;
  padding: 28px 24px 32px;
}

.helper-intro {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
}

.helper-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.helper-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.helper-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.helper-input {
  height: 44px;
  padding: 0 14px;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--ease-out);
}

.helper-input::placeholder {
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.helper-input:focus { border-color: var(--accent-crimson); }

/* Submit — understated secondary action */
.helper-submit {
  align-self: flex-end;
  height: 40px;
  padding: 0 20px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-secondary);
  background-color: transparent;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--ease-out), border-color var(--ease-out), background-color var(--ease-out);
}

.helper-submit:hover {
  color: var(--accent-crimson);
  border-color: var(--accent-crimson);
  background-color: rgba(214, 73, 90, 0.06);
}

.helper-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.helper-status {
  font-size: 0.8125rem;
  min-height: 18px;
}

.helper-status.success { color: var(--success); }
.helper-status.error { color: var(--accent-crimson); }

/* Bottom spacer */
.page-end {
  height: 160px;
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */
@media (max-width: 768px) {
  :root {
    --section-pad-y: 72px;
    --section-pad-x: 20px;
  }

  .bg-grid { background-size: 40px 40px; }

  .hero {
    min-height: 90vh;
    padding-top: 100px;
    padding-bottom: 60px;
  }

  .hero-illustration { margin-bottom: 36px; }
  .hero-illustration svg { max-width: 320px; }

  .hero-headline {
    font-size: 2.25rem;
    margin-bottom: 32px;
  }

  .hero-search-wrap { flex-direction: column; }

  .hero-search {
    border-right: 1px solid var(--border-default);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
  }

  .hero-search:focus {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .hero-search-cta {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    width: 100%;
    justify-content: center;
  }

  .hero-subhead { font-size: 1.125rem; }
  .section-headline { font-size: 1.625rem; }

  .how-steps { grid-template-columns: 1fr; }

  .how-step {
    border-right: none;
    border-bottom: 1px solid var(--border-default);
    padding: 28px 24px;
  }

  .how-step:last-child { border-bottom: none; }

  .features-grid { grid-template-columns: 1fr; }
  .feature-cell { padding: 24px 20px; }

  .waitlist {
    padding-top: 80px;
    padding-bottom: 80px;
  }

  .waitlist-mark { margin-bottom: 28px; }

  .waitlist-stat { margin-bottom: 28px; }

  .waitlist-stat-num { font-size: 1.25rem; }

  .waitlist-body { margin-bottom: 28px; }

  .waitlist-input-row { flex-direction: column; }

  .waitlist-input {
    border-right: 1px solid var(--border-default);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
  }

  .waitlist-cta {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    width: 100%;
    justify-content: center;
  }

  .helper { margin-top: 48px; }

  .helper-toggle { padding: 16px 20px; }

  .helper-panel.open { padding: 24px 20px 28px; }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html { scroll-behavior: auto; }

  .fade-section {
    opacity: 1;
    transform: none;
  }
}
