/* Mobile & tablet layer — shell. Applies below 1024px; desktop (>= 1024px) must stay pixel-identical.
   Loaded after the runtime <style> injected by portfolio.jsx, so equal-specificity rules win here.
   Inline style={{}} props still beat this file: move them to classes or use !important sparingly. */

/* Shared mobile tokens (used by every css/mobile-*.css) */
@media (max-width: 1023px) {
  :root {
    --m-pad-x: clamp(20px, 5.5vw, 40px);
    --m-section-gap: clamp(56px, 14vw, 96px);
    --m-safe-top: env(safe-area-inset-top, 0px);
    --m-safe-bottom: env(safe-area-inset-bottom, 0px);
    --m-ease: cubic-bezier(.2, .7, .2, 1);
    /* the sticky header grows by the notch inset; every "100dvh - header" calc follows */
    --m-header-bar-h: 56px;
    --site-header-h: calc(var(--m-header-bar-h) + var(--m-safe-top));

    /* ---- Unified mobile design system (round-2 spec). Every area uses these. ---- */
    --m-page-top: clamp(20px, 6vw, 32px);            /* header → first content on inner pages */
    --m-radius-card: 20px;                            /* media cards, banners, story media, video, CTA */
    --m-radius-pill: 999px;
    --m-radius-icon: 12px;                            /* logo tiles */
    --m-shadow-card: 0 1px 2px rgba(0,0,0,.06), 0 10px 28px rgba(0,0,0,.10);
    --m-shadow-float: 0 6px 24px rgba(0,0,0,.14);
    --m-reveal-y: 24px;
    --m-reveal-dur: .8s;
    --m-title-size: clamp(1.55rem, 6.6vw, 2.1rem);    /* page / section titles: weight 600, -0.02em */
    --m-meta-size: 12px;                              /* meta: 400, var(--meta-tracking), var(--ink-3) */
    --m-sep-above: 40px;                              /* space above a section hairline */
    --m-sep-below: 32px;                              /* space below a section hairline */
    /* Pill recipe (All projects / Show all / chips / camera switch):
       min-height 44px; padding 0 18px; border 1px solid var(--line); background rgba(255,255,255,.7);
       border-radius var(--m-radius-pill); font: 500 14px/1 var(--font-body); letter-spacing .01em. */
    --m-pill-h: 44px;
    --m-pill-px: 18px;
    --m-pill-font: 14px;
  }
  html { scrollbar-gutter: auto; -webkit-text-size-adjust: 100%; }
  body { -webkit-tap-highlight-color: transparent; overflow-x: clip; /* clip, not hidden: hidden makes body a scroll container and kills position:sticky on the header */ }
}

/* ==========================================================
   LANDING HERO — poster-like first screen
   ========================================================== */
