/* CCA-F Slides — shared stylesheet
 * Mỗi slide = <section class="slide">. Điều hướng: ← → / Space / PgUp PgDn / Home End / O (mục lục)
 */
:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede6;
  --text: #1d1d1b;
  --muted: #5f5d57;
  --border: #dcd9cf;
  --accent: #c2410c;        /* cam đất — màu nhấn chính */
  --accent-soft: #fdeee4;
  --term: #1d4ed8;          /* thuật ngữ tiếng Anh */
  --term-soft: #e7eefc;
  --good: #15803d;
  --good-soft: #e5f4ea;
  --bad: #b91c1c;
  --bad-soft: #fbe9e9;
  --warn: #a16207;
  --warn-soft: #fbf3dc;
  --code-bg: #1f2124;
  --code-text: #e8e6e1;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 16px rgb(0 0 0 / .05);
  --radius: 12px;
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17181a; --surface: #202225; --surface-2: #2a2c30; --text: #ecebe7; --muted: #a3a19b;
    --border: #3a3c41; --accent: #fb923c; --accent-soft: #3a2a1f; --term: #93b4ff; --term-soft: #1f2a44;
    --good: #4ade80; --good-soft: #1b3324; --bad: #f87171; --bad-soft: #3a1f1f; --warn: #facc15; --warn-soft: #3a3318;
    --code-bg: #111214; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #17181a; --surface: #202225; --surface-2: #2a2c30; --text: #ecebe7; --muted: #a3a19b;
  --border: #3a3c41; --accent: #fb923c; --accent-soft: #3a2a1f; --term: #93b4ff; --term-soft: #1f2a44;
  --good: #4ade80; --good-soft: #1b3324; --bad: #f87171; --bad-soft: #3a1f1f; --warn: #facc15; --warn-soft: #3a3318;
  --code-bg: #111214; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: clamp(15px, 1.15vw + 8px, 20px); line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Slide frame ---------- */
.deck { position: relative; height: 100%; }
.slide {
  display: none; position: absolute; inset: 0 0 56px 0;
  overflow-y: auto; padding: clamp(20px, 4vw, 56px) 16px;
}
.slide.active { display: block; }
.slide > .inner { max-width: 1080px; margin: 0 auto; }
.slide h1 { font-size: 2.1em; line-height: 1.15; margin: .2em 0 .4em; letter-spacing: -.01em; }
.slide h2 { font-size: 1.55em; line-height: 1.2; margin: .1em 0 .6em; }
.slide h3 { font-size: 1.1em; margin: 1em 0 .4em; }
.slide p, .slide li { max-width: 72ch; }
.slide ul, .slide ol { padding-left: 1.3em; }
.slide li { margin: .25em 0; }
.slide .quiz p, .slide .quiz li, .slide .card p, .slide .card li, .slide .callout p, .slide td li { max-width: none; }
a { color: var(--term); text-underline-offset: 2px; }

.kicker {
  display: inline-flex; gap: .5em; align-items: center; font-size: .78em; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin-bottom: .4em;
}
.kicker .time { color: var(--muted); font-weight: 500; }

/* Title slide */
.slide.title-slide .inner { display: flex; flex-direction: column; justify-content: center; min-height: 100%; }
.title-slide .session-no { font-size: 1em; font-weight: 700; color: var(--accent); letter-spacing: .08em; text-transform: uppercase; }
.title-slide .subtitle { font-size: 1.15em; color: var(--muted); max-width: 60ch; }

.disclaimer { margin-top: 1.5em; padding-top: .8em; border-top: 1px solid var(--border); font-size: .75em; max-width: 80ch; }

/* Section divider */
.slide.divider .inner { display: flex; flex-direction: column; justify-content: center; min-height: 100%; }
.divider h2 { font-size: 2.2em; }
.divider .block-no { font-size: 3em; font-weight: 800; color: var(--accent); line-height: 1; }

