:root {
  color-scheme: light;
}

/* Prevent Alpine.js menu flash */
[x-cloak] { display: none !important; }

body {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ── Navigation ── */
.nav-link {
  color: #374151;
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  transition: color 150ms ease, background-color 150ms ease;
  font-weight: 500;
}

.nav-link:hover {
  color: #2563eb;
  background-color: rgba(37, 99, 235, 0.07);
}

/* ── Article / Markdown ── */
article h1,
article h2,
article h3 {
  font-weight: 700;
  color: #111827;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  scroll-margin-top: 5rem;
}

article h1 { font-size: 1.875rem; }
article h2 { font-size: 1.375rem; border-bottom: 1px solid #e5e7eb; padding-bottom: 0.4rem; }
article h3 { font-size: 1.125rem; }

article p {
  color: #374151;
  line-height: 1.8;
  margin-bottom: 1rem;
}

article ul,
article ol {
  padding-left: 1.5rem;
  color: #374151;
  margin-bottom: 1rem;
  line-height: 1.8;
}

article ul  { list-style-type: disc; }
article ol  { list-style-type: decimal; }
article li  { margin-bottom: 0.25rem; }
article strong { color: #111827; }
article a   { color: #2563eb; text-decoration: underline; }

article pre {
  background-color: #f8fafc;
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  overflow-x: auto;
  margin-bottom: 1rem;
}

article code {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 0.875rem;
  background-color: #f1f5f9;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  color: #0f172a;
}

article pre code {
  background: none;
  padding: 0;
}

/* ── Cards ── */
.card {
  border: 1px solid #e5e7eb;
  background: #ffffff;
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
  display: block;
}

.card:hover {
  border-color: #93c5fd;
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.1);
}

/* ── Code block (standalone) ── */
.code-block {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  background-color: #f8fafc;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  color: #1e293b;
  overflow-x: auto;
  font-size: 0.875rem;
}

/* ── Buttons ── */
.button-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: 9999px;
  background: linear-gradient(90deg, #2563eb, #1d4ed8);
  color: white;
  font-weight: 600;
  text-decoration: none;
  font-size: 0.9rem;
  transition: transform 120ms ease, box-shadow 150ms ease;
}

.button-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.3);
}

.button-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: 9999px;
  background: #ffffff;
  color: #374151;
  font-weight: 600;
  text-decoration: none;
  font-size: 0.9rem;
  border: 1px solid #d1d5db;
  transition: border-color 120ms ease, box-shadow 150ms ease, transform 120ms ease;
}

.button-secondary:hover {
  border-color: #93c5fd;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
  transform: translateY(-1px);
}

/* ── Hero gradient ── */
.hero-gradient {
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 60%, #fefce8 100%);
  border-radius: 20px;
  border: 1px solid #dbeafe;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.badge-blue   { background: #eff6ff; color: #1d4ed8; }
.badge-green  { background: #f0fdf4; color: #15803d; }
.badge-amber  { background: #fffbeb; color: #b45309; }
.badge-purple { background: #faf5ff; color: #7c3aed; }

/* ── TOC sidebar ── */
.toc { position: sticky; top: 5rem; }

.toc-link {
  display: block;
  font-size: 0.825rem;
  color: #6b7280;
  padding: 0.28rem 0.6rem;
  border-left: 2px solid #e5e7eb;
  line-height: 1.5;
  transition: color 120ms ease, border-color 120ms ease;
}

.toc-link:hover   { color: #2563eb; border-left-color: #93c5fd; }
.toc-link.active  { color: #2563eb; border-left-color: #2563eb; font-weight: 600; }
.toc-sublink      { padding-left: 1.25rem; }

/* ── Feature icon box ── */
.icon-box {
  width: 2.5rem; height: 2.5rem;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ── Mobile TOC (collapsible strip above article) ── */
.toc-mobile-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.65rem 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  transition: background 120ms ease;
}
.toc-mobile-btn:hover { background: #f1f5f9; }
.toc-mobile-btn svg  { transition: transform 200ms ease; flex-shrink: 0; }
.toc-mobile-btn[aria-expanded="true"] svg { transform: rotate(180deg); }

.toc-mobile-list {
  display: none;
  padding: 0.5rem 0.5rem 0.5rem 0.5rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-top: none;
  border-radius: 0 0 10px 10px;
  margin-top: -1px;
}
.toc-mobile-list.open { display: block; }

.toc-mobile-link {
  display: block;
  padding: 0.45rem 0.75rem;
  font-size: 0.825rem;
  color: #374151;
  border-radius: 6px;
  transition: background 100ms ease, color 100ms ease;
  line-height: 1.4;
}
.toc-mobile-link:hover  { background: #e0e7ff; color: #1d4ed8; }
.toc-mobile-sublink     { padding-left: 1.5rem; }

/* ── Touch: disable transform on cards and buttons ── */
@media (hover: none) {
  .card:hover {
    transform: none;
    box-shadow: none;
  }
  .button-primary:hover,
  .button-secondary:hover {
    transform: none;
  }
}

/* ── Responsive: tighter article padding on small screens ── */
@media (max-width: 640px) {
  #doc-article {
    padding: 1.25rem 1rem;
    border-radius: 14px;
  }
  #doc-article h1 {
    font-size: 1.5rem;
  }
}

/* ── Safe area insets for notched phones ── */
@supports (padding: env(safe-area-inset-left)) {
  header .max-w-6xl { padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }
  main   { padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }
}
