/* ============================================
   TrLynx Homepage — Custom Styles
   Modern, responsive, dark-mode-first design
   ============================================ */

/* --- CSS Variables / Theming --- */
:root {
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --max-width: 1200px;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.3s ease;
}

[data-theme="dark"] {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-card: #1c2128;
  --bg-card-hover: #242c38;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent: #d4af37;
  --accent-hover: #e0bf5a;
  --accent-contrast: #1f1806;
  --accent-glow: rgba(212, 175, 55, 0.2);
  --border: #30363d;
  --border-light: #21262d;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --gradient-hero: linear-gradient(135deg, #0d1117 0%, #161b22 50%, #211c10 100%);
  --code-bg: #262c36;
  --kbd-bg: #2d333b;
  --kbd-border: #444c56;
}

[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f6f8fa;
  --bg-card: #ffffff;
  --bg-card-hover: #f3f4f6;
  --text-primary: #1f2328;
  --text-secondary: #57606a;
  --text-muted: #6e7781;
  --accent: #8b6159;
  --accent-hover: #744f48;
  --accent-contrast: #ffffff;
  --accent-glow: rgba(139, 97, 89, 0.14);
  --border: #d1d9e0;
  --border-light: #e8ecf0;
  --shadow: 0 8px 24px rgba(140, 149, 159, 0.2);
  --shadow-sm: 0 2px 8px rgba(140, 149, 159, 0.15);
  --gradient-hero: linear-gradient(135deg, #ffffff 0%, #f8f5f4 50%, #f2e6e3 100%);
  --code-bg: #eff1f3;
  --kbd-bg: #f3f4f6;
  --kbd-border: #d1d9e0;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 70px;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition), color var(--transition);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

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

img {
  max-width: 100%;
  height: auto;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* --- Navbar --- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.navbar-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 18px;
  color: var(--text-primary);
  text-decoration: none;
}

.navbar-brand:hover {
  color: var(--accent);
}

.navbar-logo {
  width: 32px;
  height: 32px;
  border-radius: 6px;
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: 24px;
}

.navbar-links a {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--transition);
}

.navbar-links a:hover {
  color: var(--text-primary);
}

.nav-github {
  display: flex;
  align-items: center;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.theme-toggle:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
  background: var(--bg-card);
}

[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }

/* --- Hero Section --- */
.hero {
  margin-top: 64px;
  padding: 80px 24px 60px;
  background: var(--gradient-hero);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 60px;
  max-width: 100%;
  overflow: hidden;
}

.hero-content {
  max-width: 520px;
  flex-shrink: 0;
}

.hero-logo {
  width: 72px;
  height: 72px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.hero h1 {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 16px;
}

.hero-description {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 24px;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
}

.hero-badges img {
  height: 22px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-preview {
  flex-shrink: 1;
  max-width: 560px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.hero-preview video {
  width: 100%;
  display: block;
  border-radius: var(--radius);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all var(--transition);
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-contrast);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg-card);
  border-color: var(--text-muted);
  transform: translateY(-1px);
}

/* --- Sections --- */
.section {
  padding: 80px 24px;
}

.section-alt {
  background: var(--bg-secondary);
}

.section-title {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}

.section-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 1.05rem;
  margin-bottom: 48px;
}

/* --- Features Grid --- */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 40px;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  transition: all var(--transition);
}

.feature-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.feature-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.feature-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* --- Video Carousel --- */
.carousel {
  max-width: 900px;
  margin: 0 auto;
}

.carousel-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.carousel-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.carousel-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px 24px;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0) 100%);
  color: #fff;
  pointer-events: none;
}

.carousel-caption-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.carousel-caption-text {
  font-size: 0.85rem;
  opacity: 0.85;
  line-height: 1.5;
}

/* Thumbnail selector panel */
.carousel-selector {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.carousel-thumb {
  position: relative;
  flex: 1 1 0;
  min-width: 120px;
  max-width: 200px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.carousel-thumb:hover {
  border-color: var(--text-muted);
  background: var(--bg-card-hover);
}

.carousel-thumb.active {
  border-color: var(--accent);
  background: var(--bg-card-hover);
}

.thumb-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  position: relative;
  z-index: 1;
}

.thumb-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--accent);
  width: 0%;
  transition: none;
}

.carousel-thumb.active .thumb-progress {
  transition: width linear;
}

/* --- Docs Grid --- */
.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.doc-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-decoration: none;
  color: var(--text-primary);
  transition: all var(--transition);
}

.doc-card:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  color: var(--text-primary);
}

.doc-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.doc-card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* --- Quick Start --- */
.quickstart-steps {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.step {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all var(--transition);
}

.step:hover {
  border-color: var(--accent);
  transform: translateX(4px);
}

.step-number {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.step-content h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.step-content p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.step-content code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
}

.step-content kbd {
  display: inline-block;
  background: var(--kbd-bg);
  border: 1px solid var(--kbd-border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.8rem;
  font-family: var(--font-family);
  font-weight: 500;
  box-shadow: 0 1px 0 var(--kbd-border);
}

/* --- Footer --- */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 48px 24px 24px;
}

.footer-content {
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 32px;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.footer-logo {
  width: 40px;
  height: 40px;
  border-radius: 8px;
}

.footer-brand p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-links h4 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.footer-links a {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-bottom {
  max-width: var(--max-width);
  margin: 0 auto;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer-bottom p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-opensource {
  max-width: var(--max-width);
  margin: 0 auto 24px;
  padding: 16px 24px;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  text-align: center;
}

.footer-opensource p {
  font-size: 0.875rem;
  color: var(--text-primary);
  line-height: 1.6;
}

.footer-opensource a {
  font-weight: 600;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .hero {
    flex-direction: column;
    padding: 60px 24px 40px;
    gap: 40px;
    text-align: center;
  }

  .hero-content {
    max-width: 100%;
  }

  .hero-badges {
    justify-content: center;
  }

  .hero-actions {
    justify-content: center;
  }

  .hero-preview {
    max-width: 100%;
  }

  .footer-content {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

@media (max-width: 600px) {
  .navbar-links a:not(.nav-github) {
    display: none;
  }

  .hero h1 {
    font-size: 2.2rem;
  }

  .section-title {
    font-size: 1.6rem;
  }

  /* --- Carousel: move caption below video on mobile --- */
  .carousel-stage {
    aspect-ratio: auto;
    overflow: visible;
    border-radius: var(--radius) var(--radius) 0 0;
  }

  .carousel-video {
    aspect-ratio: 16 / 9;
    height: auto;
    border-radius: var(--radius) var(--radius) 0 0;
  }

  .carousel-caption {
    position: static;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    padding: 16px 20px;
    color: var(--text-primary);
  }

  .carousel-caption-text {
    opacity: 1;
    color: var(--text-secondary);
  }

  .carousel-selector {
    flex-wrap: wrap;
  }

  .carousel-thumb {
    min-width: 100px;
  }

  .features-grid {
    grid-template-columns: 1fr;
  }

  .docs-grid {
    grid-template-columns: 1fr;
  }
}