/* ---------- Content components ---------- */
.term {
  font-family: var(--mono); font-size: .9em; color: var(--term); background: var(--term-soft);
  padding: .05em .35em; border-radius: 5px; white-space: nowrap;
}
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: .05em .3em; border-radius: 4px; }
pre {
  background: var(--code-bg); color: var(--code-text); padding: 14px 16px; border-radius: var(--radius);
  overflow-x: auto; font-size: .78em; line-height: 1.5; margin: .8em 0;
}
pre code { background: none; padding: 0; color: inherit; font-size: 1em; }
pre .c { color: #8b949e; } pre .k { color: #ff9e64; } pre .s { color: #9ece6a; } pre .hl { background: rgb(255 200 0 / .18); display: inline-block; width: 100%; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card h3 { margin-top: 0; }

.callout { border-left: 4px solid var(--border); background: var(--surface); padding: 12px 16px; border-radius: 0 var(--radius) var(--radius) 0; margin: 1em 0; }
.callout > :first-child { margin-top: 0; } .callout > :last-child { margin-bottom: 0; }
.callout .label { display: block; font-size: .75em; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin-bottom: .3em; }
.callout.good { border-color: var(--good); background: var(--good-soft); } .callout.good .label { color: var(--good); }
.callout.bad { border-color: var(--bad); background: var(--bad-soft); } .callout.bad .label { color: var(--bad); }
.callout.tip { border-color: var(--term); background: var(--term-soft); } .callout.tip .label { color: var(--term); }
.callout.remember { border-color: var(--warn); background: var(--warn-soft); } .callout.remember .label { color: var(--warn); }
.callout.exam { border-color: var(--accent); background: var(--accent-soft); } .callout.exam .label { color: var(--accent); }

/* Correct pattern vs anti-pattern */
.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin: 1em 0; }
.compare > div { border-radius: var(--radius); padding: 14px 16px; border: 1px solid var(--border); background: var(--surface); }
.compare .do { border-top: 4px solid var(--good); }
.compare .dont { border-top: 4px solid var(--bad); }
.compare h3 { margin: 0 0 .4em; font-size: 1em; }
.compare .do h3 { color: var(--good); } .compare .dont h3 { color: var(--bad); }

table { border-collapse: collapse; width: 100%; margin: .8em 0; font-size: .9em; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; }
.table-wrap { overflow-x: auto; }

.big-number { font-size: 2.4em; font-weight: 800; color: var(--accent); line-height: 1; }
.muted { color: var(--muted); }
.small { font-size: .85em; }

