/* Comic reader: page layouts and panels (ENG-12), captions and bubbles
   (ENG-13). SVG art arrives in ENG-14. Bubbles stay white with dark ink, as
   in printed comics, in both themes. */

:root {
  --bubble-bg: #ffffff;
  --bubble-ink: #121216;
  --bubble-edge: #121216;
  --bubble-name: #5a5a66;
  --caption-bg: #ffe8a3;
  --caption-ink: #121216;
}

.comic-page {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 180px;
  background: var(--panel);
  border: var(--line) solid var(--edge);
  border-radius: 4px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-scene {
  margin: 0;
  padding: 6px 12px;
  background: var(--highlight);
  color: var(--highlight-ink);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

/* Narration: caption boxes across the top of the panel. */
.captions {
  display: grid;
  gap: 6px;
  padding: 10px 10px 0;
}

.caption {
  margin: 0;
  justify-self: start;
  max-width: 92%;
  padding: 6px 10px;
  background: var(--caption-bg);
  color: var(--caption-ink);
  border: 2px solid var(--bubble-edge);
  border-radius: 2px;
  font-size: 0.95rem;
  box-shadow: 2px 2px 0 var(--shadow-color);
}

/* Speech and thought: bubbles, each leaning toward its speaker's side. */
.bubbles {
  display: grid;
  gap: 18px;
  padding: 14px 12px 34px;
}

.bubble {
  position: relative;
  max-width: 86%;
  padding: 8px 14px 10px;
  background: var(--bubble-bg);
  color: var(--bubble-ink);
  border: 2px solid var(--bubble-edge);
}

.bubble p {
  margin: 0;
}

.bubble[data-side='left'] {
  justify-self: start;
}

.bubble[data-side='right'] {
  justify-self: end;
}

.bubble-name {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bubble-name);
}

.bubble-speech {
  border-radius: 22px;
}

/* The tail: an outlined triangle under the bubble, toward the speaker. */
.bubble-speech::before,
.bubble-speech::after {
  content: '';
  position: absolute;
  top: 100%;
  border-style: solid;
}

.bubble-speech::before {
  border-width: 14px 10px 0 10px;
  border-color: var(--bubble-edge) transparent transparent transparent;
}

.bubble-speech::after {
  margin-top: -3px;
  border-width: 11px 7px 0 7px;
  border-color: var(--bubble-bg) transparent transparent transparent;
}

.bubble-speech[data-side='left']::before { left: 22px; }
.bubble-speech[data-side='left']::after { left: 25px; }
.bubble-speech[data-side='right']::before { right: 22px; }
.bubble-speech[data-side='right']::after { right: 25px; }

/* A thought cloud: scalloped edge, with two small circles trailing off. */
.bubble-thought {
  border-radius: 40px;
  border-style: dashed;
  font-style: italic;
}

.bubble-thought::before,
.bubble-thought::after {
  content: '';
  position: absolute;
  border: 2px solid var(--bubble-edge);
  border-radius: 50%;
  background: var(--bubble-bg);
}

.bubble-thought::before {
  width: 12px;
  height: 12px;
  top: calc(100% + 3px);
}

.bubble-thought::after {
  width: 7px;
  height: 7px;
  top: calc(100% + 17px);
}

.bubble-thought[data-side='left']::before { left: 24px; }
.bubble-thought[data-side='left']::after { left: 16px; }
.bubble-thought[data-side='right']::before { right: 24px; }
.bubble-thought[data-side='right']::after { right: 16px; }

.target-word {
  /* A button that reads like a highlighted word inside the sentence. */
  appearance: none;
  margin: 0;
  border: 0;
  padding: 0 3px;
  border-radius: 3px;
  background: var(--highlight);
  color: var(--highlight-ink);
  font: inherit;
  font-weight: 700;
  line-height: inherit;
  text-decoration: underline dotted 2px;
  text-underline-offset: 3px;
  cursor: pointer;
}

.target-word:hover {
  text-decoration-style: solid;
}

/* The word pop-up (ENG-15). */
.word-popup {
  width: min(480px, calc(100vw - 32px));
}

.word-title {
  margin: 0 0 4px;
  font-size: 2rem;
}

.word-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 8px;
}

.word-say {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.word-pos {
  font-style: italic;
}

.word-pron {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.word-popup h3 {
  margin: 16px 0 4px;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.word-definition {
  margin: 0;
}

.word-example {
  margin: 6px 0 0;
  padding-left: 12px;
  border-left: 4px solid var(--highlight);
  font-style: italic;
}

.word-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 16px 0 0;
}

.word-facts dt {
  font-weight: 700;
}

.word-facts dd {
  margin: 0;
}

.page-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.page-nav > :first-child {
  justify-self: start;
}

.page-nav > :last-child {
  justify-self: end;
}

.page-count {
  color: var(--ink-muted);
  font-weight: 700;
  text-align: center;
}

.story-end {
  font-weight: 700;
  font-size: 1.1rem;
}

@media (min-width: 600px) {
  .comic-page[data-layout='2x2'] {
    grid-template-columns: 1fr 1fr;
  }

  .comic-page[data-layout='1+2'] {
    grid-template-columns: 1fr 1fr;
  }

  .comic-page[data-layout='1+2'] > .panel:first-child {
    grid-column: 1 / -1;
  }
}

.word-popup .card-actions {
  margin-top: 24px;
}

/* Text-only stories (comics are parked, 2026-11-29): one chapter per page,
   set like a book page for easy reading on a phone. */
.story-chapter {
  max-width: 42rem;
  padding: 20px 18px;
  background: var(--panel);
  border: var(--line) solid var(--edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 1.125rem;
  line-height: 1.7;
}

.chapter-title {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: 1.6rem;
  letter-spacing: 0.03em;
  line-height: 1.2;
}

.chapter-number {
  display: block;
  font-family: var(--font-body);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.story-narration {
  margin: 0 0 1em;
}

.story-line {
  margin: 0 0 1em;
  padding-left: 14px;
  border-left: 4px solid var(--tone-stories);
}

.story-line .speaker {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.story-thought {
  border-left-style: dashed;
  border-left-color: var(--tone-quiz);
}

.story-thought .line-text {
  font-style: italic;
}
