/* ==========================================================================
   Module player (slides + narration + quiz). Used by sample pages and the
   home-page demo.
   ========================================================================== */

.player { display: grid; gap: 1.1rem; }

/* ---- Top bar: title + progress ---- */
.player-top { display: grid; gap: 0.8rem; }
.player-title { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.4rem 1rem; }
.player-title h2 { font-size: clamp(1.25rem, 2.2vw, 1.6rem); margin: 0; }
.player-count { color: var(--muted); font-weight: 600; font-size: 0.95rem; }

.progress { display: flex; gap: 0.35rem; list-style: none; margin: 0; padding: 0; }
.progress li { flex: 1 1 0; min-width: 0; }
.progress button {
  display: block;
  width: 100%;
  height: 2.75rem; /* big tap/click target */
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  position: relative;
}
.progress button::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 0.5rem;
  margin-top: -0.25rem;
  border-radius: 999px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
  transition: background 0.25s;
}
.progress button[aria-current="step"]::before { background: var(--btn-grad); box-shadow: none; height: 0.7rem; margin-top: -0.35rem; }
.progress button.done::before { background: var(--accent); opacity: 0.75; box-shadow: none; }
.progress button:hover::before { background: var(--accent-2); }
.progress .quiz-step button[aria-current="step"]::before { background: linear-gradient(90deg, var(--accent-3), var(--warn)); }

