/* AI Engineering Learning Hub — shared stylesheet (light + dark) */

:root {
  --accent: #635BFF;
  --accent-dark: #4F46E5;
  --accent-soft: #EEEDFF;
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --surface-2: #F1F2F6;
  --code-bg: #1E1B33;
  --code-text: #E5E4F5;
  --text: #14162B;
  --text-muted: #6B7280;
  --border: #E6E8EC;
  --success: #16A34A;
  --shadow: 0 4px 20px rgba(20, 20, 43, 0.08);
  --shadow-lg: 0 12px 44px rgba(20, 20, 43, 0.14);
}

:root[data-theme="dark"] {
  --accent: #8B84FF;
  --accent-dark: #A8A3FF;
  --accent-soft: #26244A;
  --bg: #0B0B10;
  --surface: #15151C;
  --surface-2: #1D1D26;
  --code-bg: #0F0E1A;
  --code-text: #E5E4F5;
  --text: #ECEDF3;
  --text-muted: #9A9CAC;
  --border: #26272F;
  --success: #4ADE80;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 44px rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #8B84FF;
    --accent-dark: #A8A3FF;
    --accent-soft: #26244A;
    --bg: #0B0B10;
    --surface: #15151C;
    --surface-2: #1D1D26;
    --code-bg: #0F0E1A;
    --code-text: #E5E4F5;
    --text: #ECEDF3;
    --text-muted: #9A9CAC;
    --border: #26272F;
    --success: #4ADE80;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 12px 44px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

a { color: inherit; }
a.plain { text-decoration: none; }
.muted { color: var(--text-muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.container.narrow { max-width: 760px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
  max-width: 1080px;
  margin: 0 auto;
}

.brand {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}

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

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

.pill:hover { color: var(--accent-dark); border-color: var(--accent); }
.pill svg { width: 14px; height: 14px; flex-shrink: 0; }
.pill.icon-only { padding: 7px; }
.pill .label-mobile-hide { display: inline; }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 56px 20px 28px; }

.hero h1 {
  font-size: clamp(30px, 5vw, 46px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0 0 12px;
  background: linear-gradient(135deg, var(--text) 40%, var(--accent) 130%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p { font-size: 16px; color: var(--text-muted); max-width: 600px; margin: 0 auto; }

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-muted);
}

.hero-stats span {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
}

.hero-stats strong { color: var(--text); }

/* ---------- Search + filters ---------- */
.toolbar {
  position: sticky;
  top: 57px;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  padding: 12px 0;
}

.toolbar-inner { display: flex; flex-direction: column; gap: 10px; }

.search-wrap { position: relative; }

.search-wrap svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 12px 14px 12px 40px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  outline: none;
}

.search-input:focus { border-color: var(--accent); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip.active, .chip:hover { color: var(--accent-dark); border-color: var(--accent); background: var(--accent-soft); }

.empty-state { text-align: center; color: var(--text-muted); padding: 48px 0; display: none; }
.empty-state.show { display: block; }

/* ---------- Category sections / cards ---------- */
.category-section { padding: 28px 0 24px; }
.category-section.hidden { display: none; }

.category-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.category-title::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.category-desc { margin: 0 0 18px; font-size: 14px; color: var(--text-muted); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.topic-card {
  position: relative;
  display: block;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.topic-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.topic-card.hidden { display: none; }

.topic-card .num {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topic-card .read-mark {
  display: none;
  color: var(--success);
  font-size: 11px;
  font-weight: 700;
}

.topic-card.is-read .read-mark { display: inline; }

.topic-card h3 { margin: 0 0 8px; font-size: 15.5px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.35; }
.topic-card p { margin: 0; font-size: 13.5px; color: var(--text-muted); line-height: 1.5; }

/* ---------- Article (topic page) ---------- */
.article { padding: 40px 0 24px; }

.breadcrumbs { font-size: 13px; color: var(--text-muted); margin-bottom: 18px; }
.breadcrumbs a { text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent-dark); }
.breadcrumbs .sep { margin: 0 6px; opacity: 0.6; }

.article h1 {
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 10px;
}

.article .lede { font-size: 17px; color: var(--text-muted); margin: 0 0 14px; }

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 13px;
  color: var(--text-muted);
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}

.article-meta a { text-decoration: none; color: var(--accent-dark); font-weight: 600; }

.section { margin-bottom: 32px; }

.section h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-dark);
}

.section p { margin: 0 0 10px; font-size: 16px; }
.section ul { margin: 0; padding-left: 20px; font-size: 16px; }
.section li { margin-bottom: 8px; }

.used-in {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 14px;
  padding: 16px 18px;
}

.used-in p { margin: 0; font-size: 15px; }
.used-in a { color: var(--accent-dark); font-weight: 600; }

.code-wrap { position: relative; }

pre.code-block {
  margin: 0;
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: 12px;
  padding: 18px 18px;
  overflow-x: auto;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 13.5px;
  line-height: 1.6;
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  color: #E5E4F5;
  cursor: pointer;
}

.copy-btn:hover { background: rgba(255, 255, 255, 0.16); }

.hl-keyword { color: #9D8CFF; font-weight: 600; }
.hl-string { color: #7FE8B8; }
.hl-comment { color: #8A88A6; font-style: italic; }
.hl-number { color: #FFB86C; }

details.qa {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  margin-bottom: 10px;
  overflow: hidden;
}

details.qa summary {
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 700;
  font-size: 15px;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

details.qa summary::-webkit-details-marker { display: none; }
details.qa summary::after { content: "+"; color: var(--accent); font-weight: 700; }
details.qa[open] summary::after { content: "–"; }

details.qa .qa-a {
  padding: 0 16px 16px;
  font-size: 15px;
  color: var(--text-muted);
  border-left: 3px solid var(--accent-soft);
  margin: 0 16px 16px;
  padding: 0 0 0 12px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 11px 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}

.btn svg { width: 16px; height: 16px; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-dark); }

/* ---------- Prev / next / related ---------- */
.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 36px 0 28px;
}

.pager a {
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  transition: border-color 0.15s ease;
}

.pager a:hover { border-color: var(--accent); }
.pager a.next { text-align: right; }
.pager small { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.pager strong { font-size: 14.5px; }
.pager .spacer { visibility: hidden; }

.related h2 { font-size: 18px; margin: 0 0 14px; }
.related .card-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

/* ---------- Footer CTA blocks ---------- */
.cta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 40px 0 24px;
}

.cta-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.cta-card h3 { margin: 0 0 6px; font-size: 18px; letter-spacing: -0.01em; }
.cta-card p { margin: 0 0 14px; font-size: 14px; color: var(--text-muted); }

.cta-card.hire { background: linear-gradient(135deg, var(--accent) 0%, #3B2FD6 100%); color: #fff; border: none; }
.cta-card.hire h3, .cta-card.hire p { color: #fff; }
.cta-card.hire p { opacity: 0.9; }
.cta-card.hire .btn-ghost { background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.3); color: #fff; }
.cta-card.hire .btn-ghost:hover { background: rgba(255, 255, 255, 0.24); }
.cta-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.subscribe-form { display: flex; gap: 8px; }

.subscribe-form input[type="email"] {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
}

.subscribe-form input[type="email"]:focus { border-color: var(--accent); }
.subscribe-form .hp { position: absolute; left: -9999px; }
.form-msg { font-size: 13px; margin: 10px 0 0; min-height: 18px; }
.form-msg.ok { color: var(--success); }
.form-msg.err { color: #DC2626; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0 40px;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--accent-dark); }
.site-footer nav { display: flex; gap: 14px; flex-wrap: wrap; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .container { padding: 0 16px; }
  .topbar-inner { padding: 10px 16px; }
  .pill .label-mobile-hide { display: none; }
  .pill { padding: 7px 9px; }
  .hero { padding: 40px 12px 20px; }
  .toolbar { top: 53px; }
  .cta-grid, .pager { grid-template-columns: 1fr; }
  .pager a.next { text-align: left; }
  .subscribe-form { flex-direction: column; }
}
