/* ============================================================
   UIstate Docs — Shared Stylesheet
   ============================================================ */

:root {
  --bg: #ffffff;
  --bg-secondary: #f8fafc;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --code-bg: #f1f5f9;
  --code-block-bg: #0f172a;
  --code-block-text: #e2e8f0;
  --nav-width: 240px;
  --header-height: 56px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-secondary: #1e293b;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #334155;
  --accent: #60a5fa;
  --accent-hover: #93bbfd;
  --code-bg: #1e293b;
  --code-block-bg: #020617;
  --code-block-text: #e2e8f0;
}

/* Smooth transition only on intentional toggle — not on page load */
.theme-transitioning,
.theme-transitioning *,
.theme-transitioning *::before,
.theme-transitioning *::after {
  transition: background 0.3s ease, color 0.2s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* ---- Header ---- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  z-index: 100;
  gap: 1.5rem;
}

.site-header .logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

.site-header .logo:hover { color: var(--accent); text-decoration: none; }

.site-header nav { display: flex; gap: 1.25rem; }

.site-header nav a {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.25rem 0;
}

.site-header nav a:hover,
.site-header nav a.active {
  color: var(--accent);
  text-decoration: none;
}

.header-right {
  margin-left: auto;
  display: flex;
  gap: 1rem;
  align-items: center;
}

.header-right a {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Theme toggle button */
#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 1.1rem;
  width: 2rem;
  height: 2rem;
  border-radius: 0.375rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}

#theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---- Sidebar ---- */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--nav-width);
  padding: 1.5rem 1rem;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--bg-secondary);
}

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

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

.sidebar ul { list-style: none; }

.sidebar li a {
  display: block;
  padding: 0.3rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  border-radius: 0.25rem;
  text-decoration: none;
}

.sidebar li a:hover { color: var(--text); background: var(--border); text-decoration: none; }
.sidebar li a.active { color: var(--accent); font-weight: 500; }

/* ---- Main content ---- */
.main {
  margin-left: var(--nav-width);
  margin-top: var(--header-height);
  max-width: 720px;
  padding: 2rem 2.5rem 4rem;
}

/* ---- Landing (no sidebar) ---- */
.main.landing {
  margin-left: 0;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  padding-top: 3rem;
}

/* ---- Typography ---- */
h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.75rem; line-height: 1.3; }
h2 { font-size: 1.35rem; font-weight: 600; margin-top: 2.5rem; margin-bottom: 0.5rem; padding-bottom: 0.35rem; border-bottom: 1px solid var(--border); }
h3 { font-size: 1.1rem; font-weight: 600; margin-top: 1.75rem; margin-bottom: 0.4rem; }
h4 { font-size: 0.95rem; font-weight: 600; margin-top: 1.25rem; margin-bottom: 0.3rem; }

p { margin-bottom: 0.75rem; }
ul, ol { margin-bottom: 0.75rem; padding-left: 1.5rem; }
li { margin-bottom: 0.25rem; }

/* Inline code */
code {
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, monospace;
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

/* Code blocks */
pre {
  background: var(--code-block-bg);
  color: var(--code-block-text);
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  line-height: 1.55;
}

pre code {
  background: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

/* ---- Tables ---- */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

/* ---- Hero (landing page) ---- */
.hero {
  text-align: center;
  padding: 3rem 0 2rem;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.hero .tagline {
  font-size: 1.15rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.hero .cta {
  display: inline-flex;
  gap: 0.75rem;
}

.hero .cta a {
  display: inline-block;
  padding: 0.6rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
}

.hero .cta .primary {
  background: var(--accent);
  color: #fff;
}

.hero .cta .primary:hover { background: var(--accent-hover); }

.hero .cta .secondary {
  border: 1px solid var(--border);
  color: var(--text);
}

.hero .cta .secondary:hover { border-color: var(--accent); color: var(--accent); }

/* Install snippet */
.install {
  background: var(--code-block-bg);
  color: var(--code-block-text);
  display: inline-block;
  padding: 0.5rem 1.25rem;
  border-radius: 0.5rem;
  font-family: monospace;
  font-size: 0.9rem;
  margin-bottom: 2rem;
  min-width: 290px;
}

/* ---- Feature cards (landing) ---- */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.25rem;
  margin: 2rem 0;
}

.feature-card {
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--bg-secondary);
}

.feature-card h3 {
  margin-top: 0;
  font-size: 1rem;
  margin-bottom: 0.35rem;
}

.feature-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0;
}

/* ---- API signature ---- */
.api-sig {
  font-family: monospace;
  font-size: 0.95rem;
  background: var(--code-bg);
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  border-left: 3px solid var(--accent);
  margin-bottom: 0.75rem;
}

/* ---- Version badge ---- */
.version-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  padding: 0.15em 0.55em;
  border-radius: 1rem;
  vertical-align: middle;
  margin-left: 0.5rem;
  position: relative;
  top: -2px;
  letter-spacing: 0.02em;
}

/* ---- Copy button on install blocks ---- */
.install-wrap {
  position: relative;
  display: inline-block;
}

.install-wrap pre {
  margin-bottom: 0;
  padding-right: 3.5rem;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--code-block-text);
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  cursor: pointer;
  font-family: system-ui, sans-serif;
  transition: background 0.15s, border-color 0.15s;
}

.copy-btn:hover {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.35);
}

.copy-btn.copied {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
}

/* ---- Star link in header ---- */
.star-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 0.2rem 0.6rem;
  border-radius: 0.375rem;
  transition: border-color 0.15s, color 0.15s;
}

.star-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 1.5rem 1rem; }
  .hero h1 { font-size: 1.75rem; }
  .features { grid-template-columns: 1fr; }
}
