/*
 * LaksAtlas — Mobile Overrides
 * Linked in all year pages. Desktop styles are untouched.
 * Breakpoints: 768px (tablet/phone), 420px (small phone)
 */

/* Hidden on desktop, shown only via media query below */
.nav-hamburger { display: none; }
.nav-mobile-menu { display: none; }
.map-filter-btn { display: none; }
.map-bottom-bar { display: none; }
.drawer-backdrop { display: none; }
#detailsSheet { display: none; }

/* ============================================================
   PREVENT HORIZONTAL OVERFLOW — must be first
   ============================================================ */
@media (max-width: 768px) {
  html, body {
    overflow-x: hidden !important;
    max-width: 100% !important;
  }
}

/* ============================================================
   NAVIGATION
   ============================================================ */
@media (max-width: 768px) {
  nav {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 0 14px !important;
    height: 54px !important;
    gap: 10px !important;
  }

  /* Hide desktop nav links and scope toggle — moved into dropdown */
  .nav-links {
    display: none !important;
  }

  .scope-toggle {
    display: none !important;
  }

  .nav-logo {
    flex-shrink: 0 !important;
    gap: 8px !important;
  }

  .nav-logo-img {
    height: 28px !important;
  }

  .nav-logo-text {
    font-size: 11px !important;
    letter-spacing: 1.6px !important;
  }

  /* HAMBURGER BUTTON */
  .nav-hamburger {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    gap: 5px !important;
    background: none !important;
    border: 1px solid rgba(0,200,255,0.2) !important;
    border-radius: 8px !important;
    padding: 8px 10px !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
  }

  .nav-hamburger span {
    display: block !important;
    width: 20px !important;
    height: 2px !important;
    background: var(--neon-cyan) !important;
    border-radius: 2px !important;
    transition: all 0.2s ease !important;
  }

  .nav-hamburger.open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg) !important;
  }
  .nav-hamburger.open span:nth-child(2) {
    opacity: 0 !important;
  }
  .nav-hamburger.open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg) !important;
  }

  /* MOBILE DROPDOWN MENU */
  .nav-mobile-menu {
    display: none;
    position: fixed !important;
    top: 54px !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 999 !important;
    background: rgba(4,9,26,0.97) !important;
    backdrop-filter: blur(20px) !important;
    border-bottom: 1px solid rgba(0,200,255,0.12) !important;
    padding: 16px 0 20px !important;
    flex-direction: column !important;
  }

  .nav-mobile-menu.open {
    display: flex !important;
  }

  /* Scope row inside dropdown */
  .nav-mobile-scope {
    display: flex !important;
    gap: 10px !important;
    padding: 10px 20px 16px !important;
    border-bottom: 1px solid rgba(0,200,255,0.08) !important;
    margin-bottom: 8px !important;
  }

  .nav-mobile-scope a {
    flex: 1 !important;
    text-align: center !important;
    padding: 10px !important;
    border-radius: 999px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    letter-spacing: 1px !important;
    text-transform: uppercase !important;
    text-decoration: none !important;
    color: var(--text-dim) !important;
    border: 1px solid var(--border) !important;
    background: rgba(255,255,255,0.03) !important;
    font-family: 'JetBrains Mono', monospace !important;
  }

  .nav-mobile-scope a.active-no {
    background: linear-gradient(135deg, var(--neon-cyan), #a8d8f8) !important;
    color: #04091a !important;
    border-color: rgba(0,200,255,0.75) !important;
  }

  .nav-mobile-scope a.active-gl {
    background: linear-gradient(135deg, #1de9a8, #00c8ff) !important;
    color: #04091a !important;
    border-color: rgba(0,200,255,0.75) !important;
  }

  /* Nav links inside dropdown */
  .nav-mobile-menu a.nav-mobile-link {
    display: block !important;
    padding: 13px 20px !important;
    color: var(--text-dim) !important;
    text-decoration: none !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    letter-spacing: 1.2px !important;
    text-transform: uppercase !important;
    font-family: 'JetBrains Mono', monospace !important;
    border-bottom: 1px solid rgba(255,255,255,0.04) !important;
    transition: color 0.2s !important;
  }

  .nav-mobile-menu a.nav-mobile-link:last-child {
    border-bottom: none !important;
  }

  .nav-mobile-menu a.nav-mobile-link.active {
    color: var(--neon-cyan) !important;
  }

  .nav-mobile-menu a.nav-mobile-link:hover {
    color: var(--text) !important;
  }
}

/* ============================================================
   HERO SECTION
   ============================================================ */
@media (max-width: 768px) {
  .hero {
    padding: 80px 16px 60px !important;
    min-height: auto !important;
  }

  .hero-number {
    font-size: clamp(48px, 13vw, 72px) !important;
  }

  .hero-unit {
    font-size: clamp(15px, 4.5vw, 20px) !important;
  }

  .hero-subtitle {
    font-size: 14px !important;
    line-height: 1.7 !important;
  }

  /* Override inline style="grid-template-columns:repeat(4,...)" */
  .hero-mini-stats {
    grid-template-columns: 1fr 1fr !important;
    width: 100% !important;
    gap: 10px !important;
  }

  .hero-mini-card {
    padding: 12px 14px !important;
  }

  .hero-mini-value {
    font-size: 20px !important;
  }

  .scroll-indicator {
    display: none !important;
  }
}

@media (max-width: 420px) {
  .hero-mini-stats {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================================
   YEAR TABS & WHY-LOSSES NOTE
   ============================================================ */
@media (max-width: 768px) {
  .year-tabs-wrap {
    padding: 0 12px !important;
  }

  /* The amber "why losses" note uses inline max-width:780px */
  .losses-note {
    margin: 16px 12px 0 !important;
  }
}

/* ============================================================
   SECTIONS
   ============================================================ */
@media (max-width: 768px) {
  .section {
    padding: 48px 16px !important;
  }

  .section-title {
    font-size: clamp(20px, 5.5vw, 28px) !important;
    line-height: 1.2 !important;
    margin-bottom: 10px !important;
  }

  .section-desc {
    font-size: 14px !important;
    margin-bottom: 28px !important;
  }
}

/* ============================================================
   CHARTS & CONTAINERS
   ============================================================ */
@media (max-width: 768px) {
  .chart-container {
    padding: 16px !important;
  }

  .chart-wrap {
    height: 210px !important;
  }

  .chart-title {
    font-size: 13px !important;
  }

  .two-col {
    grid-template-columns: 1fr !important;
  }

  .stat-grid {
    grid-template-columns: 1fr 1fr !important;
  }
}

@media (max-width: 420px) {
  .stat-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================================
   STAT BLOCKS (Section 01 key numbers)
   ============================================================ */
@media (max-width: 768px) {
  .stat-block-value {
    font-size: 28px !important;
  }
}

/* ============================================================
   GOVERNMENT TARGET BAR (Section below hero)
   ============================================================ */
@media (max-width: 768px) {
  .gov-target {
    padding: 36px 16px 0 !important;
  }

  .gov-target-headline {
    font-size: clamp(18px, 5vw, 24px) !important;
  }

  .gov-target-desc {
    font-size: 13px !important;
  }

  .mort-stat-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  .mort-bar-track {
    height: 24px !important;
  }
}

/* ============================================================
   VETERINARY INSTITUTE — 3-stat boxes
   Uses class .vet-stat-grid added to the inline-styled div
   ============================================================ */
@media (max-width: 768px) {
  .vet-stat-grid {
    grid-template-columns: 1fr !important;
  }

  .vet-stat-grid > div {
    padding: 16px !important;
  }

  .vet-stat-grid > div > div:first-child {
    font-size: 32px !important;
  }
}

@media (min-width: 421px) and (max-width: 768px) {
  .vet-stat-grid {
    grid-template-columns: 1fr 1fr 1fr !important;
  }
}

/* ============================================================
   MAP PAGE (map.html)
   Two-row header: row1 = logo+hamburger (54px), row2 = week nav (40px)
   Bottom bar: Filters | Details (48px)
   Details sheet: slides up from bottom, shows stat cards with inline charts
   ============================================================ */
@media (max-width: 768px) {

  /* Two-row header */
  header {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    padding: 0 14px !important;
    height: auto !important;
  }

  header .scope-toggle { display: none !important; }
  .meta-badge   { display: none !important; }
  .week-no-data { display: none !important; }

  /* Row 1: logo (order 1) + hamburger (order 2) */
  .logo {
    order: 1 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    text-decoration: none !important;
    flex: 1 !important;
    height: 54px !important;
  }
  .logo-img  { height: 28px !important; }
  .logo-text { font-size: 11px !important; letter-spacing: 1.6px !important; }

  header .nav-hamburger {
    order: 2 !important;
    display: flex !important;
    height: 54px !important;
    align-items: center !important;
  }

  /* Row 2: week nav (order 3) — full width, forces wrap */
  .header-meta {
    order: 3 !important;
    display: flex !important;
    width: 100% !important;
    justify-content: center !important;
    align-items: center !important;
    height: 40px !important;
    border-top: 1px solid rgba(0,200,255,0.08) !important;
  }

  .week-nav    { gap: 8px !important; }
  .week-display {
    font-size: 11px !important;
    white-space: nowrap !important;
    min-width: 0 !important;
  }
  .week-nav-btn {
    width: 32px !important;
    height: 32px !important;
    font-size: 18px !important;
    padding: 0 !important;
  }

  header + .nav-mobile-menu { top: 94px !important; }

  /* Map layout: header 94px, bottom bar 48px */
  .layout {
    display: block !important;
    padding-top: 94px !important;
    height: calc(100vh - 94px) !important;
  }

  #map {
    width: 100vw !important;
    height: calc(100vh - 94px - 48px) !important;
  }

  #rightPanel { display: none !important; }

  /* Hide stat cards inside filter drawer — they live in the details sheet */
  #leftPanelStats { display: none !important; }

  /* Left panel filter drawer */
  #leftPanel {
    display: flex !important;
    flex-direction: column !important;
    position: fixed !important;
    top: 94px !important;
    left: -100% !important;
    width: 88vw !important;
    max-width: 300px !important;
    height: calc(100vh - 94px - 48px) !important;
    z-index: 950 !important;
    background: rgba(4,9,26,0.97) !important;
    backdrop-filter: blur(20px) !important;
    border-right: 1px solid rgba(0,200,255,0.15) !important;
    overflow-y: auto !important;
    transition: left 0.28s ease !important;
    padding: 16px !important;
    gap: 14px !important;
  }

  #leftPanel.drawer-open { left: 0 !important; }

  .drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 940;
    background: rgba(0,0,0,0.5);
  }
  .drawer-backdrop.open { display: block; }

  /* ── Bottom bar: Filters | Details ────────────────────────── */
  .map-bottom-bar {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 48px !important;
    z-index: 900 !important;
    background: rgba(4,9,26,0.97) !important;
    border-top: 1px solid rgba(0,200,255,0.2) !important;
    backdrop-filter: blur(12px) !important;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.4) !important;
  }

  .map-bottom-btn {
    flex: 1 !important;
    background: none !important;
    border: none !important;
    border-right: 1px solid rgba(0,200,255,0.1) !important;
    color: var(--text-dim) !important;
    font-family: 'JetBrains Mono', monospace !important;
    font-size: 11px !important;
    letter-spacing: 1.2px !important;
    text-transform: uppercase !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    transition: color 0.2s !important;
  }

  .map-bottom-btn:last-child { border-right: none !important; }
  .map-bottom-btn.active,
  .map-bottom-btn:hover      { color: var(--neon-cyan) !important; }

  /* ── Details bottom sheet ──────────────────────────────────── */
  #detailsSheet {
    display: block !important;
    position: fixed !important;
    bottom: 48px !important;
    left: 0 !important;
    right: 0 !important;
    height: 65vh !important;
    z-index: 890 !important;
    background: rgba(4,9,26,0.98) !important;
    border-top: 1px solid rgba(0,200,255,0.18) !important;
    backdrop-filter: blur(20px) !important;
    transform: translateY(100%) !important;
    transition: transform 0.3s ease !important;
    pointer-events: none !important;
  }

  #detailsSheet.open {
    transform: translateY(0) !important;
    pointer-events: auto !important;
  }

  #detailsSheetInner {
    height: 100% !important;
    overflow-y: auto !important;
    padding: 16px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
  }

  #detailsSheetTitle {
    font-family: 'JetBrains Mono', monospace !important;
    font-size: 10px !important;
    letter-spacing: 2.5px !important;
    text-transform: uppercase !important;
    color: var(--text-dim) !important;
    padding-bottom: 12px !important;
    border-bottom: 1px solid rgba(0,200,255,0.08) !important;
    margin-bottom: 4px !important;
  }

  /* ── Detail cards with inline expand ──────────────────────── */
  .detail-card {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    cursor: pointer !important;
    transition: border-color 0.2s !important;
  }

  .detail-card:hover { border-color: var(--border-hover) !important; }

  .detail-card-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 12px 14px !important;
    gap: 10px !important;
  }

  .detail-card-arrow {
    color: var(--text-dim) !important;
    font-size: 16px !important;
    flex-shrink: 0 !important;
    transition: color 0.2s, transform 0.2s !important;
  }

  .detail-card.chart-open .detail-card-arrow {
    color: var(--neon-cyan) !important;
  }

  .detail-chart-wrap {
    display: none !important;
    padding: 0 12px 14px !important;
  }

  .detail-chart-wrap.open {
    display: block !important;
  }

  /* Legend above the bottom bar */
  .map-legend {
    bottom: 56px !important;
    padding: 7px 10px !important;
    gap: 4px !important;
    flex-wrap: wrap !important;
    max-width: 92vw !important;
    justify-content: center !important;
  }

  .legend-item {
    font-size: 9px !important;
    padding: 2px 7px !important;
  }
}

