/* =========================================================
   IP Stewardship Lab | Lesson Preview
   Brand: ISL live portal palette (maple-portal.onrender.com/isl)
   Defaults used from brief (no live-portal CSS access).
   ========================================================= */

/* --- Google Fonts (Inter only; no Cormorant Garamond, no Lora) --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- Color tokens (ISL live portal palette) --- */
:root {
  /* Primary accent */
  --pink:       #EC4899;    /* buttons, active dot, bullet dots, play button */
  --pink-deep:  #BE185D;    /* hover, active states */

  /* Background tones */
  --tan:        #F5EFE7;    /* boxed-section bg (objectives, study cards) */
  --tan-2:      #EFE7DB;    /* deeper alternating section bg, CTA card */
  --cream-bg:   #FAF6F0;    /* overall page background */
  --white:      #FFFFFF;    /* card / panel backgrounds, main pane */

  /* Text */
  --ink:        #1A1A1A;    /* headings */
  --text:       #2A2A2A;    /* body copy */
  --muted:      #6B6B6B;    /* meta labels, "Module N of 11", durations */

  /* Structure */
  --rule:       #E5DDD0;    /* dividers, borders */
  --lock:       #9CA3AF;    /* locked lesson icon */
  --check:      #10B981;    /* completed checkmark green */

  /* Typography */
  --font-display: 'Inter', system-ui, -apple-system, sans-serif;
  --font-body:    'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;

  /* Spacing */
  --section-gap: 2.5rem;
  --card-pad:    2rem;
  --radius:      0.5rem;
  --radius-sm:   0.375rem;
}

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

/* --- Base --- */
html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  background-color: var(--cream-bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--ink);
  line-height: 1.2;
}

h1 { font-size: 2.25rem; font-weight: 700; }
h2 { font-size: 1.5rem; font-weight: 600; }
h3 { font-size: 1.15rem; font-weight: 600; }

p { margin-bottom: 1rem; }
p:last-child { margin-bottom: 0; }

a {
  color: var(--pink);
  text-decoration: none;
}
a:hover { color: var(--pink-deep); text-decoration: underline; }

/* =========================================================
   SITE HEADER (top nav bar)
   ========================================================= */
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--rule);
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.site-header-brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.site-header-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.site-header-sub {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.site-header-nav {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.site-header-nav a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.site-header-nav a:hover {
  color: var(--ink);
  text-decoration: none;
}

/* =========================================================
   PAGE HERO (full-width below header)
   ========================================================= */
.page-hero {
  background: var(--tan);
  border-bottom: 1px solid var(--rule);
  padding: 2.5rem 2rem;
}

.page-hero h1 {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.75rem;
}

.page-hero-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.page-hero-progress-label {
  font-size: 0.8125rem;
  color: var(--muted);
  white-space: nowrap;
}

.page-hero-progress-bar {
  width: 200px;
  height: 6px;
  background: var(--rule);
  border-radius: 3px;
  overflow: hidden;
}

.page-hero-progress-fill {
  height: 100%;
  background: var(--pink);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* =========================================================
   TWO-COLUMN BODY LAYOUT
   ========================================================= */
.course-layout {
  display: flex;
  min-height: calc(100vh - 120px);
}

/* =========================================================
   LEFT SIDEBAR
   ========================================================= */
.course-sidebar {
  width: 320px;
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  height: calc(100vh - 120px);
  position: sticky;
  top: 64px;
}

.sidebar-header {
  padding: 1.25rem 1.5rem 0.75rem;
  border-bottom: 1px solid var(--rule);
}

.sidebar-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.sidebar-workbook {
  font-size: 0.8125rem;
  color: var(--pink);
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.sidebar-workbook:hover {
  color: var(--pink-deep);
  text-decoration: underline;
}

.sidebar-modules {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

/* Individual sidebar row */
.sidebar-module-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1.5rem;
  border: none;
  border-left: 3px solid transparent;
  background: transparent;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.12s, border-color 0.12s;
  text-decoration: none;
}

.sidebar-module-item:hover {
  background: var(--tan);
}

.sidebar-module-item.active {
  background: rgba(236, 72, 153, 0.05);
  border-left-color: var(--pink);
}

.sidebar-module-item.active .sidebar-module-title {
  font-weight: 600;
  color: var(--ink);
}

.sidebar-status-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 0.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Pink dot for current */
.icon-current {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pink);
}

/* Green check for done */
.icon-done {
  color: var(--check);
  font-size: 14px;
  line-height: 1;
}

/* Gray lock for locked */
.icon-lock {
  color: var(--lock);
  font-size: 13px;
  line-height: 1;
}

/* Gray dot for available but not active */
.icon-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rule);
  border: 1.5px solid var(--muted);
}

.sidebar-module-text {
  flex: 1;
  min-width: 0;
}

.sidebar-module-title {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text);
  line-height: 1.4;
  white-space: normal;
}

