/* IBM Plex Sans — self-hosted variable fonts (SIL OFL 1.1, IBM Corp.)
   Axes on both faces: wght 100-700, wdth 75-100.
   The italic file is only fetched if italic text is actually rendered. */
@font-face {
  font-family: 'IBM Plex Sans';
  src: url('/fonts/ibm-plex-sans-var.woff2') format('woff2-variations');
  font-weight: 100 700;
  font-stretch: 75% 100%;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Sans';
  src: url('/fonts/ibm-plex-sans-italic-var.woff2') format('woff2-variations');
  font-weight: 100 700;
  font-stretch: 75% 100%;
  font-style: italic;
  font-display: swap;
}

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Light mode colors (default) */
  --color-bg: #ffffff;
  --color-text: #1a1a1a;
  --color-text-light: #666666;
  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-border: #e5e7eb;
  --color-card-bg: #ffffff;

  /* Geometric background — subtle in light mode */
  --geo-glow-1: rgba(37, 99, 235, 0.06);
  --geo-glow-2: rgba(37, 99, 235, 0.03);
  --geo-triangles: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 800'><polygon points='0,0 650,0 0,550' fill='rgb(37,99,235)' fill-opacity='0.02' stroke='rgb(37,99,235)' stroke-opacity='0.06' stroke-width='1'/><polygon points='1200,800 550,800 1200,200' fill='rgb(37,99,235)' fill-opacity='0.03' stroke='rgb(37,99,235)' stroke-opacity='0.07' stroke-width='1'/><polygon points='0,600 300,800 0,800' fill='rgb(37,99,235)' fill-opacity='0.03' stroke='rgb(37,99,235)' stroke-opacity='0.08' stroke-width='1'/></svg>");

  /* Glass effect */
  --glass-bg: rgba(87, 151, 235, 0.06);
  --glass-border: rgba(210, 215, 230, 0.50);
  --glass-blur: 3px;
  --btn-glass-bg: rgba(37, 99, 235, 0.78);
  --btn-glass-bg-hover: rgba(29, 78, 216, 0.88);

  /* Fonts */
  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
  --font-mono: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, 'DejaVu Sans Mono', monospace;

  /* Layout */
  --max-width: 960px;
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;
  --spacing-2xl: 4rem;
}

/* Dark mode - system preference OR manual selection */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #0f0f0f;
    --color-text: #e5e5e5;
    --color-text-light: #a3a3a3;
    --color-accent: #3b82f6;
    --color-accent-hover: #60a5fa;
    --color-border: rgba(59, 130, 246, 0.28);
    --color-card-bg: #1a1a1a;

    /* Geometric background — prominent in dark mode */
    --geo-glow-1: rgba(59, 130, 246, 0.22);
    --geo-glow-2: rgba(37, 99, 235, 0.12);
    --geo-triangles: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 800'><polygon points='0,0 650,0 0,550' fill='rgb(59,130,246)' fill-opacity='0.03' stroke='rgb(59,130,246)' stroke-opacity='0.08' stroke-width='1.5'/><polygon points='1200,800 550,800 1200,200' fill='rgb(37,99,235)' fill-opacity='0.04' stroke='rgb(59,130,246)' stroke-opacity='0.09' stroke-width='1.5'/><polygon points='0,600 300,800 0,800' fill='rgb(59,130,246)' fill-opacity='0.05' stroke='rgb(59,130,246)' stroke-opacity='0.10' stroke-width='1.5'/></svg>");

    /* Glass effect */
    --glass-bg: rgba(10, 24, 48, 0.42);
    --glass-border: rgba(59, 130, 246, 0.42);
    --btn-glass-bg: rgba(59, 130, 246, 0.62);
    --btn-glass-bg-hover: rgba(96, 165, 250, 0.72);
  }

  /* Enhanced contrast for cards in dark mode */
  :root:not([data-theme="light"]) .card {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  }

  /* Ensure timeline dots stand out */
  :root:not([data-theme="light"]) .timeline-item::before {
    box-shadow: 0 0 0 3px var(--color-bg);
  }

  :root:not([data-theme="light"]) .pullquote {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  }

  :root:not([data-theme="light"]) .section-alt {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  }
}