@media (max-width: 1023px) {
  .landing-hero {
    height: 100svh !important;
    min-height: 100svh !important;
  }
  .landing-hero__shell {
    display: flex;
    flex-direction: column;
    padding:
      calc(var(--m-safe-top) + clamp(20px, 4svh, 44px))
      max(var(--m-pad-x), env(safe-area-inset-right, 0px))
      calc(var(--m-safe-bottom) + clamp(14px, 2.6svh, 28px))
      max(var(--m-pad-x), env(safe-area-inset-left, 0px));
  }
  .landing-hero__inner {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  /* top block: tagline on top  /  big stacked links + name anchored to the bottom (no graph on mobile) */
  .landing-top {
    flex: 1;
    min-height: 0;
    display: flex !important;
    flex-direction: column;
    row-gap: 0 !important;
  }
  /* side column dissolves so its parts can be re-ordered: tagline, links */
  .landing-top__side { display: contents !important; }
  .landing-top__tagline-headline { order: 1; }
  .landing-top__tagline-body { order: 2; margin-top: clamp(10px, 1.6svh, 16px) !important; }
  .landing-top__tagline-headline {
    /* larger now that the graph is gone, so the top of the poster carries its weight */
    font-size: clamp(1.6rem, 8.4vw, 2.3rem) !important;
    line-height: 1.12 !important;
    letter-spacing: -0.025em !important;
    min-height: 0;
    max-width: 18ch !important;
  }
  .landing-top__tagline-body {
    font-size: clamp(1.08rem, 4.8vw, 1.4rem) !important;
    line-height: 1.42 !important;
    color: var(--ink-2);
    max-width: 26ch !important;
  }

  .landing-top__nav {
    order: 4;
    /* a fixed breath between the tagline and the links (portrait sizes the hero to its content) */
    margin-top: clamp(40px, 7svh, 72px);
    padding-top: 24px;
    align-self: stretch !important;
    gap: 0 !important;
  }
  .landing-top__nav > div {
    border-top: 1px solid var(--line-soft);
  }
  .landing-top__nav .big-link {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    width: 100% !important;
    max-width: none !important;
    min-height: 44px;
    padding: 0.06em 0 0.02em !important;
    font-size: min(13.6vw, 7.6svh) !important;
    line-height: 1 !important;
    touch-action: manipulation;
  }
  .landing-top__nav .big-link::after {
    content: "";
    flex: none;
    width: 0.42em;
    height: 0.42em;
    margin-right: 0.04em;
    background: var(--accent);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='square'%3E%3Cpath d='M6 18 18 6M8 6h10v10'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='square'%3E%3Cpath d='M6 18 18 6M8 6h10v10'/%3E%3C/svg%3E") center / contain no-repeat;
    transition: transform .35s var(--m-ease);
  }
  .landing-top__nav .big-link:active::after { transform: translate(3px, -3px); }

  /* the orange name: in flow, anchored to the bottom of the first screen */
  .landing-hero__name-fit {
    position: static;
    width: 100%;
    margin-top: clamp(14px, 2.6svh, 28px);
    justify-content: flex-start;
    pointer-events: auto;
  }
  .landing-hero__name-fit .name-display {
    margin-inline: 0;
    text-align: left !important;
    padding: 0 !important;
    touch-action: pan-y;
    -webkit-touch-callout: none;
  }
  .landing-hero--stacked .name-display { line-height: 0.88 !important; }
  .landing-hero--stacked .name-display__char { line-height: 0.88; }
  .landing-hero--stacked .name-display__space {
    display: block;
    height: 0;
    overflow: hidden;
  }
}

/* portrait: no full-screen poster — the hero hugs its content so there is no empty middle,
   and the Featured Projects heading peeks in below */
@media (max-width: 1023px) and (orientation: portrait) {
  .landing-hero {
    height: auto !important;
    min-height: 0 !important;
  }
  /* one vertical rhythm for the poster: tagline → (L) → links → (M) → name */
  .landing-hero__shell {
    --m-hero-gap-l: clamp(36px, 5svh, 56px);
    --m-hero-gap-m: clamp(24px, 3.4svh, 36px);
    padding-top: calc(var(--m-safe-top) + clamp(28px, 4.6svh, 48px));
    padding-bottom: var(--m-hero-gap-m);
  }
  .landing-top__nav {
    margin-top: var(--m-hero-gap-l);
    padding-top: 0;
  }
  /* close the link list so it reads as one group, separate from the name */
  .landing-top__nav > div:last-child { border-bottom: 1px solid var(--line-soft); }
  .landing-hero__name-fit { margin-top: var(--m-hero-gap-m); }
  /* the section break after the name: the largest gap on the page, but the same on phone and tablet */
  .landing-hero + main#work { padding-top: clamp(36px, 4.4svh, 48px) !important; }
}

/* phone / tablet landscape: links left, tagline right, name on one line (like desktop) */
@media (max-width: 1023px) and (orientation: landscape) {
  .landing-hero__shell {
    padding-top: calc(var(--m-safe-top) + clamp(16px, 5svh, 48px));
  }
  .landing-top {
    display: grid !important;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) !important;
    column-gap: clamp(24px, 5vw, 64px) !important;
    align-items: end;
  }
  .landing-top__side {
    display: flex !important;
    flex-direction: column;
    gap: clamp(8px, 2svh, 16px) !important;
    grid-column: 2 !important;
    grid-row: 1 !important;
    align-self: start !important;
  }
  .landing-top__tagline-body { margin-top: 0 !important; }
  .landing-top__nav {
    grid-column: 1 !important;
    grid-row: 1 !important;
    align-self: end !important;
    margin-top: 0;
    padding-top: 0;
  }
  .landing-top__nav > div { border-top: 0; }
  .landing-top__nav .big-link {
    font-size: min(7.8vw, 12.5svh) !important;
    width: fit-content !important;
    justify-content: flex-start;
    gap: 0.28em;
  }
  .landing-top__tagline-headline { font-size: clamp(1.15rem, 2.8vw, 1.8rem) !important; }
  .landing-top__tagline-body { font-size: clamp(0.95rem, 2.1vw, 1.3rem) !important; }
}
/* tablet portrait: bigger type carries the height */
@media (min-width: 768px) and (max-width: 1023px) and (orientation: portrait) {
  .landing-top__tagline-headline { font-size: clamp(2.4rem, 5.4vw, 3.2rem) !important; max-width: 20ch !important; }
  .landing-top__tagline-body { font-size: clamp(1.35rem, 2.9vw, 1.7rem) !important; margin-top: 20px !important; }
  .landing-top__nav .big-link { font-size: min(13.6vw, 8.6svh) !important; }
}
@media (max-width: 1023px) and (orientation: landscape) and (max-height: 500px) {
  /* short phone landscape: the body line would crowd the links */
  .landing-top__tagline-body { display: none; }
}

