/* Reset & Base */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0E1117;
  --fg: #ffffff;
  --header: #1a1d24;
  --border: #2d3139;
  --accent: #8bd5ff;
  --accent-hover: #a8e0ff;
  --shadow: rgba(0, 0, 0, 0.3);
  --ascii-water: #151d29;
  --ascii-land: #45d4ff;
  --ascii-land-alt: #7a6dff;
  --ascii-land-glow: #4ff2d5;
  --ascii-cell: 8px;
  --ascii-edge-tint: rgba(10, 14, 24, 0.82);
  --ascii-letter-spacing: 0px;
  --ascii-offset-x: 0px;
  --ascii-offset-y: 0px;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Arial, sans-serif;
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
  position: relative;
  min-height: 100%;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(160% 120% at 50% 40%, rgba(8, 14, 24, 0.08) 0%, rgba(8, 14, 24, 0.04) 50%, rgba(8, 14, 24, 0.015) 78%, transparent 94%);
  backdrop-filter: blur(0.8px);
  -webkit-backdrop-filter: blur(0.8px);
  opacity: 0;
  transition: opacity 1.6s ease;
  z-index: 1;
}

body.light-mode::before {
  background:
    radial-gradient(160% 120% at 50% 38%, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.06) 54%, rgba(255, 255, 255, 0.025) 76%, transparent 94%);
}

body.story-blur-active::before {
  opacity: 1;
}

/* Light mode */
body.light-mode {
  --bg: #ffffff;
  --fg: #1d1d1f;
  --header: #f5f5f7;
  --border: #d2d2d7;
  --accent: #0066cc;
  --accent-hover: #0077ed;
  --shadow: rgba(0, 0, 0, 0.1);
  --ascii-water: #d7deef;
  --ascii-land: #2692ff;
  --ascii-land-alt: #6e5cff;
  --ascii-land-glow: #4ad7ff;
  --ascii-cell: 8px;
  --ascii-edge-tint: rgba(255, 255, 255, 0.72);
}

/* Dark mode explicit */
body.dark-mode {
  --bg: #0E1117;
  --fg: #ffffff;
  --header: #1a1d24;
  --border: #2d3139;
  --accent: #8bd5ff;
  --accent-hover: #a8e0ff;
  --shadow: rgba(0, 0, 0, 0.3);
  --ascii-water: #151d29;
  --ascii-land: #45d4ff;
  --ascii-land-alt: #7a6dff;
  --ascii-land-glow: #4ff2d5;
  --ascii-cell: 8px;
  --ascii-edge-tint: rgba(10, 14, 24, 0.82);
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--header);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.brand img {
  display: block;
  height: 44px;
  width: auto;
  border-radius: 8px;
  transition: transform 0.2s ease;
}

.brand:hover img {
  transform: scale(1.05);
}

.main-nav {
  display: flex;
  gap: 1.5rem;
  justify-content: flex-end;
}

.main-nav a {
  color: var(--fg);
  text-decoration: none;
  opacity: 0.9;
  transition: opacity 0.2s ease;
  font-size: 15px;
  font-weight: 400;
}

.main-nav a:hover {
  opacity: 1;
  text-decoration: underline;
}

/* Sections */
.section {
  padding: 7rem 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

#home.section {
  padding: 0;
  max-width: none;
  width: 100%;
  margin: 0;
  z-index: 0;
  height: 100vh;
}

#hero,
#about,
#contact {
  scroll-margin-top: 90px;
}

.section h2,
#hero h1 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: var(--fg);
}

.section p {
  font-size: 1.1rem;
  max-width: 800px;
  line-height: 1.7;
}

.section a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

.section a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* Map Container */
#map-holder {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  background: transparent;
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  --tile-pane-opacity: 0;
}

#map .leaflet-control-container {
  z-index: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

#map .leaflet-pane,
#map .leaflet-tile-pane,
#map .leaflet-overlay-pane,
#map .leaflet-shadow-pane {
  opacity: var(--tile-pane-opacity, 0);
  transition: opacity 0.3s ease;
}

#ascii-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: stretch;
  pointer-events: none;
  z-index: 650;
  isolation: isolate;
  transition: opacity 0.3s ease;
}

