/* Off Script. Sizes are in em, so the in app text size (--scale) and iPhone Text Size both apply.
   No italics anywhere: directions use square brackets. Colour is never the only signal. */

:root {
  --scale: 1;
  --lh: 1.5;
  --ls: 0;
  --ws: 0;
  color-scheme: light;
  /* Cream (the default theme) */
  --bg: #f7f1e3;
  --surface: #fffaf0;
  --raised: #ece2cc;
  --text: #1c1712;
  --muted: #4a4136;
  --border: #7a6c5a;
  --accent: #1a4d8f;
  --on-accent: #ffffff;
  --perfect: #1d6a38;
  --learning: #7a5000;
  --missed: #9a2846;
  --perfect-fill: #2e8b57;
  --learning-fill: #b07800;
  --missed-fill: #c2456a;
  --focus: #1a4d8f;
}

:root[data-theme='light'] {
  --bg: #ffffff;
  --surface: #f6f6f6;
  --raised: #e6e6e6;
  --text: #111111;
  --muted: #444444;
  --border: #767676;
  --accent: #0b57d0;
  --on-accent: #ffffff;
  --perfect: #1b6b35;
  --learning: #7a5000;
  --missed: #a3214a;
  --perfect-fill: #2f8f55;
  --learning-fill: #b37a00;
  --missed-fill: #c43d66;
  --focus: #0b57d0;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #121212;
  --surface: #1e1e1e;
  --raised: #2c2c2c;
  --text: #f3efe6;
  --muted: #cfc8bb;
  --border: #8f877b;
  --accent: #8ab4ff;
  --on-accent: #0b1a33;
  --perfect: #7fd99c;
  --learning: #f2c25b;
  --missed: #f59ab5;
  --perfect-fill: #5fbf80;
  --learning-fill: #d9a63a;
  --missed-fill: #e0789a;
  --focus: #8ab4ff;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme='auto'] {
    color-scheme: dark;
    --bg: #121212;
    --surface: #1e1e1e;
    --raised: #2c2c2c;
    --text: #f3efe6;
    --muted: #cfc8bb;
    --border: #8f877b;
    --accent: #8ab4ff;
    --on-accent: #0b1a33;
    --perfect: #7fd99c;
    --learning: #f2c25b;
    --missed: #f59ab5;
    --perfect-fill: #5fbf80;
    --learning-fill: #d9a63a;
    --missed-fill: #e0789a;
    --focus: #8ab4ff;
  }
}

/* Text: the phone's own body size (Dynamic Type), then the in app scale on top. */
html {
  font-size: 106.25%;
  font-family: -apple-system, system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation; /* no double tap to zoom anywhere, so quick taps are taps; pinch zoom still works */
}
html {
  font: -apple-system-body;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  font-style: normal !important;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: calc(1rem * var(--scale));
  line-height: var(--lh);
  letter-spacing: var(--ls);
  word-spacing: var(--ws);
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: inherit;
  word-spacing: inherit;
  color: inherit;
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0;
}
h1 {
  font-size: 1.35em;
}
h2 {
  font-size: 1.15em;
  margin: 1.4em 0 0.5em;
}
h3 {
  font-size: 1em;
  margin: 1em 0 0.35em;
}
p {
  margin: 0 0 0.75em;
}
strong {
  font-weight: 700;
}
a {
  color: var(--accent);
}

:focus {
  outline: none;
}
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
h1:focus-visible {
  outline-offset: 4px;
}

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

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

.loading {
  padding: 2em 1em;
}

/* Screen layout: a bar at the top, the body, and actions in the bottom third. */
.screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 40em;
  margin: 0 auto;
}

.bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5em;
  padding: calc(env(safe-area-inset-top) + 0.5em) calc(env(safe-area-inset-right) + 1em) 0.5em calc(env(safe-area-inset-left) + 1em);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.bar h1 {
  flex: 1 1 0;
  max-width: 100%;
  overflow-wrap: break-word; /* whole words: the bar wraps first, and only a word wider than the screen breaks */
}
.bar .back {
  margin-left: -0.5em;
}
.bar-actions {
  display: flex;
  gap: 0.25em;
}

