/* Version: 1.0.0 | Updated: 2026-11-02 */
/* Chat Simulator. Sized to be read from the back of a classroom: 1rem is about 24px on a 1080p board. */

:root {
  --navy: #002885;
  --sky: #8BB8E8;
  --sand: #EDE6DF;
  --mist: #DDEBEE;
  --ink: #0B1636;
  --muted: #3A4666;
  --page: #EEF3F7;
  --card: #FFFFFF;
  --line: #C3D1E3;
  --bubble-line: rgba(0, 40, 133, 0.28);
  color-scheme: light;
}

html {
  font-size: clamp(17px, 0.9vw + 7px, 26px);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--page);
  line-height: 1.4;
}

h1, h2, h3, p { margin: 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 4px solid var(--navy); outline-offset: 3px; }
.topbar :focus-visible, .phone-head :focus-visible, .on-dark:focus-visible { outline-color: #fff; }
[tabindex="-1"]:focus { outline: none; }

kbd {
  font: inherit; font-size: 0.65em; font-weight: 600;
  padding: 0.05em 0.35em; border: 1px solid currentColor; border-radius: 0.3em; opacity: 0.85;
}

/* ---- Buttons ---- */

.btn {
  font: inherit; font-size: 0.85rem; font-weight: 600;
  min-height: max(48px, 2.2rem); padding: 0.4rem 1rem;
  border: 2px solid var(--navy); border-radius: 0.8rem;
  background: var(--card); color: var(--navy); cursor: pointer;
}
.btn:hover { background: var(--mist); }
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:hover { background: #0B3AA8; }
.btn.big { font-size: 1.1rem; padding: 0.6rem 1.8rem; min-height: max(56px, 2.8rem); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn[aria-pressed="true"] { background: var(--sky); color: var(--ink); }
.btn[aria-pressed="true"]::before { content: "\2713\00a0"; }
.btn.on-dark { background: transparent; color: #fff; border-color: #fff; }
.btn.on-dark:hover { background: rgba(255, 255, 255, 0.15); }

.btn-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }

/* ---- Menu ---- */

.menu-head { background: var(--navy); color: #fff; padding: 1.2rem 16px; text-align: center; }
.menu-head h1 { font-size: 1.8rem; }
.menu-head p { font-size: 1rem; opacity: 0.9; }
.menu-main { max-width: 52rem; margin: 0 auto; padding: 1.2rem 16px 2rem; }

.mode-toggle { display: flex; justify-content: center; gap: 0; margin: 0.5rem 0 0.6rem; }
.mode-toggle button {
  font: inherit; font-size: 0.95rem; font-weight: 600; min-height: max(48px, 2.4rem);
  padding: 0.4rem 1.4rem; border: 3px solid var(--navy); background: var(--card); color: var(--navy); cursor: pointer;
}
.mode-toggle button:first-child { border-radius: 1rem 0 0 1rem; }
.mode-toggle button:last-child { border-radius: 0 1rem 1rem 0; border-left: none; }
.mode-toggle button[aria-pressed="true"] { background: var(--navy); color: #fff; }
.mode-toggle button[aria-pressed="true"]::before { content: "\2713\00a0"; }
.mode-help { text-align: center; color: var(--muted); font-size: 0.85rem; max-width: 38rem; margin: 0 auto 1rem; }

.lesson { margin-top: 1.2rem; }
.lesson h2 { font-size: 1rem; color: var(--navy); margin-bottom: 0.5rem; }
.scenario-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.7rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr)); }
.scenario-card {
  font: inherit; width: 100%; height: 100%; text-align: left; cursor: pointer;
  display: grid; gap: 0.15rem; padding: 0.8rem 1rem;
  background: var(--card); color: var(--ink); border: 2px solid var(--line); border-radius: 1.2rem 1.2rem 1.2rem 0.35rem;
}
.scenario-card:hover:not(:disabled) { border-color: var(--navy); background: #F7FAFD; }
.scenario-card:disabled { cursor: not-allowed; background: #F4F5F7; }
.scenario-card .code { font-size: 0.7rem; font-weight: 700; color: var(--navy); letter-spacing: 0.05em; }
.scenario-card .title { font-size: 1.05rem; font-weight: 700; }
.scenario-card .meta { font-size: 0.75rem; color: var(--muted); }
.load-warning { margin-top: 1rem; color: var(--ink); background: var(--sand); padding: 0.6rem 0.9rem; border-radius: 0.8rem; font-size: 0.85rem; }
.fiction-note { margin-top: 1.6rem; text-align: center; font-size: 0.75rem; color: var(--muted); }
.build { text-align: center; font-size: 0.65rem; color: var(--muted); padding: 0 16px 1rem; }

.notice { max-width: 40rem; margin: 3rem auto; padding: 0 16px; text-align: center; display: grid; gap: 1rem; justify-items: center; }
.notice h1 { font-size: 1.5rem; color: var(--navy); }

/* ---- Player layout ---- */

#player { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

.topbar {
  display: flex; align-items: center; gap: 1rem; padding: 0.4rem 1rem;
  background: var(--navy); color: #fff;
}
.topbar h1 { font-size: 1rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode-badge { font-size: 0.7rem; font-weight: 600; padding: 0.15rem 0.6rem; border: 1px solid #fff; border-radius: 999px; white-space: nowrap; }

.stage {
  flex: 1; min-height: 0; width: 100%; max-width: 92rem; margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 30rem) minmax(0, 1fr); gap: 1.2rem; padding: 1rem 1.2rem;
}

.phone {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--card); border: 3px solid var(--navy); border-radius: 1.6rem; overflow: hidden;
}
.phone-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  padding: 0.5rem 0.9rem; background: var(--navy); color: #fff;
}
.phone-titles { display: grid; min-width: 0; }
.app-name { font-size: 0.65rem; font-weight: 600; opacity: 0.85; letter-spacing: 0.04em; text-transform: uppercase; }
.chat-name { font-size: 0.95rem; font-weight: 700; }
.avatars { display: flex; gap: 0.2rem; flex-wrap: wrap; justify-content: flex-end; }

.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0.6rem 0.8rem; }
.chat { list-style: none; margin: 0; padding: 0; }
.typing { padding: 0.2rem 1rem 0.5rem; font-size: 0.75rem; font-style: italic; color: var(--muted); }

.side { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 0.9rem; padding-bottom: 0.5rem; }
.presenter, .controls { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.show-controls { align-self: flex-start; font-size: 0.7rem; }

/* ---- Messages ---- */

.msg { display: flex; align-items: flex-end; gap: 0.5rem; margin: 0.55rem 0; }
.msg.mine { flex-direction: row-reverse; }
.msg-body { max-width: 82%; min-width: 0; display: flex; flex-direction: column; }
.msg.mine .msg-body { align-items: flex-end; }
.msg-name { font-size: 0.7rem; font-weight: 600; color: var(--muted); margin: 0 0.6rem 0.1rem; }

.avatar {
  flex: none; display: grid; place-items: center;
  width: 2.1rem; height: 2.1rem; border-radius: 50%;
  background: var(--c); color: var(--ink); border: 2px solid var(--bubble-line);
  font-size: 0.75rem; font-weight: 700;
}
.avatar.small { width: 1.6rem; height: 1.6rem; font-size: 0.6rem; border-color: #fff; }

.bubble {
  font: inherit; color: var(--ink); text-align: left;
  background: var(--c); border: 1px solid var(--bubble-line);
  border-radius: 1.2rem; padding: 0.5rem 0.85rem; overflow-wrap: anywhere;
}
.theirs .bubble { border-bottom-left-radius: 0.35rem; }
.mine .bubble { border-bottom-right-radius: 0.35rem; }
.bubble-text { font-size: 1rem; }

.bubble.tappable { cursor: pointer; border: 3px dashed var(--navy); }
.bubble.tappable:hover { filter: brightness(0.97); }
.bubble.tappable[aria-pressed="true"] { border-style: solid; box-shadow: 0 0 0 4px var(--sky); }
.tap-hint { font-size: 0.65rem; font-weight: 600; color: var(--navy); margin: 0.15rem 0.6rem 0; }

.msg.system, .msg.divider { justify-content: center; text-align: center; }
.system-text { font-size: 0.75rem; font-style: italic; color: var(--muted); max-width: 90%; }
.msg.divider {
  font-size: 0.7rem; font-weight: 700; color: var(--navy);
  background: var(--mist); border-radius: 999px; padding: 0.2rem 0.8rem; width: fit-content; margin: 0.9rem auto;
}

.attach { background: rgba(255, 255, 255, 0.7); border: 1px solid var(--bubble-line); border-radius: 0.8rem; padding: 0.4rem 0.6rem; margin-bottom: 0.3rem; }
.attach-kind { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--navy); }
.attach-caption { font-size: 0.8rem; font-style: italic; }
.attach-quote { background: #fff; border-left: 4px solid var(--navy); border-radius: 0.4rem; padding: 0.3rem 0.5rem; margin: 0.25rem 0; }
.attach-quote-name { font-size: 0.65rem; font-weight: 700; color: var(--muted); }
.attach-quote-text { font-size: 0.85rem; }

.reach { flex-direction: column; align-items: center; gap: 0.3rem; margin: 1rem 0; }
.reach-count {
  font-size: 1.05rem; font-weight: 700; color: var(--navy);
  border: 2px solid var(--navy); border-radius: 999px; padding: 0.25rem 1rem; background: var(--mist);
}
.reach-caption { font-size: 0.75rem; color: var(--muted); max-width: 90%; }

/* ---- Side panel cards ---- */

.card { background: var(--card); border: 2px solid var(--line); border-radius: 1.2rem; padding: 1rem 1.2rem; }
.prompt-title { font-size: 1.15rem; color: var(--navy); margin-bottom: 0.7rem; }
.sub { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--navy); margin: 0.9rem 0 0.25rem; }
.hint { display: grid; justify-items: start; gap: 0.4rem; }
.hint-small { font-size: 0.75rem; color: var(--muted); margin-top: 0.6rem; }
.progress { font-size: 0.85rem; color: var(--muted); }

.choices { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.choice {
  font: inherit; font-size: 1rem; width: 100%; text-align: left; cursor: pointer;
  display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap;
  min-height: max(48px, 2.6rem); padding: 0.55rem 0.9rem;
  background: var(--card); color: var(--ink); border: 3px solid var(--navy); border-radius: 1rem;
}
.choice:hover { background: var(--mist); }
.choice[aria-pressed="true"] { background: var(--sky); }
.choice .letter {
  flex: none; display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--navy); color: #fff; font-weight: 800;
}
.choice-text { flex: 1; min-width: 0; }
.picked { font-size: 0.7rem; font-weight: 700; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--navy); color: #fff; }
.class-mode .choice { font-size: 1.1rem; padding: 0.7rem 1rem; }
.class-mode .choice .letter { width: 2.6rem; height: 2.6rem; font-size: 1.2rem; }

.outcome-what { font-size: 1.05rem; }
.outcome-think, .reflection { font-size: 1rem; }
.reflection { font-weight: 700; color: var(--navy); }
.end-chose { font-size: 1rem; }
.end-list { margin: 0; padding-left: 1.3rem; display: grid; gap: 0.3rem; font-size: 0.9rem; }

.tool-list { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.3rem; font-size: 0.85rem; }

.quoted {
  margin: 0 0 0.8rem; padding: 0.4rem 0.8rem; font-size: 1rem;
  border-left: 5px solid var(--navy); background: var(--page); border-radius: 0.4rem;
}
.thoughts { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.9rem; }
.thought {
  position: relative; display: grid; gap: 0.1rem; padding: 0.5rem 0.9rem; margin-left: 1.2rem;
  background: var(--sand); border: 1px solid var(--bubble-line); border-radius: 1.4rem;
}
/* Thought-bubble tail: two small circles to the left. */
.thought::before, .thought::after {
  content: ""; position: absolute; border-radius: 50%; background: var(--sand); border: 1px solid var(--bubble-line);
}
.thought::before { width: 0.7rem; height: 0.7rem; left: -0.8rem; bottom: 0.3rem; }
.thought::after { width: 0.4rem; height: 0.4rem; left: -1.25rem; bottom: 0; }
.thought-label { font-size: 0.8rem; color: var(--navy); }
.thought-text { font-size: 0.95rem; }

.feedback-area:empty { display: none; }
.feedback, .meaning { margin-top: 0.8rem; padding: 0.2rem 0 0.2rem 0.8rem; border-left: 6px solid var(--sky); }
.meaning { border-left-color: var(--navy); }
.feedback .sub, .meaning .sub { margin-top: 0.2rem; }

.notes { background: var(--sand); border-radius: 1.2rem; padding: 0.8rem 1.1rem; }
.notes h2 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--navy); margin-bottom: 0.2rem; }
.notes p { font-size: 0.9rem; }

.toolbox { background: var(--card); border: 2px solid var(--line); border-radius: 1.2rem; padding: 0 1.1rem; }
.toolbox summary { cursor: pointer; font-weight: 700; color: var(--navy); font-size: 0.9rem; min-height: 48px; display: flex; align-items: center; }
.toolbox[open] { padding-bottom: 0.8rem; }

/* ---- PAUSE ---- */

.pause {
  width: min(38rem, calc(100vw - 32px)); border: none; border-radius: 1.6rem; padding: 1.6rem 1.8rem;
  background: var(--card); color: var(--ink); text-align: center;
}
.pause::backdrop { background: rgba(0, 20, 66, 0.65); }
.pause h2 { font-size: 2rem; color: var(--navy); letter-spacing: 0.08em; text-transform: uppercase; }
.pause-lead { font-size: 0.9rem; color: var(--muted); margin: 0.2rem 0 1rem; }
.pause-prompts { list-style: none; margin: 0 0 1.2rem; padding: 0; display: grid; gap: 0.7rem; }
.pause-prompt {
  font-size: 1.3rem; font-weight: 700; background: var(--sky); border-radius: 1.4rem 1.4rem 1.4rem 0.35rem;
  padding: 0.6rem 1rem; width: fit-content; margin: 0 auto;
}
.pause-bar-track { height: 6px; background: var(--mist); border-radius: 3px; overflow: hidden; margin: 0 auto 1rem; max-width: 16rem; }
.pause-bar { height: 100%; width: 100%; background: var(--navy); transform-origin: left; }
.pause-bar.locking { animation: pause-fill 2s linear both; }
@keyframes pause-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---- Motion ---- */

.appear { animation: appear 220ms ease-out both; }
@keyframes appear { from { opacity: 0; transform: translateY(0.4rem); } to { opacity: 1; transform: none; } }
.bump { animation: bump 300ms ease-out; }
@keyframes bump { 50% { transform: scale(1.06); } }

@media (prefers-reduced-motion: reduce) {
  .appear, .bump, .pause-bar.locking { animation: none; }
}

/* ---- iPad portrait and narrower: stack the chat above the panel ---- */

@media (max-width: 900px) {
  #player { height: auto; min-height: 100vh; }
  .stage { grid-template-columns: minmax(0, 1fr); padding: 0.8rem 16px; }
  .phone { height: 60vh; }
  .side { overflow: visible; }
  .mode-badge { display: none; }
}
