/* ==================== Design Tokens ==================== */
:root {
  --color-dark: #21163C;
  --color-paper: #F4F3F7;
  --color-text: #191523;
  --color-brand: #5214EB;
  --color-accent: #ED926E;
  --color-white: #FFFFFF;

  --radius-card: 20px;
  --radius-btn: 12px;
  --radius-tag: 8px;
  --card-border: 1px solid rgba(25, 21, 35, 0.16);
  --card-shadow: none;

  --section-y: clamp(3.5rem, 7vw, 6rem);
  --gap: clamp(1rem, 2vw, 1.75rem);
  --content-max: 1280px;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  --line-height-body: 1.65;
  --line-height-heading: 1.25;

  /* Default text color context */
  --text-color: var(--color-text);
  --brand-color: var(--color-brand);
  --accent-color: var(--color-accent);
}

/* Dark surface context */
.dark-bg {
  --text-color: var(--color-paper);
  --brand-color: var(--color-accent);
  --accent-color: var(--color-accent);
  background-color: var(--color-dark);
  color: var(--text-color);
}

/* Light card inside dark surface */
.light-card {
  --text-color: var(--color-text);
  --brand-color: var(--color-brand);
  --accent-color: var(--color-accent);
  background-color: var(--color-paper);
  color: var(--text-color);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
}

/* ==================== Reset & Base ==================== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: var(--line-height-body);
  color: var(--text-color);
  background-color: var(--color-paper);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; height: auto; }
a { color: var(--brand-color); text-decoration: none; transition: color 0.2s; }
a:hover { opacity: 0.85; }
:focus-visible { outline: 3px solid var(--accent-color); outline-offset: 2px; border-radius: 4px; }

/* ==================== Layout ==================== */
.container {
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gap);
}
.section {
  padding-block: var(--section-y);
}
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); }
@media (min-width: 768px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ==================== Typography ==================== */
h1, h2, h3, h4 { line-height: var(--line-height-heading); font-weight: 600; letter-spacing: 0; text-wrap: balance; }
h1 { font-size: clamp(2rem, 4.6vw, 3.4rem); margin-bottom: 0.5em; }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); margin-bottom: 0.6em; }
h3 { font-size: clamp(1.2rem, 2vw, 1.5rem); margin-bottom: 0.5em; }
p { margin: 0 0 1em; max-width: 38em; }
.text-mid { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; display: inline-block; margin-bottom: 0.5em; }
.text-mid.brand { color: var(--brand-color); }
.text-mid.accent { color: var(--accent-color); }
.hl { color: var(--brand-color); }
.dark-bg .hl { color: var(--accent-color); }

/* ==================== Components ==================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  padding: 0 1.25em; height: 52px; border-radius: var(--radius-btn);
  font-weight: 600; font-size: 1rem; cursor: pointer; border: none; transition: transform 0.2s, background 0.2s;
}
.btn-primary { background: var(--accent-color); color: var(--color-dark); }
.btn-primary:hover { transform: translateY(-2px); filter: brightness(1.05); }
.btn-secondary { background: transparent; color: var(--text-color); border: 2px solid var(--text-color); }
.btn-secondary:hover { background: rgba(0,0,0,0.05); }
.dark-bg .btn-secondary { color: var(--color-paper); border-color: var(--color-paper); }

.card {
  border-radius: var(--radius-card);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  padding: var(--gap);
  background: var(--color-paper);
  color: var(--text-color);
  display: flex; flex-direction: column; gap: 0.75em;
}
.card-header { font-weight: 700; font-size: 1.1rem; }
.card-meta { font-size: 0.85rem; opacity: 0.75; }

table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: 0.95rem; }
th, td { padding: 0.75em 1em; text-align: left; border-bottom: 1px solid rgba(0,0,0,0.1); }
th { font-weight: 700; }
.dark-bg table th, .dark-bg table td { border-bottom-color: rgba(255,255,255,0.15); }

details { border: var(--card-border); border-radius: var(--radius-card); padding: 1em; margin-bottom: 0.75em; background: var(--color-paper); color: var(--text-color); }
summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 0.5em; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "+"; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: var(--brand-color); color: #fff; font-size: 0.8rem; }
details[open] summary::before { content: "-"; }
details p { margin-top: 0.75em; font-size: 0.95rem; }

/* ==================== Header & Footer ==================== */
.site-header { position: sticky; top: 0; z-index: 100; background: var(--color-paper); border-bottom: 1px solid rgba(0,0,0,0.08); backdrop-filter: blur(8px); }
.dark-bg .site-header { background: var(--color-dark); border-bottom-color: rgba(255,255,255,0.1); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo { display: flex; align-items: center; gap: 0.6em; font-weight: 800; font-size: 1.1rem; color: var(--text-color); text-decoration: none; }
.logo img { width: 28px; height: 28px; object-fit: contain; }
nav { display: flex; gap: 1.5em; }
nav a { font-weight: 500; font-size: 0.95rem; color: var(--text-color); opacity: 0.8; }
nav a:hover, nav a[aria-current="page"] { opacity: 1; color: var(--brand-color); }
.dark-bg nav a { color: var(--color-paper); }
.dark-bg nav a:hover, .dark-bg nav a[aria-current="page"] { color: var(--accent-color); }

.site-footer { padding: var(--section-y) 0; border-top: 1px solid rgba(0,0,0,0.08); margin-top: var(--section-y); }
.dark-bg .site-footer { border-top-color: rgba(255,255,255,0.1); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--gap); }
.footer-links { display: flex; gap: 1.5em; flex-wrap: wrap; }
.footer-links a { color: var(--text-color); opacity: 0.7; }
.footer-links a:hover { opacity: 1; }
.copyright { font-size: 0.85rem; opacity: 0.6; margin-top: 1.5em; }

