/* ═══════════════════════════════════════════════════════
   ysc — Design System Tokens
   ═══════════════════════════════════════════════════════ */

:root {
  /* ── Brand Colors ─── */
  --brand-h: 210;
  --brand-s: 70%;
  --brand-l: 55%;
  --brand: hsl(var(--brand-h), var(--brand-s), var(--brand-l));
  --brand-dim: hsl(var(--brand-h), 60%, 45%);
  --brand-bright: hsl(var(--brand-h), 80%, 65%);
  --brand-glow: hsla(var(--brand-h), var(--brand-s), var(--brand-l), 0.15);

  /* ── Surface Colors ─── */
  --surface-0: #0d1117;
  --surface-1: #161b22;
  --surface-2: #1c2333;
  --surface-3: #252d3f;
  --surface-4: #2d3648;

  /* ── Text Colors ─── */
  --text: #e6edf3;
  --text-secondary: #8b949e;
  --text-tertiary: #6e7681;
  --text-inverse: #0d1117;

  /* ── Semantic Colors ─── */
  --green: #3fb950;
  --green-bg: rgba(63, 185, 80, 0.1);
  --orange: #d29922;
  --orange-bg: rgba(210, 153, 34, 0.1);
  --red: #f85149;
  --red-bg: rgba(248, 81, 73, 0.1);
  --purple: #bc8cff;
  --purple-bg: rgba(188, 140, 255, 0.1);
  --cyan: #39d2c0;
  --cyan-bg: rgba(57, 210, 192, 0.1);

  /* ── Scrollbar ─── */
  --scrollbar-track: var(--surface-1);
  --scrollbar-thumb: var(--surface-4);
  --scrollbar-thumb-hover: var(--text-tertiary);

  /* ── Syntax Colors ─── */
  --syn-kw: #ff7b72;
  --syn-str: #a5d6ff;
  --syn-num: #79c0ff;
  --syn-fn: #d2a8ff;
  --syn-cm: #8b949e;
  --syn-type: #ffa657;
  --syn-op: #ffa657;

  /* ── Typography ─── */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;

  /* ── Spacing Scale ─── */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* ── Border Radius ─── */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-2xl: 16px;

  /* ── Shadows ─── */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--brand-glow);

  /* ── Transitions ─── */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ═══════════════════════════════════════════════════════
   Reset & Base
   ═══════════════════════════════════════════════════════ */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }
::-webkit-scrollbar-corner { background: var(--scrollbar-track); }

body {
  background: var(--surface-0);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

::selection {
  background: var(--brand);
  color: var(--text-inverse);
}

/* ═══════════════════════════════════════════════════════
   Navbar
   ═══════════════════════════════════════════════════════ */

nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(22, 27, 34, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--surface-3);
  padding: 0 var(--space-8);
  display: flex;
  align-items: center;
  gap: var(--space-6);
  height: 60px;
}

nav .logo {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  letter-spacing: -0.02em;
}

nav .logo .logo-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--brand), var(--cyan));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-inverse);
}

nav a:not(.logo) {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 450;
  padding: var(--space-1) 0;
  position: relative;
  transition: color var(--transition-fast);
}

nav a:not(.logo)::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--brand);
  transition: width var(--transition-base);
  border-radius: 1px;
}

nav a:not(.logo):hover {
  color: var(--text);
}

nav a:not(.logo):hover::after {
  width: 100%;
}

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

nav a.active::after {
  width: 100%;
}

nav .github {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3) !important;
  border: 1px solid var(--surface-3);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast) !important;
}

nav .github:hover {
  border-color: var(--surface-4);
  background: var(--surface-2);
}

/* ═══════════════════════════════════════════════════════
   Layout
   ═══════════════════════════════════════════════════════ */

.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

/* ═══════════════════════════════════════════════════════
   Hero
   ═══════════════════════════════════════════════════════ */

.hero {
  text-align: center;
  padding: var(--space-20) var(--space-4) var(--space-12);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--brand-glow) 0%, transparent 70%);
  pointer-events: none;
  animation: heroGlow 6s ease-in-out infinite alternate;
}

@keyframes heroGlow {
  from { opacity: 0.6; transform: translateX(-50%) scale(1); }
  to   { opacity: 1;   transform: translateX(-50%) scale(1.2); }
}

.hero .logo-hero {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--brand), var(--cyan));
  border-radius: var(--radius-xl);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-inverse);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-glow);
  animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
  0%, 100% { box-shadow: var(--shadow-glow); }
  50% { box-shadow: 0 0 30px var(--brand-glow), 0 0 60px var(--brand-glow); }
}

.hero h1 {
  font-size: 4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: var(--space-4);
}

.hero h1 .accent {
  background: linear-gradient(135deg, var(--brand), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 1.2rem;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto var(--space-8);
  line-height: 1.6;
}

.hero .btn-group {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  position: relative;
}

.btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--brand);
  color: var(--text-inverse);
  border-color: var(--brand);
}

.btn-primary:hover {
  background: var(--brand-bright);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--surface-3);
}

.btn-secondary:hover {
  background: var(--surface-3);
  border-color: var(--surface-4);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface-2);
}

/* ═══════════════════════════════════════════════════════
   Cards
   ═══════════════════════════════════════════════════════ */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
  margin: var(--space-12) 0;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  text-decoration: none;
  color: inherit;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--brand), var(--cyan));
  opacity: 0;
  transition: opacity var(--transition-base);
}

.card:hover {
  border-color: var(--surface-4);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.card:hover::before {
  opacity: 1;
}

.card:active {
  transform: translateY(-1px);
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-bottom: var(--space-4);
  background: var(--surface-3);
}

.card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--text);
}

.card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.card:hover h3 {
  color: var(--brand);
}

