/* By Damian — Section 2: About me.
   Calmer than the hero: the protagonist is Damian, not the effects.
   Starts on --next-bg, the color the phone screen turned into, so there is no cut.

   html.about-sub (set by about.js): the lines work like subtitles. The stage stays on
   screen while the track scrolls, and one line at a time shows in the same spot.
   Without JS the lines are a plain list.
   html.about-anim (never with reduced motion or ?static): the soft transitions. */

.about {
  position: relative;
  background: var(--next-bg);
  color: var(--bg);
  --about-ink-2: #6E6E69; /* small text on bone (the concrete grey is too light here) */
  --reel-h: min(calc(100svh - 230px), 720px);
}

/* ---------- Stage ---------- */
.about__stage {
  display: flex;
  flex-direction: column;
  padding: 88px clamp(16px, 4vw, 56px) 64px;
}

/* Small title at the top of the section. */
.about__label {
  margin: 0 0 clamp(20px, 3.5svh, 40px);
  color: var(--about-ink-2);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-align: center;
  text-transform: uppercase;
}

/* Desktop: video on one side, subtitles on the other. */
.about__inner {
  display: grid;
  grid-template-columns: auto minmax(0, 560px);
  align-items: center;
  justify-content: center;
  gap: clamp(40px, 6vw, 120px);
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
}

/* With JS: the stage is one screen tall and stays put while the track scrolls.
   The track's height is how long the subtitles last: one screen + ~0.6 screen per line. */
.about-sub .about__track { height: 400vh; height: 400svh; }
.about-sub .about__stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  justify-content: center;
  padding-top: 72px;
  padding-bottom: 32px;
}

/* ---------- The video ---------- */
.reel {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* Same shape as the phone screen the visitor just went into: 9:16, rounded corners. */
.reel__frame {
  position: relative;
  height: var(--reel-h);
  aspect-ratio: 9 / 16;
  border-radius: clamp(22px, 2.4vw, 34px);
  background: var(--bg);
  overflow: hidden;
  isolation: isolate;
  box-shadow:
    0 34px 64px -30px rgba(31, 31, 31, 0.5),
    0 12px 24px -14px rgba(31, 31, 31, 0.28);
}

/* Placeholder until the video exists: faint blueprint grid (the brand's plan) + the name. */
.reel__placeholder {
  position: absolute;
  inset: 0;
  transition: opacity 0.5s var(--ease);
}
.reel__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(138, 138, 133, 0.13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(138, 138, 133, 0.13) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: center center;
  -webkit-mask-image: radial-gradient(ellipse 75% 60% at 50% 50%, #000 30%, transparent 100%);
  mask-image: radial-gradient(ellipse 75% 60% at 50% 50%, #000 30%, transparent 100%);
}
.reel__name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 9%;
  text-align: center;
  color: var(--ink);
  font-family: var(--font-display);
  font-stretch: var(--display-stretch);
  font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking);
  font-size: clamp(1.2rem, 2vw, 1.8rem);
}

.reel__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--bg);
  opacity: 0;
  transition: opacity 0.4s var(--ease);
}
.reel.has-cover .reel__video,
.reel.is-started .reel__video { opacity: 1; }
.reel.has-cover .reel__placeholder,
.reel.is-started .reel__placeholder { opacity: 0; }

/* Yellow play button: the accent, used once. */
.reel__play {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  transition: transform 0.35s var(--ease), opacity 0.3s var(--ease);
}
.reel__play svg { width: 28px; height: 28px; margin-left: 3px; }
.reel__ring {
  position: absolute;
  inset: 0;
  border: 2px solid var(--accent);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}
@media (hover: hover) and (pointer: fine) {
  .reel__play:hover { transform: scale(1.06); }
}
.reel.is-playing .reel__play {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9);
}
/* While playing, tapping the video pauses it. */
.reel.is-started .reel__video { cursor: pointer; }

.reel__sound {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 2;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(237, 235, 230, 0.18);
  border-radius: 50%;
  background: rgba(31, 31, 31, 0.6);
  color: var(--ink);
  cursor: pointer;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.reel__sound[hidden] { display: none; }
.reel__sound svg { width: 20px; height: 20px; }
.reel__sound-off,
.reel__sound.is-muted .reel__sound-on { display: none; }
.reel__sound.is-muted .reel__sound-off { display: block; }

/* "Damian · Guadalajara, Mexico · Tecnológico de Monterrey" */
.about__id {
  color: var(--about-ink-2);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-align: center;
}
.about__id span { white-space: nowrap; }
.about__id i { margin: 0 0.45em; font-style: normal; opacity: 0.7; }

/* ---------- The subtitles ---------- */
.say {
  list-style: none;
  margin: 0;
  padding: 0;
}
.say__line {
  font-family: var(--font-display);
  font-stretch: var(--display-stretch);
  font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking);
  font-size: clamp(1.6rem, 2.5vw, 2.6rem);
  line-height: 1.1;
  text-wrap: balance;
}
.say__line + .say__line { margin-top: 0.9em; }

/* One spot: every line sits in the same grid cell, so the spot is as tall as the longest
   line and nothing jumps when they change. Only the current one is visible. */
.about-sub .say { display: grid; }
.about-sub .say__line {
  grid-area: 1 / 1;
  align-self: end; /* like a caption: short lines sit right above the ticks */
  margin: 0;
  opacity: 0;
  visibility: hidden;
}
.about-sub .say__line.is-on {
  opacity: 1;
  visibility: visible;
}

