/* Home: one screen, no scroll. The stage (3D or its still) fills the screen
   behind the UI. The 3D module reads .stage__frame for where the mark sits. */

:root {
  /* The mark's width / height. main.js updates it from the loaded mark file. */
  --mark-aspect: 1.0024;
  --mark-w: min(54vw, calc(44dvh * var(--mark-aspect)), 1100px);
  --mark-cx: 50%;
  --mark-cy: 40%;
}
/* Portrait: the full width between the gutters, capped by height so a round
   or tall mark still clears the line and buttons. */
@media (max-aspect-ratio: 3/4) {
  :root {
    --mark-w: min(calc(100vw - var(--gutter-l) - var(--gutter-r)), calc(37dvh * var(--mark-aspect)));
    --mark-cy: 34%;
  }
}
/* Tablets in portrait: more height to share, so the mark sits a little lower. */
@media (max-aspect-ratio: 3/4) and (min-width: 600px) {
  :root { --mark-cy: 38%; --mark-w: min(calc((100vw - var(--gutter-l) - var(--gutter-r)) * 0.9), calc(42dvh * var(--mark-aspect))); }
}
@media (max-height: 520px) and (orientation: landscape) {
  :root {
    --mark-w: min(39vw, calc(56dvh * var(--mark-aspect)));
    --mark-cx: 26%;
    --mark-cy: 55%;
  }
}

/* Home locks to the screen. Short screens (200% zoom, landscape phones) scroll. */
html.is-home body { overflow: hidden; }
@media (max-height: 479px) {
  html.is-home body { overflow: auto; }
}

/* ---------- Stage ---------- */
.stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: var(--gist-ink);
  view-transition-name: stage;
  touch-action: pan-y;
}
/* The stage shows while it holds the mark. Parked, the header logo takes over. */
html.js:not(.stage-unparked) .stage { visibility: hidden; }
.stage.is-parking { z-index: 40; background: transparent; pointer-events: none; }
.stage.is-parked { background: transparent; pointer-events: none; }

.stage__studio {
  position: absolute;
  inset: 0;
  transition: opacity var(--vt-dur) var(--vt-ease);
}
.stage.is-parking .stage__studio,
.stage.is-parked .stage__studio { opacity: 0; }

.stage__pool {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 52% 46% at var(--mark-cx) var(--mark-cy), rgb(var(--gist-navy-rgb) / 0.95) 0%, rgb(var(--gist-navy-rgb) / 0.42) 46%, rgb(var(--gist-navy-rgb) / 0) 78%),
    linear-gradient(to bottom, rgb(var(--gist-ink-rgb) / 0) 60%, rgb(2 6 18 / 0.55) 100%);
}
.stage__floor {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 79%;
  height: 1px;
  background: linear-gradient(90deg, rgb(var(--gist-cream-rgb) / 0) 0%, rgb(var(--gist-cream-rgb) / 0.14) 30%, rgb(var(--gist-cream-rgb) / 0.14) 70%, rgb(var(--gist-cream-rgb) / 0) 100%);
}

/* Softbox strips, out of focus at the sides of the stage. */
/* They end above the Home line, so no strip runs through the words. */
.stage__strip {
  position: absolute;
  top: 8%;
  height: 62%;
  left: var(--x);
  width: var(--w, 4px);
  margin-left: calc(var(--w, 4px) / -2);
  border-radius: 4px;
  opacity: var(--o, 0.5);
  background: linear-gradient(to bottom, rgb(255 248 230 / 0) 0%, rgb(255 248 230 / 0.8) 16%, rgb(255 250 238 / 1) 50%, rgb(255 248 230 / 0.8) 84%, rgb(255 248 230 / 0) 100%);
  filter: blur(var(--b, 2px));
}
.stage__strip::after {
  content: "";
  position: absolute;
  inset: 4% -40px;
  background: inherit;
  border-radius: 40px;
  filter: blur(40px);
  opacity: 0.24;
}
.stage__strip:nth-child(3) { --x: 7%;  --w: 5px; --o: 0.42; --b: 3px; }
.stage__strip:nth-child(4) { --x: 14%; --w: 3px; --o: 0.62; --b: 1.5px; top: 13%; height: 52%; }
.stage__strip:nth-child(5) { --x: 86%; --w: 3px; --o: 0.62; --b: 1.5px; top: 13%; height: 52%; }
.stage__strip:nth-child(6) { --x: 93%; --w: 5px; --o: 0.42; --b: 3px; }
@media (max-aspect-ratio: 3/4) {
  .stage__strip { top: 6%; height: 52%; }
  .stage__strip:nth-child(3) { --x: 4%; }
  .stage__strip:nth-child(6) { --x: 96%; }
  .stage__strip:nth-child(4),
  .stage__strip:nth-child(5) { display: none; }
}