/* staggered entrance + one-off weight wave across the name (mobile only) */
@media (max-width: 1023px) and (prefers-reduced-motion: no-preference) {
  .landing-top__tagline-headline { animation: mShellRise .8s var(--m-ease) .18s backwards; }
  .landing-top__tagline-body     { animation: mShellRise .8s var(--m-ease) .28s backwards; }
  .landing-top__projects         { animation: mShellRise .8s var(--m-ease) .38s backwards; }
  .landing-top__photos           { animation: mShellRise .8s var(--m-ease) .46s backwards; }
  .landing-top__about            { animation: mShellRise .8s var(--m-ease) .54s backwards; }
  .landing-hero__name-fit .name-display__char {
    animation:
      mShellCharRise .9s var(--m-ease) calc(.55s + var(--i, 0) * 40ms) backwards,
      mShellWeightWave 1.1s ease-in-out calc(1.45s + var(--i, 0) * 65ms);
  }
}
@keyframes mShellRise {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: none; }
}
@keyframes mShellCharRise {
  from { opacity: 0; transform: translateY(0.45em); }
  to   { opacity: 1; transform: none; }
}
@keyframes mShellWeightWave {
  0%, 100% { font-weight: 700; letter-spacing: -0.045em; }
  /* tighter tracking cancels the extra width of the bold, so the name never grows past the gutter */
  45%      { font-weight: 900; letter-spacing: -0.069em; }
}

/* ==========================================================
   HEADER (inner pages)
   ========================================================== */
@media (max-width: 1023px) {
  .site-header {
    padding: var(--m-safe-top) 0 0 !important;
    box-sizing: border-box;
    height: var(--site-header-h);
  }
  .site-header__inner {
    height: var(--m-header-bar-h);
    padding: 0 max(var(--m-pad-x), env(safe-area-inset-right, 0px)) 0 max(var(--m-pad-x), env(safe-area-inset-left, 0px)) !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
  }
  .site-header__name {
    display: inline-flex !important;
    align-items: center !important;
    gap: 9px !important;
    min-height: 44px !important;
    font-size: 1rem !important;
    font-weight: 650 !important;
    white-space: nowrap !important;
    touch-action: manipulation !important;
  }
  .site-header__name::before {
    content: "";
    flex: none;
    width: 22px;
    height: 22px;
    background: var(--accent);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' fill='none'%3E%3Cpath d='M4 18C6.5 18 7.5 9 10.5 9C13.5 9 14.5 25 17.5 25C20.5 25 21.5 7 24.5 7C27 7 28 16 28 16' stroke='black' stroke-width='3.25' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' fill='none'%3E%3Cpath d='M4 18C6.5 18 7.5 9 10.5 9C13.5 9 14.5 25 17.5 25C20.5 25 21.5 7 24.5 7C27 7 28 16 28 16' stroke='black' stroke-width='3.25' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  }
  .site-header__nav {
    flex-wrap: nowrap !important;
    gap: 0 !important;
    margin-right: -10px;
  }
  .site-header__link {
    position: relative !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 44px !important;
    min-width: 44px !important;
    padding: 0 10px !important;
    box-sizing: border-box !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    letter-spacing: 0.01em !important;
    color: var(--ink-2) !important;
    border-bottom: 0 !important;
    white-space: nowrap !important;
    touch-action: manipulation !important;
  }
  .site-header__link::after {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 9px;
    height: 2px;
    border-radius: 2px;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform .35s var(--m-ease);
  }
  .site-header__link.is-active { color: var(--ink) !important; font-weight: 600 !important; }
  .site-header__link.is-active::after { transform: scaleX(1); }
  .site-header__link:active { color: var(--ink) !important; }
}
@media (max-width: 389px) {
  .site-header__name { font-size: 0.94rem !important; gap: 7px !important; }
  .site-header__name::before { width: 18px; height: 18px; }
  .site-header__link { padding: 0 7px !important; font-size: 0.84rem !important; }
  .site-header__link::after { left: 7px; right: 7px; }
  .site-header__nav { margin-right: -7px; }
}

/* ==========================================================
   PAGE TRANSITION — cover the full dynamic viewport
   ========================================================== */
