/* Viewer page: layout and components. Colours, font and backdrop come from
   custom properties that an event theme (public/themes/<theme>/theme.css)
   overrides. The defaults below are the neutral Eventstream look. */

:root {
  --bg: #05070d;
  --ink: #ffffff;
  --ink-2: rgba(255, 255, 255, 0.74);
  --ink-3: rgba(255, 255, 255, 0.52);
  --line: rgba(255, 255, 255, 0.14);
  --field: rgba(255, 255, 255, 0.08);
  --field-line: rgba(255, 255, 255, 0.26);
  --surface: rgba(16, 20, 32, 0.78);
  --notice: #141a2b;
  --accent: #ffffff;
  --accent-ink: #05070d;
  --accent-hover: #d9e2ff;
  --focus: #7aa7ff;
  --error: #ff9aa8;
  --ok: #3ccf5a;
  --wait: #ffb84d;
  --bad: #f2607a;
  --live: #f2607a;
  --avatar-1: #5b6cff;
  --avatar-2: #2f9be0;
  --avatar-3: #3aa55c;
  --avatar-4: #c98a1b;
  --avatar-5: #c94f6a;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius-l: 22px;
  --radius-m: 14px;
  --radius-s: 10px;
  --gutter: max(16px, env(safe-area-inset-left, 0px));
  --top-h: 68px;
  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

body.is-loading .top,
body.is-loading main { visibility: hidden; }

img { max-width: 100%; display: block; }
h1, h2, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

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

/* Theme hook: a fixed layer behind the page for the event backdrop. */
.backdrop { position: fixed; inset: 0; z-index: -1; pointer-events: none; }

/* ------------------------------------------------------------ header */

.top {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: var(--top-h);
  padding: max(12px, env(safe-area-inset-top, 0px)) max(var(--gutter), calc((100% - 1440px) / 2)) 12px;
}
/* On the event page the header stays on top while the page scrolls. */
body.is-live .top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.top__partner { height: 32px; width: auto; flex: none; }
.top__logo { height: 38px; width: auto; flex: none; margin-left: auto; }
body.is-live .top__logo { display: none; }
.top__nav { display: flex; gap: 4px; margin-left: auto; }
.top__link {
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}
.top__link:hover { color: var(--ink); background: var(--field); }
.top__link[aria-current="true"] { color: var(--ink); background: var(--field); box-shadow: inset 0 0 0 1px var(--line); }
.top__me {
  display: none;
  margin-left: auto;
  color: var(--ink-2);
  font-size: 14px;
  text-align: right;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------ buttons, fields */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 24px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 16px;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--quiet { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--field-line); }
.btn--quiet:hover { background: var(--field); }
.btn--small { min-height: 36px; padding: 0 16px; font-size: 14px; background: var(--accent); color: var(--accent-ink); }
.btn:disabled { opacity: 0.6; cursor: progress; }
label.btn:focus-within { outline: 3px solid var(--focus); outline-offset: 3px; }

.field { display: grid; gap: 6px; }
.field__label { color: var(--ink-2); font-size: 14px; }
.field__input {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 1px solid var(--field-line);
  border-radius: var(--radius-s);
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}
.field__input:focus-visible { outline-offset: 0; border-color: transparent; }
.field__select {
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='white' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
}
.field__select option { background: #10141f; color: #fff; }
.field__input[aria-invalid="true"] { border-color: var(--error); }

.form-error { color: var(--error); font-size: 15px; }

/* Settlement combobox */
.combo__box { position: relative; }
/* Room below the field on phones while the keyboard is open (see place-picker.ts). */
body.is-picking .gate { padding-bottom: 70vh; }
.combo { scroll-margin-top: 12px; }
.combo__list {
  position: absolute;
  z-index: 5;
  top: 100%;
  left: 0;
  right: 0;
  max-height: min(52vh, 360px);
  overflow-y: auto;
  margin-top: 4px;
  padding: 6px;
  border: 1px solid var(--field-line);
  border-radius: var(--radius-m);
  background: var(--notice);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.combo__option {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: var(--radius-s);
  cursor: pointer;
}
.combo__option:hover,
.combo__option[aria-selected="true"] { background: var(--field); }
.combo__name { font-size: 16px; line-height: 1.3; }
.combo__detail { color: var(--ink-3); font-size: 14px; line-height: 1.3; }
.combo__empty,
.combo__more { padding: 10px 12px; color: var(--ink-3); font-size: 14px; }
.combo__hint { color: var(--ink-2); font-size: 14px; line-height: 1.35; }

/* Who is signed in, at the bottom of the event page. */
.whoami { color: var(--ink-3); font-size: 14px; line-height: 1.5; }
.whoami .link-btn { color: var(--ink-2); }
.link-btn {
  justify-self: start;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--ink-2);
  font: inherit;
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link-btn:hover { color: var(--ink); }

/* ------------------------------------------------------------ entry */

.gate {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 28px;
  min-height: calc(100dvh - 72px);
  padding: 24px var(--gutter) max(48px, env(safe-area-inset-bottom, 0px));
  text-align: center;
}
.gate__title { display: grid; justify-items: center; font-weight: inherit; }
.gate__logo { width: min(420px, 78vw); height: auto; }
.gate__name { font-size: clamp(28px, 6vw, 44px); line-height: 1.1; letter-spacing: -0.01em; max-width: 18ch; }
.gate__logo:not([hidden]) + .gate__name {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
}
.gate__tagline { font-size: clamp(20px, 4.6vw, 30px); line-height: 1.25; max-width: 22ch; }
.gate__form {
  display: grid;
  gap: 16px;
  width: min(400px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--surface);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  text-align: left;
}
.gate__form .btn { width: 100%; margin-top: 4px; }
.gate__check:empty { display: none; }
/* Turnstile in interaction-only mode: invisible until it needs a click; cancel the grid gap meanwhile. */
.gate__check:not(.is-interactive) { height: 0; overflow: hidden; margin-top: -16px; }
.gate__note { color: var(--ink-3); font-size: 14px; line-height: 1.4; }
.gate__closed {
  max-width: 30ch;
  padding: 20px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--surface);
  font-size: 18px;
}

/* ------------------------------------------------------------ event page */

.live {
  display: grid;
  gap: 28px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--gutter) max(48px, env(safe-area-inset-bottom, 0px));
}
.stage,
.photo { scroll-margin-top: calc(var(--top-h) + 12px); }

.player {
  position: relative;
  aspect-ratio: 16 / 9;
  margin-inline: calc(var(--gutter) * -1);
  overflow: hidden;
  background: #000;
}
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player__wait {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  padding: 16px;
  color: var(--ink-2);
  text-align: center;
}
.player__mark { width: clamp(64px, 14vw, 120px); height: auto; }

.now { padding-top: 20px; display: grid; gap: 6px; }
.now__label { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 14px; }
.now__pulse {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 var(--live);
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 70%, transparent); }
  70%, 100% { box-shadow: 0 0 0 10px transparent; }
}
.now__title { font-weight: inherit; font-size: clamp(22px, 2.6vw, 32px); line-height: 1.2; letter-spacing: -0.01em; max-width: 34ch; }
.now__meta { color: var(--ink-2); }

