/* ── CSS variables ── */
html.dark {
  --bg: #080a10;
  --bg-alt: #0a0c14;
  --surface: #0f1117;
  --surface-2: #1e2130;
  --border: #1e2130;
  --border-2: #2e3350;
  --text-1: #f3f4f6;
  --text-2: #9ca3af;
  --text-3: #6b7280;
  --text-4: #4b5563;
  --nav-bg: rgba(8, 10, 16, 0.9);
}

html.light {
  --bg: #f4f5fa;
  --bg-alt: #ecedf5;
  --surface: #ffffff;
  --surface-2: #f0f1f8;
  --border: #e2e4ef;
  --border-2: #d0d3e8;
  --text-1: #0f1117;
  --text-2: #374151;
  --text-3: #6b7280;
  --text-4: #9ca3af;
  --nav-bg: rgba(244, 245, 250, 0.92);
}

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

body {
  font-family: "Geist", sans-serif;
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh;
  transition:
    background 0.25s,
    color 0.25s;
}

html {
  scroll-behavior: smooth;
}

/* ── Loader ── */
#ldr {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.875rem;
  transition: opacity 0.4s;
}

#ldr.out {
  opacity: 0;
  pointer-events: none;
}

#ldr img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  animation: ldrb 0.75s ease-in-out infinite alternate;
}

#ldr p {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-3);
}

@keyframes ldrb {
  to {
    transform: translateY(-8px);
  }
}

/* ── Grid bg ── */
.grid-bg {
  background-image: radial-gradient(
    rgba(88, 101, 242, 0.18) 1px,
    transparent 1px
  );
  background-size: 22px 22px;
}

html.light .grid-bg {
  background-image: radial-gradient(
    rgba(88, 101, 242, 0.25) 1px,
    transparent 1px
  );
}

/* ── Nav ── */
nav {
  background: var(--nav-bg) !important;
  border-color: var(--border) !important;
  backdrop-filter: blur(20px);
}

/* ── Toggle ── */
.tog-track {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #e8e9f2;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.tog-track.on {
  background: #5865f2;
}

.tog-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
}

.tog-track.on .tog-thumb {
  transform: translateX(18px);
}

/* ── Text helpers ── */
.t1 {
  color: var(--text-1) !important;
}
.t2 {
  color: var(--text-2) !important;
}
.t3 {
  color: var(--text-3) !important;
}
.t4 {
  color: var(--text-4) !important;
}

/* ── Hero ── */
.hero-fade {
  background: linear-gradient(
    to bottom,
    rgba(88, 101, 242, 0.05),
    transparent,
    var(--bg)
  ) !important;
}

.hero-eyebrow {
  font-size: 11px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: #5865f2;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-family: "Geist Mono", monospace;
  font-weight: 500;
}

.hero-eyebrow::before,
.hero-eyebrow::after {
  content: "";
  width: 28px;
  height: 1px;
  background: rgba(88, 101, 242, 0.4);
}

.hero-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(
    ellipse at center,
    rgba(88, 101, 242, 0.15) 0%,
    rgba(88, 101, 242, 0.05) 35%,
    transparent 70%
  );
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  animation: pulse-glow 4s ease-in-out infinite alternate;
}

@keyframes pulse-glow {
  from {
    opacity: 0.7;
    transform: translate(-50%, -50%) scale(1);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08);
  }
}

/* ── Category Cards ── */
.category-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition:
    transform 0.2s,
    box-shadow 0.2s,
    border-color 0.2s;
}

.category-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(88, 101, 242, 0.15);
  border-color: #5865f2;
}

.category-card .icon-wrap {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 1rem;
  border-radius: 0.75rem;
  background: rgba(88, 101, 242, 0.1);
  border: 1px solid rgba(88, 101, 242, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.category-card:hover .icon-wrap {
  transform: scale(1.1);
}

.category-card h3 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 0.25rem;
}

.category-card p {
  font-size: 0.875rem;
  color: var(--text-3);
}

/* ── Function Sections ── */
.func-section {
  margin-bottom: 2.5rem;
}

.func-section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

.func-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

.func-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
  text-decoration: none;
  transition:
    transform 0.2s,
    box-shadow 0.2s,
    border-color 0.2s;
}

.func-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(88, 101, 242, 0.1);
  border-color: #5865f2;
}

.func-name {
  display: block;
  font-family: "Geist Mono", monospace;
  font-size: 0.9rem;
  font-weight: 600;
  color: #5865f2;
  margin-bottom: 0.5rem;
}

.func-desc {
  font-size: 0.875rem;
  color: var(--text-3);
  line-height: 1.4;
}

/* ── About section ── */
.about-section {
  background: var(--surface);
  border: 1px solid var(--border);
}

.about-eyebrow-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.about-eyebrow-wrap::before {
  content: "";
  width: 2px;
  height: 0.9rem;
  background: #5865f2;
  border-radius: 1px;
  flex-shrink: 0;
}

/* ── Animations ── */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fu {
  animation: fadeUp 0.35s ease both;
}

/* ── Doc Page Styles ── */
.doc-content {
  max-width: 48rem;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0;
  background: none;
  color: var(--text-3);
  border: none;
  border-radius: 0;
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s;
}

.back-link:hover {
  color: var(--text-2);
  text-decoration: none !important;
  border-color: transparent;
}

.doc-content h2 {
  font-size: 1.875rem;
  font-weight: 800;
  color: var(--text-1);
  font-family: "Geist Mono", monospace;
  margin-top: 0;
  margin-bottom: 1.5rem;
}

.doc-content h3 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-1);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.doc-content h4 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-1);
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

.doc-content p {
  color: var(--text-2);
  line-height: 1.7;
  margin-bottom: 1rem;
}

.doc-content code {
  font-family: "Geist Mono", monospace;
  background: var(--surface);
  color: #5865f2;
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.9em;
  border: 1px solid var(--border);
}

.doc-content pre {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 1rem 0;
}

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

.doc-content ul,
.doc-content ol {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
  color: var(--text-2);
  list-style: disc;
  padding-left: 0.5rem;
}

.doc-content ol {
  list-style: decimal;
}

.doc-content ul li {
  display: list-item;
}

.doc-content li {
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.doc-content a {
  color: #5865f2;
  text-decoration: none;
}

.doc-content a:hover {
  text-decoration: underline;
}

.doc-content blockquote {
  border-left: 3px solid #5865f2;
  padding-left: 1rem;
  margin: 1rem 0;
  color: var(--text-3);
  font-style: italic;
}

.doc-content strong {
  color: var(--text-1);
  font-weight: 600;
}

.doc-content hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 2rem 0;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .hero-glow {
    width: 300px;
    height: 300px;
  }

  .func-grid {
    grid-template-columns: 1fr;
  }
}
