/* Home, first screen (direction B §4.1, §4.2, §5.2, §5.3): statement across a moving border, the reel, the definition line, both doors. */

.kw {
  display: inline-block;
  white-space: nowrap;
}

.hero {
  position: relative;
  display: grid;
  grid-template-rows: var(--hdr) minmax(0, 1fr) auto auto;
  min-height: 100svh;
}

/* ───────── The field: statement + reel + crest. Level geometry in px of the field. ─────────
   --Y is the border's y. The CSS formula is the first paint (--level .5) and the held level;
   js/level.js overwrites the five transforms per frame. Ink bounds come from the font: marks reach .725em above the
   baseline, descenders .21em below; the baseline of the straddling line sits --bl em below the statement top. */
.field {
  --fs: 64px;
  --st: 8px;
  --n: 2;
  --stroke: 1.5px;
  --ui: 136px;
  --bl: calc(.18 + var(--n) * .92 + .794);
  --yb: calc(var(--st) + var(--fs) * (var(--bl) + .21));
  --yt: calc(var(--st) + var(--fs) * (var(--bl) - .725));
  --Y: calc(var(--yb) - var(--level) * (var(--yb) - var(--yt)));
  position: relative;
  overflow: clip;
  min-height: calc(var(--st) + var(--fs) * 3.86 + var(--ui));
}
/* Phone and tablet: four lines; the size is what is left of the screen after header, definition line (60), both doors (212) and the reel credit. */
@media (max-width: 1023.98px) {
  .field {
    --fs: clamp(
      48px,
      min(calc((100svh - var(--hdr) - 272px - var(--st) - var(--ui)) / 3.86), calc((100vw - 2 * var(--margin)) / 5.3)),
      64px
    );
  }
}
@media (min-width: 640px) and (max-width: 1023.98px) {
  .field {
    --fs: clamp(
      48px,
      min(calc((100svh - var(--hdr) - 272px - var(--st) - var(--ui)) / 3.86), calc((100vw - 2 * var(--margin)) / 5.3)),
      96px
    );
  }
}
@media (min-width: 1024px) {
  .field {
    --fs: min(10.2vw, 9.5rem);
    --st: 32px;
    --n: 1;
    --stroke: 2px;
    min-height: calc(var(--st) + var(--fs) * 2.09 + 160px);
  }
}

.win {
  position: absolute;
  inset: 0;
  overflow: clip;
  will-change: transform;
}
.win > .in {
  position: absolute;
  inset: 0;
  will-change: transform;
}
.win--below {
  transform: translateY(var(--Y));
}
.win--below > .in {
  transform: translateY(calc(var(--Y) * -1));
}
.win--above {
  transform: translateY(calc(var(--Y) - 100%));
}
.win--above > .in {
  transform: translateY(calc(100% - var(--Y)));
}

/* One statement, two copies (§5.3): same face, size, breaks, position. The contour copy is the real h1. */
.stmt {
  position: absolute;
  left: var(--frame);
  top: var(--st);
  margin: 0;
  padding-top: 0.18em;
  font-family: var(--font-statement);
  font-weight: 900;
  font-size: var(--fs);
  line-height: 0.92;
  letter-spacing: 0;
  font-kerning: normal;
  font-synthesis: none;
  text-rendering: geometricPrecision;
  white-space: nowrap;
  word-spacing: 0.1em;
}
.stmt .line {
  display: block;
}
.stmt br {
  display: none;
}
@media (max-width: 1023.98px) {
  .stmt br {
    display: inline;
  }
}
.stmt--line {
  color: transparent;
  -webkit-text-stroke: var(--stroke) var(--violet);
}
.stmt--fill {
  color: var(--vermilion);
  z-index: 2;
}

