/* ==========================================================================
   MIPL MOBILE HERO v3: "Reels" (phones, up to 767px)
   Full-screen vertical videos, one per stage. Swipe up for the next stage, like Instagram Reels.
   After the last stage the page carries on scrolling as normal.
   Used by index-v3.html. Behaviour: assets/js/pages/home/hero-reels.js
   Above 767px this section is hidden and the desktop process hero is shown.
   ========================================================================== */

/* ---------- Brand tokens (same as the site and the desktop banner) ---------- */
.mipl-reels {
  --r-blue: #2E5EB4;
  --r-red: #FF1F5A;
  --r-red-2: #FF3B3B;
  --r-navy: #0C1B3A;
  --r-white: #FFFFFF;
  --r-font-display: "Urbanist", "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --r-font: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --r-header-h: 56px;
}

.mipl-reels { display: none; }

@media (max-width: 767px) {

  /* ---------- Swap heroes: hide the desktop process hero on phones ---------- */
  .process-hero,
  .pin-spacer:has(> .process-hero) { display: none !important; }

  /* ---------- Site header: solid white bar, 56px ---------- */
  body.has-mipl-hero .site-header,
  body.has-mipl-hero .site-header.solid {
    background: rgba(255, 255, 255, .97) !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    border-bottom: 1px solid #E3E9F2 !important;
    box-shadow: none !important;
  }
  body.has-mipl-hero .site-header .nav-bar { min-height: 56px; height: 56px; padding: 0 4px 0 12px; max-width: none; margin: 0; align-items: center; }
  body.has-mipl-hero .site-header .logo img { height: 32px; }
  body.has-mipl-hero .site-header .menu-btn {
    width: 44px; height: 44px;
    color: #0C1B3A !important; background: transparent !important; box-shadow: none !important;
  }

  /* ---------- Section: exactly one screen below the header ---------- */
  .mipl-reels {
    display: block;
    position: relative;
    margin-top: var(--r-header-h);
    height: calc(100vh - var(--r-header-h));      /* fallback */
    height: calc(100svh - var(--r-header-h));     /* small viewport: browser bars never cut it */
    min-height: 480px;
    overflow: hidden;
    background: var(--r-navy);
    color: var(--r-white);
    font-family: var(--r-font);
    -webkit-text-size-adjust: 100%;
  }
  .mipl-reels *, .mipl-reels *::before, .mipl-reels *::after { box-sizing: border-box; }

  /* ---------- Vertical feed (scroll-snap) ---------- */
  .mipl-reels__track {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    outline: none;
  }
  .mipl-reels__track::-webkit-scrollbar { display: none; }
  /* banner partly scrolled away: reels locked, swipes scroll the page (set by hero-reels.js) */
  .mipl-reels.is-page .mipl-reels__track { overflow-y: hidden; touch-action: pan-y; }
  .mipl-reels__track:focus-visible { outline: 3px solid var(--r-blue); outline-offset: -3px; }

  /* ---------- One reel ---------- */
  .mipl-reel {
    position: relative;
    height: 100%;
    overflow: hidden;
    scroll-snap-align: start;
    scroll-snap-stop: always;         /* one swipe = one reel, as in Reels */
    background: linear-gradient(160deg, #1B3768 0%, #0C1B3A 100%);
    isolation: isolate;
  }

  /* placeholder (shown until the poster loads, or if it fails) */
  .mipl-reel__ph {
    position: absolute; inset: 0; z-index: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
    color: rgba(255, 255, 255, .55);
  }
  .mipl-reel__ph svg { width: 56px; height: 56px; }

  .mipl-reel__poster,
  .mipl-reel__video {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
  }
  .mipl-reel__poster { z-index: 1; }
  .mipl-reel__poster.is-broken { display: none; }
  .mipl-reel__video { z-index: 2; opacity: 0; transition: opacity 300ms ease; pointer-events: none; }
  .mipl-reel__video.is-playing { opacity: 1; }

  /* dark fades top and bottom so the white text always reads */
  .mipl-reel__shade {
    position: absolute; inset: 0; z-index: 3; pointer-events: none;
    background:
      linear-gradient(180deg, rgba(12, 27, 58, .55) 0%, rgba(12, 27, 58, .7) 50%, rgba(12, 27, 58, .85) 100%);
  }

  /* ---------- Centred panel: headline, services, current stage, buttons (stays while reels move) ---------- */
  .mipl-reels__panel {
    position: absolute; inset: 0; z-index: 6;
    display: flex; flex-direction: column; justify-content: center;
    padding: 24px 20px 64px 16px;      /* bottom room for the swipe hint and Skip */
    pointer-events: none;              /* swipes and taps go through to the reels */
  }
  .mipl-reels__panel a { pointer-events: auto; }
  #main .mipl-reels .mipl-reels__title {
    margin: 0;
    font-family: var(--r-font-display);
    font-weight: 600;
    font-size: clamp(36px, calc(36px + (100vw - 360px) * 0.1333), 40px);   /* 36px at 360px wide, 40px from 390px */
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: var(--r-white);
    white-space: normal;
    text-shadow: 0 1px 12px rgba(0, 0, 0, .25);
  }
  #main .mipl-reels .mipl-reels__accent { color: var(--r-red); font-weight: 700; }
  .mipl-reels__chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
  .mipl-reels__chip {
    display: inline-flex; align-items: center; gap: 6px;
    min-height: 32px; padding: 0 12px 0 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .16);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    color: var(--r-white);
    font: 700 13px/1 var(--r-font);
    letter-spacing: .03em;
    text-decoration: none;
  }
  .mipl-reels__chip svg { width: 16px; height: 16px; flex: none; }

  /* ---------- Position indicator: 6 short bars down the right edge ---------- */
  .mipl-reels__pos {
    position: absolute; right: 6px; top: 50%; z-index: 6;
    display: flex; flex-direction: column; gap: 6px;
    margin: 0; padding: 0; list-style: none;
    transform: translateY(-50%);
    pointer-events: none;
  }
  .mipl-reels__pos li { width: 3px; height: 14px; border-radius: 3px; background: rgba(255, 255, 255, .35); transition: height .3s ease, background-color .3s ease; }
  .mipl-reels__pos li.is-on { height: 26px; background: var(--r-red); }

  /* ---------- Current stage (text swaps on each swipe) ---------- */
  .mipl-reels__stage { margin-top: 26px; }
  .mipl-reels__kicker {
    display: inline-block;
    margin: 0 0 8px;
    padding: 5px 9px;
    border-radius: 6px;
    background: var(--r-red);
    font: 700 11px/1 var(--r-font);
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--r-white);
  }
  .mipl-reels__name {
    margin: 0;
    font: 700 26px/1.15 var(--r-font-display);
    letter-spacing: -0.01em;
    color: var(--r-white);
  }
  .mipl-reels__desc {
    margin: 6px 0 0;
    font: 400 15px/1.45 var(--r-font);
    color: rgba(255, 255, 255, .9);
  }
  .mipl-reels__stage.is-in .mipl-reels__kicker,
  .mipl-reels__stage.is-in .mipl-reels__name,
  .mipl-reels__stage.is-in .mipl-reels__desc { animation: mipl-reels-in .35s ease both; }
  .mipl-reels__stage.is-in .mipl-reels__name { animation-delay: .05s; }
  .mipl-reels__stage.is-in .mipl-reels__desc { animation-delay: .1s; }
  @keyframes mipl-reels-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

  /* ---------- Buttons: side by side, sharing the full width ---------- */
  .mipl-reels__ctas { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
  .mipl-reels__btn {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    min-width: 0; height: 50px; padding: 0 10px;
    border-radius: 14px;
    font: 700 14px/1 var(--r-font);
    white-space: nowrap;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }
  .mipl-reels__btn svg { width: 16px; height: 16px; flex: none; }
  .mipl-reels__btn--primary { background: linear-gradient(90deg, var(--r-red), var(--r-red-2)); color: var(--r-white); box-shadow: 0 10px 24px -10px rgba(255, 31, 90, .7); }
  .mipl-reels__btn--ghost { background: rgba(255, 255, 255, .14); color: var(--r-white); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .6); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }

  /* ---------- Right action rail (like the Reels buttons) ---------- */
  .mipl-reel__rail {
    position: absolute; right: 8px; bottom: 22px; z-index: 7;   /* fixed on the section, above the reels and the panel */
    display: flex; flex-direction: column; align-items: center; gap: 14px;
  }
  .mipl-reel__act {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    width: 56px; min-height: 44px;
    padding: 0; border: 0; background: none;
    color: var(--r-white);
    font: 600 11px/1.1 var(--r-font);
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .mipl-reel__act span:first-child {
    display: grid; place-items: center;
    width: 44px; height: 44px; border-radius: 50%;
    background: rgba(255, 255, 255, .16);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22);
  }
  .mipl-reel__act svg { width: 22px; height: 22px; }

  /* ---------- Playback progress line at the very bottom ---------- */
  .mipl-reel__progress { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; height: 3px; background: rgba(255, 255, 255, .2); }
  .mipl-reel__progress i { display: block; height: 100%; background: var(--r-red); transform-origin: 0 50%; transform: scaleX(0); transition: transform .25s linear; }

  /* ---------- Tap to pause / play: icon flashes in the centre ---------- */
  .mipl-reel__state {
    position: absolute; left: 50%; top: 50%; z-index: 5;
    display: grid; place-items: center;
    width: 72px; height: 72px; margin: -36px 0 0 -36px;
    border-radius: 50%;
    background: rgba(12, 27, 58, .5);
    color: var(--r-white);
    opacity: 0; transform: scale(.8);
    transition: opacity .2s ease, transform .2s ease;
    pointer-events: none;
  }
  .mipl-reel__state svg { width: 32px; height: 32px; }
  .mipl-reel.is-paused .mipl-reel__state { opacity: 1; transform: none; }

  /* ---------- "Swipe up" hint on the first reel, gone after the first swipe ---------- */
  .mipl-reels__hint {
    position: absolute; left: 50%; bottom: 18px; z-index: 6;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    transform: translateX(-50%);
    color: var(--r-white);
    font: 600 12px/1 var(--r-font);
    letter-spacing: .06em;
    text-transform: uppercase;
    pointer-events: none;
    transition: opacity .3s ease;
  }
  .mipl-reels__hint svg { width: 26px; height: 26px; animation: mipl-reels-nudge 1.4s ease-in-out infinite; }
  .mipl-reels.is-swiped .mipl-reels__hint { opacity: 0; }
  @keyframes mipl-reels-nudge { 0%, 100% { transform: translateY(4px); opacity: .6; } 50% { transform: translateY(-6px); opacity: 1; } }

  /* the site's fixed "Great Place to Work" badge sits over the action rail: hide it while the reels are on screen */
  html body.reels-in-view .gptw-badge { opacity: 0 !important; pointer-events: none !important; }

  /* ---------- Focus outlines ---------- */
  .mipl-reels__chip:focus-visible,
  .mipl-reels__btn:focus-visible,
  .mipl-reel__act:focus-visible { outline: 3px solid var(--r-white); outline-offset: 2px; border-radius: 14px; }

  /* very short screens: smaller caption so the headline and caption never meet */
  @media (max-height: 640px) {
    .mipl-reels__name { font-size: 22px; }
    .mipl-reels__desc { font-size: 14px; }
    .mipl-reels__stage { margin-top: 16px; }
    .mipl-reels__ctas { margin-top: 16px; }
    .mipl-reels__hint { display: none; }
  }
}

