/* ──────────────────────────────────────────────
   Storeharmony Docs — Design System
   ────────────────────────────────────────────── */

:root {
  /* Light theme */
  --bg: #ffffff;
  --bg-soft: #f8f9fa;
  --bg-sidebar: #f4f5f7;
  --bg-code: #f6f8fa;
  --bg-callout: #f0f7ff;
  --bg-callout-warn: #fff8f0;
  --bg-callout-tip: #f0faf4;
  --bg-hover: rgba(0,0,0,0.04);
  --bg-active: rgba(232,93,4,0.08);
  --border: #e5e7eb;
  --border-light: #f0f0f0;
  --text: #1a1a2e;
  --text-secondary: #5a5a72;
  --text-muted: #8b8ba0;
  --accent: #e85d04;
  --accent-hover: #d45300;
  --accent-soft: rgba(232,93,4,0.1);
  --code-text: #24292f;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', monospace;
  --topbar-h: 56px;
  --sidebar-w: 280px;
  --toc-w: 220px;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --bg-soft: #161822;
  --bg-sidebar: #12141e;
  --bg-code: #1a1d2e;
  --bg-callout: #141c2e;
  --bg-callout-warn: #221a10;
  --bg-callout-tip: #0e1f16;
  --bg-hover: rgba(255,255,255,0.06);
  --bg-active: rgba(232,93,4,0.15);
  --border: #2a2d3a;
  --border-light: #1e2030;
  --text: #e4e4ed;
  --text-secondary: #a0a0b8;
  --text-muted: #6b6b82;
  --accent: #ff7a1a;
  --accent-hover: #ff8f3d;
  --accent-soft: rgba(255,122,26,0.15);
  --code-text: #c9d1d9;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 24px); }
body { font-family: var(--font-sans); background: var(--bg); color: var(--text); line-height: 1.6; -webkit-font-smoothing: antialiased; }

/* ── Top Bar ── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.topbar__left { display: flex; align-items: center; gap: 12px; }
.topbar__menu-btn { display: none; background: none; border: none; color: var(--text); cursor: pointer; padding: 6px; border-radius: var(--radius-sm); }
.topbar__menu-btn:hover { background: var(--bg-hover); }
.topbar__brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.topbar__logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, #e85d04, #ff7a1a);
  display: grid; place-items: center;
  font-weight: 800; font-size: 0.85rem; color: #fff;
}
.topbar__title { font-weight: 700; font-size: 0.95rem; }
.topbar__title-thin { font-weight: 400; color: var(--text-muted); }
.topbar__center { flex: 1; max-width: 480px; margin: 0 24px; }
.topbar__right { display: flex; align-items: center; gap: 12px; }
.topbar__link { font-size: 0.85rem; color: var(--text-secondary); text-decoration: none; }
.topbar__link:hover { color: var(--accent); }
.topbar__theme-btn { background: none; border: none; color: var(--text-secondary); cursor: pointer; padding: 6px; border-radius: var(--radius-sm); }
.topbar__theme-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ── Search ── */
.search-box {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--bg-soft);
  cursor: text; transition: border-color 0.15s;
}
.search-box:focus-within { border-color: var(--accent); }
.search-box__icon { color: var(--text-muted); flex-shrink: 0; }
.search-box__input { flex: 1; border: none; background: none; outline: none; font: inherit; font-size: 0.88rem; color: var(--text); }
.search-box__input::placeholder { color: var(--text-muted); }
.search-box__kbd { font-family: var(--font-mono); font-size: 0.72rem; padding: 2px 6px; border-radius: 4px; background: var(--bg); border: 1px solid var(--border); color: var(--text-muted); }

/* ── Layout ── */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
}

/* ── Left Sidebar ── */
.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0;
  width: var(--sidebar-w);
  overflow-y: auto; overflow-x: hidden;
  padding: 20px 16px;
  border-right: 1px solid var(--border);
  background: var(--bg-sidebar);
  transition: transform 0.25s ease;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.nav-section { margin-bottom: 24px; }
