/* portrait.css: Fig. 1 (the portrait) and Fig. 3 (the year plate). Tokens come from styles.css. Machine grammar here:
   mono labels, blue for what you are pointing at. Both plates are gold with no frame line, so the gold can dissolve into the
   page's halftone (halftone.js). The replay control is the shared .icon-btn. */
.fig.portrait .fig-frame{border-color:transparent}
.fig.portrait .fig-frame::before{display:none}

/* ---------- Fig. 1: the frame holds its space from first paint ---------- */
/* no JS: the static SVG is the portrait. JS: it is hidden before first paint (no flash of the finished plate), the img only holds
   the aspect, and the canvas takes over at identical geometry. If the engine ever fails, .plain brings the SVG back. */
.js .fig .portrait-static{visibility:hidden}
.js .fig.plain .portrait-static{visibility:visible}
.portrait-canvas{position:absolute;inset:10px;width:calc(100% - 20px);height:calc(100% - 20px);display:block;touch-action:pan-y}
.plate-tip,.year-tip{position:absolute;left:0;top:0;z-index:3;pointer-events:none;white-space:nowrap;background:var(--paper);border:1px solid var(--mach);color:var(--ink);padding:.36em .6em .3em;font-size:var(--mono-s);letter-spacing:.04em;text-transform:none}

/* sizing. --pw is the frame's width where the figure is stacked. Desktop: as tall as the hero allows, never under 340px. */
@media (min-width:861px){
  .hero-side{justify-self:center;width:100%;max-width:max(340px,min(100%,calc((100svh - 372px) * .7283 + 22px)))}   /* the portrait's column: the figure, then the toolkit */
}
@media (max-width:860px){
  .fig.portrait{max-width:min(420px,calc(46svh * .7283 + 22px))}
}
/* portrait phones and tablets: the face sits straight under the headline, so the whole frame is on the first screen */
@media (max-width:860px) and (orientation:portrait),(max-width:560px){
  .fig.portrait{--pw:clamp(196px,calc((100svh - 410px) * .7283 + 22px),240px);width:100%;max-width:none}
  .fig.portrait .fig-frame,.fig.portrait .fig-readout,.fig.portrait .scrub-row{width:var(--pw)}
  .fig.portrait .fig-readout{margin-top:.8rem;gap:.55rem}
  .fig.portrait .fig-readout .count{font-size:2rem}
}
/* tablets in portrait: the plate on the left, its readout, scrubber and caption in a column beside it */
@media (min-width:600px) and (max-width:860px) and (orientation:portrait){
  .hero-side{--tw:clamp(240px,calc((100svh - 480px) * .7283 + 22px),400px)}
  .hero-side .toolkit{margin-left:calc(var(--tw) + clamp(24px,4vw,40px))}   /* the toolkit lines up under the caption, in the column beside the plate */
  .fig.portrait{--pw:var(--tw);display:grid;grid-template-columns:var(--pw) minmax(0,1fr);grid-template-rows:1fr repeat(3,auto);column-gap:clamp(24px,4vw,40px)}
  .fig.portrait .fig-frame{grid-area:1/1/-1;width:auto}
  .fig.portrait .fig-readout,.fig.portrait .scrub-row{width:auto}
  .fig.portrait .fig-readout{grid-area:2/2;margin-top:0;gap:.7rem}
  .fig.portrait .fig-readout .count{font-size:2.4rem}
  .fig.portrait .scrub-row{grid-area:3/2}
  .fig.portrait figcaption{grid-area:4/2}
}
/* landscape phones: text and face side by side, the face sized by the screen's height and never under 240px */
@media (max-width:860px) and (orientation:landscape) and (max-height:560px){
  .hero-side{align-self:start}
  .fig.portrait{--pw:min(100%,clamp(240px,calc((100svh - 96px) * .7283 + 22px),300px));width:100%;max-width:none}
  .fig.portrait .fig-frame,.fig.portrait .fig-readout,.fig.portrait .scrub-row{width:var(--pw)}
  .fig.portrait .fig-readout{margin-top:.8rem;gap:.55rem}
  .fig.portrait .fig-readout .count{font-size:2rem}
}
.fig.portrait .fig-readout{margin-top:1.15rem}
.fig.portrait figcaption{margin-top:.75rem}
/* the scrubber row arrives with the script: hold its space until it does, so nothing below moves */
.js .fig.portrait:not(.ready):not(.plain) figcaption{margin-top:calc(44px + .55rem + .75rem)}

/* the scrubber: a native range, its track a weekly dot histogram of the year; the replay icon stands at its start, the way a player's does */
.scrub-row{display:flex;align-items:center;gap:.6rem;margin-top:.55rem}
.scrub-wrap{position:relative;flex:1 1 auto;min-width:0;height:44px}
.scrub-hist{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}
.scrub{-webkit-appearance:none;appearance:none;position:absolute;inset:0;width:100%;height:100%;margin:0;padding:0;background:transparent;cursor:ew-resize;touch-action:pan-y;border-radius:2px}
.scrub::-webkit-slider-runnable-track{height:44px;background:transparent;border:0}
.scrub::-moz-range-track{height:44px;background:transparent;border:0}
.scrub::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:20px;height:44px;border:0;border-radius:0;cursor:ew-resize;
  background:radial-gradient(circle at 50% 50%,var(--mach) 0 4.5px,var(--paper) 5px 6.5px,transparent 7px),linear-gradient(var(--mach),var(--mach)) 50% 0/2px 100% no-repeat}
