/* Course player: curriculum on the left, lesson on the right. */
body.learn {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

/* ------------------------------------------------------------ top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.625rem 1.25rem;
  background: var(--blue);
  color: #fff;
}

.topbar .brand {
  color: #fff;
  font-family: var(--font-head);
  font-size: 1.25rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.course-title {
  flex: 1;
  min-width: 0;
  padding-left: 1rem;
  border-left: 1px solid rgb(255 255 255 / 0.35);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  white-space: nowrap;
}

.progress-track {
  width: 11rem;
  height: 14px;
  background: var(--blue-deep);
  border-radius: 2px;
  overflow: hidden;
}

/* Hazard-tape fill: the one loud element on the page. */
.progress-fill {
  height: 100%;
  width: 0;
  background: repeating-linear-gradient(-45deg, var(--hivis) 0 10px, var(--ink) 10px 15px);
  transition: width 0.4s ease;
}

.bar-btn {
  min-height: 40px;
  padding: 0.25rem 0.875rem;
  border: 1px solid rgb(255 255 255 / 0.6);
  border-radius: var(--radius);
  background: transparent;
  color: #fff;
  font-family: var(--font-head);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.bar-btn:hover {
  background: var(--blue-deep);
}

#menuBtn {
  display: none;
}

/* ------------------------------------------------------------ layout */
.layout {
  display: grid;
  grid-template-columns: 22rem 1fr;
  min-height: 0;
}

.sidebar {
  overflow-y: auto;
  background: var(--concrete);
  border-right: 1px solid var(--line);
}

.content {
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* ------------------------------------------------------------ curriculum */
.section + .section {
  border-top: 1px solid var(--line);
}

.section summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.125rem 0.75rem;
  padding: 0.875rem 1.25rem;
  cursor: pointer;
  list-style: none;
}

.section summary::-webkit-details-marker {
  display: none;
}

.section summary::after {
  content: "";
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}

.section[open] summary::after {
  transform: rotate(-135deg);
}

.section-title {
  font-family: var(--font-head);
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.25;
}

.section-count {
  grid-column: 1;
  color: var(--muted);
  font-size: 0.9375rem;
}

.lessons {
  margin: 0;
  padding: 0 0 0.5rem;
  list-style: none;
}

.lesson-link {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 0.75rem;
  align-items: start;
  width: 100%;
  padding: 0.625rem 1.25rem 0.625rem 1rem;
  border: 0;
  border-left: 4px solid transparent;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.lesson-link:hover:not(:disabled) {
  background: #e2e7eb;
}

.lesson-link[aria-current="true"] {
  background: var(--paper);
  border-left-color: var(--hivis);
}

.lesson-link:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.lesson-name {
  display: block;
  line-height: 1.3;
}

.lesson-link[aria-current="true"] .lesson-name {
  font-weight: 600;
}

.lesson-meta {
  display: block;
  color: var(--muted);
  font-size: 0.875rem;
}

/* Status mark: square outline = to do, green tick = done, padlock = locked */
.mark {
  width: 22px;
  height: 22px;
  margin-top: 1px;
  display: grid;
  place-items: center;
  border: 2px solid var(--muted);
  border-radius: 3px;
  background: var(--paper);
}

.mark.is-done {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.mark.is-locked {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.mark svg {
  display: block;
}

/* ------------------------------------------------------------ lesson */
.stage {
  background: var(--ink);
}

.stage video {
  display: block;
  width: 100%;
  max-height: calc(100vh - 13rem);
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  background: #000;
}

.stage-youtube iframe {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100vh - 13rem);
  aspect-ratio: 16 / 9;
  margin: 0 auto;
  border: 0;
}

.stage-fallback {
  display: grid;
  gap: 1rem;
  justify-items: start;
  padding: 3rem 2rem;
  color: #fff;
}

.lesson {
  width: min(100% - 3rem, 46rem);
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.lesson-kind {
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.lesson h1 {
  font-size: 2.25rem;
  margin-bottom: 1.5rem;
}

.hint {
  margin-bottom: 1.5rem;
  padding: 0.75rem 1rem;
  border-left: 6px solid var(--hivis);
  background: var(--concrete);
}

/* reading blocks */
.body > * + * {
  margin-top: 1.125rem;
}

.body h2 {
  font-size: 1.5rem;
  margin-top: 2.25rem;
}

.body ul,
.body ol {
  margin: 0;
  padding-left: 1.5rem;
}

.body li + li {
  margin-top: 0.375rem;
}

.body figure {
  margin-left: 0;
  margin-right: 0;
}

.body figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  background: var(--concrete);
}

.body figcaption {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.9375rem;
}

.callout {
  padding: 1rem 1.25rem;
  border: 2px solid var(--ink);
  border-left-width: 10px;
  border-left-color: var(--hivis);
  font-weight: 500;
}

/* tabs */
.tabs {
  display: flex;
  gap: 1.5rem;
  margin-top: 2.5rem;
  border-bottom: 1px solid var(--line);
}

.tab {
  padding: 0.625rem 0;
  border: 0;
  border-bottom: 4px solid transparent;
  background: none;
  font-family: var(--font-head);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.tab[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--blue);
}

.tab-panel {
  padding-top: 1.25rem;
}

.resources {
  margin: 0;
  padding: 0;
  list-style: none;
}

.resources li + li {
  margin-top: 0.5rem;
}

/* quiz */
.question {
  margin: 0 0 1.75rem;
  padding: 0;
  border: 0;
}

.question legend {
  padding: 0;
  margin-bottom: 0.75rem;
  font-family: var(--font-head);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
}

.option {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.75rem 1rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.option + .option {
  margin-top: 0.5rem;
}

.option:has(input:checked) {
  border-color: var(--blue);
  background: #eaf1f9;
}

.option input {
  width: 20px;
  height: 20px;
  margin: 3px 0 0;
  accent-color: var(--blue);
  flex: none;
}

.question.is-wrong legend::after {
  content: " (not correct yet)";
  color: var(--red);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
}

.result {
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  border-left: 10px solid var(--red);
  background: var(--concrete);
}

.result.is-pass {
  border-left-color: var(--green);
}

.result strong {
  display: block;
  font-family: var(--font-head);
  font-size: 1.375rem;
}

/* written answers */
.written {
  display: block;
  width: 100%;
  min-height: 7rem;
  padding: 0.75rem 1rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  color: inherit;
  resize: vertical;
}

.written:focus {
  border-color: var(--blue);
  outline: 3px solid var(--hivis);
  outline-offset: 1px;
}

.question.is-returned legend::after {
  content: " (sent back by your trainer)";
  color: var(--red);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
}

.trainer-note {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.75rem;
  border-left: 6px solid var(--red);
  background: var(--concrete);
}

/* breaks */
.break {
  margin-bottom: 1.5rem;
  padding: 2rem 1.5rem;
  background: var(--concrete);
  border-top: 10px solid var(--hivis);
  text-align: center;
}

.break-clock {
  margin: 0;
  font-family: var(--font-head);
  font-size: clamp(4rem, 14vw, 8rem);
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.break-message {
  min-height: 1.55em;
  margin: 1rem 0 0;
  font-weight: 600;
}

.break .actions {
  justify-content: center;
  margin-top: 1rem;
}

/* prev / next */
.lesson-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

/* ------------------------------------------------------------ presenter view */
body.presenting .layout {
  grid-template-columns: 1fr;
}

body.presenting .sidebar {
  display: none;
}

body.presenting .lesson {
  width: min(100% - 4rem, 62rem);
  font-size: 1.5rem;
}

body.presenting .lesson h1 {
  font-size: 3.25rem;
}

body.presenting .body h2 {
  font-size: 2.125rem;
}

/* ------------------------------------------------------------ small screens */
.backdrop {
  display: none;
}

@media (max-width: 900px) {
  #menuBtn {
    display: inline-block;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
  }

  .topbar .brand,
  #presentBtn {
    display: none;
  }

  .course-title {
    padding-left: 0;
    border-left: 0;
  }

  .progress {
    width: 100%;
  }

  .progress-track {
    flex: 1;
    width: auto;
  }

  .layout {
    grid-template-columns: 1fr;
    position: relative;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: min(22rem, 88vw);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0.2s;
  }

  body.nav-open .sidebar {
    transform: none;
    visibility: visible;
  }

  body.nav-open .backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 10;
    border: 0;
    background: rgb(22 32 42 / 0.55);
  }

  .lesson {
    width: min(100% - 2rem, 46rem);
    padding-top: 1.5rem;
  }

  .lesson h1 {
    font-size: 1.75rem;
  }
}

@media (max-width: 480px) {
  .lesson-nav .btn {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------ Korean */
html[lang="ko"] .question.is-wrong legend::after {
  content: " (아직 정답이 아님)";
}

html[lang="ko"] .question.is-returned legend::after {
  content: " (트레이너가 돌려보냄)";
}

html[lang="ko"] body {
  word-break: keep-all;
}

/* the official assessment placeholder */
.result.toolkit {
  border-left-color: var(--blue);
}
