/* Portrait and about layout */
/* ── Portrait + About wrapper (nuageboi pattern) ── */
/* About and portrait scroll section ---------------------------------------- */
.portrait-about-wrapper {
  position: relative;
  z-index: 2;
  /* No negative margin — hero-section's spacer is now sized to match the
     curtain trigger threshold so portrait section starts immediately
     after the curtain finishes covering. */
  background: #000;
  --portrait-media-y: 0vh;
  --portrait-enter: 0;
  --portrait-text-enter: 0;
  --portrait-progress: 0;
  --portrait-exit: 0;
}

.portrait-about-wrapper::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -22svh;
  z-index: 3;
  height: 36svh;
  pointer-events: none;
  background: none;
  opacity: 0;
}

.portrait-canvas {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  isolation: isolate;
  background: #000;
}

.portrait-canvas::after {
  display: none;
}

.portrait-video,
.portrait-image {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(62vw, 840px);
  height: min(94vh, 960px);
  object-fit: contain;
  object-position: center;
  /* Darkness reveal: the first frame stays centered while contrast and focus wake up. */
  opacity: max(0, calc(var(--portrait-enter) * 1.0 - var(--portrait-exit) * 0.98));
  filter:
    saturate(0.94)
    contrast(1.14)
    brightness(calc(0.08 + var(--portrait-enter) * 0.9 - var(--portrait-exit) * 0.22))
    blur(calc((1 - var(--portrait-enter)) * 8px + var(--portrait-exit) * 10px));
  /* No vertical lift - keep the framed portrait at geometric center.
     Source frame's face already sits close enough to center; pushing up
     was overshooting and reading "too high." */
  transform:
    translate3d(-50%, calc(-50% + var(--portrait-media-y)), 0)
    scale(calc(1.012 - var(--portrait-enter) * 0.012 - var(--portrait-exit) * 0.012));
  transform-origin: 50% 50%;
  will-change: transform, filter, opacity;
}

.portrait-video {
  z-index: 0;
  opacity: max(0, calc(var(--portrait-enter) * 1.0 - var(--portrait-exit) * 1));
  filter:
    saturate(0.96)
    contrast(1.14)
    brightness(calc(0.08 + var(--portrait-enter) * 0.9 - var(--portrait-exit) * 0.24))
    blur(calc((1 - var(--portrait-enter)) * 8px + var(--portrait-exit) * 12px));
}

body.about-centered-reveal-active .portrait-video,
body.about-centered-reveal-active .portrait-image {
  position: fixed;
  left: 50vw;
  top: 50svh;
  transform:
    translate3d(-50%, -50%, 0)
    scale(calc(1.012 - var(--portrait-enter) * 0.012 - var(--portrait-exit) * 0.012));
}

body:not(.about-centered-reveal-active) .portrait-about-wrapper:not(.is-portrait-reveal-armed):not(.is-portrait-reveal-complete) .portrait-video,
body:not(.about-centered-reveal-active) .portrait-about-wrapper:not(.is-portrait-reveal-armed):not(.is-portrait-reveal-complete) .portrait-image {
  opacity: 0 !important;
}

.portrait-image {
  z-index: 0;
  opacity: max(0, calc(var(--portrait-enter) * 0.96 - var(--portrait-exit) * 0.98));
}

.portrait-about-wrapper.is-portrait-video-ready .portrait-image {
  opacity: 0;
}

.portrait-overlay {
  display: none;
}

/* ── About rows (scrolls over portrait video) ──
   Spacer length = total scroll distance for the about scene. The portrait
   reveal/face-turn/text reveal all map onto this travel. */
.portrait-spacer {
  height: 160vh;
}

.about-rows {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  align-items: center;
  margin: 0;
  padding: clamp(86px, 10vh, 126px) clamp(34px, 4vw, 82px) clamp(92px, 12vh, 138px);
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  pointer-events: none;
}

.about-curtain {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100%;
  z-index: 12;
  pointer-events: none;
  background: #000;
  transform: translateY(108%);
  opacity: 1;
  transition: transform 1650ms cubic-bezier(0.62, 0, 0.24, 1);
  will-change: transform;
}

.portrait-canvas.is-about-curtain-down .about-curtain {
  transform: translateY(0);
}

