/* ============================================================
   Sim Racing Labs — styles.css
   Dark theme, mobile-first, production-ready
   ============================================================ */

/* ----------------------------------------------------------
   1. CSS Custom Properties (Design Tokens)
   ---------------------------------------------------------- */
:root {
  /* Colors */
  --color-bg:          #0d0f14;
  --color-surface:     #161922;
  --color-surface-alt: #1c1f2b;
  --color-border:      #252836;
  --color-accent:      #ff5733;
  --color-accent-light:#ff7a5c;
  --color-accent-dark: #cc4529;

  /* Text */
  --color-text:        #e4e6ed;
  --color-text-muted:  #8b8fa3;
  --color-text-dim:    #5d6178;

  /* Tags palette */
  --tag-hardware-bg:   rgba(255, 87, 51, .15);
  --tag-hardware-fg:   #ff7a5c;
  --tag-guide-bg:      rgba(99, 160, 255, .15);
  --tag-guide-fg:      #63a0ff;
  --tag-software-bg:   rgba(83, 211, 134, .15);
  --tag-software-fg:   #53d386;
  --tag-ecosystem-bg:  rgba(197, 134, 255, .15);
  --tag-ecosystem-fg:  #c586ff;

  /* Typography */
  --font-body:    'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;

  /* Spacing */
  --space-xs:  .25rem;
  --space-sm:  .5rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2.5rem;
  --space-2xl: 4rem;

  /* Layout */
  --container-max: 1100px;
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   12px;
  --radius-xl:   16px;

  /* Transitions */
  --ease-out:    cubic-bezier(.25, .46, .45, .94);
  --transition:  .25s var(--ease-out);
}

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

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

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

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

img, svg {
  display: block;
  max-width: 100%;
}

ul { list-style: none; }

/* ----------------------------------------------------------
   3. Utilities
   ---------------------------------------------------------- */

/* Container */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-lg);
  padding-right: var(--space-lg);
}

/* Section shared styles */
.section {
  padding-top: var(--space-2xl);
  padding-bottom: var(--space-2xl);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
}

.section-header h2 {
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 700;
  color: var(--color-text);
}

.view-all {
  font-family: var(--font-mono);
  font-size: .85rem;
  color: var(--color-accent);
  transition: color var(--transition);
  white-space: nowrap;
}

.view-all:hover {
  color: var(--color-accent-light);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .75rem 1.5rem;
  font-family: var(--font-body);
  font-size: .925rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: background-color var(--transition),
              transform var(--transition),
              box-shadow var(--transition);
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-dark));
  color: #fff;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(255, 87, 51, .35);
}

.btn-secondary {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  border-color: var(--color-accent);
  transform: translateY(-2px);
}

/* Tags (reusable) */
.tag, .art-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: .7rem;
  font-weight: 500;
  padding: .2rem .65rem;
  border-radius: 99px;
  letter-spacing: .02em;
}

.tag-hardware {
  background: var(--tag-hardware-bg);
  color: var(--tag-hardware-fg);
}

.tag-guide {
  background: var(--tag-guide-bg);
  color: var(--tag-guide-fg);
}

.tag-software {
  background: var(--tag-software-bg);
  color: var(--tag-software-fg);
}

.tag-ecosystem {
  background: var(--tag-ecosystem-bg);
  color: var(--tag-ecosystem-fg);
}

.tag-audio {
  background: rgba(255, 193, 7, .15);
  color: #ffc107;
}

.tag-cockpit {
  background: rgba(0, 188, 212, .15);
  color: #00bcd4;
}

/* ----------------------------------------------------------
   4. Skip Link (Accessibility)
   ---------------------------------------------------------- */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-md);
  z-index: 9999;
  padding: .6rem 1.2rem;
  font-family: var(--font-mono);
  font-size: .85rem;
  color: #fff;
  background: var(--color-accent);
  border-radius: var(--radius-sm);
  transition: top .2s ease;
}

.skip-link:focus {
  top: var(--space-md);
}

/* ----------------------------------------------------------
   5. Header / Navigation
   ---------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 15, 20, .85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
  transition: opacity var(--transition);
}

.logo:hover { opacity: .85; }

.logo-icon {
  font-size: 1.3rem;
}

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

/* Main Nav */
.main-nav ul {
  display: flex;
  align-items: center;
  gap: .25rem;
}

.main-nav a {
  display: block;
  padding: .4rem .85rem;
  font-size: .9rem;
  font-weight: 500;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  transition: color var(--transition), background-color var(--transition);
}

.main-nav a:hover {
  color: var(--color-text);
  background-color: var(--color-surface-alt);
}

.main-nav a.active {
  color: var(--color-accent);
}

/* Nav toggle (hamburger) — hidden ≥768px */
.nav-toggle {
  display: none; /* shown on mobile below */
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
}

.hamburger,
.hamburger::before,
.hamburger::after {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
  transition: transform .3s ease, opacity .3s ease;
}

.hamburger::before,
.hamburger::after {
  content: '';
  position: absolute;
}

.hamburger::before { transform: translateY(-6px); }
.hamburger::after  { transform: translateY(6px); }

