/* The Clock (js/clock-ui.js, js/clock-engine.js, CLOCK-1). Colours, rims and text size come from the tokens, so every look and
   the light/dark switch reach it. Touch targets are 44 px at least; Stop on the ring card is bigger. */
/* the warning amber is for fills and rings; as TEXT on a light page it needs a darker amber to be read (4.5:1) */
:root { --clk-warn-text: var(--warn); }
html[data-theme="light"] { --clk-warn-text: #8a4b00; }
.panel.clk-panel { width: min(560px, calc(100% - 48px)); height: auto; max-height: calc(100% - var(--dock-h) - 40px); }
.clk { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 18px 18px; font-size: calc(14px * var(--ts)); }
.clk-timer { display: flex; flex-direction: column; gap: 14px; }
.clk [hidden] { display: none !important; }
.clk-h { margin: 0 0 8px; font-size: .95em; font-weight: 650; color: var(--muted); }

/* new timer */
.clk-add { display: flex; flex-direction: column; gap: 10px; }
.clk-presets { display: flex; gap: 8px; flex-wrap: wrap; }
.clk-preset { flex: 1 1 0; min-width: 5.5em; min-height: 48px; font: inherit; font-weight: 600; cursor: pointer; }
.clk-own { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.clk-field { display: flex; flex-direction: column; gap: 2px; flex: 1 1 4.5em; min-width: 4.5em; }
.clk-field input { width: 100%; min-height: 48px; box-sizing: border-box; font: inherit; font-size: 1.15em; text-align: center; font-variant-numeric: tabular-nums;
  background: rgba(var(--tint), .06); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 4px 6px; }
.clk-unit { font-size: .8em; color: var(--muted); text-align: center; }
.clk-go { flex: 1 1 6em; min-height: 48px; font: inherit; font-weight: 650; cursor: pointer; }
.clk-label, .clk-name { width: 100%; box-sizing: border-box; min-height: 44px; font: inherit; background: rgba(var(--tint), .06); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; }
.clk-name { border-color: transparent; background: transparent; font-weight: 600; padding-left: 4px; }
.clk-name:hover, .clk-name:focus { border-color: var(--line); background: rgba(var(--tint), .06); }
.clk input:focus-visible, .clk select:focus-visible, .clk button:focus-visible, .clk summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* the timers */
.clk-list { display: flex; flex-direction: column; gap: 10px; }
.clk-empty { margin: 4px 0; text-align: center; }
.clk-card { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(var(--tint), .04); }
.clk-card.ringing { border-color: var(--warn); box-shadow: 0 0 0 2px var(--warn); }
.clk-num { font-size: calc(46px * var(--ts)); line-height: 1.1; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.clk-card.neg .clk-num { color: var(--clk-warn-text); }
.clk-sub { text-align: center; }
.clk-bar { height: 6px; border-radius: 3px; background: rgba(var(--tint), .12); overflow: hidden; }
.clk-bar-fill { height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(1); }
.clk-card.neg .clk-bar-fill { background: var(--warn); }
.clk-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.clk-btns button { flex: 1 1 5em; min-height: 48px; font: inherit; cursor: pointer; }
.clk-btns .solid { font-weight: 650; }
.clk-btns .clk-del { flex: 0 1 auto; margin-left: auto; }
.clk-undo:empty { display: none; }

/* how it rings */
.clk-ring { border: 1px solid var(--line); border-radius: 14px; padding: 0 14px; }
.clk-ring-sum { min-height: 48px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }
.clk-ring-rows { display: flex; flex-direction: column; gap: 6px; padding-bottom: 12px; }
.clk-group { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.clk-sw { display: flex; align-items: center; gap: 12px; min-height: 48px; flex: 1; cursor: pointer; }
.clk-sw input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
.clk-sel { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding-left: 34px; }
.clk-sel select { min-height: 44px; font: inherit; background: rgba(var(--tint), .06); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 4px 8px; max-width: 55%; }
.clk-test { min-height: 44px; font: inherit; cursor: pointer; }
.clk-note, .clk-limit { margin: 0; }
.clk-ringnote { margin: 0; text-align: center; color: var(--clk-warn-text); }
.clk-sr { position: fixed; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; pointer-events: none; }
.clk-limit { text-align: center; }

/* tabs: wrap rather than scroll sideways, so every tool is a button you can see */
.clk-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.clk-tab { flex: 1 1 5.5em; min-height: 48px; font: inherit; font-weight: 600; cursor: pointer; background: transparent; color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; padding: 4px 10px; }
.clk-tab[aria-selected="true"] { background: rgba(var(--tint), .12); border-color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }
.clk-pane, .clk-alarm { display: flex; flex-direction: column; gap: 14px; }

/* alarms */
.clk-add-alarm { min-height: 48px; font: inherit; font-weight: 650; cursor: pointer; }
.clk-acard.off .clk-atime { color: var(--muted); }
.clk-arow { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.clk-atime { font-size: calc(36px * var(--ts)); line-height: 1.1; font-weight: 600; font-variant-numeric: tabular-nums; }
.clk-aswitch { flex: none; min-height: 48px; }
.clk-acard .clk-sub { text-align: left; }
.clk-missed { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--clk-warn-text); }
.clk-dismiss, .clk-edit { min-height: 44px; font: inherit; cursor: pointer; }

/* the editor: flat, so seven day buttons of 44 px fit a phone */
.clk-editor { display: flex; flex-direction: column; gap: 12px; }
.clk-timefield { display: flex; flex-direction: column; gap: 2px; }
.clk-time { width: 100%; min-height: 56px; box-sizing: border-box; font: inherit; font-size: calc(30px * var(--ts)); text-align: center; font-variant-numeric: tabular-nums;
  background: rgba(var(--tint), .06); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 4px 6px; color-scheme: light dark; }
.clk-days { display: flex; gap: 4px; flex-wrap: wrap; }
.clk-day { flex: 1 1 0; min-width: 44px; min-height: 48px; padding: 0 2px; font: inherit; font-weight: 600; cursor: pointer; }
.clk-day[aria-pressed="true"] { background: var(--solid-bg); color: var(--on-accent); border-color: transparent; }
.clk-daysum { text-align: center; }
.clk-sel0 { padding-left: 0; }
.clk-sel0 select { max-width: 55%; }
.clk input[type="time"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* the flash: one layer over everything that lets every press through (nothing-covers-what-you-press.md) */
#clock-flash { position: fixed; inset: 0; z-index: 400; pointer-events: none; background: var(--warn); opacity: 0; display: none; }
#clock-flash.on { display: block; }
/* blink: on 400 ms, off 400 ms at the period the ring asks for (never more than 3 a second) */
#clock-flash.on.blink { animation: clk-blink var(--clk-period, 800ms) steps(1, end) infinite; }
@keyframes clk-blink { 0% { opacity: .55; } 50% { opacity: 0; } 100% { opacity: 0; } }
/* fade: reduce motion, one slow breath, no strobing */
#clock-flash.on.fade { animation: clk-fade var(--clk-period, 4000ms) ease-in-out infinite; }
@keyframes clk-fade { 0% { opacity: 0; } 50% { opacity: .28; } 100% { opacity: 0; } }

/* the ring card: always visible while something rings, whether or not the Clock window is open */
.clock-ring-card { position: fixed; z-index: 410; left: 50%; top: 18%; transform: translateX(-50%); width: min(420px, calc(100% - 32px)); max-height: 70%; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px; padding: 18px; background: var(--glass-strong); border: 2px solid var(--warn); border-radius: 20px;
  box-shadow: 0 30px 80px var(--shadow); color: var(--text); outline: none; }
.clock-ring-row { display: flex; flex-direction: column; gap: 6px; }
.clock-ring-name { font-weight: 650; text-align: center; font-size: calc(18px * var(--ts)); }
.clock-ring-num { font-size: calc(52px * var(--ts)); line-height: 1.1; font-weight: 650; text-align: center; font-variant-numeric: tabular-nums; color: var(--clk-warn-text); }
.clock-ring-btns { display: flex; flex-direction: column; gap: 18px; margin-top: 6px; }   /* a gap between Stop and the snooze: no slip from one to the other */
.clock-stop { min-height: 64px; font: inherit; font-size: 1.25em; font-weight: 700; cursor: pointer; }
.clock-snooze { min-height: 48px; font: inherit; cursor: pointer; }
.clock-ring-note { margin: 0; text-align: center; }
.clock-ring-card:focus-visible, .clock-ring-card button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

@media (max-width: 760px) {
  .panel.clk-panel { width: calc(100% - 16px); }
  .clk { padding: 12px 12px 16px; }
  .clk-num { font-size: calc(40px * var(--ts)); }
}

/* ---- the Stopwatch (CLOCK-1 step 3): one big time, two big buttons, the laps under them ---- */
.clk-stopwatch { display: flex; flex-direction: column; gap: 12px; }
.clk-swcard { gap: 10px; padding: 18px 14px; }
.clk-swnum { font-size: calc(54px * var(--ts)); white-space: nowrap; }
.clk-swstatus { min-height: 1.4em; margin: 0; }
.clk-swbtns { gap: 12px; margin-top: 2px; }
.clk-swbtns button { min-height: 64px; flex: 1 1 8em; font-size: 1.1em; }
.clk-swmain { font-weight: 700; }
.clk-swbtns button:disabled { opacity: .45; cursor: default; }
.clk-laps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.clk-lap { display: grid; grid-template-columns: minmax(4.5em, auto) 1fr 1fr; column-gap: 12px; align-items: baseline; padding: 10px 4px; border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums; }
.clk-lap-n { color: var(--muted); }
.clk-lap-split { font-weight: 600; }
.clk-lap-total { text-align: right; color: var(--muted); }
/* the mark is a word, never colour alone */
.clk-lap-mark { grid-column: 1 / -1; font-size: .85em; font-weight: 650; }
.clk-lap.best .clk-lap-mark { color: var(--ok-text, var(--ok)); }
.clk-lap.worst .clk-lap-mark { color: var(--clk-warn-text); }
html[data-theme="light"] .clk-lap.best .clk-lap-mark { color: #0b6b3a; }
@media (max-width: 760px) {
  .clk-swnum { font-size: calc(44px * var(--ts)); }
}

/* ---- the World clock (CLOCK-1 step 4): one card per city, the search box opens only when asked ---- */
.clk-world { display: flex; flex-direction: column; gap: 12px; }
.clk-wsearch { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: rgba(var(--tint), .04); }
.clk-wresults { display: flex; flex-direction: column; gap: 6px; }
.clk-wpick { min-height: 48px; font: inherit; text-align: left; cursor: pointer; padding: 6px 12px; overflow-wrap: anywhere; }
.clk-wcard { gap: 4px; }
.clk-wtop { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.clk-wname { min-width: 0; flex: 1 1 auto; }
.clk-wcity { font-weight: 650; font-size: 1.1em; overflow-wrap: anywhere; }
.clk-wplace { overflow-wrap: anywhere; }
.clk-wtime { flex: none; font-size: calc(30px * var(--ts)); line-height: 1.1; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.clk-wcard .clk-wsub { text-align: left; }
.clk-wcard .clk-del { align-self: flex-end; min-height: 44px; font: inherit; cursor: pointer; }
@media (max-width: 760px) {
  .clk-wtime { font-size: calc(26px * var(--ts)); }
}

/* ---- Bedtime (CLOCK-1 step 5): the switch with the times it gives, the few choices, two ring boxes ---- */
.clk-bedtime { display: flex; flex-direction: column; gap: 14px; }
.clk-bedhead.off .clk-bedtimes { color: var(--muted); }
.clk-bedtimes { font-size: calc(18px * var(--ts)); font-weight: 600; font-variant-numeric: tabular-nums; }
.clk-bedswitch { flex: none; min-height: 48px; }
.clk-bedhead .clk-h { margin: 0; }
.clk-bedhead .clk-sub { text-align: left; }
.clk-bedset { display: flex; flex-direction: column; gap: 12px; }
.clk-bedring { align-items: stretch; }
.clk-bedring-name { font-weight: 650; text-align: center; font-size: calc(18px * var(--ts)); }
.clk-bedring .clk-atime { text-align: center; color: var(--clk-warn-text); }
