/* ===== JAGA Labs — Design System (Cross-Browser Fix) ===== */

/* --- Tokens --- */
:root {
  --bg: #FFF9F0;
  --bg-alt: #F5EDE0;
  --bg-card: #FFFFFF;
  --primary: #C24B2B;
  --primary-light: #E8664A;
  --accent: #D4A017;
  --accent-light: #F0C75E;
  --text: #2D2D2D;
  --text-muted: #6B6258;
  --text-light: #9A8E82;
  --border: #E6D9C9;

  /* FIX: Brave/Firefox choke on rgba() with nested var() — use solid hex fallbacks */
  --map-central: #C24B2B29;
  --map-western: #D4A01738;
  --map-northern: #4C996029;
  --map-southern: #3B78BA29;
  --map-southwestern: #8A4FA829;
  --map-transition: #A08C7824;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 16px rgba(45, 45, 45, 0.06);
  --shadow-lg: 0 8px 32px rgba(45, 45, 45, 0.10);
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  /* FIX: -webkit- prefix required for Safari/older Chromium; moz removed (unsupported) */
  -webkit-font-smoothing: antialiased;
  font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-light); }

/* --- Utilities --- */
.container { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.section { padding: 80px 0; }
.section-alt { background: var(--bg-alt); }
.text-center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* --- Typography --- */
h1, h2, h3, h4 { font-family: var(--font-heading); line-height: 1.2; color: var(--text); }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 800; }
h2 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); font-weight: 700; margin-bottom: 16px; }
h3 { font-size: 1.25rem; font-weight: 600; margin-bottom: 8px; }
p { margin-bottom: 16px; }
.subtitle {
  font-size: 1.1rem; color: var(--text-muted);
  max-width: 640px; margin: 0 auto 40px;
}
.tag {
  display: inline-block; padding: 4px 14px;
  background: var(--bg-alt); border: 1px solid var(--border);
  border-radius: 20px; font-size: 0.8rem; font-weight: 500;
  color: var(--text-muted); letter-spacing: 0.5px; text-transform: uppercase;
}

/* --- Ikat Border Motif --- */
.ikat-border {
  height: 6px;
  background: repeating-linear-gradient(
    90deg,
    var(--primary) 0px, var(--primary) 12px,
    var(--accent) 12px, var(--accent) 24px,
    var(--bg) 24px, var(--bg) 28px
  );
}

/* --- Header --- */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  /* FIX: Brave Shields blocks backdrop-filter in some configs.
     Use a solid high-opacity fallback FIRST, then progressive enhance. */
  background: rgba(255, 249, 240, 0.96);
  border-bottom: 1px solid var(--border);
  transition: box-shadow var(--transition);
}

/* Progressive enhancement: only apply blur where supported */
@supports (backdrop-filter: blur(12px)) {
  .site-header {
    background: rgba(255, 249, 240, 0.92);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }
}

.site-header.scrolled { box-shadow: var(--shadow); }
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo img { height: 40px; width: 40px; object-fit: contain; }
.logo span { font-family: var(--font-heading); font-weight: 700; font-size: 1.3rem; color: var(--text); }

/* Nav */
.nav-links { display: flex; gap: 28px; list-style: none; align-items: center; }
.nav-links a {
  font-size: 0.9rem; font-weight: 500; color: var(--text-muted);
  transition: color var(--transition); position: relative;
}
.nav-links a::after {
  content: ''; position: absolute; bottom: -4px; left: 0;
  width: 0; height: 2px; background: var(--primary);
  transition: width var(--transition);
}
.nav-links a:hover, .nav-links a.active { color: var(--primary); }
.nav-cta-link {
  background: var(--primary); color: #fff !important; padding: 6px 14px !important;
  border-radius: 6px; font-size: 0.85rem !important;
  transition: background var(--transition) !important;
}
.nav-cta-link:hover { background: var(--primary-light) !important; color: #fff !important; }
.nav-cta-link::after { display: none !important; }
.nav-links a:hover::after, .nav-links a.active::after { width: 100%; }

/* Hamburger */
.hamburger {
  display: none; background: none; border: none; cursor: pointer;
  width: 32px; height: 32px; position: relative;
}
.hamburger span {
  display: block; width: 22px; height: 2px; background: var(--text);
  position: absolute; left: 5px; transition: var(--transition);
}
.hamburger span:nth-child(1) { top: 9px; }
.hamburger span:nth-child(2) { top: 15px; }
.hamburger span:nth-child(3) { top: 21px; }
.hamburger.open span:nth-child(1) { transform: rotate(45deg); top: 15px; }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: rotate(-45deg); top: 15px; }

