/* ============================================================
   RESPONSIVE.CSS — Mobile-first responsive system
   Uses min-width for progressive enhancement, max-width for overrides.
   ============================================================ */

/* ============================================================
   MOBILE BASE (default < 640px)
   ============================================================ */
.main-layout {
  grid-template-columns: 1fr;
  padding-top: calc(var(--header-height) + 12px);
}
.sidebar {
  position: static;
  max-height: none;
  overflow-y: visible;
}
.match-grid {
  grid-template-columns: 1fr;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}
.match-detail-teams {
  gap: 16px;
}
.match-detail-team-name {
  font-size: clamp(0.875rem, 2.5vw, 1.25rem);
}
.match-detail-team-badge {
  width: 48px;
  height: 48px;
}
.match-detail-score-time {
  font-size: 1.125rem;
}
.match-detail-center {
  min-width: 60px;
}
.match-detail-team {
  max-width: 120px;
}
.match-card-footer {
  display: none;
}
.hero-card-viewers {
  font-size: 0.6875rem;
}
.halftime-content {
  padding: 24px 16px;
}
.toast-container {
  left: 12px;
  right: 12px;
  bottom: 12px;
}
.toast {
  max-width: 100%;
}
.scroll-promo {
  padding: 6px 12px;
}
.scroll-promo-img {
  height: 40px;
  max-width: 100%;
}

/* Mobile: search bar full width */
.search-bar {
  max-width: 100%;
}

/* Mobile: logo smaller */
.logo-icon-img {
  height: 28px;
}

/* Mobile: hero card compact */
.hero-card {
  padding: 16px;
}
.hero-teams {
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.hero-team-badge {
  width: 40px;
  height: 40px;
}
.hero-team-name {
  font-size: 0.9375rem;
}
.hero-card-arrow {
  display: none;
}

/* Mobile: footer touch targets */
.footer-links a,
.footer-links-echo a {
  min-height: 44px;
  display: flex;
  align-items: center;
}

/* Mobile: promo images smaller */
.promo-in-content .promo-in-content-img {
  max-height: 80px;
  width: 100%;
  object-fit: cover;
}

/* Mobile: content padding */
.content-padding {
  padding-left: var(--content-padding);
  padding-right: var(--content-padding);
}

/* ============================================================
   MOBILE SIDEBAR → BOTTOM SHEET (< 768px)
   ============================================================ */
@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 55vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: var(--color-surface-raised);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
    z-index: 50;
    overflow-y: auto;
    padding: 12px 16px 16px;
    transform: translateY(calc(100% - 48px));
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .sidebar.expanded,
  .sidebar:focus-within {
    transform: translateY(0);
  }
  .sidebar:empty {
    display: none;
  }
}

/* Sidebar drag handle */
.sidebar-handle {
  display: none;
}
@media (max-width: 767px) {
  .sidebar-handle {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px 0 4px;
    cursor: grab;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
  }
  .sidebar-handle::before {
    content: "";
    width: 32px;
    height: 4px;
    border-radius: 2px;
    background: var(--color-text-muted, #666);
    opacity: 0.4;
    transition:
      opacity 0.2s,
      width 0.2s;
  }
  .sidebar-handle:hover::before,
  .sidebar.expanded .sidebar-handle::before {
    opacity: 0.7;
    width: 40px;
  }
}

/* ============================================================
   DATE NAV: horizontal scroll on small screens
   ============================================================ */
@media (max-width: 639px) {
  .date-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    gap: 4px;
  }
  .date-nav::-webkit-scrollbar {
    display: none;
  }
  .date-nav-btn {
    min-width: 48px;
    padding: 4px 6px;
    flex-shrink: 0;
  }
  .date-nav-day {
    font-size: 0.5625rem;
  }
  .date-nav-date {
    font-size: 0.875rem;
  }
  .date-nav-month {
    font-size: 0.5rem;
  }
}

/* ============================================================
   SMALL TABLET (640px+)
   ============================================================ */
