/* Hero: headline, proof strip and the 3D grill stage.
   Loop lengths are multiples of --dur-slow so every timing comes from tokens. */

/* ---------- Section ---------- */

.hero {
  position: relative;
  isolation: isolate;
  display: grid;
  align-content: center;
  min-height: 100vh;
  min-height: 100svh;
  padding-block: var(--space-12);
  overflow: hidden;
}

@media (max-width: 959px) {
  .hero {
    padding-block: var(--space-8) var(--space-12);
  }
}

/* Canvas is drawn by hero-canvas.js; CSS only places it behind the content. */
.hero-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "copy" "visual" "proof";
  gap: var(--space-12);
  align-items: center;
}

.hero-copy {
  grid-area: copy;
  justify-self: start;
  text-align: left;
}
.hero-visual { grid-area: visual; }
.hero-proof { grid-area: proof; }

.hero-brand {
  display: block;
  position: relative;
  overflow: hidden;
  inline-size: clamp(12rem, 26vw, 18rem);
  aspect-ratio: 269 / 62;
  margin-block-end: var(--space-8);
  margin-inline: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  filter: none;
}

.hero-brand .brand-logo {
  inline-size: 100%;
  max-inline-size: 100%;
  transform: none;
}

/* Desktop: copy and proof strip stacked on the left, the stage spanning both rows on the right. */
@media (min-width: 960px) {
  .hero-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "copy visual" "proof visual";
    gap: 0 var(--space-16);
  }

  .hero-copy { align-self: end; }
  .hero-proof { align-self: start; margin-top: var(--space-12); }
}

/* ---------- Headline: line masks and rise-in ---------- */

.hero-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-h1);
  font-weight: 800;
  line-height: 0.92;
  letter-spacing: -0.015em;
  text-transform: uppercase;
  text-wrap: balance;
}

/* Each line is a mask; padding keeps descenders inside it. */
.hero-title .line {
  display: block;
  overflow: hidden;
  padding-bottom: 0.08em;
  margin-bottom: -0.08em;
}

.hero-title .line > span {
  display: block;
  transform: translateY(105%);
}

html.is-ready .hero-title .line > span {
  transform: none;
  transition: transform var(--dur-slow) var(--ease-out);
}

html.is-ready .hero-title .line:nth-child(2) > span {
  transition-delay: calc(var(--dur-fast) * 0.6);
}

/* Accent word: ember text with an ember-2 underline. Inline, so it can wrap on narrow screens. */
.hero-title em {
  font-style: normal;
  color: var(--ember);
  text-decoration: underline;
  text-decoration-color: var(--ember-2);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.12em;
}

/* ---------- Copy, actions and proof strip ---------- */

.hero-lead {
  max-width: 36ch;
  margin: var(--space-6) 0 0;
  font-size: var(--fs-lg);
  line-height: 1.6;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-8);
}

/* Three columns separated by hairlines; the figure sits above its label so every column lines up. */
.hero-proof {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  border-block: 1px solid var(--line);
}

.hero-proof > div {
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-3);
}

.hero-proof > div:first-child {
  padding-left: 0;
}

.hero-proof > div + div {
  border-left: 1px solid var(--line);
}

.hero-proof dt {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero-proof dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  font-weight: 700;
  line-height: 1;
}

/* ---------- Visual: perspective wrapper and tilt stage ---------- */

.hero-visual {
  position: relative;
  justify-self: center;
  width: min(100%, 24rem);
  perspective: 1200px;
}

.hero-stage {
  --lift: var(--space-12); /* shared Z offset for floating cards */
  position: relative;
  aspect-ratio: 1;
  transform-style: preserve-3d;
  transform: rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
  transition: transform var(--dur) var(--ease-out);
}

@media (min-width: 960px) {
  .hero-visual {
    justify-self: end;
    width: 100%;
    max-width: 34rem;
  }

  .hero-stage {
    aspect-ratio: 1;
  }
}

/* ---------- Ember orb behind the grill ---------- */

.hero-orb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 115%;
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--ember-glow), transparent);
  opacity: 0.85;
  pointer-events: none;
  animation: drift calc(var(--dur-slow) * 8) var(--ease-in-out) infinite alternate;
}

/* ---------- Steel grill illustration (CSS only) ---------- */

.hero-grill {
  --grate: color-mix(in oklab, var(--steel) 34%, var(--surface));
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  grid-template-rows: 0.42fr 1fr;
  width: 64%;
  aspect-ratio: 1;
  translate: -50% -50%;
}

/* Trapezoid hood with a hairline highlight along its top edge. */
.hero-grill-hood {
  clip-path: polygon(0 100%, 8% 0, 92% 0, 100% 100%);
  background:
    linear-gradient(90deg, transparent, var(--steel) 50%, transparent) top / 100% 1px no-repeat,
    linear-gradient(180deg, color-mix(in oklab, var(--steel) 20%, var(--surface-2)), var(--surface));
}

.hero-grill-body {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 9% 9% 7%;
  border: 1px solid var(--line-strong);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background:
    linear-gradient(100deg, transparent 20%, color-mix(in oklab, var(--steel) 9%, transparent) 45%, transparent 70%),
    linear-gradient(180deg, var(--surface-2), var(--bg-2));
  box-shadow: inset 0 1px 0 var(--line-strong), var(--shadow-lift);
}

/* Grate: two rails and vertical bars, leaving room for the embers below. */
.hero-grill-grate {
  flex: 1;
  margin-bottom: 18%;
  background:
    linear-gradient(var(--grate), var(--grate)) top / 100% 3px no-repeat,
    linear-gradient(var(--grate), var(--grate)) bottom / 100% 3px no-repeat,
    repeating-linear-gradient(90deg, var(--grate) 0 3px, transparent 3px 14px);
}