/* ==================== SVG Animation Base ==================== */
.svg-panel { width: 100%; height: auto; max-width: 100%; display: block; }
.draw-line { pathLength: 1; stroke-dasharray: 1; stroke-dashoffset: 0; }
.breathe { transform-box: fill-box; transform-origin: center; }
.float { transform-box: fill-box; transform-origin: center; }
.slide-in { transform-box: fill-box; transform-origin: center; }

@keyframes orbit-breathe {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.08); opacity: 1; }
}
@keyframes draw-path {
  0% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0; }
}
@keyframes msg-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes input-dots {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}
@keyframes notif-slide {
  0%, 100% { transform: translateX(0); opacity: 1; }
  50% { transform: translateX(4px); opacity: 0.85; }
}

.anim-orbit { animation: orbit-breathe 6s ease-in-out infinite; }
.anim-draw { animation: draw-path 4s ease-in-out infinite alternate; }
.anim-float { animation: msg-float 5s ease-in-out infinite; }
.anim-dots span { animation: input-dots 2s ease-in-out infinite; }
.anim-dots span:nth-child(2) { animation-delay: 0.4s; }
.anim-dots span:nth-child(3) { animation-delay: 0.8s; }
.anim-notif { animation: notif-slide 7s ease-in-out infinite; }

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .anim-orbit, .anim-draw, .anim-float, .anim-dots span, .anim-notif { animation: none !important; }
}

/* ==================== Utility ==================== */
.flex-col { display: flex; flex-direction: column; gap: var(--gap); }
.flex-row { display: flex; flex-wrap: wrap; gap: var(--gap); }
.min-w-0 { min-width: 0; }
.overflow-wrap-anywhere { overflow-wrap: anywhere; }
.step-strip { display: flex; gap: var(--gap); overflow-x: auto; padding-bottom: 0.5rem; scroll-snap-type: x mandatory; }
.step-strip > * { flex: 0 0 260px; scroll-snap-align: start; }
.timeline { position: relative; padding-left: 2rem; border-left: 2px solid var(--brand-color); margin-left: 1rem; }
.dark-bg .timeline { border-left-color: var(--accent-color); }
.timeline-item { position: relative; margin-bottom: 2rem; }
.timeline-item::before { content: ""; position: absolute; left: -2.4rem; top: 0.3rem; width: 12px; height: 12px; border-radius: 50%; background: var(--brand-color); border: 2px solid var(--color-paper); }
.dark-bg .timeline-item::before { background: var(--accent-color); border-color: var(--color-dark); }
.timeline-time { font-weight: 700; font-size: 0.85rem; color: var(--brand-color); margin-bottom: 0.25em; display: block; }
.dark-bg .timeline-time { color: var(--accent-color); }
.highlight-list { list-style: none; padding: 0; margin: 0; }
.highlight-list li { position: relative; padding-left: 1.5em; margin-bottom: 0.75em; }
.highlight-list li::before { content: "•"; position: absolute; left: 0; color: var(--brand-color); font-weight: bold; }
.dark-bg .highlight-list li::before { color: var(--accent-color); }
.pair-row { display: grid; grid-template-columns: 1fr; gap: var(--gap); align-items: center; }
@media (min-width: 900px) { .pair-row { grid-template-columns: 1fr 1fr; } .pair-row.reverse { direction: rtl; } .pair-row.reverse > * { direction: ltr; } }