#ascii-layer.ascii-disabled {
  display: none;
}

#ascii-layer.ascii-fade-out {
  opacity: 0.25;
}

#ascii-layer.ascii-fade-in {
  opacity: 1;
}
#ascii-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to right, var(--ascii-edge-tint) 0%, rgba(0, 0, 0, 0) 18%, rgba(0, 0, 0, 0) 82%, var(--ascii-edge-tint) 100%),
    linear-gradient(to bottom, var(--ascii-edge-tint) 0%, rgba(0, 0, 0, 0) 24%, rgba(0, 0, 0, 0) 76%, var(--ascii-edge-tint) 100%);
  mix-blend-mode: multiply;
  opacity: 0.55;
}

#ascii-layer .ascii-surface {
  grid-area: 1 / 1;
  margin: 0;
  padding-top: var(--ascii-offset-y, 0px);
  padding-bottom: var(--ascii-offset-y, 0px);
  padding-left: var(--ascii-offset-x, 0px);
  padding-right: var(--ascii-offset-x, 0px);
  white-space: pre;
  font-family: "Courier New", "Monaco", "Consolas", monospace;
  font-size: var(--ascii-cell);
  line-height: var(--ascii-cell);
  letter-spacing: var(--ascii-letter-spacing, 0px);
  background-repeat: no-repeat;
  background-size: 300% 300%;
}

#ascii-layer .ascii-land {
  color: transparent;
  background-image: linear-gradient(
    120deg,
    var(--ascii-land) 0%,
    var(--ascii-land-alt) 35%,
    var(--ascii-land-glow) 55%,
    var(--ascii-land) 100%
  );
  animation: landShimmer 12s ease-in-out infinite;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 6px rgba(99, 215, 255, 0.35));
}

#ascii-layer .ascii-water {
  color: var(--ascii-water);
  background-image: none;
  opacity: 0.38;
}

body.light-mode #ascii-layer .ascii-water {
  opacity: 0.32;
}

body.light-mode #ascii-layer .ascii-land {
  filter: drop-shadow(0 0 4px rgba(0, 153, 255, 0.25));
}

@keyframes landShimmer {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

body.light-mode #ascii-layer::after {
  background:
    linear-gradient(to right, var(--ascii-edge-tint) 0%, rgba(255, 255, 255, 0) 18%, rgba(255, 255, 255, 0) 82%, var(--ascii-edge-tint) 100%),
    linear-gradient(to bottom, var(--ascii-edge-tint) 0%, rgba(255, 255, 255, 0) 24%, rgba(255, 255, 255, 0) 76%, var(--ascii-edge-tint) 100%);
  mix-blend-mode: screen;
  opacity: 0.38;
}

.map-scrim {
  display: none;
}

body.light-mode .map-scrim {
  background: rgba(255, 255, 255, 0.32);
  mix-blend-mode: multiply;
}

.map-scrim.hidden {
  opacity: 0;
  visibility: hidden;
}

.map-scrim.visible {
  opacity: 1;
  visibility: visible;
}

.reveal {
  opacity: 0;
  transform: translateY(24px);
}

.reveal.in {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

@media (prefers-reduced-motion: reduce) {
  .reveal,
  .reveal.in {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* Timeline */
#about {
  position: relative;
  --timeline-count: 5;
  --timeline-extra: 0;
  height: calc((var(--timeline-count, 5) + var(--timeline-extra, 0)) * 100vh);
  padding: 0;
  max-width: none;
  width: 100%;
  margin: 0;
  overflow: visible;
}

.timeline-sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  justify-content: flex-start;
  overflow: hidden;
  padding: 0 clamp(32px, 7vw, 100px) 0 clamp(48px, 8vw, 120px);
  z-index: 1;
  width: 100vw;
}

.timeline-track {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: 100%;
  transform: translateX(0);
  will-change: transform;
  padding: 0;
  opacity: 1;
  transition: transform 0.6s cubic-bezier(0.25, 0.85, 0.25, 1),
    opacity 0.4s ease;
  gap: clamp(36px, 6vw, 96px);
}

.timeline-section:not(.timeline-live) .timeline-track {
  opacity: 0;
}

.timeline-card {
  width: clamp(280px, 56vw, 640px);
  margin: 0;
  padding: 0 0 6rem;
  color: var(--fg);
  text-align: left;
  position: relative;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.45);
  z-index: 1;
  flex: 0 0 auto;
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 0.35s ease, transform 0.35s ease;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  pointer-events: none;
  isolation: isolate;
}

