/* ==========================================================================
   SPACE 1 - MOBILE (common for every page)
   SpaceX-style mobile layout: clean transparent header with an icon-only
   menu button, full-screen heroes with the text at the bottom, bold
   uppercase headings, tall full-bleed media sections, outline buttons,
   a slide-in menu panel and a centred minimal footer.

   Load this file LAST on every page (after animations.css and any
   page-specific stylesheet) so it can override the desktop rules.
   ========================================================================== */

/* ---------- Touch devices (any width): no sticky hover effects ---------- */
@media (hover: none) {
  .card:hover,
  .tile:hover { transform: none; box-shadow: none; }
  .card:hover img,
  .tile:hover img,
  .picture:hover img { transform: none; scale: 1; }
  .next-page:hover h2,
  .menu-list a:hover b,
  .submenu a:hover { transform: none; padding-left: 0; }
  .btn:hover::after { animation: none; }
}

/* ==========================================================================
   TABLET AND PHONE  (<= 768px)
   ========================================================================== */
@media (max-width: 768px) {

  :root {
    --header-height: 64px;
    --gutter: 20px;
    --section-space: 72px;
    --text-base: 15px;
  }

  html { -webkit-text-size-adjust: 100%; }
  body { overflow-x: hidden; }
  img, video, iframe, svg { max-width: 100%; }

  /* ---------- Headings: bold, uppercase, tight (SpaceX look) ---------- */
  h1, h2 {
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.05;
  }
  h2 { font-size: clamp(26px, 7.4vw, 34px); }
  h3 { font-size: 17px; letter-spacing: 0; }

  .eyebrow {
    margin-bottom: 14px;
    font-size: 11px;
    letter-spacing: 0.2em;
  }
  .lead { font-size: 15.5px; line-height: 1.6; }
  p { font-size: 15px; }

  /* ---------- Header: transparent, logo left, icon-only menu right ---------- */
  .site-header,
  .site-header .wrap,
  .menu-top { height: var(--header-height); }

  .site-header {
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
    border-bottom: 0;
    padding-top: env(safe-area-inset-top, 0px);
  }
  .site-header.is-solid {
    background: rgba(0, 0, 0, 0.92);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
  }

  .header-logo { height: 34px; max-width: 130px; }

  .site-header .menu-button,
  #menu-open {
    width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
    border: 0;
    font-size: 0;          /* hides the "Menu" word, keeps it for screen readers */
    letter-spacing: 0;
    gap: 0;
  }
  .site-header .menu-icon { width: 24px; height: 14px; border-width: 2px; }
  .site-header .menu-icon::after { height: 2px; }

  /* ---------- Menu: dark panel sliding in from the right ---------- */
  .menu-overlay {
    left: auto;
    width: min(100%, 420px);
    background: #000;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    clip-path: none;
    transform: translateX(100%);
    transition: transform 0.45s var(--ease-out), visibility 0s 0.45s;
    box-shadow: -20px 0 60px rgba(0, 0, 0, 0.6);
  }
  .menu-overlay.is-open {
    clip-path: none;
    transform: none;
    transition: transform 0.5s var(--ease-out), visibility 0s;
  }

  .menu-top .menu-button,
  #menu-close {
    padding: 10px 4px;
    border: 0;
    font-size: 12px;
    letter-spacing: 0.18em;
  }

  .menu-list {
    grid-template-columns: 1fr;
    gap: 0;
    margin: 12px 0 48px;
  }

  .menu-list a,
  .menu-section {
    padding: 15px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }
  /* .menu-list a { justify-content: flex-end; text-align: right; } */

  .menu-list b,
  .menu-section-link b {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
  .menu-list small,
  .menu-section-link small { display: none; }

  .menu-section { flex-wrap: wrap; }
  .menu-section-link { justify-content: flex-end; text-align: right; border: 0; padding: 0; }
  .menu-section-toggle { order: -1; width: 36px; height: 36px; border: 0; }
  .menu-section-list {
    flex-basis: 100%;
    margin-top: 10px;
    padding-top: 6px;
    text-align: right;
    border-top: 0;
  }
  .menu-section-list a {
    justify-content: flex-end;
    padding: 9px 0;
    border: 0;
    font-size: 13px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
  .menu-section-list a:hover,
  .menu-section-list a[aria-current="page"] { padding-left: 0; }

  /* ---------- Hero text (media placement is in the block at the end) ---------- */
  .hero h1 {
    max-width: 14ch;
    font-size: clamp(34px, 10.4vw, 50px) !important;
    font-weight: 800 !important;
    line-height: 1.02 !important;
    letter-spacing: -0.015em !important;
    text-transform: uppercase;
  }
  .hero .eyebrow { font-size: 10.5px; line-height: 1.6; letter-spacing: 0.22em; }
  .hero .lead {
    margin: 18px 0 28px;
    max-width: 40ch;
    font-size: 15px;
    color: rgba(255, 255, 255, 0.82);
  }
  .hero-buttons {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .hero-notes,
  .scroll-cue { display: none !important; }

  /* ---------- Buttons: SpaceX outline style ---------- */
  .btn {
    min-height: 50px;
    min-width: 200px;
    justify-content: center;
    padding: 16px 28px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.16em;
    border-width: 2px;
    border-color: #fff;
    white-space: normal;
    text-align: center;
  }
  .btn-small { min-height: 44px; min-width: 0; padding: 12px 18px; }
  .text-link { font-size: 12px; letter-spacing: 0.16em; }

  /* ---------- "On this page" list: compact horizontal scroller ---------- */
 

  /* ---------- Sections ---------- */
  .section { padding-block: var(--section-space); }
  .section-head { margin-bottom: 30px; }
  .section-head .lead { margin-top: 14px; }

  /* Split blocks stack, picture full-bleed on top */
  .split,
  .split.no-image,
  .quote-layout { grid-template-columns: 1fr !important; gap: 28px; }
  .split.is-flipped .split-copy { order: 0; }
  .split-copy h2 { margin-bottom: 16px; }
  .picture { margin-inline: calc(var(--gutter) * -1); border-radius: 0; border-inline: 0; }
  .picture img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; }

  /* ---------- Grids collapse to one column ---------- */
  .card-grid { --columns: 1 !important; gap: 14px; }
  .tile-grid,
  .steps,
  .modules,
  .course-explorer,
  .footer-columns { grid-template-columns: 1fr !important; }
  .mosaic { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

  .card,
  .tile { border-radius: 6px; }
  .card { padding: 22px; }

  /* ---------- Tabs / pills: horizontal swipe instead of wrapping ---------- */
  .pill-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }
  .pill-row::-webkit-scrollbar { display: none; }
  .pill-row > * { flex: none; scroll-snap-align: start; }
  .panel-box { border-radius: 14px; padding: 16px; }

  /* ---------- Forms: 16px text stops iOS zoom, bigger tap targets ---------- */
  input,
  select,
  textarea { font-size: 16px !important; }
  input:not([type="checkbox"]):not([type="radio"]),
  select { min-height: 50px; }
  .form { grid-template-columns: 1fr; gap: 16px; }
  .form .btn,
  form button[type="submit"] { width: 100%; }

  /* ---------- Next page link ---------- */
  .next-page { padding-block: 56px; }
  .next-page h2 { font-size: clamp(26px, 8vw, 36px); }

  /* ---------- Footer: centred and minimal ---------- */
  .site-footer {
    padding-block: 48px calc(32px + env(safe-area-inset-bottom, 0px));
    background: #000;
    text-align: center;
  }
  .footer-columns { gap: 28px; justify-items: center; }
  .footer-columns .logo { justify-content: center; }
  .footer-columns p { margin-inline: auto; }
  .footer-links {
    columns: auto !important;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 18px;
  }
  .footer-links li { margin: 0; }
  .footer-links a {
    display: inline-block;
    padding: 6px 0;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
  }
  .footer-note { margin-top: 28px; font-size: 10.5px; line-height: 1.7; }

  /* ---------- Marquee ---------- */
  .marquee { padding-block: 10px; }
  .marquee span { min-height: 34px; padding: 8px 14px; font-size: 12px; }

  /* ---------- Legal pages ---------- */
  .legal-orbit { display: none; }

  /* ---------- Tables never break the page ---------- */
  table { display: block; max-width: 100%; overflow-x: auto; }
}

/* ==========================================================================
   SMALL PHONES  (<= 420px)
   ========================================================================== */
@media (max-width: 420px) {
  :root { --gutter: 18px; --section-space: 60px; }

  .hero h1 { font-size: clamp(30px, 10vw, 42px) !important; }
  .hero-buttons .btn { width: 100%; }
  h2 { font-size: clamp(24px, 7.6vw, 30px); }
  .mosaic { grid-template-columns: 1fr 1fr; }
  .course-facts { grid-template-columns: 1fr 1fr; }
}

/* ==========================================================================
   PHONE IN LANDSCAPE: don't force full-height heroes
   ========================================================================== */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
  .hero .wrap { padding-bottom: 32px; }
}

