/* Gamut Arc, in full: two fields from one of Chevreul's colours to its opposite. The round field's colour and
   chroma are keyframes written from his measured sectors (in the page's head, one set per pair); the straight
   field is color-mix in Oklab. One sticky frame on the run's view timeline drives --t for both, the markers on
   the plate, and the readouts. The pair is a radio; :has() hands its numbers to the stage. */

@property --t{syntax:'<number>';inherits:true;initial-value:0}
@property --round{syntax:'<color>';inherits:true;initial-value:#888}
@property --cr{syntax:'<number>';inherits:true;initial-value:0}

.gamut{position:relative;width:100vw;margin-inline:calc(50% - 50vw);border:0;border-radius:0;background:#141210;color:#F4EEE4}
.run{height:calc(100svh - var(--bar) + 280svh);view-timeline:--route block;view-timeline-inset:var(--bar) 0px}
.fields{position:sticky;top:var(--bar);height:calc(100svh - var(--bar));overflow:clip;
  display:grid;grid-template-columns:1fr 1fr;
  --straight:color-mix(in oklab,var(--a),var(--b) calc(var(--t) * 100%));
  --cs:sqrt(pow((1 - var(--t)) * var(--a1) + var(--t) * var(--a2), 2) + pow((1 - var(--t)) * var(--b1) + var(--t) * var(--b2), 2));
  animation:progress linear both,round-jaune linear both;animation-timeline:--route;animation-range:contain 4% contain 96%}
@keyframes progress{from{--t:0}to{--t:1}}

/* each field wears its route's colour, and its ink flips with the colour's lightness */
.field{position:relative;display:grid;grid-template-rows:auto 1fr auto;align-content:space-between;min-width:0;
  padding:clamp(20px,4.5vh,44px) clamp(20px,4.5vw,72px);background:var(--fill);
  color:oklch(from var(--fill) clamp(.17, (.7 - l) * 999, .97) .012 h)}
.field.round{--fill:var(--round);--c:var(--cr)}
.field.straight{--fill:var(--straight);--c:var(--cs);justify-items:end;text-align:right}
.road{margin:0;display:grid;grid-template-columns:auto 1fr;align-items:center;gap:6px 10px;max-width:15rem}
.road b{font:400 10px/1.3 var(--mono);letter-spacing:.16em;text-transform:uppercase}
.road span{grid-column:2;font-size:12.5px;line-height:1.4;opacity:.8}
.straight .road{grid-template-columns:1fr auto}
.straight .road b{grid-area:1/1}.straight .road .glyph{grid-area:1/2}.straight .road span{grid-column:1}
.glyph{width:11px;height:11px;border-radius:50%;background:currentColor}
.straight .glyph{background:none;box-shadow:inset 0 0 0 2px currentColor}

/* where the round route is: Chevreul's name for the sector, with his step number */
.now{align-self:end;margin-bottom:clamp(10px,2.4vh,22px)}
.names{display:grid;margin:0;padding:0;list-style:none}
.names li{grid-area:1/1;font-family:var(--display);font-style:italic;font-size:clamp(40px,5.8vw,92px);line-height:1;letter-spacing:-.02em;
  opacity:clamp(0, (.5 - abs(var(--t) * var(--n) - var(--j))) * 999, 1)}
.names small{font-family:var(--mono);font-style:normal;font-size:.3em;letter-spacing:.1em;vertical-align:.9em;margin-left:.3em}
/* what the straight route is: a mixture of the two, by weight, set as a recipe */
.mix{align-self:end;margin:0 0 clamp(10px,2.4vh,22px);font-family:var(--display);font-style:italic;font-size:clamp(26px,3.3vw,52px);line-height:1.08;white-space:pre;
  counter-reset:pa calc(100 - var(--t) * 100) pb calc(var(--t) * 100)}
/* the weights in Switzer (Melodrama's zero is slashed), Chevreul's names in the italic */
.mix span{display:block}
.mix span::before{font-family:var(--sans);font-style:normal;font-weight:400;letter-spacing:-.03em;font-variant-numeric:tabular-nums}
.mix span:first-child::before{content:counter(pa) '% '}
.mix span:first-child::after{content:var(--na)}
.mix span:last-child::before{content:counter(pb) '% '}
.mix span:last-child::after{content:var(--nb)}

/* how much colour is left: a meter, and its number */
.meter{display:grid;grid-template-columns:auto minmax(0,1fr) 3.4em;align-items:center;gap:12px;width:min(100%,380px);margin:0;
  font:10px/1 var(--mono);letter-spacing:.14em;text-transform:uppercase}
.meter i{order:2}.meter b{order:3}
.straight .meter{grid-template-columns:3.4em minmax(0,1fr) auto}
.straight .meter span{order:3}.straight .meter b{order:1}
.meter i{position:relative;height:2px;background:color-mix(in oklab,currentColor 25%,transparent)}
.meter i::after{content:'';position:absolute;inset:-1px auto -1px 0;width:calc(min(var(--c) / .3, 1) * 100%);background:currentColor}
.straight .meter i::after{inset:-1px 0 -1px auto}
.meter b{font-weight:400;font-size:13px;letter-spacing:.04em;counter-reset:c calc(var(--c) * 100)}
.meter b::before{content:'.' counter(c, decimal-leading-zero)}

/* the plate, over the seam: a marker rides each route on it */
.medallion{--d:min(50svh,38vw);position:absolute;left:50%;top:46%;width:var(--d);height:var(--d);margin:0;translate:-50% -50%;
  border-radius:50%;overflow:clip;background:#EEE6D6;
  box-shadow:0 34px 90px -30px rgb(0 0 0 / .7),0 0 0 1px rgb(255 255 255 / .25)}
.medallion img{position:absolute;left:calc(var(--ix) * var(--d));top:calc(var(--iy) * var(--d));
  width:calc(var(--iw) * var(--d));height:calc(var(--ih) * var(--d));max-width:none}
/* the round route along the rim: travelled solid, still to come faint */
.arc{position:absolute;inset:0;border-radius:50%;
  background:conic-gradient(from var(--arc-from),
    rgb(255 255 255 / .5) 0 calc(var(--flip) * (1 - var(--t)) * var(--span)),
    #fff 0 calc(var(--flip) * var(--span) + (1 - var(--flip)) * var(--t) * var(--span)),
    rgb(255 255 255 / .5) 0 var(--span),transparent 0);
  mask:radial-gradient(circle closest-side,transparent calc(var(--m) * 100% - 1.5px),#000 0 calc(var(--m) * 100% + 1.5px),transparent 0)}
/* the straight route across it */
.chord{position:absolute;left:calc(50% + var(--ax) * 50%);top:calc(50% + var(--ay) * 50%);width:calc(var(--chord) * 50%);height:0;
  border-top:2px dashed rgb(255 255 255 / .9);transform-origin:0 0;rotate:var(--chord-angle);filter:drop-shadow(0 0 1px rgb(0 0 0 / .5))}
.marker{position:absolute;left:50%;top:50%;width:16px;height:16px;margin:-8px;border-radius:50%}
.marker.round{background:#fff;box-shadow:0 0 0 2px rgb(0 0 0 / .5),0 2px 8px rgb(0 0 0 / .4);
  translate:calc(cos(var(--th0) + var(--t) * var(--sweep)) * var(--m) * var(--d) / 2)
            calc(sin(var(--th0) + var(--t) * var(--sweep)) * var(--m) * var(--d) / 2)}
.marker.straight{box-shadow:inset 0 0 0 3px #fff,0 0 0 2px rgb(0 0 0 / .5),0 2px 8px rgb(0 0 0 / .4);
  translate:calc(((1 - var(--t)) * var(--ax) + var(--t) * var(--bx)) * var(--d) / 2)
            calc(((1 - var(--t)) * var(--ay) + var(--t) * var(--by)) * var(--d) / 2)}

/* the pairs: each chip shows its two ends */
.pairs{position:absolute;left:50%;top:clamp(14px,3vh,26px);translate:-50% 0;display:flex;gap:4px;margin:0;padding:5px;
  border:0;border-radius:999px;background:rgb(20 18 16 / .55);backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px)}
.pairs legend{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.pairs input{position:absolute;opacity:0;pointer-events:none}
.pairs label{display:flex;align-items:center;gap:9px;padding:8px 14px 8px 9px;border-radius:999px;cursor:pointer;
  font:10px/1 var(--mono);letter-spacing:.1em;text-transform:uppercase;color:rgb(244 238 228 / .72);white-space:nowrap;
  transition:background-color .3s var(--settle),color .3s var(--settle)}
.pairs label b{font-weight:400;opacity:.6}
.pairs .dot{width:18px;height:18px;border-radius:50%;background:linear-gradient(135deg,var(--ca) 50%,var(--cb) 50%);
  box-shadow:0 0 0 1px rgb(255 255 255 / .35)}
.pairs input:checked + label{background:rgb(244 238 228 / .94);color:#1B1814}
.pairs input:focus-visible + label{outline:2px solid #F4EEE4;outline-offset:2px}
.pairs label:hover{color:#F4EEE4}
.pairs input:checked + label:hover{color:#1B1814}

@media (max-width:760px){
  /* stacked: the round route above, the straight below, the plate on the seam between them */
  .fields{grid-template-columns:minmax(0,1fr);grid-template-rows:1fr 1fr}
  .field{grid-template-rows:none;align-content:start;gap:12px;padding:16px 18px}
  .field.straight{justify-items:start;text-align:left;align-content:end;padding-bottom:74px}
  .straight .road{grid-template-columns:auto 1fr}
  .straight .road .glyph{grid-area:1/1}.straight .road b{grid-area:1/2}.straight .road span{grid-column:2}
  .now,.mix{align-self:auto;margin:6px 0 0}
  .names li{font-size:clamp(30px,9.5vw,46px)}
  .mix{font-size:clamp(20px,6.2vw,30px)}
  .straight .meter{grid-template-columns:auto minmax(0,1fr) 3.4em}
  .straight .meter span{order:1}.straight .meter b{order:3}
  .straight .meter i::after{inset:-1px auto -1px 0}
  .medallion{--d:min(46vw,26svh);top:50%}
  .pairs{top:auto;bottom:12px;width:max-content;max-width:calc(100vw - 20px)}
  .pairs label{padding:7px}
  .pairs label span{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
}
