/* ---------------------------------------------
   Token system — one palette per time-of-day phase.
   Everything else derives from these variables.
   --------------------------------------------- */

:root {
  --text: #1b1e24;
  --text-dim: #1b1e2499;
  --pulse-speed: 4.5s;
  --font-display: "Space Grotesk", "Helvetica Neue", sans-serif;
  --font-body: "IBM Plex Sans", "Helvetica Neue", sans-serif;
}

body[data-phase="dawn"] {
  --bg: #f4ede3;
  --accent: #e0966b;
  --accent-soft: #e0966b33;
}

body[data-phase="day"] {
  --bg: #f7fafc;
  --accent: #4a90d9;
  --accent-soft: #4a90d933;
}

body[data-phase="dusk"] {
  --bg: #f5e3d8;
  --accent: #d9764a;
  --accent-soft: #d9764a3a;
}

body[data-phase="night"] {
  --bg: #12141b;
  --accent: #7189b8;
  --accent-soft: #7189b840;
  --text: #e7e9ee;
  --text-dim: #e7e9ee99;
}

/* condition nudges the accent without changing the phase */
body[data-condition="rain"],
body[data-condition="storm"] {
  filter: saturate(0.85);
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;
  transition: background 1.4s ease, color 1.4s ease;
  position: relative;
}

/* ---------------------------------------------
   Signature element: the pulse field.
   A slow breathing glow behind the clock whose
   speed and color respond to time and weather.
   --------------------------------------------- */

.pulse-field {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 0;
}

.pulse-ring {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft) 0%, transparent 70%);
  animation: breathe var(--pulse-speed) ease-in-out infinite;
}

.pulse-ring--outer {
  width: min(70vw, 640px);
  height: min(70vw, 640px);
}

.pulse-ring--inner {
  width: min(38vw, 340px);
  height: min(38vw, 340px);
  animation-delay: 0.4s;
  opacity: 0.8;
}

@keyframes breathe {
  0%, 100% { transform: scale(0.92); opacity: 0.55; }
  50% { transform: scale(1.05); opacity: 1; }
}

/* ---------------------------------------------
   Layout
   --------------------------------------------- */

.stage {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  text-align: center;
  padding: 1.5rem;
}

.clock-block {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.clock {
  font-size: clamp(3.5rem, 14vw, 8rem);
  letter-spacing: -0.02em;
}

.seconds {
  font-size: clamp(1rem, 3vw, 1.6rem);
  color: var(--accent);
  min-width: 2.2ch;
  text-align: left;
}

.date {
  margin: 0;
  font-size: clamp(0.85rem, 2vw, 1rem);
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.weather {
  margin-top: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: clamp(0.85rem, 2vw, 1rem);
  color: var(--text-dim);
}

.weather-temp {
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 500;
}

.weather-place::before {
  content: "·";
  margin-right: 0.55rem;
  color: var(--text-dim);
}

.weather-place:empty::before {
  content: "";
}

/* ---------------------------------------------
   Unit toggle
   --------------------------------------------- */

.unit-toggle {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 2;
  background: transparent;
  border: 1px solid var(--text-dim);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  cursor: pointer;
  transition: color 0.3s ease, border-color 0.3s ease;
}

.unit-toggle:hover,
.unit-toggle:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
}

.unit-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------------------------------------
   Footer credit + live pulse dot
   --------------------------------------------- */

.credit {
  position: fixed;
  bottom: 1.1rem;
  left: 0;
  right: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: breathe var(--pulse-speed) ease-in-out infinite;
}

/* ---------------------------------------------
   Accessibility: respect reduced motion
   --------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .pulse-ring,
  .pulse-dot {
    animation: none;
    opacity: 0.7;
  }
}

@media (max-width: 420px) {
  .weather {
    flex-direction: column;
    gap: 0.2rem;
  }
  .weather-place::before {
    content: "";
    margin: 0;
  }
}