/* Search button */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.search-btn {
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  transition: color var(--transition), background-color var(--transition);
}

.search-btn:hover {
  color: var(--color-text);
  background-color: var(--color-surface-alt);
}

/* ----------------------------------------------------------
   6. Hero Section
   ---------------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  padding-top: var(--space-2xl);
  padding-bottom: var(--space-2xl);
  text-align: center;
}

.hero-inner {
  position: relative;
  z-index: 1;
}

/* Badge */
.hero-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: .78rem;
  padding: .3rem .9rem;
  border-radius: 99px;
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-lg);
}

/* Title */
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.02em;
  color: var(--color-text);
}

/* Gradient text */
.gradient-text {
  background: linear-gradient(135deg, var(--color-accent), #ff9a76);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Description */
.hero-desc {
  max-width: 540px;
  margin: var(--space-md) auto var(--space-xl);
  font-size: clamp(.95rem, 2vw, 1.1rem);
  color: var(--color-text-muted);
}

/* CTAs */
.hero-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  justify-content: center;
  margin-bottom: var(--space-2xl);
}

/* Stats row */
.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xl);
  justify-content: center;
}

.stat {
  text-align: center;
}

.stat-num {
  display: block;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 800;
  color: var(--color-accent);
  line-height: 1.1;
}

.stat-label {
  display: block;
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--color-text-dim);
  margin-top: .25rem;
}

/* Decorative dotted grid background */
.hero-bg-grid {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .12;
  background-image: radial-gradient(circle closest-side, var(--color-text-dim) 1px, transparent 0);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse at 50% 40%, black 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 40%, black 20%, transparent 70%);
}

/* ----------------------------------------------------------
   7. Comparison Cards
   ---------------------------------------------------------- */
.comparison-grid {
  display: grid;
  gap: var(--space-lg);
  grid-template-columns: 1fr;
}

/* Card base */
.comp-card {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.comp-card:hover {
  border-color: rgba(255, 87, 51, .3);
  transform: translateY(-4px);
}

/* Glow overlay — visible on hover */
.card-glow {
  position: absolute;
  inset: -1px;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(255, 87, 51, .12), transparent 65%);
  transition: opacity .4s ease;
}

.comp-card:hover .card-glow {
  opacity: 1;
}

/* Box shadow glow on hover */
.comp-card:hover {
  box-shadow: 0 8px 32px rgba(255, 87, 51, .12),
              0 0 0 1px rgba(255, 87, 51, .1);
}

/* Card content sits above glow */
.comp-card > *:not(.card-glow) {
  position: relative;
  z-index: 1;
}

/* Card top row (tag + read time) */
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.read-time {
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--color-text-dim);
}

/* Card title */
.comp-title {
  font-size: clamp(1.05rem, 2.5vw, 1.25rem);
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: var(--space-sm);
}

/* Card description */
.comp-desc {
  font-size: .9rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-lg);
  line-height: 1.55;
}

/* Mini comparison bars */
.mini-bars {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  margin-bottom: var(--space-lg);
}

.bar-row {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  align-items: center;
  gap: .65rem;
}

.brand-a,
.brand-b {
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--color-text-muted);
  text-align: right;
}

.bar-track {
  height: 6px;
  background: var(--color-bg);
  border-radius: 99px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-accent), var(--color-accent-light));
  border-radius: inherit;
  transition: width .6s var(--ease-out);
}

.bar-fill.bar-b {
  background: linear-gradient(90deg, #63a0ff, #8bb8ff);
}

.score {
  font-family: var(--font-mono);
  font-size: .78rem;
  font-weight: 500;
  color: var(--color-text);
  min-width: 2ch;
  text-align: right;
}

/* Card meta footer */
.card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--color-text-dim);
}

.updated {
  border-left: 1px solid var(--color-border);
  padding-left: var(--space-sm);
}

/* ----------------------------------------------------------
   8. Compatibility Teaser Section
   ---------------------------------------------------------- */
.compat-teaser {
  background: linear-gradient(135deg, rgba(255, 87, 51, .08), rgba(255, 87, 51, .02));
  border-top: 1px solid rgba(255, 87, 51, .12);
  border-bottom: 1px solid rgba(255, 87, 51, .12);
}

.compat-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
  text-align: center;
}

.glow-icon {
  font-size: 1.6rem;
  margin-bottom: .5rem;
  display: block;
}

.compat-text h2 {
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 700;
  margin-bottom: var(--space-sm);
}

.compat-text p {
  max-width: 480px;
  color: var(--color-text-muted);
  font-size: .95rem;
}

/* ----------------------------------------------------------
   9a. Filter Bar (comparisons page)
   ---------------------------------------------------------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: center;
  padding-top: var(--space-lg);
  padding-bottom: var(--space-xl);
}

.filter-btn {
  font-family: var(--font-mono);
  font-size: .78rem;
  font-weight: 500;
  padding: .4rem 1rem;
  border-radius: 99px;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background-color var(--transition),
              color var(--transition),
              border-color var(--transition);
}

.filter-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-text);
}

.filter-btn.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

/* ----------------------------------------------------------
   9b. Compact Hero (sub-pages)
   ---------------------------------------------------------- */