/* FIX: Google Translate widget — hide gracefully when Brave blocks it */
.translate-wrap { display: flex; align-items: center; }
.goog-te-gadget { font-size: 0 !important; }
.goog-te-gadget-simple {
  background: var(--bg-alt) !important; border: 1px solid var(--border) !important;
  border-radius: 6px !important; padding: 4px 10px !important;
  font-size: 0.82rem !important;
}
/* Hide translate wrapper entirely if the script never loaded (Brave blocks it) */
.translate-wrap:empty { display: none; }

/* --- Hero --- */
.hero {
  padding: 140px 0 80px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; top: -60%; right: -20%;
  width: 600px; height: 600px;
  /* FIX: Use hex-based gradient stops instead of CSS var() inside radial-gradient
     — Brave's Chromium build has a parsing edge case with var() in gradient color stops */
  background: radial-gradient(circle, #F0C75E33 0%, transparent 70%);
  pointer-events: none;
}
.hero::after {
  content: ''; position: absolute; bottom: -40%; left: -15%;
  width: 500px; height: 500px;
  background: radial-gradient(circle, #E8664A1A 0%, transparent 70%);
  pointer-events: none;
}
.hero-logo { width: 80px; height: 80px; margin: 0 auto 24px; }
.hero h1 { margin-bottom: 16px; }
.hero h1 .highlight { color: var(--primary); }
.hero-tagline { font-size: 1.15rem; color: var(--text-muted); max-width: 560px; margin: 0 auto 32px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 24px; }
.hero-cta {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 28px; font-weight: 600; font-size: 0.95rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  /* FIX: Brave sometimes ignores transition on pseudo-classes without will-change hint */
  will-change: transform;
}
.hero-cta-primary {
  background: var(--primary); color: #fff;
  box-shadow: 0 4px 16px rgba(194, 75, 43, 0.30);
}
.hero-cta-primary:hover { background: var(--primary-light); color: #fff; transform: translateY(-2px); }
.hero-cta-secondary {
  background: transparent; color: var(--text-muted);
  border: 1.5px solid var(--border);
}
.hero-cta-secondary:hover { border-color: var(--primary); color: var(--primary); }
.hero-badge { margin-top: 8px; }
.hero-license { font-size: 0.82rem; color: var(--text-light); margin-top: 12px; }

/* --- Cards --- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
  transition: transform var(--transition), box-shadow var(--transition);
  will-change: transform;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.card-icon {
  width: 48px; height: 48px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; margin-bottom: 16px;
}
/* FIX: use solid hex instead of rgba(var()) for background colors */
.card-icon.red { background: #C24B2B1A; color: var(--primary); }
.card-icon.gold { background: #D4A0171A; color: var(--accent); }
.card-icon.green { background: #4C99601A; color: #4C9960; }

/* --- Map Section --- */
.map-section { padding: 80px 0; }
.map-container {
  max-width: 720px; margin: 0 auto;
}
.map-wrapper {
  position: relative;
  transition: transform 0.4s ease;
  /* FIX: SVG rendering in Brave — explicit dimensions prevent layout collapse */
  min-height: 200px;
}
.map-wrapper:hover { transform: scale(1.02); }
.map-wrapper svg {
  width: 100%; height: auto;
  /* FIX: SVG color-scheme inheritance fix for Brave dark mode */
  color-scheme: light;
}

/* Map district paths */
.district-path {
  stroke: var(--border); stroke-width: 1.2;
  cursor: pointer;
  transition: fill var(--transition), stroke var(--transition), opacity var(--transition);
}
.district-path:hover {
  stroke: var(--primary); stroke-width: 2;
  opacity: 0.85;
}
.district-path.active {
  stroke: var(--primary); stroke-width: 2.5;
}

/* Tooltip */
.map-tooltip {
  position: absolute; pointer-events: none;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  z-index: 10; max-width: 260px;
  font-size: 0.88rem;
  /* FIX: Brave GPU compositing — promote to own layer to avoid flicker */
  will-change: opacity, transform;
}
.map-tooltip.visible { opacity: 1; transform: translateY(0); }
.map-tooltip h4 { font-size: 1rem; margin-bottom: 4px; color: var(--primary); }
.map-tooltip .dialect-name { font-weight: 600; color: var(--text); }
.map-tooltip .dialect-meta { color: var(--text-muted); font-size: 0.82rem; margin-top: 4px; }

/* Detail panel */
.map-detail {
  margin-top: 24px; padding: 24px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); display: none;
}
.map-detail.visible { display: block; animation: fadeUp 0.3s ease; }
.map-detail h3 { color: var(--primary); }

/* Map loading state */
.map-loading {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 48px 0;
  font-size: 0.9rem; color: var(--text-muted);
}
.map-loading-spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Legend */
.map-legend {
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: center;
  margin-top: 24px;
}
.legend-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.82rem; color: var(--text-muted);
}
.legend-swatch {
  width: 14px; height: 14px; border-radius: 4px;
  border: 1px solid var(--border);
}

/* --- Roadmap Timeline --- */
.timeline { position: relative; max-width: 640px; margin: 0 auto; }
.timeline::before {
  content: ''; position: absolute; left: 24px; top: 0; bottom: 0;
  width: 2px; background: var(--border);
}
.timeline-item {
  position: relative; padding-left: 60px; margin-bottom: 40px;
}
.timeline-dot {
  position: absolute; left: 16px; top: 4px;
  width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid var(--primary); background: var(--bg);
}
.timeline-item.active .timeline-dot { background: var(--primary); }
.timeline-item h3 { margin-bottom: 4px; }
.timeline-item p { color: var(--text-muted); font-size: 0.95rem; }

/* --- About prose --- */
.about-prose {
  max-width: 760px; margin: 0 auto;
  font-size: 0.95rem; color: var(--text-muted); line-height: 1.8;
}
.about-prose p { margin-bottom: 14px; }
.about-prose strong { color: var(--text); }
.about-list {
  padding-left: 20px; margin: 14px 0 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.about-list li { color: var(--text-muted); line-height: 1.7; }
.about-list li strong { color: var(--text); }

/* --- Interest Form (top banner) --- */
.interest-section-top {
  background: linear-gradient(135deg, #FFF3E8 0%, #FFF9F0 60%, #F0EBE0 100%);
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.interest-banner {
  display: grid; grid-template-columns: 1.3fr 0.7fr;
  gap: 48px; align-items: start;
}
.interest-banner-left h2 { font-size: clamp(1.3rem, 2.8vw, 1.7rem); margin-bottom: 14px; }
.interest-banner-left p { color: var(--text-muted); font-size: 0.93rem; line-height: 1.75; margin-bottom: 12px; }
.interest-how { font-size: 0.88rem; }
.form-cta-box {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px;
  box-shadow: var(--shadow-lg); text-align: center;
  position: sticky; top: 88px;
}
.form-cta-tagline { font-size: 0.82rem; color: var(--text-light); margin-bottom: 16px; }
.form-cta-sub { font-size: 0.82rem; color: var(--text-muted); margin-top: 14px; }
.btn-form {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 14px 32px; background: var(--primary); color: #fff;
  border-radius: var(--radius-sm); font-weight: 600; font-size: 1rem;
  transition: background var(--transition), transform var(--transition);
  box-shadow: 0 4px 20px rgba(194, 75, 43, 0.30);
  will-change: transform;
}
.btn-form:hover { background: var(--primary-light); color: #fff; transform: translateY(-2px); }

/* --- Dataset Entries (article-style) --- */
.dataset-entry {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px 32px;
  margin-bottom: 24px;
}
.dataset-entry-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 16px;
}
.dataset-entry-header h3 { margin-bottom: 0; font-size: 1.15rem; }
.dataset-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.dataset-type-badge, .dataset-status {
  font-size: 0.72rem; font-weight: 600; padding: 2px 9px;
  border-radius: 20px; text-transform: uppercase; letter-spacing: 0.4px;
}
/* FIX: Use hex alpha instead of rgba(var()) — Brave's Chromium has parsing issues */
.badge-speech  { background: #C24B2B1A; color: var(--primary); }
.badge-dialect { background: #3B78BA1F; color: #2a5f9e; }
.badge-public  { background: #4C99601A; color: #2d7a46; }
.dataset-entry-body p {
  font-size: 0.92rem; color: var(--text-muted); line-height: 1.75;
  margin-bottom: 12px;
}
.dataset-entry-body code {
  background: var(--bg-alt); padding: 1px 6px; border-radius: 4px;
  font-size: 0.86em;
}
.dataset-table {
  width: 100%; border-collapse: collapse; margin: 16px 0;
  font-size: 0.88rem;
}
.dataset-table th {
  text-align: left; padding: 6px 12px 6px 0;
  color: var(--text); font-weight: 600; white-space: nowrap;
  border-bottom: 1px solid var(--border); width: 140px;
}
.dataset-table td {
  padding: 6px 0; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.dataset-links {
  display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px;
}
.dataset-links a {
  font-size: 0.83rem; font-weight: 500; color: var(--primary);
}
.dataset-links a:hover { color: var(--primary-light); }

/* Dataset gap note */
.dataset-gap-note {
  margin-top: 32px; padding: 24px;
  background: var(--bg-alt); border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.dataset-gap-note h3 { font-size: 1.05rem; margin-bottom: 10px; }
.dataset-gap-note p {
  font-size: 0.9rem; color: var(--text-muted); line-height: 1.75;
  margin-bottom: 10px;
}
.dataset-gap-note p:last-child { margin-bottom: 0; }

/* --- Coming Soon (roadmap) --- */
.coming-soon-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}
.cs-card {
  background: var(--bg-card); border: 1px dashed var(--border);
  border-radius: var(--radius); padding: 24px;
}
.cs-card h4 { font-size: 1rem; margin-bottom: 8px; }
.cs-card p { font-size: 0.87rem; color: var(--text-muted); margin-bottom: 14px; line-height: 1.65; }
.cs-badge {
  display: inline-block; font-size: 0.72rem; font-weight: 600;
  padding: 3px 12px; border-radius: 20px;
  background: var(--bg-alt); border: 1px solid var(--border);
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;
}

/* Map source note */
.map-source-note {
  text-align: center; margin-top: 16px;
  font-size: 0.78rem; color: var(--text-light);
}

/* --- Footer --- */
.site-footer {
  padding: 48px 0 24px;
  background: var(--bg-alt); border-top: 1px solid var(--border);
}
.footer-grid {
  display: grid; grid-template-columns: 2fr 1fr 1fr;
  gap: 40px; margin-bottom: 32px;
}
.footer-col h4 { font-size: 0.9rem; font-weight: 600; margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: 8px; }
.footer-col a { color: var(--text-muted); font-size: 0.9rem; }
.footer-col a:hover { color: var(--primary); }
.footer-bottom {
  border-top: 1px solid var(--border); padding-top: 20px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.82rem; color: var(--text-light);
}
.cc-badge { display: flex; align-items: center; gap: 6px; }
.cc-badge img { height: 20px; }

/* --- Animations --- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in {
  opacity: 0; transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
  /* FIX: Brave requires explicit will-change for intersection-observer-driven
     transitions to composite correctly */
  will-change: opacity, transform;
}
.fade-in.visible { opacity: 1; transform: translateY(0); }

/* FIX: Brave Shields sometimes delays or drops IntersectionObserver callbacks.
   Ensure elements don't stay permanently hidden if JS never fires. */
@media (prefers-reduced-motion: reduce) {
  .fade-in {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* --- Citations --- */
.citations { margin-top: 24px; }
.citations details { margin-bottom: 8px; }
.citations summary {
  cursor: pointer; font-weight: 500; font-size: 0.9rem;
  color: var(--text-muted); padding: 8px 0;
}
.citations ol { padding-left: 20px; font-size: 0.85rem; color: var(--text-muted); }
.citations li { margin-bottom: 6px; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .nav-links {
    position: fixed; top: 64px; left: 0; right: 0;
    /* FIX: Use solid background fallback — Brave blocks backdrop-filter in mobile too */
    background: rgba(255, 249, 240, 0.98);
    flex-direction: column; gap: 0; padding: 0;
    max-height: 0; overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease;
    border-bottom: 1px solid var(--border);
  }

  @supports (backdrop-filter: blur(12px)) {
    .nav-links {
      background: rgba(255, 249, 240, 0.94);
      -webkit-backdrop-filter: blur(12px);
      backdrop-filter: blur(12px);
    }
  }

  .nav-links.open { max-height: 480px; padding: 12px 0; }
  .nav-links li { width: 100%; }
  .nav-links a { display: block; padding: 12px 24px; }
  .nav-links a::after { display: none; }
  .nav-cta-link { margin: 4px 16px; display: block; text-align: center; }
  .hamburger { display: block; }
  .interest-banner { grid-template-columns: 1fr; gap: 24px; }
  .form-cta-box { position: static; }
  .dataset-entry { padding: 20px; }
  .dataset-entry-header { flex-direction: column; align-items: flex-start; }
  .dataset-table th { width: auto; }
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
  .footer-bottom { flex-direction: column; gap: 12px; text-align: center; }
  .section { padding: 56px 0; }
  .hero { padding: 110px 0 56px; }
  .map-wrapper { transform: none; }
  .map-wrapper:hover { transform: none; }
  .hero-actions { flex-direction: column; align-items: center; }
}