/* Learning Guide · Proof of Concept Nº 1 · The Dialogue
   Direction: serious publishing. Paper, ink, one Pompeian red.
   Fraunces (display) · EB Garamond (text) · IBM Plex Mono (labels) */

:root {
  --paper: #F6F1E7;
  --paper-deep: #EFE8D9;
  --ink: #211D17;
  --ink-soft: #6A6155;
  --line: rgba(33, 29, 23, 0.22);
  --line-faint: rgba(33, 29, 23, 0.12);
  --red: #93311F;
  --gold: #C8A24B;
  --lit-bg: rgba(200, 162, 75, 0.30);
  --lit-past: rgba(200, 162, 75, 0.55);

  --serif: "EB Garamond", Georgia, serif;
  --display: "Fraunces", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  --dur: 280ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(200, 162, 75, 0.08), transparent 60%),
    var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ============ Shared bits ============ */

.kicker, .col-label, .demo-tag, .ln, .who, .intro-note, .colophon {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.col-label {
  font-size: 0.66rem;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.5rem;
  margin-bottom: 1.4rem;
}

/* ============ Intro ============ */

.intro {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 3rem 1.5rem;
  transition: opacity 600ms var(--ease);
}

.intro.leaving { opacity: 0; }

.intro-inner { max-width: 660px; }

.kicker {
  font-size: 0.7rem;
  color: var(--red);
  margin-bottom: 2.2rem;
}

.intro h1 {
  font-family: var(--display);
  font-weight: 380;
  font-size: clamp(3rem, 2rem + 5vw, 5.4rem);
  line-height: 1.02;
  letter-spacing: -0.015em;
  margin-bottom: 1.8rem;
}

.intro h1 em {
  font-style: italic;
  color: var(--red);
}

.intro-lede {
  font-size: 1.3rem;
  line-height: 1.5;
  color: var(--ink);
  max-width: 56ch;
  margin-bottom: 2.4rem;
}

.proves {
  list-style: none;
  border-top: 1px solid var(--line);
  margin-bottom: 2.6rem;
}

.proves li {
  display: flex;
  gap: 1.1rem;
  align-items: baseline;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line-faint);
  font-size: 1.06rem;
}

.proves .num {
  font-family: var(--display);
  font-style: italic;
  color: var(--red);
  min-width: 1.6rem;
  text-align: right;
}

.begin {
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  padding: 1rem 1.6rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), gap var(--dur) var(--ease);
}

.begin:hover, .begin:focus-visible { background: var(--red); border-color: var(--red); gap: 1.4rem; }
.begin:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

.intro-note {
  font-size: 0.62rem;
  color: var(--ink-soft);
  margin-top: 2.2rem;
  letter-spacing: 0.08em;
}

/* ============ Study layout ============ */

.study {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity 600ms var(--ease);
}

.study.arrived { opacity: 1; }

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 2.2rem;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
}

.crumb {
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--ink-soft);
}

.demo-tag {
  font-size: 0.6rem;
  color: var(--red);
  border: 1px solid currentColor;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
}

.columns {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(380px, 44%) 1fr;
  gap: 0;
  align-items: stretch;
}

/* ---- Text column ---- */

.text-col {
  padding: 2.4rem 2.6rem 3rem 2.2rem;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper-deep) 130%);
}

.poem-title {
  font-family: var(--display);
  font-weight: 420;
  font-size: 2.1rem;
  line-height: 1.1;
}

.poem-sub {
  font-style: italic;
  color: var(--ink-soft);
  margin: 0.35rem 0 1.8rem;
}

.latin { font-feature-settings: "locl" 0; }

.latin p {
  position: relative;
  padding-left: 2rem;
  font-size: 1.08rem;
  line-height: 1.7;
}

.latin .ln {
  position: absolute;
  left: 0;
  top: 0.55em;
  font-size: 0.6rem;
  color: var(--ink-soft);
  opacity: 0.7;
  width: 1.1rem;
  text-align: right;
}

.rule {
  border: none;
  border-top: 1px solid var(--line);
  margin: 1.6rem 0;
}

.translation p {
  font-style: italic;
  font-size: 1.14rem;
  line-height: 1.75;
  color: var(--ink);
}

.translation p::first-letter {
  font-family: var(--display);
  font-style: normal;
  font-size: 3.2em;
  float: left;
  line-height: 0.82;
  padding-right: 0.12em;
  color: var(--red);
}

/* ---- Poet portrait ---- */

.poet {
  float: right;
  width: 118px;
  margin: 0.2rem 0 0.7rem 1.2rem;
  text-align: center;
}

.poet img {
  width: 118px;
  height: 118px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
  filter: sepia(0.22) contrast(0.95);
  mix-blend-mode: multiply;
}

.poet figcaption {
  font-size: 0.74rem;
  font-style: italic;
  color: var(--ink-soft);
  line-height: 1.4;
  margin-top: 0.45rem;
}