.hero-compact {
  padding-top: var(--space-xl);
  padding-bottom: var(--space-lg);
}

.hero-compact h1 {
  font-size: clamp(1.6rem, 4vw, 2.5rem);
  margin-bottom: var(--space-sm);
}

.hero-compact .hero-desc {
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 0;
}

.hero-compact .hero-badge {
  margin-bottom: var(--space-md);
}

/* ----------------------------------------------------------
   10. Articles List (Horizontal Rows)
   ---------------------------------------------------------- */
.articles-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.article-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg) 0;
  border-bottom: 1px solid var(--color-border);
  transition: background-color var(--transition);
}

.article-row:first-child {
  border-top: 1px solid var(--color-border);
}

.article-row:hover {
  background-color: rgba(255, 87, 51, .03);
}

.art-date {
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--color-text-dim);
  white-space: nowrap;
  min-width: 80px;
}

.art-body h3 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: .25rem;
}

.art-body h3 a:hover {
  color: var(--color-accent);
}

.art-body p {
  font-size: .875rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* Tag right-aligned */
.article-row .art-tag {
  flex-shrink: 0;
}

/* ----------------------------------------------------------
   10. Footer
   ---------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-2xl);
  padding-bottom: var(--space-xl);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
  text-align: center;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .25rem;
}

.footer-nav a {
  font-size: .875rem;
  color: var(--color-text-muted);
  padding: .35rem .75rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background-color var(--transition);
}

.footer-nav a:hover {
  color: var(--color-text);
  background-color: var(--color-surface-alt);
}

.footer-copy {
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--color-text-dim);
}

/* ----------------------------------------------------------
   11. Responsive — Tablet & Desktop (≥768px)
   ---------------------------------------------------------- */
@media (min-width: 768px) {

  /* Nav: hamburger hidden, menu visible */
  .nav-toggle {
    display: none !important;
  }

  .main-nav ul {
    gap: .25rem;
  }

  /* Comparison grid → multi-column */
  .comparison-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Featured card spans full width */
  .comp-card.featured {
    grid-column: 1 / -1;
  }

  /* Compatibility section — side-by-side layout */
  .compat-inner {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }

  .compat-text {
    display: flex;
    align-items: center;
    gap: var(--space-md);
  }

  /* Footer — multi-column */
  .footer-inner {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }
}

/* ----------------------------------------------------------
   12. Responsive — Large Desktop (≥1024px)
   ---------------------------------------------------------- */
@media (min-width: 1024px) {

  .comparison-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Featured card spans all columns on large screens too */
  .comp-card.featured {
    grid-column: 1 / -1;
  }
}

/* ----------------------------------------------------------
   13. Mobile — Hamburger menu (≤767px)
   ---------------------------------------------------------- */
@media (max-width: 767px) {

  /* Show hamburger toggle */
  .nav-toggle {
    display: flex !important;
  }

  /* Hide nav by default, show when toggled via JS adding [open] class on header-inner or body */
  .main-nav ul {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-md) var(--space-lg);
    gap: .25rem;
    transform: translateY(-10px);
    opacity: 0;
    pointer-events: none;
    transition: transform .3s ease, opacity .3s ease;
  }

  /* JS will toggle aria-expanded="true" on the nav-toggle button */
  .nav-toggle[aria-expanded="true"] + ul,
  .main-nav.open ul {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .main-nav a {
    padding: .65rem .75rem;
    font-size: 1rem;
  }
}

/* ----------------------------------------------------------
   14. Animations & Focus States
   ---------------------------------------------------------- */

/* Smooth focus outlines for keyboard nav */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Staggered fade-in for cards (optional, triggered by intersection observer or just CSS) */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.comp-card {
  animation: fadeInUp .5s var(--ease-out) both;
}

.comparison-grid .comp-card:nth-child(2) { animation-delay: .1s; }
.comparison-grid .comp-card:nth-child(3) { animation-delay: .2s; }
.comparison-grid .comp-card:nth-child(4) { animation-delay: .3s; }
.comparison-grid .comp-card:nth-child(5) { animation-delay: .4s; }
.comparison-grid .comp-card:nth-child(6) { animation-delay: .5s; }
.comparison-grid .comp-card:nth-child(7) { animation-delay: .6s; }
.comparison-grid .comp-card:nth-child(8) { animation-delay: .7s; }

/* Stagger for articles */
.article-row {
  animation: fadeInUp .4s var(--ease-out) both;
}

.articles-list .article-row:nth-child(2) { animation-delay: .08s; }
.articles-list .article-row:nth-child(3) { animation-delay: .16s; }

/* ----------------------------------------------------------
   15. Print Styles (minimal)
   ---------------------------------------------------------- */
@media print {
  .site-header,
  .hero-bg-grid,
  .card-glow,
  .nav-toggle,
  .search-btn,
  .skip-link { display: none; }

  body { background: #fff; color: #000; }

  a { color: #000; text-decoration: underline; }

  .comp-card,
  .article-row { border-color: #ccc; }
}