.nav-section__title {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); padding: 0 12px; margin-bottom: 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: var(--radius-sm);
  font-size: 0.88rem; color: var(--text-secondary);
  text-decoration: none; cursor: pointer; border: none; background: none;
  width: 100%; text-align: left; transition: all 0.12s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--bg-active); color: var(--accent); font-weight: 600; }
.nav-item__icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.6; }
.nav-item.active .nav-item__icon { opacity: 1; }

/* ── Main Content ── */
.main {
  grid-column: 2;
  padding: 40px 56px 80px;
  max-width: 100%;
  min-width: 0;
}

.article { max-width: 780px; }

/* Article typography */
.article h1 { font-size: 2rem; font-weight: 800; line-height: 1.2; margin-bottom: 8px; }
.article .subtitle { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 32px; line-height: 1.6; }
.article .meta-bar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 32px; }
.article .meta-pill { font-size: 0.78rem; padding: 4px 10px; border-radius: 20px; background: var(--bg-soft); border: 1px solid var(--border-light); color: var(--text-muted); }

.article h2 {
  font-size: 1.4rem; font-weight: 700; margin-top: 48px; margin-bottom: 16px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border-light);
  scroll-margin-top: calc(var(--topbar-h) + 24px);
}
.article h3 { font-size: 1.1rem; font-weight: 600; margin-top: 32px; margin-bottom: 12px; scroll-margin-top: calc(var(--topbar-h) + 24px); }
.article h4 { font-size: 0.95rem; font-weight: 600; margin-top: 24px; margin-bottom: 8px; }

.article p { margin-bottom: 16px; line-height: 1.75; color: var(--text); }
.article p + p { margin-top: 0; }

.article a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.article a:hover { color: var(--accent-hover); }

.article strong { font-weight: 600; }
.article em { font-style: italic; }

.article ul, .article ol { margin-bottom: 16px; padding-left: 24px; }
.article li { margin-bottom: 6px; line-height: 1.7; color: var(--text); }
.article li::marker { color: var(--text-muted); }

.article img {
  max-width: 100%; border-radius: var(--radius-md);
  border: 1px solid var(--border); margin: 16px 0;
  box-shadow: var(--shadow-sm);
}

.article .img-caption {
  font-size: 0.84rem; color: var(--text-muted); text-align: center;
  margin-top: -8px; margin-bottom: 16px;
}

/* Code */
.article code {
  font-family: var(--font-mono); font-size: 0.88em;
  padding: 2px 6px; border-radius: 4px;
  background: var(--bg-code); color: var(--code-text);
}
.article pre {
  margin: 16px 0; padding: 16px 20px;
  border-radius: var(--radius-md); background: var(--bg-code);
  border: 1px solid var(--border-light);
  overflow-x: auto; line-height: 1.6;
}
.article pre code { padding: 0; background: none; font-size: 0.85rem; }

