/* ==========================================================================
   Theme "fj" (F · המועצה) — the hero, copied from fi and re-toned: the room is paper (no lilac),
   the deck is ink with the live accent, the poster uses the council palette, Heebo 800 for display.
   Original notes (fi) follow.
   Theme "fi" (F · הטלפון האמיתי) — the hero only. Everything below it is fh's
   (fh.css + fh-home.css are loaded by fh's Layout). Same palette: paper, ink,
   violet, cobalt, red. Motion is transform / opacity only.

   One iPhone in a lit room (the Fabric Phone demo's "spot" world, tinted into
   fh's palette), the ribbon of news running through it, and the phone's own
   controls pinned right under it.

   States on .fi-hero:
     data-gl     off | loading | ready   the WebGL scene; off → the poster slide stands in
     data-clock  run | hold              the auto-advance (drives the progress line)
     data-pinned                         the deck has been placed under the projected phone
   ========================================================================== */

.fi-hero {
  --room: #E9E6DD;
  /* distance from the wrap to the viewport edge, so the room can bleed off the page */
  --bleed: max(28px, (100vw - 1320px) / 2);
  --stage-h: clamp(620px, calc(100svh - var(--header-h) - 28px), 800px);
  padding-block: calc(var(--header-h) + 4px) 24px;
}

.fi-grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  grid-template-rows: minmax(0, 1fr) auto auto minmax(0, 1fr);
  grid-template-areas:
    ".    stage"
    "copy stage"
    "more stage"
    ".    stage";
  column-gap: clamp(16px, 2.4vw, 40px);
}

.fi-copy {
  grid-area: copy;
  position: relative;
  z-index: 3;
  padding-block: 0 14px;
}

.fi-more {
  grid-area: more;
  position: relative;
  z-index: 3;
  align-self: start;
}

.fi-more .hx-dek { margin-block-start: 0; max-width: 46ch; }

.fi-copy { container-type: inline-size; }
.fi-copy .hx-h1 { font-size: clamp(3rem, 10.2cqi, 5.4rem); }

/* ==========================================================================
   The stage: the room, the scene, the deck
   ========================================================================== */
.fi-stage {
  grid-area: stage;
  position: relative;
  z-index: 2;
  height: var(--stage-h);
  --phone-x: 50%;
  --phone-bottom: calc(100% - 132px);
  --phone-top: 8%;
}

/* the room bleeds to the page's edge on the outside and to the hero's top and bottom,
   and dissolves into the paper toward the headline */
