/* ---------- Named values ---------- */
:root {
  /* The six blocks, F to A+ (the designer's measured colours: every letter passes 4.5 to 1 on its own). */
  --dial-f0: #e5492f; /* F  red */
  --dial-f1: #f27a30; /* D  reddish orange */
  --dial-f2: #fcb316; /* C  orange yellow: the brand yellow itself */
  --dial-f3: #fae352; /* B  yellow */
  --dial-f4: #b2d94c; /* A  greenish yellow */
  --dial-f5: #7fd487; /* A+ green */
  /* How the grade stands out: the other five drop to this strength over cream; the grade's block grows. */
  --dial-dim: 0.35;
  --dial-block-outline: 49; --dial-block: 40;
  --dial-grade-outline: 64; --dial-grade-block: 52;
  /* The case. Brass is browner and duller than the yellow. */
  --dial-brass-1: #f3dc9f; --dial-brass-2: #c69a48; --dial-brass-3: #8a6428; --dial-brass-4: #b98c3d; --dial-brass-5: #5d4117;
  --dial-lip-1: #5d4117; --dial-lip-2: #9a7230; --dial-lip-3: #ecd08c;
  --dial-face-1: #fdf6e3; --dial-face-2: #f3e7c8; --dial-face-3: #e2d0a4;
  --dial-cream: #f4ead2;
  --dial-shade: rgba(0, 0, 0, 0.28);
  --dial-screw: #6b4f1f; --dial-screw-edge: #e6cc8a; --dial-screw-slot: #2e210b;
  --dial-outline: #231f20;
  --dial-ink: #151213;
  --dial-window: #fffaf0; --dial-window-edge: #3a2a10;
  --dial-needle: #231f20; --dial-needle-tip: #b3261e; --dial-needle-cast: rgba(0, 0, 0, 0.2);
  --dial-hub-in: #3a2a10;
  /* No grade: the brass and the blocks turned grey. */
  --dial-off-brass: #8c8884; --dial-off-lip: #6d6966; --dial-off-face: #e9e6e0; --dial-off-block: #cfcbc5; --dial-off-outline: #77736f;
  --dial-off-letter: #4d4849; --dial-off-name: #5f5b5c; --dial-off-screw-edge: #b9b5b0; --dial-off-window: #f6f4f0; --dial-off-window-edge: #5f5b5c;
  /* The small dial beside a group's heading. */
  --mini-ring: #a17a35; --mini-ring-in: #6b4f1f; --mini-off: #d6c9a6;
}

