/* ==========================================================================
   COMMON — shared theme layer
   Loaded after the page's base stylesheet. The light theme is the untouched
   default; the dark theme is a warm charcoal built from the same structure,
   typography, and single-cobalt accent language.
   ========================================================================== */

.precision-toggle {
  display: block;
  width: fit-content;
  min-height: 36px;
  margin: 6px auto 0;
  padding: 8px 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.4;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

.precision-toggle::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border: 1px solid currentColor;
  vertical-align: -1px;
}

.precision-toggle[aria-checked="true"] {
  color: var(--cobalt);
}

.precision-toggle[aria-checked="true"]::before {
  background: currentColor;
}

.precision-toggle:hover {
  border-color: var(--line-strong);
}

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

html[data-theme="light"] {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --paper: #15181d;
  --paper-raised: #1c2027;
  --paper-sunk: #111419;
  --ink: #eeeae2;
  --ink-soft: #c4c2bc;
  --muted: #a5a69f;
  --faint: #858a90;
  --line: rgba(238, 234, 226, 0.16);
  --line-strong: rgba(238, 234, 226, 0.3);
  --cobalt: #93a8ff;
  --cobalt-deep: #7c92f2;
  --cobalt-wash: rgba(147, 168, 255, 0.1);
  --green: #5ecf96;
  --green-bright: #46d08d;
  --red: #ff8577;
  --on-cobalt: #11151b;
  --on-cobalt-dim: rgba(17, 21, 27, 0.82);
  --card-accent: #244df5;
}

/* The blue today card keeps its deep brand blue. The lighter dark-theme
   accent is for text, rules, and small fills where it has to read on ink. */
html[data-theme="dark"] .date-card {
  --on-cobalt: #f7f5ef;
  --on-cobalt-dim: rgba(247, 245, 239, 0.88);
  background: var(--card-accent);
}

/* Dark surfaces that the base pages hard-code in warm-paper values. */
html[data-theme="dark"] .site-header {
  background: rgba(21, 24, 29, 0.88);
}

html[data-theme="dark"] .brand-ratio,
html[data-theme="dark"] .zone-chip {
  border-color: rgba(147, 168, 255, 0.42);
}

html[data-theme="dark"] .month-card {
  background: rgba(28, 32, 39, 0.72);
}

html[data-theme="dark"] .rail:not(.rail-light) {
  background: rgba(238, 234, 226, 0.14);
}

html[data-theme="dark"] .outside-card {
  border-color: rgba(147, 168, 255, 0.45);
}

html[data-theme="dark"] .cal-day.is-selected.is-today,
html[data-theme="dark"] .special-badge.is-today.is-selected {
  box-shadow: inset 0 0 0 2px rgba(17, 21, 27, 0.6);
}

html[data-theme="dark"] .app-status,
html[data-theme="dark"] .form-error {
  background: rgba(255, 133, 119, 0.12);
}

html[data-theme="dark"] #converter-input {
  color-scheme: dark;
}

/* --------------------------------------------------------------------------
   Theme control
   The placeholder is empty until theme.js upgrades it. The native button is
   always 44 x 44, and the icon shows the theme it will switch to: a moon
   while the page is light, an outlined sun while it is dark.
   -------------------------------------------------------------------------- */

[data-theme-control] {
  display: inline-flex;
  align-items: center;
  flex: none;
}

.theme-toggle {
  appearance: none;
  -webkit-appearance: none;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius, 2px);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: border-color 0.15s var(--ease, ease), color 0.15s var(--ease, ease),
    background 0.15s var(--ease, ease);
}

.theme-toggle:hover {
  border-color: var(--cobalt);
  background: var(--cobalt-wash);
  color: var(--cobalt);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

html[data-theme="light"] .theme-icon-sun,
html[data-theme="dark"] .theme-icon-moon {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle {
    transition: none;
  }
}

/* Seasonal layer: the normal light/dark layouts remain untouched when off. */
.spooky-banner,
.spooky-tower,
.spooky-tagline,
.christmas-banner,
.christmas-tower,
.christmas-tagline {
  display: none;
}

[data-theme-control] {
  gap: 4px;
}

.season-toggle {
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius, 2px);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  touch-action: manipulation;
}

.season-toggle svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.season-toggle:hover,
.season-toggle[aria-pressed="true"] {
  color: var(--cobalt);
  border-color: var(--cobalt);
  background: var(--cobalt-wash);
}

html[data-spooky="true"] {
  color-scheme: dark;
  --paper: #160f1d;
  --paper-raised: #211627;
  --paper-sunk: #100b15;
  --ink: #f7ead2;
  --ink-soft: #dbccb7;
  --muted: #baaaa0;
  --faint: #a58f89;
  --line: rgba(255, 179, 96, 0.19);
  --line-strong: rgba(255, 179, 96, 0.4);
  --cobalt: #ffab55;
  --cobalt-deep: #f19139;
  --cobalt-wash: rgba(255, 151, 61, 0.12);
  --green: #c3d68a;
  --green-bright: #d1e990;
  --red: #ff9585;
  --on-cobalt: #201122;
  --on-cobalt-dim: rgba(32, 17, 34, 0.86);
  --card-accent: #ef963f;
}

