/* Timebase — web styles
   Main UI: SF stack. About card: Fraunces (wordmark) + Departure Mono (body).
   Sizes: 13 / 17 / 22 / 28 / 48. No other sizes. */

@font-face {
  font-family: "Departure Mono";
  src: url("/fonts/DepartureMono-Regular.woff2") format("woff2"),
       url("/fonts/DepartureMono-Regular.woff")  format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #F8F6F2;
  --fg: #11131A;
  --fg-muted: rgba(17, 19, 26, 0.55);
  --rule: rgba(0, 0, 0, 0.15);
  --sheet-bg: #FFFFFF;
  --sheet-shadow: 0 -20px 60px rgba(0, 0, 0, 0.18);
  --accent: #11131A;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", system-ui, sans-serif;
  font-feature-settings: "tnum" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E0E10;
    --fg: #F0EEE8;
    --fg-muted: rgba(240, 238, 232, 0.55);
    --rule: rgba(255, 255, 255, 0.15);
    --sheet-bg: #1A1A1D;
    --sheet-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
    --accent: #F0EEE8;
  }
}

:root[data-theme="light"] {
  --bg: #F8F6F2; --fg: #11131A; --fg-muted: rgba(17,19,26,0.55);
  --rule: rgba(0,0,0,0.15); --sheet-bg: #FFFFFF;
  --sheet-shadow: 0 -20px 60px rgba(0, 0, 0, 0.18); --accent: #11131A;
}
:root[data-theme="dark"] {
  --bg: #0E0E10; --fg: #F0EEE8; --fg-muted: rgba(240,238,232,0.55);
  --rule: rgba(255,255,255,0.15); --sheet-bg: #1A1A1D;
  --sheet-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5); --accent: #F0EEE8;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior: none;
}

body {
  font-size: 17px;
  line-height: 1.4;
}

/* Main world clock list */
#clock {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: ew-resize;
}

.row {
  flex: 1 1 0;
  min-height: 84px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 0 max(28px, env(safe-area-inset-left)) 0 max(28px, env(safe-area-inset-right));
  position: relative;
  border-top: 0.5px solid rgba(0,0,0,0.06);
  /* Two-stop vertical gradient — "almost solid but breathing". */
  background:
    linear-gradient(180deg, var(--row-bg-top, var(--row-bg, transparent)) 0%, var(--row-bg-bot, var(--row-bg, transparent)) 100%);
  color: var(--row-fg, var(--fg));
  transition: filter 0.25s ease;
  cursor: pointer;
  isolation: isolate;
}

.row::after {
  /* Paper-grain texture overlay. Two layers (soft-light + overlay) so the
     texture reads on both light and dark rows. */
  content: "";
  position: absolute;
  inset: 0;
  background-image: url('/grain.png');
  background-size: 256px 256px;
  background-repeat: repeat;
  mix-blend-mode: overlay;
  opacity: 0.55;
  pointer-events: none;
  z-index: 0;
}

.row::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url('/grain.png');
  background-size: 256px 256px;
  background-repeat: repeat;
  mix-blend-mode: soft-light;
  opacity: 0.9;
  pointer-events: none;
  z-index: 0;
}

.row > * { position: relative; z-index: 1; }

.row:first-child { border-top: none; }

.row .name {
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.005em;
}

.row .time {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}

.row .time .day-chip {
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.65;
  padding: 2px 6px;
  border: 0.5px solid currentColor;
  border-radius: 4px;
  align-self: center;
}

body.scrubbed .row { filter: saturate(0.65); }

/* Bottom dock of pills */
#dock {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 10;
  pointer-events: none;
}
#dock > * { pointer-events: auto; }

/* Skeuomorphic pills — Teenage Engineering / Braun button feel.
   Subtle gradient (light from above), inset highlight at the top, soft cast
   shadow on the surface, grain texture overlay. Pressable on :active. */
.pill {
  --pill-fill-top: #F5F2EC;
  --pill-fill-bot: #E0DAD0;
  --pill-edge:     rgba(40, 30, 18, 0.18);
  --pill-highlight: rgba(255, 255, 255, 0.85);
  --pill-shadow:   0 1px 0 rgba(255,255,255,0.6) inset,
                   0 -1px 0 rgba(0,0,0,0.06) inset,
                   0 1px 1px rgba(0,0,0,0.06),
                   0 4px 10px rgba(0,0,0,0.10);

  background: linear-gradient(180deg, var(--pill-fill-top), var(--pill-fill-bot));
  color: #1c1c1f;
  border: 0.5px solid var(--pill-edge);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: var(--pill-shadow);
  font-variant-numeric: tabular-nums;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  isolation: isolate;
  transition: transform 0.08s ease-out, box-shadow 0.12s;
}

.pill::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: url("/grain.png");
  background-size: 128px 128px;
  background-repeat: repeat;
  mix-blend-mode: overlay;
  opacity: 0.55;
  pointer-events: none;
}

.pill:hover { transform: translateY(-0.5px); }
.pill:active {
  transform: translateY(0.5px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.10) inset,
              0 -1px 0 rgba(255,255,255,0.4) inset,
              0 1px 1px rgba(0,0,0,0.04);
}

