/* ============================================================
   template.css — shared styles for all Vicente Matus courses
   All course-specific accent colours are injected via
   CSS custom properties on :root by the course data file.
   ============================================================ */
@import url('../styles/course-colors.css');

/* ── RESET & BASE ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; scroll-behavior: smooth; }

body {
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 300;
  color: var(--ink);
  background: var(--white);
  height: 100%;
  overflow: hidden;          /* fullscreen scroll handled by .lesson-body */
  -webkit-font-smoothing: antialiased;
}

/* ── DESIGN TOKENS (defaults — overridden per course) ───────── */
:root {
  --white:      #ffffff;
  --ink:        #0d0d0d;
  --ink2:       #4a4a4a;
  --ink3:       #888;
  --rule:       #e0e0e0;
  --rule2:      #f2f2f2;
  --sidebar-bg: #fafafa;
  --accent:     #1a56db;
  --acc2:       #e8f0fe;
  --mono:       'IBM Plex Mono', monospace;
  --sans:       'IBM Plex Sans', sans-serif;
  --sidebar-w:  260px;
  --topbar-h:   52px;
}

/* ── LAYOUT SHELL ────────────────────────────────────────────── */
/*
  Sidebar is a fixed overlay that slides in/out.
  .main-area fills the full viewport and shifts right only when
  sidebar is open — no gap ever.
*/
.app {
  display: contents; /* children lay themselves out */
}

.main-area {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-left: 0;
  transition: margin-left .25s ease;
}
.main-area.shifted {
  margin-left: var(--sidebar-w);
}

/* Dim backdrop shown on mobile when sidebar is open */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 99;
  cursor: pointer;
}
.sidebar-backdrop.visible { display: block; }

/* ── SIDEBAR ────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
  transform: translateX(calc(-1 * var(--sidebar-w)));
  transition: transform .25s ease;
}
.sidebar.open {
  transform: translateX(0);
}

/* Resize handle on right edge of sidebar */
.sidebar-resize-handle {
  position: absolute;
  top: 0; right: -4px; bottom: 0;
  width: 8px;
  cursor: col-resize;
  z-index: 101;
  background: transparent;
  transition: background .15s;
}
.sidebar-resize-handle:hover,
.sidebar-resize-handle.dragging {
  background: var(--accent);
  opacity: 0.3;
}

.sidebar-header {
  padding: 1.25rem 1.1rem 0.85rem;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}


.course-badge {
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 500;
  background: var(--acc2);
  color: var(--accent);
  padding: 0.18rem 0.5rem;
  border-radius: 2px;
  display: inline-block;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sidebar-title {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: var(--ink);
  margin-bottom: 0.2rem;
}

.sidebar-meta {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--ink3);
}

/* TOC scroll area */
.lesson-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0 2rem;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}
.lesson-nav::-webkit-scrollbar { width: 4px; }
.lesson-nav::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 2px; }

.unit-label {
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 500;
  color: var(--ink3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.85rem 1.1rem 0.3rem;
  user-select: none;
}

.lesson-item {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  padding: 0.38rem 1.1rem;
  cursor: pointer;
  transition: background .12s;
  border-left: 2px solid transparent;
  text-decoration: none;
  user-select: none;
}
.lesson-item:hover { background: var(--rule2); }
.lesson-item.active {
  background: var(--acc2);
  border-left-color: var(--accent);
}

.lesson-num {
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--ink3);
  flex-shrink: 0;
  width: 16px;
}
.lesson-item.active .lesson-num { color: var(--accent); }

.lesson-name {
  font-size: 0.78rem;
  color: var(--ink2);
  line-height: 1.3;
}
.lesson-item.active .lesson-name { color: var(--ink); font-weight: 500; }

/* ── TOP BAR ─────────────────────────────────────────────────── */
.topbar {
  flex-shrink: 0;
  height: var(--topbar-h);
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  gap: 1rem;
  z-index: 10;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
  padding-left: 40px;  /* space for fixed menu-toggle */
}

.menu-toggle {
  position: fixed;
  top: 10px;
  left: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  font-size: 1rem;
  color: var(--ink2);
  background: rgba(255,255,255,0.96);
  border: 1px solid var(--rule);
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color .15s, color .15s;
  line-height: 1;
  z-index: 200;
}
.menu-toggle:hover { border-color: var(--accent); color: var(--accent); }
.menu-toggle.active { background: var(--acc2); border-color: var(--accent); color: var(--accent); }

