/* ============================================================
   mobile.css — the mobile builds of Abilities, What I Build and
   Media. Everything here is either (a) a full-screen overlay /
   shared primitive that only ever exists on mobile, or (b) gated
   behind @media (max-width: 768px). Desktop is untouched.

   The mobile DOM is injected by js/mobile/*. When the mobile layer
   is active the matching desktop subtree is hidden (see the
   "hide desktop-only subtrees" block below). Kept in sync with
   MOBILE_QUERY in js/responsive.js.
   ============================================================ */

/* ============================================================
   Shared full-screen scrollable image overlay
   (js/mobile/image-overlay.js — abilities backs + media articles)
   Not gated: it lives on <body> and is only created on mobile.
   ============================================================ */
body.m-overlay-open { overflow: hidden; }

.m-imgov {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease-out);
}
.m-imgov[hidden] { display: none; }
.m-imgov.is-open { opacity: 1; pointer-events: auto; }

.m-imgov__bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.m-imgov__title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.m-imgov__close {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--fg);
}
.m-imgov__close svg { width: 13px; height: 13px; }

.m-imgov__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px 32px;
}
.m-imgov__img {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 16px;
  /* border-radius: var(--r-md); */
  transform: translateY(16px);
  opacity: 0;
  transition: transform 0.32s var(--ease-out), opacity 0.32s ease;
}
.m-imgov.is-open .m-imgov__img { transform: none; opacity: 1; }

/* card / hint animations (referenced only by mobile DOM) */
@keyframes m-card-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes m-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ============================================================
   Everything below only applies on phones / small portrait tablets
   ============================================================ */
