/*
  DCAI 300-640 Hands-On Companion — original stylesheet.
  No CDN, no framework, no build step. Plain CSS custom properties power the
  light/dark theme toggle in assets/js/app.js.
*/

:root {
  --bg: #f6f7fb;
  --bg-elevated: #ffffff;
  --bg-inset: #eef0f7;
  --text: #1c2230;
  --text-muted: #565f75;
  --border: #d7dbe8;
  --accent: #1656b8;
  --accent-contrast: #ffffff;
  --link: #0b4fa8;
  --code-bg: #171b26;
  --code-text: #e6e9f2;
  --code-border: #2b3245;
  --safe: #167a4c;
  --safe-bg: #e3f6ec;
  --illustrative: #8a5a00;
  --illustrative-bg: #fdf1da;
  --platform: #6b3fa0;
  --platform-bg: #f1e8fb;
  --production: #b3261e;
  --production-bg: #fbe4e2;
  --focus-ring: #ff9800;
  --radius: 10px;
  --nav-width: 320px;
  --shadow: 0 2px 10px rgba(20, 24, 38, 0.08);
  --transition: 160ms ease;
}

[data-theme="dark"] {
  --bg: #10131c;
  --bg-elevated: #171b28;
  --bg-inset: #1d2233;
  --text: #e7e9f2;
  --text-muted: #a5abc2;
  --border: #2c3245;
  --accent: #6ea3ff;
  --accent-contrast: #0b1220;
  --link: #8fb8ff;
  --code-bg: #0b0d14;
  --code-text: #dfe4f5;
  --code-border: #2a3040;
  --safe: #5cd695;
  --safe-bg: #103524;
  --illustrative: #f2c46b;
  --illustrative-bg: #3a2c0c;
  --platform: #c8a6f2;
  --platform-bg: #2c1f45;
  --production: #f3877f;
  --production-bg: #3a1614;
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.5);
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0);
  overflow: hidden;
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 0.75rem 1.25rem;
  z-index: 200;
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus {
  left: 0;
}

a { color: var(--link); }
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.disclaimer-banner {
  background: var(--bg-inset);
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.6rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.site-header {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.site-header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  max-width: 1400px;
  margin: 0 auto;
}
.site-title h1 {
  font-size: 1.25rem;
  margin: 0;
}
.site-title p {
  margin: 0.1rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.nav-toggle, .theme-toggle {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.5rem 0.7rem;
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}
.nav-toggle:hover, .theme-toggle:hover { background: var(--border); }
.theme-toggle { margin-left: auto; }
.site-header-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0 1.25rem 0.75rem;
  max-width: 1400px;
  margin: 0 auto;
  font-size: 0.85rem;
}

.layout {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  align-items: flex-start;
}

.site-nav {
  width: var(--nav-width);
  flex-shrink: 0;
  position: sticky;
  top: 96px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  padding: 1rem;
  border-right: 1px solid var(--border);
}
.nav-search {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.nav-search input,
.nav-search select {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.9rem;
}
.search-status {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
  min-height: 1em;
}
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-list > li { margin-bottom: 0.5rem; }
.nav-list > li > a {
  display: block;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 600;
}
.nav-domain { margin-bottom: 0.75rem; }
.nav-domain-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin: 0 0 0.35rem;
  padding: 0 0.25rem;
}
.nav-weight { color: var(--accent); font-weight: 700; }
.nav-domain ul { list-style: none; margin: 0; padding: 0; }
.nav-domain li a {
  display: block;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-size: 0.88rem;
}
.nav-domain li a:hover,
.nav-domain li a.active {
  background: var(--bg-inset);
}
.nav-obj-id {
  display: inline-block;
  min-width: 2.6em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  margin-right: 0.25rem;
}
.nav-domain li[hidden],
.nav-list li[hidden] { display: none; }

.main-content {
  flex: 1;
  min-width: 0;
  padding: 1.5rem 2rem 4rem;
}

.intro, .coverage-section {
  max-width: 900px;
  margin-bottom: 2.5rem;
}
.intro h2, .coverage-section h2 { margin-top: 0; }

.coverage-matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.coverage-matrix caption {
  text-align: left;
  padding: 0.5rem 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  caption-side: top;
}
.coverage-matrix th, .coverage-matrix td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.6rem;
  text-align: left;
}
.coverage-matrix thead th {
  background: var(--bg-inset);
  position: sticky;
  top: 0;
}
.coverage-matrix tbody tr[hidden] { display: none; }

.anchor-alias {
  display: block;
  position: relative;
  height: 0;
  margin: 0;
  padding: 0;
  visibility: hidden;
}

