/* ==========================================================================
   letter.css — page 2 "Founder Letter" (owned by the letter agent).
   Hero (chrome K + title) → the letter (ink reading) → signature → outro peek.
   JS-driven custom properties (js/views/letter.js):
     .l-hero   --nx --ny  smoothed pointer, -1..1      --sx  scroll tilt (deg)
     .l-mark__tilt --spin  extra Y rotation (deg)       .line --p  ink 0..1
     .l-signature__ink --w  pen position 0..1          .l-letter --read 0..1
   ========================================================================== */

.view--letter {
  --l-fs: clamp(17px, calc(.62rem + .68vw), 26px);
  --l-col: 30.6em; /* reproduces the mockup line breaks */
  --l-title-fs: clamp(36px, min(5vw, 8.2vh), 124px);
  --k-h: clamp(128px, min(25vh, 44vw), 400px);
  /* bright mirror chrome (mockup): high-key silver with one dark horizon band */
  --chrome: linear-gradient(172deg,
      #fff 0%, #eef0f2 14%, #c4c7cc 28%, #fbfbfc 40%, #f2f3f5 45%,
      #9a9da3 49%, #b9bcc1 58%, #e3e5e8 72%, #fafafa 86%, #c2c5ca 100%);
}

/* ---------------------------------------------------------------- hero */
.l-hero {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100svh;
  padding: calc(var(--header-h) + 9.5vh) var(--gutter) 16vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  --nx: 0; --ny: 0; --sx: 0;
}
.l-hero__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  width: 100%;
  will-change: transform, opacity;
}
/* soft shade behind the K + title so they keep contrast wherever the stage's rim passes */
.l-hero__inner::before {
  content: "";
  position: absolute; z-index: -1;
  left: 50%; top: -8%; bottom: -14%;
  width: calc(var(--k-h) * 3.8);
  max-width: 100%; /* never widen the mobile layout viewport */
  transform: translateX(-50%);
  background: radial-gradient(50% 50% at 50% 56%, rgba(0, 0, 0, .62) 0%, rgba(0, 0, 0, .38) 46%, rgba(0, 0, 0, 0) 78%);
  pointer-events: none;
}
.l-hero__eyebrow { color: var(--ink-2); }
.l-hero__eyebrow .l-char { display: inline-block; white-space: pre; }
.l-sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* chrome K ------------------------------------------------------------ */
.l-mark {
  position: relative;
  height: var(--k-h);
  width: calc(var(--k-h) * 170 / 246);
  margin-top: 5.6vh;
  perspective: calc(var(--k-h) * 4.2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.l-mark__tilt {
  --spin: 0;
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transform:
    rotateX(calc(var(--ny) * -8deg + var(--sx) * 1deg))
    rotateY(calc(var(--nx) * 8deg + var(--spin) * 1deg));
  will-change: transform;
}
.l-mark__edge,
.l-mark__face {
  position: absolute; inset: 0;
  -webkit-mask: url(../assets/brand/k-mark.svg) center / contain no-repeat;
          mask: url(../assets/brand/k-mark.svg) center / contain no-repeat;
}
/* soft bloom behind the metal (parallaxes on tilt) */
.l-mark__svg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  fill: #fff;
  opacity: .13;
  filter: blur(calc(var(--k-h) * .07));
  transform: translateZ(calc(var(--k-h) * -.18)) scale(1.06);
}
/* darker slab offset away from the light → reads as metal thickness when tilted */
.l-mark__edge {
  background: linear-gradient(180deg, #8e9198 0%, #3a3c41 46%, #17181b 72%, #5d6066 100%);
  transform: translate3d(calc(var(--nx) * -2.6px), calc(var(--ny) * -2.6px + 1.2px), -2px);
  backface-visibility: hidden;
}
.l-mark__face {
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, .06), rgba(0, 0, 0, 0) 38%, rgba(255, 255, 255, .06) 70%, rgba(0, 0, 0, .04)),
    var(--chrome);
  background-size: 100% 100%, 100% 230%;
  background-position: 0 0, 50% calc(46% + var(--ny) * 34% + var(--nx) * 14%);
}
/* pointer-tracked specular highlight */
.l-mark__spec {
  position: absolute; inset: 0;
  background: radial-gradient(closest-side, rgba(255, 255, 255, .95), rgba(255, 255, 255, .35) 45%, rgba(255, 255, 255, 0));
  background-size: 120% 72%;
  background-repeat: no-repeat;
  background-position: calc(50% + var(--nx) * 70%) calc(36% + var(--ny) * 70%);
  mix-blend-mode: soft-light;
  opacity: .9;
}
/* one-shot specular sweep (JS moves it with xPercent) */
.l-mark__sweep {
  position: absolute; top: -10%; bottom: -10%; left: -60%; width: 220%;
  background: linear-gradient(104deg,
      rgba(255, 255, 255, 0) 38%, rgba(255, 255, 255, .25) 45%, rgba(255, 255, 255, .98) 50%,
      rgba(255, 255, 255, .25) 55%, rgba(255, 255, 255, 0) 62%);
  mix-blend-mode: screen;
  transform: translate3d(-75%, 0, 0);
  pointer-events: none;
}