/* ============================================================
   ABOUT PAGE — Video hero
   ============================================================ */
@media (max-width: 768px) {

  /* Contain the hero strictly within the viewport width */
  .video-hero {
    height: 60vh !important;
    min-height: 320px !important;
    width: 100% !important;
    max-width: 100vw !important;
    overflow: hidden !important;
    position: relative !important;
  }

  /* Pin video with absolute positioning so it can never push the layout wider */
  .video-hero video {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }

  /* Move the scroll CTA up so it clears mobile browser chrome */
  .video-hero-cta {
    bottom: 28px !important;
  }

  .video-hero-cta span {
    font-size: 10px !important;
    letter-spacing: 2px !important;
  }

  /* Content padding more compact on mobile */
  .content-wrap {
    padding: 48px 16px 80px !important;
  }
}

/* ============================================================
   HEALTH OVERVIEW (bubble visualization) — mobile fixes
   ============================================================ */
@media (max-width: 768px) {
  .bv-modal-inner {
    padding: 12px 10px !important;
  }

  .bv-header {
    height: 44px !important;
    padding: 0 10px !important;
    gap: 6px !important;
  }

  .bv-sub {
    display: none !important;
  }

  .bv-title {
    font-size: 11px !important;
    letter-spacing: 1px !important;
  }

  #bvChartCanvas {
    height: 180px !important;
  }

  .bv-chart-box h4 {
    font-size: 11px !important;
  }

  .bv-chart-box p {
    font-size: 10px !important;
  }
}

/* ============================================================
   CTA & FOOTER
   ============================================================ */
@media (max-width: 768px) {
  .cta-section {
    padding: 60px 16px !important;
  }

  .cta-button {
    width: 100% !important;
    justify-content: center !important;
    padding: 14px 20px !important;
  }

  footer {
    padding: 28px 16px !important;
    font-size: 10px !important;
  }
}