@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
  .menu-overlay,
  .menu-overlay.is-open { transition: none; }
  .scroll-cue { animation: none; }
}

/* ==========================================================================
   MOBILE: BACKGROUND VIDEO / IMAGE ON TOP, CONTENT BELOW
   On desktop the video or image sits behind the text. On phones it is
   pulled out of the background and shown as a full-width block at the top
   of its section, and the text follows underneath it. Works on every page:
   heroes, every "*-video-bg" section and image tiles that carry text.
   ========================================================================== */
@media (max-width: 768px) {

  /* 1. The section stacks: media first, then content */
  .hero,
  section:has(> [class*="-video-bg"]) {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    min-height: 0 !important;
    height: auto !important;
    padding-top: 0 !important;
    background: var(--color-bg);
  }
  /* Hero: video starts at the very top, the header floats over it */
  .hero { padding-top: 0 !important; background: #000; }
  .site-header { position: fixed; top: 0; left: 0; right: 0; z-index: 50; }

  /* 2. The media block itself: in normal flow, full width, fixed ratio */
  .hero > .hero-media,
  section > [class*="-video-bg"] {
    order: -1;
    position: relative !important;
    inset: auto !important;
    z-index: 0 !important;
    flex: none;
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 16 / 9;
    margin: 0 !important;
    overflow: hidden;
    transform: none !important;   /* stops the desktop parallax shift */
    opacity: 1 !important;
  }
  .hero > .hero-media { aspect-ratio: 4 / 3; }

  .hero > .hero-media > video,
  .hero > .hero-media > img,
  section > [class*="-video-bg"] > video,
  section > [class*="-video-bg"] > img {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none;
    object-fit: cover;
    object-position: center;
    transform: none !important;
  }

  /* 3. Remove the dark overlays that were only needed for text-on-video */
  section > [class*="-video-overlay"] { display: none !important; }
  .hero::after,
  .hero::before,
  section:has(> [class*="-video-bg"])::before,
  section:has(> [class*="-video-bg"])::after { display: none !important; }

  /* 4. Content below the media */
  .hero > .wrap,
  section:has(> [class*="-video-bg"]) > .wrap {
    position: relative;
    z-index: 1;
    width: 100%;
    margin-top: 0 !important;
    padding-top: 36px !important;
  }
  .hero > .wrap { padding-bottom: 48px !important; }

  /* 5. Image / video tiles that carry text: picture on top, text below */
  .tile:has(.tile-body) {
    flex-direction: column;
    align-items: stretch;
    min-height: 0;
    background: var(--color-panel-raised);
  }
  .tile:has(.tile-body)::after { display: none; }
  .tile:has(.tile-body) > .tile-video-bg {
    position: relative !important;
    inset: auto !important;
    z-index: 0;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
  }
  .tile:has(.tile-body) > .tile-video-bg > video,
  .tile:has(.tile-body) > .tile-video-bg > img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
  }
  .tile:has(.tile-body) > img { position: relative; z-index: 0; height: auto; aspect-ratio: 16 / 9; }
  .tile:has(.tile-body) .tile-body { padding: 20px; }
}