.body {
  flex: 1;
  padding: 1em calc(env(safe-area-inset-right) + 1em) 1.5em calc(env(safe-area-inset-left) + 1em);
}

.foot {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 0.6em;
  padding: 0.75em calc(env(safe-area-inset-right) + 1em) calc(env(safe-area-inset-bottom) + 0.75em) calc(env(safe-area-inset-left) + 1em);
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.bar.flow,
.foot.flow {
  position: static;
}
.foot .row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6em;
}
.foot .row > * {
  flex: 1;
}
.foot .row > .btn {
  min-width: min-content; /* a long word at big text moves the button to its own row, not out of its border */
  max-width: 100%;
}

/* Buttons: at least 44 by 44 points. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  min-height: 2.75rem;
  min-width: 2.75rem;
  padding: 0.55em 1em;
  border: 2px solid var(--border);
  border-radius: 0.6em;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.btn.link {
  border-color: transparent;
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  padding-left: 0.5em;
  padding-right: 0.5em;
}
.btn[disabled] {
  opacity: 1;
  cursor: default;
  border-style: dashed;
  border-color: var(--border);
  background: var(--surface);
  color: var(--muted);
}
.btn[aria-pressed='true'] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}
.foot .btn {
  width: 100%;
}

.lead {
  font-size: 1.1em;
}
.help {
  color: var(--muted);
}
.plain {
  list-style: none;
  padding: 0;
  margin: 0 0 1em;
}
.plain li {
  padding: 0.35em 0;
  border-bottom: 1px solid var(--raised);
}
.steps {
  padding-left: 1.4em;
}
.steps li {
  margin-bottom: 0.5em;
}

.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5em;
  padding: 0.6em 0.8em;
  margin: 0 0 1em;
  border: 2px solid var(--accent);
  border-radius: 0.6em;
  background: var(--surface);
}
.notice p {
  margin: 0;
}
.message {
  padding: 0.6em 0.8em;
  margin: 0 0 1em;
  border-left: 0.3em solid var(--accent);
  background: var(--surface);
}

/* Today */
.headline {
  font-size: 1.2em;
  font-weight: 700;
  margin-bottom: 0.25em;
}
.summary {
  list-style: none;
  padding: 0;
  margin: 0.5em 0 1em;
}
.summary li {
  padding: 0.45em 0 0.45em 1.6em;
  position: relative;
  border-bottom: 1px solid var(--raised);
}
.summary li::before {
  content: '';
  position: absolute;
  left: 0.2em;
  top: 0.95em;
  width: 0.55em;
  height: 0.55em;
  border-radius: 50%;
  background: var(--accent);
}
.done-now {
  padding: 0.8em;
  border: 2px solid var(--perfect);
  border-radius: 0.6em;
  background: var(--surface);
  margin-bottom: 1em;
}
.done-now p:last-child {
  margin: 0;
}

/* The map: one bar per scene, segments sized by words. */
.map {
  list-style: none;
  padding: 0;
  margin: 0.5em 0 0.75em;
}
.map li {
  margin-bottom: 0.7em;
}
.map .label {
  display: block;
  margin-bottom: 0.2em;
}
.track {
  display: flex;
  height: 0.85em;
  border: 1px solid var(--border);
  border-radius: 0.3em;
  overflow: hidden;
  background: var(--surface);
}
.seg.new {
  background: var(--surface);
}
.seg.learning {
  background: var(--learning-fill);
}
.seg.perfect {
  background: var(--perfect-fill);
}
.seg.missed {
  background: repeating-linear-gradient(135deg, var(--missed-fill) 0 0.3em, var(--surface) 0.3em 0.45em);
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35em 1em;
  list-style: none;
  padding: 0;
  margin: 0 0 1em;
  color: var(--muted);
}
.legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
}
.swatch {
  display: inline-block;
  width: 1.2em;
  height: 0.85em;
  border: 1px solid var(--border);
  border-radius: 0.2em;
}

