/* SierraCast viewer pages. Colours and fonts come from the event's brand kit (see :root in the page).
   --text is readable on --bg, --surface-text on --surface, --on-brand on --brand (worked out on the server). */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1, h2 { font-family: var(--font-heading); line-height: 1.15; margin: 0 0 .3em; }
h1 { font-size: clamp(1.35rem, 2.4vw, 1.85rem); }
h2 { font-size: 1.05rem; }
a { color: inherit; }
[hidden] { display: none !important; }

.btn, .btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  font: 600 .95rem/1 var(--font-body);
  padding: .75em 1.1em; border-radius: 8px; cursor: pointer; text-decoration: none;
  border: 2px solid var(--brand);
}
.btn { background: var(--brand); color: var(--on-brand); }
.btn-secondary { background: transparent; color: inherit; border-color: currentColor; opacity: .9; }
.btn:hover { filter: brightness(1.08); }
.btn-secondary:hover { opacity: 1; }

input, textarea, select {
  font: inherit; color: inherit;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px; padding: .65em .75em; width: 100%;
}
.card input, .card textarea { background: color-mix(in srgb, var(--surface) 85%, var(--surface-text) 4%); }
input::placeholder, textarea::placeholder { color: inherit; opacity: .55; }
input:focus, textarea:focus, button:focus-visible, summary:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.card { background: var(--surface); color: var(--surface-text); border-radius: 12px; padding: 16px; }

/* header / footer */
.ev-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px 8px; max-width: var(--page-max, 1400px); width: 100%; margin: 0 auto; }
.ev-logo { max-height: 40px; max-width: 220px; display: block; }
.help-btn { background: transparent; color: inherit; border: 1px solid currentColor; border-radius: 999px; padding: .4em 1em; font: 600 .85rem var(--font-body); cursor: pointer; opacity: .85; }
.ev-footer { margin-top: auto; display: flex; justify-content: space-between; gap: 12px; padding: 16px; max-width: var(--page-max, 1400px); width: 100%; margin-inline: auto; font-size: .78rem; opacity: .6; }