/* ---- Stage ---- */
.stage {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 0.2rem);
  box-shadow: var(--shadow);
  padding: clamp(1.25rem, 3.4vw, 2.5rem);
  min-height: 24rem;
}
:root[data-theme="dark"] .stage { background: linear-gradient(180deg, #131d38 0%, #0e1630 100%); }
.stage:focus { outline: none; }
.slide-kicker { color: var(--accent-2); font-weight: 700; font-size: 0.85rem; letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 0.6rem; }
.slide-title { font-size: clamp(1.7rem, 3.6vw, 2.5rem); margin-bottom: 0.4em; outline: none; }
.slide-lead { font-size: clamp(1.05rem, 1.5vw, 1.2rem); color: var(--muted); max-width: 44rem; }

.objectives { list-style: none; padding: 0; margin: 1.4rem 0 0; display: grid; gap: 0.8rem; }
.objectives li {
  display: grid; grid-template-columns: auto 1fr; gap: 0.9rem; align-items: start;
  padding: 0.9rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.objectives svg { width: 1.5rem; height: 1.5rem; color: var(--accent-2); margin-top: 0.15rem; }

.cards-grid { display: grid; gap: 0.9rem; margin-top: 1.3rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
.mini-card {
  padding: 1.1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.mini-card h4 { font-size: 1.1rem; margin-bottom: 0.3em; }
.mini-card p { margin: 0; color: var(--muted); font-size: 0.98rem; line-height: 1.5; }
.mini-card .tag { display: inline-block; margin-bottom: 0.5rem; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-2); }

.slide-steps { counter-reset: s; list-style: none; padding: 0; margin: 1.3rem 0 0; display: grid; gap: 0.75rem; }
.slide-steps li {
  counter-increment: s;
  display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: start;
  padding: 0.9rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.slide-steps li::before {
  content: counter(s);
  width: 2.3rem; height: 2.3rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--info-bg); color: var(--text);
  font-weight: 800;
  box-shadow: inset 0 0 0 1px var(--accent);
}
.slide-steps strong { display: block; font-size: 1.06rem; }
.slide-steps span { color: var(--muted); }
.slide-steps code, .mini-card code, .slide-note code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); padding: 0.1em 0.4em; border-radius: 0.35em; color: var(--text); }

.slide-note { margin-top: 1.2rem; }

/* Tables (ONT lights) */
.table-wrap { margin-top: 1.3rem; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.slide-table { width: 100%; border-collapse: collapse; min-width: 34rem; }
.slide-table th, .slide-table td { text-align: left; padding: 0.85rem 1.1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.slide-table thead th { background: var(--surface-2); font-size: 0.85rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.slide-table tbody tr:last-child td { border-bottom: 0; }
.slide-table tbody th { font-weight: 700; }
.light { display: inline-flex; align-items: center; gap: 0.6rem; font-weight: 700; white-space: nowrap; }
.light::before {
  content: "";
  width: 1rem; height: 1rem; border-radius: 50%;
  background: var(--c, #888);
  box-shadow: 0 0 0.7rem var(--c, #888);
  border: 2px solid rgba(255, 255, 255, 0.55);
}
.light.green { --c: #2ee58a; }
.light.red { --c: #ff5a5a; }
.light.amber { --c: #ffc94d; }
.light.off { --c: transparent; }
.light.off::before { box-shadow: none; border-color: var(--border-strong); }
.light.blink::before { animation: blink 1s steps(2, jump-none) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
:root[data-theme="light"] .light::before { border-color: rgba(0, 0, 0, 0.35); box-shadow: none; }

/* Decision tree walker */
.tree { margin-top: 1.3rem; display: grid; gap: 0.8rem; }
.tree-trail { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.tree-trail li {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; justify-content: space-between;
  padding: 0.65rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--muted);
}
.tree-trail .ans { font-weight: 800; color: var(--text); padding: 0.1rem 0.7rem; border-radius: 999px; background: var(--info-bg); box-shadow: inset 0 0 0 1px var(--accent); }
.tree-now {
  padding: clamp(1.1rem, 2.4vw, 1.6rem);
  border-radius: var(--radius);
  background: var(--info-bg);
  border: 2px solid var(--accent);
}
.tree-now .tree-q { font-size: clamp(1.2rem, 2vw, 1.5rem); font-family: var(--font-display); font-weight: 750; margin: 0 0 0.35rem; }
.tree-now .tree-hint { color: var(--muted); margin: 0 0 1rem; }
.tree-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.tree-out { padding: clamp(1.1rem, 2.4vw, 1.6rem); border-radius: var(--radius); border: 2px solid; }
.tree-out.good { background: var(--good-bg); border-color: var(--good); }
.tree-out.warn { background: var(--warn-bg); border-color: var(--warn); }
.tree-out.stop { background: var(--bad-bg); border-color: var(--bad); }
.tree-out .tag { font-size: 0.8rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; display: block; margin-bottom: 0.3rem; }
.tree-out.good .tag { color: var(--good); }
.tree-out.warn .tag { color: var(--warn); }
.tree-out.stop .tag { color: var(--bad); }
.tree-out h4 { font-size: 1.35rem; margin-bottom: 0.3em; }
.tree-out p { margin: 0 0 1rem; }
.tree-out p:last-of-type { margin-bottom: 1rem; }

/* ---- Narration panel ---- */
.narration {
  display: grid;
  gap: 1rem;
  padding: clamp(1.1rem, 2.4vw, 1.6rem);
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}
.narration-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem 1.2rem; justify-content: space-between; }
.narration-head h3 { font-size: 1rem; margin: 0; display: flex; align-items: center; gap: 0.7rem; letter-spacing: 0; font-family: var(--font); }
.narration-text { font-size: clamp(1.08rem, 1.5vw, 1.25rem); line-height: 1.75; margin: 0; max-width: 56rem; }
.narration-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.7rem; }
.narration-controls select {
  min-height: 2.9rem;
  font: inherit; font-weight: 600;
  color: var(--text);
  background: var(--bg-2);
  border: 2px solid var(--border-strong);
  border-radius: 999px;
  padding: 0.35rem 2rem 0.35rem 1rem;
}
.narration-controls label { font-weight: 600; font-size: 0.95rem; color: var(--muted); display: inline-flex; align-items: center; gap: 0.5rem; }
.narration .note { color: var(--muted); font-size: 0.9rem; margin: 0; }

.wave { display: inline-flex; align-items: center; gap: 3px; height: 1.6rem; }
.wave i { display: block; width: 4px; height: 25%; border-radius: 3px; background: var(--accent-2); }
.wave i:nth-child(2n) { background: var(--accent); }
.player.speaking .wave i { animation: bar 0.9s ease-in-out infinite; }
.wave i:nth-child(1) { animation-delay: -0.9s; } .wave i:nth-child(2) { animation-delay: -0.7s; }
.wave i:nth-child(3) { animation-delay: -0.5s; } .wave i:nth-child(4) { animation-delay: -0.3s; }
.wave i:nth-child(5) { animation-delay: -0.6s; } .wave i:nth-child(6) { animation-delay: -0.2s; }
.wave i:nth-child(7) { animation-delay: -0.8s; } .wave i:nth-child(8) { animation-delay: -0.4s; }
@keyframes bar { 0%, 100% { height: 20%; } 50% { height: 100%; } }

/* ---- Nav buttons ---- */
.player-nav { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; justify-content: space-between; }
.player-nav .group { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.kbd-hint { color: var(--muted); font-size: 0.9rem; }
kbd { font-family: var(--mono); font-size: 0.85em; padding: 0.1em 0.5em; border-radius: 0.4em; border: 1px solid var(--border-strong); background: var(--surface); }

/* ---- Quiz ---- */
.quiz-q { font-size: clamp(1.3rem, 2.6vw, 1.85rem); margin-bottom: 1.2rem; line-height: 1.25; }
.quiz-fs { border: 0; padding: 0; margin: 0; min-width: 0; }
.quiz-fs legend { padding: 0; width: 100%; }
.options { display: grid; gap: 0.75rem; margin: 0 0 1.3rem; padding: 0; list-style: none; }
.option { position: relative; }
.option input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; cursor: pointer; margin: 0; }
.option label {
  display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: center;
  padding: 1rem 1.2rem;
  min-height: 3.5rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.option label::before {
  content: attr(data-letter);
  width: 2.2rem; height: 2.2rem; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 800;
  border: 2px solid var(--border-strong);
}
.option:hover label { border-color: var(--accent); background: var(--surface-2); }
.option input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 3px; }
.option input:checked + label { border-color: var(--accent); background: var(--info-bg); }
.option input:checked + label::before { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.option.correct input + label { border-color: var(--good); background: var(--good-bg); }
.option.correct input + label::before { content: "✓"; background: var(--good); color: var(--on-good); border-color: var(--good); }
.option.wrong input + label { border-color: var(--bad); background: var(--bad-bg); }
.option.wrong input + label::before { content: "✕"; background: var(--bad); color: var(--on-bad); border-color: var(--bad); }
.options.locked .option input { pointer-events: none; }
.options.locked .option:hover label { transform: none; }
.feedback { margin-bottom: 1.2rem; }
.feedback .callout strong { display: block; margin-bottom: 0.25rem; font-size: 1.1rem; }

.score {
  display: grid; place-items: center; text-align: center;
  padding: 1.5rem 1rem 1rem;
}
.score-ring {
  --p: 0;
  width: 9.5rem; height: 9.5rem; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--accent-2) calc(var(--p) * 1%), var(--surface-2) 0);
  position: relative;
  margin-bottom: 1rem;
}
.score-ring::before { content: ""; position: absolute; inset: 0.7rem; border-radius: 50%; background: var(--surface-solid); }
.score-ring span { position: relative; font-family: var(--font-display); font-weight: 800; font-size: 2.6rem; }
.review { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: 0.6rem; text-align: left; }
.review li { display: grid; grid-template-columns: auto 1fr; gap: 0.9rem; padding: 0.8rem 1rem; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.review .mark { font-weight: 900; font-size: 1.2rem; }
.review .ok { color: var(--good); }
.review .no { color: var(--bad); }
.review small { display: block; color: var(--muted); font-size: 0.92rem; margin-top: 0.2rem; }

/* ---- Full script ---- */
.script-list { list-style: none; counter-reset: sc; padding: 0; margin: 0; display: grid; gap: 1rem; }
.script-list li { counter-increment: sc; padding: 1.1rem 1.3rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }
.script-list h3 { font-size: 1.1rem; margin-bottom: 0.4em; }
.script-list h3::before { content: "Slide " counter(sc) " · "; color: var(--accent-2); }
.script-list p { margin: 0; color: var(--muted); font-size: 1.02rem; }

/* ---- Hero demo specifics ---- */
.demo-slide .slide-title { font-size: 1.5rem; }
.demo-slide .table-wrap { margin-top: 0.9rem; }
.demo-slide .slide-table th, .demo-slide .slide-table td { padding: 0.55rem 0.8rem; font-size: 0.92rem; }
.demo-slide .slide-table { min-width: 0; }
.demo-foot { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; align-items: center; justify-content: space-between; margin-top: 1rem; }
.demo-pane[hidden] { display: none; }
.demo-quiz .option label { padding: 0.7rem 0.9rem; min-height: 3rem; font-size: 0.97rem; }
.demo-quiz .quiz-q { font-size: 1.15rem; }
.demo-quiz .options { gap: 0.5rem; }

/* ---- Sticky bottom nav so Next/Previous stay reachable on long slides ---- */
.player > .player-nav {
  position: sticky;
  bottom: 0.75rem;
  z-index: 5;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border: 1px solid var(--border);
  box-shadow: 0 18px 40px -22px rgba(0, 0, 0, 0.7);
}
@media (max-width: 40rem) { .kbd-hint { display: none; } }
.options.locked label { cursor: default; }

/* Tables become stacked cards on phones: no sideways scrolling */
@media (max-width: 40rem) {
  .table-wrap { border: 0; overflow: visible; }
  .slide-table, .slide-table tbody, .slide-table tr, .slide-table th, .slide-table td { display: block; min-width: 0; }
  .slide-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .slide-table tbody { display: grid; gap: 0.6rem; }
  .slide-table tr { padding: 0.85rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
  .slide-table tbody th { padding: 0 0 0.35rem; border: 0; font-size: 1.1rem; }
  .slide-table td { padding: 0.25rem 0; border: 0; }
  .slide-table td::before { content: attr(data-label); display: block; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
  .demo-slide .slide-table th, .demo-slide .slide-table td { padding: 0.25rem 0; }
}

/* Phones: Previous / Next share one slim row */
@media (max-width: 40rem) {
  .player > .player-nav { flex-wrap: nowrap; gap: 0.6rem; padding: 0.5rem; bottom: 0.5rem; }
  .player > .player-nav .group { flex: 1 1 0; }
  .player > .player-nav .group .btn { width: 100%; padding-inline: 0.8rem; }
}
