/* =====================================================================
   SSO Academy — Mobile Responsive Layer
   Loaded LAST on every page (after academy.css, public-shell.css, lesson-player.css).
   Implements the 12 Mobile Laws + 25 rules from sso-mobile-excellence.
   Targets: iPhone SE (375px), iPhone 14/15 (390-393px), Pixel/Galaxy (360-412px).
   ===================================================================== */

/* ===== UNIVERSAL MOBILE FOUNDATIONS ===== */

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

body {
  /* Prevent horizontal scroll across the whole app — Mobile Law: no horizontal scroll ever. */
  overflow-x: hidden;
}

/* Lock background scroll when a mobile nav drawer is open. */
body.nav-locked { overflow: hidden; }

/* Safe-area-aware fixed elements (notched iPhones). */
@supports(padding: max(0px)) {
  .public-shell .sticky-mobile-cta { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}

/* Native input zoom-on-focus prevention — iOS Safari zooms any input < 16px font-size.
   This is a Mobile Law 9 violation; fix it globally. */
@media (max-width: 900px) {
  input, select, textarea, button {
    font-size: 16px !important;
  }
  .form-input,
  .public-page .enrol-discount {
    font-size: 16px !important;
  }
}

/* ===================================================================
   PUBLIC HEADER — the broken header from the screenshot.
   Show hamburger + drawer below 768px. Hide nav-toggle on desktop.
   =================================================================== */

.public-nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid #e8eef3;
  border-radius: 8px;
  width: 44px;
  height: 44px;
  padding: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
}
.public-nav-toggle-bar {
  display: block;
  width: 20px;
  height: 2px;
  background: #0c3455;
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.public-nav-toggle[aria-expanded="true"] .public-nav-toggle-bar:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.public-nav-toggle[aria-expanded="true"] .public-nav-toggle-bar:nth-child(2) {
  opacity: 0;
}
.public-nav-toggle[aria-expanded="true"] .public-nav-toggle-bar:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* Cap logo image height responsively (the original had height:48px which was too big on 375px). */
.public-logo-img {
  height: 40px;
  width: auto;
  display: block;
  max-width: 100%;
}

/* === Header layout overrides at the mobile breakpoint === */
@media (max-width: 768px) {
  /* The header was overflowing because logo+nav had no responsive layout.
     Reset the padding, shrink the logo, and convert nav to a drawer. */
  .public-header,
  .public-shell .public-header {
    padding: 12px 18px !important;
    padding-left: max(18px, env(safe-area-inset-left)) !important;
    padding-right: max(18px, env(safe-area-inset-right)) !important;
    gap: 12px;
    min-height: 64px;
  }

  .public-logo-img { height: 36px; }

  .public-nav-toggle { display: inline-flex; }

  /* Slide-down drawer — replaces the cramped inline nav.
     Use visibility + opacity (not just transform) so a short drawer
     cannot leak its bottom edge into the viewport. */
  .public-nav,
  .public-shell .public-nav {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    background: #ffffff;
    border-bottom: 1px solid #e8eef3;
    box-shadow: 0 16px 40px -16px rgba(12, 52, 85, 0.18);
    flex-direction: column;
    align-items: stretch;
    gap: 0 !important;
    padding: 12px 18px max(20px, env(safe-area-inset-bottom));
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-12px);
    transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 0.25s;
    z-index: 99;
    max-height: calc(100dvh - 64px);
    overflow-y: auto;
  }
  .public-nav.is-open,
  .public-shell .public-nav.is-open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
    transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 0s;
  }
  .public-nav a,
  .public-shell .public-nav a {
    display: block;
    padding: 14px 6px;
    font-size: 1rem !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
    border-bottom: 1px solid #f1f4f7;
    min-height: 48px;
    line-height: 1.4;
  }
  .public-nav a:last-child { border-bottom: none; }
  .public-shell .public-nav a.btn,
  .public-page .public-nav a.btn {
    text-align: center;
    padding: 14px 18px;
    margin-top: 8px;
    border-radius: 10px;
  }
}

/* ===================================================================
   APP MOBILE BAR — for logged-in users (was previously zero nav on mobile).
   Hidden on desktop, shown on mobile. Triggers slide-in sidebar drawer.
   =================================================================== */

.app-mobile-bar {
  display: none;
}
.app-sidebar-overlay {
  display: none;
}

