/* ==========================================================================
   TIIT — shared mobile-first responsive + performance layer
   Loaded LAST on every page (after each page's own <style>), so these rules
   win ties without needing !important. Nothing here removes an animation —
   it only fixes layout on small/medium screens and swaps a few very costly
   GPU effects for visually identical cheaper ones on phones.
   ========================================================================== */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
a,
button,
[role="button"],
.course-card,
.stagger-card {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
img,
svg,
video,
iframe {
  max-width: 100%;
}

/* Keyboard focus that is actually visible */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--blue, #3a86ff);
  outline-offset: 2px;
}

/* Sticky sidebars: once they stop being sticky on narrow screens the old
   `top:100px` kept shifting them 100px down on top of the next section. */
@media (max-width: 980px) {
  .course-side,
  .course-tabs-side,
  .faq-cta {
    top: auto !important;
  }
}

/* --------------------------------------------------------------------------
   Navigation: switch to the burger menu below 1100px (the full link row
   used to squash into 2-line labels on tablets and small laptops).
   The panel now animates open/closed instead of popping.
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .nav-inner {
    padding: 10px 16px;
    gap: 12px;
  }
  .nav-links {
    position: absolute;
    top: calc(100% + 8px);
    left: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.98);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    border: 1px solid var(--line, rgba(41, 54, 129, 0.12));
    border-bottom: 1px solid var(--line, rgba(41, 54, 129, 0.12));
    border-radius: 20px;
    box-shadow: 0 24px 50px -20px rgba(23, 27, 46, 0.35);
    max-height: calc(100vh - 96px);
    max-height: calc(100dvh - 96px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-10px) scale(0.98);
    transform-origin: top center;
    transition:
      opacity 0.25s ease,
      transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
      visibility 0s linear 0.3s;
    z-index: 70;
  }
  .nav-links.open {
    display: flex;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition:
      opacity 0.25s ease,
      transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
      visibility 0s;
  }
  .nav-links > a {
    width: 100%;
    padding: 13px 14px;
    border-radius: 12px;
  }
  .nav-drop {
    width: 100%;
  }
  .nav-drop-toggle {
    width: 100%;
    justify-content: space-between;
    padding: 13px 14px;
  }
  .nav-drop-menu,
  .nav-drop-menu.mega {
    position: static;
    left: auto;
    width: 100%;
    min-width: 0;
    margin: 2px 0 8px;
    padding: 6px 6px 6px 10px;
    border: none;
    border-radius: 12px;
    box-shadow: none;
    background: rgba(58, 134, 255, 0.05);
    opacity: 1;
    visibility: visible;
    transform: none;
    display: none;
    max-height: none;
    overflow: visible;
  }
  .nav-drop:hover .nav-drop-menu {
    display: none;
  }
  .nav-drop.open .nav-drop-menu {
    display: flex;
    flex-direction: column;
    animation: tiitDropIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .nav-drop.open .nav-drop-menu.mega {
    display: block;
  }
  .nav-drop.open .nav-drop-menu.mega,
  .nav-drop:hover .nav-drop-menu.mega {
    transform: none;
  }
  .mega-columns {
    columns: 2;
    column-gap: 18px;
  }
  .mega-col {
    margin-bottom: 16px;
  }
  .mega-cat {
    padding: 6px 12px;
    margin-bottom: 8px;
  }
  .mega-scroll-hint {
    display: none;
  }
  .burger {
    display: block;
  }
  .nav-cta {
    margin-left: auto;
  }
  .nav-cta .btn:first-child {
    display: none;
  }
  .mobile-login-link {
    display: block !important;
    font-weight: 600;
    color: var(--navy, #293681);
  }
  /* Menu is open: stop the page underneath from scrolling */
  html.menu-open,
  html.menu-open body {
    overflow: hidden;
  }
  /* A backdrop-filter on the header AND on the panel inside it makes Chrome
     paint the page through the open menu — drop the header's while open. */
  html.menu-open header.nav {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: rgba(255, 255, 255, 0.98);
  }
}
@media (min-width: 761px) and (max-width: 1100px) {
  /* Tablet: a right-aligned panel instead of an edge-to-edge sheet */
  .nav-links {
    left: auto;
    right: 16px;
    width: min(460px, calc(100vw - 32px));
  }
}
@media (max-width: 640px) {
  .mega-columns {
    columns: 1;
  }
}
@keyframes tiitDropIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   Phones
   -------------------------------------------------------------------------- */
@media (max-width: 760px) {
  /* iOS Safari zooms the whole page when an input under 16px is focused */
  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  section {
    padding: 60px 0;
  }
  .wrap {
    padding-left: 20px;
    padding-right: 20px;
  }

  /* Headline highlight chips never overflow their column */
  .hl {
    max-width: 100%;
  }

  /* Page / course heroes: the 140px desktop top padding was mostly empty */
  .course-hero,
  .page-hero {
    padding-top: 88px !important;
  }

  .btn {
    padding: 13px 22px;
  }

  /* Course tab strip scrolls sideways instead of wrapping */
  .course-tabs-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .course-tabs-nav::-webkit-scrollbar {
    display: none;
  }

  /* Footer */
  .footer-grid {
    gap: 28px;
  }
  .footer-ask-ai .ai-row {
    flex-wrap: wrap;
  }
  .bottom-bar {
    justify-content: center;
    text-align: center;
  }
  .floating-cta {
    right: 14px !important;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* ---- Performance on phones (same look, far less GPU work) ----
     will-change on dozens of reveal cards = dozens of permanent GPU layers,
     which is exactly what makes low/mid Android phones stutter and hang. */
  .reveal,
  .reveal-zoom {
    will-change: auto;
  }
  /* Film-grain overlays: blend modes force a full recomposite every frame
     while the particle canvas underneath animates. */
  .hero::after,
  .testi-bg::after,
  .course-hero::after,
  .page-hero::after {
    mix-blend-mode: normal;
    opacity: 0.035;
  }
  /* Soft orbs are already radial gradients that fade to transparent, so the
     extra blur filter was invisible on a phone but very expensive to animate. */
  .faq-orb,
  .spline-card .glow,
  .about-visual-orb {
    filter: none;
    mix-blend-mode: normal;
  }
  header.nav {
    -webkit-backdrop-filter: blur(12px) saturate(150%);
    backdrop-filter: blur(12px) saturate(150%);
  }
}

@media (max-width: 380px) {
  .wrap {
    padding-left: 16px;
    padding-right: 16px;
  }
  .nav-cta .btn {
    padding: 8px 12px;
    font-size: 12px;
  }
  .brand img {
    height: 32px;
  }
}

/* Touch screens: hover-only effects "stick" after a tap, so give a pressed
   state instead of a stuck hover. */
@media (hover: none) {
  .course-card:hover {
    transform: none;
  }
  .course-card:active {
    transform: scale(0.98);
  }
  .btn:hover,
  .view-all-btn:hover {
    transform: none;
  }
  .btn:active,
  .view-all-btn:active,
  .stagger-btn:active {
    transform: scale(0.96);
  }
}

/* Certificate preview has width/height attributes (no layout shift); keep its natural aspect ratio */
.cert-preview {
  height: auto;
}
