/* Styles for topic pages (content/pages/*.html). The classes are documented in docs/AUTHORING.md. */

.page { font-size: 1.05rem; }
.page > :first-child { margin-top: 0; }
.page h2 { font-size: 1.45rem; margin: 34px 0 12px; }
.page h3 { font-size: 1.15rem; margin: 24px 0 8px; }
.page p, .page ul, .page ol { margin: 0 0 14px; }
.page li { margin: 4px 0; }
.page img { max-width: 100%; border-radius: 12px; }
.page code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.page pre { background: var(--surface-2); padding: 12px 14px; border-radius: 12px; overflow: auto; font-size: .85rem; line-height: 1.5; }
.page pre code { background: none; padding: 0; }
.page .lead { font-size: 1.2rem; color: var(--text); }
.page .big { font-size: 1.6rem; font-weight: 800; }
.page mark { background: #ffe58a; color: #1f2135; padding: 0 4px; border-radius: 4px; }
.page .t, .t { color: var(--target); font-weight: 700; }

/* clickable audio */
.say { cursor: pointer; border-radius: 6px; transition: background .12s, box-shadow .12s; }
span.say, b.say, strong.say, em.say, i.say, a.say, mark.say, code.say {
  text-decoration: underline dotted color-mix(in srgb, var(--primary) 55%, transparent); text-underline-offset: 4px;
}
.say:hover { background: var(--primary-soft); box-shadow: 0 0 0 3px var(--primary-soft); }
span.say::after, b.say::after, strong.say::after, em.say::after, i.say::after { content: ' 🔊'; font-size: .7em; opacity: .55; }
p.say::before, li.say::before, td.say::before, div.say::before, h2.say::before, h3.say::before, summary.say::before { content: '🔊 '; font-size: .8em; opacity: .6; }
.say.playing { background: var(--primary-soft); box-shadow: 0 0 0 3px var(--primary-soft); animation: glow 1s ease infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--primary) 25%, transparent); } }
.page .tr { display: block; color: var(--muted); font-size: .85em; font-weight: 400; text-decoration: none; }
.has-tr { cursor: help; }

/* boxes */
.page .note, .page .tip, .page .warn, .warn {
  padding: 14px 18px; border-radius: 14px; margin: 16px 0; border-left: 5px solid;
}
.page .note { background: var(--info-soft); border-color: var(--info); }
.page .tip { background: var(--good-soft); border-color: var(--good); }
.page .warn, .warn { background: var(--warn-soft); border-color: var(--warn); }
.page .note > b:first-child, .page .tip > b:first-child, .page .warn > b:first-child { display: block; margin-bottom: 2px; }
.page .note > :last-child, .page .tip > :last-child, .page .warn > :last-child { margin-bottom: 0; }

/* layout */
.page .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 16px 0; }
.page .card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.page .card > :first-child { margin-top: 0; }
.page .card > :last-child { margin-bottom: 0; }
.page .chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chips > span { padding: 4px 12px; border-radius: 999px; background: var(--primary-soft); font-weight: 700; font-size: .92rem; }

/* sentence pattern */
.page .pattern {
  font-size: 1.5rem; font-weight: 800; text-align: center; padding: 18px; margin: 16px 0; border-radius: 16px;
  background: linear-gradient(135deg, var(--primary-soft), var(--surface)); border: 2px solid var(--primary-soft);
}
.page .slot { display: inline-block; min-width: 3ch; padding: 0 10px; margin: 0 4px; border-radius: 10px; background: var(--surface); color: var(--accent); border: 2px dashed var(--accent); }

/* dialogue bubbles */
.page .dialog { display: flex; flex-direction: column; gap: 12px; margin: 18px 0; padding: 16px; border-radius: 18px; background: var(--surface-2); }
.page .dialog > p { position: relative; max-width: 78%; margin: 0; padding: 10px 16px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); text-decoration: none; }
.page .dialog > p.a { align-self: flex-start; border-bottom-left-radius: 4px; }
.page .dialog > p.b { align-self: flex-end; border-bottom-right-radius: 4px; background: var(--primary-soft); }
.page .dialog > p[data-who]::before { content: attr(data-who); display: block; font-size: .75rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; opacity: 1; }
.page .dialog > p.say::after { content: ' 🔊'; font-size: .7em; opacity: .5; }

/* tables */
.table-wrap { overflow-x: auto; margin: 14px 0; border-radius: 14px; box-shadow: var(--shadow); }
.page table, table.vocab { width: 100%; border-collapse: collapse; background: var(--surface); }
.page > table, .page .card table { border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); margin: 14px 0; }
.page th, table.vocab th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); padding: 10px 14px; }
.page td, table.vocab td { padding: 10px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.page tr:hover td { background: color-mix(in srgb, var(--primary-soft) 40%, transparent); }
table.vocab .c-media { width: 48px; font-size: 1.6rem; text-align: center; }
table.vocab .c-media .img { max-width: 44px; max-height: 44px; }
table.vocab .c-term { font-size: 1.1rem; white-space: nowrap; }
table.vocab .c-note { color: var(--muted); font-size: .9rem; }
table.vocab .c-example .tr { margin-top: 2px; }
table.vocab td .say::after { content: ''; }

/* deck views */
.deck { margin: 14px 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.tile {
  position: relative; display: grid; justify-items: center; align-content: center; gap: 4px; min-height: 120px; padding: 14px 10px;
  border: 2px solid var(--line); border-radius: 16px; background: var(--surface); cursor: pointer; text-align: center;
  transition: transform .1s, border-color .12s, box-shadow .12s;
}
.tile:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.tile .media { font-size: 2.3rem; line-height: 1.1; }
.tile .media.img { max-width: 80px; max-height: 70px; }
.tile b { font-size: 1.1rem; }
.tile small { color: var(--muted); }
.tile.playing { border-color: var(--primary); background: var(--primary-soft); }
.tile.flip .back { display: none; }
.tile.flip.flipped { background: var(--primary-soft); border-color: var(--primary); }
.tile.flip.flipped .front { display: none; }
.tile.flip.flipped .back { display: grid; gap: 4px; animation: pop .2s ease; }
.tile.flip .front { display: grid; gap: 4px; justify-items: center; }
.deck-list { columns: 2 220px; padding-left: 18px; }

/* quiz embedded in a page */
.quiz-embed { margin: 16px 0; }
.quiz-embed .quiz-card { max-width: 520px; }

/* show / hide */
.page details { margin: 12px 0; padding: 10px 16px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.page summary { cursor: pointer; font-weight: 700; color: var(--primary); }
.page details[open] summary { margin-bottom: 8px; }