.fi-scene {
  --fade-in: linear-gradient(to left, transparent 0, #000 30%);
  --fade-v: linear-gradient(to bottom, transparent 0, #000 9%, #000 84%, transparent 100%);
  position: absolute;
  z-index: 1;
  top: calc(-1 * (var(--header-h) + 8px));
  bottom: -28px;
  left: calc(-1 * var(--bleed));
  right: calc(-1 * clamp(24px, 4.4vw, 72px));
  isolation: isolate;
  pointer-events: none;
}

.fi-scene::before,
.fi-grain {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  -webkit-mask-image: var(--fade-in), var(--fade-v);
  -webkit-mask-composite: source-in;
  mask-image: var(--fade-in), var(--fade-v);
  mask-composite: intersect;
}

/* the spot: a pool of light on the phone, falling off into a soft lilac vignette */
.fi-scene::before {
  background:
    radial-gradient(64% 58% at 50% 44%,
      color-mix(in oklab, var(--room) 40%, white) 0%,
      var(--room) 58%,
      color-mix(in oklab, var(--room) 90%, #1b1c26) 100%);
}

.fi-grain {
  display: block;
  opacity: 0.06;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.fi-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  transform: translateY(16px) scale(0.985);
  transition: opacity 800ms var(--ease), transform 1000ms var(--ease);
  pointer-events: auto;
  touch-action: pan-y;
  cursor: grab;
  -webkit-tap-highlight-color: transparent;
  -webkit-mask-image: var(--fade-in), var(--fade-v);
  -webkit-mask-composite: source-in;
  mask-image: var(--fade-in), var(--fade-v);
  mask-composite: intersect;
}

.fi-canvas.is-in { opacity: 1; transform: none; }
.fi-canvas.dragging { cursor: grabbing; }
.fi-canvas.is-link { cursor: pointer; }

/* ==========================================================================
   The poster — no WebGL / reduced motion / no JS: one slide stands in for the phone
   ========================================================================== */
.fi-poster {
  --p-bg: #0E0F16; --p-ink: #F4F3EE; --p-acc: #8E9DFF; --p-acc-ink: #0E0F16;
  position: absolute;
  z-index: 2;
  top: 6%;
  bottom: 150px;
  left: 50%;
  aspect-ratio: 4 / 5;
  max-width: 88%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: clamp(16px, 2.4vw, 28px);
  border-radius: 22px;
  background: var(--p-bg);
  color: var(--p-ink);
  box-shadow: 0 40px 60px -40px rgba(14, 15, 22, 0.55), 0 0 0 10px #15161d, 0 0 0 11.5px #b9b8c4;
  transform: translateX(-50%);
  transition: opacity 700ms var(--ease), transform 900ms var(--ease), visibility 0s;
}

.fi-hero[data-gl="ready"] .fi-poster {
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) scale(0.96);
  transition: opacity 320ms linear, transform 600ms var(--ease), visibility 0s 340ms;
}

.fi-poster[data-tone="1"] { --p-bg: #FCFBF8; --p-ink: #0E0F16; --p-acc: var(--cobalt); --p-acc-ink: #fff; }
.fi-poster[data-tone="2"] { --p-bg: var(--cobalt); --p-ink: #fff; --p-acc: #fff; --p-acc-ink: var(--cobalt); }
.fi-poster[data-tone="3"] { --p-bg: #E9E6DD; --p-ink: #0E0F16; --p-acc: var(--red); --p-acc-ink: #fff; }
.fi-poster[data-tone="4"] { --p-bg: var(--violet); --p-ink: #fff; --p-acc: #0E0F16; --p-acc-ink: #fff; }
.fi-poster[data-tone="5"] { --p-bg: #161822; --p-ink: #F4F3EE; --p-acc: var(--cyan); --p-acc-ink: #0E0F16; }

.fi-poster-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-family: var(--font-display); font-weight: 800; }
.fi-poster-top em { font-family: var(--font-sans); font-weight: 600; padding: 4px 10px 3px; border-radius: 4px; background: var(--p-acc); color: var(--p-acc-ink); font-style: normal; font-size: 0.875rem; }
.fi-poster-top b { color: var(--p-acc); }
.fi-poster strong {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 6;
  overflow: hidden;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.6rem, 2.6vw, 2.4rem);
  line-height: 1.08;
  text-wrap: balance;
}
.fi-poster-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 12px; border-top: 1px solid currentColor; font-weight: 500; font-size: 0.875rem; }
.fi-poster-foot b { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--p-acc); color: var(--p-acc-ink); }

/* ==========================================================================
   The deck: the phone's controls, pinned under the iPhone
   ========================================================================== */
.fi-deck {
  position: absolute;
  z-index: 4;
  top: calc(var(--phone-bottom) + 6px);
  left: var(--phone-x);
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(380px, 92%);
  transform: translateX(-50%);
  transition: opacity 500ms var(--ease);
}

/* until it knows where the phone is, the deck waits (no jump) */
.fi-hero[data-gl="loading"] .fi-deck,
.fi-hero[data-gl="ready"]:not([data-pinned]) .fi-deck { opacity: 0; }

.fi-deck-bar {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px 5px 4px 12px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
}

/* a short stem ties the deck to the phone above it */
.fi-deck::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  width: 2px;
  height: 8px;
  border-radius: 2px;
  background: var(--ink);
  opacity: 0.35;
  transform: translateX(-50%);
}

.fi-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
  cursor: pointer;
  transition: background-color 180ms linear, transform 260ms var(--ease);
}

.fi-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.fi-btn:hover { background: rgba(255, 255, 255, 0.12); }
.fi-btn:active { transform: scale(0.92); }
.fi-btn:focus-visible { outline: 2px solid var(--live); outline-offset: -2px; }

.fi-play { width: 44px; height: 44px; background: var(--live); color: #fff; transition: background-color 460ms var(--ease), transform 260ms var(--ease); }
.fi-play:hover { background: color-mix(in oklab, var(--live) 85%, white); }
.fi-play svg { fill: currentColor; stroke-width: 2.8; }
.fi-play .fi-i-play { display: none; }
.fi-play[aria-pressed="true"] .fi-i-play { display: block; }
.fi-play[aria-pressed="true"] .fi-i-pause { display: none; }

.fi-count {
  min-width: 52px;
  white-space: nowrap;
  padding-inline: 8px 2px;
  font: 500 0.8125rem/1 var(--font-sans);
  font-variant-numeric: tabular-nums;
  text-align: center;
  opacity: 1;
  padding: 4px 8px;
  border-radius: 4px;
  background: #fff;
  color: #11121a;
}
.fi-poster-top em[data-fi-p-label] { background: #0e0f16 !important; color: #fff !important; opacity: 1 !important; }
.fi-poster-top span[translate="no"] { display: inline-block; padding: 3px 6px; border-radius: 4px; background: #fff; color: #0e0f16 !important; -webkit-text-fill-color: #0e0f16 !important; }

/* the time the item has left on the screen */
.fi-progress {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--live);
  transform: scaleX(0);
  transform-origin: right center;
}

.fi-progress.is-run { animation: fi-progress 4200ms linear both; }
.fi-hero[data-clock="hold"] .fi-progress { animation-play-state: paused; opacity: 0.45; }

@keyframes fi-progress { to { transform: scaleX(1); } }

.fi-now {
  display: grid;
  justify-items: center;
  gap: 2px;
  max-width: 100%;
  padding: 2px 10px;
  border-radius: 8px;
  background: #fff;
  color: #11121a;
  color: var(--ink);
  text-align: center;
}

.fi-now-meta { color: var(--ink-mute); font-size: 0.8125rem; font-weight: 500; white-space: nowrap; }
html[data-a11y="1"] .fi-now-meta,
html[data-a11y="1"] .fi-now strong { color: #11121a !important; opacity: 1 !important; }
html[data-a11y="1"] .fi-count,
html[data-a11y="1"] .fi-now-meta { padding: 4px 8px; border-radius: 4px; background: #fff; color: #11121a; opacity: 1; }
html[data-a11y="1"] .fi-deck { opacity: 1 !important; }
/* r6: ...but never while the phone is not on screen yet (the bar would float alone in an empty room) */
html[data-a11y="1"] .fi-hero[data-gl="loading"] .fi-deck,
html[data-a11y="1"] .fi-hero[data-gl="ready"]:not([data-pinned]) .fi-deck { opacity: 0 !important; }
html[data-a11y="1"] .fi-poster-top em[data-fi-p-label] { background: #fff; color: #11121a; opacity: 1; }
html[data-a11y="1"] .fi-poster-top [translate="no"] { display: inline-block; padding: 3px 6px; border-radius: 4px; background: #fff; color: #11121a; -webkit-text-fill-color: #11121a; }

.fi-now strong {
  display: block;
  max-width: 100%;
  overflow: hidden;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-decoration: underline 1.5px transparent;
  text-underline-offset: 4px;
  transition: text-decoration-color 200ms linear;
}

.fi-now:hover strong { text-decoration-color: currentColor; }
.fi-now:hover strong { color: var(--live); }
.fi-now:focus-visible { outline: 2px solid var(--live); outline-offset: 2px; border-radius: 6px; }

/* no JS: the poster is the link; the buttons would do nothing */
html:not(.fi-js) .fi-deck-bar { display: none; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1239px) {
  .fi-grid { grid-template-columns: minmax(0, 4.6fr) minmax(0, 7.4fr); }
}

@media (max-width: 1039px) {
  .fi-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas: "copy" "stage" "more";
  }
  .fi-hero { --stage-h: 600px; }
  .fi-scene {
    --fade-in: linear-gradient(#000, #000);
    top: -8px;
    left: calc(-1 * var(--bleed));
    right: calc(-1 * var(--bleed));
    bottom: -8px;
  }
  .fi-more { margin-block-start: 8px; }
}

/* a phone: headline smaller, so the iPhone is on the first screen */
@media (max-width: 759px) {
  .fi-hero { --stage-h: clamp(430px, 100svh - 320px, 560px); padding-block-end: 30px; }
  /* the room reaches up behind the last headline line, so the phone sits higher and its deck fits */
  .fi-scene { top: -72px; --fade-v: linear-gradient(to bottom, transparent 0, transparent 12%, #000 30%, #000 86%, transparent 100%); }
  .fi-copy { padding-block-end: 0; }
  .fi-copy { container-type: normal; }
  .fi-copy .hx-h1 { font-size: clamp(2.7rem, 11.4vw, 3.6rem); }
  .fj-kicker { margin-block-end: 12px; font-size: 0.8125rem; gap: 10px; }
  .fi-more { margin-block-start: 0; }
  .fi-stage { --phone-bottom: calc(100% - 108px); }
  .fi-deck { gap: 6px; }
  .fi-btn { width: 48px; height: 48px; }
  .fi-play { width: 48px; height: 48px; }
  .fi-now strong { font-size: 0.9375rem; }
  .fi-poster { bottom: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  .fi-canvas, .fi-poster, .fi-deck, .fi-btn { transition: none; }
  .fi-progress,
  .fi-play { display: none; }
}



/* mobile pass (BRIEF-mobile): the phone's controls get a 44px touch area (invisible, nothing moves) */
@media (max-width: 760px), (pointer: coarse) {
  .fi-btn { position: relative; }
  .fi-btn::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; }
}

/* ==========================================================================
   Round 23 · r6 — nothing visible in the phone area until the 3D phone's first frame is drawn (Nadav, 29.11)
   r5's silver silhouette showed as a white card on refresh, so it is gone. While data-gl="loading" the dark
   poster stays out of the way and the stage is simply empty (its space is reserved by .fi-stage's height);
   the canvas is transparent until fj-hero.js has drawn a frame, then fades in (~250 ms, opacity only).
   The poster returns only when WebGL really fails (data-gl="off": no WebGL, reduced motion, error or the
   7 s timer in Hero.astro).
   ========================================================================== */
.fi-hero[data-gl="loading"] .fi-poster { opacity: 0; visibility: hidden; transition: none; }
.fi-stage::before { content: none; }
.fi-canvas { transform: none; transition: opacity 250ms linear; }
.fi-canvas.is-in { transform: none; }
