/* The world clock's stylesheet. Self-contained: this page carries its own head and
 * shares nothing with the rest of topaze.xyz but its palette and its two faces.
 *
 * LIGHT FIRST, because topaze.xyz is a light site and this is a page of it. Dark is the
 * override and gets the same care — the page is most often opened to answer "can I call
 * them now", which is a question people ask at night.
 *
 * THE COLOURS ARE THE SITE'S (www/index.html's tokens): ink, slate, mist and the blue
 * ramp, with amber for daylight. The day band is the one place they carry meaning rather
 * than decoration — amber is the sun up, the blue ramp is the sun down, which is the
 * brand ramp doing exactly what it does on the gem.
 *
 * (c) Stefan LOESCH 2026. All rights reserved.
 */

:root {
  --bg: #f6f8fa;
  --panel: #ffffff;
  --panel-lift: #f6f8fa;
  --line: #e3e7ec;
  --fg: #272b31;
  --muted: #5a6470;
  --brand: #0074bf;
  --day: #e9a63a;
  --golden: #d69228;
  --dusk: #0074bf;
  --night: #0a3350;
  --shadow: 0 1px 2px rgba(39, 43, 49, 0.06);
  --now: #e9a63a;
  --fresh: rgba(233, 166, 58, 0.34);
  --face: "Montserrat", "Helvetica Neue", Arial, sans-serif;
  --figures: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1f2227;
    --panel: #272b31;
    --panel-lift: #2f343b;
    --line: #3a3f46;
    --fg: #f6f8fa;
    --muted: #9aa5b1;
    --brand: #55c9ee;
    --day: #e9a63a;
    --golden: #d69228;
    --dusk: #00649f;
    --night: #0d1a26;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
    --now: #f2b23c;
  --fresh: rgba(242, 178, 60, 0.30);
    --fresh: rgba(242, 178, 60, 0.30);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #1f2227;
  --panel: #272b31;
  --panel-lift: #2f343b;
  --line: #3a3f46;
  --fg: #f6f8fa;
  --muted: #9aa5b1;
  --brand: #55c9ee;
  --day: #e9a63a;
  --golden: #d69228;
  --dusk: #00649f;
  --night: #0d1a26;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --now: #f2b23c;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

/* `hidden` has to win: every panel below sets a `display`, and a display rule beats the
 * attribute's own. The sync panel showing on load was exactly this. */
[hidden] {
  display: none !important;
}

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

/* The page is a column of three: the bar, the rail, and one thin line. Nothing outside
 * the rail scrolls, so the screens can scroll sideways without the page coming with
 * them. `dvh` so the rail does not sit under a phone's toolbar as it appears. */
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--face);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* The bar sits under the phone's status bar, not behind it. */
.bar {
  flex: none;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-block: 10px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

.mark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--fg);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.mark img {
  display: block;
  border-radius: 7px;
}

.bar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 13px;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--brand);
}

.chip[aria-pressed="true"],
.chip.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* THE RAIL. One screen wide per view, snapping, with the scrollbar hidden because the
 * screens are the affordance. `overscroll-behavior-x: contain` stops a swipe at the first
 * or last screen turning into the browser's back gesture. */