/* Ember bed: warm glow fading up from the firebox floor. */
.hero-grill-embers {
  position: absolute;
  left: 9%;
  right: 9%;
  bottom: 7%;
  height: 14%;
  background: radial-gradient(60% 100% at 50% 100%, color-mix(in oklab, var(--ember) 35%, transparent), transparent 70%);
}

.hero-grill-embers i {
  position: absolute;
  top: 50%;
  left: var(--x);
  width: 0.55rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, var(--ember-2) 0 22%, var(--ember) 42%, transparent 70%);
  box-shadow: 0 0 14px 3px var(--ember-glow);
  translate: -50% -50%;
  animation: flicker var(--dur-slow) var(--ease-in-out) infinite;
  animation-delay: calc(var(--d) * -0.4s);
}

.hero-grill-embers i:nth-child(1) { --x: 8%;  --d: 0; }
.hero-grill-embers i:nth-child(2) { --x: 28%; --d: 1; }
.hero-grill-embers i:nth-child(3) { --x: 50%; --d: 2; }
.hero-grill-embers i:nth-child(4) { --x: 72%; --d: 3; }
.hero-grill-embers i:nth-child(5) { --x: 92%; --d: 4; }

/* ---------- Scan line sweeping the stage ---------- */

.hero-scan {
  position: absolute;
  inset: 0;
  opacity: 0.55;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    transparent 80%,
    color-mix(in oklab, var(--steel) 12%, transparent) calc(100% - 1px),
    var(--steel) 100%
  );
  animation: scan calc(var(--dur-slow) * 4) var(--ease-in-out) infinite;
}

/* ---------- Floating UI cards (lifted in Z by --lift) ---------- */

.hero-card {
  position: absolute;
  translate: 0 0 var(--lift);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-lift);
}

/* Picker card: sits under the stage, never over the piece */
.hero-card-main {
  position: relative;
  margin-top: var(--space-4);
  padding: var(--space-4);
  translate: none;
  box-shadow: none;
}

.hero-card-top {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero-card-body strong {
  display: block;
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  line-height: 1.05;
  text-transform: uppercase;
}

.hero-card-meta {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--fs-sm);
  color: var(--muted);
}

/* Picker: piece name and line slide in from the side the user is moving towards. */
.hero-card-body.is-changing > * {
  animation: piece-in var(--dur) var(--ease-out) both;
}

.hero-card-body.is-changing > * + * {
  animation-delay: 60ms;
}

.hero-card-body[data-direction="prev"].is-changing > * {
  --from: -1.25rem;
}

@keyframes piece-in {
  from { opacity: 0; transform: translateX(var(--from, 1.25rem)); }
}

.hero-card-top strong {
  font-weight: 500;
  color: var(--text);
}

.hero-card-simulate {
  color: var(--ember-2);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}

.hero-card-simulate:hover {
  color: var(--ember);
}

/* Foot: one step per piece, then the arrows */
.hero-card-foot {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.hero-card-steps {
  display: flex;
  flex: 1;
  gap: 4px;
  margin: 0 var(--space-2) 0 0;
  padding: 0;
  list-style: none;
}

.hero-card-steps li {
  flex: 1;
  block-size: 2px;
  border-radius: 1px;
  background: var(--line-strong);
  transition: background-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}

.hero-card-steps li.is-active {
  background: var(--ember);
  box-shadow: 0 0 8px var(--ember-glow);
}

.hero-card-btn {
  display: grid;
  flex: none;
  place-items: center;
  inline-size: 2.5rem;
  block-size: 2.5rem;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font-size: var(--fs-base);
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}

.hero-card-btn:hover {
  border-color: var(--ember);
  background: var(--ember);
  color: var(--bg);
}

.hero-card-btn:active {
  scale: 0.92;
}

.hero-card-chip {
  top: 6%;
  right: 4%;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  white-space: nowrap;
  translate: 0 0 calc(var(--lift) * 1.5);
  animation: drift calc(var(--dur-slow) * 6) var(--ease-in-out) infinite alternate;
}

/* ---------- Phones ---------- */

@media (max-width: 959px) {
  .hero-visual {
    width: min(100%, 28rem);
  }

  .hero-stage {
    aspect-ratio: 1 / 0.95;
  }

  .hero-card-main {
    margin-top: var(--space-2);
    padding: var(--space-3) var(--space-4);
  }

  .hero-card-body strong {
    font-size: var(--fs-base);
  }

  .hero-card-chip {
    top: 2%;
    right: 2%;
  }
}

/* ---------- Touch screens: flat stage ----------
   Tilt needs a fine pointer, and a 3D context makes iOS Safari rasterise the canvas and cards at low resolution. */

@media (hover: none), (pointer: coarse) {
  .hero-visual {
    perspective: none;
  }

  .hero-stage {
    transform-style: flat;
    transform: none;
    transition: none;
  }

  .hero-card,
  .hero-card-chip {
    translate: none;
  }
}

/* ---------- Reduced motion: keep the composition, drop the movement ---------- */

@media (prefers-reduced-motion: reduce) {
  .hero-stage {
    transform: none;
    transition: none;
  }

  .hero-title .line > span,
  .hero-title em::after,
  html.is-ready .hero-title .line > span,
  html.is-ready .hero-title em::after {
    transform: none;
    transition: none;
  }

  .hero-orb,
  .hero-grill-embers i,
  .hero-card-body.is-changing > *,
  .hero-card-chip {
    animation: none;
  }

  .hero-scan {
    display: none;
  }
}
