/* ==========================================================================
   Scandinavian Railway Poster Aesthetic
   ========================================================================== */

:root {
  /* Color palette - inspired by mid-century Scandinavian railway posters */
  --navy: #1a2744;
  --rust: #d35400;
  --cream: #f5f2eb;
  --sky: #5dade2;
  --text: #2c3e50;

  /* Spacing */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 2rem;
  --spacing-lg: 4rem;
  --spacing-xl: 6rem;

  /* Typography */
  --font-base: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --line-height-tight: 1.2;
  --line-height-normal: 1.6;

  /* Layout */
  --max-width: 800px;
  --sidebar-width: 120px;
}

/* Dark mode colors */
[data-theme="dark"] {
  --navy: #f5f2eb;
  --cream: #1a2744;
  --text: #e8e6e3;
  --rust: #ff6b35;
  --sky: #7ec8e3;
}

/* ==========================================================================
   Base Styles
   ========================================================================== */

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

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  font-family: var(--font-base);
  line-height: var(--line-height-normal);
  color: var(--text);
  background-color: var(--cream);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: var(--line-height-tight);
  color: var(--navy);
  transition: color 0.3s ease;
}

h1 {
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  margin-bottom: var(--spacing-sm);
}

h2 {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  margin-bottom: var(--spacing-md);
  position: relative;
  display: inline-block;
}

h2::after {
  content: '';
  position: absolute;
  bottom: -0.5rem;
  left: 0;
  width: 60px;
  height: 4px;
  background-color: var(--rust);
  border-radius: 2px;
}

p {
  margin-bottom: var(--spacing-sm);
}

a {
  color: var(--rust);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
  position: relative;
}

a:hover {
  color: var(--sky);
}

a:focus-visible {
  outline: 2px solid var(--rust);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ==========================================================================
   Layout
   ========================================================================== */

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--spacing-md);
  padding-left: calc(var(--sidebar-width) + var(--spacing-md));
}

@media (max-width: 768px) {
  main {
    padding-left: var(--spacing-md);
  }
}

.section {
  margin-bottom: var(--spacing-xl);
  scroll-margin-top: var(--spacing-md);
}

/* ==========================================================================
   Hero Section
   ========================================================================== */

.hero {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-bottom: var(--spacing-xl);
}

.name {
  color: var(--navy);
  margin-bottom: var(--spacing-xs);
}

.tagline {
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  color: var(--rust);
  font-weight: 500;
  margin-bottom: var(--spacing-md);
}

.intro {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  max-width: 650px;
  line-height: 1.7;
}

.intro p {
  margin-bottom: var(--spacing-md);
}

/* ==========================================================================
   Lists
   ========================================================================== */

ul {
  list-style: none;
}

.highlights-list li,
.org-list li,
.writing-list li,
.currently-list li,
.experiments-list li {
  margin-bottom: var(--spacing-md);
  padding-left: var(--spacing-md);
  position: relative;
}

.highlights-list li::before,
.org-list li::before,
.writing-list li::before,
.currently-list li::before,
.experiments-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 8px;
  height: 8px;
  background-color: var(--rust);
  border-radius: 50%;
}

.year {
  color: var(--sky);
  font-size: 0.9em;
  font-weight: 500;
}

.currently-intro,
.experiments-note {
  font-style: italic;
  margin-bottom: var(--spacing-sm);
  color: var(--text);
}

/* ==========================================================================
   Contact Section
   ========================================================================== */

.contact-link {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-size: 1.1rem;
  padding: var(--spacing-sm) var(--spacing-md);
  background-color: var(--navy);
  color: var(--cream) !important;
  border-radius: 4px;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.contact-link:hover {
  background-color: var(--rust);
  transform: translateY(-2px);
}

.contact-link:focus-visible {
  outline: 2px solid var(--rust);
  outline-offset: 4px;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  text-align: center;
  padding: var(--spacing-lg) var(--spacing-md);
  color: var(--text);
  font-size: 0.9rem;
}

.last-signal {
  font-style: italic;
}

/* ==========================================================================
   Theme Toggle (Railway Signal)
   ========================================================================== */

.theme-toggle {
  position: fixed;
  top: var(--spacing-md);
  right: var(--spacing-md);
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 1000;
  padding: var(--spacing-xs);
  transition: transform 0.2s ease;
}

.theme-toggle:hover {
  transform: scale(1.1);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--rust);
  outline-offset: 4px;
  border-radius: 4px;
}

