/* Ardh Kumbh 2027 — Documentation site
   Editorial / reference · light + dark + responsive */

/* ----- Light theme (default + explicit) ----- */
:root,
html[data-theme="light"] {
  --bg: #f7f5f2;
  --bg-elevated: #fffef9;
  --surface: #ffffff;
  --ink: #14120f;
  --ink-muted: #5c5852;
  --ink-faint: #8a847a;
  --border: #e6e1d8;
  --border-strong: #cfc7b9;
  --accent: #9a3412;
  --accent-soft: rgba(154, 52, 18, 0.1);
  --accent-hover: #7f2d0f;
  --heading: #1c2d41;
  --navy-soft: rgba(28, 45, 65, 0.08);
  --code-bg: rgba(28, 45, 65, 0.08);
  --pre-bg: #1a1814;
  --pre-fg: #e8e4dc;
  --pre-border: #2a2620;
  --shadow: 0 1px 2px rgba(20, 18, 15, 0.06),
    0 8px 28px rgba(20, 18, 15, 0.08);
  --shadow-sidebar: 0 1px 0 rgba(20, 18, 15, 0.06);
  --focus-ring: rgba(154, 52, 18, 0.45);
  --radius: 10px;
  --radius-sm: 6px;
  --font-sans: "DM Sans", system-ui, -apple-system, sans-serif;
  --font-serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sidebar-w: min(280px, 100%);
  --content-max: 52rem;
  --lh-body: 1.65;
  --lh-tight: 1.25;
  --tap-min: 44px;
}

/* ----- Dark theme ----- */
html[data-theme="dark"] {
  --bg: #0f0e0d;
  --bg-elevated: #161412;
  --surface: #1c1a17;
  --ink: #f2ede6;
  --ink-muted: #b0a99d;
  --ink-faint: #7d766b;
  --border: #2f2b26;
  --border-strong: #3f3a34;
  --accent: #ea8c5c;
  --accent-soft: rgba(234, 140, 92, 0.12);
  --accent-hover: #f0a47a;
  --heading: #d4e2f5;
  --navy-soft: rgba(212, 226, 245, 0.08);
  --code-bg: rgba(212, 226, 245, 0.1);
  --pre-bg: #0d0c0b;
  --pre-fg: #e8e2d9;
  --pre-border: #3a3530;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 40px rgba(0, 0, 0, 0.35);
  --shadow-sidebar: 0 1px 0 rgba(255, 255, 255, 0.06);
  --focus-ring: rgba(234, 140, 92, 0.55);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0f0e0d;
    --bg-elevated: #161412;
    --surface: #1c1a17;
    --ink: #f2ede6;
    --ink-muted: #b0a99d;
    --ink-faint: #7d766b;
    --border: #2f2b26;
    --border-strong: #3f3a34;
    --accent: #ea8c5c;
    --accent-soft: rgba(234, 140, 92, 0.12);
    --accent-hover: #f0a47a;
    --heading: #d4e2f5;
    --navy-soft: rgba(212, 226, 245, 0.08);
    --code-bg: rgba(212, 226, 245, 0.1);
    --pre-bg: #0d0c0b;
    --pre-fg: #e8e2d9;
    --pre-border: #3a3530;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 40px rgba(0, 0, 0, 0.35);
    --shadow-sidebar: 0 1px 0 rgba(255, 255, 255, 0.06);
    --focus-ring: rgba(234, 140, 92, 0.55);
  }
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: clamp(0.9375rem, 0.9rem + 0.2vw, 1rem);
  line-height: var(--lh-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

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

/* Focus visibility */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

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

/* ----- Theme switcher ----- */
.theme-switcher {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.theme-switcher-label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  margin-bottom: 0.5rem;
}

.theme-switcher-btns {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.theme-btn {
  flex: 1 1 auto;
  min-width: 0;
  min-height: var(--tap-min);
  padding: 0.35rem 0.5rem;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.theme-btn:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}

.theme-btn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

@media (min-width: 960px) {
  .theme-btn {
    min-height: 36px;
  }
}

/* ----- Layout ----- */
.doc-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
}

@media (min-width: 960px) {
  .doc-shell {
    grid-template-columns: var(--sidebar-w) 1fr;
  }
}

.doc-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  max-height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1.25rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sidebar);
}

