/* ══════════════════════════════════════════════════════════════
   Москва — точное время
   Монохром + один акцент, без внешних шрифтов и библиотек.
   Вёрстка mobile-first, тема: авто / тёмная / светлая.
   ══════════════════════════════════════════════════════════════ */

:root {
  --bg:        #0b0b0c;
  --bg-soft:   #131315;
  --fg:        #f3f2ef;
  --muted:     #74747c;
  --faint:     #3a3a40;
  --line:      rgba(255, 255, 255, .12);
  --line-soft: rgba(255, 255, 255, .06);
  --accent:    #ff4d2e;
  --ok:        #35d07f;

  --pad:  clamp(18px, 4.6vw, 60px);
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
          "Helvetica Neue", Inter, Roboto, Arial, sans-serif;
}

/* светлая тема — «бумага», а не инверсия чёрного */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:        #f4f2ed;
    --bg-soft:   #ffffff;
    --fg:        #131316;
    --muted:     #84817a;
    --faint:     #c9c5bb;
    --line:      rgba(0, 0, 0, .15);
    --line-soft: rgba(0, 0, 0, .07);
  }
}

:root[data-theme="light"] {
  --bg:        #f4f2ed;
  --bg-soft:   #ffffff;
  --fg:        #131316;
  --muted:     #84817a;
  --faint:     #c9c5bb;
  --line:      rgba(0, 0, 0, .15);
  --line-soft: rgba(0, 0, 0, .07);
}

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

html { height: 100%; }

body {
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  overflow-x: hidden;
  transition: background .4s ease, color .4s ease;
}

::selection { background: var(--accent); color: #fff; }

/* тёплое световое пятно за циферблатом */
body::before {
  content: "";
  position: fixed;
  inset: -25% -10% auto;
  height: 75vh;
  background: radial-gradient(55% 55% at 50% 42%, rgba(255, 77, 46, .11), transparent 72%);
  pointer-events: none;
  z-index: 0;
}

.frame {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: clamp(20px, 4vh, 48px);
  padding:
    calc(var(--pad) + env(safe-area-inset-top))
    calc(var(--pad) + env(safe-area-inset-right))
    calc(var(--pad) + env(safe-area-inset-bottom))
    calc(var(--pad) + env(safe-area-inset-left));
}

/* ── шапка ──────────────────────────────────────────────────── */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 18px;
  flex-wrap: wrap;
  font-size: 11px;
  letter-spacing: .3em;
  text-transform: uppercase;
  user-select: none;
}

.place { display: flex; align-items: center; gap: 12px; min-width: 0; }

.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 0 transparent;
  transition: background .3s ease, box-shadow .3s ease;
  flex: none;
}

.dot[data-state="ok"]    { background: var(--ok);     animation: pulse 3.2s ease-out infinite; }
.dot[data-state="local"] { background: var(--accent); }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(53, 208, 127, .45); }
  70%  { box-shadow: 0 0 0 9px rgba(53, 208, 127, 0); }
  100% { box-shadow: 0 0 0 0 rgba(53, 208, 127, 0); }
}

.zone {
  color: var(--muted);
  letter-spacing: .16em;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.controls { display: flex; align-items: center; gap: 8px; }

.sync, .theme {
  font: inherit;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: color .25s ease, border-color .25s ease, background .25s ease;
}

.sync { padding: 9px 15px; min-height: 34px; white-space: nowrap; }

.theme {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  flex: none;
}

.theme svg { width: 15px; height: 15px; fill: currentColor; transition: transform .5s cubic-bezier(.3,.8,.2,1); }
:root[data-theme="light"] .theme svg { transform: rotate(180deg); }

.sync:hover, .theme:hover { color: var(--fg); border-color: var(--fg); }
.sync:active, .theme:active { transform: translateY(1px); }
.sync:focus-visible, .theme:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sync[data-busy="1"] { opacity: .5; }

/* ── циферблат ──────────────────────────────────────────────── */

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 0;
}

.clock {
  display: flex;
  align-items: flex-start;
  font-size: min(23vw, 26vh, 250px);
  font-weight: 200;
  letter-spacing: -.045em;
  line-height: .82;
  white-space: nowrap;
}

