/* player.css — standalone course player stylesheet for useful exports */

.error-msg { color: #e8e8f0; padding: 2rem; font-family: sans-serif; }

@font-face {
  font-family: 'icons';
  src: url('assets/fonts/icons.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
}
[class^="icon-"]:before, [class*=" icon-"]:before {
  font-family: "icons";
  font-style: normal;
  font-weight: normal;
  speak: never;
  display: inline-block;
  text-decoration: inherit;
  width: 1em;
  text-align: center;
  font-variant: normal;
  text-transform: none;
  line-height: 1em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.icon-play:before            { content: '0'; }
.icon-stop:before            { content: '1'; }
.icon-pause:before           { content: '2'; }
.icon-fast-fw:before         { content: '3'; }
.icon-rewind:before          { content: '4'; }
.icon-download:before        { content: '5'; }
.icon-ok:before              { content: '6'; }
.icon-menu:before            { content: '7'; }
.icon-fullscreen:before      { content: '8'; }
.icon-exit-fullscreen:before { content: '9'; }

@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/OpenSans-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Open Sans';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/OpenSans-Italic.woff2') format('woff2');
}
@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('assets/fonts/OpenSans-SemiBold.woff2') format('woff2');
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0d0d0f;
  --surface:      #16161e;
  --surface-hi:   #1e1e2a;
  --border:       #2a2a3e;
  --text:         #e8e8f0;
  --text-muted:   #9898b0;
  --text-dim:     #5a5a78;
  --accent:       #7c6af7;
  --accent-dim:   rgba(124,106,247,0.18);
  --danger:       #e05555;
  --radius:       6px;
  --font:         'Open Sans', system-ui, sans-serif;
  --ctrl-height:  52px;
  --sidebar-w:    320px;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

/* ── App root ──────────────────────────────────────────────────────────────── */

#app { height: 100%; }

/* Semantic fallback article — hidden when player is active */
.player-active .module-content { display: none; }

/* ── Player shell ─────────────────────────────────────────────────────────── */

#player-shell {
  display: flex;
  height: 100%;
  overflow: hidden;
}

/* ── Player area (left column) ────────────────────────────────────────────── */

#player-area {
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: hidden;
  background: #12121a;
}

/* ── Slide stage ──────────────────────────────────────────────────────────── */

#slide-stage {
  position: absolute;
  inset: 0;
  background: #12121a;
  overflow: hidden;
}

/* 1920×1080 canvas; scaled via JS transform */
#slide-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 1920px;
  height: 1080px;
  transform-origin: top left;
  font-size: 40px;
}

/* ── Slide renderer styles (match slide-preview.js) ──────────────────────── */

.sp-slide {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
  font-family: var(--font);
}
.sp-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 2.5% 5%;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  flex-shrink: 0;
  gap: 8px;
  font-size: 0.65em; /* 0.65 × 40px = 26px — same visual size as 1.3 × 20px was */
}
.sp-header img { height: 1.6em; object-fit: contain; vertical-align: middle; }
.sp-hdr-right { text-align: right; }
.sp-body {
  flex: 1; display: flex; flex-direction: column;
  justify-content: center;
  padding: 4% 7%; gap: 0.6em;
  overflow: hidden; min-height: 0;
}
.sp-columns { display: flex; width: 100%; overflow: hidden; }
.sp-col-inner {
  flex: 1; display: flex; flex-direction: column;
  justify-content: flex-start;
  padding: 4% 5%; gap: 0.5em; overflow: hidden;
}
.sp-para        { margin: 0; line-height: 1.55; }
.sp-para.big    { font-size: 1.4em; }
.sp-para.small  { font-size: 0.75em; }
.sp-para.center { text-align: center; }
.sp-para.right  { text-align: right; }
.sp-h1 { font-size: 1.8em;   font-weight: 700; line-height: 1.2; }
.sp-h2 { font-size: 1.3em; font-weight: 600; line-height: 1.3; }
.sp-h1.center, .sp-h2.center { text-align: center; }
.sp-h1.right,  .sp-h2.right  { text-align: right; }
#slide-canvas ul, #slide-canvas ol {
  margin: 0; padding-left: 1.4em; line-height: 1.6;
}
#slide-canvas ul.big li, #slide-canvas ol.big li { font-size: 1.25em; }
#slide-canvas ul.small li, #slide-canvas ol.small li { font-size: 0.75em; }
#slide-canvas ul.center, #slide-canvas ol.center {
  text-align: center; list-style-position: inside; padding-left: 0;
}
.sp-code {
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  padding: 0.7em 1em;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.88em;
  white-space: pre; overflow: auto; line-height: 1.5;
}
.sp-img-wrap     { flex: 1; min-height: 4em; overflow: hidden; }
.sp-img-wrap img { display: block; width: 100%; height: 100%; }
#slide-canvas strong { font-weight: 700; }
#slide-canvas em     { font-style: italic; }
#slide-canvas u      { text-decoration: underline; }
.sp-emph {
  display: flex; flex-direction: column; gap: 0.3em;
}
/* Emph dimming during playback — mirrors slide-preview.js exactly */
.sp-emph-active > .sp-block:not(.sp-is-emph-current) { opacity: 0.1; transition: opacity 0.25s; }
.sp-emph-active > .sp-block.sp-is-emph-current        { opacity: 1;   transition: opacity 0.25s; }
.sp-block { transition: opacity 0.25s; }
.sp-plugin {
  flex: 1; min-height: 0; overflow: hidden; position: relative;
  display: flex; flex-direction: column;
}
.sp-plugin-out { position: absolute; inset: 0; overflow: hidden; }
.sp-error {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--text-muted); font-size: 1.2em;
}