@media (min-width: 960px) {
  .doc-sidebar {
    border-bottom: none;
    border-right: 1px solid var(--border);
    box-shadow: none;
    padding: 1.75rem 1.25rem 2rem;
  }
}

.doc-brand {
  display: block;
  margin-bottom: 0.35rem;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(1.1rem, 1rem + 0.5vw, 1.25rem);
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
}

.doc-brand:hover {
  color: var(--accent);
}

.doc-brand-meta {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
  margin-bottom: 0.65rem;
}

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

.doc-nav li {
  margin: 0.12rem 0;
}

.doc-nav a {
  display: flex;
  align-items: center;
  min-height: var(--tap-min);
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  text-decoration: none;
  font-size: 0.9rem;
}

@media (min-width: 960px) {
  .doc-nav a {
    min-height: 0;
    padding: 0.45rem 0.6rem;
  }
}

.doc-nav a:hover {
  background: var(--navy-soft);
  color: var(--ink);
}

.doc-nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.doc-nav-section {
  margin-top: 1.25rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  padding: 0 0.65rem;
}

.doc-main {
  width: 100%;
  max-width: min(var(--content-max) + 4rem, 100%);
  margin-inline: auto;
  padding: clamp(1.25rem, 4vw, 2.75rem) clamp(1rem, 4vw, 2.5rem)
    clamp(2.5rem, 6vw, 5rem);
  padding-left: max(clamp(1rem, 4vw, 2.5rem), env(safe-area-inset-left));
  padding-right: max(clamp(1rem, 4vw, 2.5rem), env(safe-area-inset-right));
  padding-bottom: max(clamp(2.5rem, 6vw, 5rem), env(safe-area-inset-bottom));
}

.doc-header {
  margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
  padding-bottom: clamp(1.25rem, 3vw, 1.75rem);
  border-bottom: 1px solid var(--border);
}

.doc-kicker {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin: 0 0 0.5rem;
}

.doc-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(1.5rem, 1.2rem + 2.5vw, 2.35rem);
  letter-spacing: -0.03em;
  line-height: var(--lh-tight);
  margin: 0 0 0.75rem;
  color: var(--heading);
  word-wrap: break-word;
}

.doc-lead {
  margin: 0;
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.1rem);
  color: var(--ink-muted);
  max-width: 40em;
}

/* ----- Content typography ----- */
.doc-content h2 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(1.15rem, 1rem + 0.6vw, 1.35rem);
  margin: clamp(1.75rem, 4vw, 2.25rem) 0 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  color: var(--heading);
  scroll-margin-top: 1rem;
}

.doc-content h2:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.doc-content h3 {
  font-size: clamp(0.95rem, 0.9rem + 0.2vw, 1rem);
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
  color: var(--ink);
  scroll-margin-top: 1rem;
}

.doc-content p {
  margin: 0.65rem 0;
}

.doc-content ul,
.doc-content ol {
  margin: 0.65rem 0;
  padding-left: 1.25rem;
}

@media (max-width: 380px) {
  .doc-content ul,
  .doc-content ol {
    padding-left: 1.1rem;
  }
}

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

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