.timeline-card:last-of-type {
  margin-bottom: 0;
}

body.light-mode .timeline-card {
  color: #0b1c33;
  text-shadow: none;
}

.timeline-card.active {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}


.timeline-card-inner {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: flex-start;
  column-gap: clamp(18px, 3vw, 42px);
  row-gap: 0.85rem;
  width: 100%;
  max-width: 640px;
}

.timeline-glyph {
  font-family: "Courier New", "Consolas", monospace;
  font-size: clamp(2.4rem, 5vw, 3.2rem);
  color: var(--accent);
  text-shadow: 0 0 16px rgba(69, 242, 255, 0.35);
  line-height: 1;
  min-width: 1.8ch;
  text-align: center;
  user-select: none;
  margin-top: 0;
  align-self: flex-start;
  justify-self: start;
}

body.light-mode .timeline-glyph {
  color: #0d63d4;
  text-shadow: 0 0 16px rgba(13, 99, 212, 0.25);
}

.timeline-body {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
}

.about-year {
  display: block;
  font-size: 0.9rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin-bottom: 0.85rem;
  opacity: 0.68;
  text-align: left;
  align-self: flex-start;
}

.timeline-card h3 {
  font-size: 2.2rem;
  margin-bottom: 0.65rem;
  text-align: left;
}

.timeline-card p {
  font-size: 1.18rem;
  line-height: 1.75;
  margin: 0;
  text-align: left;
  max-width: clamp(28ch, 45vw, 42ch);
}

#hero {
  position: sticky;
  top: 0;
  text-align: center;
  min-height: 105vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1.5rem;
  transform: translateY(0);
  opacity: 1;
  transition: transform 0.9s cubic-bezier(0.22, 0.84, 0.16, 1),
    opacity 0.9s cubic-bezier(0.22, 0.84, 0.16, 1);
  isolation: isolate;
  z-index: 2;
}

#hero.hero-prep {
  transform: translateY(60px);
  opacity: 0;
}

#hero.hero-prep.hero-visible {
  transform: translateY(0);
  opacity: 1;
}

#hero h1 {
  font-size: clamp(2.8rem, 6vw, 4.5rem);
  margin: 0;
}

#hero #hero-who {
  transition: opacity 0.2s ease;
}
#contact {
  text-align: center;
  isolation: isolate;
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
}

.contact-message {
  font-size: 1.1rem;
  max-width: 640px;
}

.hint {
  opacity: 0.6;
  margin: 1rem auto;
  font-size: 0.95rem;
  text-align: center;
  max-width: 1200px;
  padding: 0 1.5rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: rgba(26, 29, 36, 0.78);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 16px 24px;
  margin-top: 4rem;
  position: relative;
  z-index: 3;
}

body.light-mode .site-footer {
  background: rgba(245, 245, 247, 0.82);
  border-top-color: rgba(0, 0, 0, 0.08);
}

.footer-inner {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 20px;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
}

.footer-home {
  color: var(--fg);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  transition: opacity 0.2s ease;
}

.footer-home:hover {
  opacity: 0.7;
}

.footer-nav {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
}

.footer-nav a {
  color: var(--fg);
  text-decoration: none;
  opacity: 0.8;
  font-size: 14px;
  transition: opacity 0.2s ease;
}

.footer-nav a:hover {
  opacity: 1;
}

.footer-nav .divider {
  opacity: 0.3;
}

.footer-right {
  display: flex;
  gap: 16px;
  align-items: center;
}

.copyright {
  font-size: 13px;
  opacity: 0.6;
  margin-top: 4px;
}

/* Segmented Control */
.segmented-control {
  --radius: 999px;
  display: inline-flex;
  align-items: stretch;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  position: relative;
}

body.light-mode .segmented-control {
  background: rgba(0, 0, 0, 0.06);
}