/* Where the mark sits. The 3D module fits its badge to this box. */
.stage__frame {
  position: absolute;
  left: var(--mark-cx);
  top: var(--mark-cy);
  width: var(--mark-w);
  aspect-ratio: var(--mark-aspect);
  transform: translate(-50%, -50%);
}
.stage__still {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  will-change: transform;
}
/* The flight into the header slot runs on the same clock and curve as the wipe. */
.stage__still.is-moving { transition: transform var(--vt-dur) var(--vt-ease); }
.stage__tilt {
  position: absolute;
  inset: 0;
  transform: perspective(1600px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transform-style: preserve-3d;
}
.stage__mark {
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}
.stage__sheen {
  position: absolute;
  inset: 0;
  pointer-events: none;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  background: linear-gradient(104deg, rgb(255 255 255 / 0) 0%, rgb(255 255 255 / 0) 42%, rgb(255 255 255 / 0.7) 50%, rgb(255 255 255 / 0) 58%, rgb(255 255 255 / 0) 100%);
  background-size: 260% 100%;
  background-repeat: no-repeat;
  background-position: var(--sheen-x, 130%) 0;
  opacity: var(--sheen-o, 0);
}
.stage__sheen.is-sweeping { animation: sheen-sweep 1300ms var(--motion-ease-in-out) both; }
@keyframes sheen-sweep {
  0% { background-position: 130% 0; opacity: 1; }
  100% { background-position: -30% 0; opacity: 1; }
}
/* When the 3D canvas is live, the still hides under it. */
.stage.has-3d .stage__still { opacity: 0; transition: opacity 600ms var(--ease-out); }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ---------- Home UI ---------- */
.view--home {
  position: relative;
  height: 100vh;
  height: 100dvh;
  min-height: 480px;
  display: grid;
  grid-template-rows: 1fr auto;
  /* Side edges line up with the header and the .wrap column on wide screens. */
  padding: calc(var(--header-h) + env(safe-area-inset-top, 0px)) var(--edge-r) calc(clamp(var(--space-5), 1rem + 2vw, var(--space-7)) + env(safe-area-inset-bottom, 0px)) var(--edge-l);
  pointer-events: none;
  view-transition-name: home-ui;
}
.view--home a,
.view--home button { pointer-events: auto; }

.home__bottom {
  grid-row: 2;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-6) var(--space-8);
}
.home__line {
  max-width: 25ch;
  font-size: clamp(2rem, 1.15rem + 2.9vw, 3.5rem);
  font-stretch: 112.5%;
  font-weight: 700;
  letter-spacing: -0.018em;
  line-height: 1.02;
  text-wrap: balance;
}
.home__ctas {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: clamp(var(--space-5), 1rem + 1.5vw, var(--space-6));
}
.home__corner {
  position: relative;
  flex: none;
  max-width: 24ch;
  padding-top: var(--space-4);
  color: var(--color-text-muted);
  text-align: left;
}
/* The hairline over the corner line draws in during the intro (motion.css). */
.home__corner::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--border-hairline);
  background: var(--color-line);
  transform-origin: left;
}

@media (max-width: 759px) {
  .home__bottom { flex-direction: column; align-items: stretch; gap: var(--space-5); }
  .home__line { font-size: clamp(1.75rem, 1rem + 4.6vw, 2.5rem); max-width: 16ch; }
  .home__ctas { display: grid; grid-template-columns: 1fr; }
  .home__ctas .btn { width: 100%; }
  .home__corner { max-width: none; padding-top: var(--space-3); }
}
/* Short phones (an iPhone SE with Safari's bars): buttons side by side and a
   smaller line, so the mark keeps a useful size above them. */
@media (max-width: 759px) and (max-height: 700px) {
  .home__bottom { gap: var(--space-4); }
  .home__line { font-size: clamp(1.5rem, 0.9rem + 4vw, 2rem); }
  .home__ctas { grid-template-columns: 1fr 1fr; gap: var(--space-2); margin-top: var(--space-4); }
  .home__ctas .btn { white-space: nowrap; padding-inline: var(--space-3); }
}
@media (max-width: 759px) and (min-height: 760px) {
  .home__ctas { margin-top: var(--space-6); }
}
@media (max-height: 520px) and (orientation: landscape) {
  /* Landscape phones: two columns that fit the screen. It only scrolls if the
     words truly don't fit (200% zoom). */
  .view--home { min-height: 0; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; align-items: center; }
  .home__bottom { grid-column: 2; grid-row: 1; flex-direction: column; align-items: flex-start; gap: var(--space-4); }
  .home__line { font-size: clamp(1.5rem, 1rem + 2vw, 2.25rem); }
  .home__ctas { margin-top: var(--space-4); }
}

/* Line reveal: each word rises behind a mask, one line at a time. The .w and
   .w__i masks are shared with the view headlines (motion.css). */
