/*
 * Clef landing (css/home.css): the hero on the staff, the live decision diagram, the math, the agent card and the
 * Decision Index preview. Everything shared (tokens, panels, prob rows, the diagram grid, code cards) lives in
 * css/clef.css; this file only lays out the landing. Owner: site builder.
 */

/* ------------------------------------------------------------------ hero */

/*
 * The hero is a full-bleed video of the Clef robot writing math on a chalkboard (media/hero-loop*.mp4, a seamless 5 s
 * loop, pre-softened when it was encoded). The filter is done with cheap layers, never a CSS filter on the video:
 *   .hero-poster  the first frame as an image (instant paint, the LCP, reduced motion and save-data keep only this)
 *   .hero-video   fades in over the poster once it plays (js/hero.js: plays only on screen and with motion allowed)
 *   .hero-scrim   one layer of gradients: a white wash behind the copy column feathering into the scene, a light
 *                 cream veil, a faint orange glow and a soft fade into the page at the bottom
 * Wide screens: the copy column sits on clean white at the left, the scene starts just right of it (--media-l).
 * Phones and portrait tablets: the scene is a band at the top that fades to white, the copy sits under it.
 * Nothing in here changes size when the video arrives, so the layout never shifts.
 */
.hero {
  --copy-w: min(600px, 56vw);
  /* the copy column's right edge, in the hero's own width (100% = the hero) */
  --copy-r: calc(max(0px, (100% - var(--wrap) - 2 * var(--gutter)) / 2) + var(--gutter) + var(--copy-w));
  --media-l: calc(var(--copy-r) - 140px);
  position: relative;
  isolation: isolate;
  overflow: clip;
  display: grid;
  align-items: center;
  min-height: clamp(520px, calc(100svh - var(--hdr-h) - 176px), 680px);
  padding-block: clamp(40px, 5vw, 72px) clamp(64px, 7vw, 104px);
}

.hero-media { position: absolute; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; background: var(--paper); }
.hero-poster, .hero-video {
  position: absolute; top: 0; right: 0; bottom: 0;
  left: var(--media-l);
  width: calc(100% - var(--media-l)); height: 100%; max-width: none;
  object-fit: cover; object-position: 50% 38%;
  user-select: none; -webkit-user-drag: none;
}
.hero-video { opacity: 0; transition: opacity 1s var(--ease); background: transparent; }
.hero-video.is-playing { opacity: 1; }
.hero-scrim {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .5) 0, rgba(255, 255, 255, 0) 64px),
    linear-gradient(180deg, rgba(255, 255, 255, 0) 68%, rgba(255, 255, 255, .55) 84%, rgba(255, 255, 255, .9) 94%, #fff 100%),
    linear-gradient(90deg, #fff 0, #fff calc(var(--copy-r) + 8px), rgba(255, 255, 255, .9) calc(var(--copy-r) + 64px),
      rgba(255, 255, 255, .74) calc(var(--copy-r) + 128px), rgba(255, 255, 255, .52) calc(var(--copy-r) + 200px),
      rgba(255, 255, 255, .32) calc(var(--copy-r) + 284px), rgba(255, 255, 255, .17) calc(var(--copy-r) + 380px),
      rgba(255, 255, 255, .08) calc(var(--copy-r) + 500px), rgba(255, 255, 255, .05) 100%),
    radial-gradient(55% 75% at 84% 28%, rgba(255, 128, 48, .10), rgba(255, 128, 48, 0) 72%),
    linear-gradient(rgba(255, 249, 242, .14), rgba(255, 249, 242, .14));
}

