/* ==========================================================================
   ABOUT — page-specific layout. Everything visual comes from tokens/components.
   Figma: About (14:213)
   ========================================================================== */

/* Each design frame is one 1440×1024 "screen" */
.screen {
  min-height: min(100svh, 64rem);
  display: flex;
  flex-direction: column;
}

/* ---------- 1. Intro ---------- */
.about-intro {
  padding-top: var(--header-h); /* room for the fixed header, as in the Figma frame */
  padding-bottom: var(--section-y);
}
.about-intro__body {
  flex: 1;
  display: grid;
  place-items: center;
}
.about-intro__lead {
  max-width: var(--measure-lead);
  font-weight: var(--weight-regular);
}

/* ---------- 2–5. Story scroll (frames 2–5 as one pinned scene) ----------
   The feature image shrinks into the centre portrait, two more images wipe up
   over it, and each paragraph is revealed line by line beside it.
   Driven by scripts/story-scroll.js on wide screens; plain stacked flow below. */
.story-scroll {
  position: relative;
  height: 520svh; /* scroll length of the whole scene */
}
.story-scroll__stage {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(var(--grid-columns), minmax(0, 1fr));
  column-gap: var(--grid-gutter);
  align-items: center;
  padding-inline: var(--grid-margin); /* same columns as .page */
}
.story-scroll__window {
  position: absolute;
  inset: 0;
  z-index: 1; /* above the text: while large, the image covers it instead of overlapping */
  clip-path: inset(var(--section-y) var(--page-gutter)); /* frame 2: full-width feature */
  will-change: clip-path;
}
.story-scroll__layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.story-scroll__layer:not(:first-child) {
  clip-path: inset(100% 0 0 0); /* waits below, wipes up */
}
.story-scroll__layer .media {
  width: 100%;
  height: 100%;
  border-radius: 0;
  will-change: transform;
}
/* Portrait photos: cover their box (JS sizes it to the frame); keep the face in view
   while the first one is the wide feature */
.story-scroll__photo { display: block; object-fit: cover; object-position: 50% 12%; }
.story-scroll__chapter {
  position: relative;
  z-index: 0;
  grid-row: 1;
  grid-column: 2 / span 3;        /* left of the portrait */
  color: var(--color-text-muted);
}
.story-scroll__chapter[data-side="right"] { grid-column: 9 / span 3; }
.story-scroll__probe { grid-column: 5 / span 4; grid-row: 1; height: 0; } /* portrait columns, measured by JS */


/* Square-cornered imagery, as in the design */
.media--flat { border-radius: 0; }

/* ---------- 6. Experience ---------- */
.experience {
  padding-block: var(--section-y);
}
.experience__grid { align-items: start; }
.experience__intro { grid-column: 1 / span 3; }
.experience__grid .list { grid-column: 5 / span 8; }
.experience__media {
  grid-column: 1 / span 3;
  aspect-ratio: 336 / 377;
}

/* ---------- 7. Statement (Figma 16:245) — scripts/scroll-statement.js ----------
   The section is tall and its text stays pinned in view while the words darken with the scroll. */
.statement { position: relative; height: 240vh; }
.statement__sticky {
  position: sticky; top: 0; height: 100vh; height: 100svh;
  display: flex; align-items: center; justify-content: center;
  padding: 90px var(--grid-margin) 40px;                 /* Figma: 90 top, 40 bottom */
}
.statement__body { width: min(100%, 40.625rem); }   /* 650 */
.statement__word { display: inline-block; color: var(--color-text); opacity: var(--o, 1); }   /* inline-block: the words can glide */
/* The marks sit in the sentence after "Figma,": closed, they take no room; open, they push the words on */
.statement__marks {
  display: inline-flex; align-items: center; vertical-align: middle;
  width: 0;
  overflow: visible; pointer-events: none;
}
.statement.is-marked .statement__marks { width: calc(8px + 38.465px * 2 - 8.929px); padding-left: 8px; }
.statement__mark {
  width: 38.465px; height: 38.465px; border-radius: 50%; object-fit: contain; flex: none;   /* Figma 125:246 */
  opacity: 0; scale: 0.4;
  transition: opacity 300ms var(--ease-out), scale 650ms cubic-bezier(0.34, 1.4, 0.64, 1);
}
.statement__mark + .statement__mark { margin-left: -8.929px; }                         /* Figma: overlap */
.statement__mark--ring { border: 0.416px solid #fff; }                                   /* Figma: white hairline */
.statement.is-marked .statement__mark { opacity: 1; scale: 1; transition-delay: 120ms; }
.statement.is-marked .statement__mark + .statement__mark { transition-delay: 200ms; }

/* ---------- 8. Personal world ---------- */
.personal {
  padding-top: var(--section-y);
  padding-bottom: var(--space-40);
  row-gap: var(--space-40);
}
/* Figma 19:120: the statement in a centred 650 column, the note under it at the column's start */
.personal__intro {
  grid-column: 1 / -1;
  justify-self: center;
  width: min(100%, 40.625rem);             /* 650 */
  display: flex;
  flex-direction: column;
  gap: var(--space-60);
}
.personal__body {
  max-width: 20.9375rem;                   /* 335 */
  line-height: 1.3;
  color: var(--color-text-muted);
}
.personal__hobby {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-24);
}

/* Photo deck — Figma photo pile that fans into an arc on hover (scripts/photo-deck.js).
   Below 1025px it becomes a draggable slider. */