/* Referenced phrases */

.ref {
  border-radius: 2px;
  transition: background 500ms var(--ease), border-color 200ms;
}

.ref.askable {
  cursor: pointer;
  border-bottom: 1px dotted rgba(33, 29, 23, 0.4);
}

.ref.askable:hover {
  border-bottom-color: var(--red);
  color: var(--red);
}

.ask-hint {
  font-family: var(--mono);
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  margin-top: 1rem;
}

.ref.lit {
  background: linear-gradient(100deg, transparent 0%, var(--lit-bg) 12%, var(--lit-bg) 100%);
  animation: sweep 900ms var(--ease);
}

.ref.lit-past {
  background: none;
  border-bottom: 2px solid var(--lit-past);
}

@keyframes sweep {
  from { background-size: 0% 100%; }
  to { background-size: 100% 100%; }
}

/* ---- Marginalia ---- */

.marginalia {
  margin-top: 2.4rem;
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.55);
  padding: 1.3rem 1.5rem 1.4rem;
}

.marginalia .col-label { margin-bottom: 1rem; }

.threads { list-style: none; }

.threads li {
  display: flex;
  gap: 0.9rem;
  align-items: baseline;
  padding: 0.55rem 0;
  font-size: 1.02rem;
  line-height: 1.45;
  border-bottom: 1px solid var(--line-faint);
  opacity: 0;
  transform: translateY(6px);
  animation: thread-in 700ms var(--ease) forwards;
}

.threads li:last-child { border-bottom: none; }

.threads .num {
  font-family: var(--display);
  font-style: italic;
  color: var(--red);
  min-width: 1.5rem;
  text-align: right;
}

@keyframes thread-in {
  to { opacity: 1; transform: translateY(0); }
}

/* ---- The Guide's notebook ---- */

.notebook {
  margin-top: 1.1rem;
  border: 1px dashed var(--line);
  background: rgba(147, 49, 31, 0.035);
  padding: 1.3rem 1.5rem 1.1rem;
}

.nb-label { color: var(--red); border-bottom-color: rgba(147, 49, 31, 0.3); }

.nb-list { list-style: none; }

.nb-list li {
  display: flex;
  gap: 0.8rem;
  align-items: baseline;
  padding: 0.5rem 0;
  font-size: 1.0rem;
  font-style: italic;
  line-height: 1.45;
  border-bottom: 1px solid var(--line-faint);
  cursor: pointer;
  opacity: 0;
  transform: translateY(6px);
  animation: thread-in 700ms var(--ease) forwards;
}

.nb-list li::before {
  content: "\203B";  /* reference mark */
  font-style: normal;
  color: var(--red);
  font-size: 0.85rem;
}

.nb-list li:last-child { border-bottom: none; }

.nb-list li:hover span { text-decoration: underline dotted; text-underline-offset: 3px; }

.nb-list li.disputed span {
  text-decoration: line-through;
  opacity: 0.5;
}

.nb-foot {
  font-family: var(--mono);
  font-size: 0.56rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  margin-top: 0.8rem;
  line-height: 1.6;
}

/* ---- Dialogue column ---- */

.dialogue-col {
  display: flex;
  flex-direction: column;
  padding: 2.4rem 2.4rem 1.6rem;
  max-height: calc(100vh - 60px);
}

.stream {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.6rem;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.msg { margin-bottom: 1.9rem; max-width: 62ch; }

.msg .who {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.6rem;
  color: var(--ink-soft);
  margin-bottom: 0.55rem;
}

.msg.guide .who::before {
  content: "\2042";  /* asterism */
  color: var(--red);
  font-size: 0.9rem;
  letter-spacing: 0;
}

.msg.guide p {
  font-size: 1.17rem;
  line-height: 1.6;
}

.msg.guide p + p { margin-top: 0.8rem; }

.msg.guide .q {
  font-family: var(--display);
  font-style: italic;
  font-weight: 420;
  font-size: 1.3rem;
  line-height: 1.45;
  color: var(--ink);
}

.msg.learner {
  margin-left: auto;
  text-align: right;
}

.msg.learner .who { justify-content: flex-end; }

.msg.learner p {
  display: inline-block;
  text-align: left;
  font-style: italic;
  font-size: 1.1rem;
  color: var(--red);
  border-right: 2px solid var(--red);
  padding-right: 0.9rem;
}

/* ---- Exhibits (plates) ---- */

.exhibit {
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.6);
  padding: 0.9rem 1.1rem 1rem;
  margin: 1.3rem 0 0.5rem;
  animation: thread-in 700ms var(--ease) both;
}

.exhibit svg {
  display: block;
  width: 100%;
  height: auto;
  margin: 0.6rem 0 0.2rem;
}

.ex-head {
  font-family: var(--mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--red);
}

