/* ═══════════════════════════════════════════════════
   LVN Design System — shared.css
   Consistent theming, dark mode, transitions, 
   micro-interactions across all pages
   ═══════════════════════════════════════════════════ */

/* ── Theme Variables ── */
:root {
  /* Core palette */
  --navy: #0F1A2E;
  --deep: #0F1A2E;
  --slate: #3D5A80;
  --teal: #2A9D8F;
  --teal-glow: #34D1BF;
  --gold: #E9C46A;
  --warm-cream: #FAF8F5;
  --warm-gray: #F0EDE8;
  --mid-text: #384455;
  --light-text: #4F5B69;
  
  /* Semantic colors */
  --bg-primary: var(--warm-cream);
  --bg-card: white;
  --bg-subtle: var(--warm-gray);
  --text-primary: var(--navy, #0F1A2E);
  --text-secondary: var(--mid-text, #384455);
  --text-muted: var(--light-text, #4F5B69);
  --border-subtle: rgba(0,0,0,0.06);
  --border-accent: rgba(42,157,143,0.15);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.08);
  
  /* Typography */
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
  --space-2xl: 4rem;
  
  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  
  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;
  
  /* Nav height */
  --nav-height: 48px;
}

/* ── Dark Mode ── */
/* NOTE: prefers-color-scheme removed — dark mode is controlled ONLY via 
   [data-theme="dark"] attribute set by the theme toggle button.
   The media query was overriding page-specific light themes (hub page). */

[data-theme="dark"] {
  --bg-primary: #0C1220;
  --bg-card: #151E30;
  --bg-subtle: #1A2540;
  --text-primary: #E8ECF2;
  --text-secondary: #9BA8BD;
  --text-muted: #8A9AAE;
  --border-subtle: rgba(255,255,255,0.06);
  --border-accent: rgba(42,157,143,0.2);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
  --warm-cream: #0C1220;
  --warm-gray: #1A2540;
  --navy: #E8ECF2;
  --mid-text: #9BA8BD;
  --light-text: #6B7A92;
}

/* ── Base Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  color: var(--text-primary, #0F1A2E);
  background: var(--bg-primary);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-top: var(--nav-height);
}

::selection { background: rgba(42,157,143,0.25); }

/* ── Skip Link ── */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  z-index: 10000;
  padding: 0.5rem 1rem;
  background: var(--teal);
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 0 0 var(--radius-md) 0;
  text-decoration: none;
}
.skip-link:focus {
  left: 0;
  top: 0;
}

/* ── Navigation ── */
.lvn-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(15,26,46,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-accent);
  height: var(--nav-height);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
}

.lvn-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
}

.lvn-nav-logo {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  color: white;
  text-decoration: none;
  letter-spacing: 0.02em;
}
.lvn-nav-logo span { color: var(--gold); }

.lvn-nav-links {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.lvn-nav-links a {
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(255,255,255,0.78);
  text-decoration: none;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast) var(--ease-out);
}
.lvn-nav-links a:hover,
.lvn-nav-links a.active {
  color: white;
  background: rgba(255,255,255,0.08);
}
.lvn-nav-links a.active {
  color: #1B6B62;
}

.lvn-nav-links .nav-gh {
  font-size: 0.68rem;
  font-weight: 600;
  color: white;
  background: var(--teal);
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-sm);
  margin-left: 0.5rem;
}
.lvn-nav-links .nav-gh:hover {
  background: var(--teal-glow);
}

.lvn-nav-theme {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.3rem;
  margin-left: 0.5rem;
  border-radius: var(--radius-sm);
  transition: color var(--duration-fast);
}
.lvn-nav-theme:hover { color: var(--gold); }

