/* ═══════════════════════════════════════════════════
   RESPONSIVE STYLES — Oxford English Boarding School
   Mobile-first comprehensive overhaul
   Breakpoints: 1200, 1024, 768, 480, 360
   ═══════════════════════════════════════════════════ */

/* ─── Global mobile resets ──────────────────────── */
* { -webkit-tap-highlight-color: transparent; }

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

body { overflow-x: hidden; }

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

/* Fix horizontal overflow everywhere */
.container, .container-sm {
  width: 100%;
  box-sizing: border-box;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

/* ─── 1200px — Large laptops ────────────────────── */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 20px; }
  .footer-grid { grid-template-columns: 1.5fr 1fr 1fr; }
  .footer-grid > div:last-child { grid-column: 1 / -1; }
}

/* ─── 1024px — Tablets landscape / small laptop ── */
@media (max-width: 1024px) {
  :root { --nav-height: 68px; }

  .section   { padding: 72px 0; }
  .section-sm{ padding: 48px 0; }

  .grid-2 { gap: 32px; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); gap: 24px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 20px; }

  /* Hero */
  .hero-stats   { gap: 32px; }
  .hero-stat-val{ font-size: 1.8rem; }

  /* About dark section grid */
  #about-preview .grid-2 { gap: 40px; }

  /* Footer */
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 32px; }

  /* Academics exam system */
  #exam-system .grid-2 { grid-template-columns: 1fr; gap: 32px; }

  /* Contact */
  #contact-info .grid-4 { grid-template-columns: repeat(2, 1fr); }

  /* Facilities featured card */
  #facilities-main .reveal:first-of-type > div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