/* The reel: a fixed box that the border uncovers; the picture never moves. */
.reel {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--yt);
  bottom: 0;
  background: var(--night);
}
.reel video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 40%;
}
.reel::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 160px;
  background: linear-gradient(transparent, rgba(12, 10, 11, 0.75));
}
/* Legibility over any frame: a shade inside the reel, under the fill copy, the height of the statement's visible line (the frame itself is unchanged). */
.reel::before {
  content: '';
  position: absolute;
  z-index: 1;
  left: 0;
  right: 0;
  top: 0;
  height: calc(var(--fs) * 1.25);
  background: linear-gradient(rgba(12, 10, 11, 0.92) 0%, rgba(12, 10, 11, 0.92) 80%, rgba(12, 10, 11, 0) 100%);
  -webkit-mask-image: linear-gradient(to right, #000 0%, #000 78%, transparent 100%);
  mask-image: linear-gradient(to right, #000 0%, #000 78%, transparent 100%);
}
@media (min-width: 1024px) {
  .reel video {
    object-position: 50% 38%;
  }
  .reel::after {
    height: 180px;
  }
}
@media (max-width: 1023.98px) {
  .reel::before {
    height: calc(var(--fs) * 2);
  }
}

.crest {
  --crest: url(#mix);
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  transform: translateY(var(--Y));
  will-change: transform;
}

/* Reel credit and controls (they stay put; only the film and the fill copy sit inside the windows). */
.reel-ui {
  position: absolute;
  z-index: 2;
  left: var(--frame);
  right: var(--frame);
  bottom: 14px;
  display: grid;
  justify-items: start;
  gap: 8px;
  pointer-events: none;
}
.reel-ui > * {
  pointer-events: auto;
}
/* Legibility of the card over a bright frame: a local shade behind the title and credit only, fading in from its left and running on to the window's right edge. */
.reel-ui::before,
.reel-ui::after {
  content: '';
  position: absolute;
  z-index: -1;
  top: -96px;
  bottom: -14px;
  background: linear-gradient(to top, rgba(12, 10, 11, 0.84), rgba(12, 10, 11, 0.62) 55%, rgba(12, 10, 11, 0));
  pointer-events: none;
}
.reel-ui::before {
  left: -30%;
  right: 0;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 35%);
  mask-image: linear-gradient(to right, transparent, #000 35%);
}
/* A percentage in the right offset would resolve against the card's own width, so the reach to the window edge is written in viewport units. */
.reel-ui::after {
  left: 100%;
  right: calc(-1 * max(var(--margin), (100vw - var(--page)) / 2));
}
.reel-title {
  margin: -0.18em 0;
  font-size: 20px;
  transition: opacity 160ms linear;
}
.reel-credit {
  --hh: 28px;
  --tab-bg: var(--vermilion);
  --tab-fg: var(--on-vermilion);
  height: auto;
  min-height: var(--hh);
  padding-block: 6px;
  white-space: normal;
  font-size: 11px;
  line-height: 1.25;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-variation-settings:
    'wdth' 112,
    'wght' 600;
  transition: opacity 160ms linear;
}
.reel-credit::before {
  pointer-events: none;
}
.reel-title.is-swap,
.reel-credit.is-swap {
  opacity: 0;
}
.hero[data-branch='business'] .reel-credit {
  --tab-bg: var(--violet-deep);
  --tab-fg: var(--sheet);
}
.reel-ctl {
  --hh: 40px;
  display: flex;
  align-items: center;
  gap: 0;
  margin-left: -6px;
  touch-action: pan-y;
}
.play {
  margin: 0 6px;
}
.play:focus-visible {
  outline-offset: 3px;
}

/* The film band: six upright strings, one per film. Each is a violet contour slot with its string inside; the film playing fills its slot with
   the branch colour from below as the chapter plays (js/films.js writes the fill), and its string turns to light ink over the mass.
   A finger or pointer swept across the band strums it (js/strings.js); a tap or click selects the film. */
.chap,
.sound-cue {
  --w: 32px;
  --h: 56px;
  --num: 18px;
  flex: none;
  width: 44px;
  height: 64px;
  display: grid;
  place-items: center;
}
.chap {
  position: relative;
}
.chap__tab {
  position: relative;
  display: block;
  width: var(--w);
  height: var(--h);
  font-size: 12px;
  color: var(--night-ink);
  font-variation-settings:
    'wdth' 100,
    'wght' 800;
  font-variant-numeric: tabular-nums;
}
.chap__tab::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--violet);
  --k: 1.5px;
  clip-path: polygon(
    evenodd,
    0 0,
    100% 0,
    100% 100%,
    0 100%,
    0 0,
    var(--k) var(--k),
    var(--k) calc(100% - var(--k)),
    calc(100% - var(--k)) calc(100% - var(--k)),
    calc(100% - var(--k)) var(--k),
    var(--k) var(--k)
  );
}
.chap__num,
.chap__fill > i > span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--num);
  line-height: var(--num);
  text-align: center;
}
.chap__fill {
  position: absolute;
  inset: 0;
  overflow: hidden;
  transform: translateY(100%);
  will-change: transform;
}
.chap__fill > i {
  position: absolute;
  inset: 0;
  display: block;
  transform: translateY(-100%);
  will-change: transform;
  background: var(--vermilion);
  color: var(--on-vermilion);
  font-style: normal;
}
.chap[data-branch='business'] .chap__fill > i {
  background: var(--violet-deep);
  color: var(--sheet);
}
.reel-ctl .chap .chap__string {
  --amax: 7;
  --crest: var(--violet);
  --len: calc(var(--h) - var(--num) - 8px);
  position: absolute;
  left: 50%;
  top: 5px;
}
.chap[aria-current='true'] .chap__string {
  --crest: var(--night-ink);
}
.chap:focus-visible {
  outline: none;
}
.chap:focus-visible .chap__tab {
  outline: 2px solid var(--night-ink);
  outline-offset: 4px;
}
@media (hover: hover) {
  .chap:hover .chap__tab::before {
    background: var(--night-ink);
  }
}