/* Dark mode - manual selection overrides light system preference */
[data-theme="dark"] {
  --color-bg: #0f0f0f;
  --color-text: #e5e5e5;
  --color-text-light: #a3a3a3;
  --color-accent: #3b82f6;
  --color-accent-hover: #60a5fa;
  --color-border: #262626;
  --color-card-bg: #1a1a1a;

  /* Geometric background — prominent in dark mode */
  --geo-glow-1: rgba(59, 130, 246, 0.22);
  --geo-glow-2: rgba(37, 99, 235, 0.12);
  --geo-triangles: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 800'><polygon points='0,0 650,0 0,550' fill='rgb(59,130,246)' fill-opacity='0.09' stroke='rgb(59,130,246)' stroke-opacity='0.18' stroke-width='1.5'/><polygon points='1200,800 550,800 1200,200' fill='rgb(37,99,235)' fill-opacity='0.07' stroke='rgb(59,130,246)' stroke-opacity='0.14' stroke-width='1.5'/><polygon points='1200,0 750,400 1200,660' fill='none' stroke='rgb(59,130,246)' stroke-opacity='0.14' stroke-width='1.5'/><polygon points='0,600 300,800 0,800' fill='rgb(59,130,246)' fill-opacity='0.05' stroke='rgb(59,130,246)' stroke-opacity='0.10' stroke-width='1.5'/></svg>");

  /* Glass effect */
  --glass-bg: rgba(10, 14, 28, 0.62);
  --glass-border: rgba(59, 130, 246, 0.18);
  --btn-glass-bg: rgba(59, 130, 246, 0.62);
  --btn-glass-bg-hover: rgba(96, 165, 250, 0.72);
}

