/* Mobile & tablet layer — projects. 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. */

@media (max-width: 1023px) {

  /* ---------- In-view reveal (classes added by useProjectReveal, mobile only) ---------- */
  .m-reveal {
    opacity: 0;
    transform: translate3d(0, var(--m-reveal-y, 24px), 0);
    transition: opacity var(--m-reveal-dur, .8s) var(--m-ease, cubic-bezier(.2, .7, .2, 1)),
                transform var(--m-reveal-dur, .8s) var(--m-ease, cubic-bezier(.2, .7, .2, 1));
  }
  .m-reveal:not(.is-in) { will-change: opacity, transform; }
  .m-reveal.is-in {
    opacity: 1;
    transform: none;
  }

  /* ============================================================
     HOME — featured projects list
     ============================================================ */
  main#work {
    padding: clamp(40px, 10vw, 72px) var(--m-pad-x) var(--m-section-gap) !important;
  }
  .projects-featured {
    grid-template-columns: minmax(0, 1fr) !important;
    row-gap: clamp(24px, 6vw, 36px) !important;
  }
  .projects-featured__aside {
    position: static !important;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
  }
  .projects-featured__aside h2 {
    font-size: var(--m-title-size, clamp(1.55rem, 6.6vw, 2.1rem)) !important;
  }
  .projects-featured__aside > span {
    margin-top: 0 !important;
    font-size: var(--m-meta-size, 12px) !important;
  }
  .projects-featured__list {
    gap: clamp(44px, 11vw, 64px) !important;
  }
  .projects-featured__card {
    gap: 0 !important;
    min-height: 0 !important;
  }
  .projects-featured .project-card-layout { justify-content: flex-start !important; }
  .projects-featured .project-card__block {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* card media: proportional instead of a fixed height */
  .projects-featured .project-media-wrap {
    border-radius: var(--m-radius-card, 20px) !important;
    box-shadow: var(--m-shadow-card) !important;
    transform: translateZ(0);
    transition: transform .45s var(--m-ease, cubic-bezier(.2, .7, .2, 1)),
                box-shadow .45s ease;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
            user-select: none;
  }
  .projects-featured .project-media,
  .projects-featured .project-placeholder {
    height: auto !important;
    aspect-ratio: 56 / 39; /* the card artwork's own ratio (2240x1560): nothing cropped */
    border-radius: 0 !important;
    transition: transform .8s var(--m-ease, cubic-bezier(.2, .7, .2, 1));
  }
  .projects-featured .project-media-wrap:active {
    transform: scale(.975);
  }
  .projects-featured .project-media-wrap:active .project-media {
    transform: scale(1.04);
  }
  /* Caption strip under the artwork (instead of a title over it): the art keeps its own
     wordmark/logo untouched, and the name + badges + "open" arrow read cleanly below. */
  .projects-featured .project-media-wrap {
    background: oklch(1 0 0);
  }
  .projects-featured .project-media__overlay-wrap {
    position: relative !important;
    inset: auto !important;
    background: oklch(1 0 0) !important;
    padding: 14px 70px 16px clamp(16px, 4.6vw, 22px) !important;
    min-height: 78px;
    box-sizing: border-box;
    justify-content: center !important;
    border-top: 1px solid var(--line);
  }
  .projects-featured .project-media__overlay {
    gap: 8px !important;
  }
  .projects-featured .project-media__overlay h3 {
    color: var(--ink) !important;
    font-size: clamp(1.3rem, 5.4vw, 1.55rem) !important;
  }
  .projects-featured .project-media__overlay .project-card__badges > span {
    color: var(--ink-2) !important;
    border-color: var(--line) !important;
    font-size: 12px !important;
    padding: 6px 12px !important;
  }

  /* the desktop arrow cursor, translated into an "open" button in the caption strip */
  .projects-featured .project-media-wrap::after {
    content: "";
    position: absolute;
    right: clamp(16px, 4.6vw, 22px);
    bottom: 18px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64' fill='none' stroke='%23fff' stroke-width='5'%3E%3Cline x1='20' y1='44' x2='44' y2='20'/%3E%3Cpolyline points='24 20 44 20 44 40'/%3E%3C/svg%3E") center / 20px 20px no-repeat,
      var(--ink);
    pointer-events: none;
    transition: transform .45s var(--m-ease, cubic-bezier(.2, .7, .2, 1)), background-color .3s ease;
  }
  .projects-featured .project-media-wrap:active::after {
    transform: rotate(45deg) scale(.92);
    background-color: var(--accent);
  }

  /* per-project blurb sits under its own card */
  .projects-featured .project-card__blurb {
    margin: 16px 2px 0 !important;
    font-size: 16px !important;
    line-height: 1.55 !important;
    color: var(--ink-2) !important;
    max-width: 60ch;
    text-wrap: pretty;
  }

  /* ============================================================
     PROJECT DETAIL (Simul, Fovere, Sportaz)
     ============================================================ */
  .fovere-detail {
    padding-top: 0 !important;
    padding-bottom: 8px !important;
  }

  /* back navigation */
  .m-detail-back {
    padding: var(--m-page-top, 24px) var(--m-pad-x) 16px;
    max-width: var(--maxw);
    margin: 0 auto;
  }
  .m-detail-back--bottom {
    display: flex;
    justify-content: center;
    padding: clamp(40px, 10vw, 64px) var(--m-pad-x) clamp(24px, 6vw, 40px);
  }
  .m-detail-back__btn {
    -webkit-appearance: none;
            appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: var(--m-pill-h, 44px);
    padding: 0 var(--m-pill-px, 18px) 0 calc(var(--m-pill-px, 18px) - 4px);
    border-radius: var(--m-radius-pill, 999px);
    border: 1px solid var(--line);
    background: oklch(1 0 0 / .7);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: var(--m-pill-font, 14px);
    font-weight: 500;
    letter-spacing: -0.005em;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform .3s var(--m-ease, cubic-bezier(.2, .7, .2, 1)), background-color .2s ease;
  }
  .m-detail-back__btn svg {
    color: var(--accent);
    transition: transform .3s var(--m-ease, cubic-bezier(.2, .7, .2, 1));
  }
  .m-detail-back__btn:active {
    transform: scale(.96);
    background: oklch(0.96 var(--tone-c) var(--tone-h));
  }
  .m-detail-back__btn:active svg { transform: translateX(-3px); }

  /* hero banner: crop the very wide banner to a calmer ratio so the logo reads */
  .fovere-detail__hero {
    padding: 0 var(--m-pad-x) !important;
  }
  .fovere-detail__hero .project-media-wrap--banner {
    border-radius: var(--m-radius-card, 20px) !important;
    box-shadow: var(--m-shadow-card) !important;
  }
  .fovere-detail__hero .project-media--banner {
    max-height: none !important;
    aspect-ratio: 3 / 1;
    object-fit: cover !important;
    border-radius: 0 !important;
  }
  /* Simul keeps its side swooshes; Fovere's wordmark is wider: both get a longer strip */
  .fovere-detail__hero [data-project="simul"] .project-media--banner {
    aspect-ratio: 4.4 / 1;
  }
  .fovere-detail__hero [data-project="fovere"] .project-media--banner {
    aspect-ratio: 4.2 / 1;
  }

  /* intro */
  .fovere-detail__intro {
    padding: clamp(24px, 7vw, 36px) var(--m-pad-x) 0 !important;
    margin-bottom: 0 !important;
    max-width: 680px !important;
  }
  .fovere-detail__tagline {
    margin-bottom: clamp(14px, 4vw, 20px) !important;
    font-size: clamp(1.75rem, 7.6vw, 2.4rem) !important;
    line-height: 1.1 !important;
    letter-spacing: -0.025em !important;
    text-wrap: balance;
  }
  .fovere-detail__hero [data-project="sportaz"] .project-media--banner {
    object-position: 44% 50% !important; /* the wordmark sits left of the artwork's centre */
  }
  .fovere-detail__blurb { text-wrap: pretty; }
  .fovere-detail__blurb {
    font-size: 16.5px !important;
    line-height: 1.62 !important;
  }

  /* promo video */
  .project-promo {
    padding: clamp(28px, 8vw, 44px) var(--m-pad-x) 0 !important;
    max-width: 680px !important;
  }
  .project-promo video {
    border-radius: var(--m-radius-card, 20px) !important;
    box-shadow: var(--m-shadow-card);
  }

  /* ---------- Story: stacked steps (MobileScrollStory) ---------- */
  .m-story {
    padding: clamp(24px, 6vw, 40px) var(--m-pad-x) 0;
    max-width: 680px;
    margin: 0 auto;
    box-sizing: content-box;
  }
  .m-story__step {
    padding: var(--m-sep-below, 32px) 0 var(--m-sep-above, 40px);
  }
  .m-story__step:first-child { padding-top: clamp(8px, 3vw, 16px); }
  .m-story__step + .m-story__step {
    border-top: 1px solid var(--line);
  }
  .m-story__media {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(28px, 8vw, 44px) 16px;
    border-radius: var(--m-radius-card, 20px);
    isolation: isolate;
    background:
      radial-gradient(120% 80% at 50% 30%, oklch(1 0 0) 0%, oklch(0.955 var(--tone-c) var(--tone-h)) 100%);
    box-shadow: inset 0 0 0 1px var(--line);
    overflow: hidden;
  }
  .m-story__img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: min(58svh, 500px);
    object-fit: contain;
    position: relative;
    z-index: 1;
    transform: scale(.94) translateY(16px);
    transition: transform 1.1s var(--m-ease, cubic-bezier(.2, .7, .2, 1)) .05s;
  }
  .m-story__media.is-in .m-story__img {
    transform: none;
  }
  /* static contact shadow under the device / box (cheaper than an animated drop-shadow filter) */
  .m-story__media::after {
    content: "";
    position: absolute;
    left: 22%;
    right: 22%;
    bottom: clamp(12px, 4vw, 22px);
    height: 28px;
    background: radial-gradient(closest-side, rgba(0, 0, 0, .22), rgba(0, 0, 0, 0));
    z-index: 0;
    pointer-events: none;
  }
  .m-story--cutout .m-story__media {
    padding: clamp(20px, 6vw, 36px) 12px;
  }
  .m-story--cutout .m-story__img {
    max-width: min(100%, calc(92% * var(--m-img-scale, 1)));
    max-height: calc(min(40svh, 340px) * var(--m-img-scale, 1));
  }
  .m-story__copy {
    margin-top: clamp(20px, 6vw, 28px);
    transition-delay: .08s;
  }
  .m-story__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-meta);
    font-size: var(--m-meta-size, 12px);
    letter-spacing: 0.04em;
    color: var(--ink-3);
    line-height: 1.3;
  }
  .m-story__count { font-weight: 600; color: var(--accent); }
  .m-story__total { color: var(--ink-3); font-weight: 400; }
  .m-story__dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    opacity: .6;
  }
  .m-story__title {
    margin: 12px 0 12px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: var(--m-title-size, clamp(1.55rem, 6.6vw, 2.1rem));
    letter-spacing: -0.02em;
    line-height: 1.14;
    color: var(--ink);
    text-wrap: balance;
  }
  .m-story__body {
    margin: 0;
    font-size: 16.5px;
    line-height: 1.62;
    color: var(--ink-2);
    max-width: 60ch;
    text-wrap: pretty;
  }

  /* ---------- App Store CTA ---------- */
  .fovere-cta {
    padding: clamp(40px, 10vw, 64px) var(--m-pad-x) 0 !important;
    gap: 22px !important;
  }
  .fovere-cta__line {
    font-size: clamp(1.25rem, 5.4vw, 1.6rem) !important;
    max-width: 30ch !important;
    text-wrap: balance;
  }
  .fovere-cta__btn {
    min-height: 56px;
    -webkit-tap-highlight-color: transparent;
    border-radius: var(--m-radius-card, 20px) !important;
    box-shadow: var(--m-shadow-card);
  }
  .fovere-cta__btn:active {
    transform: scale(.97);
    border-color: color-mix(in oklab, var(--fovere-teal) 40%, var(--line));
  }
  .fovere-cta__btn:active::before { opacity: 1; }
  .fovere-cta__kicker { font-size: 12px !important; }
}