/* ---------- Reduced motion: posters only, no animation, instant scrolling ---------- */
@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
  .mipl-reels *, .mipl-reels *::before, .mipl-reels *::after { transition: none !important; animation: none !important; }
  .mipl-reel__video { display: none; }
  .mipl-reels__track { scroll-behavior: auto; }
}

/* ==========================================================================
   V4 ONLY (index-v4.html: <section class="mipl-reels mipl-reels--v4">)
   Thin type, lighter overlay on the video, Skip button on the left. v3 is not affected.
   ========================================================================== */
@media (max-width: 767px) {
  /* thin headline and stage name (Urbanist light, as on the desktop banner) */
  #main .mipl-reels--v4 .mipl-reels__title { font-weight: 300; letter-spacing: -0.025em; text-shadow: 0 1px 14px rgba(0, 0, 0, .35); }
  #main .mipl-reels--v4 .mipl-reels__accent { font-weight: 400; }
  .mipl-reels--v4 .mipl-reels__name { font-weight: 400; text-shadow: 0 1px 10px rgba(0, 0, 0, .35); }
  .mipl-reels--v4 .mipl-reels__desc { font-weight: 300; text-shadow: 0 1px 8px rgba(0, 0, 0, .4); }

  /* lighter overlay: more of the video shows through */
  .mipl-reels--v4 .mipl-reel__shade {
    background: linear-gradient(180deg, rgba(12, 27, 58, .3) 0%, rgba(12, 27, 58, .4) 50%, rgba(12, 27, 58, .6) 100%);
  }

  /* Skip on the left */
  .mipl-reels--v4 .mipl-reel__rail { right: auto; left: 16px; bottom: 16px; }

  /* Skip as a pill, same look as the SITC / AMC / SOC pills (icon + label in a row) */
  .mipl-reels--v4 .mipl-reel__act {
    flex-direction: row; gap: 6px;
    width: auto; min-height: 36px; padding: 0 14px 0 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .16);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    font: 700 13px/1 var(--r-font);
    letter-spacing: .03em;
  }
  .mipl-reels--v4 .mipl-reel__act span:first-child {
    width: auto; height: auto; border-radius: 0;
    background: none; box-shadow: none;
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .mipl-reels--v4 .mipl-reel__act svg { width: 16px; height: 16px; }

  /* "STAGE 01 OF 06" tag: glass background like the How It Works button, no border */
  .mipl-reels--v4 .mipl-reels__kicker {
    background: rgba(255, 255, 255, .14);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    padding: 6px 10px;
    border-radius: 8px;
  }
}