/* title -------------------------------------------------------------- */
.l-title {
  margin-top: 4.2vh;
  font-size: var(--l-title-fs);
  font-weight: 500;
  line-height: 1.06;
  letter-spacing: -.028em;
  color: #c3c5c9;
  max-width: 12em;
}
/* soft silver, lighter grey than the release headline; faint sheen follows the pointer.
   Once splitLines() has run (data-split-source) only the per-line fills paint: a text-clipped
   background on the parent would also paint the (inline) words at their untransformed spots,
   outside the .line masks, i.e. a static ghost of the title during the slide-up. */
.l-title:not([data-split-source]),
.l-title .line__inner {
  background:
    linear-gradient(100deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, .5) 50%, rgba(255, 255, 255, 0) 70%)
      calc(50% - var(--nx) * 60%) 0 / 260% 100% no-repeat,
    linear-gradient(180deg, #e9eaed 0%, #c3c5ca 40%, #9c9fa5 72%, #bfc1c6 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
/* mask deep enough for Figtree's descenders (y, g) during the slide-up; intro starts at yPercent 135 */
.l-title .line { padding: .04em .06em .28em; margin: -.04em -.06em -.28em; }

/* scroll cue: the cue's own opacity is the scroll scrub's, the span's the intro fade's (letter.js),
   so a scroll during the intro can't leave the cue lit over the letter */
.l-hero__cue {
  position: absolute; left: 50%; bottom: 4.5vh;
  width: 1px; height: clamp(40px, 6.5vh, 64px);
  overflow: hidden;
}
.l-hero__cue span { position: absolute; inset: 0; background: var(--hair); }
.l-hero__cue span::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), #fff 50%, rgba(255, 255, 255, 0));
  animation: l-cue 2.6s var(--ease-in-out) infinite;
}
@keyframes l-cue { from { transform: translateY(-100%); } to { transform: translateY(100%); } }