.about-layout {
  display: grid;
  grid-template-columns: minmax(330px, 0.72fr) minmax(460px, 0.58fr);
  gap: clamp(96px, 13vw, 250px);
  align-items: center;
  width: 100%;
  max-width: 1840px;
  margin-inline: auto;
  padding-inline: 0;
  transform:
    translate3d(0, calc((1 - var(--portrait-text-enter)) * 10vh - var(--portrait-exit) * 10vh), 0)
    scale(calc(0.988 + var(--portrait-text-enter) * 0.012 - var(--portrait-exit) * 0.015));
  opacity: max(0, min(1, calc(0.04 + var(--portrait-text-enter) * 1.18 - var(--portrait-exit) * 1.08)));
  transform-origin: left bottom;
  will-change: transform, opacity;
}

.about-rows [data-reveal]:not(.about-role),
.about-rows [data-reveal].is-revealed:not(.about-role) {
  opacity: 1;
  transform: none;
  transition: none;
}

.about-rows .scroll-type-glyph {
  opacity: 1 !important;
  transform: none !important;
}

.about-left {
  display: grid;
  gap: clamp(18px, 2.7vh, 30px);
  align-content: center;
  max-width: 42ch;
  padding-top: 0;
}

.about-heading {
  margin: 0;
  font-size: clamp(2.4rem, 4.5vw, 5rem);
  line-height: 1.1;
  letter-spacing: -0.04em;
  color: rgba(248, 245, 239, 0.97);
  text-align: left;
  white-space: nowrap;
  max-width: none;
}

html[lang="zh-CN"] .about-heading {
  font-family: "MiSans", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: clamp(2.1rem, 3.2vw, 3.8rem);
  line-height: 1.16;
  letter-spacing: 0;
  font-weight: 600;
  max-width: none;
  word-break: keep-all;
}

.about-role {
  --flip-distance: -1lh;
  --flip-duration: 1700ms;
  --flip-delay-factor: 34ms;
  --flip-hover-color: #35d9c0;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: clamp(2px, 0.8vh, 10px) 0 0;
  color: rgba(246, 242, 234, 0.96);
  font-family: "MiSans", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: clamp(4.35rem, 6.65vw, 7.9rem);
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: 0;
  white-space: nowrap;
  word-break: keep-all;
  pointer-events: auto;
  opacity: max(0, min(1, calc(var(--portrait-text-enter) * 2.4 - 0.28)));
  transform:
    translate3d(0, calc((1 - var(--portrait-text-enter)) * 1.08em), 0)
    scale(calc(0.74 + var(--portrait-text-enter) * 0.26), calc(2.15 - var(--portrait-text-enter) * 1.15));
  transform-origin: 50% 0%;
  will-change: opacity, transform;
}

.about-scroll-reveal-unit {
  transform-origin: 0% 50%;
  will-change: opacity, filter, transform;
}

.about-right .about-scroll-reveal-unit {
  transform-origin: 100% 50%;
}

.about-heading .about-scroll-reveal-unit,
.about-lead .about-scroll-reveal-unit,
.about-detail .about-scroll-reveal-unit {
  display: inline-block;
}

.about-role > span:last-child {
  margin-left: 0;
}

.about-role.flip-ready,
.about-role.js-flip-text {
  cursor: default;
}

.about-role .flip-word {
  display: flex;
  width: fit-content;
  overflow: hidden;
  line-height: 0.98;
  color: rgba(246, 242, 234, 0.96);
}

.about-role .flip-char {
  display: inline-block;
  color: currentColor;
  transform: translate3d(0, 0, 0);
  transition:
    transform var(--flip-duration)
      linear(0, 0.011 0.6%, 0.041 1.2%, 0.173 2.6%, 0.894 7.4%, 1.128 9.3%, 1.271 11.1%, 1.311 12%, 1.333 13%, 1.328 14.4%, 1.286 15.9%, 1.031 21%, 0.95 23%, 0.907 24.7%, 0.888 26.5%, 0.89 27.9%, 0.904 29.4%, 1.034 42.5%, 0.997 49.3%, 0.987 53.3%, 1.004 66.5%, 1)
      calc(var(--flip-index) * var(--flip-delay-factor));
  will-change: transform;
}

.about-role:hover .flip-char,
.about-role.is-flipping .flip-char,
.about-role:focus-within .flip-char {
  transform: translate3d(0, var(--flip-distance), 0);
}

@media (prefers-reduced-motion: reduce) {
  .about-role {
    opacity: 1;
    transform: none;
  }

  .about-role .flip-char {
    transition: color 180ms ease;
  }

  .about-role:hover .flip-char,
  .about-role.is-flipping .flip-char,
  .about-role:focus-within .flip-char {
    color: var(--flip-hover-color);
    transform: none;
  }
}