/* Christmas keeps the same structure with pine, cranberry, and warm gold.
   The Halloween block above stays intact so ACTIVE_SEASON can switch back. */
html[data-christmas="true"] {
  color-scheme: dark;
  --paper: #0d1f18;
  --paper-raised: #142a20;
  --paper-sunk: #091710;
  --ink: #f6efe2;
  --ink-soft: #d8d0bf;
  --muted: #b3aa99;
  --faint: #9a9182;
  --line: rgba(246, 239, 226, 0.16);
  --line-strong: rgba(246, 239, 226, 0.32);
  --cobalt: #f0c46a;
  --cobalt-deep: #d9a441;
  --cobalt-wash: rgba(240, 196, 106, 0.12);
  --green: #8fd6a8;
  --green-bright: #a6e6bb;
  --red: #ff9a94;
  --on-cobalt: #1a130a;
  --on-cobalt-dim: rgba(26, 19, 10, 0.86);
  --card-accent: #a8323f;
}

html[data-christmas="true"] body {
  background:
    radial-gradient(ellipse at 85% 0, rgba(240, 196, 106, 0.12), transparent 58%),
    radial-gradient(ellipse at 10% 100%, rgba(168, 50, 63, 0.16), transparent 60%),
    var(--paper);
}

html[data-christmas="true"] .site-header {
  background: rgba(13, 31, 24, 0.96);
}

html[data-christmas="true"] .brand-ratio,
html[data-christmas="true"] .zone-chip,
html[data-christmas="true"] .outside-card {
  border-color: var(--line-strong);
}

html[data-christmas="true"] .date-card {
  --on-cobalt: #fff7ea;
  --on-cobalt-dim: rgba(255, 247, 234, 0.88);
  background: var(--card-accent);
}

html[data-christmas="true"] .month-card {
  background: var(--paper-raised);
}

html[data-spooky="true"] body {
  background: radial-gradient(ellipse at 85% 0, rgba(108, 53, 126, 0.22), transparent 58%), var(--paper);
}

html[data-spooky="true"] .site-header {
  background: rgba(22, 15, 29, 0.96);
}

html[data-spooky="true"] .brand-ratio,
html[data-spooky="true"] .zone-chip,
html[data-spooky="true"] .outside-card {
  border-color: var(--line-strong);
}

html[data-spooky="true"] .date-card {
  --on-cobalt: #201122;
  --on-cobalt-dim: rgba(32, 17, 34, 0.86);
}

html[data-spooky="true"] .month-card {
  background: var(--paper-raised);
}

html[data-spooky="true"] .spooky-banner {
  display: flex;
  align-items: center;
  gap: clamp(16px, 3vw, 40px);
  padding: 8px 24px 24px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--line-strong);
  background: radial-gradient(ellipse at 15% 50%, rgba(239, 150, 63, 0.1), transparent 65%);
}

.spooky-mascot {
  width: clamp(120px, 18vw, 200px);
  height: auto;
  flex: none;
  image-rendering: pixelated;
}

.spooky-kicker,
.spooky-hint,
.spooky-tagline {
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.6;
  letter-spacing: 0.1em;
}

.spooky-kicker {
  margin: 0 0 8px;
  color: var(--cobalt);
  text-transform: uppercase;
}

.spooky-banner h2 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: clamp(28px, 4.4vw, 54px);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.spooky-banner h2 span {
  color: var(--cobalt);
}

.spooky-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.02em;
}

html[data-spooky="true"] .landing-main {
  min-height: 0;
  align-items: flex-start;
  padding-block: 24px 48px;
}

html[data-spooky="true"] .clock-stage {
  position: relative;
}

/* A quiet cobweb stays outside the dial and never intercepts interaction. */
html[data-spooky="true"] .clock-stage::after {
  content: '';
  position: absolute;
  top: -8px;
  right: 0;
  width: 72px;
  height: 72px;
  pointer-events: none;
  opacity: 0.75;
  background: url('/static/art/halloween-cobweb.png') center / contain no-repeat;
  image-rendering: pixelated;
}

html[data-spooky="true"] svg.clock {
  filter: drop-shadow(0 0 18px rgba(255, 151, 61, 0.08));
}

html[data-spooky="true"] .pin-dot {
  fill: var(--cobalt);
}

html[data-spooky="true"] .hero {
  position: relative;
}

html[data-spooky="true"] .spooky-tower {
  display: block;
  float: right;
  width: clamp(180px, 28vw, 330px);
  height: auto;
  margin: -24px 0 0 24px;
  image-rendering: pixelated;
  background: radial-gradient(ellipse, rgba(151, 81, 159, 0.2), transparent 70%);
}

html[data-spooky="true"] .spooky-tagline {
  display: block;
  color: var(--cobalt);
  margin: 18px 0;
}