@media (max-width: 768px) {
  .app-mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 90;
    background: #0c3455;
    color: #fff;
    padding: 12px 18px;
    padding-left: max(18px, env(safe-area-inset-left));
    padding-right: max(18px, env(safe-area-inset-right));
    min-height: 56px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }
  .app-mobile-logo {
    color: #fff;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.18em;
  }
  .app-mobile-toggle {
    width: 44px;
    height: 44px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
  }
  .app-mobile-toggle-bar {
    display: block;
    width: 20px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
  }
  .app-mobile-toggle[aria-expanded="true"] .app-mobile-toggle-bar:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }
  .app-mobile-toggle[aria-expanded="true"] .app-mobile-toggle-bar:nth-child(2) {
    opacity: 0;
  }
  .app-mobile-toggle[aria-expanded="true"] .app-mobile-toggle-bar:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }

  /* Drawer takeover: show the sidebar as a slide-in panel on mobile. */
  .app-shell .sidebar,
  .sidebar#app-sidebar {
    display: flex !important;
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(82vw, 320px);
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 1000;
    overflow-y: auto;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.25);
  }
  .sidebar#app-sidebar.is-open { transform: translateX(0); }

  .app-sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 999;
  }
  .app-sidebar-overlay.is-open {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  /* Stop main-content getting hidden behind the sticky bar. */
  .main-content {
    margin-left: 0 !important;
    width: 100%;
  }

  /* Sidebar nav items need bigger touch targets when in drawer mode. */
  .sidebar .nav-item {
    padding: 14px 18px !important;
    font-size: 0.95rem !important;
    min-height: 48px;
  }
}

/* ===================================================================
   FORMS — Mobile Law 9 (native inputs), Law 4 (44px touch targets),
   Law 5 (keyboard eats half the screen).
   =================================================================== */

@media (max-width: 900px) {
  .form-input {
    padding: 14px 16px !important;
    min-height: 48px;
    border-radius: 10px;
  }
  .form-group { margin-bottom: 18px !important; }
  .login-wrap { padding: 24px 18px !important; padding-top: max(40px, env(safe-area-inset-top)) !important; padding-bottom: max(40px, env(safe-area-inset-bottom)) !important; min-height: 100dvh; }
  .login-card { padding: 28px 22px !important; box-shadow: 0 8px 32px -8px rgba(12, 52, 85, 0.12); border-radius: 14px; }
  .login-card .logo-area img { height: 44px !important; }

  /* Enrol form on course-detail and hero CTAs — stack inputs and CTA vertically below 600px. */
  .public-page .enrol-form {
    flex-direction: column;
    align-items: stretch;
    max-width: 100%;
  }
  .public-page .enrol-form .btn,
  .public-page .enrol-form button {
    width: 100%;
    min-height: 52px;
    justify-content: center;
  }
  .public-page .enrol-discount {
    padding: 14px 16px;
    min-height: 48px;
    font-size: 16px;
  }

  /* All-Access "Start Monthly / Start Annual" buttons — full-width on mobile. */
  .public-page .all-access-card form button { width: 100%; min-height: 52px; }
  .public-page .all-access-card form { width: 100%; }
}

