/* ==========================================================================
   Tutorials module - Course Builder (document canvas), Player, My Learning

   Colours derive from the active Serenity Pro theme. A small local palette is
   mapped from the theme's Bootstrap/Serenity custom properties, and `html.dark`
   (set by _Layout.cshtml for any "-dark" theme) overrides the few values that
   cannot be expressed once. Hardcoded hex is only ever a fallback.
   ========================================================================== */

.tutorial-canvas,
.tutorial-player,
.my-learning {
    --tc-surface:    var(--s-card-bg, var(--bs-body-bg, #fff));
    --tc-panel:      var(--s-alt-row-bg, #fbfcfd);
    --tc-stage-bg:   var(--bs-tertiary-bg, #f6f8fa);
    --tc-text:       var(--bs-body-color, #2d3748);
    --tc-heading:    var(--bs-emphasis-color, var(--bs-body-color, #1a202c));
    --tc-muted:      var(--bs-secondary-color, #6b7684);
    --tc-faint:      var(--bs-tertiary-color, #98a2b0);
    --tc-border:     var(--s-card-border, var(--bs-border-color, #e7eaee));
    --tc-input-bg:   var(--s-input-bg, var(--bs-body-bg, #fff));
    --tc-input-bd:   var(--s-input-border, var(--bs-border-color, #ccd2d9));
    --tc-input-text: var(--s-input-text, var(--bs-body-color, #2d3748));
    --tc-accent:     var(--bs-primary, #2f6fed);

    --tc-accent-bg:  rgba(47, 111, 237, .10);
    --tc-hover:      rgba(128, 128, 128, .10);
    --tc-selected:   rgba(47, 111, 237, .14);
}

html.dark .tutorial-canvas,
html.dark .tutorial-player,
html.dark .my-learning {
    --tc-panel:     rgba(255, 255, 255, .03);
    --tc-stage-bg:  rgba(0, 0, 0, .18);
    --tc-accent-bg: rgba(120, 170, 255, .16);
    --tc-hover:     rgba(255, 255, 255, .07);
    --tc-selected:  rgba(120, 170, 255, .20);
}

/* Courses grid: show which row the Open Builder button will act on. */
.slick-row.tb-row-picked > .slick-cell { background: rgba(47, 111, 237, .14); }

/* ---------------------------------------------------------- shared controls */

.tc-input, .tp-input {
    padding: 4px 6px;
    border: 1px solid var(--tc-input-bd);
    border-radius: 3px;
    font-size: 13px;
    background: var(--tc-input-bg);
    color: var(--tc-input-text);
    width: 100%;
}
.tc-input.tc-xs { width: 62px; }

.tc-field { margin-bottom: 8px; }
.tc-field > label {
    display: block; font-weight: 600; font-size: 11px; margin-bottom: 3px;
    color: var(--tc-muted); text-transform: uppercase; letter-spacing: .03em;
}
.tc-hint, .tp-hint { font-size: 11px; color: var(--tc-faint); margin-top: 4px; line-height: 1.45; }
.tc-inline, .tp-inline {
    display: inline-flex; align-items: center; gap: 5px;
    font-weight: normal; font-size: 12px; margin-right: 14px;
}

.tc-btn, .tp-btn {
    padding: 5px 12px; border: 1px solid var(--tc-input-bd); border-radius: 4px;
    background: var(--tc-input-bg); cursor: pointer; font-size: 12px; color: var(--tc-text);
}
.tc-btn:hover:not(:disabled), .tp-btn:hover:not(:disabled) { background: var(--tc-hover); }
.tc-btn:disabled, .tp-btn:disabled { opacity: .5; cursor: not-allowed; }
.tc-btn-primary, .tp-btn-primary { background: var(--tc-accent); border-color: var(--tc-accent); color: #fff; }
.tc-btn-primary:hover:not(:disabled), .tp-btn-primary:hover:not(:disabled) { filter: brightness(.92); color: #fff; }

.tc-mini, .tp-mini {
    border: none; background: transparent; cursor: pointer;
    padding: 1px 5px; font-size: 12px; color: var(--tc-faint); line-height: 1;
}
.tc-mini:hover, .tp-mini:hover { color: var(--tc-accent); }

.tc-badge {
    display: inline-block; padding: 1px 8px; border-radius: 10px;
    font-size: 11px; background: var(--tc-hover); color: var(--tc-text); margin-left: 6px;
}
.tc-badge-draft  { background: var(--bs-warning-bg-subtle, #fff3cd); color: var(--bs-warning-text-emphasis, #856404); }
.tc-badge-locked { background: var(--bs-success-bg-subtle, #d1e7dd); color: var(--bs-success-text-emphasis, #0f5132); }
.tc-warn {
    color: var(--bs-warning-text-emphasis, #92400e);
    background: var(--bs-warning-bg-subtle, #fef3c7);
    padding: 8px 10px; border-radius: 4px;
}

/* ============================================================ document canvas */

/* initFullHeightGridPage sizes the parent, so 100% fills the viewport exactly. */
.tutorial-canvas {
    display: flex; flex-direction: column; height: 100%; min-height: 480px;
    background: var(--tc-surface); color: var(--tc-text); position: relative;
}

.tc-topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 8px 16px; border-bottom: 1px solid var(--tc-border); background: var(--tc-surface);
}
.tc-topbar-right { display: flex; align-items: center; gap: 10px; }
.tc-topbar .tc-input { width: auto; }
.tc-title { font-size: 14px; color: var(--tc-text); }

.tc-savestate { font-size: 11px; color: var(--tc-faint); min-width: 96px; text-align: right; }
.tc-savestate.tc-saved { color: var(--bs-success, #16a34a); }

.tc-body { display: flex; flex: 1; min-height: 0; }

/* --- navigation ----------------------------------------------------------- */

.tc-nav {
    width: 230px; border-right: 1px solid var(--tc-border); background: var(--tc-panel);
    display: flex; flex-direction: column; padding: 10px 8px; gap: 6px;
}

.tc-course-row { display: flex; gap: 4px; align-items: center; margin-bottom: 8px; }
.tc-course-row .tc-course-picker { flex: 1; min-width: 0; font-weight: 600; }
.tc-course-new {
    flex: none; border: 1px solid var(--tc-input-bd); border-radius: 4px;
    width: 26px; height: 26px; background: var(--tc-input-bg); color: var(--tc-text);
}
.tc-course-new:hover { border-color: var(--tc-accent); }

.tc-nav-list { flex: 1; overflow: auto; }

.tc-nav-module {
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 600; font-size: 12px; color: var(--tc-text);
    padding: 6px 4px 2px; margin-top: 6px;
}
.tc-nav-mtitle { outline: none; flex: 1; }
.tc-nav-mtitle:focus { background: var(--tc-surface); box-shadow: 0 0 0 2px var(--tc-accent); border-radius: 3px; }
.tc-nav-actions { display: none; }
.tc-nav-module:hover .tc-nav-actions { display: inline-block; }

.tc-nav-lesson {
    display: flex; align-items: center; justify-content: space-between;
    padding: 4px 8px; margin-left: 6px; border-radius: 4px;
    font-size: 13px; cursor: pointer; color: var(--tc-text);
}
.tc-nav-lesson:hover { background: var(--tc-hover); }
.tc-nav-lesson.tc-nav-current { background: var(--tc-selected); font-weight: 600; }
.tc-nav-ltitle { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-nav-lesson .tc-mini { display: none; }
.tc-nav-lesson:hover .tc-mini { display: inline-block; }

/* --- the page ------------------------------------------------------------- */

/* A small gutter on the stage instead of a wide dead margin around the page. */
.tc-stage { flex: 1; overflow: auto; background: var(--tc-stage-bg); padding: 14px 16px 40px; }

.tc-page {
    margin: 0 auto; background: var(--tc-surface); border: 1px solid var(--tc-border);
    border-radius: 6px; padding: 26px 30px 44px;
    width: 100%; min-height: calc(100% - 14px);
    /* Wide enough to fill a 1080p or 1440p screen completely; the cap only bites
       on ultra-wide monitors, where unlimited width would give unreadable line
       lengths. Pick a channel above to preview a deliberately narrower device. */
    max-width: 1600px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .04);
}

/* channel preview reflows the page rather than opening a separate view */
.tc-page.tc-ch-Kiosk  { max-width: 1024px; font-size: 17px; }
.tc-page.tc-ch-Mobile { max-width: 400px; padding: 28px 22px 48px; }
.tc-page.tc-ch-Portal { max-width: 900px; }

.tc-lesson-title {
    font-size: 28px; font-weight: 700; color: var(--tc-heading);
    margin: 0 0 18px; outline: none; line-height: 1.25;
}
.tc-lesson-title:focus { box-shadow: 0 -2px 0 var(--tc-accent) inset; }

.tc-empty { text-align: center; color: var(--tc-faint); padding: 60px 20px; }
.tc-empty p { margin-bottom: 14px; }

.tc-flow { position: relative; }

/* --- blocks --------------------------------------------------------------- */

.tc-block { position: relative; }
.tc-block-body { padding: 1px 0; }

.tc-gutter {
    position: absolute; left: -40px; top: 2px; width: 34px;
    display: none; flex-direction: column; align-items: center;
}
.tc-block:hover .tc-gutter { display: flex; }

.tc-text {
    outline: none; line-height: 1.7; color: var(--tc-text);
    padding: 5px 0; min-height: 1.7em; font-size: 15px;
}
.tc-page.tc-ch-Kiosk .tc-text { font-size: 18px; line-height: 1.8; }
.tc-text:empty:before,
.tc-lesson-title:empty:before {
    content: attr(data-placeholder); color: var(--tc-faint); pointer-events: none;
}

.tc-card {
    border: 1px solid var(--tc-border); border-radius: 8px; margin: 14px 0;
    background: var(--tc-panel); overflow: hidden;
}
.tc-card-head {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; background: var(--tc-hover); border-bottom: 1px solid var(--tc-border);
    font-size: 12px;
}
.tc-card-head i { color: var(--tc-accent); }
.tc-card-type { font-weight: 700; color: var(--tc-text); }
.tc-card-summary { color: var(--tc-faint); margin-left: auto; font-size: 11px; }
.tc-card-body { padding: 12px 14px; }

.tc-card-grid { display: flex; gap: 12px; flex-wrap: wrap; }
.tc-card-grid > .tc-field { flex: 1 1 130px; margin-bottom: 6px; }

.tc-sub { margin-top: 10px; }
.tc-sub-head {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .03em; color: var(--tc-muted); margin-bottom: 6px;
}
.tc-row { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.tc-row .tc-input { flex: 1 1 70px; min-width: 0; }
.tc-step-no {
    width: 18px; height: 18px; border-radius: 50%; background: var(--tc-accent-bg);
    color: var(--tc-accent); font-size: 11px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center; flex: none;
}

/* --- insert affordance ---------------------------------------------------- */

.tc-insert {
    position: relative; height: 12px; display: flex; align-items: center;
    margin: 0 0 0 -2px;
}
.tc-insert-btn {
    width: 20px; height: 20px; border-radius: 50%; flex: none;
    border: 1px solid var(--tc-input-bd); background: var(--tc-surface); color: var(--tc-faint);
    cursor: pointer; font-size: 13px; line-height: 1; opacity: 0;
    transition: opacity .12s;
}
.tc-insert-line { flex: 1; height: 1px; background: transparent; margin-left: 6px; }
.tc-insert:hover .tc-insert-btn,
.tc-insert.tc-insert-open .tc-insert-btn { opacity: 1; }
.tc-insert:hover .tc-insert-line { background: var(--tc-accent-bg); }
.tc-insert-btn:hover { border-color: var(--tc-accent); color: var(--tc-accent); }

/* --- slash / insert menu -------------------------------------------------- */

.tc-menu {
    display: none; position: absolute; z-index: 40; width: 290px;
    background: var(--tc-surface); border: 1px solid var(--tc-border); border-radius: 8px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, .18); padding: 6px; max-height: 340px;
    overflow: auto;
}
.tc-menu-item {
    display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
    padding: 7px 9px; border: none; background: transparent;
    border-radius: 5px; cursor: pointer; font-size: 13px; color: var(--tc-text);
}
.tc-menu-item:hover:not(.tc-disabled) { background: var(--tc-accent-bg); }
.tc-menu-item.tc-disabled { opacity: .4; cursor: not-allowed; }
.tc-menu-item i { color: var(--tc-accent); width: 16px; text-align: center; }
.tc-menu-name { font-weight: 600; color: var(--tc-text); }
.tc-menu-desc {
    margin-left: auto; font-size: 10px; color: var(--tc-faint);
    max-width: 130px; text-align: right; line-height: 1.3;
}

.tutorial-canvas.tc-locked .tc-page { background: var(--tc-panel); }
.tutorial-canvas.tc-locked .tc-insert,
.tutorial-canvas.tc-locked .tc-gutter { display: none !important; }

/* ------------------------------------------------------------------- player */

.tutorial-player { display: flex; height: 100%; background: var(--tc-surface); color: var(--tc-text); }

.tp-rail { width: 290px; border-right: 1px solid var(--tc-border); display: flex; flex-direction: column; }
.tp-rail-head { padding: 12px; border-bottom: 1px solid var(--tc-border); }
.tp-course-title { font-weight: 700; }
.tp-course-meta { font-size: 11px; color: var(--tc-faint); }
.tp-rail-list { flex: 1; overflow: auto; padding: 6px; }

.tp-rail-lesson {
    font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
    color: var(--tc-muted); margin: 10px 0 4px 6px; font-weight: 700;
}
.tp-rail-item {
    display: flex; align-items: center; gap: 7px; width: 100%; text-align: left;
    padding: 5px 7px; border: none; background: transparent; border-radius: 3px;
    cursor: pointer; font-size: 13px; color: var(--tc-text);
}
.tp-rail-item:hover { background: var(--tc-hover); }
.tp-rail-item.tp-current { background: var(--tc-selected); font-weight: 600; }
.tp-rail-item i { font-size: 10px; color: var(--tc-faint); }
.tp-status-COMPLETED i { color: var(--bs-success, #16a34a); }
.tp-status-FAILED i { color: var(--bs-danger, #dc2626); }
.tp-status-IN_PROGRESS i { color: var(--bs-warning, #f59e0b); }
.tp-req { font-size: 10px; color: var(--tc-faint); font-style: italic; margin-left: auto; }

.tp-stage { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.tp-stage-head { padding: 12px 18px; border-bottom: 1px solid var(--tc-border); }
.tp-lesson-name { font-size: 11px; color: var(--tc-faint); text-transform: uppercase; letter-spacing: .04em; }
.tp-block-name { font-size: 17px; font-weight: 600; color: var(--tc-heading); }
.tp-stage-body { flex: 1; overflow: auto; padding: 18px; }
.tp-stage-foot {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 10px 18px; border-top: 1px solid var(--tc-border); background: var(--tc-panel);
}
.tp-progress-text { font-size: 12px; color: var(--tc-muted); }

.tp-richtext { max-width: 820px; line-height: 1.6; margin-bottom: 14px; }
.tp-video { width: 100%; max-width: 900px; background: #000; border-radius: 6px; }
.tp-checkpoint-active {
    margin-top: 12px; padding: 14px; border-radius: 6px;
    background: var(--bs-warning-bg-subtle, #fff7ed);
    border: 1px solid var(--bs-warning-border-subtle, #fed7aa);
    color: var(--bs-warning-text-emphasis, inherit);
}
.tp-checkpoint-q { font-weight: 600; margin-bottom: 4px; }

.tp-hotspot-wrap { position: relative; display: inline-block; max-width: 100%; }
.tp-hotspot-img { max-width: 100%; display: block; }
.tp-hotspot {
    position: absolute; border: 2px dashed rgba(47, 111, 237, .5);
    background: rgba(47, 111, 237, .08); cursor: pointer; border-radius: 3px;
}
.tp-hotspot-hit  { border-color: var(--bs-success, #16a34a); background: rgba(22, 163, 74, .18); }
.tp-hotspot-miss { border-color: var(--bs-danger, #dc2626); background: rgba(220, 38, 38, .15); }
.tp-hotspot-status { margin-top: 10px; font-size: 13px; }

.tp-seq-list { max-width: 620px; margin-bottom: 12px; }
.tp-seq-item {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 8px 10px; margin-bottom: 5px;
    border: 1px solid var(--tc-border); border-radius: 4px; background: var(--tc-panel);
}
.tp-seq-status { margin: 8px 0; font-size: 13px; }

.tp-quiz { max-width: 760px; }
.tp-quiz-head { font-size: 12px; color: var(--tc-muted); margin-bottom: 12px; }
.tp-q { padding: 12px 0; border-bottom: 1px solid var(--tc-border); }
.tp-q-stem { font-weight: 600; margin-bottom: 8px; }
.tp-opt { display: block; padding: 3px 0; cursor: pointer; }
.tp-match { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; }
.tp-match span { flex: 1; }
.tp-match .tp-input { width: 200px; }

.tp-quiz-result { text-align: center; padding: 24px; border-radius: 8px; margin-bottom: 16px; }
.tp-quiz-result.tp-pass {
    background: var(--bs-success-bg-subtle, #ecfdf5); color: var(--bs-success-text-emphasis, #065f46);
}
.tp-quiz-result.tp-fail {
    background: var(--bs-danger-bg-subtle, #fef2f2); color: var(--bs-danger-text-emphasis, #991b1b);
}
.tp-score { font-size: 40px; font-weight: 700; line-height: 1; }
.tp-result { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--tc-border); font-size: 13px; }
.tp-correct i { color: var(--bs-success, #16a34a); }
.tp-wrong i { color: var(--bs-danger, #dc2626); }

.tp-doc {
    max-width: 820px; max-height: 460px; overflow: auto;
    border: 1px solid var(--tc-border); border-radius: 6px; padding: 16px;
    background: var(--tc-surface); color: var(--tc-text); line-height: 1.6;
}
.tp-doc-ref { color: var(--tc-muted); font-style: italic; }
.tp-sign { margin-top: 14px; max-width: 420px; display: flex; flex-direction: column; gap: 8px; }

/* ------------------------------------------------------------- my learning */

.my-learning { padding: 18px; overflow: auto; height: 100%; background: var(--tc-stage-bg); color: var(--tc-text); }
.ml-group { margin-bottom: 26px; }
.ml-group h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--tc-muted); }
.ml-count {
    display: inline-block; background: var(--tc-hover); color: var(--tc-text);
    border-radius: 10px; padding: 0 8px; font-size: 12px; margin-left: 6px;
}
.ml-overdue h3, .ml-overdue .ml-count { color: var(--bs-danger-text-emphasis, #991b1b); }
.ml-overdue .ml-count { background: var(--bs-danger-bg-subtle, #fee2e2); }

.ml-cards { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
.ml-card {
    width: 290px; text-align: left; cursor: pointer; color: var(--tc-text);
    background: var(--tc-surface); border: 1px solid var(--tc-border); border-radius: 8px; padding: 14px;
}
.ml-card:hover { border-color: var(--tc-accent); box-shadow: 0 2px 8px rgba(47, 111, 237, .12); }
.ml-overdue .ml-card { border-left: 4px solid var(--bs-danger, #dc2626); }
.ml-due .ml-card { border-left: 4px solid var(--bs-warning, #f59e0b); }
.ml-done .ml-card { opacity: .75; }

.ml-card-cat { font-size: 11px; text-transform: uppercase; color: var(--tc-faint); letter-spacing: .04em; }
.ml-card-title { font-weight: 700; margin: 3px 0 5px; color: var(--tc-heading); }
.ml-card-desc {
    font-size: 12px; color: var(--tc-muted); height: 32px; overflow: hidden; line-height: 1.35;
}
.ml-bar { height: 5px; background: var(--tc-hover); border-radius: 3px; margin: 10px 0 7px; overflow: hidden; }
.ml-bar > span { display: block; height: 100%; background: var(--tc-accent); }
.ml-card-foot { display: flex; justify-content: space-between; font-size: 11px; color: var(--tc-faint); gap: 6px; }
.ml-due-date { font-weight: 600; }
.ml-empty { color: var(--tc-faint); padding: 30px; text-align: center; }

/* ------------------------------------------- kiosk: big targets, gloves on */

@media (pointer: coarse) {
    .tp-rail-item { padding: 12px 10px; font-size: 15px; }
    .tp-btn { padding: 12px 20px; font-size: 15px; }
    .tp-opt { padding: 10px 0; font-size: 16px; }
    .tp-seq-item { padding: 14px; }
}