.dial { aspect-ratio: 1; max-width: 300px; font-family: var(--font); }
@media (min-width: 760px) { .dial { max-width: 340px; } }
.dial text { text-anchor: middle; font-weight: 800; }
.dial .br1 { stop-color: var(--dial-brass-1); } .dial .br2 { stop-color: var(--dial-brass-2); } .dial .br3 { stop-color: var(--dial-brass-3); }
.dial .br4 { stop-color: var(--dial-brass-4); } .dial .br5 { stop-color: var(--dial-brass-5); }
.dial .lp1 { stop-color: var(--dial-lip-1); } .dial .lp2 { stop-color: var(--dial-lip-2); } .dial .lp3 { stop-color: var(--dial-lip-3); }
.dial .fc1 { stop-color: var(--dial-face-1); } .dial .fc2 { stop-color: var(--dial-face-2); } .dial .fc3 { stop-color: var(--dial-face-3); }
.dial .shade { fill: var(--dial-shade); }
.dial .screw circle { fill: var(--dial-screw); stroke: var(--dial-screw-edge); stroke-width: 1.5; }
.dial .screw path { stroke: var(--dial-screw-slot); stroke-width: 2.5; stroke-linecap: round; }
.f0 { stroke: var(--dial-f0); } .f1 { stroke: var(--dial-f1); } .f2 { stroke: var(--dial-f2); }
.f3 { stroke: var(--dial-f3); } .f4 { stroke: var(--dial-f4); } .f5 { stroke: var(--dial-f5); }
.dial .blk-out { fill: none; stroke: var(--dial-outline); stroke-width: var(--dial-block-outline); }
.dial .blk-base { fill: none; stroke: var(--dial-cream); stroke-width: var(--dial-block); }
.dial .blk { fill: none; stroke-width: var(--dial-block); }
.dial .blk.dim { stroke-opacity: var(--dial-dim); }
.dial .blk-out.up { stroke-width: var(--dial-grade-outline); }
.dial .blk.up { stroke-width: var(--dial-grade-block); }
.dial .rim { fill: var(--dial-ink); }
.dial .name { fill: var(--dial-outline); font-size: 14.5px; letter-spacing: 0.03em; }
.dial .win { fill: var(--dial-window); stroke: var(--dial-window-edge); stroke-width: 4; }
.dial .big { fill: var(--dial-outline); font-size: 86px; }
.dial .big.two { font-size: 68px; }
.dial .hint { fill: var(--dial-outline); font-size: 23px; font-weight: 700; }
.dial .hint.up { font-size: 22px; }
.dial .needle .shaft { fill: var(--dial-needle); }
.dial .needle .point { fill: var(--dial-needle-tip); stroke: var(--dial-needle); stroke-width: 3; stroke-linejoin: round; }
.dial .needle .barb { fill: none; stroke: var(--dial-needle); stroke-width: 5; stroke-linecap: round; }
.dial .needle .curl { fill: none; stroke: var(--dial-needle); stroke-width: 8; stroke-linecap: round; }
.dial .needle.cast path { fill: var(--dial-needle-cast); stroke: var(--dial-needle-cast); }
.dial .needle.cast .curl, .dial .needle.cast .barb { fill: none; }
.dial .hub { stroke: var(--dial-window-edge); stroke-width: 3; }
.dial .hub-in { fill: var(--dial-hub-in); }
.dial .hub-slot { stroke: var(--dial-screw-edge); stroke-width: 2.5; stroke-linecap: round; }
.dial.off .bezel, .dial.off .win-frame, .dial.off .hub { fill: var(--dial-off-brass); }
.dial.off .lip { fill: var(--dial-off-lip); }
.dial.off .face { fill: var(--dial-off-face); }
.dial.off .blk { stroke: var(--dial-off-block); stroke-opacity: 1; }
.dial.off .blk-out { stroke: var(--dial-off-outline); }
.dial.off .blk-base { stroke: var(--dial-off-face); }
.dial.off .rim { fill: var(--dial-off-letter); }
.dial.off .name, .dial.off .hint { fill: var(--dial-off-name); }
.dial.off .screw circle { fill: var(--dial-off-lip); stroke: var(--dial-off-screw-edge); }
.dial.off .win { fill: var(--dial-off-window); stroke: var(--dial-off-window-edge); }

/* The small dial beside a group's heading: 56 pixels, no needle, no letters. */
.mini { display: block; flex: none; width: 56px; height: 56px; aspect-ratio: 1; }
.mini .m-ring { fill: var(--mini-ring); } .mini .m-ring-in { fill: var(--mini-ring-in); } .mini .m-face { fill: var(--dial-cream); }
.mini .m-out { fill: none; stroke: var(--dial-outline); stroke-width: 80; }
.mini .m-blk { fill: none; stroke-width: 52; }
.mini .m-off { fill: none; stroke: var(--mini-off); stroke-width: 52; }

/* "Pause the needle" under the grading dial (designer's section 10): a checkbox in a label, no script.
   Shown only while the needle turns: not while waiting, and not with reduced motion. */
