/* ============================================================
   SWISS JUNIORS CUP — Responsive Polish
   Mobile-first refinements. Loaded after styles.css + ui-upgrade.css
   Breakpoints:
     - <= 480px  : phone
     - <= 767px  : large phone / small tablet
     - 768-1199px: tablet / small laptop
     - >= 1200px : desktop (already handled)
   ============================================================ */

/* Prevent horizontal scroll caused by any overflowing element */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

img, video, iframe {
  max-width: 100%;
}

/* ============================================================
   PHONE (<= 767px)
   ============================================================ */
@media (max-width: 767px) {

  /* Container padding */
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Section padding tighter */
  .section {
    padding: 40px 0;
  }

  /* Headings sizing */
  .section-title {
    font-size: clamp(1.6rem, 7vw, 2.2rem) !important;
    letter-spacing: 1px !important;
  }

  .section-label {
    font-size: 11px;
    letter-spacing: 1.5px;
  }

  .section-desc {
    font-size: 14px;
    line-height: 1.6;
  }

  .section-header-center {
    margin-bottom: 28px !important;
  }

  /* HEADER */
  .header-inner {
    padding: 12px 16px !important;
  }
  .logo-title { font-size: 14px !important; }
  .logo-sub { font-size: 10px !important; }
  .logo-icon { width: 36px !important; height: 36px !important; }

  /* HERO */
  .hero-fullscreen {
    height: 100vh;
    min-height: 500px;
  }
  .hero-title {
    font-size: clamp(2.4rem, 12vw, 4rem);
    letter-spacing: 1px;
  }
  .hero-subtitle {
    font-size: 14px;
    padding: 0 16px;
  }
  .hero-cta {
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 280px;
  }
  .hero-cta .btn {
    width: 100%;
    justify-content: center;
  }
  .hero-sound-btn,
  .hero-play-btn {
    width: 44px !important;
    height: 44px !important;
  }
  .hero-scroll { display: none; }

  /* STATS row */
  .stats-row {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
  }
  .stat-number { font-size: 1.6rem !important; }
  .stat-label { font-size: 11px !important; }

  /* EDITIONS cards */
  .editions-grid { grid-template-columns: 1fr !important; gap: 16px; }
  .edition-card {
    min-height: 260px !important;
    padding: 20px !important;
  }
  .edition-card-title {
    font-size: 20px !important;
  }

  /* CLUBS grid — 2 columns on phone */
  .clubs-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px;
  }
  .club-card {
    padding: 14px 10px !important;
  }
  .club-logo {
    width: 56px !important;
    height: 56px !important;
  }
  .club-name {
    font-size: 12px !important;
    line-height: 1.2;
  }
  .club-country {
    font-size: 10px !important;
  }
  .club-action-hint {
    display: none !important;
  }

  /* SOCIAL STATS (legacy 4-grid, not used anymore but safe) */
  .social-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
  }
  .social-stat { padding: 16px 10px !important; }
  .social-stat-number { font-size: 1.4rem !important; }
  .social-stat-label { font-size: 11px !important; }

  /* PARTNERS */
  .partners-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
  }
  .partner-card {
    padding: 16px !important;
    min-height: 64px !important;
  }
  .partner-card img { max-height: 36px !important; }
  .partners-level-title {
    font-size: 13px !important;
    letter-spacing: 2px !important;
  }

  /* CHAMPIONS section (image swap) */
  .champions-section { padding: 40px 0 !important; }
  .champions-image-wrap {
    border-radius: 14px !important;
    aspect-ratio: 3 / 2;
  }
  .champions-image-wrap:hover {
    transform: none !important;
  }

  /* STATS section (image swap) */
  .stats-section { padding: 40px 0 !important; }
  .stats-image-wrap {
    border-radius: 14px !important;
    aspect-ratio: 19 / 10;
  }

  /* Footer */
  .footer { padding: 40px 0 24px !important; }
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 28px !important;
    text-align: center;
  }
  .footer-brand .logo {
    justify-content: center;
  }
  .footer-brand-desc { text-align: center; }
  .footer-links {
    align-items: center;
  }
  .footer-social {
    justify-content: center !important;
  }

  /* TEAMS TICKER */
  .teams-ticker-section {
    padding: 16px 0 !important;
  }

  /* SPONSOR CAROUSEL */
  .sponsor-carousel img,
  .sponsor-track img {
    max-height: 50px !important;
  }

  /* TABLES — better than hiding columns: horizontal scroll on phones */
  .table-wrapper {
    overflow-x: auto;
    border-radius: 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    -webkit-overflow-scrolling: touch;
    position: relative;
  }
  .table-wrapper::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 24px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.85));
    pointer-events: none;
  }
  .standings-table {
    min-width: 600px;
    border-radius: 0 !important;
    box-shadow: none !important;
  }
  /* Override the earlier "hide columns" rule — we prefer scroll */
  .standings-table th:nth-child(3),
  .standings-table td:nth-child(3),
  .standings-table th:nth-child(4),
  .standings-table td:nth-child(4),
  .standings-table th:nth-child(5),
  .standings-table td:nth-child(5),
  .standings-table th:nth-child(9),
  .standings-table td:nth-child(9) {
    display: table-cell !important;
  }

  /* Group header */
  .group-header {
    gap: 12px;
    padding-bottom: 12px;
    margin-bottom: 14px;
  }
  .group-badge {
    width: 40px;
    height: 40px;
    font-size: 18px;
    border-radius: 10px;
  }
  .group-title { font-size: 16px; }
  .group-subtitle { font-size: 11px; }

  /* MATCH cards already 1-col on phone via existing rules */
  .filter-row {
    flex-wrap: wrap;
    gap: 8px;
  }
  .filter-tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }
  .filter-tab {
    white-space: nowrap;
    flex-shrink: 0;
  }
  .filter-select {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }

  /* BRACKET */
  .bracket {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .bracket-grid {
    grid-template-columns: repeat(3, 200px) !important;
    gap: 20px;
    min-width: 660px;
  }

  /* PAGE HERO (sub pages) */
  .page-hero {
    min-height: 280px !important;
    padding: 100px 0 40px !important;
  }
  .page-hero-title {
    font-size: clamp(2rem, 9vw, 3rem) !important;
    letter-spacing: 1px !important;
  }
  .page-hero-subtitle {
    font-size: 13px !important;
  }
  .page-hero-badge {
    font-size: 10px !important;
    padding: 6px 14px !important;
  }

  /* TEAM MODAL */
  .team-modal-content {
    max-height: 92vh !important;
    margin: 8px !important;
    border-radius: 14px !important;
  }
  .compo-pitch { height: 220px !important; }
  .roster-list { grid-template-columns: 1fr !important; }
  .staff-grid { grid-template-columns: 1fr !important; }

  /* CONTACT */
  .contact-grid {
    grid-template-columns: 1fr !important;
    gap: 32px;
  }
  .contact-info-item {
    padding: 14px !important;
  }

  /* GENEVE */
  .info-grid {
    grid-template-columns: 1fr !important;
    gap: 14px;
  }
  .info-card { padding: 20px !important; }
  .venue-details { padding: 20px !important; }
  .venue-info-grid {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }
  .hotels-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  .map-container iframe {
    height: 280px !important;
  }

  /* GALERIE */
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
  }
  .video-cards {
    grid-template-columns: 1fr !important;
  }

  /* JEU */
  .games-grid {
    grid-template-columns: 1fr !important;
    gap: 20px;
  }
  .gh-title {
    font-size: clamp(2rem, 10vw, 3rem) !important;
    letter-spacing: 1px !important;
  }
  .gh-logo {
    width: 80px !important;
    height: 80px !important;
  }
  .how-steps {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================================
   SMALL PHONE (<= 480px)
   ============================================================ */
@media (max-width: 480px) {

  .section { padding: 32px 0; }

  /* Logo: shorter sub label on tiny screens */
  .logo-sub { display: none !important; }

  /* CLUBS: still 2-col but tighter */
  .clubs-grid { gap: 8px; }
  .club-logo {
    width: 48px !important;
    height: 48px !important;
  }

  /* PARTNERS: 2-col then could be 1 — keep 2 for density */
  .partner-card { padding: 12px !important; }
  .partner-card img { max-height: 30px !important; }

  /* Hero badge text smaller */
  .hero-badge {
    font-size: 10px !important;
    padding: 6px 12px !important;
  }

  /* Footer titles smaller */
  .footer-nav-title { font-size: 13px !important; }
  .footer-links a { font-size: 13px !important; }

  /* Stats section image — make a touch shorter on tiny screens */
  .stats-image-wrap { aspect-ratio: 16 / 10; }
}

/* ============================================================
   TABLET (768px - 1199px)
   ============================================================ */
@media (min-width: 768px) and (max-width: 1199px) {

  .container { padding: 0 28px; }

  /* CLUBS: 3-col on tablet */
  .clubs-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  /* SOCIAL stats: 2-col on small tablet, 4 on bigger */
  .social-stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  /* PARTNERS: 4-col */
  .partners-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }

  /* Hero stays full screen */
  .hero-title {
    font-size: clamp(3rem, 8vw, 5rem);
  }

  /* Champions image: tighter aspect */
  .champions-image-wrap { aspect-ratio: 16 / 10; }
  .stats-image-wrap { aspect-ratio: 19 / 10; }
}