/* no-WebGL fallback: CSS eclipse rim fitted to the mockup composition --- */
.l-hero__fx { display: none; }
html.no-webgl .l-hero__fx {
  display: block;
  position: absolute; inset: 0 0 -40vh 0; z-index: -1;
  overflow: hidden;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, rgba(0, 0, 0, .12) 0%, rgba(0, 0, 0, .55) 38%, #000 78%), linear-gradient(180deg, #000 50%, rgba(0, 0, 0, .45) 72%, transparent 100%);
  -webkit-mask-composite: source-in;
          mask-image: linear-gradient(90deg, rgba(0, 0, 0, .12) 0%, rgba(0, 0, 0, .55) 38%, #000 78%), linear-gradient(180deg, #000 50%, rgba(0, 0, 0, .45) 72%, transparent 100%);
          mask-composite: intersect;
}
.l-hero__arc {
  position: absolute;
  left: -63.7vw; width: 178vw;
  top: -173.3vh; height: 267.8vh;
  border-radius: 50%;
  box-shadow:
    0 0 0 1.5px rgba(255, 255, 255, .92),
    0 0 6px 1px rgba(255, 255, 255, .75),
    0 0 34px 6px rgba(226, 231, 240, .32),
    0 0 120px 30px rgba(205, 214, 228, .15),
    0 0 260px 50px rgba(190, 200, 215, .06),
    inset 0 -18px 60px -30px rgba(255, 255, 255, .22);
}
@media (orientation: portrait) {
  .l-hero__arc { left: -85vw; width: 200vw; top: -62vh; height: 140vh; }
}

/* --------------------------------------------------------------- letter */
.l-letter {
  position: relative;
  width: min(100% - 2 * var(--gutter), var(--l-col));
  margin: 0 auto;
  padding-top: 4vh;
  font-size: var(--l-fs);
  line-height: 1.58;
  color: var(--ink);
  font-weight: 400;
  --read: 0;
}

.l-letter > p + p { margin-top: .95em; }
.l-salutation {
  font-size: 1.3em;
  line-height: 1.3;
  letter-spacing: -.012em;
  margin-bottom: 1.25em;
}

/* split lines: no mask clipping here; inner shrinks to the text so the ink fill spans the words */
.l-letter .line { overflow: visible; padding: 0; margin: 0; }
.l-letter .line__inner { display: inline-block; will-change: auto; }

/* scroll-linked ink: each line fills left → right as it crosses ~74% of the viewport */
.l-letter.is-ink .line { --p: 0; }
.l-letter.is-ink .line__inner {
  background-image: linear-gradient(90deg, var(--ink) calc(var(--p) * 145% - 45%), rgba(243, 243, 241, .4) calc(var(--p) * 145%));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
/* users who ask for more contrast read the letter at full ink */
@media (prefers-contrast: more) {
  .l-letter.is-ink .line__inner { background: none; color: var(--ink); -webkit-text-fill-color: currentColor; }
}
/* gentle rise on first reveal */
.l-letter.is-armed > p:not(.is-shown) .line,
.l-letter.is-armed .l-sign:not(.is-shown) .l-name,
.l-letter.is-armed .l-sign:not(.is-shown) .l-role {
  opacity: 0;
  transform: translate3d(0, 18px, 0);
}
.l-letter.is-armed > p .line,
.l-letter.is-armed .l-name,
.l-letter.is-armed .l-role {
  transition: opacity 1.1s var(--ease-out), transform 1.3s var(--ease-out);
  transition-delay: calc(var(--i, 0) * .07s);
}
/* hiding (arming on enter) is instant; only the reveal animates. Otherwise the lines already on screen
   fade out over 1.1 s under the lifting veil: a ghost "To Our Future Community," during the intro */
.l-letter.is-armed > p:not(.is-shown) .line,
.l-letter.is-armed .l-sign:not(.is-shown) .l-name,
.l-letter.is-armed .l-sign:not(.is-shown) .l-role { transition: none; }
/* name + role follow the pen (signature takes ~2.5 s) */
.l-letter.is-armed .l-name { transition-delay: 1.75s; }
.l-letter.is-armed .l-role { transition-delay: 1.9s; }
.l-letter .nowrap { white-space: nowrap; }

/* reading progress rail (desktop) */
.l-letter__rail {
  position: absolute;
  left: -3.4em; top: calc(4vh + .55em); bottom: .4em;
  width: 1px;
  background: var(--hair);
  display: none;
}
.l-letter__rail-fill {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, .2), #fff);
  transform: scaleY(var(--read));
  transform-origin: 50% 0;
}
/* travelling dot: full-height box moved by its own height × progress */
.l-letter__rail::after {
  content: "";
  position: absolute; left: -2px; top: -2.5px;
  width: 5px; height: 100%;
  background: radial-gradient(circle 2.5px at 50% 2.5px, #fff 96%, rgba(255, 255, 255, 0)) no-repeat;
  filter: drop-shadow(0 0 5px rgba(255, 255, 255, .8));
  transform: translate3d(0, calc(var(--read) * 100%), 0);
  opacity: min(1, calc(var(--read) * 30));
}
@media (min-width: 1000px) { .l-letter__rail { display: block; } }

/* signature ----------------------------------------------------------- */
.l-sign { margin-top: 2.6em; }
.l-signature {
  font-family: var(--font-sign);
  font-weight: 400;
  font-size: clamp(46px, 3.6vw, 84px); /* ≈ 40% of the column, as in the mockup */
  line-height: 1;
  letter-spacing: 0;
  color: #fff;
  transform: rotate(-3.5deg);
  transform-origin: 0 60%;
  margin: .02em 0 .06em -.08em;
  user-select: none;
}
.l-signature__ink {
  --w: 1.2;
  display: inline-block;
  /* padding gives the swashes room inside the mask box */
  padding: .22em .55em .34em .18em;
  margin: -.22em -.55em -.34em -.18em;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(var(--w) * 100% - 7%), transparent calc(var(--w) * 100% + 1%));
          mask-image: linear-gradient(90deg, #000 calc(var(--w) * 100% - 7%), transparent calc(var(--w) * 100% + 1%));
  text-shadow: 0 0 18px rgba(255, 255, 255, .18);
}
/* the swash picks up where the final s's exit flick ends (never crosses the letter) */
.l-signature__tail {
  display: inline-block;
  width: 1.05em; height: .14em;
  margin-left: .1em;
  vertical-align: .17em;
  fill: currentColor;
  overflow: visible;
}
.l-name {
  font-size: 1.14em;
  font-weight: 500;
  letter-spacing: -.005em;
  line-height: 1.35;
}
.l-role { color: var(--ink-2); line-height: 1.5; margin-top: .15em; }

/* ---------------------------------------------------------------- outro */
/* The last screen of the page. At max scroll the outro + site footer fill exactly one small
   viewport: the bottle anchor takes the height that is left (capped), so the whole bottle,
   its floor + reflection, "Coming soon" and the CTA always fit, clear of the header.
   --l-foot = site footer height, measured by letter.js. */
.l-outro {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
  min-height: calc(100vh - var(--l-foot, 104px));
  min-height: calc(100svh - var(--l-foot, 104px));
  padding: calc(var(--header-h) + clamp(8px, 2vh, 32px)) var(--gutter) clamp(40px, 6vh, 100px);
  padding: calc(var(--header-h) + clamp(8px, 2svh, 32px)) var(--gutter) clamp(40px, 6svh, 100px);
}
.l-outro__bottle {
  flex: 1 0 0px; /* grows into the space left above the text */
  width: clamp(110px, 19vh, 250px);
  width: clamp(110px, 19svh, 250px);
  min-height: 180px;
  max-height: 620px;
}
/* text sits below the floor line, clear of the bottle's reflection (≈ a quarter of its height) */
.l-outro__eyebrow { margin-top: clamp(56px, 12svh, 160px); }
.l-outro__cta { margin-top: 2.2vh; margin-top: 2.2svh; }
.l-outro__cta span { display: inline-block; transition: transform .6s var(--ease-out); }
.l-outro__cta:focus-visible span { transform: translateX(6px); }
/* real pointers only: a tap leaves :hover matched on touch, the arrow would stay nudged */
@media (hover: hover) and (pointer: fine) { .l-outro__cta:hover span { transform: translateX(6px); } }
/* keyboard ring (same look as the base :focus-visible) with room on the right for the nudged arrow */
.l-outro__cta:focus-visible { outline: none; }
.l-outro__cta:focus-visible::after {
  content: '';
  position: absolute; inset: -5px -11px -5px -5px;
  border: 1px solid rgba(255, 255, 255, .85);
  border-radius: 2px;
  pointer-events: none;
}
.l-outro.is-armed:not(.is-shown) > :not(.l-outro__bottle) { opacity: 0; transform: translate3d(0, 20px, 0); }
.l-outro.is-armed > :not(.l-outro__bottle) { transition: opacity 1.1s var(--ease-out), transform 1.3s var(--ease-out); }
.l-outro.is-armed > .l-outro__cta { transition-delay: .15s; }
.l-outro.is-armed:not(.is-shown) > :not(.l-outro__bottle) { transition: none; } /* hide instantly, reveal softly */

/* avoid a flash of the hero before the intro on first load */
html.js.is-loading .view--letter .l-hero__inner { opacity: 0; }

/* ----------------------------------------------------------- responsive */
@media (max-width: 720px) {
  .view--letter { --l-title-fs: clamp(34px, 10.2vw, 52px); --l-col: 100%; }
  .l-hero { min-height: 90vh; min-height: 90svh; padding-top: calc(var(--header-h) + 5vh); padding-bottom: 12vh; }
  .l-mark { margin-top: 4vh; }
  .l-hero__cue { bottom: 3vh; }
  .l-title { max-width: 9.5em; }
  .l-letter { padding-top: 2vh; line-height: 1.62; }
  /* phones only (wider columns keep the mockup breaks): no one-word last lines.
     splitLines measures the words in place, so these breaks are kept. */
  .l-letter > p { text-wrap: pretty; }
  .l-salutation { font-size: 1.22em; margin-bottom: 1.2em; }
  .l-signature { font-size: clamp(44px, 12.5vw, 56px); }
  .l-outro { padding-bottom: clamp(32px, 5svh, 48px); }
  .l-outro__eyebrow { margin-top: clamp(52px, 10.5svh, 100px); }
}
/* landscape phones / very short windows: one viewport can't hold the 180px bottle floor + text +
   footer, so the bottle gets a lower floor and the text block tightens (still clear of the header) */
@media (orientation: landscape) and (max-height: 500px) {
  /* hero: a smaller K + title so the whole block sits above the rim (which crosses ≈ 75% H) and the cue.
     After the max-width: 720px block, so it also covers small phones in landscape (667×375) */
  .view--letter { --k-h: clamp(72px, 24vh, 112px); --l-title-fs: clamp(26px, 8vh, 34px); }
  .l-hero { min-height: 100vh; min-height: 100svh; padding-top: calc(var(--header-h) + 1.5vh); padding-bottom: 14vh; }
  .l-mark { margin-top: 3vh; }
  .l-title { margin-top: 3.2vh; max-width: 14em; }
  .l-hero__cue { bottom: 3vh; height: 32px; }
  .l-outro { padding-bottom: 20px; }
  .l-outro__bottle { min-height: 100px; }
  .l-outro__eyebrow { margin-top: clamp(28px, 8svh, 40px); }
  .l-outro__cta { margin-top: 0; }
}

/* -------------------------------------------------------- reduced motion */
@media (prefers-reduced-motion: reduce) {
  .l-hero__cue span::before { animation: none; transform: none; opacity: .5; }
  .l-mark__tilt { transform: none; }
  .l-mark__sweep { display: none; }
}