@media (prefers-color-scheme: dark) {
  .pill {
    --pill-fill-top: #2E2A24;
    --pill-fill-bot: #1A1714;
    --pill-edge:     rgba(0, 0, 0, 0.55);
    --pill-highlight: rgba(255,255,255,0.10);
    --pill-shadow:   0 1px 0 rgba(255,255,255,0.10) inset,
                     0 -1px 0 rgba(0,0,0,0.40) inset,
                     0 2px 2px rgba(0,0,0,0.30),
                     0 6px 14px rgba(0,0,0,0.40);
    color: #F0EBE2;
  }
}

:root[data-theme="light"] .pill {
  --pill-fill-top: #F5F2EC; --pill-fill-bot: #E0DAD0;
  --pill-edge: rgba(40,30,18,0.18); color: #1c1c1f;
  --pill-shadow: 0 1px 0 rgba(255,255,255,0.6) inset,
                 0 -1px 0 rgba(0,0,0,0.06) inset,
                 0 1px 1px rgba(0,0,0,0.06),
                 0 4px 10px rgba(0,0,0,0.10);
}
:root[data-theme="dark"] .pill {
  --pill-fill-top: #2E2A24; --pill-fill-bot: #1A1714;
  --pill-edge: rgba(0,0,0,0.55); color: #F0EBE2;
  --pill-shadow: 0 1px 0 rgba(255,255,255,0.10) inset,
                 0 -1px 0 rgba(0,0,0,0.40) inset,
                 0 2px 2px rgba(0,0,0,0.30),
                 0 6px 14px rgba(0,0,0,0.40);
}

.pill[hidden] { display: none; }

.icon-pill {
  width: 38px;
  height: 38px;
  padding: 0;
}

.icon-pill .info-glyph {
  font-family: "Times New Roman", Times, serif;
  font-style: italic;
  font-size: 19px;
  font-weight: 600;
  line-height: 1;
}

#scrub-pill { font-weight: 800; padding: 10px 22px; }

/* Sheets */
dialog {
  margin: auto;
  padding: 0;
  border: none;
  background: transparent;
  max-width: 520px;
  width: 100%;
  border-radius: 16px;
  color: var(--fg);
}

dialog::backdrop {
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
}

.sheet-inner {
  background: var(--sheet-bg);
  border-radius: 16px;
  padding: 24px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: 0.5px solid var(--rule);
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.sheet-inner::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("/grain.png");
  background-size: 256px 256px;
  background-repeat: repeat;
  mix-blend-mode: overlay;
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
}
.sheet-inner > * { position: relative; z-index: 1; }

.sheet-inner header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sheet-inner header h2 {
  font-size: 22px;
  font-weight: 400;
  margin: 0;
}

.sheet-inner header button[type="submit"] {
  background: transparent;
  border: none;
  font-size: 17px;
  font-weight: 500;
  color: var(--fg);
  cursor: pointer;
  padding: 6px 8px;
}

#city-search {
  flex: 1;
  background: rgba(128,128,128,0.12);
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 17px;
  color: var(--fg);
  font-family: inherit;
}

#city-search:focus { outline: 1.5px solid var(--accent); }

#city-section-label {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin: 0;
}

#city-results {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  flex: 1;
}

#city-results li {
  padding: 12px 4px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 0.5px solid var(--rule);
  cursor: pointer;
  font-size: 17px;
}

#city-results li:last-child { border-bottom: none; }
#city-results li:hover { background: rgba(128,128,128,0.08); }

#city-results li .country {
  font-size: 13px;
  color: var(--fg-muted);
  font-weight: 400;
}

/* City detail */
.sheet-inner.detail h3 {
  font-size: 28px;
  font-weight: 400;
  margin: 0;
}
.sheet-inner.detail .country {
  font-size: 13px;
  color: var(--fg-muted);
  margin: 0 0 8px;
}
.sheet-inner.detail .big-time {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 12px 0 0;
  font-variant-numeric: tabular-nums;
}
.sheet-inner.detail .tz {
  font-size: 13px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin: 0 0 24px;
}
.sheet-inner.detail .daybar {
  position: relative;
  height: 16px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}
.sheet-inner.detail .daybar .sun-now {
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--fg);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 2px var(--sheet-bg);
}
.sheet-inner.detail .daybar .tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(0,0,0,0.4);
}
.sheet-inner.detail .day-meta {
  font-size: 13px;
  color: var(--fg-muted);
  display: flex;
  justify-content: space-between;
  margin: 0 0 24px;
  font-variant-numeric: tabular-nums;
}
.sheet-inner.detail .facts {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sheet-inner.detail .facts li {
  font-size: 17px;
  padding: 6px 0;
}
.sheet-inner.detail .facts li .label {
  font-size: 13px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: block;
}
.sheet-inner footer {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}
.sheet-inner footer button {
  flex: 1;
  background: rgba(128,128,128,0.12);
  border: none;
  padding: 12px;
  border-radius: 10px;
  font-size: 17px;
  font-family: inherit;
  color: var(--fg);
  cursor: pointer;
}
.sheet-inner footer button.danger {
  color: #C04848;
}

/* Settings list */
ul.settings {
  list-style: none;
  padding: 0;
  margin: 0;
}
ul.settings li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 0.5px solid var(--rule);
  font-size: 17px;
  gap: 12px;
}
ul.settings li:last-child { border-bottom: none; }
ul.settings select {
  background: transparent;
  border: 0.5px solid var(--rule);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 17px;
  color: var(--fg);
  font-family: inherit;
}
ul.settings button {
  background: transparent;
  border: 0.5px solid var(--rule);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 17px;
  color: var(--fg);
  font-family: inherit;
  cursor: pointer;
  width: 100%;
}
ul.settings li.about {
  display: block;
  text-align: center;
  padding-top: 24px;
}
ul.settings li.about p { margin: 4px 0; }
ul.settings li.about .muted { color: var(--fg-muted); font-size: 13px; }
ul.settings li.about a { color: var(--fg-muted); }

