/*
 * The embeddable clock (/embed/clock/{slug}). Self-contained: none of the
 * site's CSS, system fonts only. Every size is in vw/vh, so the clock fills
 * whatever frame a site gives it; min() keeps each line inside both the
 * width and the height.
 */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

.ec {
  --ec-bg: #fff;
  --ec-border: #d9e2ec;
  --ec-text: #0f2a44;
  --ec-muted: #5b6b7f;
  --ec-plate: #fff;
  --ec-ring: #cfd8e3;
  --ec-tick: #a7b4c4;
  --ec-hand: #0f2a44;
  --ec-second: #e5484d;
  overflow: hidden;
  background: transparent;
  color: var(--ec-text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.ec.theme-dark {
  --ec-bg: #0f1b2d;
  --ec-border: #24344d;
  --ec-text: #f1f5fb;
  --ec-muted: #a9b6c9;
  --ec-plate: #16233a;
  --ec-ring: #33445f;
  --ec-tick: #5d6f8a;
  --ec-hand: #f1f5fb;
}

.ec-clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5vh;
  height: 100%;
  padding: 3vh 4vw;
  border: 1px solid var(--ec-border);
  border-radius: 10px;
  background: var(--ec-bg);
  color: inherit;
  text-align: center;
  text-decoration: none;
}

.ec-clock:hover .ec-city, .ec-clock:focus-visible .ec-city { text-decoration: underline; }

.ec-city, .ec-time, .ec-date {
  display: block;
  max-width: 100%;
  overflow: hidden;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ec-city { font-weight: 600; }
.ec-date { color: var(--ec-muted); }
.ec-time { font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* Digital. The time is the widest line: eight characters with seconds, five
   without, and up to eleven on a 12-hour clock ("12:00:00 PM"). */
.is-digital .ec-city { font-size: min(7vw, 15vh); }
.is-digital .ec-time { font-size: min(21vw, 52vh); }
.is-digital.has-seconds .ec-time { font-size: min(15.5vw, 52vh); }
.is-digital .ec-clock[data-hour="12"] .ec-time { font-size: min(16vw, 52vh); }
.is-digital.has-seconds .ec-clock[data-hour="12"] .ec-time { font-size: min(12.5vw, 52vh); }
.is-digital .ec-date { font-size: min(6vw, 13vh); }
.is-digital.has-date .ec-time { font-size: min(21vw, 36vh); }
.is-digital.has-date.has-seconds .ec-time { font-size: min(15.5vw, 36vh); }
.is-digital.has-date .ec-clock[data-hour="12"] .ec-time { font-size: min(16vw, 36vh); }
.is-digital.has-date.has-seconds .ec-clock[data-hour="12"] .ec-time { font-size: min(12.5vw, 36vh); }

/* Analog: the dial, then the city and the date under it. */
.is-analog .ec-clock { gap: 1vh; }
.ec-face { display: block; width: min(86vw, 72vh); height: auto; }
.is-analog:not(.has-date) .ec-face { width: min(86vw, 78vh); }
.is-analog .ec-city { font-size: min(8.5vw, 7.5vh); }
.is-analog .ec-date { font-size: min(6.5vw, 5.5vh); }

.ec-plate { fill: var(--ec-plate); stroke: var(--ec-ring); stroke-width: 2.5; }
.ec-tick-m { stroke: var(--ec-tick); stroke-width: .8; }
.ec-tick-h { stroke: var(--ec-hand); stroke-width: 1.6; }
.ec-num { fill: var(--ec-text); font-size: 9px; font-weight: 600; }
.ec-hand-h { stroke: var(--ec-hand); stroke-width: 3.4; stroke-linecap: round; }
.ec-hand-m { stroke: var(--ec-hand); stroke-width: 2.2; stroke-linecap: round; }
.ec-hand-s { stroke: var(--ec-second); stroke-width: 1.1; stroke-linecap: round; }
.ec-cap { fill: var(--ec-hand); }
.ec-face.is-pending [data-hand] { visibility: hidden; }