@media (max-width: 768px) {

  /* ---- hide the desktop-only subtrees (mobile layer replaces them) ---- */
  .wib__pin,
  .abilities__floor,
  #abilitiesDeck,
  .media__body { display: none !important; }

  /* ---- kill phantom horizontal overflow on phones ----
     Oversized decorative layers in the not-yet-mobile Landing/Journey
     (full-bleed grids, the −50% criss motif, corner press cards) push
     past the viewport. body{overflow-x:hidden} alone doesn't always
     contain that once html is the scroll context (Lenis), which reads
     as a "cut-off" strip on the right. `clip` contains it WITHOUT
     creating a scroll container that would break scroll pinning.
     Scoped to mobile → desktop is completely untouched. */
  html { overflow-x: clip; }

  /* ---- section shells reflow to natural height on mobile ---- */
  .section-title { font-size: clamp(2.43rem, 10.2vw, 3.45rem); }
  /* landing tap hint — fades in once the scroll intro finishes */
  .landing__taphint {
    display: block;
    position: absolute;
    top: clamp(60px, 9vh, 104px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    margin: 0;
    font-family: var(--font-head);
    font-weight: 400;
    font-size: var(--step-1);
    letter-spacing: 0.01em;
    color: rgba(255, 255, 255, 0.55);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s var(--ease-out);
  }
  .landing__taphint.is-on { opacity: 1; }

  /* ---- landing (mobile): 3D hero sits behind (absolute); the tagline +
     press carousel stack at the bottom. Social icons + desktop corner
     press cards are dropped. ---- */
  .landing {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: clamp(1.25rem, 4vh, 2.25rem);
    padding: var(--space-lg) var(--section-pad) clamp(1.25rem, 4vh, 2.5rem);
  }
  #landing .press,
  .landing__social,
  .landing__halo { display: none; }               /* no green halo on mobile */

  /* criss-cross spans the full viewport, with a clearly-visible radial fade.
     --criss-opacity here is independent of the desktop value (0.05). */
  .landing__criss {
    --criss-opacity: 0.08;
    -webkit-mask-image: radial-gradient(75% 60% at 50% 50%, #000 18%, transparent 85%);
            mask-image: radial-gradient(75% 60% at 50% 50%, #000 18%, transparent 85%);
  }

  /* bigger + slightly more visible rotating motif —
     tune size with --motif-size (desktop 100vmin), visibility with --motif-opacity */
  .landing__motif { --motif-size: 220vmin; --motif-opacity: 0.45; }

  /* tagline flows in the column instead of being absolutely pinned */
  .landing__tagline {
    position: static;
    translate: none;
    inset: auto;
    max-width: 32ch;
  }

  /* swipeable press carousel with an upper + lower separator */
  .landing-m__news {
    display: block;
    width: 100%;
    z-index: var(--z-content);
    border-block: 1px solid rgba(255, 255, 255, 0.13);
    padding-block: 14px;
  }
  .landing-m__track {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .landing-m__track::-webkit-scrollbar { display: none; }
  .landing-m__slide {
    flex: 0 0 100%;
    scroll-snap-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-inline: 6px;
  }
  .landing-m__slide img {
    width: 100%;
    max-width: 440px;
    height: auto;
  }

  .abilities, .media { min-height: auto; }
  .abilities {
    gap: clamp(1.25rem, 5vw, 2rem);
    padding: var(--space-lg) var(--section-pad) var(--space-md);
  }
  .abilities__hint { margin: 0; }

  /* The mobile rails are full-bleed and own their inset (var(--section-pad)).
     Zero the section's OWN horizontal padding so rail content isn't inset
     twice (section-pad + rail-pad), and hand the non-rail intro/head their
     padding back so they still line up with the rails. */
  .wib { padding-inline: 0; }
  .wib__intro { padding-inline: var(--section-pad); }
  /* display:block (not the inherited grid): a grid item's min-width:auto
     refuses to shrink below its widest content, so the nowrap pill/chip
     rows would blow .media wider than the viewport — pushing the card
     off-screen AND leaving the rails nothing to scroll. Block sizes .media
     to the viewport, so the rails overflow and scroll as intended. */
  .media { display: block; padding-block: var(--space-lg); padding-inline: 0; }

  /* ---- shared pill row (WIB selector + Media categories) ---- */
  .wib-m__sel, .media-m__cats {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .wib-m__sel::-webkit-scrollbar, .media-m__cats::-webkit-scrollbar { display: none; }

  .wib-m__pill, .media-m__cat {
    position: relative;
    flex: 0 0 auto;
    padding: 10px 18px;
    border-radius: var(--r-pill);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--fg);
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 0.92rem;
    letter-spacing: -0.01em;
    white-space: nowrap;
    transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease;
  }
  /* offset outline "3D" layer that slides out from under the active pill */
  .wib-m__pill::before, .media-m__cat::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 1px solid var(--accent);
    opacity: 0;
    transform: translate(0, 0);
    pointer-events: none;
    transition: opacity 0.32s var(--ease-out), transform 0.32s var(--ease-out);
  }
  .wib-m__pill.is-active, .media-m__cat.is-active {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(156, 227, 37, 0.14);
  }
  .wib-m__pill.is-active::before, .media-m__cat.is-active::before {
    opacity: 0.55;
    transform: translate(-4px, 4px);
  }

  /* ---- shared dots (all three sections) ---- */
  .abil-m__dots, .wib-m__dots, .media-m__dots {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 20px;
  }
  .abil-m__dot, .wib-m__dot, .media-m__dot {
    width: 6px; height: 6px;
    border-radius: 999px;
    background: var(--border-strong);
    transition: width 0.2s ease, background 0.2s ease;
  }
  .abil-m__dot.is-active, .wib-m__dot.is-active, .media-m__dot.is-active {
    width: 18px;
    background: var(--accent);
  }

  /* ========================================================
     What I Build — mobile
     ======================================================== */
  .wib-m { margin-top: clamp(1.5rem, 6vw, 2.5rem); }
  .wib-m__sel { padding: 0 var(--section-pad) 14px; }

  .wib-m__rail {
    display: flex;
    gap: 12px;
    padding: 4px var(--section-pad) 6px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .wib-m__rail::-webkit-scrollbar { display: none; }

  .wib-m__slide {
    flex: 0 0 calc(100% - 2 * var(--section-pad));
    scroll-snap-align: center;
    scroll-snap-stop: always;
    display: flex;
    perspective: 1100px;
  }

  .wib-m__card {
    width: 100%;
    display: flex;
    flex-direction: column;
    padding: 14px;
    border-radius: 22px;
    border: 1px solid var(--border);
    background: linear-gradient(155deg, var(--tint, #141414), #0b0c09 62%);
    transform-origin: 50% 50%;
    backface-visibility: visible;
  }

  .wib-m__media {
    width: 100%;
    aspect-ratio: 1 / 1;      /* --m-media-aspect: square by default (per tsx) */
    border-radius: 14px;
    overflow: hidden;
    background: #000;
  }
  .wib-m__media img, .wib-m__media video { width: 100%; height: 100%; object-fit: cover; }

  .wib-m__tags {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-top: 14px;
  }
  .wib-m__tags li {
    padding: 5px 10px;
    border-radius: var(--r-pill);
    background: rgba(156, 227, 37, 0.12);
    border: 1px solid rgba(156, 227, 37, 0.28);
    color: var(--accent);
    font-size: var(--step--1);
    font-weight: 600;
    line-height: 1.2;
  }

  .wib-m__title {
    margin-top: 16px;
    font-family: var(--font-head);
    font-weight: 500;
    font-size: var(--step-3);
    line-height: 1.14;
    letter-spacing: -0.02em;
    color: var(--fg);
  }

  .wib-m__hint { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
  .wib-m__hint svg { width: 14px; height: 14px; flex: 0 0 auto; fill: rgba(244, 245, 242, 0.7); }
  .wib-m__hint-txt {
    font-size: var(--step--1); font-weight: 500; letter-spacing: 0.02em;
    background: linear-gradient(100deg,
      rgba(244, 245, 242, 0.42) 0%, rgba(244, 245, 242, 0.42) 38%,
      rgba(244, 245, 242, 0.95) 50%,
      rgba(244, 245, 242, 0.42) 62%, rgba(244, 245, 242, 0.42) 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text; background-clip: text;
    color: transparent;
    animation: m-shimmer 4.6s linear infinite;
  }

  .wib-m__stats {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
  }
  .wib-m__stat { min-width: 0; }
  .wib-m__stat-n {
    display: block;
    font-family: var(--font-head);
    font-weight: 500;
    font-size: var(--step-3) !important;
    line-height: 1.05;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
    color: transparent;
    background: linear-gradient(90deg, rgba(156, 227, 37, 0.9), rgba(156, 227, 37, 0.4));
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-stroke: 1px #9CE325;
    paint-order: stroke fill;
  }
  .wib-m__stat-l {
    display: block;
    margin-top: 6px;
    min-height: 2.6em;
    color: rgba(244, 245, 242, 0.92);
    font-size: var(--step--1);
    font-weight: 600;
    line-height: 1.3;
  }
  .wib-m__stat-dots { flex: 0 0 auto; display: flex; gap: 5px; padding-top: 10px; }
  .wib-m__stat-dots span {
    width: 5px; height: 5px; border-radius: 999px;
    background: var(--border-strong);
    transition: width 0.25s ease, background 0.25s ease;
  }
  .wib-m__stat-dots span.is-on { width: 14px; background: var(--accent); }

  /* CONFIG.statLayout === "grid": every stat on screen at once */
  .wib-m__stats--grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 14px; }
  .wib-m__stats--grid .wib-m__stat-n { font-size: 1.4rem; }
  .wib-m__stats--grid .wib-m__stat-l { min-height: 0; }

  .wib-m__body { margin-top: 16px; display: flex; flex-direction: column; gap: 0.75rem; color: var(--fg-dim); font-size: var(--step--1); line-height: 1.6; }

  /* ========================================================
     Abilities — mobile (swipeable fanned deck)
     ======================================================== */
  .abil-m { position: relative; }
  .abil-m__stage {
    position: relative;
    width: 100%;
    max-width: 460px;
    margin-inline: auto;
    aspect-ratio: 1 / 1;
    touch-action: pan-y;
    -webkit-user-select: none; user-select: none;
    cursor: grab;
  }
  .abil-m__stage:active { cursor: grabbing; }
  .abil-m__card {
    position: absolute;
    top: 0;
    left: 50%;
    width: 62%;
    padding: 0;
    background: none;
    border: none;
    transform-origin: 50% 135%;
    will-change: transform;
    -webkit-user-select: none; user-select: none;
  }
  .abil-m__card img { display: block; width: 100%; height: auto; pointer-events: none; border-radius: var(--r-md); }
  /* match the desktop card edge: 1px white ring, faded top→bottom, same radius
     (no hover on mobile, so it stays white) */
  .abil-m__card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: var(--r-md);
    padding: 1px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.2));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    pointer-events: none;
  }

  /* ========================================================
     Media — mobile
     ======================================================== */
  .media { overflow-x: clip; }
  .media__head { margin-bottom: var(--space-md); }
  .media-m { margin-top: 0.5rem; }

  .media-m__cats { padding: 0 var(--section-pad) 14px; }

  .media-m__chips {
    display: flex;
    align-items: flex-end;
    gap: 30px;
    overflow-x: auto;
    padding: 0 var(--section-pad) 16px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .media-m__chips::-webkit-scrollbar { display: none; }
  .media-m__group { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; }
  .media-m__group-label {
    min-height: 1em;
    color: var(--fg-faint);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    white-space: nowrap;
  }
  .media-m__chip-row { display: flex; gap: 18px; }
  .media-m__chip {
    position: relative;
    flex: 0 0 auto;
    padding: 2px 0 8px;
    color: var(--fg-dim);
    font-size: 0.94rem;
    font-weight: 400;
    white-space: nowrap;
    transition: color 0.18s ease;
  }
  .media-m__chip.is-active { color: var(--accent); font-weight: 600; }
  .media-m__chip.is-active::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 2px;
    border-radius: 2px;
    background: var(--accent);
  }

  .media-m__card-wrap { padding: 0 var(--section-pad); touch-action: pan-y; }
  .media-m__card.is-swap { animation: m-card-in 0.28s var(--ease-out); }

  .media-m__frame {
    width: 100%;
    padding: 8px;
    border-radius: 18px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
  }
  .media-m__well {
    position: relative;
    width: 100%;
    aspect-ratio: var(--aspect, 4 / 3);
    border-radius: 11px;
    overflow: hidden;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .media-m__well img, .media-m__well video, .media-m__well iframe {
    width: 100%; height: 100%; object-fit: cover; border: 0;
  }
  .media-m__play {
    position: absolute; inset: 0;
    display: grid; place-items: center;
    background: rgba(0, 0, 0, 0.28);
  }
  .media-m__play span {
    width: 0; height: 0;
    border-top: 9px solid transparent;
    border-bottom: 9px solid transparent;
    border-left: 15px solid var(--accent);
    margin-left: 4px;
    filter: drop-shadow(0 0 0 rgba(0,0,0,0));
  }
  .media-m__play::before {
    content: "";
    position: absolute;
    width: 62px; height: 44px;
    border-radius: 12px;
    background: rgba(20, 20, 20, 0.85);
  }
  .media-m__play span { position: relative; z-index: 1; }

  .media-m__title {
    margin: 18px 0 10px;
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 1.35rem;
    line-height: 1.2;
    letter-spacing: -0.015em;
    color: var(--accent-mid);
  }
  .media-m__title--center { margin: 0 0 14px; text-align: center; font-size: 1.25rem; }

  .media-m__blurb { margin: 0; color: var(--fg-dim); font-size: 0.94rem; line-height: 1.5; }
  .media-m__blurb.is-clamped {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .media-m__cta {
    display: flex;
    width: fit-content;
    margin: 16px auto 0;
    align-items: center;
    justify-content: center;
    padding: 13px 26px;
    border-radius: var(--r-pill);
    border: 1px solid var(--border);
    background: #262626;
    color: #f2f2f2;
    font-size: 0.94rem;
    font-weight: 500;
    letter-spacing: -0.01em;
  }
  .media-m__cta:active { transform: translateY(1px); }

  /* image graphic: full width, natural height (no fixed box, no crop).
     Videos keep the aspect-ratio well since iframes/players have no
     intrinsic size. */
  .media-m__img { display: block; width: 100%; height: auto; border-radius: 11px; }

  /* ========================================================
     What I Build — Read-More overlay (shared #wibOverlay), mobile
     Stack the bar so the close button gets its own row at the top and
     the project pills sit in a full-width row beneath it.
     ======================================================== */
  .wib-overlay__bar { flex-direction: column; align-items: stretch; gap: 10px; }
  .wib-overlay__close { order: -1; align-self: flex-end; }
  .wib-ov__tabs { order: 0; flex: 0 0 auto; }

  /* overlay card stats → two-column grid (desktop keeps its single nowrap row) */
  .wib-ov__body > .wib-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px 16px;
  }
  .wib-ov__body > .wib-stats .wib-stat { flex: initial; }
  /* a lone stat spans both columns instead of sitting half-width */
  .wib-ov__body > .wib-stats .wib-stat:only-child { grid-column: 1 / -1; }

  /* ========================================================
     Journey (mobile) — replaces the desktop letterboxed scene.
     A 100svh wrapper: the journey-mobile.glb canvas fills the top and
     fades out at its lower edge; an awards carousel sits in the reserved
     space beneath it, switching Act 1 ⇄ Act 2 with the pinned scrub.
     Tunables live on .journey-m (see table in the change notes).
     ======================================================== */
  .journey-scene { display: none; }        /* drop the desktop 16:9 scene */

  .journey-m {
    --jm-awards-h: 74px;    /* height reserved at the bottom for the carousel */
    --jm-fade: 5%;         /* how far up from the canvas' bottom edge it fades */
    --jm-gold: #f5a623;     /* awards card border + title colour */
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background: var(--bg);
  }

  /* canvas takes all remaining height (never full 100svh — the awards row
     owns the bottom band), full width, and dissolves at its lower edge. */
  .journey-m__canvas {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    -webkit-mask-image: linear-gradient(to bottom,
      #000 0%, #000 calc(100% - var(--jm-fade)), transparent 100%);
            mask-image: linear-gradient(to bottom,
      #000 0%, #000 calc(100% - var(--jm-fade)), transparent 100%);
  }
  /* the .scene-mount (absolute inset:0) fills this relative box */

  /* --- awards card: rounded gold border with a legend-style title on top --- */
  .journey-m__awards {
    position: relative;
    flex: 0 0 auto;
    height: var(--jm-awards-h);
    margin: 0 var(--section-pad) clamp(0.75rem, 3vh, 1.5rem);
    padding: 14px 16px;
    border: 1px solid var(--jm-gold);
    border-radius: var(--r-lg);
    display: grid;
    place-items: center;
    transition: opacity 0.4s var(--ease-out);
  }
  /* past keyframe 40 the whole card (frame + title + slides) fades out */
  .journey-m__awards.is-hidden { opacity: 0; pointer-events: none; }
  .journey-m__awards-title {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 0 12px;
    background: var(--bg);         /* masks the border it sits on */
    color: var(--jm-gold);
    font-family: var(--font-body);
    font-weight: 700;
    font-size: calc(var(--step-0) - 5px);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
  }

  /* two carousels share the same box; the active act is faded in */
  .journey-m__carousel {
    position: absolute;
    inset: 14px 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.45s var(--ease-out);
  }
  .journey-m__carousel.is-active { opacity: 1; pointer-events: auto; }

  .journey-m__track {
    display: flex;
    width: 100%;
    height: 100%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .journey-m__track::-webkit-scrollbar { display: none; }
  .journey-m__slide {
    flex: 0 0 100%;
    scroll-snap-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-inline: 4px;
  }
  .journey-m__slide img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
  }
}
