/* Tale pages: the tale's formula as the page's spine, the clean text beside it, the selected passage in a card at the passage.
   Shared by /tales/N/ and /ru/tales/N/; the page data is in each page (#t: the symbols, #d: Propp's passages).
   The design of PR #3 of the site (24 Nov 2026); source: scripts/propp/schema_page/tale.css, copied by tale_pages.py.
   On a phone (narrow or short screen) the page only shows the tale: no spine, no card. */
:root {
  --paper: #f5f5f1; --ink: #1e2230; --muted: #5b606d; --rule: #d4d3cb; --faint: #e8e7e1;
  --accent: #2c51c9; --wash: #dde4f8;
  --band: #1f2330; --band-ink: #ece4cf; --band-muted: #a8a492; --spine: #e6dcc3; --spine-ink: #1f2330;
  --font: "Geologica", "Segoe UI", system-ui, sans-serif;
  --s1: 13px; --s2: 16px; --s3: 22px; --s4: 28px;
  --gl: max(16px, env(safe-area-inset-left, 0px)); --rw: 72px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --paper: #15181f; --ink: #e8e3d5; --muted: #a2a39b; --rule: #363a46; --faint: #22262f;
  --accent: #93a8ff; --wash: #28325c; --band: #0d0f14; --band-ink: #ece4cf; --band-muted: #9c9887;
  --spine: #d9cfb5; --spine-ink: #1f2330; color-scheme: dark } }
:root[data-theme="dark"] {
  --paper: #15181f; --ink: #e8e3d5; --muted: #a2a39b; --rule: #363a46; --faint: #22262f;
  --accent: #93a8ff; --wash: #28325c; --band: #0d0f14; --band-ink: #ece4cf; --band-muted: #9c9887;
  --spine: #d9cfb5; --spine-ink: #1f2330; color-scheme: dark }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); font-size: var(--s2); line-height: 1.55; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--paper); }
.gut { padding-left: var(--gl); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.inner { max-width: 1240px; margin: 0 auto; }
p { margin: 0; }
h1 { margin: 0; text-wrap: balance; }
a { color: inherit; text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.meta { font-size: var(--s1); color: var(--muted); }
sup, sub { font-size: 0.66em; line-height: 0; }

/* ---------- the cover: the band to the right of the spine ---------- */
.band { background: var(--band); color: var(--band-ink); margin-top: calc(-1 * env(safe-area-inset-top, 0px)); padding: calc(env(safe-area-inset-top, 0px) + 16px) max(16px, env(safe-area-inset-right, 0px)) 20px 20px;
  display: grid; gap: 8px; min-width: 0; }
.topline { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: var(--s1); color: var(--band-muted); }
.topline a, .topline b { color: var(--band-ink); }
h1 { font-size: var(--s4); line-height: 1.15; font-weight: 800; letter-spacing: -0.01em; }
.band .meta { color: var(--band-muted); }
@media (min-width: 721px) { .band { padding-left: 32px; } }

/* ---------- the page: the spine (the tale's formula), the cover band, the text ---------- */
.page { display: grid; grid-template-columns: calc(var(--rw) + env(safe-area-inset-left, 0px)) minmax(0, 1fr); grid-template-rows: auto 1fr auto; min-height: 100vh; }
.page > * { min-width: 0; }
.rail { grid-column: 1; grid-row: 1 / -1; }
.band { grid-column: 2 / -1; grid-row: 1; }
.textcol { grid-column: 2; grid-row: 2; padding-left: 20px; padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.page > footer { grid-column: 2 / -1; grid-row: 3; padding-left: 20px; padding-right: max(16px, env(safe-area-inset-right, 0px)); }
@media (min-width: 1000px) {
  .page { grid-template-columns: calc(var(--rw) + env(safe-area-inset-left, 0px)) minmax(0, calc(64ch + 80px)) 1fr; }
  .textcol { padding-left: 40px; padding-right: 40px; }
  .page > footer { padding-left: 40px; }
}

/* the spine: cream as on the cover, the same in both themes */
.rail { --r-ink: #1f2330; --r-muted: #6d6655; --r-rule: #c9bd9e; --r-accent: #2c51c9; --r-win: #f7f1e2; --r-on: #dde4f8;
  background: var(--spine); color: var(--r-ink); position: sticky; top: 0; align-self: start; height: 100vh; height: 100dvh; }
.rail-in { position: absolute; top: env(safe-area-inset-top, 0px); bottom: 0; left: env(safe-area-inset-left, 0px); right: 0; }
.rail svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.rail svg.over { pointer-events: none; }
.rail .win { fill: var(--r-win); }
.rail .lane { stroke: var(--r-ink); stroke-width: 2; stroke-linecap: round; }
.rail .tick { stroke: var(--r-ink); stroke-width: 1.4; }
.rail .lead { stroke: var(--r-rule); stroke-width: 1; fill: none; }
.rail .dot { fill: var(--spine); stroke: var(--r-ink); stroke-width: 1.4; }
.rail .dot.on { fill: var(--r-accent); stroke: var(--r-accent); }
.rail .dot.mate { stroke: var(--r-accent); stroke-width: 2.4; }
.rail .pa { fill: none; stroke: var(--r-ink); stroke-width: 1.1; opacity: 0.55; }
.rail .pa.on { stroke: var(--r-accent); stroke-width: 2.2; opacity: 1; }
.rail .grp { fill: none; stroke: var(--r-muted); stroke-width: 1; }
.rail .gt { fill: var(--r-muted); font: 11px var(--font); }
.rail .bg { fill: transparent; cursor: pointer; }
.rail :focus-visible { outline-color: var(--r-accent); }
.mvn { position: absolute; transform: translate(-50%, -100%); appearance: none; border: 0; background: none; padding: 0 2px; cursor: pointer;
  font-size: 11px; font-weight: 700; color: var(--r-muted); line-height: 14px; }
.rl { position: absolute; appearance: none; border: 0; background: none; padding: 0; cursor: pointer; text-align: left;
  display: flex; align-items: center; white-space: nowrap; overflow: hidden; border-radius: 2px; color: var(--r-muted); }
.rl .s { font-size: 15px; width: var(--symw); flex: none; padding-left: 4px; overflow: hidden; text-overflow: ellipsis; }
.rl .nm { font-size: var(--s1); overflow: hidden; text-overflow: ellipsis; margin-left: var(--arcw); padding-right: 4px; }
.rl.vis { color: var(--r-ink); }
.rl.vis .s { font-weight: 700; }
.rl.nospan { opacity: 0.5; }
.rl.inv .s::after { content: "⤺"; font-size: 11px; margin-left: 2px; }
.rl:hover, .rl.hov { background: var(--r-win); color: var(--r-ink); }
.rl.on { background: var(--r-on); color: var(--r-ink); box-shadow: inset 0 0 0 2px var(--r-accent); }
.rl.mate { color: var(--r-ink); box-shadow: inset 0 0 0 1.5px var(--r-accent); }

/* ---------- the text ---------- */
.textcol { position: relative; padding-top: 24px; padding-bottom: 40px; display: grid; gap: 18px; align-content: start; }
.tale-text { white-space: pre-wrap; font-size: var(--s2); line-height: 1.8; max-width: 64ch; overflow-wrap: break-word; }
.tale-text .m { cursor: pointer; text-decoration: underline; text-decoration-color: var(--rule); text-decoration-thickness: 1.5px; text-underline-offset: 5px;
  -webkit-box-decoration-break: clone; box-decoration-break: clone; border-radius: 2px; }
.tale-text .m:hover, .tale-text .m.hov { text-decoration-color: var(--muted); }
.tale-text .m.on { background: var(--wash); text-decoration-color: var(--accent); }
.tale-text .m.mate { box-shadow: 0 0 0 1.5px var(--accent); text-decoration-color: var(--accent); }

/* ---------- the passage card, anchored to the passage ---------- */
.pop { position: absolute; z-index: 6; background: var(--paper); border: 1px solid var(--ink); border-top-width: 3px;
  padding: 12px 14px 14px; display: grid; gap: 8px; box-shadow: 0 10px 28px rgb(0 0 0 / 0.16); }
.pop::before { content: ""; position: absolute; left: var(--ax, 24px); width: 12px; height: 12px; background: var(--paper);
  border: solid var(--ink); transform: translateX(-50%) rotate(45deg); }
.pop.below::before { top: -9px; border-width: 3px 0 0 3px; }
.pop.above::before { bottom: -7px; border-width: 0 1px 1px 0; }
.pop > * { min-width: 0; }
.pop .ph { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.pop .ph .s { font-size: var(--s3); font-weight: 800; }
.pop .ph .nm { font-weight: 700; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pop .ph .meta { white-space: nowrap; order: 3; flex-basis: 100%; }
.pop .x { appearance: none; border: 0; background: none; cursor: pointer; color: var(--muted); font-size: var(--s3); line-height: 1; padding: 0 2px; }
.pop .strip { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px; padding: 4px 0 6px; border-bottom: 1px solid var(--rule); }
.pop .strip .tk { appearance: none; border: 0; background: none; padding: 1px 4px; cursor: pointer; font-size: var(--s2); border-radius: 2px; color: var(--muted); }
.pop .strip .tk:hover { background: var(--faint); color: var(--ink); }
.pop .strip .tk.on { background: var(--wash); color: var(--ink); box-shadow: inset 0 0 0 2px var(--accent); font-weight: 700; }
.pop .strip .tk.mate { color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--accent); }
.pop .strip .dots { color: var(--muted); padding: 0 2px; }
.pop .lab { color: var(--muted); font-size: var(--s1); }
.pop .pairline { border-top: 1px solid var(--rule); padding-top: 8px; }
.linkbtn { appearance: none; border: 0; background: none; padding: 0; cursor: pointer; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }

.tnav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; border-top: 1px solid var(--rule); padding-top: 18px; margin-top: 12px; max-width: 64ch; }
.tnav a { text-decoration: none; display: grid; gap: 2px; }
.tnav a:hover b { text-decoration: underline; }
.tnav .nx { text-align: right; }
footer { border-top: 1px solid var(--rule); padding-block: 18px 48px; color: var(--muted); font-size: var(--s1); }
body::before { background: var(--band); }
footer p { max-width: 90ch; }

/* ---------- on a phone: the tale only (Maria, 24 Nov 2026); a link to a passage (#s3) still lights it ---------- */
@media (max-width: 599px), (max-height: 479px) {
  .page { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .band, .textcol, .page > footer { grid-column: 1 / -1; }
  .tale-text .m { text-decoration: none; cursor: auto; }
}