.topbar-lesson {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-lesson .counter { color: var(--accent); font-weight: 500; }
.topbar-lesson .lesson-title-top {
  color: var(--ink);
  font-weight: 400;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.nav-btn {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  padding: 0.28rem 0.75rem;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid var(--rule);
  background: var(--white);
  color: var(--ink2);
  transition: border-color .15s, color .15s;
  white-space: nowrap;
}
.nav-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--acc2); }
.nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.nav-btn.primary { background: var(--accent); color: white; border-color: var(--accent); }
.nav-btn.primary:hover { background: #1347b8; border-color: #1347b8; }


.progress-pill {
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--ink3);
  background: var(--rule2);
  border: 1px solid var(--rule);
  border-radius: 99px;
  padding: 0.18rem 0.6rem;
  white-space: nowrap;
}

.exit-btn {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--ink3);
  text-decoration: none;
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  white-space: nowrap;
  transition: border-color .15s, color .15s, background .15s;
  margin-left: 0.25rem;
}
.exit-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--acc2);
}

/* ── LESSON AREA ────────────────────────────────────────────── */
.lesson-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}
.lesson-area::-webkit-scrollbar { width: 5px; }
.lesson-area::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 3px; }

/* each slide is one scroll snap unit */
.slide {
  scroll-snap-align: start;
  scroll-snap-stop: always;
  min-height: calc(100vh - var(--topbar-h));
  display: none;
  flex-direction: row-reverse;
}
.slide.active { display: flex; }

/* ── SLIDE LAYOUT: video pane + content pane ─────────────────── */
.slide-video-pane {
  width: 400px;
  flex-shrink: 0;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 1.5rem 1rem;
  gap: 1rem;
  border-left: 1px solid #1a1a1a;
  position: sticky;
  top: 0;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}

/* Vertical (portrait 9:16) video container */
.video-portrait {
  width: 100%;
  max-width: 320px;
  position: relative;
  aspect-ratio: 9 / 16;
  background: #111;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #2a2a2a;
}
.video-portrait iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* placeholder state */
.video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  padding: 1.25rem;
  text-align: center;
}
.yt-play-icon {
  width: 48px;
  height: 48px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.yt-play-icon svg { width: 18px; height: 18px; fill: white; margin-left: 3px; }
.video-placeholder-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: #666;
  line-height: 1.5;
}

/* (YT input row removed) */

