/* ============================================================
   lens-hero.css — the home page's hero
   Two groups on the page's 980px column: who, at the top, as plain
   text; and how — "I use a design lens to …" — below it, for the glass
   lens to read. The lens's stage is the whole hero's backdrop.
   js/lens-hero.js draws the hidden words into the stage at the exact
   places the browser set them, shown only under the glass; elsewhere
   they are a shifting run of glyphs (.hero-glyphs). The HTML sentence
   stays in place, transparent, for selection and screen readers;
   without WebGL (no .is-revealing) it simply shows in full.

   Lens tokens from Playground/DESIGN.md §2. The theme lives in
   data-lens-theme on <html>; in dark mode the whole page also takes
   the site's dark palette (body.dark).
   ============================================================ */

:root {
  --lens-stage: #ffffff;
  --lens-button-bg: rgba(26, 22, 112, .06);
  --lens-button-ink: #1a1670;
  --hero-lead: #161514;
}

:root[data-lens-theme="dark"] {
  --lens-stage: #000;
  --lens-button-bg: rgba(255, 255, 255, .10);
  --lens-button-ink: #eceaff;
  --hero-lead: #f5f5f7;
}

/* Not a full screen: the hero ends below the lens sentence, with half the
   room a full first screen would have left under it (--reveal-tail, set by
   js/lens-hero.js) — enough for the lens and its shadow, and the work
   comes into view on the first screen. */
.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--lens-stage);
}

/* The stage: the hero's whole backdrop, behind both groups. */
.lens-hero {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--lens-stage);
}

/* Out of flow: the stage's height comes from the hero alone. In flow, the
   canvas's own pixel size (which it sets from its box) would feed back
   into the height. */
.lens-hero__canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: default;
}

/* DEVIATION from the spec, deliberate. The Playground's stage is the whole
   page and takes every touch. Here the hero sits on top of a scrolling
   page, so vertical swipes go back to the browser; taps and sideways drags
   still move the lens, and idle drift keeps it alive. */
@media (pointer: coarse) {
  .hero { touch-action: pan-y; }
}

/* The theme toggle, in the stage's bottom corner, on the column's edge. */
.lens-hero__toggle {
  position: absolute;
  bottom: 24px;
  right: max(20px, calc((100% - 980px) / 2));
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--lens-button-bg);
  color: var(--lens-button-ink);
  cursor: pointer;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: background .2s, transform .2s;
}
.lens-hero__toggle:hover { transform: scale(1.06); }
.lens-hero__toggle:focus-visible {
  outline: 2px solid var(--lens-button-ink);
  outline-offset: 3px;
}
.lens-hero__toggle svg { width: 20px; height: 20px; }

/* Show the icon for the mode you'd switch to. */
:root[data-lens-theme="dark"] .lens-hero .icon-moon,
:root:not([data-lens-theme="dark"]) .lens-hero .icon-sun { display: none; }

/* ── The two groups ──────────────────────────────────────────── */

/* On the page's column: 980px with the wrappers' gutters (4rem from
   992px, 2rem below, 1.5rem under 480px), so the hero's left edge is the
   sections' below it. */
.hero-statement,
.hero-reveal {
  position: relative;
  z-index: 1;
  width: min(980px, 100% - 128px);
  margin: 0 auto;
}
@media screen and (max-width: 991px) {
  .hero-statement,
  .hero-reveal { width: calc(100% - 64px); }
}
@media screen and (max-width: 479px) {
  .hero-statement,
  .hero-reveal { width: calc(100% - 48px); }
}
.hero-statement { padding: 48px 0 32px; }
.hero-reveal { padding: 24px 0 var(--reveal-tail, 96px); }

/* Inter Tight at regular weight. It is already set closer than Inter, so
   it takes only a touch of extra tracking. 36px on wide screens, a size
   up from the work titles; 28 and 24 below. */
.hero-statement__text {
  margin: 0;
  color: var(--hero-lead);
  font-family: "Inter Tight", Geist, sans-serif;
  font-size: 36px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: -.01em;
}
.hero-statement__text--intro { max-width: 720px; }
.hero-statement__text--reveal { max-width: 760px; }

