/* Timer (section 20): a dial drawn in lines, as WOVE draws one, on no card at all. Rings one inside another set the
   units: the minutes outside, then the hours, then the days (the rail picks which, and can add the seconds), with a dot
   on each for every station. At the outer ring's front a pin, and beside it one large numeral and the next unit small;
   the numbers before and after lie pale round the ring that is lit, turned out from its middle. To the right: its name,
   a line saying what it is doing, and its buttons. It is two and a half times as wide as it is tall, and everything on
   it is sized to its height (cqh), so it scales as one. */
.obj.timer { container-type: size; background: transparent; border-color: transparent; box-shadow: none; }
.obj.timer:focus-within { border-color: transparent; box-shadow: none; }
.obj.timer.paper {          /* carried, its lines cast the shadow */
  box-shadow: none;
  filter: drop-shadow(0 calc(var(--lk, 0) * 10px) calc(var(--lk, 0) * 9px) var(--drop-1)) drop-shadow(0 calc(var(--lk, 0) * 2px) calc(var(--lk, 0) * 2px) var(--drop-2));
}
.cstack > .obj.timer { height: auto !important; aspect-ratio: 2.5; }
.tm-dial, .tm-labs { position: absolute; left: 0; top: 0; width: 100cqh; height: 100cqh; overflow: visible; }
.tm-labs {       /* wider and taller than the dial, so a turning number is never cut: it fades out round the back and
                    towards the top and the bottom */
  top: -24cqh; width: 116cqh; height: 148cqh; pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, transparent 52cqh, #000 76cqh), linear-gradient(transparent 6cqh, #000 36cqh, #000 112cqh, transparent 142cqh);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(90deg, transparent 52cqh, #000 76cqh), linear-gradient(transparent 6cqh, #000 36cqh, #000 112cqh, transparent 142cqh);
  mask-composite: intersect;
}
.tm-ring { fill: none; stroke: var(--rule-2); stroke-width: 1; vector-effect: non-scaling-stroke; transition: stroke 200ms ease-out; }
.tm-st { fill: var(--ink-3); opacity: .45; transition: opacity 200ms ease-out; }
.tm-rg.lit .tm-ring { stroke: color-mix(in srgb, var(--ink) 30%, transparent); }
.tm-rg.lit .tm-st { opacity: 1; }
.tm-axle { fill: var(--ink-3); }
.tm-lab {
  font-family: var(--f-mono); font-weight: 700; letter-spacing: -.04em; text-anchor: middle; dominant-baseline: central;
  fill: color-mix(in srgb, var(--ink) 17%, transparent); opacity: 0; transition: opacity 240ms ease-out;
}
.tm-lg.lit .tm-lab:not(.k0) { opacity: 1; }
.tm-spin, .tm-hand { transform-box: view-box; transform-origin: 50px 50px; }      /* about the dial's middle (DIAL.C) */
.tm-fuse { fill: none; stroke: var(--c-timer); stroke-width: 1.3; stroke-linecap: round; stroke-dasharray: 1 2; stroke-dashoffset: 1; transition: stroke 200ms ease-out; }
.tm-spark { fill: var(--c-timer); opacity: 0; transition: opacity 200ms ease-out, fill 200ms ease-out; }
.tm-pin { fill: var(--ink); transition: fill 200ms ease-out; }
.tm-rip { fill: none; stroke: var(--c-timer); stroke-width: 1.5; vector-effect: non-scaling-stroke; opacity: 0; transform-box: fill-box; transform-origin: center; }
.obj.timer:is([data-state="run"], [data-state="pause"]) .tm-spark { opacity: 1; }
.obj.timer:is([data-state="run"], [data-state="ring"]) .tm-pin { fill: var(--c-timer); }
.obj.timer[data-state="pause"] .tm-fuse { stroke: var(--ink-3); }
.obj.timer[data-state="pause"] .tm-spark { fill: var(--ink-3); }
/* Picked and set, a ring turns under the hand: dragged round, or scrolled. */
.obj.timer.tm-grab .tm-dial { cursor: grab; }
body.turning, body.turning * { cursor: grabbing !important; user-select: none !important; -webkit-user-select: none !important; }
/* The time: the large numeral beside the pin, and what stands between it and the small one says which pair it is. */
.tm-read { position: absolute; left: 98cqh; top: 50%; translate: 0 -50%; display: flex; align-items: baseline; white-space: nowrap; }
.tm-f {
  border-radius: 1.2cqh; outline: none; touch-action: none; font-variant-numeric: tabular-nums; user-select: none; -webkit-user-select: none;
  transition: background-color 120ms ease-out, color 120ms ease-out;
}
.tm-big { padding: 0 1cqh; font: 700 31cqh/1.08 var(--f-mono); letter-spacing: -.055em; color: var(--ink); }
.tm-sep { font: 500 11cqh/1 var(--f-mono); color: var(--ink-3); }
.tm-sep[data-s="c"] { margin: 0 -1.7cqh 0 -1.3cqh; }        /* a colon's wide side bearings, drawn in */
.tm-sep[data-s="l"] { margin: 0 -.4cqh 0 .2cqh; }
.tm-small { padding: 0 .8cqh; font: 600 11cqh/1.08 var(--f-mono); letter-spacing: -.02em; color: var(--ink-2); }
.obj.timer[data-state="set"] .tm-f { cursor: ns-resize; }
@media (hover: hover) { .obj.timer[data-state="set"] .tm-f:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); } }
.tm-f:focus, .tm-f.lit { text-decoration: underline var(--c-timer); text-decoration-thickness: max(1.5px, .8cqh); text-underline-offset: max(3px, 2.2cqh); text-decoration-skip-ink: none; }
.tm-f.lit:not(:focus) { text-decoration-color: color-mix(in srgb, var(--ink) 22%, transparent); }
body.spinning, body.spinning * { cursor: ns-resize !important; user-select: none !important; -webkit-user-select: none !important; }
/* Beside it: the name, what it is doing, and the buttons (Start a dark chip, Reset a hairline ring). */
.tm-side { position: absolute; left: 160cqh; right: 4cqh; top: 50%; translate: 0 -50%; display: flex; flex-direction: column; align-items: flex-start; }
.tm-side > .otag { max-width: 100%; margin: 0 0 2.6cqh; }
.tm-name {
  max-width: calc(100% + 2cqh); margin: 0 -1cqh; padding: .2cqh 1cqh; border-radius: .8cqh; box-sizing: border-box;
  font: 600 7cqh/1.3 var(--f-ui); letter-spacing: -.01em; color: var(--ink); white-space: nowrap; overflow: hidden;
}
.tm-name:not(:focus) { text-overflow: ellipsis; }
.tm-name:focus { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.tm-say { margin: .3cqh 0 0; font: 400 6cqh/1.4 var(--f-ui); color: var(--ink-2); text-wrap: pretty; }
.tm-ctl, .tm-alarm { display: flex; align-items: center; gap: 2.2cqh; margin-top: 5cqh; }
.tm-b {
  display: inline-flex; align-items: center; justify-content: center; gap: 1.9cqh; height: 12cqh; min-width: 12cqh; padding: 0; border: 0;
  border-radius: 6cqh; cursor: pointer; white-space: nowrap; box-sizing: border-box;
  font: 500 4.6cqh/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-2); background: transparent; box-shadow: inset 0 0 0 1px var(--rule-2);
  transition: color 120ms ease-out, box-shadow 120ms ease-out, background-color 120ms ease-out, opacity 160ms ease-out, scale 300ms cubic-bezier(.2,1.4,.4,1), visibility 0s;
}
.tm-b svg { flex: none; width: 4.8cqh; height: 4.8cqh; }
.tm-go { padding: 0 4.3cqh 0 3.6cqh; color: var(--surface); background: var(--ink); box-shadow: none; }
.tm-close, .tm-ext { padding: 0 4.3cqh; }
.tm-close { color: var(--ink); }
.tm-ext { color: var(--on-tc); background: var(--c-timer); box-shadow: none; }
@media (hover: hover) {
  .tm-b:hover { color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink-3); }
  .tm-go:hover { color: var(--surface); box-shadow: var(--raise-sm); }
  .tm-ext:hover { color: var(--on-tc); box-shadow: var(--raise-sm); }
}
.tm-b:active { scale: .95; }
@media (pointer: coarse) { .tm-b { position: relative; } .tm-b::after { content: ""; position: absolute; inset: -9px -2px; } }   /* a finger's reach */
.tm-b:disabled { opacity: .3; cursor: default; scale: 1; }
.tm-b:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.obj.timer[data-state="set"] .tm-reset { opacity: 0; scale: .6; visibility: hidden; transition: opacity 120ms ease-in, scale 160ms ease-in, visibility 0s linear 160ms; }
.obj.timer[data-state="ring"] .tm-ctl, .obj.timer:not([data-state="ring"]) .tm-alarm { display: none; }
.obj.timer[data-state="pause"] .tm-read { animation: tm-breathe 2.4s ease-in-out infinite; }
@keyframes tm-breathe { 50% { opacity: .42; } }
/* Small (in a column), it keeps its time and buttons and lets the line go. */
@container (max-height: 116px) { .tm-say { display: none; } }
/* Ringing: the time blinks in the timer's colour and its pin sends out rings with each burst of the alarm. */
.obj.timer[data-state="ring"] :is(.tm-f, .tm-sep) { color: var(--c-timer); }
.obj.timer[data-state="ring"] .tm-read { animation: tm-blink 1.3s linear infinite; }
@keyframes tm-blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: .3; } }
.obj.timer[data-state="ring"] .tm-rip { animation: tm-rip 1.3s cubic-bezier(.15,.6,.3,1) infinite; }
.obj.timer[data-state="ring"] .tm-rip + .tm-rip { animation-delay: .22s; }
@keyframes tm-rip { 0% { opacity: 1; scale: 1; } 70%, 100% { opacity: 0; scale: 9; } }
/* Paused or ringing, in Safari's engine: the time's opacity through --pulse, as .pic-try's (cards.css, html.wk) */
@keyframes tm-breathe-wk { 50% { --pulse: .42; } }
@keyframes tm-blink-wk { 0%, 49% { --pulse: 1; } 50%, 100% { --pulse: .3; } }
html.wk .obj.timer[data-state="pause"] .tm-read { animation-name: tm-breathe-wk; opacity: var(--pulse); }
html.wk .obj.timer[data-state="ring"] .tm-read { animation-name: tm-blink-wk; opacity: var(--pulse); }