/* ── Button System ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.3rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--duration-normal) var(--ease-spring);
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  transition: opacity var(--duration-fast);
}
.btn:hover::after { opacity: 0.08; }
.btn:active::after { opacity: 0.15; }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--teal), #238B7E);
  color: white;
  box-shadow: 0 2px 8px rgba(42,157,143,0.25);
}
.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(42,157,143,0.35);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: #1B6B62;
  border: 1.5px solid var(--border-accent);
}
.btn-secondary:hover {
  border-color: #1B6B62;
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 0.4rem 0.8rem;
}
.btn-ghost:hover { color: #1B6B62; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-lg);
  transition: all var(--duration-normal) var(--ease-out);
}
.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card-interactive { cursor: pointer; }
.card-interactive:active { transform: translateY(0) scale(0.995); }

/* ── Page Transitions ── */
.page-fade-in {
  animation: pageFadeIn var(--duration-slow) var(--ease-out) both;
}
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.stagger-1 { animation-delay: 50ms; }
.stagger-2 { animation-delay: 100ms; }
.stagger-3 { animation-delay: 150ms; }
.stagger-4 { animation-delay: 200ms; }
.stagger-5 { animation-delay: 250ms; }

/* ── Scroll Reveal ── */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .lvn-nav-links a:not(.nav-gh) {
    display: none;
  }
  .lvn-nav-logo { font-size: 0.85rem; }
  body { padding-top: 44px; }
  :root { --nav-height: 44px; }
}

/* ── Subtle Noise Texture ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
}

/* ── Footer ── */
.lvn-footer {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  border-top: 1px solid var(--border-subtle);
  margin-top: var(--space-2xl);
  color: var(--text-muted);
  font-size: 0.78rem;
}
.lvn-footer a {
  color: #1B6B62;
  text-decoration: none;
}
.lvn-footer a:hover { text-decoration: underline; }