@media (max-width: 1023px) {
  /* body is position:fixed (top:-scrollY) during a transition, which would carry the sticky
     header off-screen: pin it instead and pad the body so nothing shifts */
  html.page-transition-active .site-header {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
  }
  html.page-transition-active body:has(.site-header) {
    padding-top: var(--site-header-h);
  }
  .page-transition {
    inset: 0 0 auto 0;
    height: 100vh;
    height: 100lvh;
    touch-action: none;
  }
  .page-transition__panel {
    /* label stays centred in the visible (dynamic) viewport even when the panel is taller */
    align-items: flex-start;
  }
  .page-transition__label {
    margin-top: calc(50dvh - 0.5em);
    font-size: clamp(3rem, 14vw, 6rem);
    padding: 0 var(--m-pad-x);
    text-align: center;
  }
}

/* ==========================================================
   FOOTER
   ========================================================== */
@media (max-width: 1023px) {
  .site-footer {
    padding: 24px max(var(--m-pad-x), env(safe-area-inset-right, 0px)) calc(24px + var(--m-safe-bottom)) max(var(--m-pad-x), env(safe-area-inset-left, 0px)) !important;
    gap: 8px 16px !important;
  }
  .site-footer__nav {
    flex: 1 0 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0 22px;
    margin: -6px 0 6px;
  }
  .site-footer__nav-link {
    all: unset;
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.35rem;
    letter-spacing: -0.03em;
    text-transform: uppercase;
    color: var(--ink);
    cursor: pointer;
    touch-action: manipulation;
    transition: color .3s var(--m-ease);
  }
  .site-footer__nav-link.is-active { color: var(--accent); }
  .site-footer__nav-link:active { color: var(--accent); }
  .site-footer__nav-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .site-footer > span,
  .site-footer__link span {
    font-size: 0.875rem !important;
  }
  .site-footer__link {
    min-height: 44px;
    padding: 0 10px;
    margin-right: -10px;
    color: var(--ink) !important;
    touch-action: manipulation;
  }
  .site-footer__link svg { width: 18px; height: 18px; color: var(--ink); }
  .site-footer__link:active { color: var(--accent) !important; }
}

/* ==========================================================
   TOUCH: no custom cursors, no sticky hover states
   ========================================================== */
@media (hover: none), (pointer: coarse) {
  .nav-icon-cursor,
  .project-arrow-cursor { display: none !important; }
  .landing-top__photos .big-link,
  .landing-top__about .big-link,
  .landing-top__projects .big-link { cursor: pointer !important; }
}
@media (hover: none) {
  .big-link:hover { color: var(--ink); }
  .big-link:active { color: var(--accent); transition-duration: .08s; }
  /* the hover weight becomes a press/drag weight (HoverWeightName adds .is-pressed) */
  .name-display__char:hover { font-weight: inherit; }
  .name-display__char { transition-property: font-weight, letter-spacing; }
  .name-display__char.is-pressed {
    font-weight: 900;
    letter-spacing: -0.069em;
    transition-duration: .16s;
  }
  .bike-game__exit-btn:hover { transform: none; }
}

/* ==========================================================
   BIKE GAME — the easter egg isn't wired to the landing graph
   (MiniLineGraph gets no onGameStart), but keep it safe if enabled.
   ========================================================== */
@media (max-width: 1023px) {
  .bike-game__exit-btn {
    top: calc(var(--m-safe-top) + 12px) !important;
    right: calc(env(safe-area-inset-right, 0px) + 12px) !important;
  }
  .bike-game__controls {
    bottom: calc(var(--m-safe-bottom) + 16px) !important;
  }
  .bike-game__ctrl { touch-action: none; user-select: none; -webkit-user-select: none; }
}

/* ==========================================================
   TOUCH TABLETS >= 1024px (iPad landscape / iPad Pro): desktop layout, touch-sized header.
   Mouse desktops never match (hover:none and pointer:coarse).
   ========================================================== */
@media (min-width: 1024px) and (hover: none) and (pointer: coarse) {
  .site-header { padding: 6px 0 !important; }
  .site-header__name {
    display: inline-flex !important;
    align-items: center !important;
    min-height: 44px !important;
    font-size: 0.9rem !important;
  }
  .site-header__nav { gap: 4px !important; margin-right: -12px; }
  .site-header__link {
    display: inline-flex !important;
    align-items: center !important;
    min-height: 44px !important;
    min-width: 44px !important;
    padding: 0 12px !important;
    box-sizing: border-box !important;
    font-size: 0.8125rem !important;
    border-bottom: 0 !important;
    position: relative !important;
  }
  .site-header__link.is-active::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 10px;
    height: 1.5px;
    background: var(--accent);
  }
}