.exhibit figcaption {
  font-size: 0.98rem;
  font-style: italic;
  line-height: 1.5;
  color: var(--ink-soft);
  border-top: 1px solid var(--line-faint);
  padding-top: 0.6rem;
  margin-top: 0.5rem;
}

.svg-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  fill: var(--ink-soft);
}

.svg-label.red { fill: var(--red); }

.svg-serif {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  fill: var(--ink);
}

.svg-sea {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.42em;
  fill: rgba(33, 29, 23, 0.5);
}

/* ---- The metre, played ---- */

.scan { padding: 0.5rem 0 0.2rem; }

.scan-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 0.2rem;
}

.syl {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.15rem 0.34rem;
  transition: transform 180ms var(--ease);
}

.syl.sep { border-left: 1px solid var(--line-faint); }

.syl .mark {
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1;
  color: var(--ink-soft);
  transition: color 160ms;
}

.syl .txt {
  font-size: 1.12rem;
  line-height: 1.25;
}

.syl.on { transform: translateY(-4px); }
.syl.on .mark { color: var(--red); }
.syl.on .txt { color: var(--red); }
.syl.done .mark { color: var(--red); opacity: 0.75; }

.syl.in-chor { background: rgba(200, 162, 75, 0.14); }

.chor-note {
  font-family: var(--mono);
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--red);
  margin: 0.1rem 0 0.7rem 4.4rem;
}

.play-metre {
  font-family: var(--mono);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  transition: background var(--dur), color var(--dur);
}

.play-metre:hover, .play-metre:focus-visible {
  background: var(--ink);
  color: var(--paper);
}

/* typing indicator */

.typing {
  display: inline-flex;
  gap: 0.35rem;
  padding: 0.4rem 0;
}

.typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-soft);
  animation: blink 1.1s infinite;
}

.typing i:nth-child(2) { animation-delay: 0.18s; }
.typing i:nth-child(3) { animation-delay: 0.36s; }

@keyframes blink {
  0%, 70%, 100% { opacity: 0.25; }
  35% { opacity: 1; }
}

/* word-by-word reveal */

.w { opacity: 0; animation: w-in 300ms var(--ease) forwards; }
@keyframes w-in { to { opacity: 1; } }

/* ---- Composer ---- */

.composer {
  border-top: 1px solid var(--line);
  padding-top: 1.1rem;
  margin-top: 0.4rem;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
  min-height: 0;
}

.chip {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.02rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  padding: 0.55rem 1rem;
  cursor: pointer;
  text-align: left;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease), opacity 400ms;
  opacity: 0;
  animation: thread-in 500ms var(--ease) forwards;
}

.chip:nth-child(2) { animation-delay: 90ms; }
.chip:nth-child(3) { animation-delay: 180ms; }

.chip:hover, .chip:focus-visible {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.chip:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* next-step cards at the end */

.next-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7rem;
  width: 100%;
}

.next-card {
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.5);
  padding: 0.9rem 1rem;
  cursor: pointer;
  font-family: var(--serif);
  text-align: left;
  transition: border-color var(--dur), transform var(--dur) var(--ease);
  opacity: 0;
  animation: thread-in 500ms var(--ease) forwards;
}

.next-card:nth-child(2) { animation-delay: 100ms; }
.next-card:nth-child(3) { animation-delay: 200ms; }

.next-card:hover { border-color: var(--red); transform: translateY(-2px); }

.next-card .kind {
  font-family: var(--mono);
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--red);
  display: block;
  margin-bottom: 0.4rem;
}

.next-card .title {
  font-size: 1.02rem;
  line-height: 1.35;
  display: block;
}

.freeform {
  display: flex;
  gap: 0.6rem;
}

.freeform input {
  flex: 1;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 0.5rem 0.1rem;
}

.freeform input:focus {
  outline: none;
  border-bottom-color: var(--red);
}

.freeform input::placeholder { color: var(--ink-soft); opacity: 0.8; }

.freeform button {
  font-size: 1.2rem;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  width: 2.6rem;
  cursor: pointer;
  transition: background var(--dur), color var(--dur);
}

.freeform button:hover, .freeform button:focus-visible {
  background: var(--ink);
  color: var(--paper);
}

/* ---- Colophon ---- */

.colophon {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 2.2rem;
  border-top: 1px solid var(--line);
  font-size: 0.58rem;
  color: var(--ink-soft);
  letter-spacing: 0.1em;
}

/* ---- Toast ---- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 2.2rem;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  padding: 0.8rem 1.2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 400ms var(--ease), transform 400ms var(--ease);
  max-width: 80vw;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============ Responsive ============ */

@media (max-width: 980px) {
  .columns { grid-template-columns: 1fr; }
  .text-col { border-right: none; border-bottom: 1px solid var(--line); }
  .dialogue-col { max-height: none; }
  .stream { max-height: 60vh; }
  .next-cards { grid-template-columns: 1fr; }
  .masthead { flex-wrap: wrap; }
}

/* ============ Reduced motion ============ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}
