/* The page's tokens (contract §4.1) and the canvas behind everything; the three screens (§4.3) are the blocks' below, the phone's two at the end (M0-T57). */
:root {
  --ts-bg: #000000;
  --ts-panel: rgba(12, 14, 20, 0.84);
  --ts-line: #2a3140;
  --ts-text: #e8ecf4;
  --ts-muted: #9aa6b8;
  --ts-accent: #ffb454;
  --ts-cool: #8fb8ff;
  --ts-warn: #ff6b6b;
  --ts-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ts-size-s: 13px;
  --ts-size-m: 15px;
  --ts-size-l: 19px;
  --ts-radius: 8px;
  --ts-gap: 8px;
  --ts-panel-w: 320px;
  --ts-touch: 44px;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ts-bg);
}

#ts-canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: var(--ts-bg);
  touch-action: none;   /* M0-T50: a finger on the canvas turns the hole - the browser's own pan and pinch-zoom stay off it */
}

#ts-canvas:focus-visible {
  outline: 2px solid var(--ts-accent);   /* the keys work while the canvas has the focus */
  outline-offset: -2px;
}

/* M0-T51, the panel on a computer (§4.3): the right edge, --ts-panel-w wide, full height, scrolling inside itself; folded, it is the one `panel_open` button. The phone's sheets are the last blocks of this file (M0-T57). */
#ts-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--ts-panel-w);
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  padding: var(--ts-gap);
  /* M0-D33: the panel keeps §4.1's colour, held over the picture: a dark backing under it (no blur: a backdrop filter over a canvas that redraws every frame is a cost on the laptop's card, M0-D33's Adversarial) so the film look's pale disk
     does not average into the fill (it was (48, 49, 50) over the pale disk) and its edge does not show through as a change of tone. The panel's own translucent layer is the first background, the backing the second. */
  background: linear-gradient(var(--ts-panel), var(--ts-panel)), linear-gradient(var(--ts-back), var(--ts-back));
  --ts-back: rgba(0, 0, 0, 0.8);   /* local to the panel, not a §4.1 token */
  color: var(--ts-text);
  font: var(--ts-size-m) var(--ts-font);
  border-left: 1px solid var(--ts-line);
}

#ts-panel[data-folded] {
  bottom: auto;
  width: auto;
  overflow: visible;
  background: none;
  border-left: 0;
}

#ts-panel[data-folded] .ts-sheet,
#ts-panel:not([data-folded]) .ts-open {
  display: none;
}

.ts-sheet-head {
  display: flex;
  justify-content: flex-end;
}

.ts-sec {
  margin-top: calc(var(--ts-gap) * 2);
}

.ts-sec[hidden] {
  display: none;
}

.ts-sec-title {
  margin: 0 0 var(--ts-gap);
  font-size: var(--ts-size-m);
  font-weight: 600;
  color: var(--ts-muted);
}

.ts-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 1fr;   /* M0-D35: every row of a grid is the tallest's height (one label on two lines made its row 48 px against 30 px for the others) - it holds without `text-wrap: balance` below */
  gap: var(--ts-gap);
}

.ts-btn {
  box-sizing: border-box;
  min-height: 28px;
  padding: 4px 6px;   /* M0-D35: 6 px, not 12: « Comme au cinéma » and « Telle que la physique la donne » (129 px on one line of its two, 133 px free here) take two lines at most in the panel's 147 px columns */
  text-wrap: balance;   /* M0-D35: a label that wraps wraps evenly (« As physics gives / it » left « it » alone). Chrome and Edge 114, Firefox 121, Safari 17.5 read it; an older browser keeps the equal rows above and the shorter padding */
  border: 1px solid var(--ts-muted);   /* M0-D33: an unpicked button's edge is seen (3 : 1 against the fill, §4.1's non-text bar); it was --ts-line, 1.0 : 1 against the panel over the film look's pale disk */
  border-radius: var(--ts-radius);
  background: transparent;
  color: var(--ts-text);
  font: var(--ts-size-m) var(--ts-font);
  cursor: pointer;
}

.ts-btn:hover {
  border-color: var(--ts-text);
}

