/* Mobile layout additions share the existing identity and motion variables. */
.portfolio-v4 .brand-mobile-name,
.mobile-project-return { display: none; }

.mobile-menu-links { display: grid; gap: 8px; }
.mobile-menu-links > span {
  margin-top: 8px;
  color: #a9b0ad;
  font-size: 12px;
  font-weight: 600;
}

@media (max-width: 1120px) {
  body.menu-open {
    position: fixed;
    top: var(--menu-scroll-y, 0px);
    width: 100%;
    overflow: hidden;
  }

  .portfolio-v4 .mobile-menu {
    height: 100dvh;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 16px;
    padding: 88px 20px max(16px, env(safe-area-inset-bottom));
    overflow: hidden;
    background: #080a09;
    backdrop-filter: none;
  }

  .mobile-menu-links {
    align-content: start;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    padding: 0 2px 6px;
  }

  .portfolio-v4 .mobile-menu-links button {
    min-height: 44px;
    padding: 9px 14px;
    border-radius: 6px;
    text-align: left;
    font-size: 16px;
    line-height: 1.3;
  }

  .mobile-menu-links button[aria-current="page"] {
    color: #fff;
    background: #222b25;
    border-color: #88ff54;
  }

  .portfolio-v4 .mobile-menu-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
    padding-top: 12px;
    border-top: 1px solid #29302c;
  }

  .portfolio-v4 .mobile-menu-actions .button {
    min-height: 48px;
    padding: 10px;
    font-size: 13px;
    white-space: normal;
    line-height: 1.3;
  }
}