.objective {
  max-width: 900px;
  margin: 0 0 3.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.objective[hidden] { display: none; }
.objective-head { margin-bottom: 0.75rem; }
.objective-kicker {
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 700;
  margin: 1rem 0 0.35rem;
}
.objective-head h3 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.objective-subtitle { margin: 0; color: var(--text-muted); font-style: italic; }
.objective-summary { font-size: 1rem; }

details.prereqs, details.citations-details {
  background: var(--bg-inset);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  margin: 1rem 0;
  border: 1px solid var(--border);
}
details.prereqs summary, details.citations-details summary {
  cursor: pointer;
  font-weight: 600;
}
details ul { margin: 0.5rem 0 0.25rem 1.1rem; padding: 0; }
.citation-list { margin: 0.5rem 0 0.25rem 1.1rem; }

figure.diagram {
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}
figure.diagram svg {
  max-width: 100%;
  height: auto;
}
figure.diagram figcaption {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.diagram-box rect {
  fill: var(--bg-inset);
  stroke: var(--accent);
  stroke-width: 1.5;
}
.diagram-box-alt rect {
  fill: var(--bg-inset);
  stroke: var(--platform);
}
.diagram-box text, .diagram-box-alt text {
  fill: var(--text);
  font-size: 12px;
  text-anchor: middle;
  font-family: inherit;
}
.diagram-arrow { stroke: var(--text-muted); stroke-width: 2; fill: none; }
.diagram-arrow-dashed { stroke: var(--text-muted); stroke-width: 2; stroke-dasharray: 6 5; fill: none; }
marker path.diagram-arrow { fill: var(--text-muted); stroke: none; }
.diagram-caption { fill: var(--text-muted); font-size: 11px; font-family: inherit; }
.diagram-axis { stroke: var(--text-muted); stroke-width: 1.5; }
.diagram-threshold { stroke: var(--illustrative); stroke-width: 2; stroke-dasharray: 4 3; }
.diagram-threshold-hi { stroke: var(--production); stroke-width: 2; stroke-dasharray: 4 3; }
.diagram-queue-bg { fill: var(--bg-inset); stroke: var(--border); }
.diagram-queue-fill { fill: var(--accent); opacity: 0.35; }
.diagram-bar { fill: var(--accent); opacity: 0.55; }
.diagram-bar-alt { fill: var(--platform); opacity: 0.55; }
.diagram-bar-warn { fill: var(--production); opacity: 0.55; }
.diagram-box-alt-fill { fill: var(--bg-inset); stroke: var(--border); }
.diagram-window { fill: var(--illustrative-bg); stroke: var(--illustrative); stroke-dasharray: 5 4; }
.diagram-link { stroke: var(--text-muted); }

.example {
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.example[hidden] { display: none; }
.example-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 1rem 0.5rem;
}
.example-head h4 { margin: 0; font-size: 1.05rem; }
.badges { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}
.badge-lang { background: var(--bg-inset); color: var(--text); border-color: var(--border); }
.risk-safe { background: var(--safe-bg); color: var(--safe); }
.risk-illustrative { background: var(--illustrative-bg); color: var(--illustrative); }
.risk-platform { background: var(--platform-bg); color: var(--platform); }
.risk-production { background: var(--production-bg); color: var(--production); }

.code-block { position: relative; }
.code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--code-border);
  padding: 0.35rem 0.75rem;
}
.code-lang-tag {
  font-size: 0.72rem;
  color: var(--code-text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.75;
}
.copy-btn {
  background: transparent;
  border: 1px solid var(--code-text);
  color: var(--code-text);
  border-radius: 6px;
  font-size: 0.72rem;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
}
.copy-btn:hover { background: rgba(255,255,255,0.1); }
.copy-btn[data-copied="true"] { background: var(--safe); border-color: var(--safe); color: #06180f; }

pre {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  background: var(--code-bg);
  color: var(--code-text);
  font-size: 0.85rem;
  line-height: 1.5;
}
pre code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  white-space: pre;
}

.example-meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  padding: 0 1rem 1rem;
}
@media (min-width: 720px) {
  .example-meta { grid-template-columns: 1fr 1fr 1fr; }
}
.meta-block h5 {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
.meta-block ul { margin: 0; padding-left: 1.1rem; font-size: 0.88rem; }
.expected-output {
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem;
  font-size: 0.82rem;
  white-space: pre-wrap;
}

.theory-link { margin-top: 1rem; font-size: 0.9rem; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Responsive drawer nav for narrow viewports */
@media (max-width: 960px) {
  .layout { display: block; }
  .site-nav {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 100;
    background: var(--bg);
    width: min(85vw, var(--nav-width));
    transform: translateX(-100%);
    transition: transform var(--transition);
    box-shadow: var(--shadow);
  }
  .site-nav.open { transform: translateX(0); }
  .main-content { padding: 1.25rem 1rem 3rem; }
}
@media (min-width: 961px) {
  .nav-toggle { display: none; }
}

@media print {
  .site-header, .site-nav, .nav-toggle, .theme-toggle, .disclaimer-banner,
  .copy-btn, .skip-link, .site-header-links { display: none !important; }
  .layout { display: block; }
  body { background: #fff; color: #000; }
  .example, figure.diagram, details { box-shadow: none; border: 1px solid #999; }
  a { color: #000; text-decoration: underline; }
  .objective { page-break-inside: avoid; }
}