/* The yellow marker behind the key words (solid fill, drawn left to right). */
.say mark {
  color: inherit;
  background: linear-gradient(var(--accent), var(--accent)) no-repeat 0 88% / 100% 0.4em;
  padding: 0 0.04em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* Where we are: five short ticks, the current one dark. */
.say__ticks { display: none; }
.about-sub .say__ticks {
  display: flex;
  gap: 6px;
  margin-top: clamp(20px, 3svh, 32px);
}
.say__ticks i {
  width: 18px;
  height: 3px;
  border-radius: 2px;
  background: rgba(31, 31, 31, 0.16);
  transition: background-color 0.4s var(--ease);
}
.say__ticks i.is-on { background: var(--bg); }

/* ---------- Full script ---------- */
.script__toggle {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 10px;
  min-height: 48px;
  margin-top: clamp(24px, 4svh, 44px);
  padding: 0 22px;
  border: 1px solid rgba(31, 31, 31, 0.25);
  border-radius: 999px;
  background: transparent;
  color: var(--bg);
  font: 600 0.95rem/1 var(--font-body);
  cursor: pointer;
  transition: border-color 0.25s var(--ease);
}
html:not(.js) .script__toggle { display: none; }
.script__label {
  padding-bottom: 3px;
  background: linear-gradient(var(--accent), var(--accent)) no-repeat 0 100% / 0% 2px;
  transition: background-size 0.4s var(--ease);
}
.script__toggle:hover { border-color: rgba(31, 31, 31, 0.45); }
.script__toggle:hover .script__label { background-size: 100% 2px; }
.script__toggle svg {
  width: 18px;
  height: 18px;
  transition: transform 0.4s var(--ease);
}
.script__toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

/* The script unfolds below the stage. Folded with JS (always in the page, so search
   engines read it); open without JS. */
.script {
  scroll-margin-top: 72px; /* clears the top bar when the button brings the visitor here */
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 56px);
}
.js .script {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.6s var(--ease);
}
.js .script > .script__body {
  min-height: 0;
  overflow: hidden;
  visibility: hidden;
  transition: visibility 0s linear 0.6s;
}
.js .script.is-open { grid-template-rows: 1fr; }
.js .script.is-open > .script__body {
  visibility: visible;
  transition-delay: 0s;
}

.script__body {
  max-width: 62ch;
  margin: 0 auto;
  color: #3A3A38;
  font-size: 1.08rem;
  line-height: 1.7;
}
.script__body p {
  padding-left: 22px;
  border-left: 2px solid rgba(31, 31, 31, 0.14);
}
.script__body p:first-child { margin-top: 8px; }
.script__body p + p { padding-top: 1em; }
.script__body p:last-child { margin-bottom: 96px; }

/* ---------- Motion (never with reduced motion or ?static) ---------- */
.about-anim:not(.is-static) .reel {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 1s var(--ease), transform 1.2s var(--ease);
}
.about-anim:not(.is-static) .about.is-in .reel {
  opacity: 1;
  transform: none;
}

/* Subtitle change: the old line lifts away, the new one rises into place. */
.about-anim:not(.is-static) .say__line {
  transform: translateY(18px);
  transition: opacity 0.45s var(--ease), transform 0.7s var(--ease), visibility 0s linear 0.45s;
}
.about-anim:not(.is-static) .say__line.is-on {
  transform: none;
  transition: opacity 0.6s var(--ease) 0.12s, transform 0.8s var(--ease) 0.12s, visibility 0s;
}
.about-anim:not(.is-static) .say__line.is-past { transform: translateY(-14px); }
.about-anim:not(.is-static) .say mark {
  background-size: 0% 0.4em;
  transition: background-size 0.9s var(--ease) 0.45s;
}
.about-anim:not(.is-static) .say__line.is-on mark { background-size: 100% 0.4em; }

/* A slow sonar ring around the play button (echo of the hero's call). */
.about-anim:not(.is-static) .reel:not(.is-playing) .reel__ring {
  animation: reel-ring 2.8s var(--ease) infinite;
}
@keyframes reel-ring {
  0% { opacity: 0.55; transform: scale(1); }
  70%, 100% { opacity: 0; transform: scale(1.7); }
}

/* ---------- Phones and narrow screens: stacked, video first, subtitles below ---------- */
@media (max-width: 860px) {
  .about { --reel-h: clamp(220px, calc(100svh - 420px), 52svh); }
  .about__stage { padding: 80px 16px 48px; }
  .about__label { margin-bottom: 14px; }
  .about__inner {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 22px;
  }
  .reel { gap: 10px; }
  .about__id { font-size: 0.72rem; }
  .about__text {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .say { width: 100%; }
  .say__line { font-size: clamp(1.15rem, 5.2vw, 1.45rem); line-height: 1.16; }
  .about-sub .say__ticks { margin-top: 14px; }
  .script__toggle {
    align-self: center;
    margin-top: 16px;
    min-height: 42px;
    font-size: 0.88rem;
  }
  .about-sub .about__stage { padding-top: 64px; padding-bottom: 20px; }
  .about-sub .about__track { height: 350vh; height: 350svh; } /* ~0.5 screen per line */

  /* While #about is under the top bar, the bar gets a bone backing so the brand stays
     readable when the video frame scrolls under it. Same color as the page otherwise. */
  .topbar { transition: color 0.3s var(--ease), background-color 0.3s var(--ease); }
  .topbar.over-about {
    background-color: rgba(237, 235, 230, 0.88);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
  }
}
