/* ---------------------------------------------------------------
   Wall clock
   Two themes, one layout. Nothing here is hard-coded per theme
   except the token block below.
   --------------------------------------------------------------- */

:root {
  --ring-inset: 16px;   /* gap between screen edge and tick marks */
  --tick-minor: 16px;
  --tick-major: 26px;
  --tick-width: 6px;
}

[data-bs-theme="dark"] {
  --clock-bg: #000;
  --clock-fg: #fff;
  --tick-idle: rgba(255, 255, 255, 0.22);
}

[data-bs-theme="light"] {
  --clock-bg: #fff;
  --clock-fg: #0b0b0b;
  --tick-idle: rgba(0, 0, 0, 0.18);
}

@media (max-width: 575.98px) {
  :root {
    --ring-inset: 10px;
    --tick-minor: 10px;
    --tick-major: 17px;
    --tick-width: 4px;
  }
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background-color: var(--clock-bg);
  color: var(--clock-fg);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------------------------------------------------------------
   Stage
   --------------------------------------------------------------- */

#stage {
  position: fixed;
  inset: 0;
  transition: transform 2s linear;
}

#ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.tick {
  stroke: var(--tick-idle);
  stroke-width: var(--tick-width);
  stroke-linecap: round;
  transition: stroke 120ms linear;
}

.tick.on {
  stroke: var(--clock-fg);
}

@media (prefers-reduced-motion: reduce) {
  .tick { transition: none; }
  #stage { transition: none; }
}

/* ---------------------------------------------------------------
   Digits
   Bootstrap's default stack, but with tabular figures so the
   numerals keep a fixed advance width and the display never jitters.
   --------------------------------------------------------------- */

#clock-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#clock {
  font-size: 100px;       /* replaced by the fit routine on every resize */
  font-weight: 600;
  line-height: 0.82;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  white-space: nowrap;
  transform: translateZ(0);
}

#t-sep {
  /* Optically centre the colon; it sits high in most system faces. */
  position: relative;
  top: -0.04em;
  padding: 0 0.02em;
}

#t-ampm {
  font-size: 0.2em;
  font-weight: 500;
  letter-spacing: 0.06em;
  margin-left: 0.18em;
  vertical-align: 0.9em;
}

#t-ampm:empty {
  display: none;
}

/* ---------------------------------------------------------------
   Chrome: hides itself when the room is quiet
   --------------------------------------------------------------- */

#gear,
#sync-flag {
  position: fixed;
  z-index: 2;
  color: var(--clock-fg);
  opacity: 0.5;
  transition: opacity 400ms ease;
}

#gear {
  right: calc(var(--ring-inset) + var(--tick-major));
  bottom: calc(var(--ring-inset) + var(--tick-major));
  font-size: 1.35rem;
  line-height: 1;
  padding: 0.5rem 0.6rem;
}

#sync-flag {
  left: calc(var(--ring-inset) + var(--tick-major));
  bottom: calc(var(--ring-inset) + var(--tick-major));
  color: var(--bs-warning-text-emphasis);
  background-color: var(--bs-warning-bg-subtle);
  border: 1px solid var(--bs-warning-border-subtle);
}

#gear:hover,
#gear:focus-visible,
#sync-flag:hover,
#sync-flag:focus-visible {
  opacity: 1;
}

#gear:focus-visible,
#sync-flag:focus-visible {
  outline: 2px solid var(--clock-fg);
  outline-offset: 2px;
  box-shadow: none;
}

body.idle {
  cursor: none;
}

body.idle #gear,
body.idle #sync-flag {
  opacity: 0;
  pointer-events: none;
}

/* Keep the chrome visible whenever the modal is open. */
body.modal-open #gear,
body.modal-open #sync-flag {
  opacity: 0.5;
  pointer-events: auto;
}

/* ---------------------------------------------------------------
   Settings
   --------------------------------------------------------------- */

#tz-select {
  font-variant-numeric: tabular-nums;
}

#settings-modal .table th {
  width: 45%;
}

/* Bootstrap's modal compensates for a scrollbar we never had. */
body.modal-open {
  overflow: hidden;
  padding-right: 0 !important;
}
