:root {
  color-scheme: dark;
  --bg: #0f1419;
  --surface: #1a1f2e;
  --ink: #e8eaf6;
  --muted: #9ca3af;
  --accent: #8b5cf6;
  --accent-2: #a78bfa;
  --accent-soft: #3b2f4f;
  --border: #2d3748;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 4px 10px -2px rgba(0, 0, 0, 0.3);
  --radius: 8px;
  --max-width: 1600px;
  --gap: clamp(1.5rem, 3vw, 2.5rem);
}

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

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  width: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.75;
  color: var(--ink);
  background: var(--bg);
  background-image: radial-gradient(circle at 20% 30%, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(167, 139, 250, 0.1) 0%, transparent 50%);
  font-size: clamp(1rem, 1.1vw, 1.125rem);
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
}

h1 {
  font-size: clamp(2.25rem, 5vw, 3.75rem);
  margin: 0 0 1.25rem;
  line-height: 1.2;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
}

h2 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  margin: 0 0 1.5rem;
  line-height: 1.3;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

h3 {
  font-size: clamp(1.25rem, 2.5vw, 1.5rem);
  margin: 0 0 0.75rem;
  line-height: 1.4;
  font-weight: 600;
  color: var(--ink);
}

p {
  margin: 0 0 1.5rem;
  line-height: 1.8;
}

img {
  max-width: 100%;
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

a {
  color: inherit;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  transform: translateY(-200%);
  transition: transform 0.2s ease;
  z-index: 5;
}

.skip-link:focus {
  transform: translateY(0);
}

.container {
  width: min(100% - 4rem, var(--max-width));
  margin: 0 auto;
  padding: 0 2rem;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

.site-header {
  padding: clamp(3rem, 7vw, 5rem) 0;
  background: linear-gradient(135deg, #1a1f2e 0%, #0f1419 100%);
  border-bottom: 1px solid var(--border);
}

.header-grid {
  display: grid;
  gap: var(--gap);
  align-items: center;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.eyebrow {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent-2);
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
}

.lead {
  font-size: clamp(1.125rem, 1.5vw, 1.25rem);
  color: var(--muted);
  margin-bottom: 2rem;
  line-height: 1.7;
  max-width: 65ch;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  background: var(--accent-soft);
  color: var(--accent-2);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.875rem;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.hero-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  padding: 2.5rem;
  min-height: 240px;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, #1f2535 0%, #1a1f2e 100%);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.equilibrium-visual {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  max-width: 100%;
  overflow: hidden;
}

.balance-base {
  position: absolute;
  bottom: 30%;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 80px;
  background: linear-gradient(180deg, 
    var(--accent-2) 0%, 
    var(--accent) 50%,
    var(--accent-2) 100%
  );
  border-radius: 3px;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.5);
}

.balance-beam {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 240px;
  height: 3px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    var(--accent-2) 10%, 
    var(--accent) 50%, 
    var(--accent-2) 90%, 
    transparent 100%
  );
  border-radius: 2px;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.6);
}

.balance-beam::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(167, 139, 250, 0.8);
}

.balance-weight {
  position: absolute;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, 
    rgba(167, 139, 250, 0.95) 0%, 
    rgba(139, 92, 246, 0.85) 40%,
    rgba(99, 102, 241, 0.7) 100%
  );
  box-shadow: 0 0 25px rgba(139, 92, 246, 0.6),
              inset 0 2px 6px rgba(255, 255, 255, 0.25);
  border: 2px solid rgba(139, 92, 246, 0.4);
  top: 50%;
  transform: translateY(-50%);
}

.balance-weight.weight-left {
  left: calc(50% - 150px);
}

.balance-weight.weight-right {
  right: calc(50% - 150px);
}

.balance-weight::before {
  content: "";
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 25px;
  background: linear-gradient(180deg, 
    var(--accent-2) 0%,
    transparent 100%
  );
  box-shadow: 0 0 6px rgba(139, 92, 246, 0.5);
}

.balance-weight::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  background: var(--accent-2);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(167, 139, 250, 0.9);
  opacity: 0.9;
}

.hero-caption {
  position: relative;
  z-index: 1;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 500;
}

.site-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.site-nav ul {
  list-style: none;
  padding: 1rem 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  justify-content: center;
}

.site-nav a {
  font-weight: 500;
  color: var(--muted);
  transition: color 0.2s ease;
  font-size: 0.9375rem;
}