.ts-btn:focus-visible {
  outline: 2px solid var(--ts-accent);
  outline-offset: 2px;
}

.ts-note {
  margin: var(--ts-gap) 0 0;
  font-size: var(--ts-size-m);
  color: var(--ts-muted);
}

.ts-btn.ts-picked {
  border-color: var(--ts-accent);
  color: var(--ts-accent);
}

#ts-panel[data-folded] .ts-open {
  background: var(--ts-panel);
}

/* M0-T52, the sliders (§4.3): a label and its value on a line, the track as wide as the panel allows under it; a locked one (D12) is greyed and shows the word of its lock in place of its value. */
.ts-row {
  margin-top: var(--ts-gap);
}

.ts-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--ts-gap);
}

.ts-label {
  color: var(--ts-text);
}

.ts-value {
  color: var(--ts-muted);
  font-size: var(--ts-size-s);
  text-align: right;
}

.ts-range {
  box-sizing: border-box;
  display: block;
  width: 100%;
  min-height: 28px;
  margin: 0;
  accent-color: var(--ts-accent);
  background: transparent;
  cursor: pointer;
}

.ts-range:focus-visible {
  outline: 2px solid var(--ts-accent);
  outline-offset: 2px;
}

.ts-hint {
  margin: var(--ts-gap) 0 0;
  font-size: var(--ts-size-s);
  color: var(--ts-muted);
}

.ts-locked .ts-label,
.ts-locked .ts-value {
  color: var(--ts-muted);
}

.ts-locked .ts-range {
  opacity: 0.45;
  cursor: not-allowed;
}

/* M0-T53, the picture's controls (§4.3): the « HDR » switch on a line of its own, the bar's value typed in a field beside its label, the bar's two buttons side by side. */
.ts-row[hidden] {
  display: none;
}

.ts-switch .ts-label {
  display: flex;
  align-items: center;
  gap: var(--ts-gap);
  cursor: pointer;
}

.ts-check {
  flex: none;
  width: 28px;
  height: 28px;
  margin: 0;
  accent-color: var(--ts-accent);
  color-scheme: dark;   /* M0-D33: unticked, the native box is drawn dark with its own light rim (it was a solid white square, the brightest thing of the panel); ticked, the accent fills it as before */
  cursor: pointer;
}

.ts-typed {
  box-sizing: border-box;
  width: 8em;
  min-height: 28px;
  padding: 2px 8px;
  border: 1px solid var(--ts-line);
  border-radius: var(--ts-radius);
  background: transparent;
  color: var(--ts-text);
  font: var(--ts-size-s) var(--ts-font);
  text-align: right;
}

.ts-typed:focus-visible {
  outline: 2px solid var(--ts-accent);
  outline-offset: 2px;
}

/* M0-T54, the page's own words (§4.3): top left the title block, bottom left the hint and the place of `real_open` (M0-T55), `loading` centred on black until `ready`. Each box takes no pointer but on its link and its tag: a drag begun on
   the text turns the camera through the canvas under it. The phone's arrangements (the tag's tap, the bar) are the last blocks of this file (M0-T57). */
#ts-title,
#ts-foot {
  position: fixed;
  left: 0;
  box-sizing: border-box;
  max-width: calc(100vw - var(--ts-panel-w) - var(--ts-gap) * 2);
  padding: calc(var(--ts-gap) * 2);
  color: var(--ts-text);
  font: var(--ts-size-m) var(--ts-font);
  text-shadow: 0 0 6px #000, 0 0 2px #000;
  pointer-events: none;
}

#ts-title {
  top: 0;
  max-width: min(26em, calc(100vw - var(--ts-panel-w) - var(--ts-gap) * 2));
  border-radius: 0 0 var(--ts-radius) 0;
  background: var(--ts-panel);   /* M0-D31: the sky behind the block is not always dark (a star or the galaxy's band reads 1.3 : 1 against the title at the worst pixel); the block carries the panel's colour like the hint and the link */
}

#ts-foot {
  bottom: 0;
}

.ts-title-name {
  margin: 0;
  font-size: var(--ts-size-l);
  font-weight: 600;
}

