/* === Design Tokens & Variables === */
:root {
  --color-dark: #240F29;
  --color-paper: #F6F3F7;
  --color-text: #201523;
  --color-brand: #A711CF;
  --color-accent: #ED6E73;
  --color-divider: rgba(32, 21, 35, 0.12);
  
  --radius-card: 0;
  --radius-btn: 0;
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 960px;
  
  --font-display-weight: 500;
  --line-height-tight: 1.15;
  --line-height-body: 1.55;
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  background-color: var(--color-paper);
  color: var(--color-text);
  line-height: var(--line-height-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

/* === Typography === */
h1, h2, h3, h4 {
  font-weight: var(--font-display-weight);
  line-height: var(--line-height-tight);
  letter-spacing: -0.02em;
  text-wrap: balance;
}
h1 { font-size: clamp(2.6rem, 6.4vw, 5rem); }
h2 { font-size: clamp(1.8rem, 3.5vw, 2.8rem); margin-bottom: calc(var(--gap) * 2); }
h3 { font-size: clamp(1.25rem, 2vw, 1.5rem); margin-bottom: var(--gap); }
p { margin-bottom: var(--gap); max-width: 38em; }
.hl { color: var(--color-brand); }
.dark-surface .hl { color: var(--color-accent); }
.muted { color: rgba(32, 21, 35, 0.65); }
.dark-surface .muted { color: rgba(246, 243, 247, 0.7); }

/* === Layout Containers === */
.container {
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gap);
}
section {
  padding-block: var(--section-y);
  border-bottom: 1px solid var(--color-divider);
}
section:last-of-type { border-bottom: none; }
.dark-surface {
  background-color: var(--color-dark);
  color: var(--color-paper);
}
.dark-surface section { border-bottom-color: rgba(246, 243, 247, 0.15); }

/* === Header & Footer === */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--color-paper);
  border-bottom: 1px solid var(--color-divider);
  backdrop-filter: blur(8px);
}
.dark-surface .site-header { background-color: var(--color-dark); border-bottom-color: rgba(246, 243, 247, 0.15); }
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand { display: flex; align-items: center; gap: 0.75rem; font-weight: 700; font-size: 1.1rem; }
.brand img { height: 28px; width: auto; }
nav { display: flex; align-items: center; gap: var(--gap); }
.nav-link {
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.5rem 0;
  position: relative;
}
.nav-link:hover, .nav-link[aria-current="page"] { color: var(--color-brand); }
.dark-surface .nav-link:hover, .dark-surface .nav-link[aria-current="page"] { color: var(--color-accent); }
.nav-link[aria-current="page"]::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background-color: currentColor;
}
@media (max-width: 768px) {
  nav { gap: 0.5rem; }
  .nav-link { font-size: 0.85rem; }
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  height: 52px;
  padding: 0 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }
.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-dark);
}
.btn-primary:hover { background-color: #d95a60; }
.btn-secondary {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-text);
}
.dark-surface .btn-secondary { color: var(--color-paper); border-color: var(--color-paper); }
.dark-surface .btn-secondary:hover { background-color: rgba(246, 243, 247, 0.1); }
.btn-icon { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2; fill: none; }

/* === Cards & Panels === */
.card {
  background: color-mix(in srgb, var(--color-text) 2%, transparent);
  padding: var(--gap);
  border-radius: var(--radius-card);
}
.dark-surface .card {
  background: color-mix(in srgb, var(--color-paper) 4%, transparent);
}
.panel {
  background-color: var(--color-dark);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  overflow: hidden;
}
.dark-surface .panel { background-color: rgba(246, 243, 247, 0.08); }

/* === Grid & Flex Utilities === */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); }
.flex-row { display: flex; flex-wrap: wrap; gap: var(--gap); align-items: center; }
.min-w-0 { min-width: 0; }

/* === Tables === */
.data-table { width: 100%; border-collapse: collapse; margin-top: var(--gap); }
.data-table th, .data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-divider);
}
.data-table th { font-weight: 600; }
.dark-surface .data-table th, .dark-surface .data-table td { border-bottom-color: rgba(246, 243, 247, 0.15); }

/* === Details / FAQ === */
details {
  border-bottom: 1px solid var(--color-divider);
  padding: 1rem 0;
}
.dark-surface details { border-bottom-color: rgba(246, 243, 247, 0.15); }
summary {
  list-style: none;
  cursor: pointer;
  font-weight: 600;
  padding: 0.25rem 0;
  position: relative;
  padding-left: 1.5rem;
}
summary::-webkit-details-marker { display: none; }
summary::before {
  content: "+";
  position: absolute;
  left: 0;
  top: 0.25rem;
  font-weight: 700;
  color: var(--color-brand);
}
.dark-surface summary::before { color: var(--color-accent); }
details[open] summary::before { content: "−"; }
.details-content { padding-top: 0.75rem; color: var(--color-text); }
.dark-surface .details-content { color: var(--color-paper); }

/* === SVG Animations === */
.svg-visual { width: 100%; height: auto; max-width: 100%; }
.orbit-ring {
  fill: none;
  stroke-width: 1.5;
  transform-origin: center;
  transform-box: fill-box;
}
.orbit-1 { stroke: var(--color-brand); opacity: 0.6; animation: orbitBreathe 4s ease-in-out infinite alternate; }
.orbit-2 { stroke: var(--color-accent); opacity: 0.4; animation: orbitBreathe 5.5s ease-in-out infinite alternate-reverse; }
.orbit-3 { stroke: var(--color-text); opacity: 0.2; animation: orbitSpin 12s linear infinite; }
.dark-surface .orbit-3 { stroke: var(--color-paper); }

.draw-path {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  stroke: var(--color-text);
  opacity: 0.8;
}
.dark-surface .draw-path { stroke: var(--color-paper); }
.draw-flow { animation: drawDash 3s ease forwards; }

.float-subtle { animation: floatY 6s ease-in-out infinite; }
.bubble-pop { animation: popIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }

@keyframes orbitBreathe {
  from { transform: scale(0.96); opacity: 0.4; }
  to { transform: scale(1.04); opacity: 0.8; }
}
@keyframes orbitSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes drawDash {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}
@keyframes floatY {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