.signal {
  width: 40px;
  height: 80px;
  color: var(--navy);
}

.signal-post {
  transition: fill 0.3s ease;
}

.signal-light {
  transition: fill 0.3s ease, opacity 0.3s ease;
  stroke: var(--navy);
  stroke-width: 2;
}

.signal-light-top {
  fill: var(--cream);
  opacity: 0.3;
}

.signal-light-bottom {
  fill: var(--rust);
  opacity: 1;
}

[data-theme="dark"] .signal-light-top {
  fill: var(--sky);
  opacity: 1;
}

[data-theme="dark"] .signal-light-bottom {
  fill: var(--cream);
  opacity: 0.3;
}

/* ==========================================================================
   Train Track Animation
   ========================================================================== */

.train-track {
  position: fixed;
  left: var(--spacing-md);
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  pointer-events: none;
  z-index: 100;
}

@media (max-width: 768px) {
  .train-track {
    display: none;
  }
}

.track-line {
  position: absolute;
  left: 50%;
  top: 10%;
  width: 3px;
  height: 80%;
  background: repeating-linear-gradient(
    to bottom,
    var(--navy) 0px,
    var(--navy) 10px,
    transparent 10px,
    transparent 20px
  );
  transform: translateX(-50%);
  opacity: 0.3;
}

.train-container {
  position: absolute;
  left: 50%;
  width: 80px;
  height: 80px;
  transform: translateX(-50%);
  pointer-events: all;
  cursor: pointer;
  transition: transform 0.1s ease-out;
}

.train {
  transform-origin: center;
}

.train:hover {
  animation: trainBounce 0.5s ease-in-out;
}

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

.stations {
  position: absolute;
  right: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

.station {
  position: absolute;
  right: 0;
  font-size: 0.75rem;
  color: var(--navy);
  font-weight: 500;
  padding: var(--spacing-xs);
  background-color: var(--cream);
  border-left: 3px solid var(--rust);
  white-space: nowrap;
  transform: translateY(-50%);
  opacity: 0.7;
  transition: opacity 0.3s ease, color 0.3s ease, background-color 0.3s ease;
}

.station::before {
  content: attr(data-year);
  display: block;
  font-size: 0.65rem;
  color: var(--rust);
  margin-bottom: 2px;
}

.station.active {
  opacity: 1;
  background-color: var(--rust);
  color: var(--cream);
  border-left-color: var(--navy);
}

.station.active::before {
  color: var(--cream);
}

/* ==========================================================================
   Geometric Decorative Elements
   ========================================================================== */

.hero::before {
  content: '';
  position: absolute;
  left: -100px;
  top: 20%;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background-color: var(--sky);
  opacity: 0.1;
  z-index: -1;
}

.section:nth-child(even) {
  position: relative;
}

.section:nth-child(even)::after {
  content: '';
  position: absolute;
  right: -50px;
  top: 50%;
  width: 100px;
  height: 100px;
  background-color: var(--rust);
  opacity: 0.05;
  transform: translateY(-50%) rotate(45deg);
  z-index: -1;
}

@media (max-width: 768px) {
  .hero::before,
  .section:nth-child(even)::after {
    display: none;
  }
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
  :root {
    --spacing-lg: 3rem;
    --spacing-xl: 4rem;
  }

  .theme-toggle {
    top: var(--spacing-sm);
    right: var(--spacing-sm);
  }

  .signal {
    width: 30px;
    height: 60px;
  }
}

@media (max-width: 480px) {
  :root {
    --spacing-md: 1.5rem;
  }

  h2::after {
    width: 40px;
    height: 3px;
  }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
  .theme-toggle,
  .train-track {
    display: none;
  }

  body {
    background-color: white;
    color: black;
  }

  a {
    color: black;
    text-decoration: underline;
  }

  .section {
    page-break-inside: avoid;
  }
}

/* ==========================================================================
   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;
}

/* Focus styles for keyboard navigation */
*:focus-visible {
  outline: 2px solid var(--rust);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --navy: #000000;
    --rust: #cc4400;
    --text: #000000;
  }

  a {
    text-decoration: underline;
  }
}
