/* ============================================================
   Curso CCAR-F — tema claro/escuro, layout responsivo
   ============================================================ */

:root {
  --bg: #faf9f5;
  --bg-alt: #f0eee6;
  --surface: #ffffff;
  --text: #1a1a18;
  --text-muted: #57544c;
  --border: #d9d5c9;
  --accent: #c15f3c;
  --accent-soft: #f4e0d7;
  --link: #9a4a2b;
  --ok: #1a7f4b;
  --ok-soft: #d9f0e3;
  --err: #b3382f;
  --err-soft: #f8dedb;
  --warn: #8a6d1a;
  --warn-soft: #f6ecc8;
  --code-bg: #2b2a27;
  --code-text: #e8e6df;
  --code-inline-bg: #ece9df;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

:root[data-theme="dark"] {
  --bg: #201f1d;
  --bg-alt: #262522;
  --surface: #2b2a27;
  --text: #e8e6df;
  --text-muted: #a8a49a;
  --border: #45423c;
  --accent: #d97b57;
  --accent-soft: #4a3227;
  --link: #e09678;
  --ok: #4fbf85;
  --ok-soft: #1e3a2c;
  --err: #e07a71;
  --err-soft: #43251f;
  --warn: #d4b458;
  --warn-soft: #3d341f;
  --code-bg: #1a1917;
  --code-text: #e8e6df;
  --code-inline-bg: #3a3833;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #201f1d;
    --bg-alt: #262522;
    --surface: #2b2a27;
    --text: #e8e6df;
    --text-muted: #a8a49a;
    --border: #45423c;
    --accent: #d97b57;
    --accent-soft: #4a3227;
    --link: #e09678;
    --ok: #4fbf85;
    --ok-soft: #1e3a2c;
    --err: #e07a71;
    --err-soft: #43251f;
    --warn: #d4b458;
    --warn-soft: #3d341f;
    --code-bg: #1a1917;
    --code-text: #e8e6df;
    --code-inline-bg: #3a3833;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

/* ---------- Header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.site-header .header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.6rem 16px;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

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

.site-header .brand .badge {
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
  font-size: 0.8rem;
  margin-left: 0.3rem;
}

.site-header nav {
  display: flex;
  gap: 0.75rem;
  margin-left: auto;
  align-items: center;
  flex-wrap: wrap;
}

.site-header nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.92rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}

.site-header nav a:hover,
.site-header nav a:focus-visible {
  color: var(--accent);
  background: var(--accent-soft);
}

#theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  padding: 0.25rem 0.55rem;
  font-size: 1rem;
  line-height: 1;
}

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

/* ---------- Layout ---------- */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 16px 4rem;
}

h1 { font-size: 1.9rem; line-height: 1.25; margin: 1rem 0 0.5rem; }
h2 { font-size: 1.4rem; margin-top: 2.2rem; border-bottom: 2px solid var(--border); padding-bottom: 0.3rem; }
h3 { font-size: 1.15rem; margin-top: 1.6rem; }

a { color: var(--link); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, label:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.lead { color: var(--text-muted); font-size: 1.05rem; }

.meta-line {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 1.2rem;
}

/* ---------- Cards / tables ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  margin: 1rem 0;
  box-shadow: var(--shadow);
}

table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
  font-size: 0.95rem;
}

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

th { background: var(--bg-alt); }

.table-wrap { overflow-x: auto; }

/* ---------- Code ---------- */
pre {
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.87rem;
  line-height: 1.5;
}

pre code { background: transparent; padding: 0; color: inherit; }

code {
  font-family: ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, Menlo, monospace;
  background: var(--code-inline-bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.88em;
}

pre.mermaid {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  display: flex;
  justify-content: center;
}

/* ---------- Callouts ---------- */
.callout {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 8px 8px 0;
  padding: 0.8rem 1rem;
  margin: 1.2rem 0;
}

.callout.trap { border-left-color: var(--err); background: var(--err-soft); }
.callout.tip { border-left-color: var(--ok); background: var(--ok-soft); }
.callout.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }

.summary-5 {
  background: var(--bg-alt);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.9rem 1.2rem;
}

.summary-5 ol { margin: 0.3rem 0 0; padding-left: 1.3rem; }

/* ---------- Progress ---------- */
.progress-bar {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
  min-width: 120px;
}

.progress-bar .fill {
  background: var(--accent);
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s;
}

.progress-label { font-size: 0.85rem; color: var(--text-muted); }

.domain-card h3 { margin-top: 0; }

.domain-card .lesson-list {
  list-style: none;
  padding: 0;
  margin: 0.6rem 0 0;
}

.domain-card .lesson-list li {
  padding: 0.25rem 0;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.domain-card .lesson-list .done-mark { color: var(--ok); font-weight: 700; min-width: 1.1em; }

/* ---------- Botões ---------- */
.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1.1rem;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
}

.btn:hover { filter: brightness(1.08); }

.btn.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.danger { background: var(--err); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-row { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 1rem 0; align-items: center; }

/* ---------- Quiz de fixação ---------- */
.quiz-question {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  margin: 1rem 0;
}

.quiz-stem { font-weight: 600; margin-top: 0; }

.quiz-options { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.8rem; }

.quiz-options label {
  display: flex;
  gap: 0.55rem;
  align-items: baseline;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.quiz-options label:hover { border-color: var(--accent); }

.quiz-options label.correct { border-color: var(--ok); background: var(--ok-soft); }
.quiz-options label.incorrect { border-color: var(--err); background: var(--err-soft); }

.quiz-feedback {
  border-top: 1px dashed var(--border);
  padding-top: 0.7rem;
  margin-top: 0.5rem;
  font-size: 0.95rem;
}

.quiz-result-ok { color: var(--ok); font-weight: 700; }
.quiz-result-err { color: var(--err); font-weight: 700; }

/* ---------- Simulado ---------- */
.sim-setup fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 1rem 0;
  padding: 0.8rem 1.2rem;
}

.sim-setup legend { font-weight: 700; padding: 0 0.4rem; }

.sim-setup label { display: block; margin: 0.4rem 0; }

.sim-setup select, .sim-setup input[type="number"] {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font-size: 0.95rem;
}

.sim-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
}

#sim-timer { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 1.1rem; }
#sim-timer.low { color: var(--err); }

.sim-scenario {
  background: var(--bg-alt);
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 0.7rem 1rem;
  margin-bottom: 0.8rem;
  font-style: italic;
}

.sim-nav-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 1rem 0;
}

.sim-nav-grid button {
  width: 2.3rem;
  height: 2.1rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.sim-nav-grid button.answered { background: var(--accent-soft); border-color: var(--accent); }
.sim-nav-grid button.current { outline: 2px solid var(--accent); }

.result-headline { font-size: 1.5rem; font-weight: 700; }
.result-pass { color: var(--ok); }
.result-fail { color: var(--err); }

.review-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1.1rem;
  margin: 0.8rem 0;
  background: var(--surface);
}

.review-item .ref { font-size: 0.85rem; }

/* ---------- Navegação entre lições ---------- */
.lesson-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  border-top: 1px solid var(--border);
  padding-top: 1.2rem;
  flex-wrap: wrap;
}

.lesson-nav a { text-decoration: none; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 1.2rem 16px 2rem;
}

/* ---------- Responsivo ---------- */
@media (max-width: 640px) {
  h1 { font-size: 1.5rem; }
  .site-header .header-inner { padding: 0.5rem 12px; }
  main { padding: 1rem 16px 3rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .progress-bar .fill { transition: none; }
}

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