.hero__def {
  margin: 0;
  padding: 8px var(--margin);
  font-size: 15px;
  line-height: 1.45;
  color: var(--night-muted);
  max-width: 46ch;
}

@media (min-width: 1024px) {
  .hero {
    grid-template-rows: var(--hdr) minmax(0, 1fr) 180px;
  }
  .reel-ui {
    left: auto;
    right: var(--frame);
    bottom: 28px;
    justify-items: end;
    gap: 10px;
  }
  .reel-title {
    font-size: 28px;
    text-align: right;
  }
  .reel-credit {
    font-size: 12px;
    max-width: 520px;
  }
  .reel-ctl {
    --hh: 48px;
    margin-right: -6px;
    margin-left: 0;
  }
  .chap,
  .sound-cue {
    --w: 36px;
    --h: 60px;
    width: 48px;
    height: 68px;
  }
  .chap__tab {
    font-size: 13px;
  }
  .hero__def {
    position: absolute;
    z-index: 2;
    left: 0;
    bottom: 180px;
    padding: 0 0 28px var(--frame);
    max-width: calc(44ch + var(--frame));
    font-size: 18px;
    color: var(--night-ink);
  }
}

/* ───────── Doors: the logo's two halves. Music first (mass), business second (contour), in the logo's order. ───────── */
.doors {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 8px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.door {
  --k: 1.5px;
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 14px calc(var(--margin) + 36px) 14px var(--margin);
}
.door__label {
  margin: 0;
  font-size: 12px;
}
.door__title {
  margin: 0;
}
.door__line {
  display: none;
  margin: 0;
  max-width: 52ch;
  font-size: 15px;
  line-height: 1.4;
}
.door__arrow {
  position: absolute;
  right: var(--margin);
  top: 50%;
  translate: 0 -50%;
  font-size: 28px;
  line-height: 1;
  transition: transform var(--rise-music) var(--ease-swell);
}
.door:focus-visible {
  outline: none;
}
.door:focus-visible::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 5;
  box-shadow: inset 0 0 0 3px var(--night-ink);
  pointer-events: none;
}

.door--biz {
  --k: 3px;
  --nt: 36px;
  --nx: 9px;
  height: 96px;
  margin: 0 1px;
  background: rgba(12, 10, 11, 0.6);
  clip-path: polygon(var(--nx) 0, 100% 0, 100% 100%, 0 100%, 0 var(--nt));
}
.door--music {
  height: 108px;
}
.door__line,
.door__text {
  position: relative;
  z-index: 2;
}
.door__text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  height: 100%;
}

/* TAB: a violet contour with the logo's slant notch at its top-left; the sheet rises inside it. */
.door__edge {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--violet);
  clip-path: polygon(
    evenodd,
    var(--nx) 0,
    100% 0,
    100% 100%,
    0 100%,
    0 var(--nt),
    var(--nx) 0,
    calc(var(--nx) + var(--k) * 0.78) var(--k),
    calc(100% - var(--k)) var(--k),
    calc(100% - var(--k)) calc(100% - var(--k)),
    var(--k) calc(100% - var(--k)),
    var(--k) calc(var(--nt) + var(--k) * 0.12),
    calc(var(--nx) + var(--k) * 0.78) var(--k)
  );
}
.door__sheet {
  position: absolute;
  inset: var(--k);
  z-index: 0;
  overflow: clip;
  transform: translateY(100%);
  transition: transform var(--fall) var(--ease-fall);
  background: var(--sheet);
  background-image:
    radial-gradient(ellipse 80% 70% at 10% 0%, #fff 0%, transparent 65%),
    radial-gradient(ellipse 70% 60% at 100% 100%, #e6e2ee 0%, transparent 70%);
}
.door__sheet > i {
  position: absolute;
  inset: 0;
  display: block;
  transform: translateY(-100%);
  transition: transform var(--fall) var(--ease-fall);
}
.door__crest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--k) / 2 + 0.5px);
  z-index: 3;
  --crest: var(--violet);
}
.door--biz .door__label {
  color: var(--violet);
  font-variation-settings:
    'wdth' 112,
    'wght' 600;
  text-transform: none;
  letter-spacing: 0.04em;
  transition: color var(--rise-biz) var(--ease-tick);
}
.door--biz .door__title {
  font-size: 26px;
  color: var(--night-ink);
  transition: color var(--rise-biz) var(--ease-tick);
}
.door--biz .door__line {
  color: var(--night-muted);
  transition: color var(--rise-biz) var(--ease-tick);
}
.door--biz .door__arrow {
  color: var(--violet);
}
.door--biz.is-up .door__sheet,
.door--biz.is-up .door__sheet > i {
  transform: none;
  transition-duration: var(--rise-biz);
  transition-timing-function: var(--ease-tick);
}
.door--biz.is-up .door__label {
  color: var(--violet-deep);
}
.door--biz.is-up .door__title,
.door--biz.is-up .door__line {
  color: var(--sheet-ink);
}
.door--biz.is-up .door__arrow {
  color: var(--violet-deep);
}

