/* MelodAI Project Documentation — standalone HTML/CSS */

:root {
  --bg-deep: #040811;
  --bg-mid: #060b18;
  --bg-card: #0f0a1f;
  --bg-card-alt: #12082a;
  --bg-code: rgba(0, 0, 0, 0.35);
  --border: rgba(255, 255, 255, 0.1);
  --border-accent: rgba(167, 139, 250, 0.25);
  --text: #cbd5e1;
  --text-muted: #94a3b8;
  --text-heading: #f8fafc;
  --accent: #a78bfa;
  --accent-bright: #c4b5fd;
  --cyan: #22d3ee;
  --emerald: #34d399;
  --amber: #fbbf24;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "Segoe UI Mono", Consolas, monospace;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --sidebar-width: 280px;
  --header-height: auto;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  background: radial-gradient(circle at top, #1a1033 0%, var(--bg-mid) 45%, var(--bg-deep) 100%);
  min-height: 100vh;
}

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

a:hover {
  text-decoration: underline;
}

code,
kbd {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: rgba(167, 139, 250, 0.12);
  color: var(--cyan);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

strong {
  color: var(--text-heading);
  font-weight: 600;
}

/* Layout */
.doc-page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.doc-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.doc-brand {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.35rem;
}

.doc-topbar h1 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
  font-weight: 800;
  color: var(--text-heading);
  line-height: 1.25;
}

.doc-lead {
  margin: 0.75rem 0 0;
  max-width: 52rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.doc-topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid var(--border-accent);
  background: transparent;
  color: var(--accent-bright);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.btn:hover {
  background: rgba(167, 139, 250, 0.12);
  text-decoration: none;
}

.btn-primary {
  background: rgba(167, 139, 250, 0.15);
}

.btn-ghost {
  border-color: var(--border);
  color: var(--text);
}

.doc-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 1024px) {
  .doc-grid {
    grid-template-columns: var(--sidebar-width) 1fr;
    align-items: start;
  }
}

/* Sidebar */
.doc-sidebar {
  position: sticky;
  top: 1rem;
  padding: 1.25rem;
  background: #0d0820;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

.doc-sidebar h2 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--text-heading);
}

.doc-toc {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
}

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

.doc-toc a {
  display: block;
  padding: 0.25rem 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
}

.doc-toc a:hover,
.doc-toc a.is-active {
  color: var(--accent-bright);
  font-weight: 600;
}

.doc-nav-section {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.doc-nav-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

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

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

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

.doc-nav-links a:hover,
.doc-nav-links a[aria-current="page"] {
  color: var(--accent-bright);
  font-weight: 600;
  text-decoration: none;
}

.doc-menu-toggle {
  display: flex;
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-heading);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

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

  .doc-sidebar.is-collapsed-mobile {
    display: block !important;
  }
}

@media (max-width: 1023px) {
  .doc-sidebar:not(.is-open) {
    display: none;
  }
}

/* Main content */
.doc-main {
  min-width: 0;
}

.doc-section {
  margin-bottom: 1.25rem;
  padding: 1.5rem 1.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  scroll-margin-top: 1.5rem;
}

.doc-section h2 {
  margin: 0 0 1rem;
  font-size: clamp(1.2rem, 2.5vw, 1.65rem);
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.3;
}

.doc-section h3 {
  margin: 1.25rem 0 0.5rem;
  font-size: 1.05rem;
  color: var(--text-heading);
}

.doc-section p {
  margin: 0 0 1rem;
}

.doc-section p:last-child {
  margin-bottom: 0;
}

.doc-section ul,
.doc-section ol {
  margin: 0 0 1rem;
  padding-left: 1.35rem;
}

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

.doc-section li::marker {
  color: var(--accent);
}

/* Cards grid (index) */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin: 1rem 0;
}

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

.doc-card {
  display: block;
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-accent);
  background: rgba(167, 139, 250, 0.05);
  text-decoration: none;
  transition: background 0.2s, transform 0.2s;
}

.doc-card:hover {
  background: rgba(167, 139, 250, 0.12);
  transform: translateY(-2px);
  text-decoration: none;
}

.doc-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  color: var(--text-heading);
}

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

.doc-card--emerald {
  border-color: rgba(52, 211, 153, 0.25);
  background: rgba(52, 211, 153, 0.05);
}

.doc-card--emerald:hover {
  background: rgba(52, 211, 153, 0.1);
}

.doc-card--indigo {
  border-color: rgba(99, 102, 241, 0.25);
  background: rgba(99, 102, 241, 0.05);
}

.doc-card--indigo:hover {
  background: rgba(99, 102, 241, 0.1);
}

.doc-card--amber {
  border-color: rgba(251, 191, 36, 0.25);
  background: rgba(251, 191, 36, 0.05);
}

.doc-card--amber:hover {
  background: rgba(251, 191, 36, 0.1);
}

.doc-card--fuchsia {
  border-color: rgba(217, 70, 239, 0.25);
  background: rgba(217, 70, 239, 0.05);
  grid-column: 1 / -1;
}

.doc-card--fuchsia:hover {
  background: rgba(217, 70, 239, 0.1);
}

/* Alerts */
.alert {
  padding: 0.85rem 1rem;
  margin: 1rem 0;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.alert--warning {
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #fde68a;
}

.alert--info {
  background: rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.25);
  color: #a5f3fc;
}

/* Code blocks */
.code-block {
  margin: 0.75rem 0;
  padding: 0.85rem 1rem;
  background: var(--bg-code);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.code-block pre,
.code-block code {
  margin: 0;
  padding: 0;
  background: none;
  color: #e9d5ff;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-all;
  flex: 1 1 200px;
}

.code-block .copy-btn {
  flex-shrink: 0;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-bright);
  background: transparent;
  border: 1px solid var(--border-accent);
  border-radius: 6px;
  cursor: pointer;
}

.code-block .copy-btn:hover {
  background: rgba(167, 139, 250, 0.12);
}

.code-block .copy-btn.is-copied {
  color: var(--emerald);
  border-color: rgba(52, 211, 153, 0.4);
}

.code-blocks {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin: 0.75rem 0 1rem;
}

/* Tables */
.env-table-wrap {
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.env-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

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

.env-table th {
  background: rgba(167, 139, 250, 0.1);
  color: var(--accent-bright);
  font-weight: 600;
}

.env-table td:first-child {
  font-family: var(--font-mono);
  color: var(--cyan);
  white-space: nowrap;
}

.env-table tr:last-child td {
  border-bottom: none;
}

/* Checklist */
.checklist {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.checklist li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 0.4rem;
}

.checklist li::before {
  content: "☐";
  position: absolute;
  left: 0;
  color: var(--accent);
}

/* Footer */
.doc-footer {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

@media print {
  .doc-sidebar,
  .doc-topbar-actions,
  .copy-btn,
  .doc-menu-toggle {
    display: none !important;
  }

  .doc-grid {
    grid-template-columns: 1fr;
  }

  body {
    background: #fff;
    color: #111;
  }

  .doc-section {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }
}