.ts-title-sub {
  margin: 0;
  color: var(--ts-muted);
}

.ts-title-line {
  margin: var(--ts-gap) 0 0;
  font-size: var(--ts-size-s);
  color: var(--ts-muted);
}

.ts-tag {
  box-sizing: border-box;
  min-height: 28px;
  margin: var(--ts-gap) var(--ts-gap) 0 0;
  padding: 2px 10px;
  border: 1px solid var(--ts-accent);
  border-radius: var(--ts-radius);
  background: var(--ts-panel);
  color: var(--ts-accent);
  font: var(--ts-size-s) var(--ts-font);
  text-shadow: none;
  pointer-events: auto;
  cursor: help;
}

.ts-tag:focus-visible,
.ts-link:focus-visible {
  outline: 2px solid var(--ts-accent);
  outline-offset: 2px;
}

.ts-link {
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  min-height: 28px;
  margin-top: var(--ts-gap);
  padding: 2px 10px;
  border-radius: var(--ts-radius);
  background: var(--ts-panel);
  color: var(--ts-cool);
  pointer-events: auto;
}

/* M0-D31: the hint and the home link sit on a backing of their own (the panel's colour, like the tag's), because the opening camera puts the bright disk under both and a shadow does not make 4.5 : 1 on gold (§4.1). */
.ts-hint-line {
  box-sizing: border-box;
  width: fit-content;
  max-width: 100%;
  margin: 0;
  padding: 4px 10px;
  border-radius: var(--ts-radius);
  background: var(--ts-panel);
  font-size: var(--ts-size-s);
  color: var(--ts-muted);
  text-wrap: balance;   /* M0-D35: the hint's two lines are even (« zoomer » was left alone on the second); an older browser than Chrome 114 / Firefox 121 / Safari 17.5 breaks it as before */
}

.ts-hint-line[hidden] {
  display: none;
}

/* M0-T55, the « what is real » panel (§4.3): `real_open` bottom left (under the hint, in the place #ts-real-slot keeps for it), the dialog over the picture, centred, at most 560 px wide and 80 % of the height, scrolling inside itself; a press on the backdrop closes it. */
#ts-real-slot {
  height: calc(28px + var(--ts-gap));
}

.ts-real-open {
  position: fixed;
  left: calc(var(--ts-gap) * 2);
  bottom: calc(var(--ts-gap) * 2);
  z-index: 3;
  background: var(--ts-panel);
}

.ts-real-back {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--ts-gap);
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.5);
}

.ts-real-back[hidden] {
  display: none;
}

.ts-real {
  box-sizing: border-box;
  width: min(560px, 100%);
  max-height: 80vh;
  max-height: 80dvh;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: calc(var(--ts-gap) * 2);
  border: 1px solid var(--ts-line);
  border-radius: var(--ts-radius);
  background: rgba(12, 14, 20, 0.96);
  color: var(--ts-text);
  font: var(--ts-size-m) var(--ts-font);
}

.ts-real:focus-visible {
  outline: 2px solid var(--ts-accent);
  outline-offset: -2px;
}

.ts-real-title {
  margin: 0 0 var(--ts-gap);
  font-size: var(--ts-size-l);
  font-weight: 600;
}

.ts-real-text {
  margin: var(--ts-gap) 0 0;
}

.ts-real-head {
  color: var(--ts-muted);
  font-weight: 600;
}

.ts-real-list {
  margin: var(--ts-gap) 0 0;
  padding-left: 1.2em;
}

.ts-real-line {
  margin-top: 4px;
  font-size: var(--ts-size-s);
}

.ts-real-credit {
  color: var(--ts-muted);
  font-size: var(--ts-size-s);
}

.ts-real-more {
  margin-right: calc(var(--ts-gap) * 2);
}

.ts-real-close {
  margin-top: var(--ts-gap);
}

#ts-loading {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  background: var(--ts-bg);
  color: var(--ts-muted);
  font: var(--ts-size-l) var(--ts-font);
  pointer-events: none;
}

body:not([data-ts-state="loading"]) #ts-loading {
  display: none;
}

