/* Yo'l harakati qoidalari: the public site.
   A reference book for the road: cool concrete ground, asphalt masthead with a dashed centre line, one red
   (the clause number plates), and the scene card as the picture of every clause. System fonts only. */

/* ---------- tokens ---------- */

:root {
  color-scheme: light;

  --bg: #eef1ef;
  --surface: #ffffff;
  --tint: #e3e8e5;
  --target-bg: #e9efe6;
  --ink: #121b19;
  --ink-2: #44524f;
  --ink-3: #5a6865;
  --line: #d3dad6;
  --line-strong: #a9b5b0;
  --accent: #c4182c; /* red text and rules on the ground */
  --badge: #c4182c; /* red plate behind white clause numbers */
  --on-badge: #ffffff;
  --asphalt: #172120;
  --on-asphalt: #eef3f1;
  --on-asphalt-2: #b3c1bd;
  --marking: #f2d24b;
  --mark-bg: #ffe27a;
  --ring: #121b19;
  --shadow: 0 1px 2px rgb(18 27 25 / 0.06), 0 8px 24px -12px rgb(18 27 25 / 0.18);
  --flash-bg: #f4eec6; /* permalink flash: a soft highlighter, not the search-mark yellow */
  --stage-dim: transparent; /* laid over the scene picture; dark theme tones the pale map down */

  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-text: "Iowan Old Style", "Charter", "Palatino Linotype", "Book Antiqua", Georgia, "Noto Serif", serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  --head: calc(3.5rem + 6px); /* masthead height: sticky offsets */
  --measure: 68ch;

  /* the scene player takes its colours from the page */
  --qs-fg: var(--ink);
  --qs-bg: var(--surface);
  --qs-accent: var(--ink);
  --qs-on-accent: var(--surface);
  --qs-font: var(--font-ui);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1413;
    --surface: #16201e;
    --tint: #1e2b29;
    --target-bg: #1d2b24;
    --ink: #e9f0ed;
    --ink-2: #aebdb9;
    --ink-3: #91a19d;
    --line: #2a3835;
    --line-strong: #4a5d58;
    --accent: #ff7078;
    --badge: #cf2438;
    --asphalt: #080c0b;
    --mark-bg: #5f5000;
    --ring: #e9f0ed;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px -12px rgb(0 0 0 / 0.6);
    --stage-dim: rgb(6 12 11 / 0.22);
    --flash-bg: #2e3216;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1413;
  --surface: #16201e;
  --tint: #1e2b29;
  --target-bg: #1d2b24;
  --ink: #e9f0ed;
  --ink-2: #aebdb9;
  --ink-3: #91a19d;
  --line: #2a3835;
  --line-strong: #4a5d58;
  --accent: #ff7078;
  --badge: #cf2438;
  --asphalt: #080c0b;
  --mark-bg: #5f5000;
  --ring: #e9f0ed;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px -12px rgb(0 0 0 / 0.6);
  --stage-dim: rgb(6 12 11 / 0.22);
  --flash-bg: #2e3216;
}

/* ---------- base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: var(--line-strong) var(--bg);
  accent-color: var(--accent);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.5 var(--font-ui);
  font-kerning: normal;
  overflow-wrap: break-word;
}

body.nav-open {
  overflow: hidden;
}

::selection {
  background: var(--mark-bg);
  color: var(--ink);
}

a {
  color: inherit;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}

p a,
.source a,
.hint-list a {
  color: var(--accent);
}

h1,
h2,
h3,
p,
ol,
ul {
  margin: 0;
}

button,
input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
  border-radius: 4px;
}

[tabindex="-1"]:focus {
  outline: none; /* script-focus targets (headings, <main>, a clause) are not controls */
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  display: block;
  flex: none;
}

.skip {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 100;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  background: var(--marking);
  color: #121b19;
  font-weight: 600;
  transform: translateY(-200%);
}

.skip:focus {
  transform: none;
  outline: 3px solid #121b19;
  outline-offset: 2px;
}

.noscript {
  margin: 0;
  padding: 1rem;
  background: var(--marking);
  color: #121b19;
  text-align: center;
}

/* ---------- masthead: the road ---------- */

.masthead {
  --ring: var(--marking);
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--asphalt);
  color: var(--on-asphalt);
}

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  min-height: 3.5rem;
  padding: 0 0.5rem;
}

