/* Courant landing page styles.
   Pure CSS (no Tailwind, no build step). Custom properties + component classes
   matching the cozy aesthetic of the main app (courant/static/courant.css). */

:root {
  /* Fonts */
  --font-display: 'Fraunces', 'Playfair Display', Georgia, serif;
  --font-ui:      'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;

  /* Neutral text colors */
  --text-primary:   #f5f5f5;
  --text-secondary: rgba(245, 245, 245, 0.7);
  --text-muted:     rgba(245, 245, 245, 0.5);

  /* Panel glassmorphism */
  --panel-bg:     rgba(255, 255, 255, 0.08);
  --panel-border: rgba(255, 255, 255, 0.18);
  --panel-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  --panel-radius: 24px;
  --panel-blur:   20px;

  /* Accent colors */
  --accent-blue:       #60a5fa;
  --accent-blue-hover: #3b82f6;
}

/* Base reset (no Tailwind preflight, so we apply our own minimal reset) */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body, h1, h2, h3, h4, p, figure, blockquote, dl, dd { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

body {
  font-family: var(--font-ui);
  color: var(--text-primary);
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* Focus ring shared across links + buttons */
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ============================================================
   Hero video + overlay (fixed behind every section)
   ============================================================ */
#hero-video {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  object-fit: cover;
  z-index: -2;
}

#hero-overlay {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, rgba(26, 26, 46, 0.85) 100%);
  pointer-events: none;
}

/* When the video errors out, paint a fallback gradient */
body.video-failed #hero-video { display: none; }
body.video-failed #hero-overlay {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 60%, #0f1626 100%);
}

/* ============================================================
   Top navigation
   ============================================================ */
.cozy-nav {
  position: relative;
  z-index: 10;
  background: transparent;
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-primary);
  max-width: 1280px;
  margin: 0 auto;
}

.cozy-nav .brand {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  text-decoration: none;
}

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

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-decoration: none;
  padding: 0.4rem 0.6rem;
  border-radius: 999px;
  transition: color 150ms, background 150ms;
}
.nav-link:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.06); }

/* ============================================================
   Hero section
   ============================================================ */
.hero {
  position: relative;
  min-height: calc(100vh - 5rem);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem 4rem;
}

.hero-inner {
  max-width: 760px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(3.5rem, 8vw, 6rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 0;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.35);
}

.hero-tagline {
  font-family: var(--font-ui);
  font-size: clamp(1.05rem, 2vw, 1.5rem);
  color: var(--text-secondary);
  max-width: 36ch;
  margin: 0;
  line-height: 1.5;
}

.hero-secondary {
  color: var(--text-primary);
  font-size: 0.95rem;
  text-decoration: none;
  padding: 0.4rem 0.2rem;
  border-bottom: 1px solid transparent;
  transition: border-color 150ms, color 150ms;
}
.hero-secondary:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.hero-caption {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

/* ============================================================
   Install code block (hero) + generic code block
   ============================================================ */
.install-block {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  backdrop-filter: blur(var(--panel-blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--panel-blur)) saturate(140%);
  padding: 0;
  overflow: hidden;
  max-width: 100%;
}

.install-code {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--text-primary);
  padding: 0.85rem 1.25rem;
  background: transparent;
  white-space: nowrap;
  user-select: all;
}

/* Copy button */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  border-left: 1px solid var(--panel-border);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: background 150ms, color 150ms;
  position: relative;
}
.copy-btn:hover { background: rgba(255, 255, 255, 0.12); color: var(--text-primary); }
.copy-btn:active { transform: scale(0.98); }

.copy-btn .check-icon,
.copy-btn .copied-label { display: none; }

.copy-btn.copied .copy-icon,
.copy-btn.copied .copy-label { display: none; }
.copy-btn.copied .check-icon,
.copy-btn.copied .copied-label {
  display: inline-flex;
  align-items: center;
  color: #4ade80;
}

/* Block-style copy button used inside .code-block */
.code-block {
  position: relative;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  backdrop-filter: blur(var(--panel-blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--panel-blur)) saturate(140%);
  padding: 1.25rem 1.5rem;
  text-align: left;
  overflow: auto;
}

.code-block pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.7;
  white-space: pre;
}

.copy-btn-block {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  border-left: none;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  font-size: 0.78rem;
}

/* ============================================================
   Sections (shared layout for sections 2-5)
   ============================================================ */
.section {
  position: relative;
  padding: 6rem 1.5rem;
}

.section-inner {
  max-width: 1100px;
  margin: 0 auto;
}
.section-inner-narrow {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
}

.section-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.75rem, 3.5vw, 2.5rem);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 3rem;
  text-align: center;
  color: var(--text-primary);
}

.section-caption {
  text-align: center;
  margin-top: 2rem;
  color: var(--text-secondary);
  font-size: 1rem;
}

.section-paragraph {
  text-align: center;
  margin: 1.75rem 0 1rem;
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.6;
}

.text-link {
  display: inline-block;
  color: var(--accent-blue);
  text-decoration: none;
  font-size: 0.95rem;
  border-bottom: 1px solid transparent;
  transition: border-color 150ms;
}
.text-link:hover { border-color: var(--accent-blue); }

/* ============================================================
   Card grids (sections 2 and 5)
   ============================================================ */
.card-grid {
  display: grid;
  gap: 1.5rem;
}
.card-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.card-grid-tight {
  gap: 1rem;
}

/* Glassmorphism panel card (section 2) */
.panel-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--panel-radius);
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(var(--panel-blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--panel-blur)) saturate(140%);
  padding: 2rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: transform 250ms ease, box-shadow 250ms ease, border-color 250ms ease;
}
.panel-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 12px 40px rgba(96, 165, 250, 0.18);
}

