/* About (the legend for the capsule, the rules, the scoring slider) and the 404 / error pages. */

/* Short Chinese paragraphs (.ph) break after punctuation and at the <wbr> the template marks, never inside a word. */
:lang(zh-CN) .ph { word-break: keep-all; overflow-wrap: anywhere; text-wrap: balance; }
.nb { white-space: nowrap; }

/* ---------- About: the opening ---------- */
.opening { min-height: 80vh; min-height: 80svh; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: clamp(24px, 3.5vw, 64px); align-items: center; padding: clamp(96px, 14vh, 150px) var(--pad) 0; overflow-x: clip; container-type: inline-size; }
.opening h1 { font: 300 clamp(40px, 5.2vw, 88px)/1.02 var(--sans); letter-spacing: -.04em; margin-top: clamp(14px, 2.4vh, 26px); text-wrap: balance; }
:lang(zh-CN) .opening h1 { letter-spacing: -.01em; line-height: 1.15; }
.opening h1 span, .closing h2 span, .left h1 span { display: inline-block; }      /* lines break between phrases, never inside one */
.lede { font-size: clamp(17px, 1.4vw, 22px); line-height: 1.5; color: var(--text); max-width: 30em; margin-top: clamp(20px, 3.6vh, 40px); }
:lang(zh-CN) .lede { line-height: 1.8; }

/* The legend: a real forecast on the stage, marked up. Every mark is placed from the frame geometry the server prints:
   --ys liquid surface, --yb base-rate line, --yc a point inside the liquid (top, % of the frame); --xs --xb --xr glass edge there (left, %).
   Narrow screens (and forecasts that sit too close to their base rate to label) get short marks and a key underneath. */
.legend { --h: clamp(300px, 44svh, 400px); --w: calc(var(--h) * .4); --lead: 18px; position: relative; display: grid; justify-items: center; }
.legend .stage { height: var(--h); }
.legend .vial { animation: none; }               /* pinned: the marks point at exact levels */
.vial img { width: 100%; height: 100%; }
.tick.at-p { top: calc(var(--ys) * 1%); }
.tick.at-p i { border-top-style: solid; }
/* two labels on nearly the same level step apart, just far enough for both to be read (--gap: % of the frame between them) */
.legend .tick span { translate: 0 calc(var(--dir) * max(0px, 10px - var(--h) * var(--gap) / 200)); }
.ld { position: absolute; z-index: 4; left: calc(var(--x) * 1% + 10px); top: calc(var(--at) * 1%); width: calc((var(--xr) - var(--x)) * 1% + var(--lead)); border-top: 1px solid var(--dim); }
.ld-p { --x: var(--xs); --at: var(--ys); }
.ld-base { --x: var(--xb); --at: var(--yb); border-top-style: dashed; }
.ld-hue { visibility: hidden; --x: var(--xr); --at: var(--yc); }
.ld-gap { left: calc(var(--xr) * 1% + 28px); top: calc(var(--g0) * 1%); height: calc((var(--g1) - var(--g0)) * 1%); width: 0; border-top: 0; border-left: 1px solid var(--dim); }
.ld-gap::after { content: ""; position: absolute; left: 0; top: 50%; width: 0; border-top: 1px solid var(--dim); }
.notes { list-style: none; padding: 0; display: grid; gap: 8px; width: 100%; max-width: 420px; margin-top: calc(var(--h) * .13); font-size: 14px; line-height: 1.4; color: var(--text); }      /* clear of the reflection */
.note { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 12px; }
.note b { font-weight: 400; color: var(--fg); }
.note small { display: block; font-size: 13px; color: var(--dim); }
.key { margin-top: .7em; border-top: 1px solid var(--dim); }
.n-base .key { border-top-style: dashed; }
.n-gap .key { justify-self: center; width: 6px; height: 12px; margin-top: .25em; border: 1px solid var(--dim); border-left: 0; }
.key.sw { justify-self: center; width: 7px; height: 7px; margin-top: .45em; border: 0; background: var(--glow); }
.n-crl .sw { background: var(--crl); }
.legend figcaption { width: 100%; max-width: 420px; margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); }
.legend figcaption a { position: relative; color: var(--fg); text-transform: none; letter-spacing: .02em; margin-left: .3em; text-decoration: underline 1px var(--line-2); text-underline-offset: 5px; transition: text-decoration-color .3s; }
.legend figcaption a:hover { text-decoration-color: var(--glow); }

