/*
 * The classroom (video player, curriculum, notes, Q&A) and the certificate.
 * On top of site.css and exam.css; the player sits on a dark stage, the rest
 * on the site's white panels.
 */

.cr-body-page { background: var(--ground); }

/* ---- top bar ---------------------------------------------------------- */
.cr-top { position: sticky; top: 0; z-index: 40; background: var(--ink); color: #fff; padding-top: env(safe-area-inset-top, 0px); }
.cr-top-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 20px; min-height: 60px; }
.cr-back { display: flex; align-items: center; gap: 10px; color: #fff; min-width: 0; }
.cr-back:hover { color: #fff; }
.cr-back svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.cr-back-text { display: grid; min-width: 0; line-height: 1.5; font-weight: 700; font-size: 14.5px; }
.cr-back-text small { font-weight: 400; font-size: 11.5px; opacity: .65; }
.cr-back-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-top-tools { display: flex; align-items: center; gap: 10px; flex: none; }
.cr-top .btn-light { background: rgba(255, 255, 255, .12); color: #fff; }
.cr-progress { display: flex; align-items: center; gap: 8px; }
.cr-progress svg { width: 38px; height: 38px; transform: rotate(-90deg); }
.cr-progress circle { fill: none; stroke-width: 3.5; }
.cr-progress .track { stroke: rgba(255, 255, 255, .15); }
.cr-progress .fill { stroke: #3fd3a6; stroke-dasharray: 97.4; stroke-linecap: round; transition: stroke-dashoffset .4s; }
.cr-progress > span { display: grid; line-height: 1.4; }
.cr-progress b { font-size: 14px; }
.cr-progress small { font-size: 11.5px; opacity: .7; }
.cr-icon-btn { width: 40px; height: 40px; border: 0; border-radius: 12px; background: rgba(255, 255, 255, .12); color: #fff; display: grid; place-items: center; cursor: pointer; font-size: 22px; line-height: 1; }
.cr-icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.cr-side-toggle { display: none; }

/* ---- layout: lesson and curriculum ----------------------------------- */
.cr-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; align-items: start; max-width: 1600px; margin: 0 auto; }
.cr-main { min-width: 0; padding: 20px 24px 60px; }

.cr-stage { position: relative; background: #0b1220; border-radius: 18px; overflow: hidden; aspect-ratio: 16 / 9; max-height: calc(100vh - 150px); width: 100%; box-shadow: 0 18px 40px rgba(11, 18, 32, .25); }
.cr-stage:fullscreen { border-radius: 0; max-height: none; }
.cr-stage video { width: 100%; height: 100%; display: block; background: #000; }
.cr-embed, .cr-embed iframe { width: 100%; height: 100%; border: 0; display: block; }
.cr-embed > div, .cr-embed > span { width: 100%; height: 100%; display: block; }
.cr-novideo { height: 100%; display: grid; place-content: center; justify-items: center; gap: 8px; color: #93a0b4; text-align: center; padding: 20px; }
.cr-novideo svg { width: 48px; height: 48px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.cr-watermark { position: absolute; z-index: 2; pointer-events: none; color: #fff; opacity: .16; font-size: 14px; font-weight: 700; letter-spacing: 1px; direction: ltr; transition: top 2s ease, left 2s ease; text-shadow: 0 1px 2px #000; user-select: none; }
.cr-next { position: absolute; inset: 0; z-index: 3; background: rgba(11, 18, 32, .86); color: #fff; display: grid; place-content: center; justify-items: center; gap: 6px; text-align: center; padding: 20px; }
.cr-next b { font-size: 19px; }
.muted-light { color: #aab6c8; font-size: 13px; }
.cr-next-count { color: #aab6c8; font-size: 13px; }
.cr-next-actions { display: flex; gap: 10px; margin-top: 12px; }

.cr-lessonbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 18px; padding: 16px 2px 14px; border-bottom: 1px solid var(--line); }
.cr-lesson-title { min-width: 0; }
.cr-lesson-title .muted { font-size: 12.5px; }
.cr-lesson-title h1 { font-size: 20px; font-weight: 800; }
.cr-lesson-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.cr-speed { display: inline-flex; align-items: center; gap: 4px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px 8px; }
.cr-speed svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.cr-speed select { border: 0; background: transparent; padding: 4px 2px; font-weight: 700; cursor: pointer; }
.cr-speed select:focus { outline: 0; }
.cr-autoplay { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.cr-autoplay input { accent-color: var(--teal); width: 16px; height: 16px; }
.cr-complete { background: #fff; color: var(--ink-2); box-shadow: inset 0 0 0 1.5px var(--line); }
.cr-complete svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.cr-complete.is-done { background: var(--teal-soft); color: var(--teal-dark); box-shadow: inset 0 0 0 1.5px #bfe8da; }
.cr-nav { display: flex; gap: 6px; }

.cr-guest { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; background: var(--amber-soft); color: #7a5414; border-radius: 14px; padding: 12px 16px; margin-top: 14px; }
.cr-guest b { display: block; }
.cr-guest span { font-size: 13.5px; }

.cr-tabs { display: flex; gap: 4px; margin-top: 16px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.cr-tabs::-webkit-scrollbar { display: none; }
.cr-tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; color: var(--muted); font-weight: 600; white-space: nowrap; border-bottom: 2.5px solid transparent; margin-bottom: -1px; }
.cr-tabs a[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--teal); }
.cr-count { background: var(--ground); color: var(--muted); border-radius: 8px; padding: 0 7px; font-size: 12px; }
.cr-panel { background: var(--panel); border-radius: 0 0 var(--radius) var(--radius); box-shadow: var(--shadow); padding: 22px 24px; }
.cr-file { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; color: var(--ink); margin-bottom: 16px; max-width: 460px; }
.cr-file:hover { border-color: var(--teal); color: var(--ink); background: #f7fcfa; }
.cr-file svg { width: 30px; height: 30px; fill: none; stroke: var(--teal); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.cr-file span { display: grid; line-height: 1.6; }
.cr-file small { color: var(--muted); font-size: 12px; }
.cr-keys { color: var(--muted); font-size: 12px; margin: 16px 0 0; }
.cr-keys kbd { font: inherit; font-size: 11.5px; background: var(--ground); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 0 6px; }
@media (hover: none) { .cr-keys { display: none; } }

/* notes */
.cr-note-form { display: grid; gap: 8px; margin-bottom: 16px; }
.cr-note-form .btn { justify-self: start; }
.cr-notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cr-notes li { display: flex; align-items: flex-start; gap: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.cr-notes p { margin: 0; flex: 1; white-space: pre-line; min-width: 0; overflow-wrap: anywhere; }
.cr-stamp { border: 0; background: var(--teal-soft); color: var(--teal-dark); font-weight: 700; border-radius: 8px; padding: 2px 8px; cursor: pointer; flex: none; direction: ltr; }
.cr-stamp:hover { background: var(--teal); color: #fff; }
.cr-note-del { border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; padding: 2px 4px; }
.cr-note-del:hover { color: var(--red); }

/* Q&A */
.cr-ask { display: grid; gap: 8px; margin-bottom: 18px; }
.cr-ask .btn { justify-self: start; }
.cr-q { border-top: 1px solid var(--line); padding: 14px 0; }
.cr-q:first-of-type { border-top: 0; }
.cr-q header { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.cr-q header form { margin-inline-start: auto; }
.cr-q > p { margin: 8px 0 0; white-space: pre-line; }
.cr-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--teal-soft); color: var(--teal-dark); display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.cr-reply { background: var(--ground); border-radius: 12px; padding: 10px 14px; margin: 10px 24px 0 0; }
.cr-reply.is-staff { background: var(--teal-soft); }
.cr-reply b { font-size: 13px; }
.cr-reply p { margin: 4px 0 0; white-space: pre-line; }
.cr-reply-form { margin: 8px 24px 0 0; }
.cr-reply-form summary { cursor: pointer; color: var(--teal-dark); font-size: 13px; font-weight: 700; list-style: none; }
.cr-reply-form summary::-webkit-details-marker { display: none; }
.cr-reply-form form { display: grid; gap: 8px; margin-top: 8px; }
.cr-reply-form .btn { justify-self: start; }
.cr-link-btn { border: 0; background: none; color: var(--muted); font-size: 12.5px; cursor: pointer; }
.cr-link-btn:hover { color: var(--red); }

/* ---- curriculum sidebar ----------------------------------------------- */
.cr-side { position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; background: #fff; border-inline-start: 1px solid var(--line); }
.cr-side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.cr-side-close { display: none; background: var(--ground); color: var(--ink); }
.cr-section { border-bottom: 1px solid var(--line); }
.cr-section summary { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 18px; cursor: pointer; font-weight: 700; font-size: 14px; background: #fafbfc; list-style: none; }
.cr-section summary::-webkit-details-marker { display: none; }
.cr-section summary small { color: var(--muted); font-weight: 500; }
.cr-section ol { list-style: none; margin: 0; padding: 4px 0; }
.cr-section li a { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px 18px; color: var(--ink-2); font-size: 13.5px; line-height: 1.7; }
.cr-section li a:hover { background: var(--ground); color: var(--ink); }
.cr-section li.is-current a { background: var(--teal-soft); color: var(--teal-dark); font-weight: 700; box-shadow: inset -3px 0 0 var(--teal); }
.cr-state { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid #c6ced8; display: grid; place-items: center; }
.cr-state svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.cr-state .i-play { fill: currentColor; stroke: none; width: 10px; height: 10px; }
.cr-state .i-done { display: none; }
li.is-done .cr-state { background: var(--teal); border-color: var(--teal); color: #fff; }
li.is-done .cr-state .i-done { display: block; }
li.is-done .cr-state .i-play { display: none; }
li.is-locked a { color: var(--muted); }
li.is-locked .cr-state { border-style: dashed; }
li.is-locked .cr-state svg { width: 11px; height: 11px; stroke-width: 2.2; }
.cr-item-time { color: var(--muted); font-size: 12px; }
.cr-backdrop { position: fixed; inset: 0; background: rgba(11, 18, 32, .5); z-index: 55; }

.cr-done-dialog { text-align: center; }
.cr-trophy { font-size: 46px; line-height: 1.2; }
.cr-done-dialog .xm-dialog-actions { justify-content: center; }

@media (max-width: 1100px) {
    .cr-layout { grid-template-columns: minmax(0, 1fr); }
    .cr-side-toggle, .cr-side-close { display: grid; }
    .cr-side { position: fixed; top: 0; bottom: 0; right: 0; width: min(380px, 88vw); height: auto; z-index: 60; transform: translateX(105%); transition: transform .25s ease; box-shadow: -10px 0 30px rgba(11, 18, 32, .2); padding-top: env(safe-area-inset-top, 0px); }
    .side-open .cr-side { transform: none; }
    .side-open { overflow: hidden; }
}
@media (max-width: 720px) {
    .cr-top-row { padding: 6px 12px; gap: 10px; }
    .cr-progress small { display: none; }
    .cr-progress svg { width: 32px; height: 32px; }
    .cr-main { padding: 0 0 40px; }
    .cr-stage { border-radius: 0; max-height: none; box-shadow: none; }
    .cr-lessonbar, .cr-tabs, .cr-guest { margin-inline: 12px; }
    .cr-lessonbar { padding-inline: 0; }
    .cr-lesson-title h1 { font-size: 17px; }
    .cr-lesson-actions { width: 100%; }
    .cr-nav { margin-inline-start: auto; }
    .cr-autoplay { display: none; }
    .cr-panel { margin-inline: 12px; padding: 16px; }
    .cr-reply, .cr-reply-form { margin-right: 12px; }
}
@media (prefers-reduced-motion: reduce) { .cr-side, .cr-watermark, .cr-progress .fill { transition: none; } }

/* ---- certificate ------------------------------------------------------ */
.cert-page { max-width: 1000px; margin: 24px auto; padding-inline: 16px; }
.cert-actions { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.cert { background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 22px; aspect-ratio: 1.414; max-width: 100%; }
.cert-border { position: relative; height: 100%; border: 2px solid var(--teal); outline: 6px double #cfe9df; outline-offset: -14px; border-radius: 12px; padding: 7% 8%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: radial-gradient(800px 300px at 50% -10%, #eefaf5, transparent); }
.cert-head { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; margin-bottom: 4%; }
.cert-eyebrow { color: var(--teal-dark); font-weight: 800; font-size: clamp(18px, 3vw, 30px); letter-spacing: 1px; margin: 0 0 3%; }
.cert-line { color: var(--ink-2); font-size: clamp(13px, 1.6vw, 16px); margin: 0; }
.cert-name { font-size: clamp(24px, 4.4vw, 44px); font-weight: 800; margin: 1% 0 2%; border-bottom: 2px solid var(--line); padding-bottom: 6px; }
.cert-course { font-size: clamp(16px, 2.4vw, 24px); font-weight: 800; margin: 1% 0 2%; color: var(--ink); }
.cert-foot { display: flex; justify-content: center; gap: clamp(16px, 6vw, 64px); margin-top: 5%; }
.cert-foot span { display: block; color: var(--muted); font-size: 12px; }
.cert-foot b { font-size: clamp(13px, 1.6vw, 15px); }
.cert-seal { position: absolute; left: 6%; bottom: 8%; width: clamp(50px, 9vw, 90px); color: var(--teal); }
.cert-seal svg { width: 100%; fill: var(--teal-soft); stroke: currentColor; stroke-width: 1; }
.cert-seal svg path:last-child { stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 640px) { .cert { aspect-ratio: auto; padding: 12px; } .cert-border { padding: 32px 18px; } .cert-seal { display: none; } }
@media print {
    @page { size: A4 landscape; margin: 0; }
    .cert-body { background: #fff; }
    .cert-page { margin: 0; padding: 0; max-width: none; }
    .cert { box-shadow: none; border-radius: 0; height: 100vh; width: 100vw; aspect-ratio: auto; }
    .no-print, .toast { display: none !important; }
}
