/* ─────────────────────────────────────────
   DESIGN TOKENS
───────────────────────────────────────── */
:root {
  /* Brand */
  --green-900: #052e1c;
  --green-800: #083d26;
  --green-700: #0B5E38;
  --green-600: #0B8457;
  --green-500: #0ea86f;
  --green-200: #a3d9bc;
  --green-100: #d6f0e2;
  --green-50:  #eef8f2;

  /* Accent */
  --gold:      #C9993A;
  --gold-light:#F0C96C;

  /* Neutrals */
  --ink:       #0d1f17;
  --ink-soft:  #3a5248;
  --muted:     #6b8a7a;
  --border:    #d0e8da;
  --surface:   #ffffff;
  --bg:        #f2f8f5;

  /* Typography */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;

  /* Elevation */
  --shadow-card: 0 2px 8px rgba(5,46,28,0.07), 0 12px 40px rgba(5,46,28,0.10);
  --shadow-inset: inset 0 1px 3px rgba(5,46,28,0.08);

  /* Shape */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-xl: 32px;
}

[data-theme="dark"] {
  --ink:       #e8f5ee;
  --ink-soft:  #a8cdb8;
  --muted:     #6b9980;
  --border:    #1d3d2c;
  --surface:   #0f2318;
  --bg:        #091a10;
  --green-50:  #0d2319;
  --green-100: #122b1e;
  --shadow-card: 0 2px 8px rgba(0,0,0,0.3), 0 16px 48px rgba(0,0,0,0.5);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px 16px 0;
  transition: background 0.35s ease, color 0.35s ease;
  /* Subtle dot-grid background */
  background-image: radial-gradient(circle, var(--green-200) 1px, transparent 1px);
  background-size: 28px 28px;
  background-attachment: fixed;
}

[data-theme="dark"] body {
  background-image: radial-gradient(circle, var(--border) 1px, transparent 1px);
}

/* ─────────────────────────────────────────
   SPLASH SCREEN
───────────────────────────────────────── */
#splash {
  position: fixed;
  inset: 0;
  background: var(--green-900);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.55s ease;
}

#splash.hidden {
  opacity: 0;
  pointer-events: none;
}

.splash-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: splashFloat 2s ease-in-out infinite;
}

.splash-wordmark {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--green-200);
  letter-spacing: -0.03em;
}

.splash-wordmark span {
  color: var(--gold-light);
}

.splash-tagline {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--green-500);
}

.splash-bar {
  width: 160px;
  height: 2px;
  background: var(--green-800);
  border-radius: 2px;
  overflow: hidden;
}

.splash-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green-500), var(--gold-light));
  border-radius: 2px;
  animation: loadBar 2s ease-in-out forwards;
}

@keyframes loadBar {
  from { width: 0%; }
  to   { width: 100%; }
}

@keyframes splashFloat {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

/* ─────────────────────────────────────────
   GLOBAL ANIMATIONS
───────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.65; }
}

/* ─────────────────────────────────────────
   THEME TOGGLE
───────────────────────────────────────── */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-card);
  z-index: 200;
}

.theme-toggle:hover  { transform: scale(1.08); }
.theme-toggle:active { transform: scale(0.94); }

/* ─────────────────────────────────────────
   APP WRAPPER
───────────────────────────────────────── */
#app {
  display: none;
  width: 100%;
  max-width: 540px;
}

#app.visible {
  display: block;
  animation: fadeUp 0.6s ease both;
}

/* ─────────────────────────────────────────
   HEADER / WORDMARK
───────────────────────────────────────── */
.app-header {
  text-align: center;
  margin-bottom: 32px;
}

.wordmark {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  color: var(--green-600);
  letter-spacing: -0.04em;
  line-height: 1;
}

[data-theme="dark"] .wordmark { color: var(--green-200); }

.wordmark .dot { color: var(--gold); }

.app-tagline {
  margin-top: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ─────────────────────────────────────────
   MAIN CARD
───────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 40px 36px;
  box-shadow: var(--shadow-card);
  transition: background 0.35s ease, border-color 0.35s ease;
}

/* ─────────────────────────────────────────
   DATE INPUT
───────────────────────────────────────── */
.field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.date-input-wrap {
  position: relative;
}

.date-input-wrap::before {
  content: '📅';
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  pointer-events: none;
  z-index: 1;
}

input[type="date"] {
  width: 100%;
  padding: 15px 18px 15px 46px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  background: var(--green-50);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-inset);
}

input[type="date"]:hover {
  border-color: var(--green-500);
  background: var(--surface);
}

input[type="date"]:focus {
  border-color: var(--green-600);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(11,132,87,0.12), var(--shadow-inset);
}