.scrub::-moz-range-thumb{width:20px;height:44px;border:0;border-radius:0;cursor:ew-resize;
  background:radial-gradient(circle at 50% 50%,var(--mach) 0 4.5px,var(--paper) 5px 6.5px,transparent 7px),linear-gradient(var(--mach),var(--mach)) 50% 0/2px 100% no-repeat}
@media (hover:hover){
  .scrub:hover::-webkit-slider-thumb{background:radial-gradient(circle at 50% 50%,var(--em) 0 4.5px,var(--paper) 5px 6.5px,transparent 7px),linear-gradient(var(--em),var(--em)) 50% 0/2px 100% no-repeat}
  .scrub:hover::-moz-range-thumb{background:radial-gradient(circle at 50% 50%,var(--em) 0 4.5px,var(--paper) 5px 6.5px,transparent 7px),linear-gradient(var(--em),var(--em)) 50% 0/2px 100% no-repeat}
}
.scrub:active::-webkit-slider-thumb{transform:scaleX(1.15)}
.scrub:focus-visible{outline:2px solid var(--mach);outline-offset:2px}

/* ---------- Fig. 3: the year plate ---------- */
/* the arrangement control: the shared segmented control (a pill track, ink-filled selection). On phones the label sits above it, full width. */
.year-tools{display:flex;flex-wrap:wrap;align-items:center;gap:.6rem 1rem;margin:0 0 1.3rem}
.year-tools::before{content:"Arrange the same marks as";flex:0 0 auto;font:400 var(--mono-m)/1.4 var(--mono);letter-spacing:.08em;text-transform:uppercase;color:var(--ink-2)}
.year-seg{display:inline-flex;gap:2px;padding:3px;border:1.5px solid var(--ink);border-radius:999px}
.year-seg button{min-height:40px;padding:.55em 1.15em;border:0;border-radius:999px;background:transparent;color:var(--ink);font:600 .84375rem/1.15 var(--sans);letter-spacing:0;cursor:pointer;transition:background .16s,color .16s}
@media (hover:hover){.year-seg button:hover{background:var(--paper-2)}.year-seg button[aria-checked="true"]:hover{background:var(--ink)}}
.year-seg button[aria-checked="true"]{background:var(--ink);color:var(--paper)}
@media (pointer:coarse){.year-seg button{min-height:44px}}
@media (max-width:600px){
  .year-tools::before{flex-basis:100%}
  .year-seg{width:100%}
  .year-seg button{flex:1;padding-inline:.6em}
}
/* the year is printed on the portrait's gold, re-pointing the tokens the canvas reads; halftone.js adds the band of dots under it */
.fig.year{--crop:transparent}
.fig.year .year-stage{--paper:#F3F4F7;--paper-2:#E8EAF0;--ink:var(--night);--ink-2:#4A5263;--rule:rgba(10,14,23,.14);--rule-hard:rgba(10,14,23,.5);--hot:#7A3E00;background:var(--amber);border-color:transparent;padding:clamp(16px,3vw,44px)}
.fig.year .year-stage::before{display:none}
.year-stage{position:relative;touch-action:pan-y}
.year-stage:empty{display:none}
.js .year-stage:empty{display:block;min-height:260px}
.js .fig.plain .year-stage:empty{display:none}
.year-stage:focus-visible{outline-offset:8px}
.year-clip{position:relative;width:100%;overflow:hidden;transition:height .7s cubic-bezier(.2,.7,.2,1)}
.year-canvas{display:block;width:100%;touch-action:pan-y}
.year-stats dd small{font:italic 500 .38em/1 var(--serif);font-stretch:100%;letter-spacing:0;color:var(--ink-2);margin-left:.35em}
.year-stats{margin-top:1.9rem}
.year-stage + .ht.band + .year-stats{margin-top:1rem}
.fig.plain .ht.band{display:none}
/* the monthly table is the text alternative to the canvas: it fits 320px (no min-width, headers may wrap) and, if it ever cannot, marks.js makes it a labelled, focusable scroller */
.year-table .table-wrap table{min-width:0;width:100%}
.year-table .table-wrap th,.year-table .table-wrap td{padding-right:.9em;vertical-align:bottom}
.year-table .table-wrap td,.year-table .table-wrap thead th:not(:first-child){text-align:right;font-variant-numeric:tabular-nums lining-nums}
.table-wrap tfoot th,.table-wrap tfoot td{border-bottom:0;border-top:1.5px solid var(--ink);font-weight:500;color:var(--ink)}
.fig figcaption a.out{font:inherit;letter-spacing:inherit}
.fig.year figcaption{max-width:64em}
@media (prefers-reduced-motion:reduce){.year-clip{transition:none}}

/* forced colours: the plate keeps its paper so ink marks stay legible; the controls take the system palette */
@media (forced-colors:active){
  .fig-frame{forced-color-adjust:none;background:#FFFFFF;border-color:#0F0F12}
  .plate-tip,.year-tip{forced-color-adjust:none}
  .scrub::-webkit-slider-thumb{width:8px;background:Highlight}
  .scrub::-moz-range-thumb{width:8px;background:Highlight}
  .year-seg{border-color:CanvasText}
  .year-seg button[aria-checked="true"]{forced-color-adjust:none;background-color:Highlight;color:HighlightText;border-color:Highlight}
}