.site-nav a:hover {
  color: var(--accent-2);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes fadeZoom {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(30px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.section {
  padding: clamp(3rem, 8vw, 6rem) 0;
  position: relative;
  min-height: 70vh;
  display: flex;
  align-items: center;
  opacity: 1;
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.section.alt {
  background: #151a24;
}

.section.in-view {
  opacity: 1;
  animation: fadeZoom 1s ease forwards;
}

.section:nth-child(even).in-view {
  animation: slideInRight 1s ease forwards;
}

.section:nth-child(odd).in-view {
  animation: slideInLeft 1s ease forwards;
}

.section + .section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  transform: translateY(-100%);
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.15) 0%, rgba(139, 92, 246, 0.08) 50%, transparent 100%);
  animation: fadeIn 1s ease;
}

.section h2 {
  opacity: 0;
  transform: translateY(60px);
  transition: none;
}

.section.in-view h2 {
  opacity: 1;
  transform: translateY(0);
  animation: slideInUp 0.9s ease 0.3s forwards;
}

.section .container > *:not(h2) {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease 0.4s, transform 0.6s ease 0.4s;
}

.section.in-view .container > *:not(h2) {
  opacity: 1;
  transform: translateY(0);
}

.section-intro {
  max-width: 70ch;
  color: var(--muted);
  font-size: 1.0625rem;
  line-height: 1.8;
  margin-bottom: 2rem;
}

.split {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-items: start;
}

.info-card {
  background: var(--surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
}

.bullet-list {
  padding-left: 1.1rem;
}

.timeline {
  display: grid;
  gap: 1.5rem;
  margin-top: 1.5rem;
  list-style: none;
  padding: 0;
}

.timeline-item {
  background: var(--surface);
  padding: 2rem;
  border-radius: var(--radius);
  border-left: 4px solid var(--accent);
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  position: relative;
}

.gallery {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-top: 2rem;
  list-style: none;
  padding: 0;
}

.gallery-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.gallery-card img {
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  display: block;
}

.gallery-card figcaption {
  padding: 1rem;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.cards {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.card h3 {
  margin-top: 0;
  color: var(--accent-2);
}

.card p {
  margin-bottom: 0;
  line-height: 1.7;
}

.card:hover,
.info-card:hover,
.timeline-item:hover,
.gallery-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 22px 46px rgba(52, 30, 8, 0.18);
}

.glossary {
  display: grid;
  gap: 1.5rem;
  margin: 0;
}

.glossary dt {
  font-weight: 700;
}

.glossary dd {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

.reference-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
  display: grid;
  gap: 0.75rem;
}

.reference-list a {
  color: var(--accent-2);
  word-break: break-word;
}

.site-footer {
  background: #0a0e14;
  color: var(--muted);
  padding: 3rem 0;
  margin-top: 4rem;
  border-top: 1px solid var(--border);
}

.footer-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.back-to-top {
  color: var(--muted);
  text-decoration: none;
}

.back-to-top:hover {
  color: var(--ink);
}

@media (max-width: 720px) {
  .container {
    padding: 0 1rem;
    width: 100%;
    max-width: 100vw;
  }

  .header-grid {
    grid-template-columns: 1fr !important;
    gap: 2rem;
  }

  .hero-card {
    min-height: 180px;
    padding: 1.5rem;
  }

  .equilibrium-visual {
    min-height: 150px;
  }

  .balance-beam {
    width: 160px !important;
  }

  .balance-weight {
    width: 45px !important;
    height: 45px !important;
  }

  .balance-weight.weight-left {
    left: calc(50% - 100px) !important;
  }

  .balance-weight.weight-right {
    right: calc(50% - 100px) !important;
  }

  .balance-base {
    height: 50px !important;
  }

  .site-nav ul {
    justify-content: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 0;
    flex-wrap: wrap;
  }

  .gallery {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .gallery-card {
    margin: 0;
  }

  .gallery-card img {
    aspect-ratio: 16 / 9;
  }

  .section {
    padding: clamp(2rem, 5vw, 3rem) 0;
    min-height: auto;
  }

  /* Disable horizontal slide animations on mobile to prevent overflow */
  .section.in-view,
  .section:nth-child(even).in-view,
  .section:nth-child(odd).in-view {
    animation: fadeIn 0.8s ease forwards;
  }

  .section-intro {
    font-size: 1rem;
    margin-bottom: 1.5rem;
  }

  .cards {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .card {
    padding: 1.5rem;
  }

  .split {
    grid-template-columns: 1fr !important;
  }

  .info-card {
    margin-top: 1.5rem;
  }

  h1 {
    font-size: clamp(1.75rem, 8vw, 2.5rem) !important;
  }

  h2 {
    font-size: clamp(1.5rem, 6vw, 2rem) !important;
  }

  .tag {
    font-size: 0.75rem;
    padding: 0.4rem 0.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }

  .section {
    opacity: 1 !important;
    transform: none !important;
  }

  .section h2,
  .section .container > * {
    opacity: 1 !important;
    transform: none !important;
  }
}