/* Tablet & landscape phones: image and copy side by side, alternating */
@media (max-width: 1023px) and (min-width: 700px) {
  .m-story {
    max-width: 920px;
  }
  .m-story__step {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: clamp(28px, 5vw, 56px);
    align-items: center;
    padding: var(--m-sep-below, 32px) 0 var(--m-sep-above, 40px);
  }
  .m-story__step:nth-child(even) .m-story__media { order: 2; }
  .m-story__copy { margin-top: 0; }
  .m-story__img { max-height: min(62svh, 520px); }
  .m-story--cutout .m-story__img { max-height: calc(min(40svh, 320px) * var(--m-img-scale, 1)); }
  .fovere-detail__intro,
  .project-promo { max-width: 760px !important; }
  .fovere-detail__hero .project-media--banner { aspect-ratio: 4.6 / 1; }
  .fovere-detail__hero [data-project="fovere"] .project-media--banner { aspect-ratio: 5.6 / 1; }
  .fovere-detail__hero [data-project="sportaz"] .project-media--banner { object-position: 38% 50% !important; }

  /* Home list: first project featured full width, the next two side by side */
  .projects-featured__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(36px, 5vw, 48px) clamp(20px, 3vw, 28px) !important;
  }
  .projects-featured__card:first-child { grid-column: 1 / -1; }
  .projects-featured__card:first-child .project-media,
  .projects-featured__card:first-child .project-placeholder { aspect-ratio: 16 / 9; }
  .projects-featured .project-card__blurb { font-size: 15.5px !important; }
}