/* ── SLIDE CONTENT PANE ─────────────────────────────────────── */
.slide-content-pane {
  flex: 1;
  min-width: 0;           /* prevent flex blowout */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.slide-header {
  padding: 2.5rem 3.5rem 0;
  flex-shrink: 0;
}
.slide-body {
  padding: 0 3.5rem 2.5rem;
  flex: 1;
}

.slide-kicker {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--accent);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.slide-kicker::before { content: ''; width: 18px; height: 1px; background: var(--accent); }

.slide-title {
  font-size: clamp(1.5rem, 2.5vw, 2.2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 0.55rem;
}

.slide-subtitle {
  font-size: 0.95rem;
  color: var(--ink2);
  font-weight: 300;
  line-height: 1.6;
  margin-bottom: 1.75rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}

/* ── CONTENT COMPONENTS ─────────────────────────────────────── */
.objective {
  background: var(--acc2);
  border-left: 2px solid var(--accent);
  padding: 0.8rem 0.95rem;
  border-radius: 0 3px 3px 0;
  font-size: 0.86rem;
  color: var(--ink);
  line-height: 1.65;
  margin-bottom: 1.5rem;
}

.lesson-disclaimer {
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--ink2);
  background: var(--acc2);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 1rem;
}

.lesson-disclaimer strong {
  color: var(--ink);
}

.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
.content-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.content-grid.cols-1 { grid-template-columns: 1fr; }

.card {
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1rem 1.1rem;
}
.card-title {
  font-family: var(--mono);
  font-size: 0.63rem;
  font-weight: 500;
  color: var(--ink3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.55rem;
}
.card ul { padding-left: 1rem; }
.card ul li { font-size: 0.84rem; color: var(--ink2); line-height: 1.6; margin-bottom: 0.18rem; }
.card p { font-size: 0.84rem; color: var(--ink2); line-height: 1.65; }

.steps { display: flex; flex-direction: column; gap: 0.7rem; margin-bottom: 1.5rem; }
.step { display: grid; grid-template-columns: 28px 1fr; gap: 0 0.9rem; align-items: start; }
.step-num {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 500;
  color: white;
  background: var(--accent);
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 0.12rem;
}
.step-title { font-size: 0.86rem; font-weight: 500; margin-bottom: 0.12rem; }
.step-desc { font-size: 0.8rem; color: var(--ink2); line-height: 1.55; }

.flow {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 0; margin-bottom: 1.5rem;
}
.flow-box {
  background: var(--rule2); border: 1px solid var(--rule);
  border-radius: 3px; padding: 0.5rem 0.75rem;
  font-size: 0.76rem; font-weight: 500; text-align: center; min-width: 82px;
}
.flow-box.hi { background: var(--acc2); border-color: var(--accent); color: var(--accent); }
.flow-arrow { font-family: var(--mono); color: var(--ink3); padding: 0 0.45rem; font-size: 0.85rem; }

.data-table { width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; font-size: 0.82rem; }
.data-table thead tr { border-bottom: 2px solid var(--ink); }
.data-table th {
  font-family: var(--mono); font-size: 0.62rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink2);
  padding: 0 0 0.55rem; text-align: left;
}
.data-table tbody tr { border-bottom: 1px solid var(--rule2); }
.data-table td { padding: 0.55rem 0; color: var(--ink2); vertical-align: top; }
.data-table td:first-child { font-weight: 500; color: var(--ink); padding-right: 1.25rem; }

.callout {
  display: flex; gap: 0.8rem; align-items: flex-start;
  background: var(--rule2); border-radius: 4px;
  padding: 0.85rem 0.95rem; margin-bottom: 1.1rem;
  font-size: 0.83rem; line-height: 1.6; color: var(--ink2);
}
.callout-icon { font-size: 0.95rem; flex-shrink: 0; margin-top: 0.1rem; }
.callout.warn { background: #fefce8; border-left: 2px solid #d97706; }
.callout.tip  { background: #f0fdf4; border-left: 2px solid #16a34a; }
.callout.info { background: var(--acc2); border-left: 2px solid var(--accent); }

.tag-row { display: flex; flex-wrap: wrap; gap: 0.38rem; margin-top: 1.25rem; }
.tag {
  font-family: var(--mono); font-size: 0.6rem; font-weight: 500;
  padding: 0.16rem 0.5rem; border-radius: 2px;
  background: var(--rule2); color: var(--ink2);
  text-transform: uppercase; letter-spacing: 0.04em;
  border: 1px solid var(--rule);
}

/* (Figures and lesson notes sections removed — now handled by MD files) */

/* ── PROGRESS BAR ───────────────────────────────────────────── */
.progress-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 2px; background: var(--rule); z-index: 20;
  transition: left .25s ease;
}
.progress-bar.shifted {
  left: var(--sidebar-w);
}
.progress-fill {
  height: 100%; background: var(--accent); transition: width .35s ease;
}

/* ── CAROUSEL DOTS (mobile) ────────────────────────────────── */
.carousel-dots {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: none;            /* hidden on desktop */
  overflow: hidden;
  /* 7 dots × 7px + 6 gaps × 6px = 85px */
  width: 85px;
  height: 12px;
  align-items: center;
  z-index: 25;
  pointer-events: none;
}
.carousel-dots-track {
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform .25s ease;
  will-change: transform;
}
.carousel-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--rule);
  transition: transform .25s ease, background .25s ease;
  flex-shrink: 0;
}
.carousel-dot.active {
  background: var(--accent);
  transform: scale(1.35);
}

