/* ============================================================
   Xike Yang — Personal Academic Homepage  (V2)
   Deck layout — hero first, then a cube docked to the top-left.

   <main class="deck"> is tall: one "screen" of scroll per panel.
   .deck-pin sticks to the viewport and cross-fades one .panel at a
   time. The hero panel is a plain, centred intro with no cube; once you
   scroll into "01 About" the cube (css/cube.css) fades in, docked to the
   top-left of the content column, and stays there for the rest of the page.
   js/animation.js writes the cube reveal + each panel's opacity.

   Layout per panel:
     .panel-head  sits to the RIGHT of the top-left cube (section title)
     .panel-body  sits BELOW the cube, full content width (scrolls
                  internally only if it is taller than the band)
   ============================================================ */

/* Float the nav over the deck so the pin starts at y=0. */
html.js .site-header {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
}

/* Shared geometry: the content column the cube docks into. */
:root {
  /* The left/right edge of the content column. On wide screens this lines up
     with the nav's text column; on narrow ones it falls back to the gutter.
     (Percentages here resolve against .deck-pin = the full viewport.) */
  --deck-inset: max(var(--page-pad), calc((100% - var(--container)) / 2 + 1.5rem));
}

.deck {
  position: relative;
  /* Override the 960px centred `main` container from style.css: the pin
     must span the full viewport so the cube can dock against the corner. */
  max-width: none;
  margin: 0;
  padding: 0;
  /* One panel ≈ 120vh of scroll (the extra 20vh is a small "hold").
     svh, not vh: vh resolves against the *large* mobile viewport while
     .deck-pin below uses svh (the small one), so the deck and its own pin
     disagreed by the height of a mobile URL bar — and every panel's scroll
     position moved whenever that bar hid or came back. */
  height: calc(var(--panel-count, 7) * 120vh);
  height: calc(var(--panel-count, 7) * 120svh);
}

.deck-pin {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;                 /* avoids mobile URL-bar jump where supported */
  overflow: hidden;
}

/* ---------- Panels (cross-faded by JS) ---------- */
.panel {
  position: absolute;
  inset: 0;
  z-index: 1;                     /* below .cube-stage (z-index 5) */
  opacity: 0;
  pointer-events: none;
}
.panel.is-active {
  pointer-events: auto;
}

/* ---------- Head (right of the cube) / body (below the cube) ---------- */
.panel-head,
.panel-body {
  position: absolute;
  z-index: 2;
  text-align: left;
}

.panel-head {
  top: calc(var(--corner-top) + var(--cube-size) / 2);
  /* 1.3x keeps the title clear of the cube even at 45°, where the rotating
     silhouette swells to ~1.21x its resting width. */
  left: calc(var(--deck-inset) + var(--cube-size) * 1.3 + var(--cube-gap));
  right: var(--deck-inset);
  transform: translateY(-50%);
}

.panel-body {
  top: calc(var(--corner-top) + var(--cube-size) * 1.18 + var(--cube-gap));
  left: var(--deck-inset);
  right: var(--deck-inset);
  bottom: calc(var(--page-pad) + 0.5rem);
  overflow-y: auto;
  overscroll-behavior: auto;      /* keep scrolling on to the next panel */
  padding: 0;
  /* No visible scrollbar — the soft fade below is the only affordance. */
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.panel-body::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* On a phone the panel body is a scroller of its own. With chaining left on,
   one flick that reached the end of the text carried straight on into the
   PAGE — and the page is a deck where ~705px is a whole section, so a single
   flick could coast three or four panels past the one you were reading. Stop
   the chain on touch/narrow screens; desktop keeps chaining on purpose. */
@media (max-width: 1023px), (hover: none) {
  .panel-body { overscroll-behavior-y: contain; }
}

/* Fade the bottom edge only while there is more content to scroll to
   (js/animation.js toggles .has-overflow / .at-bottom). */
.panel-body.has-overflow:not(.at-bottom) {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 34px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 34px), transparent);
}

/* ---------- Head typography ---------- */
.panel-head .section-num { display: block; margin-bottom: 0.3rem; }
.panel-head h2 { font-size: clamp(1.45rem, 2.8vw, 2rem); line-height: 1.15; }

/* ---------- Hero: no cube, just a centred intro ---------- */
.panel-hero .panel-body {
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translate(-50%, -50%);
  width: min(100% - 2 * var(--page-pad), 46rem);
  max-height: 78vh;
  overflow: visible;
  text-align: center;
}
/* Reserved portrait slot. Drop a real photo in later: an <img> placed inside
   .hero-avatar is cropped to the circle automatically. */
.panel-hero .hero-avatar {
  width: clamp(68px, 12vmin, 104px);
  height: clamp(68px, 12vmin, 104px);
  margin: 0 auto 1rem;
  display: grid;
  place-items: center;
  border: 1px dashed var(--border);
  border-radius: 50%;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  overflow: hidden;
}
.panel-hero .hero-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }

