/* Learning pages: /spanish-dialogues (chat bubbles) and /spanish-false-friends (flip cards + quiz).
   Built by scripts/site/build_talk_pages.py; behavior in dialogues.js and false-friends.js.
   Uses only site.css tokens, so dark mode follows automatically. */

:root { --me-bg: var(--slate); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --me-bg: #3A4F5E; } }
:root[data-theme="dark"] { --me-bg: #3A4F5E; }

/* ---------- shared: round play button ---------- */
.say { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--rule); background: var(--paper); color: var(--ink); display: inline-grid; place-items: center; cursor: pointer; padding: 0; }
.say:hover { border-color: var(--ink); }
.say .i-pause { display: none; }
.say.playing { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.say.playing .i-play { display: none; }
.say.playing .i-pause { display: block; }
.say-sm { width: 44px; height: 44px; }
.say-sm svg { width: 15px; height: 15px; }
.more-row { color: var(--ink-soft); margin: 8px 0 0; line-height: 2.2; }
.more-row a { white-space: nowrap; }
.keep-going h2 { margin-bottom: 22px; }

/* =====================================================================================
   Dialogues
   ===================================================================================== */
.dlg-pick-section { padding: 36px 0 8px; }
.dlg-pick { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.dlg-pick a { display: block; text-decoration: none; color: var(--ink); border-radius: 14px; }
.dlg-pick img { aspect-ratio: 3 / 2; object-fit: cover; width: 100%; border-radius: 12px; margin-bottom: 8px; }
.dlg-pick .pk-t { display: block; font: 700 16px/1.2 var(--display); }
.dlg-pick .pk-s { display: block; font-size: 13.5px; color: var(--muted); line-height: 1.3; }
.dlg-pick a:hover .pk-t { text-decoration: underline; }

.dlg-list { padding: 32px 0 40px; }
.dlg { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 44px; align-items: start; padding: 48px 0; border-top: 1px solid var(--rule); scroll-margin-top: 12px; }
.dlg:first-of-type { border-top: 0; }
.dlg-side { position: sticky; top: 20px; }
.dlg-pic { width: 100%; aspect-ratio: 2 / 1; object-fit: cover; border-radius: 16px; margin-bottom: 18px; }
.dlg h2 { font-size: clamp(26px, 3.2vw, 34px); margin-bottom: 10px; }
.dlg .setup { font-size: 18px; color: var(--ink-soft); margin: 0 0 10px; }
.dlg .from { font-size: 14.5px; color: var(--muted); margin: 0 0 20px; }
.dlg-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.dlg-controls[hidden] { display: none; }
.dlg-controls .btn-ink, .dlg-controls .btn-line { min-height: 48px; }
.dlg-controls [aria-pressed="true"].btn-line { background: var(--ink); color: var(--paper); }
.tgls { display: inline-flex; gap: 6px; }
.tgl { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--rule); background: transparent; color: var(--muted); font: 600 14.5px/1 var(--ui); cursor: pointer; }
.tgl[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); background: var(--tint); }
.tgl[aria-pressed="true"]::before { content: "✓ "; }
.dlg-status { flex-basis: 100%; margin: 2px 0 0; min-height: 1.5em; font-weight: 600; color: var(--ink); }

/* the chat */
.chat { list-style: none; margin: 0; padding: 22px 18px; display: flex; flex-direction: column; gap: 14px; background: var(--paper-2); border: 1px solid var(--rule); border-radius: 22px; }
.msg { max-width: 88%; display: flex; flex-direction: column; }
.msg.them { align-self: flex-start; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg .who { font: 600 12.5px/1 var(--ui); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 0 6px 6px; }
.msg .who.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }
.chat .msg.cont { margin-top: -8px; }
.bubble { display: flex; gap: 8px; align-items: flex-start; }
.msg.me .bubble { flex-direction: row-reverse; }
.bubble .say { margin-top: 4px; }
.line { text-align: left; font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--rule); border-radius: 20px 20px 20px 6px; padding: 11px 16px 12px; cursor: pointer; min-height: 48px; display: flex; flex-direction: column; gap: 4px; box-shadow: 0 6px 16px -14px rgba(30,42,51,.5); }
.msg.me .line { background: var(--me-bg); color: var(--on-slate); border-color: transparent; border-radius: 20px 20px 6px 20px; }
.line .es { font: 400 19px/1.45 var(--story); }
.line .en { font-size: 15px; line-height: 1.4; color: var(--muted); }
.msg.me .line .en { color: var(--on-slate-muted); }
.msg.now .line { outline: 3px solid var(--marker); outline-offset: 2px; }
.msg.turn .line { outline: 3px dashed var(--marker); outline-offset: 2px; }
.turn-tag { display: none; font: 700 12px/1 var(--ui); letter-spacing: .06em; text-transform: uppercase; color: var(--ink); background: var(--marker); color: #1E2A33; border-radius: 6px; padding: 5px 8px; margin: 0 6px 6px; }
.msg.turn .turn-tag { display: inline-block; }
.turn-bar { display: none; height: 4px; border-radius: 2px; background: var(--marker); margin: 6px 6px 0; width: 0; }
.msg.turn .turn-bar { display: block; }
@media (prefers-reduced-motion: no-preference) {
  .msg.turn .turn-bar { animation: turnbar var(--turn, 3s) linear forwards; }
}
@media (prefers-reduced-motion: reduce) { .msg.turn .turn-bar { width: 100%; } }
@keyframes turnbar { from { width: 0; } to { width: calc(100% - 12px); } }

/* narration between lines */
.note { align-self: center; max-width: 92%; display: flex; gap: 10px; align-items: center; color: var(--muted); padding: 2px 0; }
.note p { margin: 0; font-size: 14.5px; line-height: 1.45; text-align: left; }
.note .es { font-family: var(--story); font-style: italic; color: var(--ink-soft); }
.note .en { display: block; }
.note.now .es { color: var(--ink); text-decoration: underline 2px; text-decoration-color: var(--marker); text-underline-offset: 4px; }

/* with JS: English hidden until asked for; Spanish can be covered */
.dlg.js .line .en { display: none; }
.dlg.js.show-en .line .en, .dlg.js .msg.open .line .en { display: block; }
.dlg.js.hide-es .msg:not(.open):not(.check) .line .es { color: transparent; background: var(--tint); border-radius: 6px; user-select: none; }
.dlg.js.hide-es .msg.me:not(.open):not(.check) .line .es { background: rgba(255,255,255,.14); }
.dlg.js.hide-es .line .en { display: block; }
.dlg.js .msg.turn .line .es { color: transparent; background: var(--tint); border-radius: 6px; }
.dlg.js .msg.me.turn .line .es { background: rgba(255,255,255,.14); }
.dlg.js .msg.turn .line .en { display: block; }

/* phrases to keep */
.phrases-box { margin: 26px 0 0; }
.phrases-box h3 { margin-bottom: 4px; }
.phrases-box > p { margin: 0 0 10px; font-size: 15px; }
.phrases-box > p[hidden] { display: none; }
.phrases { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.chip { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; min-height: 48px; padding: 8px 14px; border-radius: 14px; border: 1.5px solid var(--rule); background: var(--card); color: var(--ink); cursor: pointer; font: inherit; }
.chip .es { font: 600 16.5px/1.25 var(--story); }
.chip .en { font-size: 13.5px; color: var(--muted); line-height: 1.3; }
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed="true"] { border-color: var(--marker); }
.chip[aria-pressed="true"] .es { background: linear-gradient(transparent 38%, var(--marker) 38%, var(--marker) 92%, transparent 92%); color: var(--ink); }
.chip[aria-pressed="true"]::after { content: "Kept"; font: 600 11px/1 var(--ui); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.dlg details.reveal { margin-top: 22px; }
.kept-box { background: var(--card); border: 1px solid var(--rule); border-left: 4px solid var(--marker); border-radius: 14px; padding: 20px 22px; margin: 32px 0 8px; }
.kept-box[hidden] { display: none; }
.kept-box h3 { margin: 0 0 4px; }
.kept-box > p { margin: 10px 0 0; }
.kept-list li { display: inline-flex; flex-direction: column; padding: 6px 12px; border-radius: 12px; background: var(--paper-2); }
.kept-list .es { font: 600 16px/1.3 var(--story); color: var(--ink); }
.kept-list .en { font-size: 13.5px; color: var(--muted); }

@media (max-width: 980px) {
  .dlg-pick { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 880px) {
  .dlg { grid-template-columns: 1fr; gap: 22px; padding: 40px 0; }
  .dlg-side { position: static; }
}
@media (max-width: 600px) {
  .dlg-pick { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .dlg-pick img { aspect-ratio: 2 / 1; }
  .chat { padding: 16px 10px; margin: 0 -6px; border-radius: 18px; }
  .msg { max-width: 94%; }
  .line .es { font-size: 17.5px; }
  .dlg-controls .btn-ink, .dlg-controls .btn-line { flex: 1 1 100%; }
}

/* =====================================================================================
   False friends
   ===================================================================================== */
.ff-open { padding-bottom: 64px; }
.ff-open-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 44px; align-items: start; }
.ff-open-pic { margin: 0; position: sticky; top: 20px; }
.ff-open-pic img { width: 100%; aspect-ratio: 2 / 1; object-fit: cover; border-radius: 18px; }
.ff-open-pic figcaption { font-size: 14px; color: var(--muted); margin-top: 8px; }
.ff-open h2 { font-size: clamp(28px, 3.6vw, 38px); }
.frames { list-style: none; margin: 18px 0 18px; padding: 0; counter-reset: fr; display: grid; gap: 12px; }
.frames li { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border: 1px solid var(--rule); border-radius: 14px; padding: 12px 14px; }
.frames p { margin: 0; }
.frames .es, .ff-ex .es { display: block; font: 400 19px/1.45 var(--story); color: var(--ink); }
.frames .en, .ff-ex .en { display: block; font-size: 15px; color: var(--muted); line-height: 1.4; margin-top: 2px; }

.ff-bar { display: flex; flex-wrap: wrap; gap: 12px 28px; align-items: center; justify-content: space-between; margin: 0 0 22px; }
.ff-intro { margin: 0; color: var(--ink-soft); max-width: 36em; }
.ff-tools { display: flex; gap: 14px; align-items: center; }
.ff-tools[hidden] { display: none; }
.ff-count { margin: 0; font-weight: 600; color: var(--ink); }

.ff-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.ff { perspective: 1400px; scroll-margin-top: 16px; }
.ff-inner { display: grid; height: 100%; }
.ff-front, .ff-back { grid-area: 1 / 1; border-radius: 18px; border: 1px solid var(--rule); min-height: 230px; }
.ff-front { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; text-align: left; gap: 6px; padding: 20px 20px 18px; background: var(--card); color: var(--ink); cursor: pointer; font: inherit; box-shadow: 0 16px 30px -26px rgba(30,42,51,.6); background-image: repeating-linear-gradient(to bottom, transparent 0 31px, var(--tint) 31px 32px); background-position: 0 58px; }
.ff-front:hover { border-color: var(--ink); }
.ff-n { font: 600 12px/1 var(--ui); letter-spacing: .08em; color: var(--muted); }
.ff-word { font: 700 clamp(28px, 3vw, 34px)/1.1 var(--display); letter-spacing: -0.01em; margin-top: 10px; word-break: break-word; }
.ff-looks { font-size: 16px; color: var(--ink-soft); }
.ff-looks i { font-family: var(--story); font-size: 18px; color: var(--ink); text-decoration: line-through 2px; text-decoration-color: var(--marker); }
.ff-tap { margin-top: auto; padding-top: 16px; font-size: 14px; font-weight: 600; color: var(--muted); }
.ff-tap::after { content: " ↻"; }
.ff-back { background: var(--paper-2); padding: 18px 20px 10px; display: flex; flex-direction: column; gap: 8px; }
.ff-back p { margin: 0; }
.ff-word-sm { font: 700 15px/1 var(--display); color: var(--muted); letter-spacing: .02em; }
.ff-means { font-size: 15px; }
.ff-means strong { display: block; font: 700 23px/1.2 var(--display); color: var(--ink); margin-top: 2px; }
.ff-want { font-size: 15.5px; color: var(--ink-soft); }
.ff-want b { color: var(--ink); font-family: var(--story); font-size: 17px; }
.ff-ex { display: flex; gap: 10px; align-items: flex-start; border-top: 1px solid var(--rule); padding-top: 10px; margin-top: 2px; }
.ff-ex .es { font-size: 17px; }
.ff-ex .en { font-size: 14px; }
.ff-ex .src { display: block; font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.ff-again { align-self: flex-start; margin-top: auto; padding-left: 0; font-size: 15px; }

/* without JS: both faces show, stacked */
.ff-grid:not(.ff-js) .ff-inner { display: flex; flex-direction: column; }
.ff-grid:not(.ff-js) .ff-front { min-height: 0; border-radius: 18px 18px 0 0; cursor: default; }
.ff-grid:not(.ff-js) .ff-back { min-height: 0; border-radius: 0 0 18px 18px; border-top: 0; }
.ff-grid:not(.ff-js) .ff-tap, .ff-grid:not(.ff-js) .ff-again { display: none; }

/* with JS: the flip */
.ff-js .ff-front, .ff-js .ff-back { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.ff-js .ff-inner { transform-style: preserve-3d; }
.ff-js .ff-back { transform: rotateY(180deg); }
.ff-js .ff.flipped .ff-inner { transform: rotateY(180deg); }
.ff-js .ff.flipped .ff-front { pointer-events: none; }
.ff-js .ff:not(.flipped) .ff-back { pointer-events: none; }
@media (prefers-reduced-motion: no-preference) {
  .ff-js .ff-inner { transition: transform .5s cubic-bezier(.2,.7,.2,1); }
}
@media (prefers-reduced-motion: reduce) {
  .ff-js .ff-inner, .ff-js .ff.flipped .ff-inner, .ff-js .ff-back { transform: none; }
  .ff-js .ff-front, .ff-js .ff-back { backface-visibility: visible; -webkit-backface-visibility: visible; }
  .ff-js .ff.flipped .ff-front { visibility: hidden; }
  .ff-js .ff:not(.flipped) .ff-back { visibility: hidden; }
}
.ff.hl .ff-front, .ff.hl .ff-back { outline: 3px solid var(--marker); outline-offset: 3px; }

/* quiz */
.quiz { background: var(--card); border: 1px solid var(--rule); border-radius: 22px; padding: 24px 24px 22px; margin-top: 18px; box-shadow: 0 24px 50px -40px rgba(30,42,51,.5); }
.quiz[hidden] { display: none; }
.quiz-top { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin: 0 0 14px; font-size: 14px; color: var(--muted); }
.quiz-dots { display: flex; gap: 5px; flex-wrap: wrap; }
.quiz-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--rule); }
.quiz-dots i.ok { background: var(--ink); }
.quiz-dots i.no { background: transparent; box-shadow: inset 0 0 0 2px var(--ink); }
.quiz-dots i.cur { background: var(--marker); }
.quiz-sent { display: flex; gap: 12px; align-items: flex-start; margin: 0 0 14px; }
.quiz-es { font: 400 21px/1.45 var(--story); color: var(--ink); margin: 0; }
.quiz-q { font: 600 20px/1.35 var(--display); color: var(--ink); margin: 0 0 16px; outline: none; }
.quiz-opts { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.opt { width: 100%; min-height: 54px; text-align: left; padding: 10px 16px; border-radius: 14px; border: 1.5px solid var(--rule); background: var(--paper); color: var(--ink); font: 500 17px/1.3 var(--ui); cursor: pointer; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.opt:hover:not(:disabled) { border-color: var(--ink); }
.opt:disabled { cursor: default; }
.opt.right { border-color: var(--ink); background: var(--tint); font-weight: 700; }
.opt.right::after { content: "✓ Right answer"; font: 600 13px/1 var(--ui); color: var(--ink); }
.opt.wrong { border-style: dashed; color: var(--muted); }
.opt.wrong::after { content: "✗ Your answer"; font: 600 13px/1 var(--ui); color: var(--muted); }
.quiz-fb { margin: 16px 0 0; min-height: 1.5em; color: var(--ink-soft); }
.quiz-fb strong { color: var(--ink); }
.quiz-act { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; align-items: center; }
.quiz-score { font: 700 clamp(30px, 5vw, 44px)/1.1 var(--display); margin: 0 0 8px; outline: none; }
.quiz-miss { padding-left: 1.2em; }
.quiz-miss li { margin: 6px 0; }
.quiz-static { padding-left: 1.3em; }
.quiz-static > li { margin: 0 0 22px; }
.quiz-static .quiz-q { font-size: 18px; margin: 4px 0 6px; }
.quiz-static .quiz-es { font-size: 19px; }
.quiz-static ul { margin: 0; color: var(--ink-soft); }

@media (max-width: 880px) {
  .ff-open-grid { grid-template-columns: 1fr; gap: 24px; }
  .ff-open-pic { position: static; }
}
@media (max-width: 600px) {
  /* phone: small cards two to a row; a flipped card opens across the whole row */
  .ff-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; grid-auto-flow: row dense; }
  .ff-grid:not(.ff-js) { grid-template-columns: 1fr; }
  .ff-js .ff-inner, .ff-js .ff.flipped .ff-inner { display: block; transform: none; transition: none; }
  .ff-js .ff-front, .ff-js .ff-back { backface-visibility: visible; -webkit-backface-visibility: visible; min-height: 0; visibility: visible; }
  .ff-js .ff-front { width: 100%; min-height: 168px; padding: 16px 14px 14px; background-position: 0 50px; }
  .ff-js .ff-back { transform: none; display: none; }
  .ff-js .ff.flipped { grid-column: 1 / -1; }
  .ff-js .ff.flipped .ff-front { display: none; }
  .ff-js .ff.flipped .ff-back { display: flex; }
  .ff-word { font-size: 25px; }
  .ff-looks { font-size: 14.5px; }
  .ff-tap { font-size: 13px; padding-top: 10px; }
  .ff-back { min-height: 0; }
  .quiz { padding: 20px 16px 18px; }
  .quiz-es { font-size: 19px; }
}
@media (max-width: 600px) and (prefers-reduced-motion: no-preference) {
  .ff-js .ff.flipped .ff-back { animation: ffin .28s ease-out; }
}
@keyframes ffin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