[data-theme="dark"] input[type="date"] {
  background: var(--green-100);
  color: var(--ink);
  border-color: var(--border);
}

[data-theme="dark"] input[type="date"]:hover,
[data-theme="dark"] input[type="date"]:focus {
  background: var(--green-50);
  border-color: var(--green-500);
}

/* ─────────────────────────────────────────
   DIVIDER
───────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 28px 0;
  border: none;
}

/* ─────────────────────────────────────────
   EMPTY STATE
───────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 16px;
}

.empty-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 16px;
  opacity: 0.45;
}

.empty-state h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.6;
}

/* ─────────────────────────────────────────
   RESULTS
───────────────────────────────────────── */
.results {
  display: none;
}

.results.visible {
  display: block;
  animation: fadeUp 0.5s ease both;
}

/* Section label above each result block */
.result-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

/* ── Age Block ── */
.age-block {
  background: var(--green-50);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
  margin-bottom: 16px;
  transition: background 0.35s ease;
}

[data-theme="dark"] .age-block {
  background: var(--green-100);
  border-color: var(--border);
}

.age-block .result-label { color: var(--green-600); }
[data-theme="dark"] .age-block .result-label { color: var(--green-200); }

/* Big year number */
.age-years {
  font-family: var(--font-display);
  font-size: 5rem;
  font-weight: 700;
  color: var(--green-600);
  line-height: 1;
  letter-spacing: -0.04em;
  margin-bottom: 4px;
}

[data-theme="dark"] .age-years { color: var(--green-200); }

.age-years-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 20px;
}

/* Stat pills row */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 8px;
  text-align: center;
  transition: background 0.35s ease;
}

[data-theme="dark"] .stat-pill {
  background: var(--green-50);
}

.stat-number {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
  display: block;
}

.stat-unit {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-top: 4px;
}

/* ── Birthday Countdown Block ── */
.bday-block {
  background: linear-gradient(145deg, var(--green-900) 0%, var(--green-700) 100%);
  border-radius: var(--r-lg);
  padding: 28px;
  position: relative;
  overflow: hidden;
}

.bday-block::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: rgba(201,153,58,0.12);
}

.bday-block::after {
  content: '';
  position: absolute;
  bottom: -30px; left: -20px;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: rgba(14,168,111,0.15);
}

.bday-block .result-label {
  color: var(--green-200);
  position: relative;
  z-index: 1;
}

.bday-stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  position: relative;
  z-index: 1;
}

.bday-pill {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--r-sm);
  padding: 14px 6px;
  text-align: center;
  backdrop-filter: blur(4px);
}

.bday-number {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--gold-light);
  line-height: 1;
  display: block;
}

.bday-unit {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--green-200);
  display: block;
  margin-top: 5px;
}

/* Birthday celebration state */
.bday-celebrate {
  text-align: center;
  padding: 8px 0;
  position: relative;
  z-index: 1;
}

.bday-celebrate .celebrate-emoji {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 10px;
}

.bday-celebrate h3 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gold-light);
  margin-bottom: 6px;
}

.bday-celebrate p {
  font-size: 0.9rem;
  color: var(--green-200);
  line-height: 1.5;
}

/* ─────────────────────────────────────────
   VALIDATION MESSAGE (replaces alert())
───────────────────────────────────────── */
.validation-msg {
  display: none;
  align-items: center;
  gap: 8px;
  background: #fff5f5;
  border: 1px solid #fca5a5;
  border-radius: var(--r-sm);
  padding: 10px 14px;
  margin-top: 10px;
  font-size: 0.875rem;
  color: #b91c1c;
  font-weight: 500;
}

[data-theme="dark"] .validation-msg {
  background: #2d1212;
  border-color: #7f1d1d;
  color: #fca5a5;
}

.validation-msg.visible { display: flex; }

/* ─────────────────────────────────────────
   FOOTER
───────────────────────────────────────── */
footer {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin-top: 20px;
  padding-bottom: 16px;
}

footer a {
  color: var(--green-600);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

footer a:hover { border-bottom-color: var(--green-600); }

[data-theme="dark"] footer a { color: var(--green-200); }

/* ─────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────── */
@media (max-width: 540px) {
  .card { padding: 28px 20px; }
  .wordmark { font-size: 2.4rem; }
  .age-years { font-size: 4rem; }
  .bday-number { font-size: 1.5rem; }
  .stat-number { font-size: 1.3rem; }
}

@media (max-width: 360px) {
  .bday-stat-row { grid-template-columns: repeat(2, 1fr); }
}

/* ─────────────────────────────────────────
   ACCESSIBILITY
───────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border-width: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
