/* ==========================================================================
   Metarium AI — mai.net
   Clean, professional dark theme inspired by the CMS docs
   ========================================================================== */

:root {
  --bg: #1a1a2e;
  --bg-card: #16213e;
  --bg-code: #0f3460;
  --border: #1a3a5c;
  --accent: #7ec8e3;
  --accent-hover: #5fb8d9;
  --text: #e0e0e0;
  --text-muted: #a0a0c0;
  --text-dim: #606080;
  --white: #ffffff;
  --green: #28a745;
  --blue: #007bff;
  --red: #dc3545;
  --orange: #fd7e14;
  --max-w: 960px;
  --radius: 8px;
  --radius-sm: 4px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

img { max-width: 100%; height: auto; }

/* ==========================================================================
   Layout
   ========================================================================== */

.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ==========================================================================
   Navigation
   ========================================================================== */

.nav {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--white);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.01em;
}

.nav-brand:hover { text-decoration: none; color: var(--white); }

.nav-logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--bg);
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 2px;
  align-items: center;
}

.nav-links a {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.nav-links a:hover {
  color: var(--accent);
  background: rgba(126, 200, 227, 0.08);
  text-decoration: none;
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  line-height: 1;
}

/* ==========================================================================
   Hero
   ========================================================================== */

.hero {
  text-align: center;
  padding: 4rem 1.5rem 3rem;
  max-width: var(--max-w);
  margin: 0 auto;
}

.hero-title {
  font-size: 2.75rem;
  font-weight: 800;
  color: var(--white);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 1rem;
}

.hero-accent { color: var(--accent); }

.hero-subtitle {
  color: var(--text-muted);
  font-size: 1.125rem;
  max-width: 560px;
  margin: 0 auto 0.5rem;
  line-height: 1.7;
}

.hero-cta {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 2rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 22px;
  border-radius: 6px;
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s;
  cursor: pointer;
  border: none;
  line-height: 1.4;
}

.btn:hover { text-decoration: none; transform: translateY(-1px); }

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}
.btn-primary:hover { background: var(--accent-hover); color: var(--bg); }

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: rgba(126, 200, 227, 0.08); border-color: var(--accent); color: var(--accent); }

/* ==========================================================================
   Sections
   ========================================================================== */

.section {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

.section + .section {
  border-top: 1px solid var(--border);
}

.section-title {
  color: var(--accent);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.section-subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 640px;
  margin-bottom: 1.5rem;
  line-height: 1.7;
}

.section-intro {
  margin-bottom: 2rem;
  line-height: 1.7;
}

/* ==========================================================================
   Level Cards (homepage)
   ========================================================================== */

.levels {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin: 1.5rem 0 2rem;
}

.level-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: border-color 0.15s;
}

.level-card:hover {
  border-color: var(--accent);
}

.level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: var(--bg-code);
  color: var(--accent);
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}

.level-card h3 {
  color: var(--white);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.level-card p {
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  font-size: 0.9375rem;
  line-height: 1.7;
}

.level-card ol {
  padding-left: 1.25rem;
  margin-bottom: 0.75rem;
}

.level-card li {
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

/* ==========================================================================
   Feature Cards
   ========================================================================== */

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin: 1.5rem 0;
}

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

.card-icon {
  width: 2.5rem;
  height: 2.5rem;
  background: var(--bg-code);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.card-icon svg {
  width: 1.25rem;
  height: 1.25rem;
  stroke: var(--accent);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card h3 {
  color: var(--white);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

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

/* ==========================================================================
   Code & Pre
   ========================================================================== */

code {
  background: var(--bg-code);
  color: var(--text);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.875em;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', 'Monaco', monospace;
}

pre {
  background: var(--bg-code);
  color: var(--text);
  padding: 1rem 1.25rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 0.75rem 0 1.25rem;
  font-size: 0.85rem;
  line-height: 1.6;
  border: 1px solid var(--border);
}

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

/* ==========================================================================
   Steps (Get Started)
   ========================================================================== */

.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
}

.steps > li {
  counter-increment: step;
  position: relative;
  padding: 1rem 1.25rem 1rem 3.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}

.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 1rem;
  top: 1rem;
  width: 1.75rem;
  height: 1.75rem;
  background: var(--bg-code);
  color: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

.steps > li strong {
  color: var(--white);
  display: block;
  margin-bottom: 0.25rem;
}

.steps > li p {
  color: var(--text-muted);
  margin: 0;
  font-size: 0.9rem;
}

/* ==========================================================================
   Endpoint Cards (Architecture)
   ========================================================================== */

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

.endpoint-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.method {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--white);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.m-get { background: var(--green); }
.m-post { background: var(--blue); }
.m-delete { background: var(--red); }
.m-patch { background: var(--orange); }

.endpoint-path {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.9rem;
  color: var(--white);
}

.endpoint p {
  margin-top: 0.4rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ==========================================================================
   Tables
   ========================================================================== */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0 1.25rem;
  font-size: 0.875rem;
}

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

th {
  background: var(--bg-code);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

td { background: var(--bg-card); }

/* ==========================================================================
   Note / Callout
   ========================================================================== */

.note {
  background: rgba(126, 200, 227, 0.06);
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Architecture Diagram
   ========================================================================== */

.diagram {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 1rem 0;
  overflow-x: auto;
}

.diagram pre {
  background: none;
  padding: 0;
  margin: 0;
  border: none;
  font-size: 0.8rem;
  color: #a0d2db;
  line-height: 1.5;
}

/* ==========================================================================
   Content (prose)
   ========================================================================== */

.content h2 {
  color: var(--accent);
  font-size: 1.5rem;
  font-weight: 700;
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.content h3 {
  color: #a0d2db;
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
}

.content h4 {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  margin: 1rem 0 0.4rem;
}

.content p {
  margin-bottom: 0.75rem;
  line-height: 1.7;
}

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

.content li {
  margin-bottom: 0.35rem;
  line-height: 1.65;
}

/* ==========================================================================
   Glossary
   ========================================================================== */

.glossary {
  margin: 1rem 0;
}

.glossary dt {
  color: var(--accent);
  font-weight: 600;
  margin-top: 0.75rem;
  font-size: 0.95rem;
}

.glossary dd {
  color: var(--text-muted);
  margin-left: 0;
  padding-left: 1rem;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  max-width: var(--max-w);
  margin: 3rem auto 0;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.footer p { margin-bottom: 0.4rem; }
.footer a { color: var(--text-muted); }
.footer a:hover { color: var(--accent); }

/* ==========================================================================
   Error Page
   ========================================================================== */

.error-page {
  text-align: center;
  padding: 6rem 1.5rem;
  max-width: var(--max-w);
  margin: 0 auto;
}

.error-code {
  font-size: 6rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 0.5rem;
}

.error-message {
  font-size: 1.125rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

/* ==========================================================================
   Responsive — Tablet (>=640px)
   ========================================================================== */

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

  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==========================================================================
   Responsive — Desktop (>=1024px)
   ========================================================================== */

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

  .card-grid.two-col {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==========================================================================
   Responsive — Mobile (<=768px)
   ========================================================================== */

@media (max-width: 768px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 0.5rem;
  }

  .nav-links.active { display: flex; }

  .nav-links a {
    padding: 10px 16px;
    font-size: 0.95rem;
  }

  .nav-toggle { display: block; }

  .hero { padding: 2.5rem 1rem 2rem; }
  .hero-title { font-size: 2rem; }

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

  .section { padding: 2rem 1rem; }
}