/* First-run hint */
#hint {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  z-index: 20;
  padding: 24px;
  text-align: center;
}
#hint[hidden] { display: none; }
#hint p {
  color: #fff;
  font-size: 22px;
  font-weight: 400;
  max-width: 380px;
  margin: 0 0 8px;
  line-height: 1.4;
}
#hint button {
  margin-top: 24px;
  background: #fff;
  color: #000;
  border: none;
  padding: 12px 28px;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

/* About card — Macintosh-style */
#about-sheet {
  max-width: 460px;
}
#about-sheet::backdrop {
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(6px);
}

.about-card {
  background: var(--sheet-bg);
  border-radius: 14px;
  border: 0.5px solid var(--rule);
  padding: 28px 26px 22px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.18), 0 2px 4px rgba(0,0,0,0.06);
  text-align: center;
  position: relative;
  font-family: "Departure Mono", ui-monospace, "SF Mono", Menlo, monospace;
  isolation: isolate;
  overflow: hidden;
}

.about-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("/grain.png");
  background-size: 256px 256px;
  background-repeat: repeat;
  mix-blend-mode: overlay;
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
}
.about-card > * { position: relative; z-index: 1; }

.about-wordmark {
  font-family: "Crimson Text", ui-serif, Georgia, serif;
  font-weight: 600;
  font-size: 52px;
  line-height: 1;
  letter-spacing: -0.005em;
  margin: 4px 0 6px;
  color: var(--fg);
}

.about-version {
  font-family: "Departure Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 22px;
}

.about-tagline {
  font-family: "Departure Mono", ui-monospace, monospace;
  font-size: 14px;
  line-height: 1.45;
  color: var(--fg);
  margin: 0 0 10px;
}

.about-subline {
  font-family: "Departure Mono", ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.5;
  color: var(--fg-muted);
  margin: 0 0 22px;
}

.about-settings {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 18px;
  padding: 12px 14px;
  background: rgba(128,128,128,0.06);
  border: 0.5px solid var(--rule);
  border-radius: 10px;
}

.about-settings label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: "Departure Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.about-settings select {
  background: transparent;
  border: 0.5px solid var(--rule);
  border-radius: 6px;
  padding: 4px 8px;
  font-family: "Departure Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--fg);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.about-divider {
  height: 1px;
  background: var(--rule);
  margin: 0 -8px 14px;
}

.about-foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.about-credit {
  font-family: "Departure Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
}
.about-credit a {
  color: var(--fg);
  text-decoration: none;
  border-bottom: 0.5px solid currentColor;
}

.about-links {
  display: flex;
  gap: 14px;
  align-items: center;
}
.about-links a {
  color: var(--fg-muted);
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.about-links a:hover {
  color: var(--fg);
  background: rgba(128,128,128,0.10);
}

/* Traffic lights — macOS-style window controls. Red closes; yellow + green
   are decorative homage. Symbols appear on hover of the group. */
.traffic-lights {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  gap: 8px;
}
.traffic-light {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 0.5px solid rgba(0,0,0,0.18);
  padding: 0;
  cursor: default;
  display: grid;
  place-items: center;
  background: var(--tl-color);
}
.traffic-light.close { --tl-color: #FF5F57; cursor: pointer; }
.traffic-light.minimize { --tl-color: #FFBD2E; }
.traffic-light.maximize { --tl-color: #28C940; }

@media (prefers-color-scheme: dark) {
  .traffic-light { border-color: rgba(0,0,0,0.5); }
}

.traffic-light svg {
  width: 8px;
  height: 8px;
  stroke: rgba(0,0,0,0.55);
  stroke-width: 1.25;
  stroke-linecap: round;
  fill: none;
  opacity: 0;
  transition: opacity 0.12s;
}
.traffic-lights:hover .traffic-light svg { opacity: 1; }
.traffic-light:focus-visible svg { opacity: 1; }
.traffic-light.close:focus { outline: none; }

@media (max-width: 600px) {
  dialog { max-width: 100%; margin: auto 12px 12px; }
  .row { min-height: 72px; padding: 0 20px; }
  .row .name { font-size: 22px; }
  .row .time { font-size: 28px; }
  .about-wordmark { font-size: 40px; }
}
