/* Scripts and directions.
   The pixel faces (Press Start 2P, VT323, Bungee) only have Latin glyphs. Chinese, Hindi and Arabic
   get a system face that has them (no font files are shipped for these: Windows, macOS, iOS and
   Android all carry one) and a size bump, because an 8×8 pixel glyph cannot hold a Han character
   or a Devanagari conjunct. Latin-script languages keep the pixel faces (Turkish, Polish, German,
   French, Spanish and Portuguese letters are in them). */
:root[data-script="hans"] { --pixel: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif; --term: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", "Noto Sans CJK SC", sans-serif; --display: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif; }
:root[data-script="deva"] { --pixel: "Nirmala UI", "Kohinoor Devanagari", "Noto Sans Devanagari", "Mangal", sans-serif; --term: "Nirmala UI", "Kohinoor Devanagari", "Noto Sans Devanagari", "Mangal", sans-serif; --display: "Nirmala UI", "Noto Sans Devanagari", sans-serif; }
:root[data-script="arab"] { --pixel: "Segoe UI", "Geeza Pro", "Noto Sans Arabic", "Noto Naskh Arabic", Tahoma, sans-serif; --term: "Segoe UI", "Geeza Pro", "Noto Sans Arabic", "Noto Naskh Arabic", Tahoma, sans-serif; --display: "Segoe UI", "Geeza Pro", "Noto Sans Arabic", sans-serif; }

/* the pixel face's fixed px sizes are tiny for these scripts: scale the UI text a step up */
:root:not([data-script="latn"]) .cart-item b, :root:not([data-script="latn"]) .df-exit, :root:not([data-script="latn"]) .ep-back,
:root:not([data-script="latn"]) .df-end-row button, :root:not([data-script="latn"]) .ep-row button, :root:not([data-script="latn"]) .ag-row button,
:root:not([data-script="latn"]) .settings-row .toggle, :root:not([data-script="latn"]) .settings-done, :root:not([data-script="latn"]) .df-prompt,
:root:not([data-script="latn"]) .df-rule-tag, :root:not([data-script="latn"]) .df-end-kind, :root:not([data-script="latn"]) .ep-kind,
:root:not([data-script="latn"]) .cart-hint, :root:not([data-script="latn"]) .ep-pause-row button, :root:not([data-script="latn"]) .epc-card .badge,
:root:not([data-script="latn"]) .ep-door-label, :root:not([data-script="latn"]) .door-prompt, :root:not([data-script="latn"]) .skip { font-weight: 600; font-size: 15px; }
:root:not([data-script="latn"]) .cart-title, :root:not([data-script="latn"]) .settings-box h2, :root:not([data-script="latn"]) .ag-screen h2 { font-weight: 700; font-size: 20px; }
:root:not([data-script="latn"]) .df-banner { font-weight: 700; }
:root:not([data-script="latn"]) .cart-item small, :root:not([data-script="latn"]) .ag-how, :root:not([data-script="latn"]) .df-goal,
:root:not([data-script="latn"]) .ep-goal, :root:not([data-script="latn"]) .ep-hint, :root:not([data-script="latn"]) .df-rule p { font-size: 16px; line-height: 1.45; }
:root:not([data-script="latn"]) .df-end p, :root:not([data-script="latn"]) .ep-result p, :root:not([data-script="latn"]) .df-premise p { font-size: 20px; line-height: 1.5; }
:root[data-script="deva"] * { line-height: 1.55; }

/* Arabic: the interface reads right to left; the game worlds do not mirror (doors stay where they
   are drawn, canvases and the 3D world are not flipped, arrows of media controls keep pointing right). */
:root[dir="rtl"] .ag .ag-canvas, :root[dir="rtl"] canvas, :root[dir="rtl"] .ep-frame, :root[dir="rtl"] .df-canvas, :root[dir="rtl"] .ep-choice { direction: ltr; }
:root[dir="rtl"] .edge { direction: ltr; }   /* the room arrows turn the camera: left stays left */
:root[dir="rtl"] .df-exit, :root[dir="rtl"] .ep-back { left: auto; right: 12px; }
:root[dir="rtl"] .df-pausebtn, :root[dir="rtl"] .ep-pause { right: auto; left: 12px; }
:root[dir="rtl"] .ag-how { text-align: right; }
:root[dir="rtl"] .cart-item { text-align: right; border-left: 0; border-right: 4px solid var(--c); }
:root[dir="rtl"] .ag-how li::before { content: "◂ "; }
/* numbers, codes, seeds and file names stay left to right inside right-to-left text */
.num, .ag-score, .cart-seed input, .df-end-meta, .ep-found, .hub, #word, .dos-out, .dos-in, .bios, pre.note { unicode-bidi: plaintext; }
:root[dir="rtl"] .dos, :root[dir="rtl"] .bios, :root[dir="rtl"] #word { direction: ltr; }

/* long German / Polish / French words must wrap instead of overflowing a button */
button, .cart-item b, .df-rule-name, .ep-result h2, .df-end h2 { overflow-wrap: anywhere; hyphens: auto; }

/* film subtitles (site/episodes/epNN/subs/<locale>.vtt): above the controls, direction from the text itself */
.ep-subs { position: absolute; left: 50%; bottom: calc(14% + var(--safe-b, 0px)); transform: translateX(-50%); z-index: 7; width: max-content; max-width: min(92%, 760px); padding: 4px 12px 5px; text-align: center; white-space: pre-line;
  font: 600 clamp(15px, 2.3vw, 22px)/1.35 system-ui, "Segoe UI", "Nirmala UI", "Microsoft YaHei", sans-serif; color: #fff; background: rgba(0, 0, 0, .62); border-radius: 3px; text-shadow: 0 1px 2px #000; pointer-events: none; unicode-bidi: plaintext; }
.ep-subs:empty { display: none; }