.rail {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.rail::-webkit-scrollbar {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .rail {
    scroll-behavior: auto;
  }
}

/* One screen. It scrolls DOWN on its own, which is what keeps the sideways scroll of the
 * rail and the vertical scroll of a long list from fighting each other. */
.view {
  flex: 0 0 100%;
  min-width: 100%;
  scroll-snap-align: start;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

/* What a screen is allowed to be read at. Reading a list is reading, so it keeps a
 * column; a dial is a picture and takes the room it has. */
.column {
  margin: 0 auto;
  padding-block: 20px 28px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: 26px;
}

/* BY `data-screen`, NOT BY ID: the ghosts at the ends of the rail (clock.js `arrange`)
 * carry the screen's name but not its id, and must be laid out exactly as it is — keyed
 * by id, a ghost came up full width and snapped narrower when the real screen replaced
 * it (owner, 2026-11-28). */
[data-screen="list"] .column,
[data-screen="qr"] .column {
  max-width: 680px;
}

[data-screen="dial24"] .column,
[data-screen="dial12"] .column {
  max-width: 820px;
}

[data-screen="ampm"] .column {
  max-width: 1100px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Where you are: the one card with the big face. */
.here {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
}

.place {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.zone {
  margin: 2px 0 10px;
  font-size: 13px;
  color: var(--muted);
}

/* Every figure on the page is set in the mono face: the digits then keep their columns
 * as the seconds turn, which a proportional face does not. */
.now {
  margin: 0;
  font-family: var(--figures);
  font-size: clamp(48px, 16vw, 72px);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.04em;
}

.now .sec {
  font-size: 0.4em;
  color: var(--muted);
  letter-spacing: 0;
  margin-left: 0.2em;
  vertical-align: 0.45em;
}

.now .ampm {
  font-family: var(--face);
  font-size: 0.26em;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-left: 0.3em;
  vertical-align: 1.1em;
}

.date {
  margin: 8px 0 14px;
  font-size: 14px;
  color: var(--muted);
}

/* The day, as the sun actually runs there: the script writes the background as a
 * hard-stop gradient of the sun's real elevation, cut from the logo's ramp. */
.arc {
  position: relative;
  height: 22px;
  border-radius: 7px;
  overflow: visible;
  background: var(--panel-lift);
  border: 1px solid var(--line);
}

/* NOW, and the only amber on the page. The strip says where the sun is; this says where
 * you are in it, so it is the one mark that must be found without looking for it. */
.arc .pin {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 3px;
  border-radius: 2px;
  background: var(--now);
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.45), 0 0 10px rgba(233, 166, 58, 0.55);
  transform: translateX(-1.5px);
}

.solar {
  margin: 8px 0 0;
  font-family: var(--figures);
  font-size: 12px;
  color: var(--muted);
}

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.row {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 13px 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: baseline;
}

/* Night there: the card steps back, so a glance finds the places that are awake. */
.row.asleep {
  background: var(--panel-lift);
}

.row .name {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  min-width: 0;
  overflow-wrap: anywhere;
}

.row .time {
  margin: 0;
  min-width: 0;
  font-family: var(--figures);
  font-size: 28px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.03em;
  text-align: right;
}

.row .time .ampm {
  font-family: var(--face);
  font-size: 0.38em;
  vertical-align: 0.7em;
  margin-left: 0.25em;
  color: var(--muted);
  font-weight: 700;
}

.row .where {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  min-width: 0;
}

.row .shift {
  margin: 0;
  font-family: var(--figures);
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

.row .band {
  grid-column: 1 / -1;
  margin-top: 9px;
}

.row .arc {
  height: 17px;
}

.row .foot-line {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 7px;
}

.drop {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 8px;
  padding: 3px 6px;
  cursor: pointer;
}

/* A city's colour and Remove, side by side at the foot of its card. */
.row-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tint {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px 4px;
  cursor: pointer;
}

/* A CITY'S COLOUR: the frame of its card, the same colour washed out behind it, and its
 * marker on the dials. One shade each, set here once as `--tint`. */
.c-yellow { --tint: var(--now); }
.c-red { --tint: #d64545; }
.c-purple { --tint: #8a5cc8; }
.c-green { --tint: #2e9e62; }
.c-grey { --tint: #7a8591; }

.row[class*="c-"] {
  border-color: var(--tint);
  box-shadow: 0 0 0 1px var(--tint), var(--shadow);
  background: color-mix(in srgb, var(--tint) 12%, var(--panel));
}

.plain li[class*="c-"] {
  box-shadow: inset 4px 0 0 var(--tint);
  background: color-mix(in srgb, var(--tint) 12%, transparent);
}

.face .dot[class*="c-"] {
  fill: var(--tint);
}

.drop:hover {
  color: var(--fg);
  background: var(--panel-lift);
}

.empty,
.note,
.qr-note {
  color: var(--muted);
  font-size: 14px;
}

.add {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px;
}

/* A FIELD WITH A CROSS IN IT. WebKit has one of its own, but it is hidden the moment
 * anything styles the field, and it does not exist in every browser — so the cross is
 * ours, shown only while there is something to clear. */
.search-wrap {
  position: relative;
  display: block;
}

.search {
  font: inherit;
  width: 100%;
  color: var(--fg);
  background: var(--panel-lift);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 40px 10px 12px;
}

.search::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.search-wrap .clear {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.search-wrap .clear:hover {
  color: var(--fg);
  background: var(--line);
}

.hits {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hits button {
  font: inherit;
  width: 100%;
  text-align: left;
  color: var(--fg);
  background: var(--panel-lift);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.hits button:hover {
  border-color: var(--brand);
}

.hits .at {
  color: var(--muted);
  font-size: 13px;
  font-family: var(--figures);
  white-space: nowrap;
}

.sync {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sync h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.code {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* White behind the code in BOTH themes, and the quiet zone drawn into the canvas: a QR
 * on a dark ground, or with no margin, is one a phone will not read. */
#clockQr {
  width: min(320px, 100%);
  height: auto;
  background: #ffffff;
  border-radius: 10px;
  padding: 10px;
  image-rendering: pixelated;
}

.payload {
  font-family: var(--figures);
  font-size: 12px;
  width: 100%;
  color: var(--fg);
  background: var(--panel-lift);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  resize: vertical;
  overflow-wrap: anywhere;
}

.sync-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.said {
  font-size: 13px;
  color: var(--muted);
}

.said.bad {
  color: var(--golden);
}

.foot {
  flex: none;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
  border-top: 1px solid var(--line);
  padding-block: 9px;
  padding-bottom: calc(9px + env(safe-area-inset-bottom, 0px));
}

.foot p {
  margin: 0;
}

.foot a {
  color: var(--brand);
}

@media (prefers-reduced-motion: no-preference) {
  .chip,
  .drop,
  .hits button {
    transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
  }
}


/* ── THE MENU ────────────────────────────────────────────────────────────────────────
 *
 * Everything that is not the clock lives behind the hamburger, so the page shows the time
 * and nothing else until somebody asks for more. */

.viewing {
  margin: 0 auto 0 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 40px;
  height: 36px;
  padding: 0 9px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}

.hamburger span {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: var(--fg);
}

.hamburger[aria-expanded="true"] {
  border-color: var(--brand);
}

.menu {
  position: absolute;
  top: calc(58px + env(safe-area-inset-top, 0px));
  left: 0;
  right: 0;
  z-index: 6;
  max-width: 680px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(10, 20, 30, 0.18);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.views {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.views button {
  font: inherit;
  font-weight: 600;
  width: 100%;
  text-align: left;
  color: var(--fg);
  background: var(--panel-lift);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

.views button:hover {
  border-color: var(--line);
}

/* The view you are on, marked in the menu as well as in the bar. */
.views button[aria-current="true"] {
  background: var(--brand);
  color: #ffffff;
}

.menu-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── THE DIALS ───────────────────────────────────────────────────────────────────────
 *
 * Blue throughout, including daylight: the band says WHEN, and a second hue would read as
 * a second kind of fact. The face carries its own colours so it is legible on either
 * theme without the drawing code knowing which is on. */

/* NO BOX. A dial is already a shape; a card around it is a second one, and two shapes
 * arguing is what made the page look busy (owner, 2026-11-18). */
.dial-wrap {
  margin: 0;
  padding: 0;
}

.face {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

/* The band's own shades are set on each facet, from the logo's ramp (`dials.js`): they
 * are the brand's colours, not the theme's, so the dial is the same stone in both. */

.face .tick {
  stroke: var(--muted);
  stroke-width: 1.5;
  opacity: 0.5;
}

.face .tick.major {
  stroke: var(--fg);
  stroke-width: 2;
  opacity: 0.75;
}

.face .hour {
  fill: var(--muted);
  font-family: var(--figures);
  font-size: 15px;
  text-anchor: middle;
  dominant-baseline: middle;
}

/* A ring's name, written on the ring: white, because the ring it sits on is a brand
 * blue in every shade the ramp has. */
.face .ringname {
  fill: #ffffff;
  font-size: 13px;
  font-weight: 700;
  /* No letter-spacing: each letter is placed on its own, so spacing would only push it
   * off its seat on the ring. */
  text-anchor: middle;
  dominant-baseline: middle;
  opacity: 0.9;
}

.face .keyname {
  fill: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  dominant-baseline: middle;
}

.face .keyname.centred {
  text-anchor: middle;
}

.face .facename {
  fill: var(--fg);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-anchor: middle;
  /* the alphabetic baseline: `faceName` in dials.js centres the capitals with `dy` */
  opacity: 0.5;
}

.face .dot {
  fill: var(--brand);
  stroke: var(--panel);
  stroke-width: 2.5;
}

/* WHERE THE READER IS: bigger than the others, and amber — the same amber as the marker
 * on the daylight strip, and the only amber on the page. One colour, one meaning: this
 * is you, now. On a face that is blue in every shade it carries, it is found before it
 * is read. */
.face .dot.here {
  fill: var(--now);
}

.face .leader {
  stroke: var(--line);
  stroke-width: 1.5;
}

.face .label {
  fill: var(--fg);
  font-size: 15px;
  font-weight: 600;
  dominant-baseline: middle;
}

.face .label.here {
  font-weight: 700;
}

/* A city on the inner ring of a two-ring face (AM/PM, day/night): light grey, name and
 * time alike, so it reads apart from the outer ring's cities beside it. */
.face .label.inner,
.face .label.inner .at {
  fill: #9aa5b1;
}

.face .label .at {
  fill: var(--muted);
  font-family: var(--figures);
  font-size: 13px;
  font-weight: 400;
}

/* Two dials: beside each other when the screen is wider than it is tall, stacked when it
 * is not. Which is the ask, and also the only way both stay big enough to read. */
.pair {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (orientation: landscape) and (min-width: 620px) {
  .pair {
    grid-template-columns: 1fr 1fr;
  }
}

/* The code view's list of cities: names and zones, no times — see `drawCode`. */
.plain {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.plain li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--panel-lift);
}

.plain .at {
  color: var(--muted);
  font-family: var(--figures);
  font-size: 12.5px;
}




/* ── a city just added ───────────────────────────────────────────────────────────────
 * The row is scrolled to and then LIT AND LET GO. An animation rather than a class
 * toggled with a transition: the row is brand new, so there is no previous value for a
 * transition to run from and the first frame would simply be the finished state. */
@keyframes freshen {
  from { background: var(--fresh); border-color: var(--now); }
  to   { background: var(--panel); border-color: var(--line); }
}

.row.fresh {
  animation: freshen 2600ms ease-out 1;
}

.row.fresh.asleep {
  animation-name: freshen-asleep;
}

@keyframes freshen-asleep {
  from { background: var(--fresh); border-color: var(--now); }
  to   { background: var(--panel-lift); border-color: var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  .row.fresh { animation-duration: 1ms; }
}

/* ── the carousel ────────────────────────────────────────────────────────────────────
 * The screen itself does not scroll; the ring inside it does, so the loop arithmetic
 * owns one element and nothing else can move it. The cards are the list's own cards —
 * the two views differ in how they are scrolled and in nothing else. */
[data-screen="loop"] {
  overflow-y: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

.loop-add {
  flex: 0 0 auto;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding-top: 18px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

.loop-add .hits {
  max-height: 46vh;
  overflow-y: auto;
}

/* NO `-webkit-overflow-scrolling: touch`: the legacy value puts the scroller on its own
 * composited layer, which paints blank while a fast flick outruns it — and it defers the
 * scroll events the loop needs to move the content back under the reader. */
.loop {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
}

.loop::-webkit-scrollbar {
  display: none;
}

.loop-inner {
  margin: 0 auto;
  max-width: 680px;
  padding-block: 14px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Where you are, in the amber the dials use for the same thing. */
/* HOME IS YELLOW, frame and wash, like any coloured city (owner, 2026-11-28): your own
 * card in the carousel, and the Here card at the top of the list. */
.row.mine,
.here {
  border-color: var(--now);
  box-shadow: 0 0 0 1px var(--now), var(--shadow);
  background: color-mix(in srgb, var(--now) 12%, var(--panel));
}


/* The hour beside a search hit is a time to READ, not a footnote: the clock's figures,
 * at a size you can look up a city with and never add it. */
.hits .hit-time {
  font-family: var(--figures);
  font-size: 21px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}