/* ── Dark Mode Deep Overrides ── */
[data-theme="dark"] .provocation,
[data-theme="dark"] .story-card,
[data-theme="dark"] .chip-group {
  background: var(--bg-card);
  border-color: var(--border-subtle);
}
[data-theme="dark"] .stat-row .stat { background: rgba(255,255,255,0.04); }
[data-theme="dark"] .prov-footer { background: var(--bg-subtle); }
[data-theme="dark"] .stake { background: rgba(42,157,143,0.1); }
[data-theme="dark"] .position:hover { background: rgba(42,157,143,0.08); }
[data-theme="dark"] .layer { background: rgba(255,255,255,0.03); }
[data-theme="dark"] .doc-card { background: var(--bg-card); border-color: var(--border-subtle); }
[data-theme="dark"] .doc-card:hover { border-color: #1B6B62; }
[data-theme="dark"] header, [data-theme="dark"] .hero { background: #080E1A; }
[data-theme="dark"] .conn-label { color: rgba(255,255,255,0.68); }
[data-theme="dark"] input, [data-theme="dark"] textarea, [data-theme="dark"] select {
  background: var(--bg-subtle); color: var(--text-primary, #0F1A2E); border-color: var(--border-subtle);
}
[data-theme="dark"] .filter-btn { background: var(--bg-card); color: var(--text-secondary); border-color: var(--border-subtle); }
[data-theme="dark"] .match-filters { background: var(--bg-subtle); }
[data-theme="dark"] .intro, [data-theme="dark"] .intro-hero { border-color: var(--border-accent); }
[data-theme="dark"] .prov-body p { color: var(--text-secondary); }
[data-theme="dark"] .pos-text { color: var(--text-secondary); }
[data-theme="dark"] .prompt { color: var(--text-secondary); }
[data-theme="dark"] .hero-canvas { opacity: 0.5; }

/* ── Print Styles ── */
@media print {
  .lvn-nav, .hero-canvas, .skip-link, .lvn-nav-theme,
  .resume-banner, .match-filters, .gh-stats, .journey-flow { display: none !important; }
  body { padding-top: 0; background: white; color: black; }
  .card, .provocation, .doc-card { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
  a { color: #1B6B62; }
  a[href]::after { content: " (" attr(href) ")"; font-size: 0.7em; color: #666; }
  .reveal { opacity: 1 !important; transform: none !important; }
}

/* ── Scroll-Driven Lazy Reveal ── */
@supports (content-visibility: auto) {
  .lazy-section {
    content-visibility: auto;
    contain-intrinsic-size: auto 500px;
  }
}

/* ── Focus Visible ── */
:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ── Smooth Scroll Anchor Offset ── */
[id] {
  scroll-margin-top: calc(var(--nav-height) + 1rem);
}

/* ── Mobile Menu ── */
.lvn-nav-toggle {
  display: none;
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.3rem;
  line-height: 1;
  transition: color 200ms;
}
.lvn-nav-toggle:hover { color: white; }

@media (max-width: 768px) {
  .lvn-nav-toggle { display: block; }
  .lvn-nav-links {
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: rgba(15,26,46,0.98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    flex-direction: column;
    padding: 0.8rem 1.5rem 1rem;
    gap: 0.15rem;
    border-bottom: 1px solid rgba(42,157,143,0.15);
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
    transition: all 300ms cubic-bezier(0.16, 1, 0.3, 1);
  }
  .lvn-nav-links.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  .lvn-nav-links a:not(.nav-gh) {
    display: block;
    padding: 0.6rem 0.4rem;
    font-size: 0.85rem;
  }
  .lvn-nav-links .nav-gh {
    margin: 0.4rem 0 0;
    text-align: center;
  }
  .lvn-nav-theme {
    position: absolute;
    right: 3rem;
    top: 50%;
    transform: translateY(-50%);
  }
}

/* ── Hero Text Animation ── */
.hero-reveal {
  opacity: 0;
  transform: translateY(20px);
  animation: heroReveal 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.hero-reveal:nth-child(1) { animation-delay: 0.1s; }
.hero-reveal:nth-child(2) { animation-delay: 0.25s; }
.hero-reveal:nth-child(3) { animation-delay: 0.4s; }
.hero-reveal:nth-child(4) { animation-delay: 0.55s; }
.hero-reveal:nth-child(5) { animation-delay: 0.7s; }
.hero-reveal:nth-child(6) { animation-delay: 0.85s; }

@keyframes heroReveal {
  to { opacity: 1; transform: translateY(0); }
}

/* ── Onboarding Tour ── */
.tour-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9990;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms;
}
.tour-overlay.active { opacity: 1; pointer-events: auto; }

.tour-tooltip {
  position: fixed;
  z-index: 9991;
  background: var(--bg-card, white);
  border: 2px solid var(--teal);
  border-radius: 12px;
  padding: 1.2rem;
  max-width: 300px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  opacity: 0;
  transform: translateY(8px);
  transition: all 300ms cubic-bezier(0.16, 1, 0.3, 1);
}
.tour-tooltip.active {
  opacity: 1;
  transform: translateY(0);
}
.tour-tooltip-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: #1B6B62;
  margin-bottom: 0.3rem;
}
.tour-tooltip-text {
  font-size: 0.82rem;
  color: var(--text-secondary, #5A6577);
  line-height: 1.5;
  margin-bottom: 0.8rem;
}
.tour-tooltip-step {
  font-family: var(--font-mono, monospace);
  font-size: 0.6rem;
  color: var(--text-muted, #8B95A5);
  margin-bottom: 0.6rem;
}
.tour-tooltip-btns {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
}
.tour-btn {
  padding: 0.35rem 0.8rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 200ms;
}
.tour-btn-next {
  background: var(--teal);
  color: white;
}
.tour-btn-next:hover { background: var(--teal-glow, #34D1BF); }
.tour-btn-skip {
  background: transparent;
  color: var(--text-muted, #8B95A5);
}
.tour-btn-skip:hover { color: var(--text-primary, #0F1A2E); }

.tour-highlight {
  position: relative;
  z-index: 9992;
  border-radius: 8px;
  box-shadow: 0 0 0 4px rgba(42,157,143,0.3), 0 0 0 9999px rgba(0,0,0,0.45);
}

/* ── Enhanced Footer ── */
.lvn-footer-full {
  background: var(--deep, #0F1A2E);
  color: rgba(255,255,255,0.7);
  padding: 3rem 1.5rem 2rem;
  border-top: 1px solid rgba(42,157,143,0.1);
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2rem;
  max-width: 900px;
  margin: 0 auto;
}
.footer-brand .footer-logo {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: white;
  margin-bottom: 0.5rem;
}
.footer-brand .footer-logo span { color: var(--gold); }
.footer-brand p {
  font-size: 0.75rem;
  line-height: 1.6;
  color: rgba(255,255,255,0.78);
  margin-bottom: 0.8rem;
}
.footer-col h4 {
  font-family: var(--font-mono, monospace);
  font-size: 0.62rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #1B6B62;
  margin-bottom: 0.6rem;
}
.footer-col a {
  display: block;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.68);
  text-decoration: none;
  padding: 0.2rem 0;
  transition: color 200ms;
}
.footer-col a:hover { color: rgba(255,255,255,0.8); }
.footer-bottom {
  text-align: center;
  padding-top: 1.5rem;
  margin-top: 2rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}
.footer-bottom p {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.55);
  line-height: 1.6;
}

@media (max-width: 768px) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 1.5rem; }
  .footer-brand { grid-column: 1 / -1; }
}

/* ── Scroll to Top Button ── */
.scroll-top-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--teal, #2A9D8F);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(42,157,143,0.3);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: all 300ms cubic-bezier(0.16,1,0.3,1);
  z-index: 900;
}
.scroll-top-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}
.scroll-top-btn:hover {
  background: var(--teal-glow, #34D1BF);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(42,157,143,0.4);
}

/* ── Reading Progress Bar ── */
.reading-progress {
  position: fixed;
  top: var(--nav-height, 56px);
  left: 0;
  width: 0%;
  height: 2px;
  background: linear-gradient(90deg, var(--teal, #2A9D8F), var(--gold, #E9C46A));
  z-index: 1001;
  transition: width 60ms linear;
}

/* ── Global Smooth Scroll ── */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* ── Focus Visible ── */
:focus-visible {
  outline: 2px solid var(--teal, #2A9D8F);
  outline-offset: 3px;
  border-radius: 3px;
}
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--teal, #2A9D8F);
  outline-offset: 3px;
}

/* ── Counter Animation ── */
.count-up { transition: none; }

/* ── Section Anchor Offset ── */
[id] { scroll-margin-top: calc(var(--nav-height, 56px) + 1rem); }

/* ── Hub Dark Mode: Map hardcoded vars ── */
[data-theme="dark"] .section-title,
[data-theme="dark"] .why-thread h3,
[data-theme="dark"] .cascade-step strong { color: #E8EDF3; }

[data-theme="dark"] .section-lead,
[data-theme="dark"] .why-thread p,
[data-theme="dark"] .cascade-step p,
[data-theme="dark"] .section-container p { color: #8BA5BE; }

[data-theme="dark"] .why-thread { 
  background: linear-gradient(135deg, rgba(42,157,143,0.06), rgba(233,196,106,0.03));
  border-color: rgba(42,157,143,0.12); 
}

[data-theme="dark"] .why-thread blockquote {
  background: rgba(42,157,143,0.04);
  border-left-color: rgba(42,157,143,0.3);
  color: #8BA5BE;
}

[data-theme="dark"] .story-card,
[data-theme="dark"] .evidence-card,
[data-theme="dark"] .faq-item {
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.06);
}

[data-theme="dark"] .gap-callout {
  background: rgba(42,157,143,0.06);
  border-color: rgba(42,157,143,0.15);
}

[data-theme="dark"] .cascade::before {
  opacity: 0.7;
}

[data-theme="dark"] .cascade-step::before {
  background: var(--bg-primary, #0F1A2E);
}

[data-theme="dark"] .how-step {
  border-color: rgba(255,255,255,0.06);
}

[data-theme="dark"] .audience-tab.active {
  background: rgba(42,157,143,0.15);
}

/* ── Thread Expand/Collapse ── */
.why-thread-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  gap: 0.6rem;
}
.why-thread-toggle h3 {
  flex: 1;
  margin: 0;
}
.why-thread-arrow {
  font-size: 0.8rem;
  color: #1B6B62;
  transition: transform 300ms cubic-bezier(0.16,1,0.3,1);
  flex-shrink: 0;
}
.why-thread.collapsed .why-thread-arrow {
  transform: rotate(-90deg);
}
.why-thread-body {
  max-height: 800px;
  overflow: hidden;
  transition: max-height 500ms cubic-bezier(0.16,1,0.3,1), opacity 300ms;
  opacity: 1;
}
.why-thread.collapsed .why-thread-body {
  max-height: 0;
  opacity: 0;
}

/* ── Staggered Thread Reveal ── */
.why-thread.reveal-item {
  opacity: 0;
  transform: translateY(16px);
  transition: all 500ms cubic-bezier(0.16,1,0.3,1);
}
.why-thread.reveal-item.visible {
  opacity: 1;
  transform: none;
}