/* Sprint cards */
.timebar {
  height: 0.35em;
  margin: 0 0 1em;
  border-radius: 0.2em;
  background: var(--raised);
  overflow: hidden;
}
.timebar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 0.2em;
}
.where {
  color: var(--muted);
  margin-bottom: 0.6em;
}
.cue {
  padding: 0.6em 0.8em;
  margin: 0 0 1em;
  border-radius: 0.6em;
  background: var(--surface);
  border: 1px solid var(--border);
}
.cue-label {
  color: var(--muted);
  font-size: 0.9em;
  font-weight: 600;
  margin: 0 0 0.2em;
}
.cue p:last-child {
  margin-bottom: 0;
}
.note {
  color: var(--muted);
}
.speaker {
  font-weight: 700;
  margin-bottom: 0.25em;
}
.line {
  font-size: 1.25em;
  line-height: var(--lh);
  margin: 0 0 0.75em;
  overflow-wrap: break-word;
}
.answer {
  min-height: 1.6em;
}
.prompt {
  font-weight: 600;
}
.tok.miss {
  color: var(--missed);
  font-weight: 700;
  text-decoration: underline wavy;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.2em;
}
.tok .cross {
  font-size: 0.7em;
  vertical-align: 0.2em;
  margin-left: 0.05em;
}
.result {
  display: flex;
  align-items: flex-start;
  gap: 0.5em;
  padding: 0.6em 0.8em;
  margin: 0 0 1em;
  border-radius: 0.6em;
  border: 2px solid var(--border);
  background: var(--surface);
  font-weight: 700;
}
.result.perfect {
  border-color: var(--perfect);
  color: var(--perfect);
}
.result.misses {
  border-color: var(--missed);
  color: var(--missed);
}
.result .icon {
  flex: none;
}

/* Who's next: speaker chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  margin: 0.25em 0 1em;
}
.chip {
  flex: 1 1 40%;
}
.chip.right {
  border-color: var(--perfect);
  color: var(--perfect);
  box-shadow: inset 0 0 0 2px var(--perfect);
}
.chip.wrong {
  border-color: var(--missed);
  color: var(--missed);
  border-style: dashed;
}

/* Say mode: tap the words missed */
.words {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35em;
  margin: 0 0 1em;
}
.word {
  min-height: 2.75rem;
  padding: 0.3em 0.55em;
  border: 2px solid var(--border);
  border-radius: 0.5em;
  background: var(--surface);
  font-size: 1.1em;
  touch-action: manipulation;
}
.word[aria-pressed='true'] {
  border-color: var(--missed);
  color: var(--missed);
  font-weight: 700;
  border-style: dashed;
}
.word.note-word {
  border-color: transparent;
  color: var(--muted);
}

/* The keypad: never the phone's own keyboard. Keys are an exception to 44 points across, as ten
   must fit a row; they are tall instead. */
.key-caption {
  margin: 0 0 6px;
  text-align: center;
  font-weight: 600;
}

.keypad {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.5rem calc(env(safe-area-inset-right) + 0.25rem) calc(env(safe-area-inset-bottom) + 0.5rem) calc(env(safe-area-inset-left) + 0.25rem);
  background: var(--raised);
  user-select: none;
  -webkit-user-select: none;
}
.keys {
  display: flex;
  justify-content: center;
  gap: 0.3rem;
}
.key {
  flex: 0 1 2.4rem;
  min-width: 0;
  height: 3rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  background: var(--surface);
  color: var(--text);
  font-size: min(1.2rem, 5.5vw);
  font-weight: 600;
  touch-action: manipulation;
  cursor: pointer;
}
.keys.digits .key {
  height: 2.4rem;
  font-size: min(1rem, 4.5vw);
}
.key.reveal {
  flex-basis: 3.4rem;
  background: var(--bg);
  border-width: 2px;
}
.key:active {
  background: var(--accent);
  color: var(--on-accent);
}
.foot.keyboard {
  padding: 0;
  gap: 0;
  border-top: 0;
}

/* Scenes and the reader */
.scene-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.scene-list li {
  margin-bottom: 0.6em;
}
.scene-list .btn {
  width: 100%;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}
