/* Mobile Enhancements - Touch-Friendly & Responsive Improvements */

/* ─────────────────────────────────────────────────────────────
   TOUCH & INTERACTION OPTIMIZATIONS
   ───────────────────────────────────────────────────────────── */

/* Touch targets: scope to interactive controls only, not all anchors.
   Inline text links and logo anchors must not be forced to 48px blocks. */
button,
input[type="submit"],
input[type="button"],
.btn,
.mob-cta,
.nav-enquire {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Better tap feedback for links and buttons */
a {
  -webkit-tap-highlight-color: rgba(26, 58, 92, 0.1);
  tap-highlight-color: rgba(26, 58, 92, 0.1);
}

button {
  -webkit-tap-highlight-color: transparent;
  tap-highlight-color: transparent;
}

/* Improve link visibility in body content */
.bh-p a, p a {
  color: var(--red, #c8102e);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  transition: color 0.25s ease, background-color 0.25s ease;
}

.bh-p a:hover, p a:hover {
  color: var(--navy, #1a3a5c);
  text-decoration-color: var(--navy, #1a3a5c);
}

.bh-p a:active, p a:active {
  background-color: rgba(200, 16, 46, 0.1);
}

/* External link indicator — scoped to body content only.
   Excludes nav, footer, buttons, and logo anchors. */
.banner-body a[target="_blank"]::after,
.welcome-text a[target="_blank"]::after,
.bh-p a[target="_blank"]::after,
p a[target="_blank"]::after {
  content: ' ↗';
  font-size: 0.9em;
  margin-left: 2px;
}

/* ─────────────────────────────────────────────────────────────
   ENHANCED MOBILE BREAKPOINTS (640px & Below)
   ───────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  /* Improved touch spacing */
  button, a.btn, .nav-enquire, .mob-cta {
    padding: 14px 20px;
    font-size: 0.9rem;
    min-height: 48px;
  }

  /* Better form field sizing */
  input, textarea, select {
    min-height: 48px;
    padding: 12px 14px;
    font-size: 16px; /* Prevents zoom on iOS */
  }

  /* Improved text readability on mobile */
  body {
    font-size: 16px;
    line-height: 1.75;
  }

  h1 {
    font-size: clamp(1.75rem, 4.5vw, 2.4rem);
    line-height: 1.2;
  }

  h2 {
    font-size: clamp(1.4rem, 3.5vw, 2rem);
    line-height: 1.3;
  }

  h3 {
    font-size: clamp(1.1rem, 2.5vw, 1.35rem);
    line-height: 1.3;
  }

  p {
    font-size: 0.95rem;
    line-height: 1.75;
  }

  /* Content links in body - enhanced mobile styling */
  .bh-p a, p a, li a {
    display: inline;
    padding: 2px 4px;
    border-radius: 2px;
  }

  /* Better container padding on small screens — defer to the --page-gutter token
     set by the 760px block below, so this never fights the central gutter system. */
  .container {
    padding-left: var(--page-gutter);
    padding-right: var(--page-gutter);
  }

  /* Section spacing is governed by site-consistency.css rhythm tokens. */

  /* Improved card spacing */
  .level-card, .bh-level-card, .bh-resource {
    padding: 24px 18px;
  }

  /* Better list rendering */
  li {
    margin-bottom: 0.75rem;
  }

  /* Sticky footer CTA on mobile */
  .sticky-mobile-cta {
    position: sticky;
    bottom: 0;
    background: var(--navy, #1a3a5c);
    padding: 12px 16px;
    text-align: center;
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
  }

  .sticky-mobile-cta a {
    color: #fff;
    font-weight: 700;
    text-decoration: none;
  }
}

/* ─────────────────────────────────────────────────────────────
   MEDIUM SCREENS (641px - 768px)
   ───────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  /* Grid optimization for medium screens */
  .bh-level-grid, .bh-resources {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* Better spacing for medium screens */
  .container {
    padding: 0 24px;
  }

  /* Mobile drawer width — matches the min(320px,90vw) value set in page HTML */
  .mob-drawer {
    width: min(320px, 90vw);
  }

  /* Better button groups on medium screens */
  .cta-actions {
    flex-direction: column;
    gap: 12px;
  }

  .cta-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ─────────────────────────────────────────────────────────────
   LANDSCAPE ORIENTATION (Mobile Landscape)
   ───────────────────────────────────────────────────────────── */

@media (max-height: 500px) and (orientation: landscape) {
  /* Section spacing stays token-based in landscape for consistent rhythm. */

  h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
  }

  h2 {
    font-size: 1.3rem;
    margin-bottom: 0.75rem;
  }

  p {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
  }
}

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE IMAGE OPTIMIZATION
   ───────────────────────────────────────────────────────────── */

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

/* Image frame wrappers: width:100% is safe; height must NOT be set to auto on
   frames using the absolute-fill pattern (position:relative + aspect-ratio drives height).
   max-height must NOT be used on these wrappers — override aspect-ratio instead. */
.img-frame,
.intro-img,
.about-split-img,
.bh-split__img {
  width: 100%;
}

@media (max-width: 640px) {
  /* Compact portrait ratio on small screens */
  .bh-split__img {
    aspect-ratio: 16 / 9 !important;
  }

  .img-strip {
    gap: 2px;
  }

  /* Wider crop for small-screen generic frames */
  .img-frame {
    aspect-ratio: 16 / 9 !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   IMPROVED FOCUS & KEYBOARD NAVIGATION
   ───────────────────────────────────────────────────────────── */

a:focus, button:focus, input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--red, #c8102e);
  outline-offset: 2px;
}

.btn:focus {
  outline: 2px solid var(--red, #c8102e);
  outline-offset: 2px;
}

/* ─────────────────────────────────────────────────────────────
   ACCESSIBLE CONTENT LINKS
   ───────────────────────────────────────────────────────────── */

/* Contextual link styling for body content */
.content-link {
  display: inline-block;
  padding: 2px 6px;
  margin: 0 2px;
  border-radius: 3px;
  color: var(--red, #c8102e);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  transition: all 0.25s ease;
}

.content-link:hover {
  background-color: rgba(200, 16, 46, 0.1);
  color: var(--navy, #1a3a5c);
  text-decoration-color: var(--navy, #1a3a5c);
}

/* Link to related pages within content */
.related-page-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  color: var(--red, #c8102e);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  transition: all 0.25s ease;
}

.related-page-link::after {
  content: '→';
  font-size: 1.1em;
  transition: transform 0.25s ease;
}

.related-page-link:hover {
  background-color: rgba(200, 16, 46, 0.08);
  gap: 10px;
}

.related-page-link:hover::after {
  transform: translateX(2px);
}

/* External link styling */
a[target="_blank"].content-link,
a[target="_blank"].related-page-link {
  position: relative;
}

a[target="_blank"].content-link::after,
a[target="_blank"].related-page-link::after {
  content: '↗';
}

/* ─────────────────────────────────────────────────────────────
   IMPROVED BUTTON SIZING & SPACING
   ───────────────────────────────────────────────────────────── */

.btn-red, .btn-navy, .btn-outline, .btn-red-solid {
  min-height: 48px;
  min-width: 120px;
  padding: 12px 24px;
}

@media (max-width: 640px) {
  .btn-red, .btn-navy, .btn-outline, .btn-red-solid {
    width: 100%;
    padding: 14px 20px;
    min-width: 100%;
  }

  .cta-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .cta-actions .btn {
    width: 100%;
  }
}

/* ─────────────────────────────────────────────────────────────
   FORM OPTIMIZATION FOR MOBILE
   ───────────────────────────────────────────────────────────── */

input[type="text"],
input[type="email"],
input[type="phone"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 1.5px solid rgba(26, 58, 92, 0.2);
  border-radius: 4px;
  transition: border-color 0.25s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--red, #c8102e);
}

/* Prevent iOS zoom on input focus */
input[type="text"],
input[type="email"],
input[type="phone"],
input[type="number"],
textarea {
  font-size: 16px;
}

/* ─────────────────────────────────────────────────────────────
   STICKY HEADER MOBILE OPTIMIZATION
   ───────────────────────────────────────────────────────────── */

/* main-nav is position:fixed in page CSS (transparent over hero, solid on scroll).
   Do not override with sticky here — it breaks the scroll-triggered transparency effect. */
.main-nav {
  z-index: 1000;
  will-change: transform;
}

@media (max-width: 640px) {
  .main-nav {
    height: auto;
    padding: 12px 0;
  }

  .nav-inner {
    height: 56px;
  }
}

/* ─────────────────────────────────────────────────────────────
   IMPROVED FOOTER ON MOBILE
   ───────────────────────────────────────────────────────────── */

/* Footer mobile layout is governed by the 760px token block below and page CSS.
   Avoid overriding at 640px to prevent conflicts with the established breakpoint system. */

/* ─────────────────────────────────────────────────────────────
   IMPROVED BREADCRUMB NAVIGATION ON MOBILE
   ───────────────────────────────────────────────────────────── */

.breadcrumb {
  font-size: 0.7rem;
  flex-wrap: wrap;
  gap: 4px;
}

@media (max-width: 480px) {
  .breadcrumb {
    font-size: 0.65rem;
  }

  .breadcrumb-sep {
    display: none;
  }

  .breadcrumb a,
  .breadcrumb span {
    display: block;
    width: 100%;
    margin-bottom: 4px;
  }
}

/* ─────────────────────────────────────────────────────────────
   ACCESSIBILITY & READABLE TEXT
   ───────────────────────────────────────────────────────────── */

/* Ensure sufficient color contrast */
.soft-text {
  color: var(--soft, #586879);
}

/* Improve readability of small text */
.small-text, small {
  font-size: 0.85rem;
  line-height: 1.6;
}

/* Better spacing for lists */
ul, ol {
  margin: 1rem 0;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.75rem;
  line-height: 1.75;
}

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE TABLE OPTIMIZATION
   ───────────────────────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

td, th {
  padding: 12px 8px;
  text-align: left;
}

@media (max-width: 640px) {
  table {
    font-size: 0.85rem;
  }

  td, th {
    padding: 10px 6px;
  }
}

/* ─────────────────────────────────────────────────────────────
   IMPROVED CTA BANDS ON MOBILE
   ───────────────────────────────────────────────────────────── */

/* .cta-band padding governed by --section-y token via global_min.css and site-consistency.css */

@media (max-width: 640px) {
  .cta-band, .cta-band-light, .bh-cta-band {
    padding: var(--section-y) 0;
  }

  .cta-band h2, .cta-band-light h2, .bh-cta-band h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
  }

  .cta-band p, .cta-band-light p, .bh-cta-band p {
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
  }

  .cta-actions {
    flex-direction: column;
    gap: 10px;
  }
}

/* ─────────────────────────────────────────────────────────────
   REDUCED MOTION SUPPORT
   ───────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   DARK MODE SUPPORT (Optional for future use)
   ───────────────────────────────────────────────────────────── */

@media (prefers-color-scheme: dark) {
  /* Add dark mode styles if needed in future */
}

/* Keep mobile page rhythm aligned with the homepage across templates. */
@media (max-width: 760px) {
  :root {
    --page-gutter: 20px;
    --section-y: 40px;
    --section-y-compact: 32px;
    --block-gap: 24px;
  }

  .container,
  .nav-inner,
  .footer-inner,
  .hero-inner {
    padding-left: var(--page-gutter) !important;
    padding-right: var(--page-gutter) !important;
  }

  .page-intro,
  .page-banner,
  .page-header,
  .bh-banner,
  .merit-banner {
    padding-top: var(--section-y-compact) !important;
    padding-bottom: var(--section-y-compact) !important;
  }

  .section,
  .bh-section,
  .faq-page,
  .fees-body,
  .form-outer,
  .section-legal,
  .school-section,
  .payment-section,
  .download-strip,
  .testimonial-band,
  .stats-strip,
  .values-strip,
  .global-band,
  .safety-band,
  .map-section,
  .newsletter-strip,
  .prog-intro,
  .prog-offers,
  .prog-resources,
  .enrol-cta,
  .cta-band,
  .cta-band-light,
  .bh-cta-band,
  .cbc-strip,
  .transport-hero,
  .transport-section,
  .legal-main,
  .blog-hero {
    padding-top: var(--section-y) !important;
    padding-bottom: var(--section-y) !important;
  }

  .section-intro,
  .section-header,
  .news-header,
  .seo-link-hub__intro {
    margin-bottom: var(--block-gap) !important;
  }

  .page-hero {
    min-height: 340px;
  }

  /* ── SCHOOL SPLIT – mobile fixes ── */
  .school-text {
    padding: var(--section-y) var(--page-gutter) !important;
    text-align: center;
  }

  /* Ensure heading is legible on the dark background */
  .school-text.bg-dark h2,
  .school-text.bg-dark h2[style] {
    color: var(--white) !important;
  }

  /* Centre the hr rule under the centred heading */
  .school-text .hr-rule {
    margin-left: auto !important;
    margin-right: auto !important;
  }

  /* Style the button to be full-width and clearly visible on dark bg */
  .school-text .btn-outline-white {
    display: block !important;
    width: 100% !important;
    text-align: center !important;
    padding: 14px 24px !important;
    border: 2px solid rgba(255, 255, 255, 0.85) !important;
    color: var(--white) !important;
    font-weight: 600 !important;
    margin-top: 1.5rem !important;
    box-sizing: border-box !important;
  }
}