/* The fan may spread past the grid to the viewport edge (html clips horizontally) */
.deck { width: 100%; overflow: visible; }
.deck__stage {
  --card-max: 26.4375rem;                  /* 423 × 590 — the Figma photo pile */
  --card-w: min(var(--card-max), 42vw);
  --card-h: calc(var(--card-w) * 590 / 423);
  --lift: 64px;
  --deck-ease: cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  align-self: stretch;
  /* the lift headroom overlaps the gap above, so the resting pile sits close to the copy */
  margin-top: calc(var(--lift) * -1);
  /* JS sets --stage-h to clear the fan's lowest corner, so the caption never sits under it */
  height: var(--stage-h, calc(var(--card-h) * 1.32 + var(--lift)));
}
.deck__card {
  position: absolute;
  left: 50%;
  top: var(--lift);
  width: var(--card-w);
  height: var(--card-h);
  margin-left: calc(var(--card-w) / -2);
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transform-origin: 50% 100%;
  /* --dx / --dy / --dr: the swing, on top of the card's place in the pile or fan */
  transform: translate(calc(var(--x, 0px) + var(--dx, 0px)), calc(var(--y, 0px) + var(--dy, 0px))) rotate(calc(var(--r, 0deg) + var(--dr, 0deg))) scale(var(--s, 1));
  transition: transform 900ms var(--deck-ease) var(--delay, 0ms);
  will-change: transform;
}
.deck__card.is-lifted {
  transition: transform 600ms var(--deck-ease);
}
.deck__card .media { display: block; width: 100%; height: 100%; border-radius: 0; object-fit: cover; }
.deck__stage.is-instant .deck__card { transition: none; }
/* Swinging (scripts/photo-deck.js): the springs move the cards, so no transition; drags are the deck's */
.deck:not(.deck--slider) .deck__stage { touch-action: pan-y; }
.deck:not(.deck--slider) .deck__card { cursor: grab; }
.deck__stage.is-swinging,
.deck__stage.is-swinging .deck__card { cursor: grabbing; }
.deck__stage.is-swung .deck__card { transition: none; } /* held, and until it settles */
.deck:not(.deck--slider) .deck__card .media { pointer-events: none; -webkit-user-drag: none; }

/* Slider (≤ 1024px): native swipe with snap; JS adds mouse drag + centre detection */
.deck--slider .deck__stage {
  --card-w: min(70vw, 18.75rem);
  margin-top: 0;                                       /* the pile's lift headroom isn't needed here: no overlap with the copy */
  display: flex;
  gap: var(--space-16);
  height: auto;
  margin-inline: calc(var(--grid-margin) * -1);        /* bleed to the screen edges */
  padding: 0 calc(50% - var(--card-w) / 2 + var(--grid-margin));
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
}
.deck--slider .deck__stage::-webkit-scrollbar { display: none; }
.deck--slider .deck__stage.is-dragging { scroll-snap-type: none; cursor: grabbing; }
.deck--slider .deck__card {
  position: relative;
  left: auto;
  top: auto;
  flex: none;
  margin: 0;
  transform: none;
  transition: none;
  scroll-snap-align: center;
}
.deck--slider .deck__card img,
.deck--slider .deck__card .media { pointer-events: none; -webkit-user-drag: none; }
.deck--slider { overflow-x: visible; }

/* Captions stack in one cell so the old one can leave while the new one arrives */
.deck__caption {
  display: grid;
  justify-items: center;
  min-height: 5rem;
}
.deck__caption > * {
  grid-area: 1 / 1;
  max-width: var(--measure-narrow);
}

/* ---------- Responsive ---------- */
@media (max-width: 64rem) {
  /* Story scroll becomes a normal stacked section: image, text, image, text… */
  .story-scroll { height: auto; }
  .story-scroll__stage {
    position: static;
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-24);
    padding-block: var(--section-y);
  }
  .story-scroll__window { display: contents; }
  .story-scroll__layer,
  .story-scroll__layer:not(:first-child) {
    position: static;
    clip-path: none;
    width: min(100%, 26.4375rem);
    aspect-ratio: 423 / 590;
  }
  .story-scroll__layer .media { transform: none; }
  .story-scroll__chapter { max-width: 26.4375rem; margin-bottom: var(--space-40); }
  .story-scroll__probe { display: none; }
  .story-scroll__layer:nth-child(1) { order: 1; }
  .story-scroll__chapter[data-chapter="0"] { order: 2; }
  .story-scroll__layer:nth-child(2) { order: 3; }
  .story-scroll__chapter[data-chapter="1"] { order: 4; }
  .story-scroll__layer:nth-child(3) { order: 5; }
  .story-scroll__chapter[data-chapter="2"] { order: 6; }
  .story-scroll .line { transform: none; }

  .experience__grid { row-gap: var(--space-40); }
  .experience__intro,
  .experience__grid .list { grid-column: 1 / -1; }
  .experience__media { grid-column: 1 / span 4; }

}

@media (max-width: 40rem) {
  .personal__intro { gap: var(--space-40); }

  /* company and year on one line, the role under the company, all left-aligned */
  .list-row {
    grid-template-columns: 1fr auto;
    row-gap: var(--space-4);
  }
  .list-row > :nth-child(2) {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: start;
    width: auto;
    color: var(--color-text-muted);
  }
  .list-row > :first-child { grid-column: 1; grid-row: 1; }
  .list-row > :last-child { grid-column: 2; grid-row: 1; }
}