/* Buttons in general — enforce 44px minimum height on mobile. */
@media (max-width: 768px) {
  .btn,
  .btn-primary,
  .btn-ghost,
  .public-page .btn-primary,
  .public-page .btn-ghost {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .public-page .btn-lg { padding: 16px 24px; font-size: 0.95rem; }
}

/* ===================================================================
   HERO + SECTION RESPONSIVE TIGHTENING
   The existing @media (max-width: 900px) is too wide for the smallest phones.
   Add tighter rules for <=480px.
   =================================================================== */

@media (max-width: 600px) {
  .public-page .hero-public,
  .public-shell .hero-public {
    padding: 56px 20px 48px !important;
  }
  .public-page .hero-public.small { padding: 48px 20px 40px !important; }
  .public-page .hero-public h1 { font-size: clamp(1.6rem, 7vw, 2.1rem); line-height: 1.18; }
  .public-page .hero-public p,
  .public-page .hero-public .hero-subtitle { font-size: 1rem; line-height: 1.5; margin-bottom: 28px; }
  .public-page .section { padding: 48px 20px !important; }
  .public-page .section h2 { font-size: clamp(1.45rem, 6vw, 1.9rem); line-height: 1.2; }
  .public-page .section-intro { font-size: 1rem; }

  /* Course hero giant number — collapse on tiny screens, it overflows. */
  .public-page .hero-course-num { font-size: 5.5rem; margin-bottom: 4px; }

  /* The hero meta row (Hosted by X · 6 modules · Self-paced) was too tightly spaced. */
  .public-page .hero-meta-row { font-size: 0.65rem; gap: 12px; margin-bottom: 24px; }
}

/* ===================================================================
   COURSE CARDS / GRIDS — single column on phone, no horizontal scroll
   =================================================================== */

@media (max-width: 600px) {
  .public-page .course-grid {
    grid-template-columns: 1fr !important;
    gap: 14px;
  }
  .public-page .course-card-header { padding: 26px 22px 22px; }
  .public-page .course-card-num { font-size: 2.2rem; }
  .public-page .course-card-title { font-size: 1.15rem; }
  .public-page .course-card-body { padding: 18px 22px 22px; }
}

/* ===================================================================
   ALL-ACCESS CARD — pricing grid stacks, buttons full-width
   =================================================================== */

@media (max-width: 600px) {
  .public-page .all-access-card,
  .public-page .bundle-banner {
    padding: 32px 22px 28px !important;
    grid-template-columns: 1fr !important;
    gap: 18px;
    border-radius: 14px;
  }
  .public-page .all-access-grid { grid-template-columns: 1fr; gap: 20px; }
  .public-page .all-access-price { font-size: 2.4rem; }
}

/* ===================================================================
   FOUNDER LETTER / LANDING — fix the rotated paper letter on phones
   =================================================================== */

@media (max-width: 600px) {
  .founder-letter-grid { gap: 28px !important; }
  .founder-letter-grid .ol-paper p { font-size: 19px !important; line-height: 1.45 !important; }
  .founder-letter-grid .ol-paper { padding: 22px 22px 20px !important; }
}

/* ===================================================================
   SALES PAGE FRAGMENT (sp-*) — already handles 900px but needs <600px polish
   =================================================================== */

@media (max-width: 600px) {
  .public-page .sp-stack-section,
  .public-page .sp-shift-section,
  .public-page .sp-outcomes-section,
  .public-page .sp-who-section,
  .public-page .sp-host-section { padding: 48px 20px !important; }

  .public-page .sp-stack { grid-template-columns: 1fr !important; gap: 12px; }
  .public-page .sp-stack-item { grid-template-columns: 40px 1fr !important; padding: 20px 18px !important; gap: 14px; }
  .public-page .sp-stack-num { font-size: 1.7rem !important; }
  .public-page .sp-who-card { padding: 22px 20px 20px !important; }
  .public-page .sp-lead { font-size: 1rem; }
  .public-page .final-cta-section { padding: 56px 20px !important; }
}

/* ===================================================================
   HONEST GATE MODAL — must scroll inside viewport on small phones
   =================================================================== */

@media (max-width: 600px) {
  #honest-gate {
    align-items: flex-start !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    padding: 12px !important;
  }
  #honest-gate > div {
    max-width: 100% !important;
    padding: 28px 22px 26px !important;
    margin: 24px auto !important;
    max-height: none !important;
  }
  #honest-gate h2 { font-size: 1.25rem !important; line-height: 1.25; }
  #honest-gate label span { font-size: 0.95rem !important; }
  #honest-gate .hg-check { transform: scale(1.3) !important; margin-right: 4px; }
  #honest-gate button { min-height: 48px; }
}

/* ===================================================================
   STICKY MOBILE CTA — already declared but tighten a few values
   =================================================================== */

@media (max-width: 600px) {
  .public-page .sticky-mobile-cta {
    padding: 10px 14px !important;
    padding-bottom: max(10px, env(safe-area-inset-bottom)) !important;
    gap: 10px;
  }
  .public-page .sticky-mobile-cta .smc-label { font-size: 0.58rem; }
  .public-page .sticky-mobile-cta .smc-amount { font-size: 1rem; }
  .public-page .sticky-mobile-cta .smc-btn { padding: 12px 18px; font-size: 0.78rem; min-height: 48px; }
}

/* ===================================================================
   FOOTER — already collapses well but tighten padding on smallest screens
   =================================================================== */

@media (max-width: 480px) {
  .public-page .site-footer .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 28px;
  }
  .public-page .site-footer .footer-logo img { height: 52px; }
}

/* ===================================================================
   LESSON PLAYER — full mobile reflow.
   =================================================================== */

