/* ==========================================================================
   Editorial lesson pilot
   A single-page pattern for separating ākonga mahi from kaiako guidance while
   preserving the lesson as a calm, printable professional document.
   ========================================================================== */

body.editorial-lesson-page {
  --editorial-paper: #faf9f7;
  --editorial-ink: #24302b;
  --editorial-rule: color-mix(in srgb, var(--page-accent, #6b4c9a) 28%, #d8d3cc);
  --lesson-scroll-progress: 0;
}

/* Activate progress bar on all lesson pages */
body.tc-lesson-body {
  --lesson-scroll-progress: 0;
}

/* ── Lesson bottom nav strip ─────────────────────────────────────────────── */
.tka-lesson-nav-strip {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 800;
  background: var(--tc-accent, #123b2f);
  color: white;
  height: 44px;
  display: flex;
  align-items: stretch;
  box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.22);
}

.tka-lns-inner {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 0.5rem;
}

.tka-lns-btn {
  display: flex;
  align-items: center;
  padding: 0 1rem;
  height: 44px;
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.tka-lns-btn:not(.tka-lns-disabled):hover {
  background: rgba(255, 255, 255, 0.14);
  color: white;
}

.tka-lns-disabled {
  opacity: 0.3;
  cursor: default;
}

.tka-lns-pos {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
}

.tka-lns-track {
  display: flex;
  gap: 4px;
  align-items: center;
}

.tka-lnd {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  transition: transform 0.15s;
}

.tka-lnd-done {
  background: rgba(255, 255, 255, 0.5);
}

.tka-lnd-cur {
  background: rgba(255, 255, 255, 0.95);
  width: 8px;
  height: 8px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.tka-lnd-future {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.tka-lns-label {
  font-size: 0.8rem;
  font-weight: 500;
  opacity: 0.78;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.tka-lns-print {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.72);
  font-size: 1rem;
  padding: 0 0.65rem;
  height: 44px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  transition: color 0.15s;
  border-radius: 0;
}

.tka-lns-print:hover { color: #fff; }

@media (max-width: 480px) {
  .tka-lns-btn { padding: 0 0.6rem; font-size: 0.75rem; }
  .tka-lns-track { display: none; }
  .tka-lns-label { font-size: 0.72rem; }
  .tka-lns-print { padding: 0 0.4rem; }
}

@media print {
  .tka-lesson-nav-strip { display: none; }
}

/* ── Print header — visible only when ?class= or ?date= URL params present ── */
.tka-print-header {
  display: none;
}

@media print {
  .tka-print-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0 0 3mm;
    margin-bottom: 5mm;
    border-bottom: 0.4pt solid #c8c8c8;
    font-family: 'Outfit', 'Inter', sans-serif;
    font-size: 8.5pt;
    color: #555;
    letter-spacing: 0.01em;
  }
  .tka-print-header span:first-child {
    font-weight: 700;
    color: #234b43;
  }
}

/* Lesson title h1 carries the subject accent color */
.lesson-header .lesson-title {
  color: var(--tc-accent);
}

.lesson-reading-progress {
  background: color-mix(in srgb, var(--page-accent, #6b4c9a) 12%, transparent);
  height: 4px;
  inset: 0 0 auto;
  pointer-events: none;
  position: fixed;
  z-index: 1200;
}

.lesson-reading-progress__bar {
  background: var(--page-accent, var(--tc-accent, #6b4c9a));
  box-shadow: 0 0 10px color-mix(in srgb, var(--page-accent, #6b4c9a) 45%, transparent);
  display: block;
  height: 100%;
  transform: scaleX(var(--lesson-scroll-progress));
  transform-origin: left center;
}

.editorial-layout {
  align-items: start;
  display: grid;
  gap: clamp(1.5rem, 4vw, 3rem);
  grid-template-columns: minmax(0, 72ch) minmax(210px, 260px);
  justify-content: center;
}

.editorial-primary {
  min-width: 0;
}

.editorial-primary > .lesson-section,
.editorial-primary > .lesson-intro-grid,
.editorial-primary > .teacher-planning-stack {
  width: 100%;
}

.editorial-rail {
  border-block: 1px solid var(--editorial-rule);
  color: var(--editorial-ink);
  padding: 1.1rem 0;
  position: sticky;
  top: 5.25rem;
}

.editorial-rail__kicker,
.teacher-planning-kicker {
  color: var(--page-accent, var(--tc-accent, #6b4c9a));
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  margin: 0 0 0.35rem;
  text-transform: uppercase;
}

.editorial-rail h2 {
  color: var(--editorial-ink);
  font-family: var(--font-display, Georgia, serif);
  font-size: 1.2rem;
  margin: 0 0 0.85rem;
}

.editorial-rail__nav {
  display: grid;
  gap: 0.15rem;
}

.editorial-rail__nav a {
  border-left: 2px solid transparent;
  color: var(--color-text-secondary, #53635c);
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.25;
  padding: 0.48rem 0.6rem;
  text-decoration: none;
}

.editorial-rail__nav a:hover,
.editorial-rail__nav a:focus-visible {
  background: var(--editorial-paper);
  border-left-color: var(--page-accent, var(--tc-accent, #6b4c9a));
  color: var(--page-accent, var(--tc-accent, #6b4c9a));
}

.audience-key {
  border-top: 1px solid var(--editorial-rule);
  display: grid;
  gap: 0.45rem;
  margin-top: 1rem;
  padding-top: 0.9rem;
}

.audience-key span {
  align-items: center;
  color: var(--color-text-secondary, #53635c);
  display: flex;
  font-size: 0.75rem;
  gap: 0.5rem;
}

.audience-key span::before {
  background: #fff;
  border: 2px solid var(--page-accent, var(--tc-accent, #6b4c9a));
  content: "";
  height: 0.65rem;
  width: 0.65rem;
}

.audience-key .audience-key__teacher::before {
  background: var(--editorial-paper);
  border-color: var(--editorial-rule);
}

.editorial-print-button {
  align-items: center;
  background: var(--page-accent, var(--tc-accent, #6b4c9a));
  border: 0;
  bottom: 1.25rem;
  box-shadow: 0 10px 28px rgba(30, 20, 45, 0.2);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 800;
  gap: 0.45rem;
  padding: 0.78rem 1rem;
  position: fixed;
  right: 1.25rem;
  z-index: 80;
}

.editorial-print-button:hover,
.editorial-print-button:focus-visible {
  background: color-mix(in srgb, var(--page-accent, #6b4c9a) 84%, #000);
  box-shadow: 0 12px 32px rgba(30, 20, 45, 0.28);
  transform: translateY(-2px);
}

.editorial-print-button:focus-visible,
.section-anchor:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

/* Student-facing work: brighter paper, full reading measure, generous rhythm. */
.student-activity {
  background: #fff;
  border: 1px solid color-mix(in srgb, var(--page-accent, #6b4c9a) 18%, #dfe4e1);
  border-left: 3px solid var(--page-accent, var(--tc-accent, #6b4c9a));
  line-height: 1.72;
  padding: 1.05rem 1.15rem;
}

.student-activity > :where(p, ol, ul) {
  max-width: 72ch;
}

.audience-label {
  color: var(--page-accent, var(--tc-accent, #6b4c9a));
  font-size: 0.68rem !important;
  font-weight: 850;
  letter-spacing: 0.11em;
  margin: 0 0 0.45rem !important;
  text-transform: uppercase;
}

/* Teacher-only cues: warm stock, a quieter scale, and one consistent rule. */
.teacher-note,
.curriculum-alignment {
  background: var(--editorial-paper) !important;
  border: 0 !important;
  border-left: 3px solid var(--page-accent, var(--tc-accent, #6b4c9a)) !important;
  color: #4e5853;
  font-size: 0.86rem;
  line-height: 1.55;
}

p.teacher-note,
div.teacher-note {
  margin-block: 0.8rem;
  padding: 0.75rem 0.9rem;
}

.teacher-note :where(p, li, blockquote),
.curriculum-alignment :where(p, li, blockquote) {
  font-size: inherit;
  line-height: inherit;
}

.teacher-planning-stack {
  border-top: 1px solid var(--editorial-rule);
  margin-top: clamp(3rem, 6vw, 5rem);
  padding-top: 1.2rem;
}

.teacher-planning-stack > h2 {
  color: var(--editorial-ink);
  font-family: var(--font-display, Georgia, serif);
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin: 0 0 0.35rem;
}

.teacher-planning-intro {
  color: var(--color-text-secondary, #53635c);
  margin: 0 0 1.15rem;
  max-width: 62ch;
}

.teacher-planning-stack details.teacher-note {
  margin-bottom: 0.75rem;
}

.teacher-planning-stack details.teacher-note summary {
  color: var(--editorial-ink);
  font-size: 0.9rem;
  letter-spacing: 0.01em;
}

.activity-head h2 {
  align-items: baseline;
  display: flex;
  gap: 0.45rem;
}

.section-anchor {
  color: var(--page-accent, var(--tc-accent, #6b4c9a));
  font-family: var(--font-body, sans-serif);
  font-size: 0.8em;
  opacity: 0;
  text-decoration: none;
  transition: opacity 140ms ease;
}

.student-facing-section:hover .section-anchor,
.section-anchor:hover,
.section-anchor:focus-visible {
  opacity: 0.42;
}

.editorial-lesson-page .tc-activity,
.editorial-lesson-page .intro-card,
.editorial-lesson-page .glance-step,
.editorial-lesson-page .activity-run,
.editorial-lesson-page .frame-box,
.editorial-lesson-page .kupu-card,
.editorial-lesson-page .source-type-card,
.editorial-lesson-page .lesson-resource-card,
.editorial-lesson-page .lesson-sources,
.editorial-lesson-page details.planning-details {
  border-radius: 0;
}

@media (max-width: 980px) {
  .editorial-layout {
    display: block;
  }

  .editorial-rail {
    margin-bottom: 1.5rem;
    position: static;
  }

  .editorial-rail__nav {
    display: flex;
    gap: 0.3rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
  }

  .editorial-rail__nav a {
    border: 1px solid var(--editorial-rule);
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .audience-key {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
  }
}

@media (max-width: 600px) {
  .editorial-print-button {
    bottom: 0.75rem;
    padding: 0.65rem 0.78rem;
    right: 0.75rem;
  }

  .student-activity {
    padding: 0.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lesson-reading-progress__bar,
  .editorial-print-button,
  .section-anchor {
    transition: none;
  }
}

@media print {
  body.editorial-lesson-page {
    --editorial-paper: #fff;
    font-size: 9.5pt;
  }

  .lesson-reading-progress,
  .editorial-rail,
  .editorial-print-button,
  .section-anchor,
  .content-hierarchy-breadcrumb,
  #resource-usage-widget,
  #resource-rating-widget,
  #resource-discussion-widget {
    display: none !important;
  }

  body.editorial-lesson-page header.unit-hero {
    background: #fff !important;
    color: #1d3028 !important;
    display: block !important;
    min-height: 0 !important;
    padding: 0 0 0.35in !important;
  }

  body.editorial-lesson-page header.unit-hero::before,
  body.editorial-lesson-page header.unit-hero::after,
  body.editorial-lesson-page .unit-hero__breadcrumb,
  body.editorial-lesson-page .unit-hero__sequence {
    display: none !important;
  }

  body.editorial-lesson-page .unit-hero__inner,
  body.editorial-lesson-page .unit-hero__header {
    display: block !important;
    max-width: none !important;
    padding: 0 !important;
  }

  body.editorial-lesson-page .unit-hero__title {
    border-bottom: 2px solid #1d3028;
    color: #1d3028 !important;
    font-size: 22pt !important;
    margin: 0 0 0.12in !important;
    padding-bottom: 0.1in;
  }

  body.editorial-lesson-page .unit-hero__summary {
    color: #394b43 !important;
    font-size: 10pt !important;
    line-height: 1.4 !important;
    margin: 0 !important;
    max-width: 70ch;
  }

  .editorial-layout {
    display: block;
  }

  .editorial-primary {
    max-width: none;
    width: 100%;
  }

  .student-activity,
  .teacher-note,
  .curriculum-alignment {
    box-shadow: none !important;
    print-color-adjust: exact;
  }

  body.editorial-lesson-page .lesson-runsheet {
    display: grid !important;
    gap: 0.08in;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  body.editorial-lesson-page .glance-step {
    break-inside: avoid;
    font-size: 8pt;
    padding: 0.08in;
  }

  body.editorial-lesson-page .editorial-primary > .lesson-section,
  body.editorial-lesson-page .editorial-primary .tc-activity {
    break-inside: auto !important;
    page-break-inside: auto !important;
  }

  body.editorial-lesson-page .student-activity,
  body.editorial-lesson-page .teacher-note,
  body.editorial-lesson-page .frame-box,
  body.editorial-lesson-page .kupu-card,
  body.editorial-lesson-page .source-type-card,
  body.editorial-lesson-page .lesson-resource-card {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  body.editorial-lesson-page .tc-activity {
    margin: 0.18in 0 !important;
    padding: 0.14in !important;
  }

  body.editorial-lesson-page .tc-activity h2 {
    font-size: 14pt !important;
  }

  body.editorial-lesson-page .editorial-primary :where(p, li) {
    font-size: 9.2pt;
    line-height: 1.35;
  }

  body.editorial-lesson-page .student-activity {
    padding: 0.11in !important;
  }

  .student-activity {
    border-color: #c9c9c9;
  }

  .teacher-note,
  .curriculum-alignment {
    border-left-color: #555 !important;
  }

  .teacher-planning-stack {
    margin-top: 0.3in;
  }

  .teacher-planning-stack details.teacher-note > * {
    display: block !important;
  }
}

/* ── Running lesson header — slides in from behind fixed header on scroll ─── */
.tka-lesson-running-header {
    position: fixed;
    left: 0; right: 0;
    top: var(--header-height, 75px);
    z-index: 499;
    background: var(--tc-accent, var(--color-primary, #0f766e));
    color: rgba(255, 255, 255, 0.92);
    height: 34px;
    display: flex;
    align-items: center;
    transform: translateY(-100%);
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.tka-lesson-running-header.tka-lrh-visible {
    transform: translateY(0);
}

.tka-lrh-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    overflow: hidden;
}

.tka-lrh-unit {
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
    flex-shrink: 1;
    min-width: 0;
}

.tka-lrh-unit:hover { color: #fff; text-decoration: underline; }

.tka-lrh-band, .tka-lrh-pos {
    opacity: 0.78;
    white-space: nowrap;
    flex-shrink: 0;
}

.tka-lrh-sep {
    opacity: 0.4;
    flex-shrink: 0;
}

@media (max-width: 600px) {
    .tka-lrh-unit { max-width: 180px; }
    .tka-lrh-band { display: none; }
    .tka-lesson-running-header { top: var(--header-height, 72px); }
}

@media print {
    .tka-lesson-running-header { display: none !important; }
}
