/* ─── Custom properties ────────────────────────────────────────────── */
:root {
  --bg:        #eeeeed;
  --fg:        #1e1e1e;
  --muted:     #6e6e6e;
  --border:    #d8d8d6;
  --card-bg:   #e5e5e4;

  --font-body: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg:      #222222;
    --fg:      #e2e2e0;
    --muted:   #7a7a7a;
    --border:  #333333;
    --card-bg: #2a2a2a;
  }
}

[data-theme="dark"] {
  --bg:      #222222;
  --fg:      #e2e2e0;
  --muted:   #7a7a7a;
  --border:  #333333;
  --card-bg: #2a2a2a;
}

[data-theme="light"] {
  --bg:      #eeeeed;
  --fg:      #1e1e1e;
  --muted:   #6e6e6e;
  --border:  #d8d8d6;
  --card-bg: #e5e5e4;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.18s, color 0.18s;
}

/* ─── Page shell ───────────────────────────────────────────────────── */
.page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 0 32px;
}

/* ─── Top bar ──────────────────────────────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.site-name {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--fg);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* ─── Date picker area ─────────────────────────────────────────────── */
.date-picker-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.current-date {
  font-size: 0.8125rem;
  color: var(--muted);
  white-space: nowrap;
}

#datePicker {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  padding: 3px 0;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
  color-scheme: light dark;
}

#datePicker:focus,
#datePicker:hover {
  border-bottom-color: var(--fg);
}

/* ─── Theme toggle ─────────────────────────────────────────────────── */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s;
  line-height: 1;
}

.theme-toggle:hover {
  color: var(--fg);
}

.icon-sun  { display: none; }
.icon-moon { display: block; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) .icon-sun  { display: block; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .icon-moon { display: none;  }
}

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

/* ─── Fact stage ───────────────────────────────────────────────────── */
.fact-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fact-content {
  max-width: 680px;
  width: 100%;
  text-align: center;
  padding: 0 16px;
}

.fact-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 28px;
}

.fact-text {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--fg);
  margin-bottom: 24px;
  transition: opacity 0.2s;
}

.fact-detail {
  font-size: 0.9375rem;
  color: var(--muted);
  line-height: 1.7;
  max-width: 540px;
  margin: 0 auto;
  transition: opacity 0.2s;
}

.fact-content.fading .fact-text,
.fact-content.fading .fact-detail {
  opacity: 0;
}

/* ─── Bottom bar ───────────────────────────────────────────────────── */
.bottom-bar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.attribution {
  font-size: 0.75rem;
  color: var(--muted);
}

.attr-link {
  color: inherit;
  text-decoration: none;
}

.attr-link:hover {
  color: var(--fg);
}

/* ─── Mobile ───────────────────────────────────────────────────────── */
@media (max-width: 520px) {
  .page {
    padding: 0 20px;
  }

  .current-date {
    display: none;
  }

  .fact-text {
    font-size: clamp(1.3rem, 6vw, 1.8rem);
  }
}
