:root {
  --radius: 14px;
}

/* Dark is the default theme. */
:root,
:root[data-theme="dark"] {
  --bg: #0b0d10;
  --surface: #14171c;
  --border: #232831;
  --text: #e6e8eb;
  --muted: #8b94a3;
}

/* Light theme: applied when manually selected... */
:root[data-theme="light"] {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #14171c;
  --muted: #5c6573;
}

/* ...or when the system prefers light and the user hasn't overridden it. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --border: #e2e5ea;
    --text: #14171c;
    --muted: #5c6573;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden; /* guard against accidental horizontal scroll */
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.page {
  width: 100%;
  max-width: 72rem;
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 3rem);
  padding-bottom: clamp(3rem, 8vw, 6rem);
  display: flex;
  flex-direction: column;
}

/* ---- Hero: fills the first screen, counter centered ---- */
.hero {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(2rem, 6vw, 4rem);
  text-align: center;
}

/* ---- Masthead ---- */
.masthead {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

/* ---- Avatar ---- */
.avatar {
  width: clamp(5.5rem, 16vw, 9rem);
  height: clamp(5.5rem, 16vw, 9rem);
  margin-bottom: clamp(0.75rem, 2vw, 1.5rem);
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.45);
}

.title {
  font-size: clamp(1.75rem, 6vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.subtitle {
  font-size: clamp(0.9rem, 2.5vw, 1.05rem);
  color: var(--muted);
}

.subtitle time {
  color: var(--text);
  font-weight: 500;
}

/* ---- Bio tagline ---- */
.bio {
  font-size: clamp(0.8rem, 2.4vw, 1.05rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  background: linear-gradient(90deg, var(--text), var(--muted));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---- Counter group (subtitle + counter, tightly paired) ---- */
.counter-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1rem, 3vw, 1.75rem);
}

/* ---- Counter grid ---- */
.counter {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: clamp(1.5rem, 7vw, 5rem);
}

/* Each unit = the number plus its label sitting below it. */
.unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-width: 4.5rem;
}

.tile {
  display: grid;
  place-items: center;
}

.value {
  font-size: clamp(2rem, 7vw, 3.75rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  font-feature-settings: "tnum" 1;
}

.label {
  font-size: clamp(0.65rem, 1.6vw, 0.8rem);
  font-weight: 500;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

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

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

/* ---- Theme toggle ---- */
.theme-toggle {
  position: fixed;
  top: clamp(0.75rem, 2vw, 1.25rem);
  right: clamp(0.75rem, 2vw, 1.25rem);
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.15s ease;
}

.theme-toggle:hover {
  border-color: var(--muted);
  transform: translateY(-1px);
}

.theme-toggle svg {
  width: 1.2rem;
  height: 1.2rem;
}

/* Show exactly one icon for the active theme — driven by CSS, not JS, so it's
   correct on first paint. Dark shows the sun (tap to go light); light the moon. */
.icon-moon {
  display: none;
}
.icon-sun {
  display: block;
}
:root[data-theme="light"] .icon-sun {
  display: none;
}
:root[data-theme="light"] .icon-moon {
  display: block;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .icon-sun {
    display: none;
  }
  :root:not([data-theme]) .icon-moon {
    display: block;
  }
}

/* ---- Timeline heading arrow ---- */
.timeline-arrow {
  display: inline-block;
  margin-left: 0.35rem;
  color: var(--muted);
  animation: nudge 2.4s ease-in-out infinite;
}

@keyframes nudge {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  50% {
    transform: translateY(4px);
    opacity: 1;
  }
}

/* ---- Timeline section wrapper ---- */
.timeline-section {
  display: flex;
  flex-direction: column;
  gap: clamp(2rem, 5vw, 3.5rem);
}

.timeline-heading {
  font-size: clamp(1.4rem, 4vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  text-wrap: balance;
}

/* Dark-theme overrides for squarechip/timeline (it hardcodes light colors). */
.timeline:not(.timeline--horizontal)::before {
  background-color: var(--border); /* center line */
}

.timeline__item::after {
  background-color: var(--bg); /* node dot fill */
  border-color: var(--muted);
}

.timeline__content {
  background-color: var(--surface);
  border-color: var(--border);
  border-radius: var(--radius);
  color: var(--text);
}

/* Caret: outer (::before) matches the bubble border, inner (::after) the fill.
   Left-aligned items point right; right-aligned + mobile items point left. */
.timeline__content::before {
  border-left-color: var(--border);
}
.timeline__content::after {
  border-left-color: var(--surface);
}
.timeline__item--right .timeline__content::before,
.timeline--mobile .timeline__item .timeline__content::before {
  border-right-color: var(--border);
}
.timeline__item--right .timeline__content::after,
.timeline--mobile .timeline__item .timeline__content::after {
  border-right-color: var(--surface);
}

.event-date {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.event-text {
  margin: 0;
  font-size: clamp(0.9rem, 2vw, 1rem);
  line-height: 1.45;
}

.event-icon {
  margin-right: 0.25rem;
}

/* ---- Mobile fine-tuning ---- */
@media (max-width: 30rem) {
  /* A full-height centered hero leaves a big dead zone on tall phones; let it
     size to its content with comfortable padding instead. */
  .hero {
    min-height: auto;
    justify-content: flex-start;
    padding-block: clamp(3.5rem, 14vh, 7rem);
    gap: clamp(1.75rem, 6vw, 2.75rem);
  }

  /* Tidy, aligned 2×2 grid rather than an uneven flex wrap. */
  .counter {
    display: grid;
    grid-template-columns: 1fr 1fr;
    max-width: 19rem;
    margin-inline: auto;
    column-gap: 1.5rem;
    row-gap: 1.75rem;
  }
  .unit {
    min-width: 0;
  }

  .theme-toggle {
    width: 2.5rem;
    height: 2.5rem;
  }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .timeline-arrow {
    animation: none;
  }
  /* Don't fade/slide timeline entries in. */
  .timeline__item.animated {
    opacity: 1 !important;
    animation: none !important;
  }
  .theme-toggle,
  .avatar {
    transition: none;
  }
}
