/* Monochrome and quiet: near-black surfaces, white type, one weight of emphasis,
   square-ish 4px corners. Nothing competes with the stream. */
:root {
  color-scheme: dark;
  --bg: #000;
  --surface: #121212;
  --surface-raised: rgb(255 255 255 / 0.08);
  --surface-hover: rgb(255 255 255 / 0.14);
  --border: rgb(255 255 255 / 0.12);
  --text: #fff;
  --muted: #a0a0a0;
  --danger: #f2575c;
  --radius: 4px;
  --handle: 28px;
  /* How solid the in-stream menu is; the stream stays visible, blurred, behind it. */
  --dock-opacity: 0.85;
  --ease: cubic-bezier(0.5, 0, 0, 0.75);
  font-family: "Gotham SSm", "Gotham", "Inter", "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  letter-spacing: 0.01em;
}

* { box-sizing: border-box; }

html { height: 100%; }

/* The page is exactly one screen tall and centres its content, so nothing scrolls
   unless the content truly does not fit (a phone in landscape, say). */
body {
  margin: 0;
  height: 100%;
  display: flex;
  overflow: auto;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

/* ------------------------------------------------------------------ sign-in */

/* Auto margins centre the panel, and unlike align-items they let it start at the top
   and scroll when it is taller than the screen instead of being cut off. */
.panel {
  width: min(22rem, calc(100% - 3rem));
  margin: auto;
  padding: 1.5rem 0;
}

.logo {
  display: block;
  width: 9.5rem;
  height: auto;
  margin: 0 auto 1rem;
  color: var(--text);
}

h1 {
  margin: 0 0 clamp(1.25rem, 4vh, 2.5rem);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.42em;
  /* Letter-spacing adds a gap after the last letter too; balance it so the text stays centred. */
  padding-left: 0.42em;
  text-transform: uppercase;
  text-align: center;
  color: var(--muted);
}

p { margin: 0 0 clamp(0.75rem, 2vh, 1.25rem); line-height: 1.5; color: var(--muted); }
.hint { font-size: 0.85rem; word-break: break-all; }
code { color: var(--text); font-family: inherit; letter-spacing: 0.06em; }

form { display: grid; gap: clamp(0.75rem, 2vh, 1.25rem); }
label { display: grid; gap: 0.5rem; font-size: 0.85rem; font-weight: 500; color: var(--muted); }

input {
  height: 2.75rem;
  padding: 0 0.9rem;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: border-color 0.2s var(--ease);
}
input:focus-visible { outline: none; border-color: var(--text); }

/* A checkbox with its sentence beside it, the whole line clickable. */
.check { display: flex; align-items: center; gap: 0.75rem; cursor: pointer; }
.check input {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  accent-color: #fff;
  cursor: pointer;
}
.check input:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

button {
  min-height: 2.75rem;
  padding: 0 1.5rem;
  font: inherit;
  font-weight: 500;
  color: var(--text);
  background: var(--surface-raised);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 0.2s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
button:hover { background: var(--surface-hover); }
button.primary { color: #000; background: #fff; }
button.primary:hover { background: #e2e2e2; }
button:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
button:disabled { opacity: 0.4; cursor: default; }

.actions { display: grid; gap: 0.75rem; }

/* A link that looks like the secondary buttons. */
a.button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0 1.5rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  background: var(--surface-raised);
  border-radius: var(--radius);
  transition: background-color 0.2s var(--ease);
}
a.button:hover { background: var(--surface-hover); }
a.button:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.theater-offer { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.theater-offer .hint { margin: 0.6rem 0 0; text-align: center; word-break: normal; }

.devices { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.devices h2 { margin: 0 0 0.75rem; font-size: 0.85rem; font-weight: 500; color: var(--muted); }
.devices ul { display: grid; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.devices li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.devices .name { display: block; }
.devices .detail { display: block; font-size: 0.8rem; color: var(--muted); }
.devices button { min-height: 2.25rem; padding: 0 0.9rem; font-size: 0.85rem; }
/* Takes no room until there is something to say. */
.message { margin: 0; color: var(--danger); text-align: center; }
.message:not(:empty) { margin-top: 1rem; }

/* ----------------------------------------------------------------- language */

/* A quiet button in the corner of the sign-in pages: a globe and a two-letter code. */
.language-button {
  position: fixed;
  top: calc(0.75rem + env(safe-area-inset-top));
  right: calc(0.75rem + env(safe-area-inset-right));
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0 0.75rem;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  background: transparent;
}
.language-button svg { width: 1.25rem; height: 1.25rem; }

/* The page stays visible behind the sheet, dimmed and out of focus. */
.sheet-scrim {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgb(0 0 0 / 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: sheet-fade 0.3s var(--ease);
}

.sheet {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  width: min(26rem, 100%);
  padding: calc(4.5rem + env(safe-area-inset-top)) calc(2rem + env(safe-area-inset-right)) 2rem 2rem;
  overflow-y: auto;
  background: var(--surface);
  animation: sheet-slide 0.3s var(--ease);
}
.sheet h2 { margin: 0 0 1.25rem; font-size: 1.25rem; font-weight: 500; }
.sheet-close {
  position: absolute;
  top: calc(0.75rem + env(safe-area-inset-top));
  right: calc(0.75rem + env(safe-area-inset-right));
  display: grid;
  place-items: center;
  width: 2.75rem;
  padding: 0;
  background: transparent;
}
.sheet-close svg { width: 1.5rem; height: 1.5rem; }
.sheet-list { display: grid; gap: 0.25rem; margin: 0 -0.9rem; padding: 0; list-style: none; }
.sheet-list button {
  display: grid;
  gap: 0.15rem;
  width: 100%;
  min-height: 3.5rem;
  padding: 0.6rem 0.9rem;
  text-align: left;
  background: transparent;
}
.sheet-list button:hover { background: var(--surface-raised); }
/* The language in use is the one already lit. */
.sheet-list button[aria-current] { background: var(--surface-raised); }
.sheet-list .name { font-size: 1rem; }
.sheet-list .detail { font-size: 0.75rem; letter-spacing: 0.08em; color: var(--muted); }

@keyframes sheet-slide { from { transform: translateX(100%); } }
@keyframes sheet-fade { from { opacity: 0; } }

/* -------------------------------------------------------------------- stage */

.stage {
  position: fixed;
  inset: 0;
  background: #000;
  overflow: hidden;
  /* Gestures on the picture belong to the remote PC, not to the browser. */
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
/* How the picture fills this box is set from script (object-fit), per the user's choice. */
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; display: block; }

.keyboard-proxy {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  min-height: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  /* 16px stops iOS from zooming the page when the field takes focus. */
  font-size: 16px;
}

.touch-only { display: none; }
.stage.has-touch .touch-only, .stage.touch .touch-only { display: flex; }

.capture-hint {
  position: absolute;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 3rem);
  margin: 0;
  padding: 0.6rem 1rem;
  color: var(--text);
  font-size: 0.85rem;
  text-align: center;
  background: rgb(0 0 0 / 0.6);
  border-radius: var(--radius);
  pointer-events: none;
}

/* --------------------------------------------------------------------- dock */

.dock-scrim { position: absolute; inset: 0; }

/* The dock is [handle][panel] laid out away from its edge, and pushed off screen
   by its own size minus the handle. Opening it removes that push. */
.dock {
  position: absolute;
  display: flex;
  pointer-events: none;
  transition: transform 0.35s var(--ease);
}
.dock.dragging { transition: none; }
.dock > * { pointer-events: auto; }

.dock[data-edge="right"] { inset: 0 0 0 auto; flex-direction: row; transform: translateX(calc(100% - var(--handle))); }
.dock[data-edge="left"] { inset: 0 auto 0 0; flex-direction: row-reverse; transform: translateX(calc(-100% + var(--handle))); }
.dock[data-edge="bottom"] { inset: auto 0 0 0; flex-direction: column; transform: translateY(calc(100% - var(--handle))); }
.dock[data-edge="top"] { inset: 0 0 auto 0; flex-direction: column-reverse; transform: translateY(calc(-100% + var(--handle))); }
.dock.open { transform: none; }

/* A wide invisible target with a thin visible bar inside it. */
.dock-handle {
  position: relative;
  flex: none;
  min-height: 0;
  padding: 0;
  background: none;
  border-radius: 0;
  touch-action: none;
  cursor: grab;
}
.dock-handle:hover { background: none; }
.dock-handle::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  background: #fff;
  border-radius: 2px;
  opacity: 0.55;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.35);
  transition: opacity 0.2s var(--ease);
}
.dock.open .dock-handle::after, .dock.dragging .dock-handle::after, .dock-handle:hover::after { opacity: 1; }

.dock[data-edge="left"] .dock-handle, .dock[data-edge="right"] .dock-handle {
  width: var(--handle);
  height: 88px;
  align-self: flex-start;
  /* --offset is the handle's centre as a fraction of the edge. */
  margin-top: calc(var(--offset, 0.5) * 100vh - 44px);
  margin-top: calc(var(--offset, 0.5) * 100dvh - 44px);
}
.dock[data-edge="left"] .dock-handle::after, .dock[data-edge="right"] .dock-handle::after { width: 4px; height: 48px; }

.dock[data-edge="top"] .dock-handle, .dock[data-edge="bottom"] .dock-handle {
  width: 88px;
  height: var(--handle);
  align-self: flex-start;
  margin-left: calc(var(--offset, 0.5) * 100vw - 44px);
}
.dock[data-edge="top"] .dock-handle::after, .dock[data-edge="bottom"] .dock-handle::after { width: 48px; height: 4px; }

.dock-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.5rem 1.25rem;
  background: rgb(10 10 10 / var(--dock-opacity));
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  overflow: auto;
}
.dock[data-edge="left"] .dock-panel, .dock[data-edge="right"] .dock-panel {
  width: min(18rem, calc(100vw - var(--handle) - 1rem));
  justify-content: center;
  padding-top: max(1.5rem, env(safe-area-inset-top));
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
}
.dock[data-edge="top"] .dock-panel, .dock[data-edge="bottom"] .dock-panel {
  flex-flow: row wrap;
  justify-content: center;
  align-items: center;
}
.dock[data-edge="top"] .dock-panel .row, .dock[data-edge="bottom"] .dock-panel .row { flex: 1 1 11rem; max-width: 16rem; }

/* Section titles inside the menu. In the horizontal layouts each starts a new line. */
.group {
  margin: 1rem 0 0.25rem;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.dock-panel > .group:first-child { margin-top: 0; }
.group-body { display: contents; }
.dock[data-edge="top"] .group, .dock[data-edge="bottom"] .group { flex-basis: 100%; text-align: center; }

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 0 1rem;
  text-align: left;
}
.row.primary { justify-content: center; margin-top: 1.25rem; }
.row .value { color: var(--muted); font-weight: 400; white-space: nowrap; }

/* A row that holds a slider instead of being a button. */
.row.slider {
  min-height: 2.75rem;
  font-size: inherit;
  font-weight: 500;
  color: var(--text);
  background: var(--surface-raised);
  border-radius: var(--radius);
}
.row.slider .value { min-width: 2.75rem; text-align: right; font-variant-numeric: tabular-nums; }
.row.slider input {
  flex: 1;
  min-width: 0;
  height: 1.5rem;
  padding: 0;
  background: none;
  border: 0;
  accent-color: #fff;
  cursor: pointer;
}
.row.slider input:disabled { opacity: 0.35; cursor: default; }
.row.slider input:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

/* --------------------------------------------------------- on-screen readout */

.hud {
  position: absolute;
  top: max(0.75rem, env(safe-area-inset-top));
  left: max(0.75rem, env(safe-area-inset-left));
  margin: 0;
  padding: 0.4rem 0.65rem;
  color: #fff;
  font-size: 0.75rem;
  line-height: 1.5;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  white-space: pre;
  background: rgb(0 0 0 / 0.6);
  border-radius: var(--radius);
  pointer-events: none;
}

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

.toast {
  position: absolute;
  left: 50%;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 15rem;
  max-width: calc(100% - 2rem);
  /* A pill: fully rounded ends, with room on the right to balance the icon on the left. */
  padding: 0.6rem 1.6rem 0.6rem 0.7rem;
  color: #fff;
  background: rgb(10 10 10 / var(--dock-opacity));
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: 999px;
  pointer-events: none;
  /* Above the hint, which shares this spot, while sliding in and out. */
  z-index: 2;
  /* Parked just below the screen until it has something to say. */
  opacity: 0;
  transform: translate(-50%, calc(100% + 2rem));
  transition: transform 0.45s var(--ease), opacity 0.3s var(--ease);
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
/* The icon sits in a round badge so marks of different shapes line up the same way. */
.toast-icon { flex: none; width: 2.5rem; height: 2.5rem; padding: 0.55rem; border-radius: 50%; background: var(--surface-raised); overflow: visible; }
.toast-icon.spinning { animation: toast-spin 0.9s linear infinite; }
.toast-text { display: grid; gap: 0.1rem; min-width: 0; }
.toast-title { font-weight: 500; }
.toast-detail { font-size: 0.8rem; color: var(--muted); }
@keyframes toast-spin { to { transform: rotate(360deg); } }

/* The hint would sit on top of an open menu. */
.dock.open ~ .capture-hint { display: none; }

/* While the pointer is captured the stream has the whole screen. */
.stage.captured .dock, .stage.captured .capture-hint:not(.menu-shortcut) { display: none; }
/* The hint and the notification share the bottom of the screen; the notification wins. */
.stage:has(.toast.visible) .capture-hint { display: none; }
/* The short reminder about the menu takes the hint's place while it shows. */
.stage:has(.menu-shortcut:not([hidden])) #capture-hint { display: none; }

@media (prefers-reduced-motion: reduce) {
  .dock, input, button, .dock-handle::after, .toast { transition: none; }
  .sheet, .sheet-scrim { animation: none; }
  /* A spinner that does not spin still reads as "busy"; slow it rather than stop it. */
  .toast-icon.spinning { animation-duration: 2.4s; }
}
