/* ─────────────────────────────────────────────────────────────
   Foldable layouts — tuned for the Galaxy Z Fold 8, shared by every page.
   Loaded after each page's own styles, so these rules win.

   Cover screen: 5.5", 1248 × 1972 px, 10:16. In a browser that is a short
   "passport" viewport of roughly 420–480 × 560–700 CSS px. It is much less tall
   than a normal phone, so it is detected by aspect ratio, not width alone.

   Inner screen: 7.6", 2448 × 1848 px, 4:3, and wider than tall when unfolded.
   That is roughly 820–950 × 560–720 CSS px, a small touch landscape. Without
   these rules it would get the hamburger, single-column mobile layout.

   Also covers the Fold 8 Ultra (21:9 cover, 10:9 inner), rotated inner screens,
   and the half-folded postures, via the Viewport Segments API where supported.
   ───────────────────────────────────────────────────────────── */


/* ═════════ COVER SCREEN — short, wide-ish portrait ═════════ */
@media (max-width: 560px) and (orientation: portrait) and (min-aspect-ratio: 5/8) and (min-height: 460px) {
  .mast-inner { height: 48px; padding: 0 18px; }
  .masthead { backdrop-filter: blur(10px); }
  .mob-menu { top: 48px; padding: 26px 22px; gap: 18px; }
  .mob-menu a { font-size: 19px; }
  .frame { padding: 0 18px; }

  .hero { padding-top: 48px; min-height: 100svh; }
  .hero-eyebrow { margin-bottom: 14px; font-size: 10px; }
  .hero-sub { font-size: 14.5px; line-height: 1.55; margin-bottom: 20px; }
  .btn { height: 40px; padding: 0 16px; font-size: 12.5px; }
  .cta-row { gap: 8px; }

  /* Home: compact title, info in two tight columns */
  .hero-inner:has(.hero-side) { padding: 28px 18px 56px; gap: 22px; align-self: stretch; align-content: center; }
  .hero-title { font-size: clamp(44px, 13.5vw, 64px); margin-bottom: 16px; }
  .maze-rule { height: 5px; }
  .hero-side { grid-template-columns: 1fr 1fr; column-gap: 18px; padding-top: 14px; }
  .hero-side-item { padding: 8px 0; }
  .hero-side-val { font-size: 12.5px; overflow-wrap: anywhere; }

  /* Portfolio */
  .hero-inner:has(.hero-left) { padding: 0 18px 48px; }
  .hero-left { padding: 28px 0 22px; }
  .hero-kicker { margin-bottom: 18px; }
  .hero-name { font-size: clamp(48px, 15vw, 72px); }
  .hero-bottom { margin-top: 22px; gap: 16px; }
  .hero-tagline { font-size: 14.5px; }
  .hero-right { grid-template-columns: 1fr 1fr; column-gap: 18px; padding: 18px 0; }
  .contact-grid { grid-template-columns: 1fr 1fr; }

  /* Games */
  .hero-inner:has(> .hero-eyebrow) { padding: 36px 18px 56px; }
  .game-images { grid-template-columns: 1fr 1fr; }

  /* Basalt */
  .hero:has(.hero-logo) { padding: 96px 0 48px; }
  .hero-logo { width: 44px; height: 44px; margin-bottom: 18px; }
  .hero-cta { margin-bottom: 32px; }

  /* Sections: shorter screen, tighter rhythm */
  .section { padding: 52px 0; }
  .section-head { padding-bottom: 26px; margin-bottom: 30px; gap: 10px; }
  .section-title { font-size: clamp(30px, 9vw, 42px); }
  .pillar, .product-card { padding: 24px 18px; }
}