/* Once the lens is running it draws the hidden words itself, so the HTML
   copy goes transparent. The opening words aren't in the lens's scene:
   they stay real text over the glass, so it never refracts them. */
.hero.is-revealing .hero-statement__text--reveal { color: transparent; }
.hero.is-revealing .hero-reveal__shown { color: var(--hero-lead); }
.hero.is-revealing .hero-statement__text--reveal::selection,
.hero.is-revealing .hero-statement__text--reveal *::selection { color: var(--hero-lead); }

/* ── The glyph layer ──────────────────────────────────────────
   The hidden words, until the lens reaches them: a run of glyphs in each
   one's place, shuffling slowly. The lens punches a hole in this layer
   (--lx, --ly, --lr from js/lens-hero.js), so under the glass the real
   words show and nowhere else. */
.hero-glyphs { display: none; }
.hero.is-revealing .hero-glyphs {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(circle at var(--lx, -9999px) var(--ly, -9999px), transparent calc(var(--lr, 0px) - 1px), #000 var(--lr, 0px));
  mask-image: radial-gradient(circle at var(--lx, -9999px) var(--ly, -9999px), transparent calc(var(--lr, 0px) - 1px), #000 var(--lr, 0px));
}

/* ── Smaller screens ─────────────────────────────────────────── */

@media screen and (max-width: 991px) {
  .hero-statement__text { font-size: 28px; }
}
@media screen and (max-width: 767px) {
  .hero-statement { padding: 32px 0 24px; }
  .hero-reveal { padding-top: 16px; }
  .hero-statement__text { font-size: 24px; }
}

/* ?hero=focus — no glyphs. Away from the glass the words are a dim grey
   (js/lens-hero.js); the glass brings them up to full ink at its centre and
   eases back to the grey at its rim. */
.hero[data-variant="focus"] .hero-glyphs { display: none; }

/* ?hero=focus-spectrum-pixel-geist — the hero set in Geist (loaded by
   js/lens-hero.js for that prototype only), to pair with the Geist Pixel
   keywords. */
.hero[data-font="geist"] .hero-statement__text { font-family: Geist, sans-serif; }

/* The prototype switcher (js/lens-hero.js), on prototype URLs only. */
.proto-switch {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 50;
  display: flex;
  gap: 2px;
  max-width: calc(100% - 32px);
  padding: 4px;
  overflow-x: auto;
  transform: translateX(-50%);
  border-radius: 999px;
  background: rgba(30, 30, 32, .78);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25), inset 0 0 0 1px rgba(255, 255, 255, .08);
  scrollbar-width: none;
}
.proto-switch a {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: 999px;
  color: rgba(255, 255, 255, .62);
  font: 500 13px/1.2 Geist, sans-serif;
  text-decoration: none;
  white-space: nowrap;
}
.proto-switch a:hover { color: #fff; }
.proto-switch a[aria-current="page"] { background: rgba(255, 255, 255, .14); color: #fff; }

/* ?hero=focus-spectrum-pixel-geist-stretch — the lens sentence first, the
   intro after it (js/lens-hero.js moves them). The room above the lens
   sentence (--reveal-head) is what the glass needs to reach its first
   line; the tail (--reveal-tail) goes below the intro. */
.hero[data-order="lens-first"] .hero-reveal { padding: var(--reveal-head, 48px) 0 32px; }
.hero[data-order="lens-first"] .hero-statement { padding: 24px 0 var(--reveal-tail, 96px); }
@media screen and (max-width: 767px) {
  .hero[data-order="lens-first"] .hero-reveal { padding-bottom: 24px; }
  .hero[data-order="lens-first"] .hero-statement { padding-top: 16px; }
}

/* …and the intro, now second, set as the work list's subtitles are
   (.link-copy in css/home.css): Geist 500, 16px / 170%, 14px on phones. */
.hero[data-order="lens-first"] .hero-statement__text--intro {
  font-family: Geist, sans-serif;
  font-size: 16px;
  font-weight: 500;
  line-height: 170%;
  letter-spacing: normal;
}
@media screen and (max-width: 767px) {
  .hero[data-order="lens-first"] .hero-statement__text--intro { font-size: 14px; }
}