/* MUSIC: a vermilion mass; its right edge feathers into the contour next to it (the border fades). */
.door__mass {
  position: absolute;
  z-index: 0;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  isolation: isolate;
  transition: transform var(--rise-music) var(--ease-swell);
}
.door__fill {
  position: absolute;
  inset: 0;
  background: var(--vermilion);
}
.door__rise {
  position: absolute;
  inset: 0;
  overflow: clip;
  transform: translateY(100%);
  transition: transform var(--fall) var(--ease-fall);
}
.door__rise-in {
  display: block;
  position: absolute;
  inset: 0;
  transform: translateY(-100%);
  transition: transform var(--fall) var(--ease-fall);
}
.door__rise video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 25%;
  mix-blend-mode: multiply;
  opacity: 0.9;
}
.door--music .door__crest {
  --crest: var(--vermilion);
  top: 0;
  z-index: 4;
  mix-blend-mode: normal;
}
.door--music {
  color: var(--on-vermilion);
}
.door--music .door__label {
  font-variation-settings:
    'wdth' 112,
    'wght' 650;
}
.door--music .door__title {
  font-size: 28px;
  line-height: 0.92;
} /* English words, no Vietnamese marks to clear */
.door--music .door__line {
  color: rgba(12, 10, 11, 0.8);
}
.door--music.is-up .door__rise,
.door--music.is-up .door__rise-in {
  transform: none;
  transition-duration: var(--rise-music);
  transition-timing-function: var(--ease-swell);
}

@media (min-width: 1024px) {
  .doors {
    container-type: inline-size;
    --frame: max(var(--margin), calc((100cqw - var(--page)) / 2));
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0;
    padding-bottom: 0;
    height: 180px;
    overflow: clip;
  }
  .door {
    --k: 2px;
    --tw: calc(50cqw - var(--frame) - var(--margin) - 56px);
    padding: 22px calc(var(--margin) + 56px) 22px var(--margin);
    gap: 6px;
  }
  .door--music {
    padding-left: var(--frame);
  }
  .door--biz {
    padding-right: calc(var(--frame) + 56px);
  }
  .door--biz .door__arrow {
    right: var(--frame);
  }
  .door--biz,
  .door--music {
    height: 180px;
    margin: 0;
  }
  .door--biz {
    --k: 3px;
    --nt: 40px;
    --nx: 10px;
    margin: 1px;
    height: 178px;
  }
  .door__label {
    font-size: 13px;
  }
  .door__line {
    display: block;
    max-width: var(--measure);
    font-size: 15px;
    line-height: 1.35;
  }
  .door__text {
    gap: 6px;
  }
  .door__title {
    white-space: nowrap;
  }
  .door__arrow {
    font-size: 32px;
  }
  .door--biz .door__title {
    font-size: min(44px, calc(var(--tw) / 11.07));
  }
  .door--music .door__title {
    font-size: min(48px, calc(var(--tw) / 12.4));
  }
  .door__mass {
    left: -48px;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 96px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 96px), transparent);
  }
}
@media (hover: hover) and (min-width: 1024px) {
  .door--music.is-up .door__mass {
    transform: translateX(48px);
  }
  .door--music:has(~ .door--biz.is-up) .door__mass {
    transform: translateX(-48px);
  }
  .door.is-up .door__arrow {
    transform: translateX(8px);
  }
}

.crest {
  transition: opacity 200ms linear;
}
.crest.is-quiet {
  opacity: 0;
}
@media (prefers-reduced-motion: reduce) {
  .crest {
    display: none;
  }
}

/* The case light of the home business half: TRIO's film glow still, fixed under the night (direction B §3.10). */
#business .stage::before {
  background:
    linear-gradient(rgba(12, 10, 11, 0.78), rgba(12, 10, 11, 0.78)),
    url('/assets/films/NASGuWU1zig-glow.jpg') 100% 0 / 60% auto no-repeat fixed,
    var(--night);
}

/* On a phone the sign-off docks under the client sites, as the page's gaps there are 72 to 112 px. */
@media (max-width: 1023.98px) {
  #business .signoff {
    padding-top: 16px;
  }
}