.road {
  height: 6px;
  background:
    linear-gradient(90deg, var(--marking) 22px, transparent 22px) 0 center / 44px 2px repeat-x,
    var(--asphalt);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn:hover {
  background: rgb(255 255 255 / 0.12);
}

.brand {
  display: flex;
  flex-direction: column;
  flex: 1 1 7rem; /* takes what the icon buttons leave, its text wraps instead of pushing a button to a second row */
  min-width: 0;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  line-height: 1.15;
}

.brand-name {
  font-size: 1rem;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.brand-sub {
  display: none;
  margin-top: 0.1rem;
  color: var(--on-asphalt-2);
  font-size: 0.8125rem;
}

.search {
  position: relative;
  display: none;
  align-items: center;
  order: 5;
  flex: 1 1 100%;
  padding: 0 0.25rem 0.6rem;
}

.search-open .search {
  display: flex;
}

.search input {
  flex: 1 1 auto;
  min-width: 0;
  height: 2.5rem;
  padding: 0 2.75rem 0 0.8rem;
  border: 1px solid rgb(255 255 255 / 0.24);
  border-radius: 10px;
  background: rgb(255 255 255 / 0.1);
  color: var(--on-asphalt);
  font-size: 1rem; /* 16px: iOS does not zoom into the field */
}

.search input::placeholder {
  color: var(--on-asphalt-2);
  opacity: 1;
}

.search input:focus {
  border-color: var(--marking);
}

.search input::-webkit-search-cancel-button {
  filter: invert(1);
  opacity: 0.7;
}

.search-go {
  position: absolute;
  top: 0;
  right: 0.25rem;
  width: 2.5rem;
  height: 2.5rem;
}

.search-toggle {
  margin-left: auto;
}

.theme-btn {
  margin-left: 0;
}

@media (min-width: 480px) {
  .brand-sub {
    display: block;
  }
}

@media (min-width: 700px) {
  .brand {
    flex: 0 1 auto;
  }

  .search {
    display: flex;
    order: 0;
    flex: 1 1 16rem;
    max-width: 26rem;
    margin-left: auto;
    padding: 0;
  }

  .search-go {
    right: 0;
  }

  .search-toggle {
    display: none;
  }

  .theme-btn {
    margin-left: 0.25rem;
  }
}

@media (min-width: 900px) {
  .menu-btn {
    display: none;
  }

  .bar {
    padding: 0 1rem 0 0.75rem;
  }
}

/* ---------- shell: rail + main ---------- */

.shell {
  display: block;
}

.rail {
  padding: 0.75rem 0.75rem 3rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.rail-inner {
  max-width: 22rem;
}

.rail-title {
  margin: 1.5rem 0.75rem 0.4rem;
  color: var(--ink-3);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
}

.rail-list {
  padding: 0;
  list-style: none;
}

.rail-top {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.rail-top .rail-home {
  flex: 1 1 auto;
}

.rail-close {
  display: none;
}

.rail-link {
  display: grid;
  grid-template-columns: 2.4rem minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0.25rem;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  color: var(--ink);
  font-size: 0.9375rem;
  line-height: 1.3;
  text-decoration: none;
}

.rail-link-wide {
  grid-template-columns: 4rem minmax(0, 1fr) auto;
}

.rail-home {
  grid-template-columns: minmax(0, 1fr);
  font-weight: 650;
}

.rail-no {
  color: var(--ink-3);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.rail-count {
  min-width: 1.5rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--tint);
  color: var(--ink-2);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.rail-link:hover {
  background: var(--tint);
}

.rail-link[aria-current="page"] {
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  font-weight: 650;
}

.rail-link[aria-current="page"] .rail-no {
  color: var(--accent);
}

.scrim {
  display: none;
}

/* Under 900 px the rail is a drawer. */
@media (max-width: 899.98px) {
  .rail-close {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
  }

  .rail-close:hover {
    background: var(--tint);
  }

  .rail {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 70;
    width: min(88vw, 21rem);
    padding-top: 1rem;
    background: var(--surface);
    border-right: 1px solid var(--line);
    visibility: hidden;
    transform: translateX(-102%);
    transition:
      transform 0.28s var(--ease),
      visibility 0s linear 0.28s;
  }

  .nav-open .rail {
    visibility: visible;
    transform: none;
    transition-delay: 0s;
    box-shadow: var(--shadow);
  }

  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgb(5 10 9 / 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s var(--ease);
  }

  .nav-open .scrim {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (min-width: 900px) {
  .shell {
    display: grid;
    grid-template-columns: 18rem minmax(0, 1fr);
    align-items: start;
  }

  .rail {
    position: sticky;
    top: var(--head);
    height: calc(100vh - var(--head));
    height: calc(100dvh - var(--head));
    border-right: 1px solid var(--line);
  }
}

/* ---------- pages ---------- */

main {
  min-width: 0;
}

.page {
  max-width: 54rem;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3rem) 1rem 5rem;
}

@media (min-width: 640px) {
  .page {
    padding-inline: 2rem;
  }
}

.page-head {
  margin-bottom: 1.5rem;
}

.page-title,
.home-title {
  max-width: 24ch;
  font-size: clamp(1.75rem, 1.2rem + 2.6vw, 2.9rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.08;
  text-wrap: balance;
  scroll-margin-top: calc(var(--head) + 1rem);
}

.home-title {
  max-width: 14ch;
  font-size: clamp(2.35rem, 1.2rem + 5.4vw, 4.6rem);
  letter-spacing: -0.032em;
  line-height: 1;
}

.head-no {
  color: var(--accent);
}

.page-meta {
  margin-top: 0.75rem;
  color: var(--ink-2);
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
}

.lead {
  max-width: 60ch;
  margin-top: 1rem;
  color: var(--ink-2);
  font: 400 1.1875rem/1.6 var(--font-text);
  text-wrap: pretty;
}

.lead + p {
  margin-top: 1.5rem;
}

.road-rule {
  height: 4px;
  margin-top: 1.25rem;
  background: linear-gradient(90deg, var(--line-strong) 20px, transparent 20px) 0 0 / 40px 4px repeat-x;
}

.section-title {
  margin: 3rem 0 0.5rem;
  font-size: 1.375rem;
  font-weight: 750;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.source {
  max-width: 60ch;
  margin-top: 3rem;
  color: var(--ink-3);
  font-size: 0.875rem;
}

.button {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 1.1rem;
  border: 1px solid var(--ink);
  border-radius: 10px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

@media (prefers-reduced-motion: no-preference) {
  .page > .page-head .road-rule,
  .home-head .road-rule {
    animation: draw 0.9s var(--ease) both;
  }

  @keyframes draw {
    from {
      clip-path: inset(0 100% 0 0);
    }

    to {
      clip-path: inset(0 0 0 0);
    }
  }
}

/* ---------- home: contents ---------- */

.home-head {
  margin-bottom: 2rem;
}

.home-featured {
  max-width: 45rem;
  margin-bottom: 1rem;
}

.home-featured-link {
  margin-top: 0.75rem;
  color: var(--ink-2);
  font-size: 0.9375rem;
}

.toc {
  display: grid;
  gap: 0 2.5rem;
  padding: 0;
  list-style: none;
}

@media (min-width: 760px) {
  .toc {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.toc-row {
  display: grid;
  grid-template-columns: 3.4rem minmax(0, 1fr);
  grid-template-areas:
    "no title"
    "no meta";
  column-gap: 0.5rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}

.toc-appendix .toc-row {
  grid-template-columns: 4.6rem minmax(0, 1fr);
}

.toc-no {
  grid-area: no;
  color: var(--accent);
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.toc-no-wide {
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  padding-top: 0.3rem;
}

.toc-title {
  grid-area: title;
  font-weight: 650;
  line-height: 1.3;
}

.toc-meta {
  grid-area: meta;
  margin-top: 0.15rem;
  color: var(--ink-3);
  font-size: 0.875rem;
}

.toc-row:hover .toc-title {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* ---------- chapter: clause index ---------- */

.clause-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.5rem;
}

.clause-chip {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-width: 2.5rem;
  height: 2.5rem;
  padding: 0 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}

.clause-chip:hover {
  border-color: var(--ink);
}

.clause-chip[aria-current] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--surface);
}

.chip-count {
  min-width: 1.35rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--badge);
  color: var(--on-badge);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
}

.chip-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--accent);
}

.clause-chip[aria-current] .chip-dot {
  background: var(--marking);
}

@media (max-width: 639.98px) {
  .clause-nav {
    flex-wrap: nowrap;
    margin-inline: -1rem;
    padding: 0.1rem 1rem 0.5rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scroll-padding-inline: 1rem;
    scrollbar-width: none;
  }

  .clause-chip {
    scroll-snap-align: start;
  }
}

/* ---------- chapter: clauses ---------- */

.clauses {
  margin-top: 0.5rem;
}

.clause {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin-inline: -1rem;
  padding: 1.75rem 1rem 2rem;
  border-radius: 12px;
  scroll-margin-top: calc(var(--head) + 0.75rem);
}

.clause + .clause::before {
  content: "";
  position: absolute;
  top: 0;
  left: 1rem;
  right: 1rem;
  border-top: 1px solid var(--line);
}

.clause-side {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.clause-no {
  font-size: 1.0625rem;
  line-height: 1;
}

.clause-no a,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  padding: 0.38rem 0.6rem;
  border-radius: 8px;
  background: var(--badge);
  color: var(--on-badge);
  font-family: var(--font-ui);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  text-decoration: none;
  white-space: nowrap;
}

.clause-no a:hover {
  filter: brightness(1.1);
}

.copy-link {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
}

.copy-link:hover,
.copy-link.copied {
  background: var(--tint);
  color: var(--ink);
}

@media (hover: hover) {
  .copy-link {
    opacity: 0;
  }

  .clause:hover .copy-link,
  .clause:focus-within .copy-link,
  .copy-link:focus-visible,
  .copy-link.copied {
    opacity: 1;
  }
}

.clause-text {
  min-width: 0;
  font-family: var(--font-text);
  font-size: 1.125rem;
  line-height: 1.62;
}

.clause-lead,
.para,
.item-text {
  max-width: var(--measure);
  text-wrap: pretty;
}

.clause-lead + .parts,
.clause-lead + .para {
  margin-top: 0.85rem;
}

.para {
  margin-top: 0.85rem;
}

.parts {
  padding: 0 0 0 1.25rem;
  list-style: disc;
  list-style: "– ";
}

.parts li {
  padding-left: 0.2rem;
}

.parts li + li {
  margin-top: 0.55rem;
}

.parts li::marker {
  color: var(--ink-3);
}

.parts li > .scenes {
  margin-left: -1.45rem;
}

.clause-scenes {
  margin-top: 0.25rem;
}

.clause.is-target {
  background: var(--target-bg);
}

@media (prefers-reduced-motion: no-preference) {
  .clause.is-target {
    animation: target-flash 2.2s var(--ease);
  }

  @keyframes target-flash {
    from {
      background: var(--flash-bg);
    }

    to {
      background: var(--target-bg);
    }
  }
}

@media (min-width: 600px) {
  .clause {
    grid-template-columns: 4.75rem minmax(0, 1fr);
    column-gap: 1rem;
  }

  .clause-side {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
    margin-bottom: 0;
  }

  .clause-text {
    grid-column: 2;
  }

  .clause-scenes {
    grid-column: 2;
  }
}

/* ---------- scene card ---------- */

.scenes {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
}

.scenes:not(:first-child),
.clause-text > .scenes {
  margin-top: 1.1rem;
}

/* The card is the picture of a clause: an asphalt title strip with the same dashed yellow line as the masthead,
   the stage at the width of the text column (45 rem at most), one row of controls under it. */
.scene {
  --qs-radius: 10px;
  container: scene / inline-size;
  position: relative;
  max-width: 45rem;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.4;
}

.scene-head {
  --ring: var(--marking);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 0.5rem;
  padding: 0.2rem 0.3rem 0 1rem;
  background: var(--asphalt);
  color: var(--on-asphalt);
}

.scene-line {
  flex: 0 0 auto;
  align-self: stretch;
  width: calc(100% + 1.3rem);
  height: 6px;
  margin: 0.2rem -0.3rem 0 -1rem;
  background: linear-gradient(90deg, var(--marking) 18px, transparent 18px) 0 center / 36px 2px repeat-x;
}

.scene-title {
  flex: 1 1 0%;
  min-width: 0;
  padding-block: 0.25rem;
  font-size: 0.9375rem;
  font-weight: 650;
  line-height: 1.3;
  text-wrap: balance;
}

.scene-ord {
  flex: none;
  padding: 0.05rem 0.5rem;
  border: 1px solid rgb(255 255 255 / 0.28);
  border-radius: 999px;
  color: var(--on-asphalt-2);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.scene-time {
  flex: none;
  color: var(--on-asphalt-2);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.scene-tools {
  display: flex;
  flex: none;
  gap: 0.1rem;
}

.tool-btn {
  display: inline-grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.tool-btn:hover {
  background: rgb(255 255 255 / 0.14);
}

.tool-btn[aria-pressed="true"] {
  background: var(--marking);
  color: #121b19;
}

.tool-btn[hidden] {
  display: none;
}

.scene-body {
  position: relative;
}

/* Waiting room of a card whose Player is not mounted: an empty road, as tall as the real thing so the page does not jump. */
.scene-live.is-empty {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  aspect-ratio: 16 / 9;
  padding: 1rem;
  background:
    linear-gradient(90deg, var(--line-strong) 24px, transparent 24px) 0 center / 48px 3px repeat-x,
    var(--tint);
  text-align: center;
}

@supports (width: 1cqw) {
  .scene-live.is-empty {
    aspect-ratio: auto;
    min-height: calc(56.25cqw + 10.4rem); /* stage + caption box + two control rows */
  }

  @container scene (min-width: 36rem) {
    .scene-live.is-empty {
      min-height: calc(56.25cqw + 3.7rem);
    }
  }
}

.scene-live[hidden] {
  display: none; /* picture mode: the empty waiting room must not stay above the picture */
}

.scene-note {
  position: relative;
  margin: 0;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  background: var(--tint);
  color: var(--ink-2);
  font-size: 0.9375rem;
}

.scene-live.is-error .scene-note {
  color: var(--ink);
}

/* The Player's stage: no frame of its own, captions as subtitles on the picture, a dimmer in the dark theme. */
.scene .qs-stage {
  position: relative;
  border: 0;
  border-radius: 0;
}

.scene .qs-svg,
.scene-pic {
  position: relative;
}

.scene .qs-svg::after,
.scene-pic::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--stage-dim);
  pointer-events: none;
}

/* Captions: on a narrow card they stay where the Player puts them, in a box under the picture (it reserves the
   height of the longest caption, so nothing jumps while the scene plays). Only a wide card has room to lay them
   over the picture as subtitle plates. Browsers without container queries keep the box under the picture. */
.scene .qs-captions-box {
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  line-height: 1.4;
}

@container scene (min-width: 36rem) {
  .scene .qs-captions-box {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 0.6rem 0.75rem;
    border: 0;
    background: transparent;
    pointer-events: none;
  }

  .scene .qs-caption {
    width: fit-content;
    max-width: 100%;
    padding: 0.3rem 0.65rem;
    border-radius: 6px;
    background: rgb(8 14 13 / 0.84);
    color: #f1f6f4;
    line-height: 1.35;
  }

  .scene .qs-caption + .qs-caption {
    margin-top: 0.3rem;
  }
}

/* The Player's two control rows become one row when the card is wide: play, restart, steps, scrub, time, speed. */
.scene .qs-controls {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.5rem;
  margin: 0;
  padding: 0.55rem 0.75rem 0.5rem;
}

.scene .qs-row {
  display: contents;
}

.scene .qs-play {
  order: 1;
}

.scene .qs-restart {
  order: 2;
}

.scene .qs-prev {
  order: 3;
}

.scene .qs-next {
  order: 4;
}

.scene .qs-speed {
  order: 5;
}

.scene .qs-scrub {
  order: 6;
  flex: 1 1 8rem;
}

.scene .qs-time {
  order: 7;
  min-width: 0;
}

@container scene (min-width: 36rem) {
  .scene .qs-scrub {
    order: 5;
  }

  .scene .qs-time {
    order: 6;
  }

  .scene .qs-speed {
    order: 7;
    margin-left: 0;
  }
}

/* After its automatic runs a scene rests on the poster frame and offers one big button. */
.scene-replay-layer {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  display: grid;
  place-items: center;
  aspect-ratio: var(--scene-ar, 16 / 9);
  background: rgb(8 14 13 / 0.4);
  pointer-events: none;
}

.scene-replay-layer[hidden] {
  display: none;
}

.scene-replay {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.75rem;
  padding: 0 1.15rem 0 0.95rem;
  border: 0;
  border-radius: 999px;
  background: var(--marking);
  color: #121b19;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
}

.scene-replay:hover {
  filter: brightness(1.06);
}

.scene-replay:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px #121b19,
    0 0 0 5px #fff;
}

.scene-pic > svg {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: var(--scene-ar, 16 / 9);
}

.scene-pic .scene-note {
  margin: 1rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  padding: 0 0.9rem 0 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 0.9375rem;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.chip:hover {
  border-color: var(--ink);
}

/* "N ta sahna": a collapsed list of the clause's scenes with a jump link to each card. */
.scene-list {
  max-width: var(--measure);
  margin-top: 0.85rem;
  font-family: var(--font-ui);
}

.scene-list > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.5rem;
  padding: 0 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.9375rem;
  font-weight: 650;
  list-style: none;
  cursor: pointer;
}

.scene-list > summary::-webkit-details-marker {
  display: none;
}

.scene-list > summary::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--accent);
}

.scene-list > summary:hover,
.scene-list[open] > summary {
  border-color: var(--ink);
}

.scene-list > ol {
  max-height: 18rem;
  margin: 0.6rem 0 0;
  padding: 0.6rem 0.9rem 0.6rem 2.2rem;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 0.9375rem;
  line-height: 1.35;
}

.scene-list li + li {
  margin-top: 0.35rem;
}

.scene-list a {
  color: var(--ink);
  text-decoration-color: var(--line-strong);
}

.scene-list a:hover {
  text-decoration-color: var(--ink);
}

.scene {
  scroll-margin-top: calc(var(--head) + 0.75rem);
}

.result-scenes {
  color: var(--accent);
  font-weight: 600;
}

/* ---------- appendix ---------- */

.appendix-scenes {
  max-width: 45rem;
  margin-bottom: 1rem;
}

.entries {
  margin-top: 0.75rem;
}

.entry {
  max-width: var(--measure);
  margin-bottom: 0.8rem;
  font-family: var(--font-text);
  font-size: 1.0625rem;
  line-height: 1.6;
  text-wrap: pretty;
}

.entry-no {
  color: var(--accent);
  font-family: var(--font-ui);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

/* ---------- previous / next ---------- */

.pager {
  display: grid;
  gap: 0.75rem;
  margin-top: 3.5rem;
}

.pager-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 4.25rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.pager-link:hover {
  border-color: var(--ink);
}

.pager-next {
  justify-content: space-between;
  text-align: right;
}

.pager-text {
  display: grid;
  min-width: 0;
}

.pager-dir {
  color: var(--ink-3);
  font-size: 0.8125rem;
}

.pager-title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-weight: 650;
  line-height: 1.3;
}

.pager-gap {
  display: none;
}

@media (min-width: 640px) {
  .pager {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pager-gap {
    display: block;
  }
}

/* ---------- search results ---------- */

.results {
  padding: 0;
  list-style: none;
}

.result-link {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  padding: 1rem 0.5rem;
  border-bottom: 1px solid var(--line);
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
}

.result-link:hover {
  background: var(--tint);
}

.result-link .badge {
  justify-self: start;
  min-width: 3rem;
}

.badge-quiet {
  background: var(--tint);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  font-size: 0.8125rem;
}

.result-main {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.result-where {
  color: var(--ink-3);
  font-size: 0.875rem;
}

.snippet {
  max-width: var(--measure);
  font-family: var(--font-text);
  font-size: 1.0625rem;
  line-height: 1.55;
}

mark {
  padding: 0 0.12em;
  border-radius: 3px;
  background: var(--mark-bg);
  color: var(--ink);
}

.search-hints {
  max-width: var(--measure);
  color: var(--ink-2);
}

.hint-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0;
  list-style: none;
}

.hint-list a {
  display: inline-block;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  text-decoration: none;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  z-index: 90;
  max-width: calc(100vw - 2rem);
  padding: 0.7rem 1.1rem;
  border-radius: 10px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.9375rem;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 0.75rem);
  transition:
    opacity 0.2s var(--ease),
    transform 0.2s var(--ease);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- motion, print ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .masthead,
  .rail,
  .copy-link,
  .scene-foot,
  .pager,
  .toast {
    display: none !important;
  }

  .shell {
    display: block;
  }

  body {
    background: #fff;
    color: #000;
  }
}