.gauge .pause-row { margin: 12px 0 0; text-align: center; }
.gauge .pause { position: relative; display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 16px 0 14px; border: 2px solid currentColor; border-radius: 6px; font: 700 14px/1 var(--font); cursor: pointer; }
.gauge .pause input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.gauge .pause::before { content: ""; width: 12px; height: 14px; border-left: 4px solid currentColor; border-right: 4px solid currentColor; box-sizing: border-box; }
.gauge .pause:has(input:checked)::before { width: 0; height: 0; border: 0; border-left: 12px solid currentColor; border-top: 7px solid transparent; border-bottom: 7px solid transparent; }
.gauge .pause .when-off, .gauge .pause:has(input:checked) .when-on { display: none; }
.gauge .pause:has(input:checked) .when-off { display: inline; }
.gauge .pause:has(input:focus-visible) { outline: 3px solid var(--yellow); outline-offset: 3px; }
.gauge:not(:has(.turning)) .pause-row { display: none; }
@media (prefers-reduced-motion: reduce) { .gauge .pause-row { display: none; } }

/* A result's first showing: the page round it is one element with class "settle" (display: contents, so it adds no
   box). The per-letter class sets the trip from rest; the grading page's script overrides it from the moving needle,
   or adds "shown" when the visitor paused the needle, so the grade is simply shown. */
.settle { display: contents; }
/* The grading page moves focus to the result's heading when it comes in, so a screen reader says it; the heading is
   not a control, so it gets no focus ring. */
main h1[tabindex="-1"]:focus { outline: none; }
.settle.to-f { --to: 247.5deg; --over: 254.5deg; --under: 244.5deg; --over2: 248.7deg; --d: 1.54s; }
.settle.to-d { --to: 292.5deg; --over: 299.5deg; --under: 289.5deg; --over2: 293.7deg; --d: 1.9s; }
.settle.to-c { --to: 337.5deg; --over: 344.5deg; --under: 334.5deg; --over2: 338.7deg; --d: 2.26s; }
.settle.to-b { --to: 382.5deg; --over: 389.5deg; --under: 379.5deg; --over2: 383.7deg; --d: 2.62s; }
.settle.to-a { --to: 427.5deg; --over: 434.5deg; --under: 424.5deg; --over2: 428.7deg; --d: 2.98s; }
.settle.to-ap { --to: 472.5deg; --over: 479.5deg; --under: 469.5deg; --over2: 473.7deg; --d: 3.34s; }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  /* Grading: one steady clockwise turn every 5 seconds. */
  .dial.turning .needle { animation: dial-turn 5s linear infinite; }
  .gauge:has(.pause input:checked) .needle { animation-play-state: paused; }
  /* The settle: from --from (rest after a reload) round to --to, 7 past, 3 short, 1.2 past, and onto it. */
  .settle:not(.shown) .dial .needle { animation: dial-settle var(--d) cubic-bezier(0.4, 0, 0.3, 1) 1; }
  /* Nothing names the grade until the needle lands at 82%: the grade's mark and big letter, the words under the
     dial and the rest of the page wait; the other five blocks stay at full colour till then. */
  .settle:not(.shown) :is(.dial .late, .result .dial ~ *), .settle:not(.shown) > .result ~ * { animation: dial-wait calc(var(--d) * 0.82) step-end 1; }
  .settle:not(.shown) .dial .blk.dim { animation: dial-full calc(var(--d) * 0.82) step-end 1; }
}
@keyframes dial-turn { from { transform: rotate(180deg); } to { transform: rotate(540deg); } }
@keyframes dial-settle {
  0% { transform: rotate(var(--from, 180deg)); }
  64% { transform: rotate(var(--over)); animation-timing-function: ease-in-out; }
  80% { transform: rotate(var(--under)); animation-timing-function: ease-in-out; }
  92% { transform: rotate(var(--over2)); animation-timing-function: ease-in-out; }
  100% { transform: rotate(var(--to)); }
}
@keyframes dial-wait { from, to { opacity: 0; } }
@keyframes dial-full { from, to { stroke-opacity: 1; } }