/* M0-T56, §4.3 « a message » (main.ts `showMessage`): the three failures sit centred on black over the whole page (never a blank one); `msg_too_slow` is a card over the picture, the page under it still turning. */
#ts-msg {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--ts-gap) * 2);
  box-sizing: border-box;
  background: var(--ts-bg);
}

#ts-msg[data-over="picture"] {
  background: none;
  pointer-events: none;   /* the picture under the card stays the player's */
}

.ts-msg-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--ts-gap) * 2);
  max-width: 480px;
  padding: calc(var(--ts-gap) * 3);
  box-sizing: border-box;
  text-align: center;
  color: var(--ts-text);
  font: var(--ts-size-l) var(--ts-font);
  background: var(--ts-panel);          /* M0-D34, §4.1: every message is a card with --ts-warn for its edge - the three black ones centred on the black, msg_too_slow over the picture (and the card index.html's onerror writes: same classes) */
  border: 1px solid var(--ts-warn);
  border-radius: var(--ts-radius);
}

#ts-msg[data-over="picture"] .ts-msg-card {
  pointer-events: auto;
}

.ts-msg-text {
  margin: 0;
  line-height: 1.4;
}

/* M0-D38 (§4.3 « a message », §0.5 override (xxi)): a black message's `home` link (main.ts `showMessage`, index.html's `onerror` card), the card's last line under the button - the card's own gap above it, `.ts-link`'s
   --ts-cool, --ts-accent focus ring and --ts-touch height by touch; the size of the page's other words, not the sentence's. */
.ts-msg-card .ts-msg-home {
  margin-top: 0;
  font-size: var(--ts-size-s);
}

/* M0-T57, §4.3's two phone screens. « A phone » is the site's own test, `(hover: none) and (pointer: coarse)`; a window 720 px wide or less is taken for one. Both are « compact »: the panel is a sheet (the one `panel_open` button
   folds it - on a phone it starts folded: controls.ts), `real_open` leaves the corner and goes into the sheet's own top line (folded: into the bar), `early_line` is behind the tag's tap (main.ts sets `data-open`). Compact's
   defaults are the phone on its side - a sheet from the right, at most 50 % of the width and --ts-panel-w, folded to a column of the two buttons; the block after it moves the sheet to the bottom for the upright phone and the
   narrow window. The sheet scrolls inside itself, its top line (`real_open`, `panel_close`) stays in view; the page never scrolls. */