.card-icon {
  color: var(--accent-blue);
  width: 44px; height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(96, 165, 250, 0.12);
  border-radius: 12px;
}

.card-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  margin: 0;
  color: var(--text-primary);
}

.card-text {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0;
}

/* Feature card (section 5) — smaller, denser variant */
.feature-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  backdrop-filter: blur(12px) saturate(130%);
  -webkit-backdrop-filter: blur(12px) saturate(130%);
  padding: 1.4rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: transform 200ms ease, border-color 200ms ease;
}
.feature-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.22);
}

.feature-icon {
  color: var(--accent-blue);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  background: rgba(96, 165, 250, 0.12);
  border-radius: 10px;
  margin-bottom: 0.25rem;
}

.feature-title {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
  margin: 0;
}

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

/* ============================================================
   Screenshots grid (section 3)
   ============================================================ */
.screenshot-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
}

.screenshot-figure {
  margin: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  overflow: hidden;
  aspect-ratio: 16 / 10;
}

.screenshot-figure img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
}

/* If image fails to load, show fallback caption via alt text */
.screenshot-figure img:not([src]),
.screenshot-figure img[src=""] {
  visibility: hidden;
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  position: relative;
  z-index: 1;
  background: rgba(10, 14, 28, 0.6);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 3rem 1.5rem 1.5rem;
  margin-top: 3rem;
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 1.5rem;
  align-items: center;
}

.footer-brand {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.footer-brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--text-primary);
}

.footer-version {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  justify-content: center;
  font-size: 0.9rem;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 150ms;
}
.footer-links a:hover { color: var(--text-primary); }

.footer-credit {
  text-align: right;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.footer-credit a {
  color: var(--accent-blue);
  text-decoration: none;
}
.footer-credit a:hover { text-decoration: underline; }

.footer-bottom {
  max-width: 1100px;
  margin: 2rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ============================================================
   Scroll reveal animations
   ============================================================ */
[data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 700ms cubic-bezier(0.22, 1, 0.36, 1),
              transform 700ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, transform;
}

[data-reveal].revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger reveal slightly when in a grid by using nth-child delays */
.card-grid [data-reveal]:nth-child(2) { transition-delay: 80ms; }
.card-grid [data-reveal]:nth-child(3) { transition-delay: 160ms; }
.card-grid [data-reveal]:nth-child(4) { transition-delay: 240ms; }
.card-grid [data-reveal]:nth-child(5) { transition-delay: 320ms; }
.card-grid [data-reveal]:nth-child(6) { transition-delay: 400ms; }

/* ============================================================
   Reduced motion : disable all animations and reveal everything
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   Mobile / tablet adjustments
   ============================================================ */
@media (max-width: 900px) {
  .card-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .screenshot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer-inner {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .footer-brand { justify-content: center; }
  .footer-credit { text-align: center; }
}

@media (max-width: 768px) {
  .cozy-nav { padding: 1rem 1.25rem; }
  .nav-links { gap: 0.5rem; }
  .nav-link span { display: none; } /* icons only on small screens */
  .nav-link { padding: 0.5rem; }

  .section { padding: 4rem 1.25rem; }
  .section-title { margin-bottom: 2rem; }

  .hero { padding: 1.5rem 1.25rem 3rem; min-height: calc(100vh - 4rem); }
  .hero-inner { gap: 1.25rem; }
  .hero-title { font-size: clamp(3rem, 12vw, 4rem); }

  .install-block { flex-direction: column; }
  .install-code { white-space: normal; word-break: break-word; text-align: center; padding: 1rem; }
  .copy-btn { border-left: none; border-top: 1px solid var(--panel-border); justify-content: center; }
}

@media (max-width: 560px) {
  .card-grid-3 { grid-template-columns: 1fr; }
  .screenshot-grid { grid-template-columns: 1fr; }
  .footer-links { gap: 0.85rem; }
}

/* ----- Ambient audio player (Spotify-style mini-player, bottom-left) ----- */

.audio-player {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem 0.5rem 0.5rem;
  background: rgba(18, 18, 30, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  width: 360px;
  max-width: calc(100vw - 3rem);
  color: var(--text-primary);
  font-family: var(--font-ui);
}

.audio-art {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}
.audio-art svg { width: 100%; height: 100%; display: block; }

.audio-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.audio-track-title {
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.audio-track-artist {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
}

.audio-control {
  background: transparent;
  border: none;
  padding: 6px;
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.audio-control:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.08); }
.audio-control:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}
.audio-control .audio-icon { width: 18px; height: 18px; fill: currentColor; display: block; }

/* Play/pause button = circular white pill, Spotify-style emphasis */
.audio-toggle {
  background: #ffffff;
  color: #0b0b14;
  width: 36px;
  height: 36px;
  padding: 0;
  margin: 0 4px;
  transition: transform 120ms ease, background-color 120ms ease;
}
.audio-toggle:hover { background: #f3f3f3; color: #0b0b14; transform: scale(1.06); }
.audio-toggle:focus-visible { outline-offset: 3px; }
.audio-toggle .audio-icon { width: 18px; height: 18px; }

/* Swap play <-> pause via .is-playing class on the toggle */
.audio-toggle .icon-pause { display: none; }
.audio-toggle.is-playing .icon-play { display: none; }
.audio-toggle.is-playing .icon-pause { display: block; }

@media (max-width: 768px) {
  .audio-player {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
    width: auto;
    max-width: none;
    padding: 0.5rem 0.5rem 0.5rem 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .audio-toggle { transition: none; }
  .audio-toggle:hover { transform: none; }
}