.colon {
  margin: 0 .03em;
  animation: blink 2s steps(1, end) infinite;
}

@keyframes blink { 50% { opacity: .2; } }

.ss {
  align-self: flex-start;
  margin-left: .17em;
  font-size: .23em;
  font-weight: 400;
  letter-spacing: .05em;
  color: var(--accent);
  transform: translateY(.32em);
}

/* тонкий индикатор текущей минуты под цифрами */
.minute {
  width: min(46vw, 320px);
  height: 1px;
  margin-top: clamp(16px, 2.6vh, 30px);
  background: var(--line-soft);
  overflow: hidden;
}

.minute i { display: block; height: 100%; width: 0; background: var(--accent); opacity: .55; }

.date {
  margin-top: clamp(14px, 2.4vh, 26px);
  font-size: clamp(13px, 1.4vw + 8px, 19px);
  font-weight: 400;
  letter-spacing: .05em;
  color: var(--muted);
}

.date::first-letter { text-transform: uppercase; }

.drift {
  margin-top: 8px;
  min-height: 15px;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--faint);
}

/* ── подвал ─────────────────────────────────────────────────── */

.bottom { display: grid; gap: clamp(18px, 3vh, 30px); }

.day { position: relative; }

.suns { position: relative; height: 15px; }

.sun {
  position: absolute;
  bottom: 0;
  transform: translateX(-50%);
  font-size: 10px;
  font-style: normal;
  letter-spacing: .1em;
  color: var(--muted);
  white-space: nowrap;
}

.sun::after {
  content: "";
  display: block;
  width: 1px; height: 5px;
  margin: 3px auto -1px;
  background: var(--line);
}

.track {
  position: relative;
  height: 1px;
  background: var(--line-soft);
}

/* светлое время суток — чуть заметная подложка */
.daylight {
  position: absolute;
  top: -1px; height: 3px;
  background: var(--faint);
  opacity: .55;
}

.tick { position: absolute; top: -3px; width: 1px; height: 7px; background: var(--line); }

.fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--accent);
}

.fill::after {
  content: "";
  position: absolute;
  right: -1px; top: -3.5px;
  width: 2px; height: 8px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.scale {
  display: flex;
  justify-content: space-between;
  margin-top: 9px;
  font-size: 10px;
  letter-spacing: .18em;
  color: var(--faint);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.stats dt {
  font-size: 9.5px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats dd { font-size: clamp(14px, 1.2vw + 8px, 19px); font-weight: 300; }

.stats div + div { padding-left: 14px; border-left: 1px solid var(--line-soft); }

/* ── телефоны ───────────────────────────────────────────────── */

@media (max-width: 620px) {
  .top { font-size: 10px; letter-spacing: .24em; }
  .place { flex: 1 1 100%; justify-content: space-between; }
  .controls { flex: 1 1 100%; justify-content: space-between; }
  .sync { flex: 1; text-align: center; }

  .clock { font-size: min(27vw, 22vh); }
  .minute { width: 62vw; }

  .stats { grid-template-columns: repeat(2, 1fr); gap: 18px 12px; }
  .stats div:nth-child(odd) { padding-left: 0; border-left: 0; }
}

/* телефон в альбомной ориентации — ужимаем всё по высоте */
@media (orientation: landscape) and (max-height: 480px) {
  .frame { gap: 14px; }
  .clock { font-size: min(17vw, 30vh); }
  .minute { margin-top: 10px; }
  .drift { display: none; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .stats div:nth-child(odd) { padding-left: 14px; border-left: 1px solid var(--line-soft); }
  .stats div:first-child { padding-left: 0; border-left: 0; }
}

/* ── появление и доступность ────────────────────────────────── */

.top, .stage, .bottom { animation: rise .75s cubic-bezier(.2, .7, .2, 1) backwards; }
.stage  { animation-delay: .07s; }
.bottom { animation-delay: .14s; }

@keyframes rise { from { opacity: 0; transform: translateY(16px); } }

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