@media (max-width: 720px), (hover: none) and (pointer: coarse) {
  #ts-panel {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    column-gap: var(--ts-gap);
    width: min(var(--ts-panel-w), 50vw);
    --ts-pad-l: var(--ts-gap);
    --ts-pad-r: max(var(--ts-gap), env(safe-area-inset-right, 0px));
    --ts-hit: 28px;                                         /* a control's height here: the touch block below makes it --ts-touch */
    --ts-strip: calc(var(--ts-gap) * 2 + var(--ts-hit));    /* the header strip: a gap, the two buttons, a gap */
    --ts-head: rgb(12, 14, 20);                             /* the strip is opaque: the sheet's body is --ts-panel, the strip is what scrolls under nothing */
    padding: 0 var(--ts-pad-r) max(var(--ts-gap), env(safe-area-inset-bottom, 0px)) var(--ts-pad-l);
    overscroll-behavior: contain;
  }

  /* M0-D32: the header row is one opaque strip over the sheet's whole width (its padding included), sticky at the top, over everything that scrolls; it takes no room (its margin takes back its height), `real_open` and `panel_close` stand
     on it, one baseline, with no fill of their own. */
  #ts-panel:not([data-folded])::before {
    content: "";
    order: -3;
    position: sticky;
    top: 0;
    z-index: 3;
    flex: none;
    width: calc(100% + var(--ts-pad-l) + var(--ts-pad-r));
    height: var(--ts-strip);
    margin: 0 calc(var(--ts-pad-r) * -1) calc(var(--ts-strip) * -1) calc(var(--ts-pad-l) * -1);
    background: var(--ts-head);
  }

  #ts-panel[data-folded] {
    top: auto;
    bottom: 0;
    flex-direction: column;
    flex-wrap: nowrap;
    row-gap: var(--ts-gap);   /* M0-D35: the column's two buttons are a gap apart (they touched); the bar's row gap is its column gap above */
    align-content: normal;
    align-items: stretch;
    width: auto;
    padding: var(--ts-gap) max(var(--ts-gap), env(safe-area-inset-right, 0px)) max(var(--ts-gap), env(safe-area-inset-bottom, 0px)) var(--ts-gap);
  }

  .ts-sheet {
    display: contents;
  }

  .ts-real-open {
    position: sticky;
    top: var(--ts-gap);   /* a sticky box stops by its border box: this is the head's own padding-top, so the two buttons share a top */
    z-index: 4;
    left: auto;
    bottom: auto;
    order: -2;
    flex: none;
    align-self: flex-start;
    margin-top: 0;
  }

  #ts-panel[data-folded] .ts-real-open {
    order: 0;
    background: var(--ts-panel);
  }

  #ts-panel[data-folded] .ts-open {
    order: 1;
  }

  .ts-sheet-head {
    order: -1;
    flex: 1 1 0;
    position: sticky;
    top: 0;
    z-index: 4;
    padding-top: var(--ts-gap);
  }

  .ts-sec {
    flex: 0 0 100%;
  }

  #ts-real-slot {
    display: none;
  }

  #ts-title {
    max-width: min(26em, calc(100vw - min(var(--ts-panel-w), 50vw) - var(--ts-gap) * 2));
  }

  #ts-foot {
    max-width: calc(100vw - min(var(--ts-panel-w), 50vw) - var(--ts-gap) * 2);
  }

  .ts-title-line {
    display: none;
  }

  .ts-title-line[data-open] {
    display: block;
  }

  /* M0-D35: the « what is real » dialog is a sheet over the page here; the title block, tag included, stands back while it is open (the dialog's top used to cut the tag in half). `:has` is Chrome 105, Firefox 121, Safari 15.4: an older browser shows the tag as before. */
  body:has(.ts-real-back:not([hidden])) #ts-title {
    visibility: hidden;
  }
}

/* The upright phone, and a window 720 px wide or less that is no phone on its side: the sheet rises from the bottom, at most 55 % of the height; folded, a bar along the bottom holding `real_open` and `panel_open`. */
@media (max-width: 720px) and (orientation: portrait), (max-width: 720px) and (hover: hover), (max-width: 720px) and (pointer: fine), (hover: none) and (pointer: coarse) and (orientation: portrait) {
  #ts-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    max-height: 55vh;
    max-height: 55dvh;
    --ts-pad-l: max(var(--ts-gap), env(safe-area-inset-left, 0px));
    padding: 0 var(--ts-pad-r) max(var(--ts-gap), env(safe-area-inset-bottom, 0px)) var(--ts-pad-l);
    border-top: 1px solid var(--ts-line);
    border-left: 0;
  }

  #ts-panel[data-folded] {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    max-height: none;
    padding: var(--ts-gap) max(var(--ts-gap), env(safe-area-inset-right, 0px)) max(var(--ts-gap), env(safe-area-inset-bottom, 0px)) max(var(--ts-gap), env(safe-area-inset-left, 0px));
    background: var(--ts-panel);
  }

  #ts-title {
    max-width: min(26em, calc(100vw - var(--ts-gap) * 2));
  }

  #ts-foot {
    max-width: calc(100vw - var(--ts-gap) * 2);
    bottom: calc(var(--ts-touch) + var(--ts-gap) * 2);
  }
}

/* By touch every control is --ts-touch each way (§4.1, §4.3); a mouse's are 28 px (above). */
@media (hover: none) and (pointer: coarse) {
  .ts-btn,
  .ts-typed,
  .ts-range,
  .ts-check,
  .ts-tag,
  .ts-link {
    min-height: var(--ts-touch);
    min-width: var(--ts-touch);
  }

  #ts-panel {
    --ts-hit: var(--ts-touch);
  }

  .ts-tag,
  .ts-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}