.hero-in { position: relative; width: 100%; }
.hero-copy { display: grid; justify-items: start; max-width: var(--copy-w); min-width: 0; }
.hero-copy .eyebrow { margin-bottom: 22px; }
.hero-title { font: 500 clamp(40px, 4.7vw, 70px)/1.02 var(--display); letter-spacing: -.03em; color: var(--ink); text-wrap: balance; max-width: 11.5em; }
.hero-sub { margin-top: 22px; max-width: 32em; font-size: clamp(17px, 1.45vw, 19px); line-height: 1.6; color: var(--body); text-wrap: pretty; }
.hero-cta { margin-top: 34px; display: flex; flex-wrap: wrap; gap: 12px; }
.hero-cta .btn .ico { transition: transform .25s var(--ease-out); }
.hero-cta .btn:hover .ico { transform: translateX(3px); }

/* the live ticker under the button: a pill, then three small figures (key above value) split by hairlines */
.ticker { margin-top: 30px; display: flex; align-items: center; }
.ticker-live { display: inline-flex; align-items: center; gap: 8px; height: 26px; padding: 0 11px 0 9px; border-radius: 999px; background: var(--chip); color: var(--rust); font: 600 11.5px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; margin-right: 20px; flex: none; }
.ticker-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 0 rgba(255, 94, 31, .45); animation: live-ring 2s var(--ease) infinite; }
@keyframes live-ring { 0% { box-shadow: 0 0 0 0 rgba(255, 94, 31, .45); } 80%, 100% { box-shadow: 0 0 0 7px rgba(255, 94, 31, 0); } }
.ticker-item { display: grid; gap: 6px; padding: 0 18px; white-space: nowrap; min-width: 0; }
.ticker-live + .ticker-item { padding-left: 0; }
.ticker-item + .ticker-item { border-left: 1px solid var(--line); }
.ticker-k { font: 600 10.5px/1 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ticker-v { font: 500 14px/1 var(--mono); color: var(--ink); font-variant-numeric: tabular-nums; }
.ticker-v .nil { width: 3em; }
/* before the deploy nothing is open: a quiet pill, no pulse (js/home.js) */
.ticker-live.is-soon { background: var(--concrete); color: var(--muted); }
.ticker-live.is-soon .ticker-dot { background: var(--faint); animation: none; }

/* one primary CTA in view: the header's Launch app waits until the hero button has scrolled away (js/home.js).
   While it waits its slot is folded to nothing (no hole at the header's right edge); it unfolds with an eased slide. */
[data-page="home"] .hdr-cta {
  max-width: 0; padding-inline: 0; border-width: 0; margin-left: -8px; overflow: hidden; opacity: 0; visibility: hidden;
  transition: max-width .3s var(--ease), padding .3s var(--ease), margin .3s var(--ease), opacity .2s var(--ease), visibility 0s linear .3s;
}
[data-page="home"].hero-cta-out .hdr-cta {
  max-width: 220px; padding-inline: 16px; border-width: 1px; margin-left: 0; opacity: 1; visibility: visible;
  transition: max-width .35s var(--ease), padding .35s var(--ease), margin .35s var(--ease), opacity .3s var(--ease) .08s, visibility 0s;
}
@media (max-width: 820px), (pointer: coarse) { [data-page="home"] .hdr-cta { margin-left: -4px; } }
@media (max-width: 380px) { [data-page="home"].hero-cta-out .hdr-cta { padding-inline: 12px; } }

/* phones and portrait tablets: the scene is a band on top that fades into the page; the copy sits under it */
@media (max-width: 899px) {
  .hero {
    --media-h: min(clamp(240px, 64vw, 460px), 58svh);
    --copy-w: 100%;
    display: block; min-height: 0;
    padding-block: calc(var(--media-h) - 44px) 52px;
  }
  .hero-media { bottom: auto; height: var(--media-h); }
  .hero-poster, .hero-video { left: 0; width: 100%; object-position: 62% 40%; }
  .hero-scrim {
    background:
      linear-gradient(180deg, rgba(255, 255, 255, .16) 0, rgba(255, 255, 255, .04) 30%, rgba(255, 255, 255, .5) 58%, rgba(255, 255, 255, .93) 80%, #fff 90%),
      radial-gradient(70% 60% at 80% 22%, rgba(255, 128, 48, .10), rgba(255, 128, 48, 0) 72%);
  }
  .hero-copy { justify-items: center; text-align: center; margin-inline: auto; max-width: 640px; }
  .hero-copy .eyebrow { margin-bottom: 14px; }
  .hero-title { max-width: 12em; }
  .hero-sub { margin-top: 16px; }
  .hero-cta { margin-top: 26px; justify-content: center; }
  .ticker { justify-content: center; margin-top: 24px; }
}
@media (max-width: 600px) {
  .ticker-live { display: none; }
  /* before the deploy the pill is the only thing that says nothing is open yet: keep it, on a row of its own */
  .ticker-live.is-soon { display: inline-flex; grid-column: 1 / -1; justify-self: center; margin-bottom: 14px; }
  .ticker { display: grid; grid-template-columns: repeat(3, minmax(0, auto)); justify-content: center; }
  .ticker-item { justify-items: center; padding: 0 16px; }
  .ticker-live + .ticker-item { padding-left: 16px; }
}
@media (max-width: 420px) {
  .hero-cta .btn { width: 100%; }
  .hero-cta { width: 100%; }
  .ticker-item { padding: 0 12px; }
  .ticker-live + .ticker-item { padding-left: 12px; }
}
@media (max-width: 359px) {
  .ticker-item { padding: 0 8px; }
  .ticker-live + .ticker-item { padding-left: 8px; }
  .ticker-v { font-size: 13px; }
}
/* a phone on its side: a short band, the copy close under it */
@media (max-width: 899px) and (orientation: landscape) and (max-height: 520px) {
  .hero { --media-h: min(52vh, 240px); padding-top: calc(var(--media-h) - 36px); }
}
/* reduced motion or no video: the poster stays (js/hero.js never starts the loop) */
@media (prefers-reduced-motion: reduce) {
  .hero-video { display: none; }
}

/* ------------------------------------------------------------------ the live decision */

.decision { padding-top: clamp(32px, 4.5vw, 64px); }
.decision-head { max-width: 860px; }
.decision .diagram { margin-top: 8px; }

.dg-quote { font: 600 clamp(17px, 1.5vw, 19px)/1.4 var(--display); letter-spacing: -.01em; color: var(--ink); text-wrap: pretty; margin-bottom: 14px; }
.dg-assets { display: grid; gap: 0; }
.dg-assets li { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto 72px; align-items: center; column-gap: 10px; padding: 8px 0; border-top: 1px solid rgba(251, 179, 79, .32); font-size: 14.5px; }
.dg-assets li:first-child { border-top: 0; }
.dg-assets b { font: 600 13.5px/1 var(--mono); color: var(--ink); letter-spacing: .01em; }
.dg-assets .dg-name { font: 400 13px/1 var(--sans); color: var(--rust); margin-left: 6px; opacity: .85; }
.dg-px { font: 500 13.5px/1 var(--mono); font-variant-numeric: tabular-nums; color: var(--ink); text-align: right; }
.dg-mv { font: 500 12.5px/1 var(--mono); font-variant-numeric: tabular-nums; text-align: right; color: var(--muted); }
.dg-mv.up { color: var(--good); }
.dg-mv.down { color: var(--bad); }

.dg-qs { display: grid; }
.dg-q { padding: 12px 0; border-top: 1px solid rgba(251, 179, 79, .32); }
.dg-q:first-child { padding-top: 2px; border-top: 0; }
.dg-q:last-child { padding-bottom: 2px; }
.dg-q-title { font: 600 clamp(16px, 1.35vw, 18px)/1.3 var(--display); letter-spacing: -.01em; color: var(--ink); text-wrap: pretty; }
.dg-q-opts { margin-top: 4px; font-size: 15px; line-height: 1.4; color: var(--rust); }

.dg-output .panel-head { margin-bottom: 10px; }
.dg-output .probs { gap: 9px; }
.dg-output .prob-name { font-size: 15px; }
.dg-session { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 12px; border-top: 1px solid rgba(251, 179, 79, .32); font: 500 12.5px/1.4 var(--mono); color: var(--rust); }
.dg-session::before { content: ''; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--orange); }
.dg-session.is-off::before { background: var(--plate); box-shadow: 0 0 0 1px #8fb0ee; }
.dg-soft { font-size: 13.5px; line-height: 1.55; color: var(--muted); text-wrap: pretty; }

/* static widths for the no-JS example (js/home.js sets --p inline once it runs) */
.prob-bar > i.w9 { --p: 9; } .prob-bar > i.w20 { --p: 20; } .prob-bar > i.w22 { --p: 22; } .prob-bar > i.w27 { --p: 27; }
.prob-bar > i.w31 { --p: 31; } .prob-bar > i.w33 { --p: 33; } .prob-bar > i.w38 { --p: 38; } .prob-bar > i.w48 { --p: 48; }
.prob-bar > i.w52 { --p: 52; } .prob-bar > i.w36 { --p: 36; }

.decision-foot { margin-top: clamp(28px, 4vw, 44px); display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 18px; text-align: center; font-size: 14.5px; color: var(--muted); }
.decision-src b { color: var(--ink); font-weight: 600; }

@media (max-width: 900px) {
  .decision-foot { justify-content: flex-start; text-align: left; }
}

/* ------------------------------------------------------------------ the math */

/* the crystal-ball clef on the staff (it left the hero for the video): five lines through the ball, fading out to
   both sides, in a row of their own so they never cross text */
.math { position: relative; overflow: clip; }
.math-staff { --orb-w: 210px; position: relative; width: var(--orb-w); height: calc(var(--orb-w) * 1.1047); margin: calc(-1 * clamp(8px, 2vw, 28px)) auto clamp(18px, 2.4vw, 28px); }
.math-lines {
  position: absolute; left: 50%; width: min(1200px, 100vw); max-width: none; transform: translateX(-50%);
  top: calc(var(--orb-w) * 1.1047 * .2195); height: calc(var(--orb-w) * 1.1047 * .202);
  overflow: visible;
  -webkit-mask-image: linear-gradient(90deg, transparent 6%, #000 34%, #000 66%, transparent 94%);
  mask-image: linear-gradient(90deg, transparent 6%, #000 34%, #000 66%, transparent 94%);
}
.math-lines line { stroke: var(--staff-line); stroke-width: 1.4px; vector-effect: non-scaling-stroke; }
.math-orb { position: relative; z-index: 1; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.math-spark { position: absolute; z-index: 1; color: var(--spark); width: var(--sw, 52px); height: auto; aspect-ratio: 3 / 2; transform: translate(-58%, -50%); animation: twinkle 5.5s var(--ease) infinite; animation-delay: var(--sd, 0s); }
.math-spark.s1 { top: 27%; left: -30%; --sw: 46px; }
.math-spark.s2 { top: 32.05%; left: 128%; --sw: 34px; --sd: -2.6s; }
@keyframes twinkle { 0%, 100% { opacity: 1; transform: translate(-58%, -50%) scale(1); } 50% { opacity: .62; transform: translate(-58%, -50%) scale(.86); } }

.math .sec-head { margin-bottom: clamp(36px, 5vw, 60px); }
.formulas { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: auto auto auto; }
.formula { display: grid; grid-row: span 3; grid-template-rows: subgrid; align-content: start; gap: 18px; padding: 4px clamp(20px, 2.6vw, 36px); border-left: 1px solid var(--line); min-width: 0; }
.formula:first-child { border-left: 0; padding-left: 0; }
.formula:last-child { padding-right: 0; }
.formula-k { font: 600 12.5px/1.3 var(--sans); letter-spacing: .07em; text-transform: uppercase; color: var(--orange-text); }
.formula-k span { display: block; margin-top: 4px; font: 500 12px/1.3 var(--mono); letter-spacing: .02em; text-transform: none; color: var(--muted); }
.formula .mathbox { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 10px; min-height: 96px; }
.formula math[display='block'] { font-size: clamp(19px, 1.7vw, 23px); margin: 0; }
.formula-where { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 22px; font-size: clamp(15px, 1.25vw, 17px); color: var(--body); }
.formula-where math { font-size: inherit; }
.formula p { font-size: 15px; line-height: 1.6; color: var(--body); max-width: 34ch; }
.scorer-slot { margin-top: clamp(40px, 5vw, 64px); }

@media (max-width: 900px) {
  .formulas { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  .formula { grid-row: auto; grid-template-rows: auto; padding: 26px 0; border-left: 0; border-top: 1px solid var(--line); }
  .formula:first-child { border-top: 0; padding-top: 0; }
  .formula .mathbox { min-height: 0; }
  .formula p { max-width: 60ch; }
}
@media (max-width: 760px) {
  .math-staff { --orb-w: 150px; }
  .math-spark.s1 { left: -34%; --sw: 36px; }
  .math-spark.s2 { left: 132%; --sw: 26px; }
}

/* ------------------------------------------------------------------ for agents */

.agents-in { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(32px, 5vw, 80px); align-items: center; }
.agents-art { position: relative; aspect-ratio: 1; border-radius: var(--r-xl); overflow: hidden; background: #ff7a00; box-shadow: var(--shadow-2); }
.agents-art img { width: 100%; height: 100%; object-fit: cover; }
.agents-copy { display: grid; gap: 18px; justify-items: start; min-width: 0; }
.agents-copy .lede { max-width: 40em; }
.agents-code { width: 100%; margin-top: 6px; }
.agents-code pre { font-size: 12.5px; white-space: pre; overflow-x: auto; }
@media (max-width: 600px) { .agents-code pre { font-size: 11.5px; padding: 14px 14px 16px; } }

@media (max-width: 860px) {
  .agents-in { grid-template-columns: minmax(0, 1fr); }
  .agents-art { max-width: 420px; width: 100%; justify-self: center; order: 2; }
}

/* ------------------------------------------------------------------ Decision Index preview */

.index-prev { padding-top: 0; padding-bottom: clamp(56px, 7vw, 96px); }
.index-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 32px; max-width: none; flex-wrap: wrap; }
.index-head > div { display: grid; gap: 14px; }
.board { border-top: 1px solid var(--line); }
.board .tbl td { padding-block: 15px; }
.board .tbl .rank { width: 56px; font: 600 13px/1 var(--mono); color: var(--muted); }
.board .tbl tr:first-child .rank { color: var(--orange-text); }
.board .tbl .who { font: 500 14px/1 var(--mono); color: var(--ink); white-space: nowrap; }
.board .tbl td.num { white-space: nowrap; }
.board .tbl td.up { color: var(--good); }
.board .tbl td.down { color: var(--bad); }
.board .tbl .who .you { margin-left: 8px; }
.board-note { margin-top: 14px; font-size: 13px; color: var(--muted); }
@media (max-width: 640px) {
  .board .tbl .hide-sm { display: none; }
  .board .tbl th, .board .tbl td { padding-inline: 8px; }
  .board .tbl th:first-child, .board .tbl td:first-child { padding-left: 0; }
  .board .tbl th:last-child, .board .tbl td:last-child { padding-right: 0; }
  .board .tbl td { font-size: 13px; }
  .board .tbl .who { font-size: 13px; }
  .board .tbl .rank { width: 36px; }
}

/* ------------------------------------------------------------------ motion preferences */

@media (prefers-reduced-motion: reduce) {
  .ticker-dot, .math-spark { animation: none; }
}

/* recent settled rounds under the index preview, each linking to its recap */
.index-recent { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin-top: 16px; font: 500 13.5px/1.4 var(--mono); }
.index-recent-k { font: 600 11.5px/1.2 var(--sans); letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
@media (max-width: 820px), (pointer: coarse) { .index-recent a { min-height: 44px; display: inline-flex; align-items: center; } }