/* ─── 768px — Tablets portrait & large mobiles ─── */
@media (max-width: 768px) {
  :root { --nav-height: 64px; }

  /* ── Typography ── */
  h1 { font-size: clamp(1.7rem, 6vw, 2.4rem); }
  h2 { font-size: clamp(1.4rem, 5vw, 2rem); }
  h3 { font-size: clamp(1.1rem, 4vw, 1.4rem); }

  .section    { padding: 56px 0; }
  .section-sm { padding: 40px 0; }

  /* ── Grids → single column ── */
  .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 16px; }
  .grid-4 { grid-template-columns: 1fr 1fr; gap: 14px; }

  /* ── Navbar ── */
  .nav-links { display: none; }
  .btn-admin { display: none; }
  .nav-toggle { display: flex; }

  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: var(--nav-height);
    left: 0; right: 0; bottom: 0;
    background: #fff;
    padding: 16px;
    gap: 4px;
    overflow-y: auto;
    z-index: 999;
    box-shadow: var(--shadow-xl);
  }

  .nav-links.open .nav-link {
    padding: 14px 16px;
    font-size: 1rem;
    border-radius: var(--radius-sm);
    border-bottom: 1px solid var(--border);
  }

  .nav-links.open::after {
    content: '';
    display: block;
    padding: 8px;
  }

  /* Mobile admin button inside menu */
  .nav-links.open .btn-admin-mobile {
    display: flex !important;
    margin-top: 8px;
    justify-content: center;
    padding: 13px;
    font-size: 0.95rem;
  }

  /* ── Hero ── */
  .hero { min-height: 90vh; padding-top: var(--nav-height); }

  .hero-content { max-width: 100%; }

  .hero-tag  { font-size: .72rem; padding: 5px 12px; }
  .hero-title { font-size: clamp(1.6rem, 7vw, 2.4rem); margin-bottom: 14px; }
  .hero-desc  { font-size: .95rem; margin-bottom: 24px; }

  .hero-actions { gap: 12px; }
  .hero-actions .btn { padding: 12px 20px; font-size: .875rem; width: 100%; justify-content: center; }

  .hero-stats {
    gap: 20px;
    margin-top: 32px;
    padding-top: 28px;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .hero-stat-val   { font-size: 1.6rem; }
  .hero-stat-label { font-size: .7rem; }

  /* ── Info cards ── */
  .info-card { padding: 24px 16px; }
  .info-val  { font-size: 1.8rem; }

  /* ── Section headings ── */
  .section-sub { font-size: .95rem; }
  .divider-gold { margin: 14px auto 24px; }

  /* ── About dark section ── */
  #about-preview .grid-2 { gap: 0; }
  #about-preview .reveal-right { order: -1 !important; }
  #about-preview .reveal-right img { height: 260px !important; }
  #about-preview .reveal-right > div[style*="position:absolute"] { display: none; }
  #about-preview .reveal-left { padding: 0 16px; }

  /* ── Class tabs ── */
  .class-tabs {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
    padding-bottom: 4px;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .class-tabs::-webkit-scrollbar { display: none; }
  .class-tab { flex-shrink: 0; white-space: nowrap; }

  /* ── News cards ── */
  .grid-3 .news-card { max-width: 100%; }
  .news-card-img { height: 160px; }

  /* ── Leaderboard ── */
  .podium { gap: 8px; }
  .podium-block.gold   { height: 70px; width: 80px; font-size: 1.2rem; }
  .podium-block.silver { height: 52px; width: 80px; font-size: 1.2rem; }
  .podium-block.bronze { height: 38px; width: 80px; font-size: 1.2rem; }
  .podium-avatar { width: 52px; height: 52px; font-size: 1.1rem; }
  .podium-name { font-size: .78rem; max-width: 80px; }

  /* Leaderboard table — scroll horizontally */
  .lb-table { font-size: .78rem; min-width: 520px; }
  .lb-table th, .lb-table td { padding: 10px 10px; }

  /* Show last column (subjects) only on wide */
  .lb-table th:last-child,
  .lb-table td:last-child { display: none; }

  /* ── English policy section ── */
  #english-policy > .container > div:first-child { flex-direction: column; gap: 20px; }

  /* ── Page banner ── */
  .page-banner { padding: calc(var(--nav-height) + 40px) 0 48px; }
  .page-banner h1 { font-size: clamp(1.5rem, 6vw, 2rem); }
  .page-banner p  { font-size: .9rem; }

  /* ── Footer ── */
  .footer { padding: 48px 0 0; }
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
  .footer-logo-name { font-size: .9rem; }
  .footer-desc { font-size: .825rem; }

  /* ── Buttons ── */
  .btn-lg { padding: 13px 24px; font-size: .95rem; }

  /* ── Contact ── */
  #contact-info .grid-4 { grid-template-columns: 1fr 1fr; }
  #main-contact-area .grid-2 { grid-template-columns: 1fr; }
  .map-container { height: 260px; }

  /* ── About page grids ── */
  #mission .grid-2 { grid-template-columns: 1fr; }
  #english-policy .grid-2 { grid-template-columns: 1fr; }
  #english-policy .reveal-right { order: -1; }

  /* ── Facilities ── */
  #facilities-main > .container > .reveal > div { display: block !important; }
  #facilities-main > .container > .reveal > div > div:last-child { margin-top: 32px; padding: 32px 24px; }

  /* ── Daily schedule ── */
  #daily-schedule > .container > div:last-child { max-width: 100%; }

  /* ── Stats infographic ── */
  #stats .grid-4 { grid-template-columns: 1fr 1fr; gap: 28px; }

  /* ── Academics ── */
  #curriculum-overview > .container > div[style*="grid-template-columns:1fr 1fr"] {
    display: block !important;
  }
  #curriculum-overview > .container > div > div { margin-bottom: 24px; }
  #class1 .grid-3 { grid-template-columns: 1fr; }
  #exam-system .grid-2 { grid-template-columns: 1fr; }

  /* ── Modal ── */
  .modal { border-radius: var(--radius-md); }
  .modal-header { padding: 18px 20px; }
  .modal-body   { padding: 18px 20px; }
  .modal-title  { font-size: 1.1rem; }
}