.sidebar-module-duration {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.2rem;
  font-family: var(--font-mono);
}

/* =========================================================
   MAIN CONTENT PANE
   ========================================================= */
.course-main {
  flex: 1;
  background: var(--white);
  padding: 2.5rem;
  max-width: 820px;
  overflow-y: auto;
}

.lesson-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
}

.lesson-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
  margin-bottom: 1.75rem;
}

/* =========================================================
   LEARNING OBJECTIVES BOX
   ========================================================= */
.objectives-box {
  background: var(--tan);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: var(--section-gap);
}

.objectives-box-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--pink);
  margin-bottom: 1rem;
}

.objectives-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.objectives-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text);
}

.objectives-list li::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pink);
  flex-shrink: 0;
  margin-top: 0.525rem;
}

/* =========================================================
   VIDEO WRAPPER + CONTROLS
   ========================================================= */
.video-section {
  margin-bottom: var(--section-gap);
}

.video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1420 / 1080;  /* 1920×1080 minus right 18% (346px) and left 8% (154px) = 1420×1080 */
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}

/* Dual-side crop: remove left 8% (154px) and right 18% (346px) of 1920px original.
   Visible window: pixels 154–1574, width 1420px.
   We render the video at 135.21% width (1920/1420) and shift left by 10.85% (154/1420)
   so pixel 154 of the source aligns with the wrapper left edge. */
.video-element {
  position: absolute;
  top: 0;
  left: -10.85%;   /* shifts video left so original pixel 154 = wrapper left edge */
  width: 135.21%;  /* 1920/1420 — full 1920px source fills 135.21% of 1420px wrapper */
  height: 100%;
  object-fit: fill; /* fill keeps the 1920×1080 ratio intact; cropping is done by wrapper overflow:hidden */
  /* Exposure / color correction via CSS custom properties (driven by sliders in app.js) */
  filter: brightness(var(--brightness, 0.94)) contrast(var(--contrast, 1.05)) saturate(var(--saturation, 1.02)) sepia(var(--warmth, 0)) hue-rotate(var(--hue, 0deg));
}

/* Highlight dim mask — right-side gradient overlay to soften bright areas.
   Sits above video (z-index 2) but below title card (z-index 10). */
.highlight-mask {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(to left, rgba(0,0,0,var(--highlight-dim, 0)) 0%, transparent 60%);
}

/* Title card overlay */
.title-card {
  position: absolute;
  inset: 0;
  background: var(--tan);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.875rem;
  z-index: 10;
  opacity: 1;
  transition: opacity 1s ease;
  pointer-events: none;
}

.title-card.fading {
  opacity: 0;
}

.title-card-label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--pink);
}

.title-card-text {
  font-family: var(--font-display);
  font-size: 2.75rem;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  line-height: 1.15;
  padding: 0 2rem;
}

/* =========================================================
   CUSTOM VIDEO PLAYER CONTROLS
   ========================================================= */