/* ============================================================
   TOUCH DEVICES — disable hover-driven swap with tap-to-toggle
   ============================================================ */
@media (hover: none) and (pointer: coarse) {
  /* Allow tap-to-toggle via :focus on the link */
  .champions-image-wrap:active .champions-image-front,
  .stats-image-wrap:active .stats-image-front {
    opacity: 0;
    transform: scale(1.08);
  }
  .champions-image-wrap:active .champions-image-back,
  .stats-image-wrap:active .stats-image-back {
    opacity: 1;
    transform: scale(1);
  }

  /* Disable :has() driven bg zoom on touch (battery friendly) */
  .champions-section:has(.champions-image-wrap:hover) .champions-bg,
  .stats-section:has(.stats-image-wrap:hover) .stats-bg {
    transform: none;
  }
}

/* ============================================================
   LANDSCAPE PHONES — short height
   ============================================================ */
@media (max-height: 480px) and (orientation: landscape) {
  .hero-fullscreen {
    min-height: 100vh;
  }
  .hero-title {
    font-size: clamp(2rem, 8vh, 3.5rem) !important;
  }
  .hero-cta {
    flex-direction: row;
  }
  .hero-scroll { display: none; }
  .page-hero {
    min-height: auto !important;
    padding: 80px 0 30px !important;
  }
}

/* ============================================================
   PRINT — clean output
   ============================================================ */
@media print {
  .header, .footer, .hamburger, .mobile-menu, .hero-fullscreen video,
  .sponsor-carousel, .champions-bg, .champions-bg-overlay,
  .stats-bg, .stats-bg-overlay, .nav-live {
    display: none !important;
  }
  body { color: #000; background: #fff; }
  .section { padding: 20px 0; page-break-inside: avoid; }
}