@media (max-width: 780px) {
  .portfolio-v4 .site-header {
    top: 10px;
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
    min-height: 64px;
    padding: 8px 10px;
    transform: none;
  }

  .portfolio-v4 .brand { gap: 10px; min-width: 0; }
  .portfolio-v4 .brand .brand-mobile-name {
    display: block;
    width: auto;
    height: auto;
    padding: 0;
    color: #f4f5f2;
    background: none;
    border: 0;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    text-align: left;
  }
  .portfolio-v4 .brand .brand-mobile-name small {
    display: block;
    margin-top: 2px;
    color: #adb4af;
    font-size: 11px;
    font-weight: 400;
  }
  .portfolio-v4 .menu-toggle { width: 46px; height: 46px; flex-shrink: 0; }
  .portfolio-v4.menu-open .menu-toggle span:first-child { transform: translateY(4px) rotate(45deg); }
  .portfolio-v4.menu-open .menu-toggle span:last-child { transform: translateY(-4px) rotate(-45deg); }
  .portfolio-v4 .header-actions { gap: 6px; }
  .portfolio-v4 :is(button, a, input, select, textarea) { -webkit-tap-highlight-color: transparent; }
  .portfolio-v4 :is(button, a):focus-visible { outline: 2px solid #96ffd8; outline-offset: 4px; }
  .portfolio-v4 :is(input, select, textarea) { font-size: 16px; }

  .portfolio-v4 .motion-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto;
    align-content: start;
    gap: 12px;
    height: auto;
    min-height: 0;
    max-height: none;
    padding: 100px 20px 18px;
    background-color: #000;
  }

  .portfolio-v4 .motion-hero-eyebrow {
    position: relative;
    inset: auto;
    grid-row: 1;
    font-size: 11px;
    line-height: 1.4;
    color: #b6bdb9;
  }
  .portfolio-v4 .motion-hero-object,
  .portfolio-v4 .motion-hero-object.is-character-mode {
    position: relative;
    inset: auto;
    grid-row: 2;
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    margin: 0;
    touch-action: pan-y;
    transform: translate3d(calc(var(--character-x, 0px) * .3), calc(var(--character-y, 0px) * .3), 0)
      rotateX(var(--character-tilt-x, 0deg)) rotateY(var(--character-tilt-y, 0deg));
  }
  .portfolio-v4 .motion-hero-object.is-character-mode .motion-head-frame { inset: 0; }
  .portfolio-v4 .motion-hero-name { top: 195px; width: calc(100% - 20px); font-size: 50px; }
  .portfolio-v4 .motion-hero-grid { top: 20%; }
  .portfolio-v4 .motion-hero-logo-burst { top: 30%; }
  .portfolio-v4 .motion-hero-copy {
    position: relative;
    inset: auto;
    grid-row: 3;
    width: 100%;
    padding: 0;
  }
  .portfolio-v4 .motion-hero-copy > span { display: block; margin-bottom: 10px; font-size: 12px; line-height: 1.45; color: #c2cbc5; }
  .portfolio-v4 .motion-hero-copy p { max-width: none; margin-bottom: 18px; font-size: 15px; line-height: 1.6; color: #b6c0b9; }
  .portfolio-v4 .motion-hero-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: none; }
  .portfolio-v4 .motion-hero-actions .motion-button:last-child { display: inline-flex; }
  .portfolio-v4 .motion-button { min-height: 48px; padding: 10px 14px; font-size: 12px; line-height: 1.3; gap: 8px; }
  .portfolio-v4 .motion-hero-bottom {
    position: relative;
    inset: auto;
    grid-row: 4;
    justify-content: center;
    margin-top: 4px;
  }
  .portfolio-v4 .motion-hero-bottom > span { display: none; }
  .portfolio-v4 .motion-hero-bottom button { min-height: 44px; font-size: 11px; gap: 12px; }
  .portfolio-v4 .motion-hero-bottom button i { width: 32px; height: 32px; }

  .portfolio-v4 .home-latest-projects { min-height: 0; }
  .portfolio-v4 .home-latest-stage {
    position: relative;
    top: auto;
    height: auto;
    min-height: 0;
    padding: 40px 16px;
    overflow: visible;
  }
  .portfolio-v4 .home-latest-heading { display: grid; grid-template-columns: 1fr; gap: 8px; }
  .portfolio-v4 .home-latest-heading h2 { font-size: 30px; line-height: 1.1; }
  .portfolio-v4 .home-latest-heading > span { font-size: 11px; }
  .portfolio-v4 .home-latest-heading p { max-width: none; font-size: 14px; line-height: 1.5; }
  .portfolio-v4 .home-latest-viewport { height: auto; }
  .portfolio-v4 .home-latest-track { align-items: stretch; height: auto; }
  .portfolio-v4 .home-latest-page {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(3, auto);
    gap: 12px;
    height: auto;
  }
  .portfolio-v4 .home-latest-card { aspect-ratio: 4 / 3; }
  .portfolio-v4 .home-latest-card-copy { padding: 9px; }
  .portfolio-v4 .home-latest-card-copy strong { font-size: 12px; line-height: 1.25; }
  .portfolio-v4 .home-latest-nav { margin-top: 16px; }
  .portfolio-v4 .home-latest-nav > span { font-size: 12px; }
  .portfolio-v4 .home-latest-nav button { width: 48px; height: 48px; }
  .portfolio-v4 .home-latest-media:active { border-color: #96ffd8; }

  .portfolio-v4 .project-stack-card { border-radius: 8px; padding: 16px; gap: 16px; }
  .portfolio-v4 .project-stack-card-header { grid-template-columns: 40px minmax(0, 1fr); gap: 12px; }
  .portfolio-v4 .project-stack-number { font-size: 32px; letter-spacing: 0; }
  .portfolio-v4 .project-stack-category { font-size: 11px; letter-spacing: 0; }
  .portfolio-v4 .project-stack-card h3 { font-size: 22px; line-height: 1.2; }
  .portfolio-v4 .project-stack-button { min-height: 46px; height: auto; width: 100%; font-size: 12px; padding: 12px 16px; }
  .portfolio-v4 .project-stack-body { gap: 16px; }
  .portfolio-v4 .project-stack-copy > p { display: block; font-size: 14px; line-height: 1.55; overflow: visible; -webkit-line-clamp: unset; }
  .portfolio-v4 .project-stack-media-grid {
    order: -1;
    grid-template-rows: 190px 84px;
    height: 281px !important;
  }
  .portfolio-v4 .project-stack-primary { height: 190px !important; }
  .portfolio-v4 .project-stack-secondary { grid-template-rows: 84px; height: 84px !important; }
  .portfolio-v4 .project-stack-meta-cell small { font-size: 10px; }
  .portfolio-v4 .project-stack-meta-cell strong { font-size: 12px; line-height: 1.4; white-space: normal; overflow: visible; overflow-wrap: anywhere; }
  .portfolio-v4 .project-stack-tags span { min-height: 28px; font-size: 11px; }
  .portfolio-v4 .project-stack-media-grid figure { border-radius: 6px; }

  .portfolio-v4 .panel:not(#panel-home) :is(h2, .panel-head h2) { font-size: 30px !important; line-height: 1.15 !important; }
  .portfolio-v4 .panel:not(#panel-home) h3 { font-size: 22px; line-height: 1.25; }
  .portfolio-v4 .detail-toolbar { gap: 12px; }
  .portfolio-v4 :is(.detail-toolbar, .dubai-nav, .aipo-nav) button,
  .portfolio-v4 :is(.button, .story-nav button, .ilayda-story-controls button, .modal-close) { min-height: 44px; font-size: 13px; }
  .portfolio-v4 :is(.dubai-nav, .aipo-nav) { overflow-x: auto; flex-wrap: nowrap; overscroll-behavior-inline: contain; }
  .portfolio-v4 :is(.dubai-nav, .aipo-nav) > * { flex-shrink: 0; }
  .portfolio-v4.is-project-detail-open #panel-projects { padding-bottom: 84px; }
  .portfolio-v4.is-project-detail-open .mobile-project-return {
    position: fixed;
    z-index: 60;
    left: 50%;
    bottom: max(16px, env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 48px;
    padding: 12px 20px;
    transform: translateX(-50%);
    color: #f4f6f3;
    background: #111512;
    border: 1px solid #69756b;
    border-radius: 24px;
    box-shadow: 0 4px 20px #0006;
    font-size: 14px;
    white-space: nowrap;
  }
  .portfolio-v4.is-project-detail-open .mobile-project-return span { font-size: 20px; }
  .portfolio-v4:is(.is-project-detail-open, .menu-open, .modal-open) .mobile-sticky-cta,
  .portfolio-v4:is(.menu-open, .modal-open) .mobile-project-return { display: none; }
  .portfolio-v4 .mobile-sticky-cta .button { min-height: 46px; font-size: 12px; }
  .portfolio-v4 .home-comment-card { min-width: 0; }
  .portfolio-v4 .home-comment-quote { font-size: 14px; line-height: 1.5; }
}

@media (max-width: 380px) {
  .portfolio-v4 .motion-hero-name { font-size: 46px; }
  .portfolio-v4 .brand .brand-mobile-name { font-size: 12px; }
  .portfolio-v4 .motion-button { padding-inline: 10px; }
}