/* Flow diagram (simple boxes + arrows) */
.flow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 1em 0; }
.flow .node { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; font-size: .9em; box-shadow: var(--shadow); }
.flow .node.hl { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.flow .arrow { color: var(--muted); font-weight: 700; }

/* Glossary */
.glossary { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px; }
.glossary div { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; }
.glossary dt { font-family: var(--mono); color: var(--term); font-weight: 600; font-size: .9em; }
.glossary dd { margin: .2em 0 0; font-size: .88em; color: var(--muted); }

/* ---------- Quiz ---------- */
.quiz { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin: 1em 0; box-shadow: var(--shadow); }
.quiz .q-meta { font-size: .75em; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .3em; }
.quiz .q { font-weight: 600; margin: 0 0 .7em; max-width: none; }
.quiz .scenario { font-weight: 400; font-style: italic; color: var(--muted); display: block; margin-bottom: .4em; }
.quiz ol.options { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.quiz ol.options li {
  max-width: none; margin: 0; padding: 9px 12px 9px 44px; position: relative; border: 1px solid var(--border);
  border-radius: 9px; cursor: pointer; background: var(--bg); transition: border-color .15s, background .15s;
}
.quiz ol.options li::before {
  content: attr(data-key); position: absolute; left: 12px; top: 9px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--surface-2); font-size: .78em; font-weight: 700;
  display: grid; place-items: center;
}
.quiz ol.options li:hover { border-color: var(--accent); }
.quiz ol.options li:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.quiz.answered ol.options li { cursor: default; }
.quiz.answered ol.options li.correct { border-color: var(--good); background: var(--good-soft); }
.quiz.answered ol.options li.correct::before { background: var(--good); color: #fff; content: "✓"; }
.quiz.answered ol.options li.wrong { border-color: var(--bad); background: var(--bad-soft); }
.quiz.answered ol.options li.wrong::before { background: var(--bad); color: #fff; content: "✗"; }
.quiz .explain { display: none; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); font-size: .92em; }
.quiz.answered .explain { display: block; }
.quiz .explain .why { margin: .4em 0; }
.quiz .explain ul { margin: .3em 0; }
.quiz .result-tag { display: none; font-weight: 700; margin-bottom: .3em; }
.quiz.answered.is-correct .result-tag.ok { display: block; color: var(--good); }
.quiz.answered.is-wrong .result-tag.no { display: block; color: var(--bad); }

/* Exercise with hidden solution */
details.solution { margin: .8em 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 16px; }
details.solution summary { cursor: pointer; font-weight: 600; color: var(--accent); }
details.solution[open] summary { margin-bottom: .6em; }
.exercise { background: var(--surface); border: 1px dashed var(--accent); border-radius: var(--radius); padding: 14px 18px; margin: 1em 0; }
.exercise .label { font-size: .75em; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }

/* Agenda */
.agenda { display: grid; gap: 6px; }
.agenda .row { display: grid; grid-template-columns: 3.2em 1fr auto; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; }
.agenda .row b { color: var(--accent); }
.agenda .row .t { color: var(--muted); font-size: .85em; white-space: nowrap; }

/* ---------- Chrome: nav bar ---------- */
.navbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: 56px; display: flex; align-items: center; gap: 10px;
  padding: 0 16px; background: var(--surface); border-top: 1px solid var(--border); z-index: 10; font-size: 14px;
}
.navbar .progress { position: absolute; top: -1px; left: 0; height: 3px; background: var(--accent); transition: width .2s; }
.navbar button, .navbar a.btn {
  font: inherit; font-size: 14px; border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 8px; height: 34px; min-width: 34px; padding: 0 10px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.navbar button:hover, .navbar a.btn:hover { border-color: var(--accent); }
.navbar .counter { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 4.5em; text-align: center; }
.navbar .deck-title { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); }
.navbar .score { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent); white-space: nowrap; }
@media (max-width: 640px) { .navbar .deck-title { display: none; } .navbar { gap: 6px; padding: 0 8px; } }

/* Table of contents dialog */
dialog.toc { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 0; width: min(640px, calc(100vw - 32px)); max-height: 80vh; }
dialog.toc::backdrop { background: rgb(0 0 0 / .4); }
dialog.toc header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
dialog.toc ol { margin: 0; padding: 8px 8px 8px 40px; }
dialog.toc li { padding: 4px 6px; border-radius: 6px; cursor: pointer; }
dialog.toc li:hover, dialog.toc li.current { background: var(--accent-soft); }
dialog.toc button { font: inherit; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 8px; padding: 4px 10px; cursor: pointer; }

/* ---------- Index page ---------- */
.index-page { max-width: 1080px; margin: 0 auto; padding: 40px 16px 64px; }
.index-page h1 { font-size: 2.2em; margin: .2em 0; }
.sessions { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-top: 1.5em; }
.sessions a { text-decoration: none; color: inherit; }
.sessions .card { height: 100%; transition: border-color .15s, transform .15s; }
.sessions a:hover .card { border-color: var(--accent); transform: translateY(-2px); }
.sessions .no { font-weight: 800; color: var(--accent); font-size: .85em; letter-spacing: .08em; }
.sessions h2 { font-size: 1.1em; margin: .3em 0; }
.sessions .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: .6em; }
.sessions .tags span { font-size: .72em; background: var(--surface-2); padding: 2px 8px; border-radius: 99px; color: var(--muted); }

/* ---------- Print: mỗi slide 1 trang ---------- */
@media print {
  .navbar, dialog { display: none !important; }
  .slide { display: block !important; position: static; overflow: visible; page-break-after: always; break-after: page; }
  .quiz .explain { display: block; }
  details.solution { display: block; }
  body { background: #fff; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
