/* CERC Learning — player styles (Rise-like layout, CERC brand) */
@font-face { font-family: "Draft Natural"; src: url("fonts/draft-natural-bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Draft Natural"; src: url("fonts/draft-natural-regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Draft Natural A"; src: url("fonts/draft-natural-a-bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --amber: #eca327; --amber-dark: #b97a0c; --orange: #ee7b42;
  --navy: #3b3a5e; --navy-dark: #27273e; --teal: #4faac6; --cream: #efede5;
  --bg: #ffffff; --bg-soft: #f6f5f1; --text: #22223a; --muted: #5d5d72; --line: #e3e1da;
  --ok: #2f7d5b; --ok-bg: #e6f3ec; --bad: #b3412e; --bad-bg: #fbe9e5;
  --side-w: 320px; --col: 760px;
  --font-display: "Draft Natural", "Barlow Condensed", "Arial Narrow", sans-serif;
  --font-body: "Barlow", "Segoe UI", system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1c2b; --bg-soft: #24243a; --text: #ececf3; --muted: #a9a9be; --line: #37374f;
    --ok-bg: #1f3a2e; --bad-bg: #432520; --cream: #2a2a40;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1c2b; --bg-soft: #24243a; --text: #ececf3; --muted: #a9a9be; --line: #37374f;
  --ok-bg: #1f3a2e; --bad-bg: #432520; --cream: #2a2a40;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 18px/1.65 var(--font-body); -webkit-font-smoothing: antialiased; }
img { max-width: 100%; display: block; }
a { color: var(--navy); }
:root[data-theme="dark"] a, .dark-links a { color: var(--amber); }
button { font: inherit; cursor: pointer; }
.ico { width: 1.15em; height: 1.15em; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.2em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .5em; min-height: 46px; padding: .6em 1.4em; border-radius: 999px; border: 2px solid transparent; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-size: .82rem; text-decoration: none; }
.btn-primary { background: var(--amber); color: #27273e; }
.btn-primary:hover { background: #f3b443; }
.btn-ghost { background: transparent; color: inherit; border-color: currentColor; }
.btn-navy { background: var(--navy); color: #fff; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* Top bar (language + exit) */
.topbar { position: fixed; top: 0; right: 0; z-index: 30; display: flex; gap: 8px; padding: 12px 16px; }
.lang { display: inline-flex; border: 1.5px solid currentColor; border-radius: 999px; overflow: hidden; font-size: .78rem; font-weight: 700; }
.lang button { background: none; border: 0; color: inherit; padding: 6px 12px; min-height: 34px; }
.lang button[aria-pressed="true"] { background: var(--amber); color: #27273e; }
.cover .topbar { color: #fff; }
.app .topbar { color: var(--muted); position: absolute; }

/* Cover */
.cover { min-height: 100vh; display: flex; flex-direction: column; }
.cover-hero { position: relative; min-height: 62vh; display: flex; align-items: flex-end; color: #fff; background: var(--navy-dark) center/cover no-repeat; }
.cover-hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(39,39,62,.25) 0%, rgba(39,39,62,.88) 75%); }
.cover-inner { position: relative; width: 100%; max-width: var(--col); margin: 0 auto; padding: 96px 24px 48px; }
.cover-logo { height: 40px; width: auto; margin-bottom: 28px; background: #fff; padding: 6px 10px; border-radius: 6px; }
.kicker { font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; color: var(--amber); }
.cover h1 { font: 700 clamp(2.4rem, 6vw, 4rem)/1.02 var(--font-display); margin: .2em 0 .35em; }
.cover .lede { font-size: 1.15rem; max-width: 36em; opacity: .95; margin: 0 0 1.4em; }
.cover-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.cover-band { height: 8px; background: linear-gradient(90deg, var(--amber) 0 70%, var(--orange) 70% 85%, var(--teal) 85%); }
.cover-details { max-width: var(--col); margin: 0 auto; padding: 40px 24px 64px; width: 100%; }
.cover-details h2 { font: 700 1.6rem var(--font-display); margin: 1.4em 0 .4em; color: var(--navy); }
:root[data-theme="dark"] .cover-details h2 { color: var(--amber); }
.meta-row { display: flex; flex-wrap: wrap; gap: 10px 26px; color: var(--muted); font-size: .95rem; margin-bottom: 18px; }
.meta-row span { display: inline-flex; align-items: center; gap: .45em; }
.cover-lessons { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.cover-lessons li { border-bottom: 1px solid var(--line); }
.cover-lessons button { width: 100%; text-align: left; background: none; border: 0; color: inherit; padding: 14px 4px; display: flex; gap: 14px; align-items: center; min-height: 52px; }
.cover-lessons .num { font: 700 1.1rem var(--font-display); color: var(--amber-dark); width: 2em; }
.cover-lessons .st { margin-left: auto; color: var(--muted); font-size: .85rem; display: inline-flex; gap: .4em; align-items: center; }

/* App layout */
.app { display: none; min-height: 100vh; }
body.in-course .cover { display: none; }
body.in-course .app { display: flex; }
.side { width: var(--side-w); flex: none; background: var(--navy-dark); color: #e9e8f2; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.side-head { padding: 22px 22px 18px; background: linear-gradient(180deg, rgba(39,39,62,.45), rgba(39,39,62,.95)), var(--cover) center/cover; }
.side-head button { background: none; border: 0; color: inherit; padding: 0; text-align: left; }
.side-title { font: 700 1.5rem/1.1 var(--font-display); color: #fff; margin: 12px 0 14px; }
.prog { height: 6px; background: rgba(255,255,255,.2); border-radius: 6px; overflow: hidden; }
.prog > i { display: block; height: 100%; background: var(--amber); width: 0; transition: width .4s; }
.prog-label { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; margin-top: 8px; font-weight: 700; }
.side nav { padding: 8px 0 24px; }
.side nav button { display: flex; width: 100%; gap: 12px; align-items: center; text-align: left; background: none; border: 0; color: inherit; padding: 13px 22px; min-height: 52px; font-size: .95rem; border-left: 4px solid transparent; }
.side nav button:hover { background: rgba(255,255,255,.06); }
.side nav button[aria-current="true"] { background: rgba(255,255,255,.1); border-left-color: var(--amber); color: #fff; font-weight: 600; }
.side nav .dot { margin-left: auto; width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(255,255,255,.45); display: grid; place-items: center; flex: none; }
.side nav .dot.done { background: var(--amber); border-color: var(--amber); color: #27273e; }
.side nav .dot .ico { width: 13px; height: 13px; stroke-width: 3; }
.side nav button[disabled] { opacity: .45; cursor: not-allowed; }
.side-foot { margin-top: auto; padding: 16px 22px; font-size: .78rem; color: #b9b8cc; }

.main { flex: 1; min-width: 0; position: relative; }
.menu-btn { display: none; position: absolute; top: 10px; left: 12px; z-index: 5; background: var(--bg); border: 1.5px solid var(--line); color: var(--text); border-radius: 8px; width: 46px; height: 46px; place-items: center; }
.lesson-head { max-width: var(--col); margin: 0 auto; padding: 72px 24px 28px; }
.lesson-head .of { font-style: italic; color: var(--muted); font-size: .9rem; }
.lesson-head h1 { font: 700 clamp(2rem, 4.5vw, 2.9rem)/1.1 var(--font-display); margin: .25em 0 .45em; color: var(--navy); }
:root[data-theme="dark"] .lesson-head h1 { color: #fff; }
.lesson-head .rule { width: 96px; height: 5px; background: var(--amber); border-radius: 3px; }
.lesson-progress { position: sticky; top: 0; height: 4px; background: var(--line); z-index: 4; }
.lesson-progress i { display: block; height: 100%; width: 0; background: var(--amber); transition: width .3s; }

/* Blocks */
.blocks { padding-bottom: 40px; }
.block { max-width: var(--col); margin: 0 auto; padding: 18px 24px; }
.block.wide { max-width: 1100px; }
.block.hidden { display: none; }
.block h2 { font: 700 1.75rem/1.15 var(--font-display); margin: .6em 0 .3em; color: var(--navy); }
:root[data-theme="dark"] .block h2 { color: var(--amber); }
.block h3 { font-size: 1.1rem; margin: 1em 0 .3em; }
.block p { margin: 0 0 1em; }
.block ul, .block ol { padding-left: 1.3em; }
.block li { margin-bottom: .35em; }
.band { background: var(--bg-soft); }
.band-wrap { padding: 22px 0; margin: 12px 0; }
.fig img { width: 100%; border-radius: 6px; aspect-ratio: 16/9; object-fit: cover; }
.fig figcaption { font-size: .85rem; color: var(--muted); margin-top: 8px; }
.fig { margin: 0; }

.callout { display: flex; gap: 16px; padding: 20px 22px; border-radius: 8px; background: var(--cream); border-left: 6px solid var(--amber); }
.callout.info { border-left-color: var(--teal); }
.callout.warn { border-left-color: var(--bad); background: var(--bad-bg); }
.callout .ico { width: 28px; height: 28px; color: var(--amber-dark); }
.callout.info .ico { color: var(--teal); }
.callout.warn .ico { color: var(--bad); }
.callout strong.t { display: block; margin-bottom: 4px; }
.callout p:last-child { margin-bottom: 0; }

.quote { border: 0; margin: 0; padding: 8px 0 8px 28px; border-left: 5px solid var(--amber); font: 400 1.45rem/1.35 var(--font-display); }
.quote cite { display: block; font: italic .9rem var(--font-body); color: var(--muted); margin-top: 10px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat { padding: 18px; border-radius: 8px; background: var(--navy); color: #fff; }
.stat b { display: block; font: 700 2.3rem/1 var(--font-display); color: var(--amber); }
.stat span { font-size: .9rem; line-height: 1.35; display: block; margin-top: 8px; }

.list-check { list-style: none; padding: 0 !important; }
.list-check li { display: flex; gap: 12px; align-items: flex-start; }
.list-check li .ico { color: var(--amber-dark); margin-top: .25em; }

.acc-item { border-bottom: 1px solid var(--line); }
.acc-item:first-child { border-top: 1px solid var(--line); }
.acc-item > button { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; background: none; border: 0; color: inherit; padding: 16px 4px; font-weight: 700; text-align: left; min-height: 52px; }
.acc-item > button .ico { transition: transform .2s; color: var(--amber-dark); }
.acc-item > button[aria-expanded="true"] .ico { transform: rotate(45deg); }
.acc-body { padding: 0 4px 16px; }
.acc-body[hidden] { display: none; }

.tabs-bar { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 2px solid var(--line); }
.tabs-bar button { background: none; border: 0; color: var(--muted); padding: 10px 14px; font-weight: 700; border-bottom: 3px solid transparent; margin-bottom: -2px; min-height: 46px; }
.tabs-bar button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--amber); }
.tab-panel { padding: 18px 2px 4px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.flip { perspective: 1000px; background: none; border: 0; padding: 0; min-height: 200px; color: inherit; text-align: left; }
.flip-in { position: relative; width: 100%; height: 100%; min-height: 200px; transition: transform .5s; transform-style: preserve-3d; }
.flip.on .flip-in { transform: rotateY(180deg); }
.flip-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 10px; padding: 20px; display: flex; flex-direction: column; justify-content: center; }
.flip-front { background: var(--navy); color: #fff; font: 700 1.3rem/1.2 var(--font-display); }
.flip-front small { font: 600 .72rem var(--font-body); letter-spacing: .1em; text-transform: uppercase; color: var(--amber); margin-top: 14px; display: flex; gap: 6px; align-items: center; }
.flip-back { background: var(--cream); transform: rotateY(180deg); font-size: .95rem; line-height: 1.5; border: 1.5px solid var(--amber); }

.process { border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; }
.process-steps { display: flex; background: var(--bg-soft); overflow-x: auto; }
.process-steps button { flex: 1; min-width: 70px; background: none; border: 0; color: var(--muted); padding: 12px 8px; font-weight: 700; font-size: .85rem; border-bottom: 3px solid transparent; min-height: 48px; }
.process-steps button[aria-current="true"] { color: var(--text); border-bottom-color: var(--amber); background: var(--bg); }
.process-steps button.seen { color: var(--text); }
.process-body { padding: 22px 24px; min-height: 160px; }
.process-body .n { font: 700 2.4rem/1 var(--font-display); color: var(--amber); }
.process-body h3 { margin-top: .3em; font-size: 1.25rem; }
.process-nav { display: flex; justify-content: space-between; padding: 0 24px 20px; }

.timeline { position: relative; padding-left: 30px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 3px; background: var(--line); }
.tl-item { position: relative; padding-bottom: 24px; }
.tl-item::before { content: ""; position: absolute; left: -29px; top: 6px; width: 17px; height: 17px; border-radius: 50%; background: var(--amber); border: 3px solid var(--bg); box-shadow: 0 0 0 2px var(--amber); }
.tl-date { font: 700 1.25rem var(--font-display); color: var(--amber-dark); }
.tl-item h3 { margin: .1em 0 .3em; }

/* Knowledge check */
.kc { border-radius: 10px; padding: 26px 26px 22px; background: var(--bg); border: 1.5px solid var(--line); box-shadow: 0 8px 26px rgba(39,39,62,.08); }
.kc-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; color: var(--amber-dark); display: flex; gap: 6px; align-items: center; }
.kc-q { font-weight: 700; font-size: 1.12rem; margin: 8px 0 4px; }
.kc-hint { font-size: .85rem; color: var(--muted); margin-bottom: 14px; }
.opts { display: grid; gap: 10px; }
.opt { display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 13px 16px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--bg); color: inherit; min-height: 50px; }
.opt .box { width: 22px; height: 22px; border: 2px solid var(--muted); border-radius: 50%; flex: none; margin-top: 2px; display: grid; place-items: center; }
.opt.multi .box { border-radius: 5px; }
.opt[aria-pressed="true"] { border-color: var(--navy); background: var(--bg-soft); }
.opt[aria-pressed="true"] .box { border-color: var(--navy); background: var(--navy); color: #fff; }
:root[data-theme="dark"] .opt[aria-pressed="true"] .box { background: var(--amber); border-color: var(--amber); color: #27273e; }
.opt .box .ico { width: 14px; height: 14px; stroke-width: 3; }
.opt.right { border-color: var(--ok); background: var(--ok-bg); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt[disabled] { cursor: default; }
.kc-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.fb { margin-top: 16px; padding: 14px 16px; border-radius: 8px; display: flex; gap: 12px; }
.fb.ok { background: var(--ok-bg); }
.fb.no { background: var(--bad-bg); }
.fb .ico { width: 24px; height: 24px; }
.fb.ok .ico { color: var(--ok); }
.fb.no .ico { color: var(--bad); }
.fb p:last-child { margin: 0; }

/* Scenario */
.scen { border-radius: 10px; overflow: hidden; border: 1.5px solid var(--line); }
.scen-top { background: var(--navy); color: #fff; padding: 22px 24px; display: flex; gap: 16px; }
.scen-top .ico { width: 34px; height: 34px; color: var(--amber); }
.scen-top p:last-child { margin: 0; }
.scen-body { padding: 18px 24px 22px; }
.scen-body .opts { margin-top: 8px; }

/* Sorting */
.sort-item { padding: 14px 16px; border-radius: 8px; border: 1.5px dashed var(--muted); margin-bottom: 14px; font-weight: 600; }
.sort-bins { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.sort-bins button { min-height: 50px; border-radius: 8px; border: 1.5px solid var(--navy); background: var(--bg); color: var(--text); font-weight: 700; padding: 8px 12px; }
.sort-done { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-top: 16px; }
.sort-col { background: var(--bg-soft); border-radius: 8px; padding: 12px 14px; }
.sort-col h4 { margin: 0 0 8px; font-size: .9rem; text-transform: uppercase; letter-spacing: .06em; }
.sort-col div { font-size: .92rem; padding: 6px 0; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.sort-col .ico { color: var(--ok); margin-top: .2em; }
.sort-col .x .ico { color: var(--bad); }
.sort-count { font-size: .85rem; color: var(--muted); margin-bottom: 8px; }

/* Continue + lesson nav */
.continue { max-width: var(--col); margin: 10px auto; padding: 10px 24px; text-align: center; }
.continue .btn { width: 100%; justify-content: center; }
.continue .need { font-size: .85rem; color: var(--muted); margin-top: 8px; }
.lesson-nav { max-width: var(--col); margin: 30px auto 80px; padding: 0 24px; }
.next-card { display: flex; align-items: center; gap: 16px; width: 100%; padding: 22px 24px; border-radius: 10px; background: var(--navy); color: #fff; border: 0; text-align: left; min-height: 70px; }
.next-card small { display: block; color: var(--amber); text-transform: uppercase; letter-spacing: .1em; font-weight: 700; font-size: .72rem; }
.next-card b { font: 700 1.35rem/1.2 var(--font-display); }
.next-card .ico { margin-left: auto; width: 28px; height: 28px; color: var(--amber); }
.next-card[disabled] { opacity: .5; }

/* Final quiz */
.quiz-card { max-width: var(--col); margin: 0 auto; padding: 0 24px; }
.quiz-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: .9rem; margin-bottom: 10px; }
.result { text-align: center; padding: 30px 24px; border-radius: 12px; background: var(--bg-soft); }
.result .score { font: 700 4rem/1 var(--font-display); color: var(--amber-dark); }
.result.pass .score { color: var(--ok); }
.review { text-align: left; margin-top: 22px; }
.review div { padding: 10px 0; border-top: 1px solid var(--line); display: flex; gap: 10px; font-size: .95rem; }
.review .ok .ico { color: var(--ok); }
.review .no .ico { color: var(--bad); }

/* Certificate */
.cert-form { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0; justify-content: center; }
.cert-form input { font: inherit; padding: 10px 14px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--bg); color: var(--text); min-height: 46px; min-width: 260px; }
.cert { display: none; }
@media print {
  body * { visibility: hidden !important; }
  .cert, .cert * { visibility: visible !important; }
  .cert { display: block !important; position: fixed; inset: 0; padding: 18mm; background: #fff; color: #27273e; }
  @page { size: A4 landscape; margin: 0; }
}
.cert-frame { border: 6px solid #3b3a5e; outline: 2px solid #eca327; outline-offset: -14px; height: 100%; padding: 16mm; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4mm; }
.cert-frame img { height: 22mm; width: auto; }
.cert-frame .c-k { letter-spacing: .2em; text-transform: uppercase; font-size: 11pt; color: #b97a0c; font-weight: 700; }
.cert-frame .c-name { font: 700 34pt var(--font-display); color: #27273e; border-bottom: 2px solid #eca327; padding: 0 10mm 2mm; }
.cert-frame .c-course { font: 700 22pt var(--font-display); color: #3b3a5e; }
.cert-frame .c-small { font-size: 11pt; color: #444; }

/* Mobile */
@media (max-width: 900px) {
  .side { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .25s; max-width: 88vw; visibility: hidden; }
  body.side-open .side { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  body.side-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  .menu-btn { display: grid; }
  body { font-size: 16px; }
  .block, .lesson-head, .continue, .lesson-nav, .quiz-card { padding-left: 16px; padding-right: 16px; }
  .kc { padding: 20px 16px; }
  .cover-inner { padding-left: 16px; padding-right: 16px; }
  .cover-details { padding-left: 16px; padding-right: 16px; }
}