@media (min-width: 640px) {
  .match-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .match-detail-teams {
    gap: 24px;
  }
  .match-detail-team-badge {
    width: 56px;
    height: 56px;
  }
  .hero-card {
    padding: 24px;
  }
  .hero-team-badge {
    width: 48px;
    height: 48px;
  }
  .hero-team-name {
    font-size: 1.0625rem;
  }
  .hero-card-arrow {
    display: block;
  }
  .hero-card-viewers {
    font-size: 0.75rem;
  }
  .promo-in-content .promo-in-content-img {
    max-height: 100px;
  }
}

/* ============================================================
   TABLET (768px+) — restore desktop sidebar, show card footer
   ============================================================ */
@media (min-width: 768px) {
  .match-card-footer {
    display: flex;
  }
  .sidebar {
    position: static;
    transform: none;
    max-height: none;
    border-radius: var(--radius-lg);
    border-top: none;
    box-shadow: var(--shadow-sm);
    padding: 16px;
  }
}

/* ============================================================
   DESKTOP (1024px+) — two-column with sticky sidebar
   ============================================================ */
@media (min-width: 1024px) {
  /* Default layout: main + right sidebar */
  .main-layout {
    grid-template-columns: 1fr var(--sidebar-width);
    padding-top: calc(var(--header-height) + 16px);
  }
  .sidebar {
    position: sticky;
    top: calc(var(--header-height) + 16px);
    max-height: calc(100vh - var(--header-height) - 32px);
    overflow-y: auto;
  }
  .footer-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .content-padding {
    padding-left: 0;
    padding-right: 0;
  }

  /* Bravo: LEFT sidebar — reverse grid order */
  [data-theme="bravo"] .main-layout {
    grid-template-columns: var(--sidebar-width) 1fr;
  }
  [data-theme="bravo"] .main-content {
    order: 2;
  }
  [data-theme="bravo"] .sidebar {
    order: 1;
  }
  [data-theme="bravo"] .match-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Alpha: RIGHT sidebar, visible */
  [data-theme="alpha"] .match-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Charlie: NO sidebar (inline) — except on match page */
  [data-theme="charlie"] .main-layout:not(.match-page-main) {
    grid-template-columns: 1fr;
  }
  [data-theme="charlie"] .main-layout:not(.match-page-main) .sidebar {
    display: none;
  }

  /* Delta: RIGHT sidebar, visible */
  [data-theme="delta"] .match-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Echo: NO sidebar (inline) — except on match page */
  [data-theme="echo"] .main-layout:not(.match-page-main) {
    grid-template-columns: 1fr;
  }
  [data-theme="echo"] .main-layout:not(.match-page-main) .sidebar {
    display: none;
  }

  /* Theme-specific container widths */
  [data-theme="alpha"] .container {
    max-width: 1600px;
  }
  [data-theme="bravo"] .container {
    max-width: 1400px;
  }
  [data-theme="charlie"] .container {
    max-width: 1100px;
  }
  [data-theme="delta"] .container {
    max-width: 1300px;
  }
  [data-theme="echo"] .container {
    max-width: 1200px;
  }
}

/* ============================================================
   LARGE DESKTOP (1280px+)
   ============================================================ */