/* Photo for the map: the one card on the page. */
.photo {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--surface);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.photo__map { position: relative; padding: 24px 24px 0; }
.photo__map-img { width: 100%; height: auto; }
.photo__map-img:not([src]) { display: none; }
.photo__thumb {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 84px;
  height: 84px;
  translate: -50% -50%;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--state, var(--ink));
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--state, var(--ink)) 30%, transparent), 0 10px 30px rgba(0, 0, 0, 0.5);
}
.photo__body { display: grid; gap: 12px; padding: 20px 24px 24px; }
.photo__title { font-weight: inherit; font-size: 22px; line-height: 1.2; letter-spacing: -0.01em; }
.photo__text { color: var(--ink-2); font-size: 15px; line-height: 1.45; }
.photo__actions { display: flex; flex-wrap: wrap; gap: 12px; }
.photo__actions:not(:has(> :not([hidden]))) { display: none; }

.status { display: inline-flex; align-items: center; gap: 10px; font-size: 16px; }
.status__dot { width: 12px; height: 12px; border-radius: 50%; background: var(--state, var(--ink-3)); flex: none; }
[data-state="pending"] { --state: var(--wait); }
[data-state="approved"] { --state: var(--ok); }
[data-state="rejected"] { --state: var(--bad); }

/* Programme drawer over the stream: wide screens only (see the 1100px query). */
.screen { position: relative; }
.toggle,
.drawer { display: none; }
.toggle {
  position: absolute;
  z-index: 3;
  top: 16px;
  right: 16px;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 6, 24, 0.62);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.toggle:hover { background: rgba(0, 6, 24, 0.82); }
