/* one red pen — reader styles.
   Slide geometry is in "u": the slide is 1000u × 562.5u (16:9); 60 pt Century Gothic on a 960 pt slide = 62.5u.
   PQ letter styles follow our Word output (pq-office/pq_office.py STYLE). */
@font-face { font-family: "Didact Gothic"; src: url("fonts/DidactGothic-latin.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "PQ Stretch"; src: url("fonts/PQStretch.ttf") format("truetype"); font-display: block; }
@view-transition { navigation: auto; }

:root {
  --book-font: "Century Gothic", "CenturyGothic", "URW Gothic", "Didact Gothic", "Avant Garde", sans-serif;
  --syl2: #ff0000;           /* syllable 2 (the deck's red) */
  --syl2-silent: #f6a5a5;    /* a gray (silent) letter inside a red syllable */
  --gray: #a9a9a9;           /* SL: silent letter */
  --bar: 64px;
  --frame: #eceae4;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--frame); font-family: var(--book-font); color: #000; -webkit-tap-highlight-color: transparent; }
main.orp-page.dark { background: #2a2a2a; }
main.orp-page { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 8px 8px calc(var(--bar) + 8px); }

/* ---- slide stage ---- */
.orp-stage {
  --sw: min(100vw - 16px, (100dvh - var(--bar) - 16px) * 16 / 9);
  --u: calc(var(--sw) / 1000);
  position: relative; width: var(--sw); height: calc(var(--sw) * 0.5625);
  background: #fff; box-shadow: 0 4px 24px rgba(0,0,0,.12); border-radius: calc(6 * var(--u));
  font-size: calc(62.5 * var(--u)); line-height: 1;
}
.orp-stage.dark { background: #000; }
/* the twesl.com pop-up's stylesheet sets body{font-family:system-ui…}; keep the book's own font */
html body .orp-stage { font-family: var(--book-font); }
.orp-panel { position: absolute; left: calc(var(--x) * var(--u)); top: calc(var(--y) * var(--u));
  width: calc(var(--w) * var(--u)); height: calc(var(--h) * var(--u)); border: calc(4.7 * var(--u)) solid var(--border, #000); }
.orp-pics { position: absolute; inset: 0; cursor: pointer; }
.orp-pics img { position: absolute; display: block; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.orp-words { position: absolute; left: 0; right: 0; top: 68%; height: 20%; display: flex; align-items: center; justify-content: center; }
.orp-line { white-space: pre; }                  /* keeps the two spaces between words */
.orp-stage.dark .orp-words { background: #fff; color: #000; }

/* ---- a word: baked PQ form + plain form; "PQ all" shows one or the other ---- */
.orp-wrap { display: inline-block; white-space: nowrap; }
.orp-wrap .pq { display: none; }
html.orp-pq .orp-wrap .pq { display: inline; }
html.orp-pq .orp-wrap .plain { display: none; }

/* PQ clothes (Word: LN bold 113%, SL gray A9A9A9, SW 72%, ER italic + 0.09em, XS 160% stretch,
   XU raised 0.18em (c, s 0.28em), XD lowered 0.32em, CL solid / BL dotted underline) */
.pq .L { position: relative; }
.pq .pq-LN { font-weight: bold; font-size: 1.13em; }
.pq .pq-SL { color: var(--gray); }
.pq .pq-SW { font-size: .72em; }
.pq .pq-ER { font-style: italic; margin-right: .09em; }
.pq .pq-XS { font-family: "PQ Stretch", var(--book-font); margin-right: .05em; }   /* wide letter, strokes kept regular weight */
.pq .pq-XU { top: -.18em; }
.pq .pq-XU.xu-cs { top: -.28em; }
.pq .pq-XD { top: .32em; }
/* group underlines are drawn as one background per group, so dots stay evenly spaced across letters */
.pq .g { background-repeat: repeat-x; background-position: 0 92%; }
.pq .g-CL { background-image: linear-gradient(#111, #111); background-size: 100% .075em; }
.pq .g-BL { background-image: radial-gradient(circle, #111 0 .05em, transparent .06em); background-size: .2em .12em; }
.century { font-family: "Century", "Century Schoolbook", "TeX Gyre Schola", serif; }

/* Syllables: syllable 1 black, syllable 2 red, alternating (works with PQ all on and off) */
html.orp-syl .s2 { color: var(--syl2); }
html.orp-syl .pq .pq-SL.s2 { color: var(--syl2-silent); }

/* ---- cover ---- */
.orp-cover { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(26 * var(--u)); }
.orp-cover .orp-title { margin: 0; font-weight: normal; font-size: calc(110 * var(--u)); }
.orp-cover .orp-cover-pic { position: static; width: calc(560 * var(--u)); }
.orp-cover .orp-cover-pic img { position: static; width: 100%; height: auto; }
.orp-cover .orp-sub { font-size: calc(28 * var(--u)); color: #666; }
.orp-cover .orp-start { font-size: calc(34 * var(--u)); padding: .35em 1.2em; border-radius: 2em; color: #000; text-decoration: none;
  border: calc(4 * var(--u)) solid #fe0000; background: #fff; }
.orp-cover .orp-dots { display: flex; gap: calc(14 * var(--u)); }
.orp-cover .orp-dots a { width: calc(26 * var(--u)); height: calc(26 * var(--u)); border-radius: 50%; display: block; }
.orp-cover .orp-dots a.ring { box-shadow: inset 0 0 0 2px #000; }

/* ---- phone, portrait: number + colour on top, objects below ---- */
@media (max-width: 600px) and (orientation: portrait) {
  main.orp-page { align-items: flex-start; }
  .orp-stage { --u: calc((100vw - 28px) / 471); width: auto; height: auto; background: transparent; box-shadow: none;
    display: flex; flex-wrap: wrap; justify-content: center; gap: calc(22 * var(--u)); padding: calc(10 * var(--u)) 0; }
  .orp-stage.dark { background: #000; padding: calc(16 * var(--u)); border-radius: 10px; }
  .orp-panel { position: relative; left: auto; top: auto; background: #fff; }
  .orp-stage.dark .orp-panel { background: #000; }
  .orp-panel.objects { width: calc(471 * var(--u)); height: calc(var(--h) * var(--u) * .92); }
  .orp-stage.orp-cover { background: #fff; width: calc(100vw - 16px); min-height: 70dvh; flex-direction: column; flex-wrap: nowrap; }
  .orp-cover .orp-cover-pic { width: 80%; }
}

/* ---- bottom bar ---- */
.orp-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid #ddd; box-shadow: 0 -2px 10px rgba(0,0,0,.08);
  font: 14px system-ui, -apple-system, "Segoe UI", sans-serif; }
.orp-nav button, .orp-nav a { font: 600 14px system-ui, sans-serif; min-height: 44px; min-width: 44px; padding: 8px 14px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid #ccc; border-radius: 22px; background: #f7f7f8; color: #1a1a1a; cursor: pointer; text-decoration: none; }
.orp-nav [aria-disabled="true"] { opacity: .35; pointer-events: none; }
.orp-nav button[aria-pressed="true"] { background: #1a1a1a; color: #fff; border-color: #1a1a1a; }
.orp-nav button.orp-syl-btn[aria-pressed="true"] { background: #e00000; border-color: #e00000; }
.orp-nav .orp-tg { display: inline-flex; gap: 6px; margin: 0 auto; }
.orp-nav .orp-pos { color: #555; white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 599px) { .orp-nav .orp-tg { order: -1; flex-basis: 100%; justify-content: center; } .orp-nav .orp-pos { margin-left: auto; } }
.orp-toc { position: fixed; inset: 0; z-index: 1100; background: rgba(0,0,0,.45); overflow: auto; }
.orp-toc ol { margin: 0; max-width: min(460px, 90vw); min-height: 100%; background: #fff; padding: 24px 20px 24px 48px; font: 18px system-ui, sans-serif; }
.orp-toc li { margin: .6em 0; } .orp-toc a { color: #1a1a1a; text-decoration: none; } .orp-toc a.cur { font-weight: 700; }

/* page turn (cross-document view transition) */
html[data-turn="next"]::view-transition-old(root) { animation: orp-out-l .28s ease-in both; }
html[data-turn="next"]::view-transition-new(root) { animation: orp-in-r .28s ease-out both; }
html[data-turn="prev"]::view-transition-old(root) { animation: orp-out-r .28s ease-in both; }
html[data-turn="prev"]::view-transition-new(root) { animation: orp-in-l .28s ease-out both; }
@keyframes orp-out-l { to { transform: translateX(-30%); opacity: 0; } }
@keyframes orp-out-r { to { transform: translateX(30%); opacity: 0; } }
@keyframes orp-in-r { from { transform: translateX(30%); opacity: 0; } }
@keyframes orp-in-l { from { transform: translateX(-30%); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; } }
