/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --bg:          #11111b;
  --surface:     #1e1e2e;
  --surface2:    #313244;
  --overlay:     #45475a;
  --text:        #cdd6f4;
  --subtext:     #a6adc8;
  --muted:       #585b70;
  --accent:      #cba6f7;   /* mauve */
  --accent2:     #89dceb;   /* sky */
  --past:        #b4befe;   /* lavender */
  --current:     #a6e3a1;   /* green */
  --future-bg:   #313244;
  --week-size:   10px;
  --week-gap:    2px;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-mono:    'DM Mono', monospace;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Utilities ──────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.page   { min-height: 100vh; }

/* ── Login ──────────────────────────────────────────────────────────────── */
#page-login {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

.login-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4rem;
  gap: 2.5rem;
  z-index: 1;
  background: var(--bg);
}

.login-brand {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.brand-glyph {
  font-size: 2rem;
  color: var(--accent);
  line-height: 1;
}

.brand-glyph.small { font-size: 1.2rem; }

.login-brand h1 {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
}

.brand-tagline {
  color: var(--subtext);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-philosophy blockquote {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--subtext);
  line-height: 1.7;
  border-left: 2px solid var(--accent);
  padding-left: 1.25rem;
}

.btn-google {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  text-decoration: none;
  width: fit-content;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
}

.btn-google:hover {
  background: var(--surface2);
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* login background — ghost grid of weeks */
.login-background {
  position: relative;
  overflow: hidden;
  background: var(--surface);
}

.bg-weeks-preview {
  position: absolute;
  inset: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 2rem;
  align-content: flex-start;
  opacity: 0.25;
}

.bg-week-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
  flex-shrink: 0;
}

/* ── Onboarding ─────────────────────────────────────────────────────────── */
#page-onboarding {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.onboarding-container {
  max-width: 520px;
  text-align: center;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  align-items: center;
}

.onboarding-container h2 {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 400;
  letter-spacing: -0.02em;
}

.onboarding-container p {
  color: var(--subtext);
  line-height: 1.7;
  font-size: 0.95rem;
}

.dob-input-group {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  flex-wrap: wrap;
  justify-content: center;
}

input[type="date"] {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 1rem;
  padding: 0.8rem 1rem;
  color-scheme: dark;
  flex: 1;
  min-width: 180px;
}

input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: var(--bg);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 400;
  padding: 0.8rem 1.5rem;
  transition: opacity 0.2s, transform 0.1s;
  white-space: nowrap;
}

.btn-primary:hover { opacity: 0.85; transform: translateY(-1px); }

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

/* ── App Header ─────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--surface2);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--text);
}

.header-stats {
  font-size: 0.8rem;
  color: var(--subtext);
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.stat-sep { color: var(--muted); }

.header-user {
  display: flex;
  align-items: center;
  gap: 1rem;
}

#user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--surface2);
  object-fit: cover;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--surface2);
  border-radius: 6px;
  color: var(--subtext);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
  transition: border-color 0.2s, color 0.2s;
}

.btn-ghost:hover { border-color: var(--overlay); color: var(--text); }

/* ── Calendar ───────────────────────────────────────────────────────────── */
.calendar-main {
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.calendar-legend {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  font-size: 0.75rem;
  color: var(--subtext);
  align-items: center;
}

.calendar-legend span { display: flex; align-items: center; gap: 0.4rem; }

.calendar-legend span::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.legend-past::before   { background: var(--past); }
.legend-current::before { background: var(--current); }
.legend-future::before  { background: var(--future-bg); border: 1px solid var(--overlay); }

.calendar-wrapper {
  display: flex;
  gap: 6px;
  width: fit-content;
  margin: 0 auto;
}

.year-labels {
  display: flex;
  flex-direction: column;
  gap: var(--week-gap);
  padding-top: 0;
}

.year-label {
  height: var(--week-size);
  width: 20px;
  font-size: 6px;
  color: var(--muted);
  text-align: right;
  line-height: var(--week-size);
  overflow: hidden;
  white-space: nowrap;
}

/* The grid: 52 columns (weeks) × 80 rows (years) */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(52, var(--week-size));
  grid-template-rows: repeat(80, var(--week-size));
  gap: var(--week-gap);
  width: fit-content;
}

.week-cell {
  width: var(--week-size);
  height: var(--week-size);
  border-radius: 2px;
  cursor: pointer;
  transition: transform 0.1s, filter 0.1s;
  position: relative;
}

.week-cell:hover {
  transform: scale(1.6);
  z-index: 10;
  filter: brightness(1.3);
}

.week-cell.has-note::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1.5px var(--bg);
  pointer-events: none;
}

.week-cell.past {
  background: var(--past);
}

.week-cell.current {
  background: var(--current);
  box-shadow: 0 0 0 1px var(--current), 0 0 8px var(--current);
  animation: pulse-current 2s ease-in-out infinite;
}

.week-cell.future {
  background: var(--future-bg);
  border: 1px solid var(--overlay);
}

@keyframes pulse-current {
  0%, 100% { box-shadow: 0 0 0 1px var(--current), 0 0 8px var(--current); }
  50%       { box-shadow: 0 0 0 1px var(--current), 0 0 16px var(--current); }
}

/* ── Tooltip ────────────────────────────────────────────────────────────── */
.week-tooltip {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-size: 0.78rem;
  color: var(--subtext);
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.week-tooltip .tooltip-note {
  color: var(--accent);
  font-weight: 400;
  margin-bottom: 4px;
}

.week-tooltip .tooltip-age {
  color: var(--text);
  font-weight: 400;
  margin-bottom: 2px;
}

/* ── Note panel ─────────────────────────────────────────────────────────────── */
.note-panel {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: 8px;
  padding: 0.6rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 220px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.note-input {
  background: var(--bg);
  border: 1px solid var(--surface2);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.4rem 0.6rem;
  width: 100%;
}

.note-input:focus {
  outline: none;
  border-color: var(--accent);
}

.note-actions {
  display: flex;
  gap: 0.4rem;
}

.note-actions .btn-primary {
  font-size: 0.75rem;
  padding: 0.3rem 0.7rem;
  flex: 1;
}

.note-actions .btn-ghost {
  font-size: 0.75rem;
  padding: 0.3rem 0.7rem;
  color: var(--muted);
  border-color: var(--surface2);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  #page-login { grid-template-columns: 1fr; }
  .login-background { display: none; }
  .login-container { padding: 2.5rem 1.5rem; }

  :root {
    --week-size: 7px;
    --week-gap: 1.5px;
  }

  .calendar-main { padding: 1rem; }
  .year-label { font-size: 5px; }
}

@media (max-width: 560px) {
  :root {
    --week-size: 5px;
    --week-gap: 1px;
  }

  .year-label { display: none; }
  .app-header { padding: 0.75rem 1rem; }
}

/* ── Loading state ──────────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  font-family: var(--font-mono);
  color: var(--subtext);
  font-size: 0.85rem;
  gap: 0.75rem;
}

.loading-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 1.2s ease-in-out infinite;
}

.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
  40%           { opacity: 1;   transform: scale(1.2); }
}