.custom-player {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0 0;
  width: 100%;
}

.custom-player-play {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--pink);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
  color: #fff;
  font-size: 0.875rem;
  line-height: 1;
  padding: 0;
}

.custom-player-play:hover {
  background: var(--pink-deep);
}

.custom-player-play .play-icon {
  /* triangle via border trick — visually centered */
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 10px solid #fff;
  margin-left: 2px; /* optical centering */
  display: block;
}

.custom-player-play .pause-icon {
  display: flex;
  gap: 3px;
  align-items: center;
}

.custom-player-play .pause-icon span {
  display: block;
  width: 3px;
  height: 12px;
  background: #fff;
  border-radius: 1px;
}

.custom-player-time {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.custom-player-time .time-elapsed {
  color: var(--muted);
}

.custom-player-time .time-sep {
  color: var(--muted);
}

.custom-player-time .time-total {
  color: var(--ink);
}

.custom-player-progress {
  flex: 1;
  position: relative;
  height: 20px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.custom-player-track {
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--rule);
  border-radius: 2px;
  overflow: hidden;
  pointer-events: none;
}

.custom-player-fill {
  height: 100%;
  background: var(--pink);
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s linear;
  pointer-events: none;
}

.custom-player-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--pink);
  top: 50%;
  transform: translate(-50%, -50%);
  left: 0%;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--pink);
  pointer-events: none;
  transition: left 0.1s linear;
}

/* Keyboard hints row below video */
.video-hints {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0 0;
  gap: 1rem;
}

.video-hints-keys {
  font-size: 0.8rem;
  color: var(--muted);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

/* Speed pills */
.speed-pills {
  display: flex;
  gap: 0.375rem;
}

.speed-pill {
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  border: 1px solid var(--rule);
  background: transparent;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--muted);
  transition: all 0.15s;
}

.speed-pill.active {
  background: var(--pink);
  border-color: var(--pink);
  color: #fff;
}

.speed-pill:hover:not(.active) {
  border-color: var(--pink);
  color: var(--pink);
}

/* Exposure controls panel */
.exposure-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--muted);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0.5rem 0 0;
  font-family: var(--font-body);
  transition: color 0.15s;
}

.exposure-toggle:hover {
  color: var(--pink);
}

.exposure-panel {
  background: var(--tan);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-top: 0.75rem;
  display: none;
}

.exposure-panel.open {
  display: block;
}

.exposure-row {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 0.75rem;
}

.exposure-row:last-of-type {
  margin-bottom: 1rem;
}

.exposure-label {
  font-size: 0.8125rem;
  color: var(--text);
  font-weight: 500;
  min-width: 80px;
}

.exposure-row input[type="range"] {
  flex: 1;
  accent-color: var(--pink);
}

.exposure-val {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  min-width: 36px;
  text-align: right;
}

.exposure-group-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--pink);
  margin-bottom: 0.5rem;
  margin-top: 0.25rem;
}

.exposure-group + .exposure-group {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--rule);
}

.exposure-reset {
  font-size: 0.8125rem;
  color: var(--muted);
  background: none;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.875rem;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all 0.15s;
}

.exposure-reset:hover {
  border-color: var(--pink);
  color: var(--pink);
}

/* =========================================================
   TRANSCRIPT PANEL
   ========================================================= */
.transcript-section {
  margin-bottom: var(--section-gap);
}

.transcript-pill {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.25rem;
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  font-family: var(--font-body);
  transition: border-color 0.15s;
}

.transcript-pill:hover {
  border-color: var(--pink);
}

.transcript-pill-arrow {
  font-size: 0.875rem;
  color: var(--muted);
  transition: transform 0.2s;
  display: inline-block;
}

.transcript-pill.open .transcript-pill-arrow {
  transform: rotate(90deg);
}

.transcript-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.5s ease, margin-top 0.2s;
}

.transcript-body.open {
  max-height: 4000px;
  margin-top: 0.75rem;
}

