/* УЧИЛИЩЕ НА СЪРЦЕТО - интерактивен учебник-игра. Същата система, повече игра. */
.xp { position: sticky; top: var(--header-h); z-index: 30; background: color-mix(in srgb, var(--night) 92%, transparent); backdrop-filter: blur(14px); color: var(--night-ink); border-bottom: 1px solid var(--night-line); }
.xp__in { display: flex; align-items: center; gap: 20px; height: 64px; }
.xp__lvls { display: flex; gap: 6px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.xp__lvl { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px 0 6px; border-radius: var(--r-pill); border: 1px solid var(--night-line); font-size: var(--t-xs); color: var(--night-muted); white-space: nowrap; transition: all var(--d); }
.xp__lvl b { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.06); font-family: var(--f-mono); font-size: 11px; font-weight: 500; }
.xp__lvl.is-on { color: #fff; border-color: var(--night-ink); }
.xp__lvl.is-done b { background: var(--red); color: #fff; }
.xp__score { display: flex; align-items: center; gap: 12px; font-family: var(--f-mono); font-size: 12px; white-space: nowrap; }
.xp__bar { width: 140px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.08); overflow: hidden; }
.xp__bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--red), #FF6B73); transition: width .8s var(--ease); }
.xp__pts { color: #fff; font-size: 14px; }
@media (max-width: 760px) { .xp__bar { display: none; } .xp__lvl span { display: none; } .xp__lvl { padding: 0 6px; } }

.lesson { padding-block: clamp(64px, 8vw, 128px); scroll-margin-top: calc(var(--header-h) + 64px); position: relative; }
.lesson--night { background: var(--night); color: var(--night-ink); }
.lesson__head { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); align-items: end; margin-bottom: clamp(32px, 4vw, 56px); }
.lesson__head > div { grid-column: 1 / span 7; }
.lesson__head p { grid-column: 9 / -1; color: var(--muted); }
.lesson--night .lesson__head p, .lesson--night .label { color: var(--night-muted); }
.lesson__no { font-family: var(--f-mono); font-size: 12px; letter-spacing: .1em; color: var(--red); }
.lesson--night .lesson__no { color: #FF6B73; }
@container (max-width: 860px) { .lesson__head > div, .lesson__head p { grid-column: 1 / -1; } }
.reward { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-radius: var(--r-pill); background: rgba(227, 6, 19, .1); color: var(--red-ink); font-family: var(--f-mono); font-size: 11px; letter-spacing: .06em; }
.lesson--night .reward { background: rgba(255, 107, 115, .12); color: #FF8A90; }
.done-badge { display: none; align-items: center; gap: 10px; margin-top: 24px; padding: 14px 18px; border-radius: var(--r-md); background: rgba(19, 138, 90, .1); color: var(--ok); font-weight: 500; animation: pop var(--d) var(--ease); }
.is-complete .done-badge { display: inline-flex; }
.lesson--night .done-badge { background: rgba(80, 220, 160, .1); color: #6FE3B4; }

/* 1 · Анатомия */
.anat { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); align-items: center; }
.anat__fig { grid-column: 1 / span 7; position: relative; max-width: 560px; justify-self: center; width: 100%; }
.anat__fig .heart { --hs: rgba(207, 216, 230, .62); --heart-fill-hi: #172338; --heart-fill-lo: #0A1220; }
.anat__fig .heart .h-contours path { opacity: .12; }
.hs { position: absolute; transform: translate(-50%, -50%); width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; }
.hs::before { content: ''; position: absolute; inset: 0; border-radius: 50%; background: rgba(255, 255, 255, .1); border: 1.5px solid #fff; animation: hsPing 2.2s infinite; }
.hs::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: #fff; transition: background var(--d); }
.hs.is-found::before { animation: none; border-color: var(--red); background: rgba(227, 6, 19, .2); }
.hs.is-found::after { background: var(--red); }
.hs.is-on::before { border-color: #FF6B73; transform: scale(1.25); }
@keyframes hsPing { 0% { box-shadow: 0 0 0 0 rgba(255,255,255,.4); } 70%, 100% { box-shadow: 0 0 0 14px rgba(255,255,255,0); } }
.anat__card { grid-column: 9 / -1; min-height: 340px; border: 1px solid var(--night-line); border-radius: var(--r-lg); padding: 28px; display: grid; align-content: start; gap: 14px; background: rgba(255,255,255,.02); }
.anat__card h3 { font-size: clamp(1.6rem, 2.4vw, 2.2rem); font-weight: 500; letter-spacing: -.035em; line-height: 1.05; }
.anat__card p { color: var(--night-muted); }
.anat__fact { margin-top: 6px; padding: 14px 16px; border-radius: var(--r-sm); background: rgba(47, 107, 219, .12); color: #BFD3F7; font-size: var(--t-sm); }
.anat__fact b { color: #fff; }
.found { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.found span { width: 28px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.1); transition: background var(--d); }
.found span.on { background: var(--red); }
@container (max-width: 860px) { .anat__fig, .anat__card { grid-column: 1 / -1; } }

/* 2 · Пулс */
.pulse { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); }
.pulse__sim { grid-column: 1 / span 7; background: var(--white); border: 1px solid var(--line-2); border-radius: var(--r-lg); overflow: hidden; }
.pulse__top { display: grid; grid-template-columns: auto 1fr; gap: 32px; align-items: center; padding: 28px; }
.pulse__heart { width: 120px; height: 120px; display: grid; place-items: center; }
.pulse__heart svg { width: 100%; height: 100%; transform-origin: 50% 55%; }
.pulse__heart path { fill: var(--red); }
.pulse__bpm { font-family: var(--f-mono); font-size: clamp(3rem, 6vw, 4.8rem); font-weight: 500; letter-spacing: -.05em; line-height: 1; }
.pulse__bpm small { font-size: 14px; color: var(--muted); letter-spacing: .04em; margin-left: 6px; }
.pulse__state { margin-top: 8px; font-weight: 500; }
.pulse__strip { height: 110px; border-top: 1px solid var(--line-2); background-image: linear-gradient(rgba(227,6,19,.07) 1px, transparent 1px), linear-gradient(90deg, rgba(227,6,19,.07) 1px, transparent 1px); background-size: 12px 12px; }
.pulse__strip canvas { width: 100%; height: 100%; display: block; }
.pulse__ctrl { padding: 22px 28px 28px; display: grid; gap: 14px; }
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 3px; background: linear-gradient(90deg, #8EB0E8 0 20%, #6FD3A3 20% 47%, #F2B35A 47% 70%, var(--red) 70%); outline: none; }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); box-shadow: var(--sh-2); cursor: grab; }
.range::-moz-range-thumb { width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); cursor: grab; }
.range-scale { display: flex; justify-content: space-between; font-family: var(--f-mono); font-size: 10.5px; color: var(--faint); }
.pulse__me { grid-column: 9 / -1; background: var(--ink); color: var(--paper); border-radius: var(--r-lg); padding: 28px; display: grid; gap: 16px; align-content: start; }
.pulse__me p { color: rgba(246,245,241,.65); font-size: var(--t-sm); }
.tap { width: 100%; aspect-ratio: 1.6; border-radius: var(--r-md); background: rgba(255,255,255,.05); border: 1.5px dashed rgba(255,255,255,.2); color: #fff; display: grid; place-items: center; text-align: center; font-size: 1.125rem; font-weight: 500; transition: background var(--d-fast), transform .08s; user-select: none; }
.tap:active { transform: scale(.98); background: rgba(227,6,19,.2); }
.tap.is-run { border-color: var(--red); border-style: solid; }
.tap big { display: block; font-family: var(--f-mono); font-size: 2.6rem; letter-spacing: -.04em; }
@container (max-width: 860px) { .pulse__sim, .pulse__me { grid-column: 1 / -1; } .pulse__top { grid-template-columns: 1fr; } }

/* 3 · Пътят на кръвта */
.flow { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
.flow__track { grid-column: 1 / span 5; display: grid; gap: 8px; counter-reset: f; }
.flow__slot { height: 58px; border-radius: var(--r-sm); border: 1.5px dashed var(--line); display: flex; align-items: center; gap: 14px; padding: 0 16px; color: var(--faint); font-size: var(--t-sm); transition: all var(--d); }
.flow__slot b { font-family: var(--f-mono); font-size: 12px; font-weight: 500; }
.flow__slot.is-filled { border-style: solid; border-color: var(--ink); color: var(--ink); background: var(--white); font-size: 1.0625rem; font-weight: 500; }
.flow__slot.is-filled[data-o='1'] { border-left: 4px solid #3F6FD8; }
.flow__slot.is-filled[data-o='2'] { border-left: 4px solid var(--red); }
.flow__pool { grid-column: 7 / -1; display: flex; flex-wrap: wrap; gap: 10px; align-content: start; }
.flow__pool button { height: 52px; padding: 0 20px; border-radius: var(--r-pill); background: var(--white); border: 1px solid var(--line); font-size: 1rem; font-weight: 500; transition: all var(--d-fast); }
.flow__pool button:hover { border-color: var(--ink); transform: translateY(-2px); }
.flow__pool button.is-wrong { animation: shake .4s; border-color: var(--red); color: var(--red-ink); }
.flow__pool button[disabled] { opacity: 0; pointer-events: none; transform: scale(.8); }
.flow__hint { width: 100%; margin-top: 18px; padding: 18px; border-radius: var(--r-md); background: var(--clinical-tint); color: #23417A; font-size: var(--t-sm); }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@container (max-width: 860px) { .flow__track, .flow__pool { grid-column: 1 / -1; } }

/* 4 · Навици */
.habits { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); align-items: center; }
.deck { grid-column: 3 / span 8; display: grid; justify-items: center; gap: 24px; }
.hcard { width: min(440px, 100%); min-height: 240px; border-radius: var(--r-lg); background: var(--white); border: 1px solid var(--line-2); box-shadow: var(--sh-3); padding: 32px; display: grid; align-content: center; gap: 14px; text-align: center; transition: transform .45s var(--ease), opacity .45s; }
.hcard .i { width: 40px; height: 40px; justify-self: center; stroke-width: 1.2; }
.hcard h3 { font-size: 1.6rem; font-weight: 500; letter-spacing: -.03em; line-height: 1.15; }
.hcard.out-l { transform: translateX(-60px) rotate(-8deg); opacity: 0; }
.hcard.out-r { transform: translateX(60px) rotate(8deg); opacity: 0; }
.hbtns { display: flex; gap: 12px; }
.hbtns .btn { height: 60px; padding: 0 30px; font-size: 1.0625rem; }
.hfeed { min-height: 56px; text-align: center; max-width: 52ch; font-size: var(--t-sm); color: var(--ink-2); }
.hfeed b.ok { color: var(--ok); } .hfeed b.no { color: var(--red-ink); }
.hscore { display: flex; gap: 6px; }
.hscore span { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.hscore span.ok { background: var(--ok); } .hscore span.no { background: var(--red); }
@container (max-width: 860px) { .deck { grid-column: 1 / -1; } }

/* 5 · Тест */
.quiz { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); }
.quiz__q { grid-column: 1 / span 7; }
.quiz__q h3 { font-size: clamp(1.5rem, 2.4vw, 2.2rem); font-weight: 500; letter-spacing: -.035em; line-height: 1.15; margin: 14px 0 28px; }
.opts { display: grid; gap: 10px; }
.opt { display: grid; grid-template-columns: 36px 1fr; gap: 14px; align-items: center; padding: 18px 20px; border-radius: var(--r-md); border: 1px solid var(--night-line); text-align: left; font-size: 1.0625rem; color: var(--night-ink); transition: all var(--d-fast); }
.opt span { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--night-line); display: grid; place-items: center; font-family: var(--f-mono); font-size: 12px; }
.opt:hover:not([disabled]) { border-color: var(--night-ink); background: rgba(255,255,255,.03); }
.opt.is-right { border-color: #6FE3B4; background: rgba(111, 227, 180, .08); }
.opt.is-right span { background: #6FE3B4; color: var(--night); border-color: #6FE3B4; }
.opt.is-wrong { border-color: #FF6B73; background: rgba(255, 107, 115, .08); }
.opt[disabled] { cursor: default; }
.quiz__side { grid-column: 9 / -1; display: grid; gap: 16px; align-content: start; }
.explain-box { border-radius: var(--r-md); padding: 22px; background: rgba(47, 107, 219, .12); color: #CFDDF8; font-size: var(--t-sm); min-height: 120px; }
.qprog { display: flex; gap: 6px; }
.qprog i { flex: 1; height: 4px; border-radius: 2px; background: var(--night-line); }
.qprog i.ok { background: #6FE3B4; } .qprog i.no { background: #FF6B73; } .qprog i.cur { background: #fff; }
@container (max-width: 860px) { .quiz__q, .quiz__side { grid-column: 1 / -1; } }

/* Сертификат */
.cert { position: relative; max-width: 880px; margin: 0 auto; background: var(--white); border-radius: var(--r-lg); padding: clamp(32px, 5vw, 64px); box-shadow: var(--sh-3); text-align: center; overflow: hidden; border: 1px solid var(--line-2); }
.cert::before { content: ''; position: absolute; inset: 14px; border: 1px solid var(--line); border-radius: 18px; pointer-events: none; }
.cert__mark { width: 72px; height: 72px; min-height: 72px; margin: 0 auto 20px; } /* min-height: в grid-а SVG без него се свива до 0 и застъпва надписа */
.cert h2 { font-family: var(--f-serif); font-style: italic; font-weight: 400; font-size: clamp(2.2rem, 5vw, 3.8rem); letter-spacing: -.03em; line-height: 1.05; }
.cert__name { font-size: clamp(1.6rem, 3vw, 2.4rem); font-weight: 500; letter-spacing: -.03em; margin: 22px auto 8px; border-bottom: 1px solid var(--line); padding-bottom: 10px; max-width: 520px; min-height: 1.4em; }
.cert__stats { display: flex; justify-content: center; gap: 32px; margin-top: 28px; flex-wrap: wrap; }
.cert__stats b { display: block; font-family: var(--f-mono); font-size: 1.6rem; font-weight: 500; }
.cert__stats span { font-size: var(--t-xs); color: var(--muted); }
.cert__ecg { width: 100%; height: 50px; margin-top: 24px; }
.cert__ecg path { stroke: var(--red); stroke-width: 1.5; fill: none; }
.cert { aspect-ratio: 297 / 210; display: grid; align-content: center; justify-items: center; overflow: clip; } /* clip (не hidden): A4 е минимумът, височината расте, ако съдържанието не се побира */
.cert__lock { position: absolute; inset: 0; display: none; place-items: center; z-index: 2; }
.cert.is-locked .cert__lock { display: grid; opacity: 1; }
.cert__lock span { background: var(--ink); color: var(--paper); padding: 12px 20px; border-radius: var(--r-pill); font-size: var(--t-sm); font-weight: 500; box-shadow: var(--sh-2); }
.cert__date { font-family: var(--f-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* Печат / PDF - точно А4 хоризонтално, с цветовете */
@media print {
  @page { size: A4 landscape; margin: 0; }
  html, body { background: #fff !important; margin: 0; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  body > *:not(main), main > *:not(#cert-sec), .no-print { display: none !important; }
  #cert-sec { padding: 0 !important; }
  #cert-sec > .wrap { padding: 0 !important; max-width: none; }
  .cert { width: 297mm; height: 210mm; max-width: none; aspect-ratio: auto; margin: 0; border-radius: 0; border: 0; box-shadow: none !important; padding: 18mm 24mm; page-break-inside: avoid; }
  .cert::before { inset: 8mm; border: 1.5px solid #0B1626; border-radius: 0; }
  .cert h2 { font-size: 46pt; } .cert__name { font-size: 30pt; } .cert__mark { width: 22mm; height: 22mm; min-height: 22mm; }
}
/* сертификатът на телефон - височината следва съдържанието (A4 формата е за печат/PNG) */
@media (max-width: 700px) { .cert { aspect-ratio: auto; padding: 40px 22px; min-height: 0; } .cert h2 { font-size: 2rem; } .cert__stats { gap: 22px; } }