/* Callouts */
.callout {
  margin: 20px 0; padding: 16px 20px;
  border-radius: var(--radius-md);
  border-left: 4px solid;
  font-size: 0.92rem; line-height: 1.7;
}
.callout-info { background: var(--bg-callout); border-color: #3b82f6; }
.callout-warn { background: var(--bg-callout-warn); border-color: #f59e0b; }
.callout-tip { background: var(--bg-callout-tip); border-color: #10b981; }
.callout-danger { background: rgba(239,68,68,0.08); border-color: #ef4444; }
.callout__title { font-weight: 600; margin-bottom: 4px; }
.callout-info .callout__title { color: #3b82f6; }
.callout-warn .callout__title { color: #d97706; }
.callout-tip .callout__title { color: #059669; }
.callout-danger .callout__title { color: #dc2626; }

/* Tables */
.article table {
  width: 100%; border-collapse: collapse; margin: 16px 0;
  font-size: 0.9rem;
}
.article th, .article td {
  padding: 10px 14px; text-align: left;
  border-bottom: 1px solid var(--border-light);
}
.article th { font-weight: 600; font-size: 0.84rem; color: var(--text-secondary); background: var(--bg-soft); }
.article tr:hover td { background: var(--bg-hover); }

/* Embedded video */
.video-embed {
  position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;
  margin: 24px 0; border-radius: var(--radius-md); box-shadow: var(--shadow-md);
}
.video-embed iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; border-radius: var(--radius-md); }

/* Badges / tags */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 3px 8px; border-radius: 4px;
}
.badge-new { background: #dcfce7; color: #15803d; }
.badge-beta { background: #fef3c7; color: #92400e; }
.badge-api { background: #dbeafe; color: #1e40af; }

/* Steps */
.steps { counter-reset: step; margin: 24px 0; }
.step { display: flex; gap: 16px; margin-bottom: 24px; counter-increment: step; }
.step::before {
  content: counter(step); flex-shrink: 0;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.85rem;
}
.step__body { flex: 1; padding-top: 4px; }
.step__body h4 { margin-top: 0; }

/* ── Right Sidebar (TOC) ── */
.toc {
  position: fixed; top: var(--topbar-h); bottom: 0; right: 0;
  width: var(--toc-w);
  overflow-y: auto; padding: 24px 16px;
  border-left: 1px solid var(--border);
}
.toc::-webkit-scrollbar { width: 4px; }
.toc::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.toc__header {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); margin-bottom: 12px;
}
.toc__item {
  display: block; padding: 4px 0; font-size: 0.82rem;
  color: var(--text-muted); text-decoration: none; transition: color 0.12s;
  border-left: 2px solid transparent; padding-left: 12px; margin-left: -1px;
}
.toc__item:hover { color: var(--text); }
.toc__item.active { color: var(--accent); border-left-color: var(--accent); font-weight: 500; }
.toc__item--h3 { padding-left: 24px; }

/* ── Search Overlay ── */
.search-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
  display: grid; place-items: start center; padding-top: 15vh;
}
.search-overlay[hidden] { display: none; }
.search-modal {
  width: 90%; max-width: 560px;
  background: var(--bg); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  overflow: hidden;
}
.search-modal__input {
  width: 100%; padding: 16px 20px;
  border: none; border-bottom: 1px solid var(--border);
  background: var(--bg); color: var(--text);
  font: inherit; font-size: 1rem; outline: none;
}
.search-modal__results { max-height: 400px; overflow-y: auto; }
.search-result {
  padding: 12px 20px; cursor: pointer; border-bottom: 1px solid var(--border-light);
  transition: background 0.1s;
}
.search-result:hover, .search-result.focused { background: var(--bg-active); }
.search-result__title { font-weight: 600; font-size: 0.92rem; }
.search-result__section { font-size: 0.8rem; color: var(--text-muted); }
.search-result__snippet { font-size: 0.84rem; color: var(--text-secondary); margin-top: 2px; }
.search-result__snippet mark { background: var(--accent-soft); color: var(--accent); border-radius: 2px; }
.search-modal__footer {
  padding: 10px 20px; font-size: 0.76rem; color: var(--text-muted);
  border-top: 1px solid var(--border); background: var(--bg-soft);
}
.search-modal__footer kbd {
  font-family: var(--font-mono); font-size: 0.7rem;
  padding: 1px 5px; border-radius: 3px;
  background: var(--bg); border: 1px solid var(--border);
}

/* ── Responsive ── */
@media (max-width: 1200px) {
  .toc { display: none; }
  .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
}
@media (max-width: 768px) {
  .topbar__menu-btn { display: block; }
  .topbar__center { display: none; }
  .sidebar { transform: translateX(-100%); z-index: 90; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .layout { grid-template-columns: 1fr; }
  .main { padding: 24px 20px 60px; }
  .article h1 { font-size: 1.6rem; }
  .article h2 { font-size: 1.2rem; }
}