html[data-christmas="true"] .christmas-banner {
  display: flex;
  align-items: center;
  gap: clamp(16px, 3vw, 40px);
  padding: 8px 24px 24px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--line-strong);
  background: radial-gradient(ellipse at 15% 50%, rgba(240, 196, 106, 0.1), transparent 65%);
}

.christmas-mascot {
  width: clamp(120px, 18vw, 200px);
  height: auto;
  flex: none;
  image-rendering: pixelated;
}

.christmas-kicker,
.christmas-hint,
.christmas-tagline {
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.6;
  letter-spacing: 0.1em;
}

.christmas-kicker {
  margin: 0 0 8px;
  color: var(--cobalt);
  text-transform: uppercase;
}

.christmas-banner h2 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: clamp(28px, 4.4vw, 54px);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.christmas-banner h2 span {
  color: var(--cobalt);
}

.christmas-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.02em;
}

html[data-christmas="true"] .landing-main {
  min-height: 0;
  align-items: flex-start;
  padding-block: 24px 48px;
}

html[data-christmas="true"] .clock-stage {
  position: relative;
}

html[data-christmas="true"] .clock-stage::after {
  content: '';
  position: absolute;
  top: -8px;
  right: 0;
  width: 72px;
  height: 72px;
  pointer-events: none;
  opacity: 0.75;
  background: url('/static/art/christmas-snowflake.png') center / contain no-repeat;
  image-rendering: pixelated;
}

html[data-christmas="true"] svg.clock {
  filter: drop-shadow(0 0 18px rgba(240, 196, 106, 0.1));
}

html[data-christmas="true"] .pin-dot {
  fill: var(--cobalt);
}

html[data-christmas="true"] .hero {
  position: relative;
}

html[data-christmas="true"] .christmas-tower {
  display: block;
  float: right;
  width: clamp(180px, 28vw, 330px);
  height: auto;
  margin: -24px 0 0 24px;
  image-rendering: pixelated;
  background: radial-gradient(ellipse, rgba(240, 196, 106, 0.18), transparent 70%);
}

html[data-christmas="true"] .christmas-tagline {
  display: block;
  color: var(--cobalt);
  margin: 18px 0;
}

/* Snowfall: a fixed, non-interactive overlay shown only in Christmas mode.
   The tiled gradients drift at two speeds; each animation distance is a
   multiple of every tile size, so the loop is seamless. */
.snow {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.55;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.9) 0 1px, transparent 1.6px),
    radial-gradient(circle at 70% 60%, rgba(255, 255, 255, 0.75) 0 1.4px, transparent 2px),
    radial-gradient(circle at 40% 80%, rgba(255, 255, 255, 0.6) 0 1.8px, transparent 2.4px);
  background-size: 120px 120px, 200px 200px, 300px 300px;
  animation: snow-fall 24s linear infinite;
}

.snow::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.7;
  background-image:
    radial-gradient(circle at 65% 25%, rgba(255, 255, 255, 0.8) 0 1px, transparent 1.5px),
    radial-gradient(circle at 30% 70%, rgba(255, 255, 255, 0.65) 0 1.2px, transparent 1.8px),
    radial-gradient(circle at 80% 50%, rgba(255, 255, 255, 0.5) 0 1.6px, transparent 2.2px);
  background-size: 80px 80px, 160px 160px, 240px 240px;
  animation: snow-fall-alt 32s linear infinite;
}

html[data-christmas="true"] .snow {
  display: block;
}

@keyframes snow-fall {
  from {
    background-position: 0 0, 0 0, 0 0;
  }
  to {
    background-position: 0 600px, 0 600px, 0 600px;
  }
}

@keyframes snow-fall-alt {
  from {
    background-position: 0 0, 0 0, 0 0;
  }
  to {
    background-position: 0 480px, 0 480px, 0 480px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .snow,
  .snow::before {
    animation: none;
  }
}

@media (max-width: 600px) {
  .header-inner {
    column-gap: 8px;
  }

  .header-actions {
    gap: 4px;
  }

  html[data-spooky="true"] .spooky-banner {
    padding: 8px 0 20px;
    gap: 12px;
    margin-bottom: 24px;
  }

  .spooky-mascot {
    width: 110px;
  }

  .spooky-kicker {
    font-size: 8px;
  }

  .spooky-banner h2 {
    font-size: 30px;
  }

  .spooky-banner > div > p:not([class]) {
    font-size: 12px;
  }

  html[data-spooky="true"] .spooky-tower {
    float: none;
    width: 180px;
    margin: 0 auto 20px;
  }

  html[data-christmas="true"] .christmas-banner {
    padding: 8px 0 20px;
    gap: 12px;
    margin-bottom: 24px;
  }

  .christmas-mascot {
    width: 110px;
  }

  .christmas-kicker {
    font-size: 8px;
  }

  .christmas-banner h2 {
    font-size: 30px;
  }

  .christmas-banner > div > p:not([class]) {
    font-size: 12px;
  }

  html[data-christmas="true"] .christmas-tower {
    float: none;
    width: 180px;
    margin: 0 auto 20px;
  }
}

@media (max-width: 360px) {
  .header-inner {
    padding-block: 8px;
    row-gap: 6px;
  }
}