@media (max-width: 900px) {
  .lesson-shell-page .lp-lesson-num,
  .lesson-shell-page [class*="lp-num-"],
  .lesson-shell-page .lp-cover-num { font-size: clamp(4rem, 18vw, 7rem) !important; line-height: 0.9 !important; }
  .lesson-shell-page h1,
  .lesson-shell-page .lp-title { font-size: clamp(1.5rem, 6vw, 2rem) !important; line-height: 1.2 !important; }
  .lesson-shell-page h2 { font-size: clamp(1.25rem, 5vw, 1.6rem) !important; line-height: 1.25 !important; }
  .lesson-shell-page h3 { font-size: 1.05rem !important; }
  .lesson-shell-page p, .lesson-shell-page li { font-size: 1rem !important; line-height: 1.6 !important; }

  .lesson-shell-page iframe,
  .lesson-shell-page video,
  .lesson-shell-page .lp-video,
  .lesson-shell-page .lp-embed {
    width: 100% !important;
    height: auto !important;
    max-width: 100%;
    aspect-ratio: 16 / 9;
  }
  .lesson-shell-page img { max-width: 100%; height: auto; }
}

@media (max-width: 768px) {
  .lesson-shell-page,
  .lesson-shell-page .lp-shell,
  .lesson-shell-page .lp-grid,
  .lesson-shell-page .lp-layout {
    grid-template-columns: 1fr !important;
    display: block !important;
  }
  .lesson-shell-page .lp-sidebar,
  .lesson-shell-page .lp-curriculum {
    width: 100% !important;
    position: static !important;
    border-left: none !important;
    border-top: 1px solid #e8eef3;
  }
  .lesson-shell-page .lp-content,
  .lesson-shell-page .lesson-content {
    padding: 24px 18px 32px !important;
  }
  .lesson-shell-page .lp-nav,
  .lesson-shell-page .lp-prev-next {
    flex-direction: column;
    gap: 10px;
  }
  .lesson-shell-page .lp-nav a,
  .lesson-shell-page .lp-prev-next a {
    width: 100%;
    min-height: 48px;
    text-align: center;
  }
}

/* ===================================================================
   CALCULATOR / LEAD MAGNET — iframe sizing on mobile
   =================================================================== */

@media (max-width: 768px) {
  .public-page .calculator-shell {
    margin-top: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow: none;
  }
  .public-page .calculator-iframe {
    min-height: 600px;
  }
}

/* ===================================================================
   DASHBOARD / ACCOUNT / PURCHASES
   =================================================================== */

@media (max-width: 768px) {
  .content-area {
    padding: 20px 18px !important;
    padding-left: max(18px, env(safe-area-inset-left)) !important;
    padding-right: max(18px, env(safe-area-inset-right)) !important;
  }
  .main-content table,
  .content-area table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }
  .dashboard-grid,
  .courses-grid,
  .my-courses-grid {
    grid-template-columns: 1fr !important;
    gap: 14px;
  }
  .card, .course-tile, .my-course-card {
    padding: 20px 18px !important;
  }
}

/* ===================================================================
   CHECKOUT SUCCESS / CANCEL
   =================================================================== */

@media (max-width: 600px) {
  .checkout-success,
  .checkout-cancel {
    padding: 32px 20px !important;
  }
}

/* ===================================================================
   REVIEWS MARQUEE
   =================================================================== */

@media (max-width: 480px) {
  .rm-card { width: 280px !important; padding: 16px 18px !important; }
  .rm-quote { font-size: 0.86rem !important; }
}

/* ===================================================================
   FAQ details
   =================================================================== */

@media (max-width: 600px) {
  details summary {
    padding: 14px 32px 14px 0 !important;
    min-height: 48px;
    font-size: 0.95rem !important;
    line-height: 1.4 !important;
  }
}

/* ===================================================================
   GLOBAL ACCESSIBILITY — respect reduced motion
   =================================================================== */

@media (prefers-reduced-motion: reduce) {
  .public-nav,
  .sidebar#app-sidebar,
  .app-sidebar-overlay,
  .public-nav-toggle-bar,
  .app-mobile-toggle-bar { transition: none !important; }
}

/* ===================================================================
   PRINT — hide mobile UI bits when printing
   =================================================================== */

@media print {
  .public-nav-toggle,
  .app-mobile-bar,
  .app-sidebar-overlay,
  .sticky-mobile-cta { display: none !important; }
}