.panel-hero .hero-kicker { margin-bottom: 0.9rem; }
.panel-hero h1 {
  font-size: clamp(2.4rem, 7vw, 4rem);
  font-weight: 700;
  line-height: 1.1;
}
.panel-hero .hero-line {
  margin: 1.4rem auto 0;
  max-width: 34rem;
  font-size: clamp(1.05rem, 2.4vw, 1.25rem);
  color: var(--muted);
}
.panel-hero .hero-actions { margin-top: 1.7rem; justify-content: center; }

/* ---------- Tighten spacing so each panel fits one screen ---------- */
.panel-body .lede { font-size: 1.05rem; max-width: 46rem; }
.panel-body .muted-note { margin-bottom: 1rem; }
.panel-body .facts {
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  gap: 0.9rem 2rem;
  max-width: 48rem;
  border-top: 1px solid var(--border);
}
.panel-body .block-label { margin: 1.05rem 0 0.6rem; }
.panel-body .chips { gap: 0.5rem; }
.panel-body .cards { gap: 0.75rem; max-width: 52rem; }
.panel-body .card { padding: 1rem 1.15rem; }
.panel-body .card h3 { font-size: 1.05rem; margin-bottom: 0.3rem; }
.panel-body .card p { font-size: 0.92rem; }
.panel-body .timeline { margin-top: 0.5rem; max-width: 26rem; }

/* Gallery lives in the About panel; the V1 two-row collage needs the room. */
.panel-body .gallery {
  max-width: min(100%, 46rem);
  margin: 0.5rem 0 0;
}

/* ---------- Desktop: About splits into text (left) + photography (right) ----------
   The V1 collage is a tall block, so the two-column split is what keeps the
   whole panel on one screen while the photos stay large. */
@media (min-width: 1024px) {
  #about .panel-body {
    display: grid;
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
    /* One row per left-column block (lede / facts / hobbies / chips) so the
       photo stack can span them all — without this, `1 / -1` only covers the
       single implicit row and the left blocks get pushed into extra rows. */
    grid-template-rows: repeat(4, auto);
    column-gap: clamp(1.5rem, 3.2vw, 3rem);
    align-content: start;
    align-items: start;
  }
  #about .panel-body > .lede { grid-column: 1; grid-row: 1; max-width: none; }
  #about .panel-body > .facts { grid-column: 1; grid-row: 2; max-width: none; }
  #about .panel-body > .block-hobbies { grid-column: 1; grid-row: 3; }
  #about .panel-body > .chips { grid-column: 1; grid-row: 4; }
  /* Label and photos travel together as one stacked block, so the heading sits
     right above the collage instead of being stranded up at the lede's height. */
  #about .panel-body > .about-photos {
    grid-column: 2;
    grid-row: 1 / -1;
    align-self: start;
    min-width: 0;
  }
  #about .panel-body > .about-photos .block-label { margin: 0.15rem 0 0.35rem; }
  #about .panel-body > .about-photos .gallery { max-width: none; margin-top: 0; }
}

/* ---------- Phones: photography moves up under the intro ----------
   On a phone the whole About panel is one scrolling column, and the gallery
   used to sit at the very bottom of it — below the fold, inside a scroll area
   that hides its own scrollbar — so the photos were effectively invisible.
   Lifting the block right under the lede is what actually fixes that; the
   collage is replaced by a single-photo carousel for the same reason (see the
   carousel section in style.css). Order: intro, photos, facts, hobbies. --- */
@media (max-width: 1023px) {
  #about .panel-body {
    display: flex;
    flex-direction: column;
  }
  #about .panel-body > .lede { order: 1; }
  #about .panel-body > .about-photos { order: 2; }
  #about .panel-body > .facts { order: 3; }
  #about .panel-body > .block-hobbies { order: 4; }
  #about .panel-body > .chips { order: 5; }
}

/* ---------- Narrow screens: tighter so the About panel still fits ---------- */
@media (max-width: 768px) {
  .panel-head h2 { font-size: 1.35rem; }
  .panel-head .section-num { margin-bottom: 0.15rem; }
  .panel-body .facts {
    margin-top: 0.9rem;
    padding-top: 0.9rem;
    gap: 0.7rem 1.5rem;
  }
  .panel-body .block-label { margin: 0.85rem 0 0.5rem; }
  .panel-body .gallery { margin-top: 0.4rem; }
}

/* ---------- No-JS fallback: unpin into a normal document flow ---------- */
html:not(.js) .deck { height: auto; }
html:not(.js) .deck-pin {
  position: static;
  height: auto;
  overflow: visible;
}
html:not(.js) .panel {
  position: static;
  opacity: 1;
  padding: 4rem 1.5rem;
  pointer-events: auto;
}
html:not(.js) .panel-head,
html:not(.js) .panel-body {
  position: static;
  left: auto;
  right: auto;
  top: auto;
  bottom: auto;
  transform: none;
  width: auto;
  max-width: var(--container);
  max-height: none;
  overflow: visible;
  -webkit-mask-image: none;
  mask-image: none;
  margin: 0 auto;
  text-align: center;
}
html:not(.js) .cube-stage {
  position: static;
  margin: 2.5rem auto;
  transform: none;
  opacity: 1;
}