/* The alarm: whatever board a ringing timer is on, this card at the top has its two buttons. */
#alarm {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 58px); translate: -50% 0; z-index: 35;
  display: flex; align-items: center; gap: 12px; box-sizing: border-box; max-width: calc(100% - 32px); padding: 9px 9px 9px 12px;
  border-radius: 10px; background: var(--surface); box-shadow: var(--pop), inset 0 0 0 1px var(--rule);
}
.al-bell { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: var(--on-tc); background: var(--c-timer); animation: al-ring 1.3s ease-in-out infinite; }
.al-bell svg { width: 16px; height: 16px; }
@keyframes al-ring { 0%, 36%, 100% { rotate: 0deg; } 6% { rotate: 16deg; } 12% { rotate: -14deg; } 18% { rotate: 10deg; } 24% { rotate: -7deg; } 30% { rotate: 3deg; } }
.al-tx { display: grid; gap: 2px; min-width: 0; margin-right: 6px; }
.al-tx b { font: 500 16px/1.2 var(--f-display); letter-spacing: -.01em; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.al-tx span { font: 500 9.5px/1.3 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--c-timer); }
.al-b { flex: none; height: 32px; padding: 0 13px; border: 0; border-radius: 10px; font: 500 12.5px/1 var(--f-ui); cursor: pointer; white-space: nowrap; }
.al-x { color: var(--ink); background: var(--canvas); box-shadow: var(--raise-sm), var(--edge); }
.al-e { color: var(--on-tc); background: var(--c-timer); }
.al-e span { opacity: .78; }
.al-b:active { box-shadow: var(--press); }
.al-b:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