.transcript-body-inner {
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.transcript-body-inner p {
  font-size: 0.9375rem;
  line-height: 1.8;
  color: var(--text);
  margin-bottom: 1.125rem;
}

/* =========================================================
   STUDY CARDS SECTION
   ========================================================= */
.study-cards-section {
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: var(--section-gap);
}

.study-cards-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.study-cards-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

.study-cards-counter {
  font-size: 0.8125rem;
  color: var(--muted);
}

.study-card {
  background: var(--tan);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin-bottom: 1rem;
}

.study-card-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--pink);
}

.study-card-question {
  font-size: 0.9375rem;
  color: var(--ink);
  font-weight: 500;
  line-height: 1.55;
}

.study-card-nav {
  display: flex;
  justify-content: center;
  gap: 0.625rem;
}

.card-nav-btn {
  padding: 0.4375rem 1.125rem;
  border-radius: 1.5rem;
  border: 1px solid var(--pink);
  background: transparent;
  color: var(--pink);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.card-nav-btn:hover:not(:disabled) {
  background: var(--pink);
  color: #fff;
}

.card-nav-btn:disabled {
  border-color: var(--rule);
  color: var(--muted);
  cursor: default;
}

.study-card-download-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.875rem;
}

.study-card-download-btn {
  font-size: 0.8125rem;
  color: var(--pink);
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.study-card-download-btn:hover {
  color: var(--pink-deep);
  text-decoration: underline;
}

/* =========================================================
   END-OF-MODULE CTA
   ========================================================= */
.cta-section {
  background: var(--tan-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: var(--card-pad);
  margin-bottom: var(--section-gap);
}

.cta-section p {
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 1.25rem;
}

.cta-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
  display: inline-block;
  background: var(--pink);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 0.25rem;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
}

.btn:hover {
  background: var(--pink-deep);
  color: #fff;
  text-decoration: none;
}

.btn:active { opacity: 0.9; }

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--rule);
}

.btn-outline:hover {
  border-color: var(--ink);
  background: transparent;
  color: var(--ink);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--rule);
  font-size: 0.875rem;
}

.btn-ghost:hover {
  border-color: var(--pink);
  color: var(--pink);
  background: transparent;
}

.btn-disabled {
  background: var(--rule);
  color: var(--muted);
  cursor: default;
  pointer-events: none;
  border: none;
}

.btn-reviewed {
  background: var(--check);
  color: #fff;
}

/* =========================================================
   SITE FOOTER
   ========================================================= */
.site-footer {
  border-top: 1px solid var(--rule);
  padding: 1.5rem 2rem;
  text-align: center;
  background: var(--white);
}

.site-footer p {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

/* =========================================================
   STAGGER-IN SCROLL ANIMATION
   ========================================================= */
.stagger-item {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.stagger-item.visible {
  opacity: 1;
  transform: translateY(0);
}

/* =========================================================
   MOBILE RESPONSIVE
   ========================================================= */
@media (max-width: 900px) {
  .course-layout {
    flex-direction: column;
  }

  .course-sidebar {
    width: 100%;
    height: auto;
    position: relative;
    top: 0;
    border-right: none;
    border-bottom: 1px solid var(--rule);
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.5rem;
    gap: 0;
  }

  .sidebar-header {
    display: none;
  }

  .sidebar-modules {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: visible;
    padding: 0;
  }

  .sidebar-module-item {
    flex-direction: column;
    min-width: 120px;
    border-left: none;
    border-bottom: 3px solid transparent;
    padding: 0.75rem;
  }

  .sidebar-module-item.active {
    border-bottom-color: var(--pink);
    border-left-color: transparent;
  }

  .course-main {
    padding: 1.25rem 1rem;
  }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }

  .title-card-text {
    font-size: 1.75rem;
    padding: 0 1rem;
  }

  .page-hero h1 {
    font-size: 1.375rem;
  }

  .site-header-nav {
    display: none;
  }
}