/* ----- Tables ----- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1rem 0 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.doc-content table {
  width: 100%;
  min-width: min(100%, 520px);
  border-collapse: collapse;
  font-size: clamp(0.8rem, 0.75rem + 0.2vw, 0.875rem);
}

.doc-content th,
.doc-content td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  hyphens: auto;
}

.doc-content th {
  font-weight: 600;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  background: var(--bg-elevated);
  white-space: nowrap;
}

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

.doc-content code {
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, monospace;
  font-size: 0.84em;
  background: var(--code-bg);
  padding: 0.12em 0.4em;
  border-radius: 4px;
  word-break: break-word;
}

.doc-content pre {
  margin: 1rem 0;
  padding: clamp(0.85rem, 2vw, 1rem) clamp(0.9rem, 2.5vw, 1.1rem);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  border: 1px solid var(--pre-border);
  background: var(--pre-bg);
  color: var(--pre-fg);
  font-size: clamp(0.72rem, 0.65rem + 0.35vw, 0.8rem);
  line-height: 1.55;
}

.doc-content pre code {
  background: none;
  padding: 0;
  color: inherit;
  word-break: normal;
}

/* ----- Callouts & cards ----- */
.callout {
  margin: 1.25rem 0;
  padding: clamp(0.9rem, 2vw, 1rem) clamp(1rem, 2.5vw, 1.1rem);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

.callout-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  margin: 0 0 0.35rem;
}

.callout p {
  margin: 0;
  font-size: 0.95rem;
}

.callout.accent {
  border-color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  background: var(--accent-soft);
}

.card-grid {
  display: grid;
  gap: clamp(0.75rem, 2vw, 1rem);
  margin-top: clamp(1.25rem, 3vw, 2rem);
}

@media (min-width: 560px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1100px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.1rem;
  }
}

.doc-card {
  display: block;
  padding: clamp(1rem, 2.5vw, 1.25rem) clamp(1.1rem, 2.5vw, 1.35rem);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  min-height: var(--tap-min);
}

@media (hover: hover) and (pointer: fine) {
  .doc-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
    box-shadow: var(--shadow), 0 4px 12px rgba(0, 0, 0, 0.06);
  }

  html[data-theme="dark"] .doc-card:hover {
    box-shadow: var(--shadow), 0 4px 20px rgba(0, 0, 0, 0.25);
  }
}

.doc-card:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.doc-card h3 {
  margin: 0 0 0.35rem;
  font-family: var(--font-serif);
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.1rem);
  color: var(--heading);
}

.doc-card p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.doc-footer {
  margin-top: clamp(2rem, 5vw, 3rem);
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--ink-faint);
}

.doc-footer a {
  margin-right: 0.35rem;
}

/* ----- Mobile nav toggle ----- */
.menu-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: var(--tap-min);
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.65rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.menu-toggle:hover {
  border-color: var(--border-strong);
}

@media (min-width: 960px) {
  .menu-toggle {
    display: none;
  }
}

.doc-sidebar-inner.collapsed .doc-nav {
  display: none;
}

@media (min-width: 960px) {
  .doc-sidebar-inner.collapsed .doc-nav {
    display: block;
  }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .doc-card {
    transition: none;
  }
  .doc-card:hover {
    transform: none;
  }
}

/* ----- Development plan: table of contents ----- */
.plan-toc {
  margin: 0 0 2rem;
  padding: 1.1rem 1.25rem 1.15rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.doc-content .plan-toc h2 {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  padding: 0;
  border: none;
  color: var(--heading);
}

.plan-toc ul {
  margin: 0;
  padding-left: 1.15rem;
  font-size: 0.9rem;
}

.plan-toc li {
  margin: 0.4rem 0;
}

.plan-toc a {
  text-decoration: none;
}

.plan-toc a:hover {
  text-decoration: underline;
}

.plan-phase {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-right: 0.5rem;
  vertical-align: middle;
}

/* Print */
@media print {
  .doc-sidebar,
  .theme-switcher,
  .menu-toggle {
    display: none !important;
  }
  .doc-shell {
    display: block;
  }
  .doc-main {
    max-width: none;
    padding: 0;
  }
  html[data-theme="dark"] {
    --ink: #000;
    --heading: #000;
    --bg: #fff;
    --surface: #fff;
  }
}