/* ═══════════════════════════════════════════════════════
   Content Pages
   ═══════════════════════════════════════════════════════ */

.content {
  padding: var(--space-12) 0 var(--space-16);
  flex: 1;
}

.content h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--surface-3);
}

.content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--brand);
  margin-top: var(--space-12);
  margin-bottom: var(--space-4);
  letter-spacing: -0.01em;
}

.content h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-top: var(--space-8);
  margin-bottom: var(--space-3);
  color: var(--text);
}

.content p {
  margin: var(--space-4) 0;
  color: var(--text-secondary);
  line-height: 1.8;
  font-size: 0.95rem;
}

.content ul, .content ol {
  margin: var(--space-4) 0;
  padding-left: var(--space-6);
  color: var(--text-secondary);
}

.content li {
  margin: var(--space-2) 0;
  line-height: 1.6;
}

.content li::marker {
  color: var(--brand-dim);
}

.content code {
  background: var(--surface-2);
  padding: 0.2em 0.4em;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 0.85em;
  color: var(--cyan);
}

.content pre {
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin: var(--space-5) 0;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.6;
  position: relative;
}

.content pre::before {
  content: attr(data-lang);
  position: absolute;
  top: var(--space-2);
  right: var(--space-3);
  font-family: var(--font);
  font-size: 0.7rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.content pre code {
  background: none;
  padding: 0;
  color: var(--text);
}

.content table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: var(--space-6) 0;
  border: 1px solid var(--surface-3);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.content th {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--surface-3);
}

.content td {
  padding: var(--space-3) var(--space-4);
  color: var(--text-secondary);
  font-size: 0.9rem;
  border-bottom: 1px solid var(--surface-3);
}

.content tr:last-child td {
  border-bottom: none;
}

.content tr:hover td {
  background: var(--surface-2);
}

.content blockquote {
  border-left: 3px solid var(--brand);
  padding: var(--space-4) var(--space-5);
  margin: var(--space-6) 0;
  background: var(--surface-1);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.content blockquote p {
  margin: 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* ── Syntax Highlighting ─── */
.kw  { color: var(--syn-kw); }
.str { color: var(--syn-str); }
.num { color: var(--syn-num); }
.fn  { color: var(--syn-fn);  }
.cm  { color: var(--syn-cm); font-style: italic; }
.typ { color: var(--syn-type); }
.op  { color: var(--syn-op); }

/* ── Section Title with Accent Line ─── */
.section-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-12) 0 var(--space-6);
}

.section-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--surface-3), transparent);
}

.section-header h2 {
  margin: 0;
}

/* ═══════════════════════════════════════════════════════
   Quick Example Block
   ═══════════════════════════════════════════════════════ */

.example-block {
  background: linear-gradient(135deg, var(--surface-1), var(--surface-2));
  border: 1px solid var(--surface-3);
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin: var(--space-8) 0;
}

.example-block .example-header {
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--surface-3);
  font-size: 0.8rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.example-block pre {
  margin: 0;
  padding: var(--space-5);
  border: none;
  border-radius: 0;
  background: transparent;
}

/* ═══════════════════════════════════════════════════════
   Playground
   ═══════════════════════════════════════════════════════ */

.playground-wrap {
  display: flex;
  gap: var(--space-4);
  min-height: 60vh;
  margin: var(--space-6) 0;
}

.playground-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.playground-output {
  width: 360px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.playground-output pre {
  flex: 1;
  margin: 0;
  padding: var(--space-4);
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.6;
  overflow: auto;
  white-space: pre-wrap;
  background: transparent;
  border-radius: 0;
}

.playground-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--surface-3);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.playground-status {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-left: auto;
}

.playground-tabs {
  display: flex;
  background: var(--surface-2);
  border-bottom: 1px solid var(--surface-3);
}

.playground-tab {
  padding: var(--space-2) var(--space-4);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-tertiary);
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  user-select: none;
}

.playground-tab:hover {
  color: var(--text-secondary);
}

.playground-tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

/* ═══════════════════════════════════════════════════════
   Footer
   ═══════════════════════════════════════════════════════ */

footer {
  margin-top: auto;
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--text-tertiary);
  font-size: 0.8rem;
  border-top: 1px solid var(--surface-3);
}

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

footer a:hover {
  text-decoration: underline;
}

/* ═══════════════════════════════════════════════════════
   Animations
   ═══════════════════════════════════════════════════════ */

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

.animate-in {
  animation: fadeInUp 0.5s ease both;
}

.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.1s; }
.animate-in:nth-child(3) { animation-delay: 0.15s; }
.animate-in:nth-child(4) { animation-delay: 0.2s; }

/* ═══════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  :root {
    --space-8: 1.5rem;
    --space-6: 1.25rem;
  }

  nav {
    padding: 0 var(--space-4);
    gap: var(--space-3);
    height: 52px;
  }

  nav .github {
    border: none;
    padding: var(--space-1) !important;
  }

  nav .github span {
    display: none;
  }

  .hero {
    padding: var(--space-12) var(--space-4) var(--space-8);
  }

  .hero h1 {
    font-size: 2.5rem;
  }

  .hero p {
    font-size: 1rem;
  }

  .container {
    padding: 0 var(--space-4);
  }

  .cards {
    gap: var(--space-3);
  }

  .playground-wrap {
    flex-direction: column;
  }

  .playground-output {
    width: 100%;
    min-height: 300px;
  }
}

@media (max-width: 480px) {
  .hero h1 {
    font-size: 2rem;
  }

  .hero .btn-group {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    justify-content: center;
  }

  .content h1 {
    font-size: 1.8rem;
  }

  .content h2 {
    font-size: 1.2rem;
  }

  .content pre {
    font-size: 0.75rem;
    padding: var(--space-4);
  }
}