[data-theme="dark"] .card {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .timeline-item::before {
  box-shadow: 0 0 0 3px var(--color-bg);
}

[data-theme="dark"] .pullquote {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .section-alt {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  background-image:
    radial-gradient(ellipse 90% 65% at -5% -5%, var(--geo-glow-1) 0%, transparent 60%),
    radial-gradient(ellipse 70% 55% at 105% 105%, var(--geo-glow-2) 0%, transparent 55%),
    var(--geo-triangles);
  background-size: auto, auto, cover;
  background-attachment: fixed;
  transition: background-color 0.3s ease, color 0.3s ease;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Typography */
h1 {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--spacing-md);
}

h2 {
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.3;
  margin-top: var(--spacing-xl);
  margin-bottom: var(--spacing-md);
}

h3 {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.4;
  margin-top: var(--spacing-lg);
  margin-bottom: var(--spacing-sm);
}

p {
  margin-bottom: var(--spacing-md);
  color: var(--color-text);
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

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

ul, ol {
  margin-left: var(--spacing-lg);
  margin-bottom: var(--spacing-md);
}

li {
  margin-bottom: var(--spacing-xs);
}

strong {
  font-weight: 600;
}

/* Navigation */
.nav {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.nav-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--spacing-md) var(--spacing-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-logo {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
}

.nav-logo:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: var(--spacing-lg);
  list-style: none;
  margin: 0;
}

.nav-links a {
  color: var(--color-text-light);
  font-weight: 500;
  transition: color 0.2s;
}

.nav-links a:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.nav-links a.active {
  color: var(--color-accent);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
}

/* Theme toggle button */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: var(--color-text-light);
}

.theme-toggle:hover {
  background: var(--color-card-bg);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.theme-toggle svg {
  display: none;
  width: 20px;
  height: 20px;
}

.theme-toggle .sun-icon.active,
.theme-toggle .moon-icon.active {
  display: block;
}

/* Main content */
.main-content {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: var(--spacing-2xl) var(--spacing-lg);
}

/* Hero section */
.hero {
  margin-bottom: var(--spacing-2xl);
}

.hero h1 {
  margin-bottom: var(--spacing-md);
}

.hero .subhead {
  font-size: 1.25rem;
  color: var(--color-text-light);
  margin-bottom: var(--spacing-lg);
}

.hero .intro {
  font-size: 1.125rem;
  line-height: 1.7;
  margin-bottom: var(--spacing-lg);
}

/* Stats section */
.stats {
  margin: var(--spacing-2xl) 0;
  padding: var(--spacing-xl) 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.stats-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--spacing-xl);
  text-align: center;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.stat-number {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--color-accent);
  line-height: 1;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--color-text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

/* Sections */
.section {
  margin-bottom: var(--spacing-2xl);
}

.section-alt {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  margin-left: calc(-1 * var(--spacing-lg));
  margin-right: calc(-1 * var(--spacing-lg));
  padding: var(--spacing-xl) var(--spacing-lg);
  border-radius: 8px;
}

.section-title {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-sm);
  border-bottom: 2px solid var(--color-border);
}

/* Pull quote */
.pullquote {
  margin: var(--spacing-xl) 0;
  padding: var(--spacing-lg);
  padding-left: var(--spacing-xl);
  border-left: 4px solid var(--color-accent);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-top: 1px solid var(--glass-border);
  border-right: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
  font-size: 1.25rem;
  font-style: italic;
  line-height: 1.6;
  color: var(--color-text);
  border-radius: 4px;
}

/* Icon list */
.icon-list {
  list-style: none;
  margin-left: 0;
}

.icon-list li {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.icon-list li:last-child {
  margin-bottom: 0;
}

.icon-list .icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  color: var(--color-accent);
  margin-top: 2px;
}

.icon-list span {
  flex: 1;
  line-height: 1.6;
}

/* Cards */
.card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.card h3 {
  margin-top: 0;
}

/* Buttons and CTAs */
.cta-buttons {
  display: flex;
  gap: var(--spacing-md);
  flex-wrap: wrap;
  justify-content: center;
  margin-top: var(--spacing-lg);
}

.btn {
  display: inline-block;
  padding: var(--spacing-sm) var(--spacing-lg);
  background: var(--btn-glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.20);
  border-radius: 6px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.2s, transform 0.1s;
}

.btn:hover {
  background: var(--btn-glass-bg-hover);
  color: white;
  text-decoration: none;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  color: var(--color-accent);
  border: 1px solid var(--glass-border);
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.1s;
}

.btn-secondary:hover {
  background: var(--btn-glass-bg);
  color: white;
  border-color: transparent;
  transform: translateY(-1px);
}

/* Timeline */
.timeline {
  position: relative;
  padding-left: var(--spacing-lg);
  border-left: 2px solid var(--color-border);
}

.timeline-item {
  margin-bottom: var(--spacing-xl);
  position: relative;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: calc(-1 * var(--spacing-lg) - 6px);
  top: 8px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 2px solid var(--color-bg);
}

.timeline-date {
  font-weight: 600;
  color: var(--color-accent);
  margin-bottom: var(--spacing-xs);
}

.timeline-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: var(--spacing-xs);
}

.timeline-subtitle {
  color: var(--color-text-light);
  margin-bottom: var(--spacing-sm);
}

/* Contact info */
.contact-info {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.contact-item {
  display: flex;
  align-items: baseline;
  gap: var(--spacing-sm);
}

.contact-label {
  font-weight: 600;
  min-width: 100px;
}

/* Footer */
.footer {
  border-top: 1px solid var(--color-border);
  padding: var(--spacing-lg);
  text-align: center;
  color: var(--color-text-light);
  font-size: 0.875rem;
}

.footer-container {
  max-width: var(--max-width);
  margin: 0 auto;
}

.footer p {
  margin-bottom: var(--spacing-xs);
}

/* Responsive */
@media (max-width: 768px) {
  :root {
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  .nav-container {
    flex-direction: column;
    gap: var(--spacing-md);
    align-items: flex-start;
  }

  .nav-right {
    width: 100%;
    justify-content: space-between;
  }

  .nav-links {
    gap: var(--spacing-md);
    flex-wrap: wrap;
  }

  .main-content {
    padding: var(--spacing-lg) var(--spacing-md);
  }

  .stats-container {
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
  }

  .section-alt {
    margin-left: calc(-1 * var(--spacing-md));
    margin-right: calc(-1 * var(--spacing-md));
    padding: var(--spacing-lg) var(--spacing-md);
  }

  .pullquote {
    font-size: 1.125rem;
    padding: var(--spacing-md);
    padding-left: var(--spacing-lg);
  }
}

@media (max-width: 480px) {
  .nav-links {
    gap: var(--spacing-sm);
    font-size: 0.875rem;
  }

  .stat-number {
    font-size: 2rem;
  }

  .cta-buttons {
    flex-direction: column;
  }

  .btn {
    text-align: center;
  }
}

/* ---------- 404 page ---------- */
.error-page {
  text-align: center;
  padding: var(--spacing-xl) 0;
}

.error-code {
  font-family: var(--font-mono);
  font-size: 5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--color-accent);
  letter-spacing: 0.05em;
}

.error-terminal {
  display: inline-block;
  margin: var(--spacing-lg) auto;
  padding: var(--spacing-md) var(--spacing-lg);
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--color-accent);
  background: var(--color-card-bg);
  border: 2px solid var(--color-accent);
  border-radius: 8px;
}

.error-terminal-line {
  display: block;
}

.error-cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.05em;
  vertical-align: text-bottom;
  background: var(--color-accent);
  animation: error-blink 1.06s step-end infinite;
}

@keyframes error-blink {
  50% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .error-cursor { animation: none; }
}

[data-theme="dark"] .error-terminal {
  background: rgba(59, 130, 246, 0.08);
}

/* Same treatment when following the system preference (matches the pattern above) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .error-terminal {
    background: rgba(59, 130, 246, 0.08);
  }
}

@media (max-width: 480px) {
  .error-code { font-size: 3.5rem; }
  .error-terminal { font-size: 0.8rem; }
}
