/*
  The Bling web. The family base (colours, corners, type stacks) comes from familia.css, loaded first;
  this file uses its tokens (var(--ec-...)) and adds only what is The Bling's.
  Rules: 3px corners, fewer lines, DM Sans for words, IBM Plex Mono for every number,
  light preferred, dark is the same page inverted.
*/

/* Fonts: bundled, no outside requests. DM Sans Display is the cut used from 26px up. */
@font-face { font-family: "DM Sans"; src: url("fonts/DMSans-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("fonts/DMSans-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("fonts/DMSans-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("fonts/DMSans-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "DM Sans Display"; src: url("fonts/DMSans-Display.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "DM Sans Display"; src: url("fonts/DMSans-DisplaySemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/IBMPlexMono-Light.woff2") format("woff2"); font-weight: 300; font-display: block; }
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/IBMPlexMono-Regular.woff2") format("woff2"); font-weight: 400; font-display: block; }
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/IBMPlexMono-Medium.woff2") format("woff2"); font-weight: 500; font-display: block; }
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/IBMPlexMono-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: block; }

/*
  The Bling's one accent: gold, the family's `star`. Only in marks (the dot, the playhead,
  the dial pointer), never in text.
*/
:root {
  --accent: #E8A21A;
  --switch-off: var(--ec-softer);
  --gutter: var(--ec-gutter);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --accent: #F0B43C; }
}
:root[data-theme="dark"] { --accent: #F0B43C; }

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0; background: var(--ec-bg); color: var(--ec-ink);
  font-family: var(--ec-sans); font-size: 15px; line-height: 1.3;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:active { opacity: .6; }
:focus-visible { outline: 2px solid var(--ec-ink); outline-offset: 2px; }
p { margin: 0; }
.mono { font-family: var(--ec-mono); }

/* Seal: ink with the drawing in paper; inverted in dark, with the drawing a touch thicker (+1.18).
   Colours go in as variables, because the drawing lives inside <use>. */
.mark { width: 30px; height: 29px; flex: 0 0 auto; --seal-b: var(--ec-ink); --seal-d: var(--ec-bg); --seal-x: 0; }
.seal-b { fill: var(--seal-b); }
.seal-d { fill: var(--seal-d); stroke: var(--seal-d); stroke-width: var(--seal-x); }
.seal-r { stroke: var(--seal-d); stroke-width: calc(11px + var(--seal-x) * 1px); stroke-linecap: round; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mark { --seal-x: 1.18; } }
:root[data-theme="dark"] .mark { --seal-x: 1.18; }

/* Layout: one column on the phone; from 900px the countdown fills the left and the settings sit in a grey panel. */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.stage {
  display: flex; flex-direction: column; gap: 28px;
  padding: calc(18px + env(safe-area-inset-top)) var(--gutter) 34px;
  transition: background-color .25s ease, color .25s ease;
}
.panel { background: var(--ec-soft); padding: 28px var(--gutter) calc(28px + env(safe-area-inset-bottom)); }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: minmax(0, 1fr) 400px; height: 100dvh; }
  .stage { padding: 28px 48px 40px; justify-content: space-between; overflow: hidden; }
  .panel { height: 100dvh; overflow-y: auto; padding: 32px 28px 28px; }
}

/* Top: the seal and the name on the left, the status on the right. */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 11px; margin: 0; font: 400 26px/1 var(--ec-display); letter-spacing: .35px; }
.status { display: flex; align-items: center; gap: 8px; font: 700 13px/1 var(--ec-sans); letter-spacing: .6px; text-transform: uppercase; color: var(--ec-muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ec-softer); }
.is-running .dot { background: var(--accent); animation: blink 2s ease-in-out infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* Readout: the big clock, centred, with the ruler of what is left under it. */
.readout { width: 100%; max-width: 760px; margin: 0 auto; text-align: center; }
.clock {
  font: 300 clamp(88px, 27vw, 128px)/.9 var(--ec-mono); letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}
@media (min-width: 900px) { .clock { font-size: clamp(140px, 15vw, 220px); } }
.next { min-height: 1.3em; margin-top: 14px; font: 400 13px/1.3 var(--ec-sans); color: var(--ec-muted); }

.ruler { position: relative; height: 34px; margin-top: 30px; color: var(--ec-ink); }
.ticks {
  position: absolute; inset: 0;
  background-image: linear-gradient(to right, currentColor 0 1.5px, transparent 1.5px);
  background-size: var(--gap, 10px) 100%; background-repeat: repeat-x;
}
.ticks.spent { opacity: .14; }
.ticks.left { opacity: .9; }
.playhead { position: absolute; top: -5px; bottom: -5px; left: 0; width: 2px; background: var(--accent); transition: left .2s linear; }
.rulerkey { display: flex; justify-content: space-between; margin-top: 8px; font: 400 12px/1 var(--ec-mono); color: var(--ec-muted); }

/* Ringing: the countdown turns into a block of ink until the sound stops. */
.stage.is-ringing { background: var(--ec-ink); color: var(--ec-on-ink); }
.is-ringing .status, .is-ringing .next, .is-ringing .rulerkey, .is-ringing .scope { color: var(--ec-on-ink); }
.is-ringing .ruler { color: var(--ec-on-ink); }
.is-ringing .mark { --seal-b: var(--ec-on-ink); --seal-d: var(--ec-ink); }
.is-ringing .scope.warn { color: var(--ec-on-ink); }
.is-ringing .dot { background: var(--accent); animation: none; }
.is-ringing .btn-ink { background: var(--ec-on-ink); color: var(--ec-ink); }
.is-ringing .btn-line { border-color: var(--ec-on-ink); color: var(--ec-on-ink); }
.is-ringing :focus-visible { outline-color: var(--ec-on-ink); }

/* Buttons: ink block for the main one, a 2px ink frame for the others. Labels in capitals. */
.controls { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.actions { display: flex; gap: 8px; width: 100%; max-width: 420px; }
.btn {
  height: 56px; padding: 0 20px; border-radius: var(--ec-radius);
  font: 700 15px/1 var(--ec-sans); letter-spacing: .8px; text-transform: uppercase;
}
.btn-ink { flex: 2 1 0; border: 0; background: var(--ec-ink); color: var(--ec-on-ink); }
.btn-line { flex: 1 1 0; border: 2px solid var(--ec-ink); background: transparent; color: var(--ec-ink); }
.btn-sm { flex: 0 0 auto; height: 42px; padding: 0 14px; font-size: 13px; letter-spacing: .6px; }

.scope { max-width: 420px; text-align: center; font: 400 13px/1.4 var(--ec-sans); color: var(--ec-muted); }
.scope.warn { color: var(--ec-danger); }

/* Panel fields */
.field + .field { margin-top: 30px; }
.fieldhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.label { font: 700 13px/1.2 var(--ec-sans); letter-spacing: .6px; text-transform: uppercase; color: var(--ec-muted); }
.fieldval { font: 500 16px/1 var(--ec-mono); font-variant-numeric: tabular-nums; }
.note { display: block; margin-top: 8px; font: 400 13px/1.4 var(--ec-sans); color: var(--ec-muted); }
.note.warn { color: var(--ec-danger); }
.note:empty { display: none; }

/* Interval tape: drag, scroll or use the arrows. */
.dial {
  position: relative; height: 62px; border-radius: var(--ec-radius); background: var(--ec-bg); overflow: hidden;
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 14%, #000 86%, transparent);
          mask-image: linear-gradient(to right, transparent, #000 14%, #000 86%, transparent);
}
.dial:active { cursor: grabbing; }
.dial:focus-visible { outline-offset: -2px; -webkit-mask-image: none; mask-image: none; }
.tape { position: absolute; top: 0; bottom: 0; left: 50%; will-change: transform; }
.tape.snap { transition: transform .18s cubic-bezier(.22, .61, .36, 1); }
.tk { position: absolute; width: 1.5px; background: var(--ec-ink); }
.tk.maj { top: 10px; height: 17px; opacity: .5; }
.tk.min { top: 15px; height: 8px; opacity: .18; }
.lb {
  position: absolute; top: 34px; transform: translateX(-50%);
  font: 400 13px/1 var(--ec-mono); color: var(--ec-muted); opacity: .6;
  transition: color .15s, opacity .15s;
}
.lb.on { color: var(--ec-ink); opacity: 1; font-weight: 600; }
.dialmark { position: absolute; left: 50%; top: 6px; bottom: 6px; width: 2px; background: var(--accent); transform: translateX(-50%); pointer-events: none; }

/* Segmented control: the options touch, so they are square; the corner is on the whole. */
.seg { display: flex; border: 1.5px solid var(--ec-ink); border-radius: var(--ec-radius); overflow: hidden; background: var(--ec-bg); }
.seg button {
  flex: 1 1 auto; min-height: 44px; padding: 8px 6px; border: 0; border-radius: 0; background: transparent;
  font: 500 14px/1.15 var(--ec-sans);
}
.seg button + button { box-shadow: -1px 0 0 var(--ec-hairline); }
.seg button[aria-checked="true"] { background: var(--ec-ink); color: var(--ec-on-ink); font-weight: 600; box-shadow: none; }
.seg button[aria-checked="true"] + button { box-shadow: none; }
.seg button:focus-visible { outline-offset: -5px; }
.seg button[aria-checked="true"]:focus-visible { outline-color: var(--ec-on-ink); }
.seg [data-ring="back"] { flex-grow: 1.6; }

/* How many times: minus, the number, plus. */
.stepper { display: flex; align-items: center; gap: 0; margin-top: 8px; width: max-content; border: 1.5px solid var(--ec-ink); border-radius: var(--ec-radius); background: var(--ec-bg); overflow: hidden; }
.stepper[hidden] { display: none; }
.step { width: 44px; height: 42px; display: grid; place-items: center; border: 0; border-radius: 0; background: transparent; }
.step svg { width: 14px; height: 14px; }
.step:disabled { opacity: .3; cursor: default; }
.step:focus-visible { outline-offset: -4px; }
.count { min-width: 92px; text-align: center; font: 500 15px/1 var(--ec-sans); }
.count b { font: 500 16px/1 var(--ec-mono); font-weight: 500; }

/* Sound */
.soundrow { display: flex; gap: 8px; }
.select { position: relative; flex: 1 1 auto; }
.select select {
  width: 100%; height: 42px; padding: 0 36px 0 12px; appearance: none; -webkit-appearance: none;
  border: 1.5px solid var(--ec-ink); border-radius: var(--ec-radius); background: var(--ec-bg); color: var(--ec-ink);
  font: 500 15px/1 var(--ec-sans); cursor: pointer;
}
.select::after {
  content: ""; position: absolute; right: 15px; top: 50%; width: 7px; height: 7px; margin-top: -6px;
  border-right: 2px solid var(--ec-ink); border-bottom: 2px solid var(--ec-ink); transform: rotate(45deg); pointer-events: none;
}
.volrow { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.volrow input { flex: 1 1 auto; accent-color: var(--ec-ink); margin: 0; }
.volout { width: 28px; text-align: right; font: 400 13px/1 var(--ec-mono); color: var(--ec-muted); }

/* Switch rows */
.opts { display: grid; gap: 18px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.rowtext { min-width: 0; }
.name { font: 500 15.5px/1.3 var(--ec-sans); }
.rowtext .note { margin-top: 3px; }
.switch {
  position: relative; flex: 0 0 auto; width: 44px; height: 26px; padding: 0; border: 0;
  border-radius: var(--ec-radius); background: var(--switch-off); transition: background .18s;
}
.switch::after {
  content: ""; position: absolute; top: 4px; left: 4px; width: 18px; height: 18px;
  border-radius: 2px; background: var(--ec-bg); transition: transform .18s;
}
.switch[aria-checked="true"] { background: var(--ec-ink); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.switch:disabled { opacity: .35; cursor: not-allowed; }

/* Last alert */
.last { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.last .val { font: 400 22px/1 var(--ec-mono); font-variant-numeric: tabular-nums; }
.last .val.none { font: 400 13px/1 var(--ec-sans); color: var(--ec-muted); }

.hint { margin-top: 30px; font: 400 13px/1.4 var(--ec-sans); color: var(--ec-muted); }

/* Footer: credits, the app, the family's production line, version and feedback. */
.foot { margin-top: 26px; }
.credits, .production { font: 500 12.5px/1.5 var(--ec-sans); color: var(--ec-muted); }
.credits a, .production a { color: var(--ec-ink); text-underline-offset: 3px; }
.production .mono { font-size: 12px; letter-spacing: .02em; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