/* The marks draw in one after another: the dashed line first, while the liquid still sits on it, the rest once the liquid
   has landed (site.js adds .landed). Only animations hide them, so without scripts, with reduced motion, or if the stage
   never reports in, they are simply there. None of this sits in a media query: a resize must not replay it. */
@keyframes draw { from { clip-path: inset(-2px 100% -2px 0); } to { clip-path: inset(-2px 0 -2px 0); } }
@keyframes drop { from { clip-path: inset(0 -80px 100% -2px); } to { clip-path: inset(0 -80px 0 -2px); } }
@keyframes rise { from { clip-path: inset(100% -80px 0 -2px); } to { clip-path: inset(0 -80px 0 -2px); } }
@keyframes note { from { opacity: 0; translate: -8px 0; } }
@keyframes late { from { opacity: 0; } }
.js .ld-base { animation: draw .4s .2s var(--ease) both; }
.js [data-stage] ~ .notes .n-base { animation: note .4s .3s var(--ease) both; }
.js [data-stage]:not(.landed) :is(.at-p, .ld-p, .ld-gap, .ld-hue), .js [data-stage]:not(.landed) ~ .notes :is(.n-p, .n-gap, .n-hue, .n-crl) { animation: late 0s 6s both; }
.js .landed .at-p { animation: note .4s var(--ease) both; }
.js .landed .ld-p { animation: draw .4s var(--ease) both; }
.js .landed ~ .notes .n-p { animation: note .4s .1s var(--ease) both; }
.js .landed .ld-gap { animation: drop .4s .4s var(--ease) both; }
.js .landed .ld-gap.up { animation-name: rise; }
.js .landed ~ .notes .n-gap { animation: note .4s .5s var(--ease) both; }
.js .landed .ld-gap::after { animation: draw .3s .6s var(--ease) both; }
.js .landed .ld-hue { animation: draw .4s .8s var(--ease) both; }
.js .landed ~ .notes :is(.n-hue, .n-crl) { animation: note .4s .9s var(--ease) both; }

@media (min-width: 721px) {
  .legend { --h: clamp(380px, 56svh, 620px); grid-template-columns: var(--w) clamp(280px, 24vw, 340px); justify-items: stretch; margin-left: 76px; }      /* room for the tick labels hanging off the capsule's left side */
  :lang(en) .legend { margin-left: 104px; }
  /* the key beside the capsule, its caption right under it: the two rows share the capsule's height, so the pair is centred on it */
  .legend.is-list { column-gap: 28px; }
  .legend.is-list .stage { grid-row: 1 / 3; }
  .legend.is-list .notes { align-self: end; margin: 0; }
  .legend.is-list figcaption { grid-column: 2; align-self: start; width: auto; margin-left: 34px; }      /* under the text, not the glyphs */
  .legend.is-list .notes:last-child { grid-row: 1 / 3; align-self: center; }      /* no example on the record: no caption */

  /* leaders: each label sits at the end of its line, level with what it names */
  .legend:not(.is-list) { --lead: 46px; }
  .legend:not(.is-list) .ld-hue { visibility: visible; width: calc(var(--lead) - 16px); }      /* stops short of the swatch */
  .legend:not(.is-list) .ld-gap::after { width: calc(var(--lead) - 18px); }
  .legend:not(.is-list) .notes { display: block; position: relative; max-width: none; margin: 0; }
  .legend:not(.is-list) .note { display: block; position: absolute; top: calc(var(--at) * 1%); left: calc(var(--w) * (var(--xr) - 100) / 100 + var(--lead) + 20px); right: 0; transform: translateY(-.7em); }
  .legend:not(.is-list) .n-p { --at: var(--ys); }
  .legend:not(.is-list) .n-base { --at: var(--yb); }
  .legend:not(.is-list) .n-gap { --at: calc((var(--g0) + var(--g1)) / 2); }
  .legend:not(.is-list) :is(.n-hue, .n-crl) { --at: var(--yc); }
  .legend:not(.is-list) .n-crl { transform: translateY(calc(1.4em + 5px - .7em)); }
  .legend:not(.is-list) .key { display: none; }
  .legend:not(.is-list) .key.sw { display: block; position: absolute; left: -17px; top: calc(.7em - 3.5px); margin: 0; }
  .legend:not(.is-list) figcaption { position: absolute; bottom: calc((100 - var(--yf)) * 1%); left: calc(var(--w) * var(--xr) / 100 + var(--lead) + 20px); right: 0; width: auto; margin: 0; padding: 0; border: 0; }
}

