/* ── Cantrip Documentation ─────────────────────────────────────── */
/* Extends the shared tokens for prose-heavy pages.                 */

@import url("../tokens.css");

/* Page-specific overrides */
:root { --max-w: 820px; --sidebar-w: 220px; }

/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── Skip link ────────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 200;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
}

.skip-link:focus {
  top: 0.75rem;
  color: #fff;
}

/* ── Focus styles ─────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ── Navigation ───────────────────────────────────────────────── */
.doc-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

@supports not (backdrop-filter: blur(10px)) {
  .doc-nav { background: var(--bg); }
}

.doc-nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.doc-nav-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}

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

.doc-nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.doc-nav-links a {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.doc-nav-links a:hover { color: var(--text); }

.doc-nav-links .current { color: var(--accent); }

/* ── Mobile nav toggle ────────────────────────────────────────── */
.doc-nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
}

.doc-nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.doc-nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.doc-nav-toggle.open span:nth-child(2) { opacity: 0; }
.doc-nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 640px) {
  .doc-nav-toggle { display: flex; }

  .doc-nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    padding: 0.5rem 1.5rem 1rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    gap: 0;
  }

  .doc-nav-links.open { display: flex; }

  .doc-nav-links a {
    padding: 0.7rem 0;
    font-size: 1rem;
    border-bottom: 1px solid var(--border);
  }

  .doc-nav-links a:last-child { border-bottom: none; }
}

/* ── Layout ───────────────────────────────────────────────────── */
.doc-layout {
  display: flex;
  max-width: 1100px;
  margin: 0 auto;
  padding: 5rem 1.5rem 3rem;
  gap: 3rem;
}

.doc-sidebar {
  flex: 0 0 var(--sidebar-w);
  position: sticky;
  top: 5rem;
  align-self: flex-start;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
}

.doc-sidebar h4 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  margin-top: 1.25rem;
}

.doc-sidebar h4:first-child { margin-top: 0; }

.doc-sidebar ul {
  list-style: none;
  margin-bottom: 0.25rem;
}

.doc-sidebar li a {
  display: block;
  padding: 0.35rem 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.doc-sidebar li a:hover { color: var(--text); }
.doc-sidebar li a.current { color: var(--accent); font-weight: 600; }

.doc-content {
  flex: 1;
  min-width: 0;
  max-width: var(--max-w);
}

@media (max-width: 768px) {
  .doc-layout { flex-direction: column; gap: 1.5rem; }
  .doc-sidebar { position: static; flex: none; max-height: none; }
}

/* ── Prose ─────────────────────────────────────────────────────── */
.doc-content h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.doc-content .subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.doc-content h2 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.doc-content h3 {
  font-size: 1.15rem;
  font-weight: 650;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

.doc-content p {
  margin-bottom: 1rem;
}

.doc-content ul, .doc-content ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.doc-content li {
  margin-bottom: 0.35rem;
}

.doc-content li::marker {
  color: var(--text-muted);
}

/* ── Code ──────────────────────────────────────────────────────── */
.doc-content code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 4px;
  padding: 0.15em 0.4em;
}

.doc-content pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.25rem;
  position: relative;
}

.doc-content pre .copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.25rem 0.55rem;
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.doc-content pre:hover .copy-btn,
.doc-content pre .copy-btn:focus-visible {
  opacity: 1;
}

.doc-content pre .copy-btn:hover {
  color: var(--accent);
}

.doc-content pre .copy-btn.copied {
  color: var(--accent);
  opacity: 1;
}

.doc-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.88rem;
  line-height: 1.6;
}

.prompt { color: var(--accent); }
.comment { color: var(--text-muted); }
.dim { opacity: 0.6; }

/* ── Tables ────────────────────────────────────────────────────── */
.doc-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.25rem;
  font-size: 0.92rem;
}

.doc-content th {
  text-align: left;
  font-weight: 650;
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--border);
}

.doc-content td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

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

/* ── Callouts ──────────────────────────────────────────────────── */
.callout {
  background: var(--accent-bg);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.callout p { margin-bottom: 0; }

.callout-warn {
  background: var(--warn-bg);
  border-left-color: var(--warn);
}

/* ── Category Cards (index page) ──────────────────────────────── */
.doc-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.doc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.doc-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
}

.doc-card h3 {
  font-size: 1.1rem;
  font-weight: 650;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.doc-card p {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.doc-card ul {
  list-style: none;
  padding: 0;
}

.doc-card ul li {
  font-size: 0.88rem;
  color: var(--accent);
  padding: 0.15rem 0;
}

.doc-card-label {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

/* ── Definition list (reference pages) ─────────────────────────── */
.doc-content dl {
  margin-bottom: 1.25rem;
}

.doc-content dt {
  font-weight: 650;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  margin-top: 1rem;
}

.doc-content dd {
  margin-left: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}

/* ── Footer ────────────────────────────────────────────────────── */
.doc-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  margin-top: 3rem;
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.doc-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.doc-footer-inner a { color: var(--text-muted); }
.doc-footer-inner a:hover { color: var(--text); }

/* ── Breadcrumb ────────────────────────────────────────────────── */
.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { margin: 0 0.4rem; }

/* ── Reduced motion ───────────────────────────────────────────── */
@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;
  }
}