.segmented-control input[type="radio"] {
  display: none;
}

.segmented-control label {
  position: relative;
  z-index: 1;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--fg);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: color 0.25s ease;
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.segmented-control input[type="radio"]:checked + label {
  color: var(--fg);
  font-weight: 500;
}

.segmented-control .seg-indicator {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / 3);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.15);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

body.light-mode .segmented-control .seg-indicator {
  background: rgba(0, 0, 0, 0.1);
}

#theme-light:checked ~ .seg-indicator {
  transform: translateX(0%);
}

#theme-dark:checked ~ .seg-indicator {
  transform: translateX(100%);
}

#theme-auto:checked ~ .seg-indicator {
  transform: translateX(200%);
}

/* Language Dropdown */
.lang-select {
  position: relative;
}

.lang-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s ease;
}

.lang-button:hover {
  background: rgba(255, 255, 255, 0.05);
}

body.light-mode .lang-button:hover {
  background: rgba(0, 0, 0, 0.05);
}

.lang-button:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chevron {
  font-size: 12px;
  transition: transform 0.2s ease;
}

.lang-button[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.lang-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  list-style: none;
  margin: 0;
  padding: 6px 0;
  min-width: 160px;
  background: var(--header);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  display: none;
  z-index: 10;
}

body.light-mode .lang-menu {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.lang-menu.show {
  display: block;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.lang-menu li {
  padding: 8px 14px;
  cursor: pointer;
  color: var(--fg);
  font-size: 14px;
  transition: background 0.15s ease;
}

.lang-menu li[aria-selected="true"] {
  font-weight: 500;
}

.lang-menu li[aria-selected="true"]::after {
  content: "✓";
  float: right;
  opacity: 0.7;
}

.lang-menu li:hover {
  background: rgba(255, 255, 255, 0.08);
}

body.light-mode .lang-menu li:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* Accessibility */
.visually-hidden {
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

/* Responsive */
@media (max-width: 768px) {
  .footer-inner {
    grid-template-columns: 1fr;
    gap: 12px;
    text-align: center;
  }

  .footer-nav {
    order: 2;
  }

  .footer-right {
    order: 3;
    justify-content: center;
    flex-wrap: wrap;
  }

  .main-nav {
    gap: 1rem;
  }

  .site-header {
    padding: 0.75rem 1rem;
  }

  .timeline-track {
    gap: clamp(20px, 6vw, 48px);
  }

  .timeline-card {
    width: clamp(240px, 78vw, 520px);
    margin-bottom: 7rem;
    padding: 0 0 5.5rem;
  }

  .timeline-card-inner {
    column-gap: clamp(16px, 4vw, 28px);
    row-gap: 0.75rem;
  }

  #about::before {
    opacity: 0;
  }

  #hero {
    padding-top: 8rem;
  }
}

@media (max-width: 480px) {
  .segmented-control label {
    padding: 5px 10px;
    font-size: 12px;
  }

  .section {
    padding: 2rem 1rem;
  }

  .section h2 {
    font-size: 1.5rem;
  }

  #home.section {
    padding-left: 0;
    padding-right: 0;
  }

  .timeline-track {
    gap: clamp(16px, 8vw, 32px);
  }

  .timeline-card {
    width: clamp(220px, 88vw, 480px);
    padding: 0 0 4.5rem;
    margin-bottom: 6rem;
  }

  .timeline-card-inner {
    column-gap: clamp(12px, 5vw, 24px);
    row-gap: 0.75rem;
  }

  #about::before {
    opacity: 0;
  }
}
#hero.hero-prep.hero-visible.hero-out,
#hero.hero-out {
  transform: translateY(-110vh);
  opacity: 0;
  pointer-events: none;
}
#scroll-hint {
  position: fixed;
  left: 50%;
  bottom: 6vh;
  transform: translateX(-50%) translateY(12px);
  opacity: 0;
  pointer-events: none;
  width: 40px;
  transition: opacity 0.35s ease, transform 0.35s ease;
  z-index: 700;
}

#scroll-hint.visible {
  opacity: 0.9;
  transform: translateX(-50%) translateY(0);
}