.scene-list .btn span {
  font-weight: 400;
  color: var(--muted);
}
.reader p {
  margin: 0 0 0.9em;
}
.reader .n {
  display: inline-block;
  min-width: 2.2em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.reader .dir,
.reader .on-screen {
  color: var(--muted);
}
.reader .playing {
  outline: 2px solid var(--accent);
  outline-offset: 0.2em;
}

/* Settings */
.field {
  margin: 0 0 1em;
}
.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25em;
}
.field select,
.field input[type='text'],
.field input[type='date'] {
  display: block;
  width: 100%;
  min-height: max(2.75rem, 44px); /* the phone's smallest text size makes a rem less than 16px */
  padding: 0.4em 0.6em;
  border: 2px solid var(--border);
  border-radius: 0.5em;
  background: var(--surface);
  color: var(--text);
}
.field select {
  overflow: hidden; /* WebKit lets a long option widen the page, whatever the width of the list */
  text-overflow: ellipsis;
}
.check {
  display: flex;
  align-items: center;
  gap: 0.6em;
  min-height: 2.75rem;
  margin: 0 0 1em;
  font-weight: 600;
}
.check input {
  width: 1.5em;
  height: 1.5em;
  accent-color: var(--accent);
}
.group {
  padding: 0 0 0.5em;
  border-bottom: 1px solid var(--raised);
  margin-bottom: 1em;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 0.6em;
  margin: 0 0 1em;
}
.stack .btn {
  width: 100%;
}

/* Walk */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.5em, 1fr));
  gap: 0.6em;
  margin: 0 0 1em;
}
.big {
  min-height: 4.5rem;
  font-size: 1.15em;
}
.halves {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6em;
}
.halves .btn {
  min-height: 9rem;
  font-size: 1.2em;
}
.review-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1em;
}
.review-list li {
  border-bottom: 1px solid var(--raised);
}
.review-list label {
  display: flex;
  align-items: flex-start;
  gap: 0.6em;
  min-height: 2.75rem;
  padding: 0.5em 0;
}
.review-list input {
  flex: none;
  width: 1.5em;
  height: 1.5em;
  margin-top: 0.1em;
  accent-color: var(--missed);
}

/* The stage: the cast app's own theme. A dark house, warm light. */
:root[data-theme='stage'] {
  color-scheme: dark;
  --bg: #14131f;
  --surface: #201e30;
  --raised: #2e2b44;
  --text: #f6f1e4;
  --muted: #cfc8d8;
  --border: #8f88a6;
  --accent: #ffc857;
  --on-accent: #1a1608;
  --perfect: #7fe0a4;
  --learning: #ffc857;
  --missed: #ff9db5;
  --perfect-fill: #7fe0a4;
  --learning-fill: #ffc857;
  --missed-fill: #ff9db5;
  --focus: #ffc857;
}

.ring {
  --pc: 0;
  width: min(11em, 100%);
  aspect-ratio: 1;
  margin: 1em auto;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(closest-side, var(--bg) 79%, transparent 80%), conic-gradient(var(--accent) calc(var(--pc) * 1%), var(--raised) 0);
}
.ring-num { font-size: 2.6em; font-weight: 700; line-height: 1.1; }
.ring-word { color: var(--muted); }
.fading { text-align: center; font-weight: 600; }
.who { text-align: center; color: var(--muted); margin: 0; }

.lights { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.5em; }
.light { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25em 0.75em; padding: 0.5em 0.75em; background: var(--surface); border: 1px solid var(--border); border-radius: 0.6em; }
.lamp { flex: none; width: 1.1em; height: 1.1em; border: 2px solid var(--border); border-radius: 50%; overflow: hidden; }
.lamp-fill { display: block; height: 100%; background: var(--accent); }
.light.lit .lamp { box-shadow: 0 0 0.9em 0.2em var(--accent); }
.light-name { flex: 1; }
.light-pc { font-weight: 600; }

.moment { text-align: center; padding: 1em; margin-bottom: 1em; border: 2px solid var(--accent); border-radius: 0.8em; background: var(--surface); animation: lights-up 900ms ease-out; }
.moment-big { font-size: 2.2em; font-weight: 700; margin: 0; color: var(--accent); }
@keyframes lights-up {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .moment { animation: none; }
}

.spot { font-weight: 700; color: var(--accent); }
.science { padding: 0.75em 1em; border-left: 4px solid var(--accent); background: var(--surface); }
.guide { font-size: 1.5em; font-weight: 700; text-align: center; }
.all-steps h2 { margin-top: 1.25em; }