/* Short landscape screens: keep the stage within the viewport */
@media (max-width: 1023px) and (max-height: 520px) and (orientation: landscape) {
  .m-story__media { padding: 20px 12px; }
  .m-story__img { max-height: 72svh; }
  .m-story--cutout .m-story__img { max-height: calc(56svh * var(--m-img-scale, 1)); }
  .projects-featured__list { gap: 32px 20px !important; }
  .project-promo video {
    width: auto !important;
    max-width: 100%;
    max-height: calc(100svh - var(--site-header-h, 56px) - 24px);
    margin: 0 auto;
  }
  .projects-featured .project-media__overlay-wrap { padding: 12px 58px 14px 14px !important; min-height: 72px; }
  .projects-featured .project-media-wrap::after { right: 12px; bottom: 16px; width: 38px; height: 38px; }
  .projects-featured .project-media__overlay h3 { font-size: 1.2rem !important; }
  .projects-featured .project-card__badges > span { padding: 5px 9px !important; }
}

/* Landscape (phones and tablets): all three cards in one row so card + caption fit the height */
@media (max-width: 1023px) and (min-width: 600px) and (orientation: landscape) {
  .projects-featured__list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .projects-featured__card:first-child { grid-column: auto; }
  .projects-featured__card:first-child .project-media,
  .projects-featured__card:first-child .project-placeholder { aspect-ratio: 56 / 39; }
}