/* ─── 480px — Phones ────────────────────────────── */
@media (max-width: 480px) {
  :root { --nav-height: 60px; }

  .container { padding: 0 14px; }

  /* ── Local nav logo ── */
  .logo-name { font-size: .9rem; }
  .logo-sub  { font-size: .55rem; }
  .nav-logo img { width: 38px; height: 38px; }

  /* ── Hero ── */
  .hero-title { font-size: 1.55rem; }
  .hero-desc  { font-size: .875rem; }
  .hero-stats { grid-template-columns: 1fr 1fr; gap: 12px; }
  .hero-stat-val { font-size: 1.4rem; }

  /* ── Grids ── */
  .grid-4 { grid-template-columns: 1fr; }

  /* ── Info cards ── */
  .info-card { padding: 20px 14px; }
  .info-icon { width: 52px; height: 52px; font-size: 22px; }
  .info-val  { font-size: 1.6rem; }

  /* ── Section headings ── */
  .section-tag { font-size: .68rem; padding: 5px 12px; }

  /* ── Cards ── */
  .card-body { padding: 18px; }

  /* ── Buttons ── */
  .btn { padding: 11px 20px; font-size: .85rem; }
  .btn-lg { padding: 12px 20px; font-size: .9rem; }

  /* ── CTA sections ── */
  .hero-actions { flex-direction: column; gap: 10px; }
  .hero-actions .btn { width: 100%; }

  /* ── News ── */
  .news-card-body { padding: 18px; }
  .news-card-title { font-size: 1rem; }

  /* ── Contact ── */
  #contact-info .grid-4 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr !important; gap: 0; }
  .form-row > div { margin-bottom: 16px; }

  /* ── Academics ── */
  .class-tab { padding: 8px 12px; font-size: .78rem; }
  #exam-system table { font-size: .8rem; }
  #exam-system td, #exam-system th { padding: 8px 10px !important; }

  /* ── Leaderboard ── */
  .podium { gap: 4px; }
  .podium-block.gold   { width: 72px; height: 64px; }
  .podium-block.silver { width: 72px; height: 48px; }
  .podium-block.bronze { width: 72px; height: 36px; }
  .podium-avatar { width: 46px; height: 46px; font-size: 1rem; }
  .podium-name   { font-size: .72rem; max-width: 72px; }
  .podium-pct    { font-size: .68rem; }

  /* ── Facilities daily schedule ── */
  #daily-schedule > .container > div:last-child { padding: 0 8px; }

  /* ── Footer ── */
  .footer { padding: 36px 0 0; }
  .footer-links a { font-size: .825rem; }
  .footer-contact-item { font-size: .825rem; }
  .footer-bottom { font-size: .75rem; padding: 18px 0; }

  /* ── Principal message ── */
  blockquote { font-size: 1.05rem !important; }

  /* ── Stats sections ── */
  #stats .grid-4 { grid-template-columns: 1fr 1fr; }

  /* ── Marquee ── */  
  [style*="marqueeScroll"] { font-size: .78rem; }
}

/* ─── 360px — Very small phones ────────────────── */
@media (max-width: 360px) {
  .container { padding: 0 12px; }

  .hero-title { font-size: 1.35rem; }
  .hero-actions .btn { font-size: .82rem; padding: 10px 16px; }

  .logo-name { display: none; }

  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.1rem; }

  .info-val { font-size: 1.4rem; }
  .hero-stat-val { font-size: 1.2rem; }
}

/* ─── Landscape phone fix ───────────────────────── */
@media (max-width: 768px) and (orientation: landscape) {
  .hero { min-height: 100svh; }
  .hero-stats { grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .hero-title { font-size: 1.4rem; }
  .hero-desc  { font-size: .85rem; margin-bottom: 16px; }
}

/* ─── Touch optimizations ───────────────────────── */
@media (hover: none) and (pointer: coarse) {
  /* Larger tap targets */
  .nav-link { padding: 12px 14px; min-height: 44px; display: flex; align-items: center; }
  .btn      { min-height: 44px; }
  .class-tab{ min-height: 40px; }
  .footer-links a { padding: 6px 0; display: inline-block; min-height: 36px; }

  /* Remove hover effects that don't work on touch */
  .card:hover,
  .info-card:hover,
  .news-card:hover,
  .hover-lift:hover { transform: none; box-shadow: var(--shadow-sm); }

  /* Feature items hover */
  .feature-item:hover { background: transparent; }
}

/* ─── Safe area insets (iPhone notch) ───────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .footer-bottom {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .nav-links.open {
    padding-bottom: env(safe-area-inset-bottom);
  }
}