/* ── SWIPE HINTS (mobile) ───────────────────────────────────── */
.swipe-hint {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 56px;
  background: rgba(0,0,0,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.3rem;
  opacity: 0;
  transition: opacity .1s;
  pointer-events: none;
  z-index: 300;
}
.swipe-hint-prev { left: 0; border-radius: 0 6px 6px 0; }
.swipe-hint-next { right: 0; border-radius: 6px 0 0 6px; }

/* ── SLIDE TRANSITION ANIMATION ─────────────────────────────── */
@keyframes slide-from-right {
  from { opacity: 0.3; transform: translateX(36px); }
  to   { opacity: 1;   transform: translateX(0); }
}
@keyframes slide-from-left {
  from { opacity: 0.3; transform: translateX(-36px); }
  to   { opacity: 1;   transform: translateX(0); }
}
.slide.anim-forward  { animation: slide-from-right .22s ease-out; }
.slide.anim-backward { animation: slide-from-left  .22s ease-out; }

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* On mobile the sidebar never shifts the main area — it overlays */
  .main-area.shifted {
    margin-left: 0;
  }
  /* Show backdrop on mobile when sidebar open */
  .sidebar-backdrop.visible { display: block; }

  /* Disable scroll-snap on mobile — navigation is handled by horizontal swipe */
  .lesson-area {
    scroll-snap-type: none;
  }

  /* Video moves to AFTER title/subtitle on mobile */
  .slide {
    flex-direction: column;
    min-height: auto;
  }
  /* Dissolve the content pane so header and body participate directly in the flex column */
  .slide-content-pane {
    display: contents;
  }
  .slide-header {
    order: 1;
    padding: 1.5rem 1.1rem 0.75rem;
    flex-shrink: 0;
  }
  .slide-video-pane {
    order: 2;
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--rule);
    padding: 1rem 1rem 1.25rem;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    background: var(--ink);
    min-height: unset;
    position: static;
    height: auto;
    overflow-y: visible;
  }
  .slide-body {
    order: 3;
    padding: 0.75rem 1.1rem 1.5rem;
    flex: 1;
  }
  .video-portrait { max-width: 160px; flex-shrink: 0; }
  .content-grid, .content-grid.cols-3 { grid-template-columns: 1fr; }
  .progress-bar.shifted { left: 0; }

  /* Show carousel dots on mobile */
  .carousel-dots { display: flex; }

  /* ── TOPBAR: icons-only on mobile ── */
  .topbar { padding: 0 0.75rem; gap: 0.5rem; }
  .topbar-left { padding-left: 36px; }
  .topbar-lesson { display: none; }
  .topbar-right { gap: 0.35rem; }
  .btn-label { display: none; }
  .nav-btn { padding: 0.28rem 0.5rem; }
  .exit-btn { padding: 0.28rem 0.5rem; margin-left: 0; }
}

