/* Interactive presentations — Khan-style blackboard + classroom controls */
:root {
  --bg: #05080f;
  --panel: #0b1220;
  --line: #1e293b;
  --muted: #94a3b8;
  --chalk: #ecfdf5;
  --chalk-yellow: #fde68a;
  --chalk-green: #86efac;
  --chalk-pink: #f9a8d4;
  --chalk-white: #f8fafc;
  --board-bg: linear-gradient(160deg, #0f3d2e 0%, #0a2a20 55%, #071c15 100%);
  --board-edge: #14532d;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; min-height: 100%;
  background: var(--bg);
  color: #e2e8f0;
  font-family: "DM Sans", system-ui, sans-serif;
}
.bg {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(34, 197, 94, .12), transparent),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(59, 130, 246, .1), transparent);
}

.pres-shell { position: relative; z-index: 1; max-width: 1100px; margin: 0 auto; padding: 1rem 1.1rem 3rem; }

.pres-top {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem;
  margin-bottom: 1rem;
}
.pres-brand { display: flex; gap: .65rem; align-items: center; flex: 1 1 auto; }
.pres-brand .mark {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; font-weight: 700;
  background: linear-gradient(135deg, #166534, #22c55e); color: #052e16;
}
.pres-brand .title { font-family: "Instrument Serif", Georgia, serif; font-size: 1.25rem; }
.pres-brand .sub { color: var(--muted); font-size: .82rem; }
.pres-top a { color: #93c5fd; text-decoration: none; font-size: .9rem; }
.pres-top a:hover { text-decoration: underline; }

.stage {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 900px) {
  .stage { grid-template-columns: 1.4fr .9fr; align-items: start; }
}

/* Khan blackboard */
.board-card {
  border-radius: 18px;
  border: 2px solid var(--board-edge);
  background: var(--board-bg);
  box-shadow: inset 0 0 50px rgba(0,0,0,.4), 0 12px 40px rgba(0,0,0,.35);
  min-height: 420px;
  padding: 1.1rem 1.25rem 1.4rem;
  position: relative;
  overflow: hidden;
}
.board-card::before {
  content: "";
  position: absolute; inset: 0; pointer-events: none; opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.board-label {
  font-size: .72rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--chalk-green); margin-bottom: .65rem; position: relative;
}
.board-canvas {
  position: relative;
  min-height: 340px;
  color: var(--chalk);
  font-family: "Caveat", "Segoe Print", "Comic Sans MS", cursive;
  font-size: 1.55rem;
  line-height: 1.35;
}
.chalk-line {
  opacity: 0;
  transform: translateY(4px);
  margin: .35rem 0;
  white-space: pre-wrap;
  text-shadow: 0 1px 0 rgba(0,0,0,.25);
}
.chalk-line.visible {
  opacity: 1;
  transform: none;
  transition: opacity .35s ease, transform .35s ease;
}
.chalk-line.writing {
  border-right: 2px solid var(--chalk-yellow);
  animation: caret 1s steps(1) infinite;
}
@keyframes caret {
  50% { border-right-color: transparent; }
}
.chalk-line.color-yellow { color: var(--chalk-yellow); }
.chalk-line.color-green { color: var(--chalk-green); }
.chalk-line.color-pink { color: var(--chalk-pink); }
.chalk-line.color-white { color: var(--chalk-white); }
.chalk-line.is-title {
  font-size: 2.1rem;
  font-weight: 600;
  margin-bottom: .75rem;
  letter-spacing: .02em;
}
.chalk-line.is-box {
  display: inline-block;
  margin-top: .75rem;
  padding: .45rem .85rem;
  border: 2px dashed var(--chalk-yellow);
  border-radius: 8px;
  font-size: 1.35rem;
}
.chalk-line.is-note {
  font-size: 1.25rem;
  font-style: italic;
  opacity: .95;
}
.chalk-cursor {
  display: inline-block;
  width: 10px; height: 1.1em;
  margin-left: 2px;
  background: var(--chalk-yellow);
  vertical-align: text-bottom;
  animation: blink .8s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.side-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem 1.1rem;
}
.side-card h2 {
  font-family: "Instrument Serif", Georgia, serif;
  font-weight: 400;
  margin: 0 0 .35rem;
  font-size: 1.35rem;
}
.side-card .muted { color: var(--muted); font-size: .9rem; margin: 0 0 .85rem; }

.unit-progress {
  display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0 1rem;
}
.unit-dot {
  width: 28px; height: 8px; border-radius: 999px;
  background: #1e293b; border: 1px solid var(--line);
}
.unit-dot.done { background: #22c55e; border-color: #16a34a; }
.unit-dot.active { background: #fbbf24; border-color: #f59e0b; }

.controls {
  display: flex; flex-wrap: wrap; gap: .45rem;
  margin: .75rem 0;
}
.btn {
  appearance: none; border: 1px solid var(--line);
  background: #111827; color: #e2e8f0;
  border-radius: 999px; padding: .45rem .9rem;
  font: inherit; font-size: .9rem; cursor: pointer;
}
.btn:hover { border-color: #475569; }
.btn.primary {
  background: linear-gradient(135deg, #166534, #22c55e);
  border-color: #16a34a; color: #052e16; font-weight: 600;
}
.btn.danger {
  background: rgba(239, 68, 68, .15);
  border-color: rgba(239, 68, 68, .45);
  color: #fecaca;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; }

.status {
  min-height: 1.4rem;
  font-size: .88rem;
  color: var(--chalk-yellow);
  margin: .35rem 0 .5rem;
}
.status.idle { color: var(--muted); }

.ask-panel {
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px dashed var(--line);
}
.ask-panel label {
  display: block; font-size: .78rem; color: var(--muted);
  margin-bottom: .35rem; letter-spacing: .04em; text-transform: uppercase;
}
.ask-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.ask-row input {
  flex: 1 1 160px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0a0f1a;
  color: #e2e8f0;
  padding: .55rem .7rem;
  font: inherit;
}
.ask-reply {
  margin-top: .65rem;
  padding: .65rem .75rem;
  border-radius: 10px;
  background: rgba(15, 61, 46, .35);
  border: 1px solid rgba(34, 197, 94, .25);
  color: #ecfdf5;
  font-size: .95rem;
  line-height: 1.45;
  white-space: pre-wrap;
  max-height: 220px;
  overflow: auto;
}
.ask-reply.hidden { display: none; }

.hint {
  font-size: .8rem;
  color: var(--muted);
  margin: .5rem 0 0;
}

/* Index grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}
.tile {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.1rem 1.15rem;
  transition: border-color .15s, transform .15s;
}
.tile:hover {
  border-color: #22c55e;
  transform: translateY(-2px);
}
.tile h3 {
  font-family: "Instrument Serif", Georgia, serif;
  font-weight: 400;
  margin: .2rem 0 .4rem;
  font-size: 1.35rem;
}
.tile .badge {
  display: inline-block;
  font-size: .7rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--chalk-green);
  border: 1px solid rgba(134, 239, 172, .35);
  border-radius: 999px;
  padding: .15rem .5rem;
}


/* —— Shared board stack (tutor chalk + learner canvas) —— */
.board-stack {
  position: relative;
  min-height: 340px;
}
.board-stack .board-canvas {
  min-height: 340px;
  position: relative;
  z-index: 1;
  pointer-events: none; /* clicks go to user canvas when tools on */
}
.user-board {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
  pointer-events: none; /* enabled when Interactive */
}
.user-board.active {
  pointer-events: auto;
}
.board-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  margin-top: .65rem;
  position: relative;
  z-index: 3;
}
.board-tools .tools-label {
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--chalk-green);
  margin-right: .25rem;
}
.tool-btn {
  border: 1px solid rgba(134, 239, 172, .35);
  background: rgba(6, 30, 20, .55);
  color: #ecfdf5;
  border-radius: 999px;
  padding: .3rem .75rem;
  font-size: .82rem;
  cursor: pointer;
}
.tool-btn.active {
  border-color: var(--chalk-yellow);
  background: rgba(250, 204, 21, .15);
  color: var(--chalk-yellow);
}
.tool-btn:hover { filter: brightness(1.08); }

.btn.interactive {
  border: 1px solid rgba(96, 165, 250, .55);
  background: rgba(30, 58, 138, .45);
  color: #dbeafe;
}
.btn.interactive[aria-pressed="true"] {
  border-color: #60a5fa;
  background: rgba(37, 99, 235, .55);
  box-shadow: 0 0 0 2px rgba(96, 165, 250, .25);
}
.mic-warn {
  margin: .5rem 0 0;
  padding: .55rem .75rem;
  border-radius: 10px;
  border: 1px solid rgba(251, 191, 36, .4);
  background: rgba(120, 53, 15, .35);
  color: #fde68a;
  font-size: .88rem;
  line-height: 1.4;
}
.mic-warn.hidden { display: none; }


/* mobile pen board — phone-first, stylus-ready */
.board-card {
  /* larger touch target on phones */
  min-height: min(70vh, 560px);
}
@media (max-width: 700px) {
  .board-card {
    min-height: 62vh;
    border-radius: 14px;
    padding: 0.75rem 0.85rem 1rem;
  }
  .board-stack,
  .board-stack .board-canvas {
    min-height: 52vh;
  }
  .user-board.active {
    /* prevent page scroll while drawing */
    touch-action: none;
  }
  .board-tools {
    position: sticky;
    bottom: 0;
    padding: 0.45rem 0 0.15rem;
    gap: 0.5rem;
  }
  .tool-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 0.45rem 0.95rem;
    font-size: 0.95rem;
  }
  .controls .btn {
    min-height: 44px;
  }
  .ask-row input {
    min-height: 44px;
    font-size: 16px; /* iOS zoom avoid */
  }
}
.user-board.active {
  cursor: crosshair;
  touch-action: none;
}

.tools-hint {
  font-size: .75rem;
  color: var(--muted);
  margin-left: .35rem;
}
@media (max-width: 700px) {
  .tools-hint { display: none; }
}

/* Saved board library (per-unit snapshots) */
.board-library {
  margin-top: .55rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem;
}
.board-library-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}
.board-library-thumbs button {
  border: 1px solid rgba(134, 239, 172, .35);
  background: rgba(6, 30, 20, .55);
  border-radius: 8px;
  padding: 2px;
  cursor: pointer;
}
.board-library-thumbs img {
  display: block;
  width: 56px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
}

/* iPad + large phone: thumb-reach tools, no hover required */
@media (max-width: 1100px) {
  .pres-shell { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .board-tools {
    position: sticky;
    bottom: env(safe-area-inset-bottom, 0px);
    z-index: 4;
    background: linear-gradient(180deg, transparent, rgba(6, 20, 16, .92));
  }
  .tool-btn, .controls .btn {
    min-height: 44px;
  }
  .ask-row input { font-size: 16px; }
}
@media (min-width: 701px) and (max-width: 1100px) {
  .board-card { min-height: 58vh; }
}