@media (min-width: 1280px) {
  [data-theme="alpha"] .match-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  [data-theme="alpha"] .match-list .match-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  [data-theme="bravo"] .match-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  [data-theme="echo"] .match-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .footer-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ============================================================
   MATCH PAGE — per-theme layout, sidebar always visible
   ============================================================ */
@media (min-width: 1024px) {
  .match-page-main {
    grid-template-columns: 1fr var(--sidebar-width);
  }
  .match-page-main .sidebar {
    display: block !important;
    position: sticky;
    top: calc(var(--header-height) + 16px);
    max-height: calc(100vh - var(--header-height) - 32px);
    overflow-y: auto;
  }
  .referral-banner-side {
    display: block;
  }
  /* Alpha: full-width content, right sidebar */
  [data-theme="alpha"] .match-page-main {
    max-width: 1600px;
  }
  /* Bravo: LEFT sidebar */
  [data-theme="bravo"] .match-page-main {
    grid-template-columns: var(--sidebar-width) 1fr;
  }
  [data-theme="bravo"] .match-page-main .main-content {
    order: 2;
  }
  [data-theme="bravo"] .match-page-main .sidebar {
    order: 1;
  }
  /* Charlie: narrower content, right sidebar */
  [data-theme="charlie"] .match-page-main {
    max-width: 1200px;
  }
  /* Delta: standard with right sidebar */
  [data-theme="delta"] .match-page-main {
    max-width: 1400px;
  }
  /* Echo: right sidebar */
  [data-theme="echo"] .match-page-main {
    max-width: 1100px;
  }
}

/* ============================================================
   SIDEBAR TOGGLE — Mobile only, hidden on desktop
   ============================================================ */
@media (min-width: 1024px) {
  .sidebar-toggle {
    display: none !important;
  }
  .sidebar-handle {
    display: none;
  }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .sidebar-toggle {
    display: flex;
  }
  .sidebar-handle {
    display: none;
  }
}

/* ============================================================
   REFERRAL BANNER — Mobile max-height
   ============================================================ */
@media (max-width: 480px) {
  .referral-banner-side img {
    max-height: 300px;
  }
}

/* ============================================================
   ULTRA WIDE (1536px+)
   ============================================================ */
@media (min-width: 1536px) {
  [data-theme="alpha"] .match-grid {
    grid-template-columns: repeat(5, 1fr);
  }
  [data-theme="echo"] .match-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ============================================================
   THEME-SPECIFIC MOBILE OVERRIDES
   ============================================================ */

/* Charlie: stack teams vertically on very small screens */
@media (max-width: 480px) {
  [data-theme="charlie"] .match-detail-teams {
    flex-direction: column;
    gap: 12px;
  }
  [data-theme="charlie"] .match-detail-center {
    flex-direction: row;
    gap: 12px;
  }
}

/* Delta: disable blur on mobile for performance */
@media (max-width: 639px) {
  [data-theme="delta"] .match-card {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  [data-theme="delta"] .search-bar {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  [data-theme="delta"] .sidebar-widget {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* Echo: tighter mobile layout */
@media (max-width: 639px) {
  [data-theme="echo"] .match-card {
    border-left-width: 2px;
  }
  [data-theme="echo"] .filter-chip {
    font-size: 0.5625rem;
    padding: 6px 8px;
  }
}

/* Bravo: hero card mobile */
@media (max-width: 639px) {
  [data-theme="bravo"] .hero-card {
    padding: 16px;
  }
  [data-theme="bravo"] .hero-teams {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }
  [data-theme="bravo"] .hero-team-badge {
    width: 40px;
    height: 40px;
  }
  [data-theme="bravo"] .hero-team-name {
    font-size: 0.9375rem;
  }
  [data-theme="bravo"] .hero-card-arrow {
    display: none;
  }
  [data-theme="bravo"] .hero-card-viewers {
    font-size: 0.75rem;
  }
}

/* ============================================================
   MOBILE SIDEBAR — Per-theme bottom-sheet overrides (< 768px)
   ============================================================ */
@media (max-width: 767px) {
  /* Alpha: remove irrelevant left border, clean top edge */
  [data-theme="alpha"] .sidebar {
    border-left: none;
    border-top: 3px solid var(--color-primary);
  }
  /* Bravo: keep glassmorphism, add blue top accent */
  [data-theme="bravo"] .sidebar {
    border-top: 2px solid rgba(37, 99, 235, 0.4);
    backdrop-filter: blur(12px);
  }
  /* Charlie: newspaper top rule */
  [data-theme="charlie"] .sidebar {
    border-left: none;
    border-top: 3px double var(--color-primary);
  }
  /* Delta: purple glow top accent */
  [data-theme="delta"] .sidebar {
    border-top: 2px solid rgba(168, 85, 247, 0.3);
    box-shadow: 0 -4px 24px rgba(168, 85, 247, 0.15);
  }
  /* Echo: minimal top line */
  [data-theme="echo"] .sidebar {
    border-left: none;
    border-top: 1px solid #333;
  }

  /* Referral banner: full width, no black bars, fit mobile */
  .referral-banner-side {
    width: 100%;
    border-radius: var(--radius);
    overflow: hidden;
  }
  .referral-banner-side img {
    max-height: 350px;
    width: 100%;
    object-fit: contain;
    border-radius: var(--radius);
  }

  /* CTA banner: compact mobile */
  .cta-banner {
    margin: 8px 0;
  }
  .cta-banner-overlay {
    padding: 8px 12px;
  }
  .cta-banner-title {
    font-size: 0.8125rem;
  }
  .cta-banner-text {
    font-size: 0.6875rem;
    margin-bottom: 4px;
  }
  .cta-banner-btn {
    font-size: 0.6875rem;
    padding: 5px 12px;
  }

  /* Sidebar widgets: compact mobile */
  .sidebar-widget {
    padding: 12px;
    margin-bottom: 8px;
  }
  .sidebar-widget-title {
    font-size: 0.6875rem;
    margin-bottom: 8px;
  }

  /* Safe area for iOS home indicator */
  .sidebar {
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
}

/* ============================================================
   FOOTER RESPONSIVE
   ============================================================ */
@media (max-width: 767px) {
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .footer-col-title {
    margin-bottom: 8px;
  }
  .footer-links {
    gap: 2px;
  }
  .footer-links a {
    padding: 6px 0;
    font-size: 0.8125rem;
  }
  .footer-bottom {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================================
   TOUCH DEVICES: larger tap targets
   ============================================================ */
@media (hover: none) and (pointer: coarse) {
  .sport-tab {
    min-height: 44px;
    padding: 10px 16px;
  }
  .filter-chip {
    min-height: 44px;
    padding: 10px 16px;
  }
  .date-nav-btn {
    min-height: 44px;
  }
  .match-card-link {
    padding: 4px;
  }
  .source-item {
    min-height: 48px;
    padding: 12px;
  }
  .toast-close {
    min-width: 44px;
    min-height: 44px;
  }
  .promo-modal-close {
    min-width: 44px;
    min-height: 44px;
  }
  .btn {
    min-height: 44px;
  }
  .btn-sm {
    min-height: 36px;
  }
  .notif-bell {
    min-height: 44px;
  }
  .halftime-dismiss {
    min-height: 44px;
    padding: 10px 16px;
  }
  .sidebar-handle {
    min-height: 32px;
  }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .site-header,
  .site-footer,
  .sidebar,
  .stream-wrapper,
  .toast-container,
  .promo-modal-overlay,
  .promo-banner,
  .notif-bell,
  .skip-link,
  #theme-switcher,
  .hero-card,
  .scroll-promo,
  .sidebar-handle,
  .promo-in-content {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
  .main-layout {
    grid-template-columns: 1fr;
    padding: 0;
  }
  .match-card {
    border: 1px solid #ccc;
    break-inside: avoid;
  }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }
  .promo-in-content {
    animation: none;
  }
}

/* Hide sidebar completely on mobile (no toggle) */
@media (max-width: 767px) {
  .sidebar {
    display: none !important;
  }
}

/* Force sticky sidebar on desktop */
@media (min-width: 1024px) {
  .sidebar {
    position: sticky !important;
    top: calc(var(--header-height) + 16px) !important;
    z-index: 10;
  }
}

/* Force sticky sidebar on desktop */
@media (min-width: 1024px) {
  .sidebar {
    position: sticky !important;
    top: calc(var(--header-height) + 16px) !important;
    z-index: 10;
  }
}

@media (min-width: 1024px) {
  .sidebar {
    position: sticky !important;
    top: calc(var(--header-height) + 16px) !important;
  }
}

@media (min-width: 1024px) {
  .sidebar {
    position: sticky !important;
    top: calc(var(--header-height) + 16px) !important;
  }
}