/* ---------- About: the rules ---------- */
.rules { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(36px, 6vh, 56px) var(--pad); }
/* The row starts at the fold, where its top edge is the cue to scroll: it comes in with the page, not on scroll. */
.rules article { border-top: 1px solid var(--line); padding-top: 14px; animation: fade 1.2s .3s both; }
.rules article:nth-child(2) { animation-delay: .38s; }
.rules article:nth-child(3) { animation-delay: .46s; }
.rules article:nth-child(4) { animation-delay: .54s; }
.rules h2 { font: 300 clamp(22px, 1.9vw, 30px)/1.15 var(--sans); letter-spacing: -.02em; margin: clamp(28px, 5vh, 56px) 0 12px; }
:lang(zh-CN) .rules h2 { letter-spacing: 0; line-height: 1.3; }
.rules article > p:last-child, .rules li { color: var(--text); max-width: 34em; }
:lang(en) .rules :is(p, li) { text-wrap: pretty; }      /* English only: `pretty` rebreaks Chinese inside its words, where the .nb tails keep the last line long enough instead */
.rules ul { list-style: none; padding: 0; display: grid; gap: 6px; }

/* ---------- About: the scoring slider ---------- */
.score { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 9fr); gap: var(--pad); align-items: start; padding-top: clamp(22px, 4vh, 40px); }
.no-js .js-only { display: none; }
.worked { font-size: clamp(17px, 1.4vw, 22px); line-height: 1.5; color: var(--fg); max-width: 30em; text-wrap: balance; }
.guess { display: flex; align-items: baseline; gap: 14px; }
.guess .num { font-size: 28px; line-height: 1; color: var(--fg); }
.slider { position: relative; margin: 18px max(0px, 22px - var(--pad)) 0; }      /* the input overhangs by half a thumb: keep that on the page */
.scale { display: flex; justify-content: space-between; }
.scale span { width: 0; height: 30px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.scale span::after { content: ""; width: 1px; height: 5px; background: var(--dim); }
.scale span:nth-child(5n + 1)::after { height: 9px; }
.scale b { font-weight: 400; margin-bottom: 6px; letter-spacing: .04em; }
.scale span:first-child { align-items: flex-start; }
.scale span:last-child { align-items: flex-end; }
/* The input is wider than the scale by one thumb, so the thumb's centre stops exactly on the end ticks. The thumb is a
   44px square to grab; what shows is its content box (the 12 x 26 pill) inside its padding box (the gap it cuts in the track). */
.slider input { -webkit-appearance: none; appearance: none; display: block; width: calc(100% + 44px); height: 44px; margin: -14px -22px 0; cursor: pointer; touch-action: pan-y;
  background: linear-gradient(var(--glow), var(--glow)) 22px 50% / calc((100% - 44px) * var(--v) / 100) 1px no-repeat, linear-gradient(var(--line-2), var(--line-2)) 22px 50% / calc(100% - 44px) 1px no-repeat; }
.slider input::-webkit-slider-runnable-track { height: 44px; background: none; }
.slider input::-moz-range-track { height: 44px; background: none; }
.slider input::-webkit-slider-thumb { -webkit-appearance: none; box-sizing: border-box; width: 44px; height: 44px; border: solid transparent; border-width: 4px 11px; padding: 5px; border-radius: 22px / 15px;
  background: linear-gradient(var(--fg), var(--fg)) content-box, linear-gradient(var(--bg), var(--bg)) padding-box, radial-gradient(closest-side, rgba(var(--glow-rgb), .4), transparent) border-box; }
.slider input::-moz-range-thumb { box-sizing: border-box; width: 44px; height: 44px; border: solid transparent; border-width: 4px 11px; padding: 5px; border-radius: 22px / 15px;
  background: linear-gradient(var(--fg), var(--fg)) content-box, linear-gradient(var(--bg), var(--bg)) padding-box, radial-gradient(closest-side, rgba(var(--glow-rgb), .4), transparent) border-box; }
.slider input:focus-visible { outline: none; }
.slider input:focus-visible::-webkit-slider-thumb { box-shadow: inset 0 0 0 1px var(--glow); }
.slider input:focus-visible::-moz-range-thumb { box-shadow: inset 0 0 0 1px var(--glow); }
.outs-h { display: flex; justify-content: space-between; gap: 16px; margin-top: 22px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.outs { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; }      /* rows share the columns: every bar starts at the same x */
.outs, .outs > div, .outs dd { column-gap: clamp(14px, 2.4vw, 32px); }
.outs > div { grid-column: 1 / -1; display: grid; grid-template-columns: 10em minmax(0, 1fr); grid-template-columns: subgrid; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.outs dd { grid-column: 2 / -1; display: grid; grid-template-columns: minmax(0, 1fr) 3em; grid-template-columns: subgrid; align-items: center; }      /* a real box, so it stays a definition to assistive tech */
.outs i { height: 2px; background: linear-gradient(var(--fg), var(--fg)) 0 0 / var(--e) 100% no-repeat, var(--line); }
.outs .num { font-size: 17px; text-align: right; min-width: 4ch; }      /* room for 1.00, so the bars do not shift */
.outs .ref { color: var(--dim); }
.outs .ref i { background-image: linear-gradient(var(--dim), var(--dim)); }
.verdict { display: grid; margin-top: 18px; color: var(--text); max-width: 36em; text-wrap: balance; }
.verdict::before { content: attr(data-no); visibility: hidden; }      /* the longest of its three sentences, unseen, holds the height */
.verdict::before, .verdict span { grid-area: 1 / 1; }

/* ---------- About: the close ---------- */
.closing h2 { max-width: 15em; text-wrap: balance; }
.ways { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 32px; margin-top: clamp(22px, 4vh, 40px); }
.ways a { position: relative; }
.quiet { color: var(--dim); font-size: 14px; padding: 6px 0; border-bottom: 1px solid var(--line); transition: color .3s, border-color .3s; }
.quiet:hover { color: var(--fg); border-color: var(--line-2); }

/* ---------- 404 and other errors: the homepage stage again, with the capsule empty ---------- */
.lost { position: relative; min-height: 100vh; min-height: 100svh; display: grid; grid-template-columns: minmax(0, 5fr) auto minmax(0, 4fr); gap: clamp(12px, 2.5vw, 48px); align-items: center; padding: 76px var(--pad) 0; overflow: hidden; }
.left { align-self: stretch; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding-bottom: 7vh; position: relative; z-index: 2; }
.left .mono { text-wrap: balance; }
.left h1 { font-size: clamp(28px, 4.4vw, 72px); margin-top: 14px; text-wrap: balance; }
.left h1 + p:not(.ways) { color: var(--dim); margin-top: clamp(12px, 2vh, 20px); max-width: 32em; text-wrap: pretty; }
.lost .stage { height: min(84vh, 880px); align-self: center; }
.queue { align-self: stretch; display: flex; flex-direction: column; justify-content: center; padding-bottom: 4vh; position: relative; z-index: 2; }
.queue .h { display: flex; justify-content: space-between; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.queue ol { list-style: none; padding: 0; }
.row { display: grid; grid-template-columns: 3.6em 4.4em 1fr auto; gap: 10px; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--dim); font-size: 14px; transition: color .3s, border-color .3s; }
.row .d, .row .t { font: 400 12px var(--mono); letter-spacing: .04em; }
.row .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .p { font: 400 14px var(--mono); font-variant-numeric: tabular-nums; }
.row:hover, .row:focus-visible { color: var(--fg); border-color: var(--line-2); }

@media (min-width: 1000px) {
  .opening h1 { font-size: clamp(46px, 6.6vw - 20px, 88px); }      /* sized to the column the legend leaves it */
  :lang(en) .opening h1 { font-size: clamp(42px, min(6.6vw - 20px, 9.85vw - 55.7px), 88px); }      /* English lines are longer: below 1100px they shrink with the column, so the three lines hold */
  .legend { --h: clamp(380px, min(56svh, 40vw), 620px); }          /* on a tall, narrow window the headline keeps its width */
}
@media (min-width: 1200px) {
  /* the legend's text starts on the left edge of the fourth rules column underneath */
  @supports (width: 1cqw) {
    .legend:not(.is-list) { grid-template-columns: var(--w) calc((100cqw - 3 * var(--pad)) / 4 + var(--lead) + 20px - var(--w) * (100 - var(--xr)) / 100); }
    .legend.is-list { grid-template-columns: var(--w) calc((100cqw - 3 * var(--pad)) / 4 + 34px); }      /* 34px: the key's glyphs hang to the left of it */
  }
}
@media (max-width: 1199px) {
  .rules { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rules h2 { margin-top: 24px; }
}
@media (max-width: 1100px) {
  .score { grid-template-columns: minmax(0, 1fr); gap: 28px; }
}
@media (max-width: 1020px) {
  .lost { grid-template-columns: minmax(0, 1fr) auto; padding-bottom: 28px; align-items: start; align-content: start; }      /* rows keep their own height: a short page starts at the top */
  .left { padding: 3vh 0 0; }
  .lost .stage { --sh: min(56vh, 520px); height: var(--sh); margin: 0 -4% calc(var(--sh) * .15) 0; }      /* the bottom margin is the reflection's: the rows start below it */
  .queue { grid-column: 1 / -1; padding: 12px 0 0; }
}
@media (max-width: 999px) {
  .opening { grid-template-columns: minmax(0, 1fr); min-height: 0; gap: clamp(40px, 8vh, 72px); }
  .legend { justify-self: end; }                    /* text top left, legend bottom right */
}
@media (max-width: 720px) {
  .opening { padding-top: 96px; }
  .legend { justify-self: stretch; }
  .legend [data-stage] { margin-left: 44px; }       /* the two tick labels hang off its left side: centre the pair, not the frame */
}
@media (max-width: 560px) {
  .rules { grid-template-columns: minmax(0, 1fr); }
  :lang(en) .closing h2 { font-size: min(34px, 9vw); }      /* "is not any one forecast." stays on one line down to 320px */
  .lost .stage { --sh: 46vh; margin-right: -9%; }
}
@media (pointer: coarse) {
  /* 44px tap height, without moving the underline away from its words */
  .ways { row-gap: 18px; }
  .ways a::before, .legend figcaption a::before { content: ""; position: absolute; inset: -6px 0; }
  .legend figcaption a::before { inset: -15px 0; }
}