/* ── Controls auto-hide ───────────────────────────────────────────────────── */

#controls {
  transition: opacity 0.4s ease, visibility 0s linear 0.4s;
}
/* Hide when playing and no recent mouse activity */
#player-area.controls-hidden #controls {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0s linear 0.4s;
}
#player-area.controls-hidden { cursor: none; }

/* ── Controls bar ─────────────────────────────────────────────────────────── */

#controls {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 10;
  height: var(--ctrl-height);
  background: rgba(13, 13, 15, 0.88);
  backdrop-filter: blur(4px);
  display: flex; align-items: center;
  padding: 0 12px; gap: 8px;
  user-select: none;
}

#controls-left  { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
#controls-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

#controls-progress {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 8px;
}

.ctrl-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  font-family: var(--font);
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
  min-height: 32px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.ctrl-btn:hover { color: var(--text); border-color: var(--border); background: var(--surface-hi); }
.ctrl-btn:active { background: var(--accent-dim); }
.ctrl-btn[hidden] { display: none; }

#btn-play-pause {
  border-color: var(--border);
  background: var(--surface-hi);
  color: var(--text);
  min-width: 40px;
}

#time-current, #time-total, #time-remaining {
  font-size: 12px; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
#time-remaining { display: none; }

#progress-bar-wrap {
  flex: 1; min-width: 0;
  /* Enlarged touch target */
  padding: 10px 0; margin: -10px 0;
  cursor: pointer; position: relative;
}

#progress-bar-bg {
  height: 4px; border-radius: 2px;
  background: var(--border);
  position: relative; overflow: visible;
}

#progress-bar-fill {
  height: 100%; border-radius: 2px;
  background: var(--accent);
  pointer-events: none;
  transition: width 0.1s linear;
}

#progress-scrubber {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
  margin: 0; padding: 0;
  /* Expand touch target */
  top: -10px; height: calc(100% + 20px);
}
#progress-scrubber::-webkit-slider-thumb { cursor: pointer; }

#speed-select {
  background: var(--surface-hi);
  color: var(--text);
  border-color: var(--border);
  cursor: pointer;
}
#speed-select option {
  background: var(--surface-hi);
  color: var(--text);
}

/* ── Resume prompt ────────────────────────────────────────────────────────── */

#resume-prompt {
  position: absolute;
  bottom: var(--ctrl-height);
  left: 0; right: 0;
  z-index: 10;
  background: rgba(30, 30, 42, 0.92);
  backdrop-filter: blur(4px);
  border-top: 1px solid var(--accent);
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px;
  font-size: 13px; color: var(--text-muted);
}
#resume-prompt[hidden] { display: none; }
#resume-prompt button {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  padding: 4px 12px; cursor: pointer; font-size: 12px;
  font-family: var(--font);
  transition: background 0.15s;
}
#resume-prompt button:hover { background: var(--accent); color: #fff; }
#btn-resume-no {
  background: transparent; border-color: var(--border); color: var(--text-muted);
}
#btn-resume-no:hover { background: var(--surface); color: var(--text); }

/* ── Module sidebar (right column) ───────────────────────────────────────── */

#module-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow: hidden;
}

/* Scrollbar styles for sidebar */
#module-sidebar::-webkit-scrollbar { width: 6px; }
#module-sidebar::-webkit-scrollbar-track { background: transparent; }
#module-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

#sidebar-title {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px 10px 16px;
  font-weight: 600; font-size: 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  color: var(--text);
}
#sidebar-title-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#btn-install { padding: 4px 8px; flex-shrink: 0; font-size: 14px; }

#module-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 8px 0;
}
#module-list::-webkit-scrollbar { width: 6px; }
#module-list::-webkit-scrollbar-track { background: transparent; }
#module-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.module-item {
  cursor: pointer;
  padding: 0;
  border-left: 2px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.module-item:hover      { background: var(--surface-hi); }
.module-item.is-active  { border-left-color: var(--accent); background: var(--accent-dim); }
.module-item.is-complete { opacity: 0.75; }

.module-item-inner {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  min-height: 44px;
}

.module-check {
  width: 16px; flex-shrink: 0;
  color: var(--accent); font-size: 13px;
  font-weight: 700;
}

