/* The lesson viewer. Class prefix ls-. Uses only variables from tokens.css. */

.ls-root, .ls-root * { box-sizing: border-box; }
.ls-root [hidden] { display: none !important; }

.ls-root {
  position: absolute; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: clamp(8px, 2vh, 26px) clamp(10px, 2.4vw, 36px);
  overflow: hidden;
  font-family: var(--font); font-size: var(--size-body); color: var(--ink);
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
.ls-backdrop {
  position: absolute; inset: 0;
  background: rgba(42, 27, 94, 0.45);
  background: color-mix(in srgb, var(--night) 45%, transparent);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: ls-fade 0.3s ease-out both;
}
.ls-card {
  position: relative; width: min(1180px, 100%); height: min(100%, 800px);
  display: flex; flex-direction: column; gap: clamp(8px, 1.4vh, 16px);
  padding: clamp(10px, 1.8vh, 22px) clamp(14px, 2vw, 30px);
  background: var(--cream); border: var(--outline); border-radius: var(--radius-l);
  box-shadow: var(--shadow-sticker), var(--shadow-soft);
  animation: ls-rise 0.5s var(--pop) both;
  overflow: hidden;
}

/* header: leave room for the shell's pause button, as the puzzle does */
.ls-head { flex: 0 0 auto; display: flex; align-items: center; gap: 14px; padding-left: 56px; min-height: 48px; }
.ls-badge {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 4px 18px 4px 10px;
  background: var(--turquoise); border: 3px solid var(--ink); border-radius: 999px;
  font-weight: 800; font-size: var(--size-body); line-height: 1.2;
}
.ls-badge-icon { font-size: 26px; line-height: 1; }
.ls-title {
  margin: 0; min-width: 0; font-weight: 900; line-height: 1.15;
  font-size: clamp(24px, 3.6vh, 34px); overflow-wrap: anywhere;
}

/* the card itself */
.ls-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  display: flex; flex-direction: column; outline: none;
  padding: clamp(10px, 2vh, 22px) clamp(12px, 2vw, 28px);
  background: var(--paper); border: 3px solid var(--lilac); border-radius: var(--radius-m);
}
.ls-page { margin: auto 0; display: flex; flex-direction: column; align-items: center; gap: clamp(10px, 2vh, 20px); text-align: center; }
.ls-card-title { margin: 0; font-weight: 900; font-size: clamp(30px, 5vh, 46px); line-height: 1.15; color: var(--orchid-deep); }
.ls-text { margin: 0; max-width: 34em; font-weight: 700; font-size: clamp(22px, 3.3vh, 30px); line-height: 1.4; }
.ls-html {
  width: 100%; max-width: 100%; overflow-x: auto; display: flex; flex-direction: column; align-items: center;
  font-size: clamp(26px, 4.2vh, 40px); line-height: 1.35;
}
.ls-html > * { max-width: 100%; }
.ls-in-next { animation: ls-pop-next 0.4s var(--pop) both; }
.ls-in-back { animation: ls-pop-back 0.4s var(--pop) both; }

/* footer */
.ls-foot { flex: 0 0 auto; display: grid; grid-template-columns: minmax(150px, 1fr) auto minmax(150px, 1fr); align-items: center; gap: 14px; }
.ls-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: clamp(64px, 9.5vh, 84px); padding: 8px 26px;
  background: var(--paper); color: var(--ink); border: var(--outline); border-radius: var(--radius-m);
  box-shadow: var(--shadow-sticker);
  font: inherit; font-weight: 900; font-size: clamp(24px, 3.6vh, 32px); line-height: 1.1; cursor: pointer;
  touch-action: manipulation; -webkit-user-select: none; user-select: none;
  transition: transform 0.12s var(--pop), box-shadow 0.12s;
}
.ls-btn:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.ls-btn:focus-visible { outline: 4px solid var(--turquoise); outline-offset: 2px; }
.ls-btn:disabled { opacity: 0.55; cursor: default; }
.ls-btn-back { background: var(--lilac); justify-self: start; min-width: 150px; }
.ls-btn-next { background: var(--turquoise); justify-self: end; min-width: 170px; }
.ls-btn-go { background: var(--gold); font-size: clamp(28px, 4.4vh, 38px); min-width: 240px; animation: ls-pulse 1.4s ease-in-out infinite; }

.ls-dots { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
.ls-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--lilac); border: 3px solid var(--ink); transition: transform 0.2s var(--pop), background 0.2s; }
.ls-dot-done { background: var(--orchid); }
.ls-dot-on { background: var(--gold); transform: scale(1.5); }

@keyframes ls-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ls-rise { from { opacity: 0; transform: translateY(26px) scale(0.93); } to { opacity: 1; transform: none; } }
@keyframes ls-pop-next { 0% { opacity: 0; transform: translateX(28px) scale(0.96); } 100% { opacity: 1; transform: none; } }
@keyframes ls-pop-back { 0% { opacity: 0; transform: translateX(-28px) scale(0.96); } 100% { opacity: 1; transform: none; } }
@keyframes ls-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

@media (prefers-reduced-motion: reduce) {
  .ls-root *, .ls-root *::before, .ls-root *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important;
  }
  .ls-btn-go { animation: none; outline: 4px solid var(--gold-deep); }
}

@media (max-height: 640px) {
  .ls-badge { min-height: 38px; font-size: 18px; }
  .ls-foot { grid-template-columns: auto 1fr auto; }
}

.ls-body { touch-action: pan-y; }   /* vertical scroll stays, horizontal swipes reach our handler */

/* lead: room for the shell's Done / pause button at the top left */
.ls-head { padding-left: 64px; }