/* layout: on desktop the video, title and chat fit on one screen */
.ev {
  --chat-w: 420px;
  --reserve: 210px; /* header + title block + gaps, so the video never pushes the page past one screen */
  width: 100%; margin: 0 auto; padding: 0 16px 16px;
  display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr);
  max-width: min(1400px, calc((100vh - var(--reserve)) * 16 / 9 + 32px));
}
.ev:has(#social) { max-width: min(1400px, calc((100vh - var(--reserve)) * 16 / 9 + var(--chat-w) + 16px + 32px)); }
.ev > .social { order: 5; }
@media (min-width: 1000px) {
  .ev:has(#social) {
    grid-template-columns: minmax(0, 1fr) var(--chat-w);
    grid-template-areas: "flash flash" "banner banner" "stage social" "info info";
    align-items: start;
  }
  .ev:has(#social) > .flash { grid-area: flash; }
  .ev:has(#social) > .banner { grid-area: banner; }
  .ev:has(#social) > .stage { grid-area: stage; }
  .ev:has(#social) > .info { grid-area: info; }
  /* The chat takes exactly the video's height and scrolls inside. */
  .ev:has(#social) > .social { grid-area: social; align-self: stretch; contain: size; order: 0; }
}

.flash { background: color-mix(in srgb, var(--brand) 14%, var(--surface)); color: var(--surface-text); border-left: 4px solid var(--brand); padding: 10px 14px; border-radius: 8px; margin: 0; }
.banner { background: #F2B705; color: #1b1300; font-weight: 600; padding: 10px 14px; border-radius: 8px; margin: 0; }

/* stage */
.stage { position: relative; aspect-ratio: 16 / 9; width: 100%; border-radius: 12px; overflow: hidden; background: #000; }
.poster {
  position: absolute; inset: 0; background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 70%, #000), #000);
  background-size: cover; background-position: center; display: flex; align-items: flex-end;
}
.poster-inner { padding: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
/* One small light pill in the poster corner: status · countdown · Get notified */
.poster-pill { display: inline-flex; align-items: center; gap: 2px; background: rgba(255,255,255,.88); color: #1b1f27; border-radius: 10px; padding: 4px; font-size: .78rem; box-shadow: 0 1px 6px rgba(0,0,0,.18); backdrop-filter: blur(6px); max-width: 100%; flex-wrap: wrap; }
.state-pill { margin: 0; padding: .35em .6em; border-radius: 7px; font-weight: 700; font-size: .7rem; letter-spacing: .05em; text-transform: uppercase; color: #4b5563; }
.stage[data-status="live"] .state-pill { background: #E0242F; color: #fff; }
.countdown { display: inline-flex; gap: 3px; align-items: baseline; padding: .35em .6em; border-left: 1px solid rgba(0,0,0,.12); }
.countdown span { display: inline-flex; align-items: baseline; gap: 1px; }
.countdown b { font: 700 1em/1 var(--font-body); font-variant-numeric: tabular-nums; }
.countdown small { font-size: .9em; opacity: .75; margin-right: 3px; }
.notify-btn { display: inline-flex; align-items: center; gap: 5px; border: 0; background: transparent; color: inherit; font: 600 .78rem var(--font-body); padding: .35em .6em; border-radius: 7px; cursor: pointer; border-left: 1px solid rgba(0,0,0,.12); }
.notify-btn svg { width: 15px; height: 15px; }
.notify-btn:hover { background: rgba(0,0,0,.07); }
.notify-btn.done { color: #1F7A45; }
.ended-note { margin: 0; background: rgba(255,255,255,.88); color: #1b1f27; border-radius: 8px; padding: .4em .8em; font-size: .9rem; }
.notify-dialog { border: 0; border-radius: 14px; background: var(--surface); color: var(--surface-text); width: min(400px, calc(100vw - 32px)); padding: 22px; }
.notify-dialog::backdrop { background: rgba(0,0,0,.5); }
.notify-dialog h2 { margin: 0 0 4px; }
.notify-dialog p { margin: 0 0 12px; font-size: .92rem; }
.notify-dialog .stack { gap: 8px; }
.player { position: absolute; inset: 0; }
.player video { width: 100%; height: 100%; background: #000; display: block; }
.player-msg { position: absolute; bottom: 60px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.75); color: #fff; padding: .5em 1em; border-radius: 8px; margin: 0; }

/* Big, obvious sound button for viewers whose browser started the video muted */
.unmute {
  position: absolute; inset: 0; margin: auto; width: max-content; height: max-content; max-width: 90%;
  display: flex; align-items: center; gap: .6em;
  background: var(--brand); color: var(--on-brand); border: 4px solid #fff; border-radius: 16px;
  padding: .8em 1.3em; font: 800 clamp(1.2rem, 3.2vw, 2rem)/1.1 var(--font-body);
  cursor: pointer; box-shadow: 0 10px 40px rgba(0,0,0,.55); animation: pulse 1.6s ease-in-out infinite; z-index: 3;
}
.unmute svg { width: 1.4em; height: 1.4em; flex: none; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@media (prefers-reduced-motion: reduce) { .unmute { animation: none; } }

/* Cast / AirPlay */
.cast-bar { position: absolute; top: 10px; right: 10px; display: flex; gap: 8px; z-index: 2; }
.cast-bar button, .cast-bar google-cast-launcher {
  width: 40px; height: 40px; border-radius: 8px; background: rgba(0,0,0,.6); border: 0; padding: 8px; cursor: pointer;
  --disconnected-color: #fff; --connected-color: #4fc3f7; display: block;
}
.cast-bar svg { width: 24px; height: 24px; fill: #fff; display: block; }

/* info */
.info { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; align-items: flex-start; }
.info-text { flex: 1 1 300px; min-width: 0; }
.when, .where { margin: 0; opacity: .85; font-size: .95rem; }
.desc { margin: .4em 0 0; white-space: pre-line; opacity: .9; font-size: .95rem; }
.viewers { margin: .3em 0 0; font-weight: 600; font-size: .95rem; }
.viewers::before { content: ""; display: inline-block; width: .55em; height: .55em; border-radius: 50%; background: #E0242F; margin-right: .45em; vertical-align: .05em; }
.cal { position: relative; }
.cal summary { list-style: none; }
.cal summary::-webkit-details-marker { display: none; }
.cal-menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); color: var(--surface-text); border-radius: 10px; padding: 6px; min-width: 180px; box-shadow: 0 10px 30px rgba(0,0,0,.25); z-index: 5; display: grid; }
.cal-menu a { padding: .6em .8em; border-radius: 6px; text-decoration: none; }
.cal-menu a:hover { background: var(--line); }

/* forms */
.notify h2 { margin-bottom: .2em; }
.notify p { margin: 0 0 .6em; font-size: .92rem; }
.row-form { display: flex; flex-wrap: wrap; gap: 8px; }
.row-form input { flex: 1 1 160px; }
.fine { font-size: .78rem; opacity: .7; margin: .5em 0 0; }
.stack { display: grid; gap: 10px; }
.check { display: flex; gap: .5em; align-items: center; }
.check input { width: auto; }
.error { color: var(--danger); margin: 0; }
.notice { font-size: .88rem; opacity: .85; margin: .4em 0 0; }

/* chat + guestbook */
.social { padding: 0; overflow: hidden; display: flex; flex-direction: column; height: 440px; }
@media (min-width: 1000px) { .social { height: auto; } }
.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.tab { flex: 1; background: none; border: 0; color: inherit; padding: 12px; font: 600 .95rem var(--font-body); cursor: pointer; opacity: .65; border-bottom: 3px solid transparent; }
.tab[aria-selected="true"] { opacity: 1; border-bottom-color: var(--brand); }
.panel { padding: 10px 14px 14px; display: flex; flex-direction: column; min-height: 0; flex: 1; }
.chat-list, .gb-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; overscroll-behavior: contain; }
.chat-list li { padding: 5px 0; }
.chat-list strong, .pinned strong { font-weight: 700; margin-right: .4em; }
.chat-list time, .pinned time { font-size: .72rem; opacity: .6; }
.chat-list p, .pinned p { margin: 1px 0 0; overflow-wrap: anywhere; }
.mod-badge { display: inline-block; background: var(--brand); color: var(--on-brand); font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; border-radius: 4px; padding: .1em .45em; margin-right: .5em; vertical-align: .1em; }
.from-mod p { font-weight: 600; }
.pinned { background: color-mix(in srgb, var(--brand) 16%, transparent); border-radius: 8px; padding: 6px 10px; margin-bottom: 6px; flex: none; }
.pinned > span { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; opacity: .8; }
.pinned li { list-style: none; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 8px; flex: none; }
.chat-form #chat-name { grid-column: 1 / -1; }
.gb-form { display: grid; gap: 8px; margin-top: 10px; flex: none; }
.gb-list li { padding: 10px 0; border-top: 1px solid var(--line); }
.gb-list li:first-child { border-top: 0; }
.gb-list p { margin: 4px 0 0; white-space: pre-line; overflow-wrap: anywhere; }

/* gates */
.gate { flex: 1; display: grid; place-items: center; padding: 16px; }
.gate-card { width: 100%; max-width: 460px; padding: 24px; }
.gate-card .when { margin-bottom: 16px; }
.code-input { font-size: 1.6rem; letter-spacing: .4em; text-align: center; }

/* help */
.help { border: 0; border-radius: 14px; background: var(--surface); color: var(--surface-text); width: min(560px, calc(100vw - 32px)); padding: 24px; }
.help::backdrop { background: rgba(0,0,0,.6); }
.help-close { position: absolute; right: 10px; top: 6px; }
.help-close button { background: none; border: 0; color: inherit; font-size: 1.8rem; cursor: pointer; }
.help-steps { padding-left: 1.2em; }
.help-steps li { margin-bottom: .6em; }
.selfcheck ul { list-style: none; padding: 0; margin: 12px 0 0; }
.selfcheck li { margin: .3em 0; }
.selfcheck li.ok { color: var(--ok); }
.selfcheck li.warn { color: var(--warn); }
.help-contact { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.chat-as { margin: 8px 0 0; font-size: .82rem; opacity: .8; flex: none; }
.linkish { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; }

@media (max-width: 520px) {
  .stage[data-status="scheduled"] .state-pill { display: none; }
  .stage[data-status="scheduled"] .countdown { border-left: 0; }
  .countdown > small:first-child { display: none; }
  .poster-inner { padding: 8px; }
}

/* ---------- download page ---------- */
.dl-page { max-width: 880px; width: 100%; margin: 0 auto; padding: 8px 16px 24px; }
.dl-page h1 { margin-top: 8px; }
.dl-page .when { margin-bottom: 20px; }
.dl-tiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 28px; }
.dl-tile {
  position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; text-decoration: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: var(--brand) center / cover; color: #fff; font: 700 1.15rem var(--font-heading);
}
.dl-tile::before { content: ""; position: absolute; inset: 0; background: rgba(0,0,0,.45); transition: background .15s; }
.dl-tile:hover::before { background: rgba(0,0,0,.3); }
.dl-tile > * { position: relative; }
.dl-tile svg { width: 34px; height: 34px; }
.dl-tile small { font: 500 .8rem var(--font-body); opacity: .9; }
.dl-tile.disabled { background: color-mix(in srgb, var(--surface) 70%, #8b95a7); color: var(--surface-text); cursor: default; }
.dl-tile.disabled::before { display: none; }
.dl-stats { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.dl-stats strong { font-family: var(--font-heading); font-size: 1.15rem; margin-right: .35em; }