.toggle[aria-expanded="true"] { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.drawer {
  position: absolute;
  z-index: 2;
  top: 72px;
  bottom: 16px;
  left: 16px;
  width: min(360px, 40%);
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease, visibility 0s linear 0.35s;
}
.drawer:not(.is-open) { opacity: 0; visibility: hidden; transform: translateX(-16px); pointer-events: none; }
.drawer.is-open { transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease, visibility 0s; }
.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 10px 12px 18px;
  border-bottom: 1px solid var(--line);
}
.drawer__title { font-weight: inherit; font-size: 18px; }
.drawer__close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.drawer__close:hover { background: var(--field); color: var(--ink); }
.drawer__scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 0 18px 8px; }
.drawer .programme li { grid-template-columns: 46px minmax(0, 1fr); padding: 10px 0; }
.drawer .programme li:last-child { border-bottom: 0; }
.drawer .programme__title { font-size: 15px; }
.drawer .programme__time { font-size: 14px; }
.drawer .programme__who { font-size: 13px; }

/* Programme and speaker feed: plain lists, no cards. */
.panel { display: grid; gap: 4px; }
.panel__title { font-weight: inherit; font-size: 20px; line-height: 1.2; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.panel__empty { color: var(--ink-3); font-size: 15px; padding: 12px 0; }

.programme li {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 2px 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.programme__time { color: var(--ink-3); font-size: 15px; font-variant-numeric: tabular-nums; padding-top: 1px; }
.programme__title { font-size: 16px; line-height: 1.35; }
.programme__who { grid-column: 2; color: var(--ink-2); font-size: 14px; }
.programme li.is-past { opacity: 0.55; }
.programme li.is-current .programme__time { color: var(--ink); }
.programme__now {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 8px; color: var(--live); font-size: 13px; white-space: nowrap;
}
.programme__now::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.feed li { display: grid; gap: 8px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.feed__head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.feed__name { font-size: 15px; min-width: 0; overflow-wrap: anywhere; }
.feed__time { margin-left: auto; color: var(--ink-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.feed__text { font-size: 15px; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; }
.feed__links { display: grid; gap: 4px; font-size: 15px; }

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--avatar-1);
  color: #fff;
  font-size: 13px;
}

/* Connection notices */
.notice {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  translate: -50% 0;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 32px);
  padding: 10px 12px 10px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--notice);
  font-size: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

/* ------------------------------------------------------------ wider screens */

@media (max-width: 419px) {
  .top { gap: 10px; }
  .top__partner { height: 28px; }
  .top__nav { gap: 2px; }
  .top__link { padding: 8px 9px; font-size: 14px; }
}
@media (max-width: 359px) {
  body.is-live .top__partner { display: none; }
  .top__nav { margin-left: 0; }
}

@media (min-width: 560px) {
  body.is-live .top__logo { display: block; margin-left: 0; }
}

@media (min-width: 700px) {
  :root { --top-h: 80px; }
  .top__logo { margin-left: 0; }
  .top__nav { margin-left: 16px; }
  .top__me { display: block; }
  .player { margin-inline: 0; border-radius: var(--radius-l); }
  .top__partner { height: 38px; }
  .top__logo { height: 46px; }
}

/* The photo card lies flat when there is room: map left, text right. */
@media (min-width: 900px) {
  .photo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; }
  .photo__map { padding: 28px; }
  .photo__body { padding: 28px 36px 28px 8px; }
  .photo__title { font-size: 26px; }
  .photo__text { font-size: 16px; max-width: 42ch; }
}

/* One column; the stream fits the screen height (as in the demo). */
@media (min-width: 1100px) {
  .live { max-width: clamp(760px, calc((100dvh - var(--top-h) - 40px) * 16 / 9), 1440px); }
  .toggle { display: inline-flex; }
  .drawer { display: flex; }
  .panel--programme { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .now__pulse { animation: none; }
  .drawer,
  .drawer.is-open,
  .toggle { transition: none; }
  .btn { transition: none; }
}