/* ── MARKDOWN BODY ───────────────────────────────────────── */
.md-body h1, .md-body h2, .md-body h3, .md-body h4 {
  margin: 1.2em 0 0.4em; font-weight: 600; line-height: 1.3;
}
.md-body h1 { font-size: 1.25rem; }
.md-body h2 { font-size: 1.1rem; }
.md-body h3 { font-size: 0.95rem; }
.md-body p { margin: 0.6em 0; line-height: 1.65; }
.md-body ul, .md-body ol { padding-left: 1.4em; margin: 0.6em 0; }
.md-body li { margin-bottom: 0.25em; line-height: 1.55; }
.md-body code {
  font-family: var(--mono, 'IBM Plex Mono', monospace);
  font-size: 0.85em; background: var(--acc2, #f2f2f2);
  padding: 0.15em 0.4em; border-radius: 3px;
}
.md-body pre {
  background: #1e1e1e; color: #d4d4d4; padding: 1rem 1.2rem;
  border-radius: 4px; overflow-x: auto; font-size: 0.82rem;
  line-height: 1.5; margin: 0.8em 0;
}
.md-body pre code { background: none; padding: 0; color: inherit; }
.md-body blockquote {
  border-left: 3px solid var(--accent, #1a56db); margin: 0.8em 0;
  padding: 0.4em 1em; color: var(--ink2, #4a4a4a);
}
.md-body table { width: 100%; border-collapse: collapse; margin: 0.8em 0; font-size: 0.85rem; }
.md-body th, .md-body td { border: 1px solid var(--rule, #e0e0e0); padding: 0.45em 0.7em; text-align: left; }
.md-body th { background: var(--soft, #f2f2f2); font-weight: 500; }
.md-body hr { border: none; border-top: 1px solid var(--rule, #e0e0e0); margin: 1.2em 0; }
.md-body img { max-width: 100%; border-radius: 4px; cursor: zoom-in; }
.md-body a { color: var(--accent, #1a56db); text-decoration: underline; }

/* ── COVER PAGE ─────────────────────────────────────────────── */
.cover-page {
  display: none;
  flex-direction: column;
  min-height: calc(100vh - var(--topbar-h));
}
.cover-page.active { display: flex; }

/* Hero */
.cover-hero {
  position: relative;
  background: linear-gradient(135deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 60%, #000) 100%);
  padding: 3.5rem 2.5rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-height: 320px;
  overflow: hidden;
}
.cover-hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.35;
}
.cover-hero-overlay {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 680px;
}
.cover-badge-lg {
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.75);
  background: rgba(255,255,255,0.12);
  padding: 0.25rem 0.7rem;
  border-radius: 2px;
  display: inline-block;
  margin-bottom: 1rem;
}
.cover-hero-title {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 0.6rem;
}
.cover-hero-meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.03em;
}

/* Body */
.cover-body {
  max-width: 860px;
  margin: 0 auto;
  padding: 2.5rem 3rem 3rem;
  width: 100%;
}
.cover-section {
  margin-bottom: 2.5rem;
}
.cover-section h2 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
}
.cover-section p {
  font-size: 0.9rem;
  color: var(--ink2);
  line-height: 1.7;
}
.cover-actions-block {
  margin-top: 3rem;
  margin-bottom: 3rem;
  padding: 1.35rem 1.5rem 1.5rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--white) 0%, var(--rule2) 100%);
  box-shadow: 0 10px 30px rgba(14, 20, 34, 0.05);
}
.cover-actions-block h2 {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0.35rem;
}
.cover-actions-block p {
  margin-bottom: 1.15rem;
}
.cover-section-annex {
  margin-top: 3.25rem;
  padding-top: 1.5rem;
  border-top: 1px dashed var(--rule);
}

/* TOC grid */
.cover-toc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
.cover-unit-card {
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--white);
  transition: border-color 0.15s;
  overflow: hidden;
}
.cover-unit-card:hover,
.cover-unit-card.open {
  border-color: var(--accent);
}

/* Collapsible header */
.cover-unit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.85rem 1.1rem;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.12s;
}
.cover-unit-header:hover { background: var(--rule2); }
.cover-unit-num {
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  display: block;
  margin-bottom: 0.15rem;
}
.cover-unit-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  display: block;
}
.cover-unit-chevron {
  font-size: 0.7rem;
  color: var(--ink3);
  transition: transform 0.2s ease;
  flex-shrink: 0;
  margin-left: 0.5rem;
}
.cover-unit-card.open .cover-unit-chevron {
  transform: rotate(180deg);
}

/* Collapsible lesson list */
.cover-unit-lessons {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.cover-unit-card.open .cover-unit-lessons {
  max-height: 600px; /* large enough for 5 items */
}
.cover-unit-card li {
  font-size: 0.78rem;
  color: var(--ink2);
  line-height: 1.5;
  padding: 0.15rem 1.1rem;
  border-top: 1px solid var(--rule2);
}
.cover-unit-card li a {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
  padding: 0.15rem 0;
  transition: color 0.12s;
}
.cover-unit-card li a:hover { color: var(--accent); }
.toc-num {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--ink3);
  margin-right: 0.3rem;
}

/* Navigation guide */
.nav-guide-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
.nav-guide-card {
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1rem 0.85rem;
  text-align: center;
  background: var(--white);
  transition: border-color 0.15s;
}
.nav-guide-card:hover { border-color: var(--accent); }
.nav-guide-keys {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}
.nav-guide-keys kbd {
  font-family: var(--mono);
  font-size: 0.75rem;
  background: var(--rule2);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.15rem 0.4rem;
  color: var(--ink);
}
.nav-guide-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.25rem;
}
.nav-guide-desc {
  font-size: 0.68rem;
  color: var(--ink3);
  line-height: 1.45;
}

/* Navigation video placeholder */
.cover-nav-video {
  margin-top: 1.25rem;
}
.cover-nav-video iframe {
  width: 100%;
  max-width: 560px;
  aspect-ratio: 16 / 9;
  border: none;
  border-radius: 6px;
  display: block;
  margin: 0 auto;
}

/* Action buttons */
.cover-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-start;
  flex-wrap: wrap;
}
.cover-btn {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.65rem 1.5rem;
  border-radius: 4px;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
  min-width: 220px;
  text-align: center;
}
.cover-btn:hover { opacity: 0.88; transform: translateY(-1px); }
.cover-btn:active { transform: translateY(0); }
.cover-btn-start {
  background: var(--accent);
  color: #fff;
}
.cover-btn-download {
  background: var(--white);
  color: var(--ink);
  border: 1px solid var(--rule);
}
.cover-btn-download:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Lightbox ──────────────────────────────────────────── */
#lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,.85);
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
#lightbox.open {
  display: flex;
}
#lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 6px;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
  cursor: default;
  object-fit: contain;
}
#lightbox-close {
  position: fixed;
  top: 1rem;
  right: 1.2rem;
  font-size: 2rem;
  line-height: 1;
  color: #fff;
  cursor: pointer;
  opacity: .7;
  user-select: none;
}
#lightbox-close:hover { opacity: 1; }

/* Cover responsive */
@media (max-width: 768px) {
  .cover-hero {
    padding: 2.5rem 1.25rem 2rem;
    min-height: 220px;
  }
  .cover-hero-title {
    font-size: 1.6rem;
  }
  .cover-body {
    padding: 1.5rem 1.1rem 2rem;
  }
  .cover-toc-grid {
    grid-template-columns: 1fr;
  }
  .nav-guide-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }
  .cover-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .cover-btn {
    text-align: center;
  }
}