.about-right {
  --about-copy-width: min(34rem, 100%);
  display: grid;
  gap: clamp(18px, 2.5vh, 28px);
  width: min(34rem, 100%);
  max-width: 100%;
  padding: clamp(8px, 1.8vh, 18px) 0 0;
  justify-self: end;
  justify-items: stretch;
}

/* About copy and skills */
.about-lead {
  color: rgba(246, 242, 234, 0.9);
  width: var(--about-copy-width);
  max-width: 100%;
  font-size: clamp(1rem, 1.14vw, 1.14rem);
  line-height: 1.78;
  letter-spacing: 0.005em;
  text-align: justify;
  text-align-last: left;
  text-wrap: pretty;
}

.about-detail {
  color: rgba(246, 242, 234, 0.62);
  width: var(--about-copy-width);
  max-width: 100%;
  font-size: 0.92rem;
  line-height: 1.78;
  letter-spacing: 0.015em;
  text-align: justify;
  text-align-last: left;
  text-wrap: pretty;
}

html[lang="zh-CN"] .about-lead {
  font-family: "MiSans", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-weight: 500;
  font-size: clamp(1.02rem, 1vw, 1.12rem);
  line-height: 1.9;
  letter-spacing: 0.035em;
  max-width: 100%;
  word-break: keep-all;
  text-align: justify;
  text-align-last: left;
}

html[lang="zh-CN"] .about-detail {
  font-family: "MiSans", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-weight: 400;
  font-size: 0.88rem;
  line-height: 1.92;
  letter-spacing: 0.03em;
  max-width: 100%;
  word-break: keep-all;
  text-align: justify;
  text-align-last: left;
}

.about-skills {
  margin-top: clamp(4px, 1.2vh, 14px);
}

.about-skills-label {
  margin: 0 0 12px;
  font-size: 0.68rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(235, 231, 224, 0.32);
}

.about-skills-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 8px;
  max-width: 38em;
}

.about-skills-list span {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  font-size: 0.64rem;
  letter-spacing: 0.045em;
  color: rgba(235, 231, 224, 0.52);
  background: rgba(255, 255, 255, 0.025);
  transition: border-color 200ms ease, color 200ms ease;
}

.about-skills-list span:hover {
  border-color: rgba(0, 204, 189, 0.4);
  color: rgba(0, 204, 189, 0.9);
}

/* About responsive tablet */
@media (max-width: 1120px) {
  .about-rows {
    padding-inline: clamp(30px, 5vw, 64px);
  }

  .about-layout {
    grid-template-columns: minmax(300px, 0.78fr) minmax(340px, 0.62fr);
    gap: clamp(42px, 6vw, 86px);
  }

  .about-role {
    font-size: clamp(4.2rem, 8.4vw, 6.6rem);
  }

  .about-right {
    max-width: 40ch;
  }
}

/* About responsive mobile */
@media (max-width: 760px) {
  .portrait-about-wrapper {
    --portrait-media-y: 0vh;
  }

  .about-rows {
    min-height: auto;
    padding: 86px 22px 82px;
  }

  .about-layout {
    grid-template-columns: 1fr;
    gap: 34px 0;
    align-items: end;
    transform:
      translate3d(0, calc((1 - var(--portrait-text-enter)) * 10vh - var(--portrait-exit) * 10vh), 0)
      scale(calc(0.99 + var(--portrait-text-enter) * 0.01 - var(--portrait-exit) * 0.014));
  }

  .about-heading {
    max-width: none;
  }

  .about-role {
    font-size: clamp(3.7rem, 18vw, 6.2rem);
  }

  .about-right {
    justify-self: start;
    max-width: min(34ch, 100%);
  }
}

/* About text interactions */
.scrambled-text {
  cursor: crosshair;
}

.about-rows .scrambled-text,
.about-rows .scramble-char {
  pointer-events: auto;
}

.scramble-char {
  display: inline-block;
  white-space: pre;
  will-change: contents;
}


/* Section scroll typography: starts from About and blurs the text itself. */
.scroll-type-text {
  position: relative;
  isolation: isolate;
}

.scroll-type-glyph {
  display: inline-block;
  --type-focus: 1;
  --type-blur: 0px;
  --type-y: 0px;
  --type-opacity: 1;
  white-space: pre;
  opacity: var(--type-opacity);
  transform: translate3d(0, var(--type-y), 0);
  will-change: opacity, transform;
  transition:
    opacity 120ms linear,
    transform 260ms cubic-bezier(0.19, 1, 0.22, 1);
}