/* ═════════ INNER SCREEN — unfolded, small touch landscape (4:3) ═════════ */
@media (min-width: 680px) and (max-width: 1100px) and (min-aspect-ratio: 1/1) and (max-aspect-ratio: 8/5) and (max-height: 880px) and (pointer: coarse) {
  /* Room for the real navigation instead of the hamburger */
  .mast-inner { padding: 0 28px; }
  .mast-nav { display: flex; gap: 18px; }
  .mast-nav a { font-size: 12px; }
  .mob-btn { display: none; }
  #mob-toggle:checked ~ .mob-menu { display: none; }
  .frame { padding: 0 28px; }

  /* Home: side-by-side hero sized to the short screen */
  .hero { min-height: 100svh; }
  .hero-inner:has(.hero-side) { grid-template-columns: 1fr 250px; gap: 40px; padding: 40px 28px 56px; align-items: center; }
  .hero-title { font-size: min(10vw, 15vh); margin-bottom: 22px; }
  .hero-sub { font-size: 15.5px; margin-bottom: 26px; }
  .hero-side { display: flex; flex-direction: column; border-top: none; border-left: 1px solid var(--line-2); padding: 0 0 0 26px; }
  .hero-side-item { padding: 10px 0; }

  /* Portfolio */
  .hero-inner:has(.hero-left) { grid-template-columns: 1fr 250px; padding: 0 28px 48px; }
  .hero-left { border-right: 1px solid var(--line-2); border-bottom: none; padding: 40px 40px 40px 0; }
  .hero-right { display: block; padding: 32px 0 32px 26px; }
  .hero-name { font-size: min(9vw, 15vh); }
  .about-layout { grid-template-columns: 1fr 1.4fr; gap: 48px; }
  .skill-row { grid-template-columns: 170px 1fr; gap: 24px; }
  .contact-grid { grid-template-columns: repeat(3, 1fr); }

  /* Games */
  .hero-inner:has(> .hero-eyebrow) { padding: 64px 28px 64px; }
  .panel-cols { grid-template-columns: 1fr 240px; }

  /* Basalt */
  .hero:has(.hero-logo) { padding: 120px 0 64px; }
  .screen { grid-template-columns: 1fr 1fr; gap: 36px; }
  .screen:nth-child(even) { direction: rtl; }
  .screen:nth-child(even) > * { direction: ltr; }
  .feat-grid { grid-template-columns: repeat(2, 1fr); }
  .try-cols { grid-template-columns: 1.1fr .9fr; gap: 40px; }

  /* Sections: desktop structure, tighter spacing */
  .section { padding: 72px 0; }
  .section-head { grid-template-columns: 150px 1fr; gap: 32px; padding-bottom: 34px; margin-bottom: 40px; }
  .section-title { font-size: clamp(34px, 5vw, 52px); }
  .pillars { grid-template-columns: repeat(3, 1fr); }
  .pillar { padding: 28px 24px; border-right: 1px solid var(--line); border-bottom: none; }
  .project-item { grid-template-columns: 52px 1fr auto; }
  .proj-links { grid-column: auto; }
  .product-grid { grid-template-columns: repeat(2, 1fr); }
  .product-card { padding: 30px 26px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .contact-cols { grid-template-columns: 1.2fr 1fr; gap: 48px; }
  .footer-inner { flex-direction: row; align-items: center; }
}


/* ═════════ INNER SCREEN — turned to portrait (3:4) ═════════ */
@media (min-width: 560px) and (max-width: 900px) and (orientation: portrait) and (min-aspect-ratio: 3/5) and (pointer: coarse) {
  .hero-side { grid-template-columns: 1fr 1fr 1fr; }
  .product-grid { grid-template-columns: repeat(2, 1fr); }
  .product-card { border-right: 1px solid var(--line); }
  .pillars { grid-template-columns: repeat(2, 1fr); }
  .contact-grid { grid-template-columns: repeat(3, 1fr); }
  .feat-grid { grid-template-columns: repeat(2, 1fr); }
}


/* ═════════ HALF-FOLDED (Flex mode) ═════════ */
/* Tabletop, hinge horizontal: the scene sits on the upper half, the text on the lower */
@media (vertical-viewport-segments: 2) {
  .hero { min-height: 100svh; align-items: flex-end; }
  .hero-inner:has(.hero-side),
  .hero-inner:has(> .hero-eyebrow) { padding-top: calc(env(viewport-segment-bottom 0 0, 50vh) + 20px); padding-bottom: 88px; }
  .hero-left { padding-top: calc(env(viewport-segment-bottom 0 0, 50vh) - 36px); }
}
/* Book, hinge vertical: keep the hero's two columns on either side of the hinge */
@media (horizontal-viewport-segments: 2) {
  .hero-inner:has(.hero-side),
  .hero-inner:has(.hero-left) {
    grid-template-columns: calc(env(viewport-segment-width 0 0, 50vw) - 60px) 1fr;
    column-gap: calc(env(viewport-segment-left 1 0, 50vw) - env(viewport-segment-right 0 0, 50vw) + 60px);
  }
}