.module-title {
  flex: 1; min-width: 0;
  font-size: 13px; line-height: 1.35;
  color: var(--text);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.module-dur {
  font-size: 11px; color: var(--text-muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.module-progress {
  height: 2px;
  background: var(--border);
  margin: 0 14px 6px;
  border-radius: 1px;
  overflow: hidden;
}
.module-progress-fill {
  height: 100%; background: var(--accent);
  border-radius: 1px;
  transition: width 0.3s;
}

#course-progress-wrap {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#course-progress-label {
  font-size: 12px; color: var(--text-muted);
}

/* ── Offline caching progress ─────────────────────────────────────────────── */

#sw-status {
  padding: 8px 14px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
#sw-status[hidden] { display: none; }
#sw-status-text { font-size: 11px; color: var(--text-muted); }
#sw-status-bar-wrap {
  height: 3px;
  background: var(--bg-elevated);
  border-radius: 2px;
  overflow: hidden;
}
#sw-status-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.4s ease;
}


/* ── Content update notice ────────────────────────────────────────────────── */

#sw-update {
  padding: 8px 14px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#sw-update[hidden] { display: none; }
#sw-update-text { font-size: 11px; color: var(--text-muted); }
#btn-sw-update {
  align-self: flex-start;
  padding: 4px 10px;
  font-size: 11px;
  font-family: var(--font);
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  line-height: 1.6;
}
#btn-sw-update:hover { opacity: 0.85; }

/* ── Data-usage confirmation modal ───────────────────────────────────────── */

#data-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
#data-modal[hidden] { display: none; }
#data-modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px 18px;
  max-width: 320px;
  width: calc(100% - 40px);
  display: flex; flex-direction: column; gap: 16px;
}
#data-modal-msg {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  margin: 0;
}
#data-modal-btns {
  display: flex; gap: 8px; justify-content: flex-end;
}
#data-modal-btns button {
  padding: 6px 14px;
  font-size: 12px;
  font-family: var(--font);
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid var(--border);
}
#btn-data-cancel  { background: var(--surface-hi); color: var(--text-muted); }
#btn-data-confirm { background: var(--accent);     color: #fff; border-color: var(--accent); }
#btn-data-cancel:hover  { opacity: 0.8; }
#btn-data-confirm:hover { opacity: 0.85; }

/* ── Fullscreen: sidebar accessible as hover overlay ─────────────────────── */

#player-shell:fullscreen #module-sidebar {
  position: absolute; right: 0; top: 0; bottom: 0;
  z-index: 20;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  border-left: none;
  box-shadow: -4px 0 24px rgba(0,0,0,0.6);
}
#player-shell:fullscreen #module-sidebar:hover,
#player-shell:fullscreen #module-sidebar.is-open {
  transform: translateX(0);
}

/* ── Mobile (< 768px): single-column + modules drawer ────────────────────── */

@media (max-width: 767px) {
  html, body { overflow: hidden; }

  #player-shell {
    flex-direction: column;
    position: relative;
  }

  #player-area { flex: 1; min-height: 0; }

  #module-sidebar {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    width: 100%;
    height: 60%;
    border-left: none;
    border-top: 1px solid var(--border);
    transform: translateY(100%);
    transition: transform 0.25s ease;
    z-index: 30;
  }
  #module-sidebar.is-open { transform: translateY(0); }

  /* Backdrop when drawer is open */
  #module-sidebar.is-open::before {
    content: '';
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: -1;
  }

  #btn-modules { display: flex; }

  #controls { padding: 0 8px; gap: 4px; }
  .ctrl-btn  { padding: 4px 8px; font-size: 12px; }
  .btn-label { display: none; }

  #time-current, #time-total { display: none; }
  #time-remaining { display: block; }
  #progress-bar-wrap { display: none; }


}

@media (min-width: 768px) {
  #btn-modules { display: none; }
}

/* ── Medium screens (768–1023px): narrower sidebar ───────────────────────── */

@media (min-width: 768px) and (max-width: 1023px) {
  :root { --sidebar-w: 260px; }
}

/* ── No-JS fallback: module-content (article) is readable without JS ──────── */

.module-content {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}
.module-content h1 { font-size: 1.8rem; margin-bottom: 1.5rem; }
.module-content h2 { font-size: 1.4rem; margin: 1.5rem 0 0.5rem; }
.module-content h3 { font-size: 1.2rem; margin: 1.2rem 0 0.4rem; }
.module-content p  { margin-bottom: 0.8rem; }
.module-content ul, .module-content ol { margin: 0.5rem 0 0.8rem 1.5rem; }
.module-content li { margin-bottom: 0.25rem; }
.module-content pre {
  background: #1a1a2e; padding: 1rem; border-radius: 6px;
  overflow-x: auto; margin: 0.8rem 0; font-size: 0.875rem;
}
.module-content figure { margin: 1rem 0; }
.module-content img { max-width: 100%; border-radius: 4px; }
.module-content .slide { border-bottom: 1px solid var(--border); padding: 1.5rem 0; }
.module-content .slide:last-child { border-bottom: none; }
.module-content .columns { display: flex; gap: 1rem; }
.module-content .col { flex: 1; }