/* Narrow landscape phones (3 cards ~190px wide): the arrow moves up into the title row so the
   badges get the full caption width and every card keeps the same height */
@media (max-width: 899px) and (min-width: 600px) and (orientation: landscape) {
  .projects-featured .project-media-wrap::after { display: none; }
  .projects-featured .project-media__overlay-wrap { padding: 12px 12px 14px 14px !important; }
  .projects-featured .project-media__overlay { align-items: stretch !important; }
  .projects-featured .project-media__overlay h3 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .projects-featured .project-media__overlay h3::after {
    content: "";
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64' fill='none' stroke='%23fff' stroke-width='5'%3E%3Cline x1='20' y1='44' x2='44' y2='20'/%3E%3Cpolyline points='24 20 44 20 44 40'/%3E%3C/svg%3E") center / 16px 16px no-repeat,
      var(--ink);
    transition: transform .45s var(--m-ease, cubic-bezier(.2, .7, .2, 1));
  }
  .projects-featured .project-media-wrap:active h3::after { transform: rotate(45deg) scale(.92); }
  .projects-featured .project-card__badges { flex-wrap: nowrap !important; }
}

@media (max-width: 1023px) and (prefers-reduced-motion: reduce) {
  .m-reveal,
  .m-reveal.is-in {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .m-story__img,
  .m-story__media.is-in .m-story__img { transform: none; transition: none; }
  .projects-featured .project-media-wrap,
  .projects-featured .project-media { transition: none; }
}

/* Phones: left-align the tagline with the left-aligned intro paragraphs */
@media (max-width: 767px) {
  .fovere-detail__tagline { text-align: left !important; }
}
