/* Pildiraadio app — live stream shell */

:root {
  --accent: #e7a25f;
  --accent-strong: #d98b46;
  --accent-light: #f0b97a;
  --panel: #fff7ee;
  --panel-2: #ffe8cb;
  --ink: #171310;
  --ink-soft: #6b5442;
  --glass: rgba(255, 247, 237, 0.44);
  --glass-hover: rgba(255, 247, 237, 0.72);
  --live: #e0402f;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #000;
  color: var(--panel);
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.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;
}

.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

/* ── Stage ───────────────────────────────────────────────────────── */

.stage {
  position: absolute;
  inset: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  /* Pinch and drag are handled in app.js, so the browser must not claim them. */
  touch-action: none;
}

.stage-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
  transform-origin: 50% 50%;
  will-change: transform;
}

/* Scrims so overlay text stays readable on bright picture */
.stage::before,
.stage::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 1;
}
.stage::before {
  top: 0;
  height: calc(96px + var(--safe-t));
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.62), transparent);
}
.stage::after {
  bottom: 0;
  height: calc(128px + var(--safe-b));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.66), transparent);
}
.app.ui-awake .stage::before,
.app.ui-awake .stage::after { opacity: 1; }

/* ── Top bar ─────────────────────────────────────────────────────── */

.stage-top {
  position: absolute;
  top: calc(12px + var(--safe-t));
  left: calc(14px + var(--safe-l));
  right: calc(14px + var(--safe-r));
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 3;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.app.ui-awake .stage-top { opacity: 1; transform: translateY(0); }

.live-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--live);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-shadow: none;
}
.live-badge::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #fff;
  animation: pulse 2s ease-in-out infinite;
}
.live-badge.is-off { background: rgba(0, 0, 0, 0.55); color: #e8d9c8; }
.live-badge.is-off::before { animation: none; background: #9b8674; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.zoom-chip {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 5px 12px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 247, 237, 0.5);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  pointer-events: auto;
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  backdrop-filter: blur(12px) saturate(1.2);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25), inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.zoom-chip[hidden] { display: none; }
.zoom-chip:active { background: rgba(255, 247, 237, 0.78); }

.now-title {
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Centre button ───────────────────────────────────────────────── */

.big-btn {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 108px;
  height: 108px;
  border: none;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: var(--glass);
  color: var(--ink);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.34), inset 0 0 0 1px rgba(255, 255, 255, 0.38);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  backdrop-filter: blur(16px) saturate(1.3);
  cursor: pointer;
  z-index: 4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.18s ease, background 0.18s ease;
}
.app.show-big-btn .big-btn { opacity: 1; pointer-events: auto; }
.big-btn:active { transform: translate(-50%, -50%) scale(0.95); }

.big-btn-icon {
  width: 54px;
  height: 54px;
  fill: currentColor;
}
.big-btn-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  max-width: 96px;
  text-align: center;
  line-height: 1.15;
}
.big-btn-label:empty { display: none; }
.big-btn.has-label .big-btn-icon { width: 40px; height: 40px; }

/* Landing state: opened as a web page rather than launched as an app. The
   stream has not started, so the only offered actions are "watch", the install
   bar, and the schedule — the transport controls would have nothing to act on. */
.app.landing .big-btn {
  width: 136px;
  height: 136px;
}
.app.landing .big-btn-label {
  max-width: 112px;
  font-size: 0.82rem;
}
.app.landing #playButton,
.app.landing .volume-cluster,
.app.landing #fullscreenButton {
  display: none;
}

/* ── Spinner ─────────────────────────────────────────────────────── */

.spinner {
  position: absolute;
  top: 50%; left: 50%;
  width: 46px; height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  border: 3px solid rgba(255, 247, 237, 0.28);
  border-top-color: var(--accent-light);
  animation: spin 0.9s linear infinite;
  z-index: 3;
}
.spinner[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Messages ────────────────────────────────────────────────────── */

.stage-message {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(88%, 420px);
  padding: 18px 20px 14px;
  border-radius: 18px;
  background: rgba(12, 8, 5, 0.82);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 1px rgba(255, 247, 237, 0.16);
  text-align: center;
  z-index: 5;
}
.stage-message[hidden] { display: none; }
.stage-message-text {
  margin: 0 0 10px;
  font-size: 0.98rem;
  line-height: 1.4;
  color: var(--panel);
}

.text-btn {
  appearance: none;
  border: none;
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--accent-light);
  color: #211a13;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.text-btn:active { background: var(--accent-strong); }

/* ── Controls ────────────────────────────────────────────────────── */

.controls {
  position: absolute;
  bottom: calc(14px + var(--safe-b));
  left: calc(12px + var(--safe-l));
  right: calc(12px + var(--safe-r));
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 3;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.app.ui-awake .controls {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.controls-spacer { flex: 1 1 auto; }

.icon-btn {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--glass);
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.26), inset 0 0 0 1px rgba(255, 255, 255, 0.34);
  -webkit-backdrop-filter: blur(14px) saturate(1.25);
  backdrop-filter: blur(14px) saturate(1.25);
  cursor: pointer;
  transition: background 0.18s ease, transform 0.14s ease;
}
.icon-btn:active { transform: scale(0.93); background: var(--glass-hover); }
.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }

/* The menu button is the way into the schedule, chat and donations, so it is
   given the brand orange rather than the same glass as the transport controls —
   it has to be findable against a bright picture. */
#infoButton {
  background: var(--accent);
  color: #2a1a0c;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.32), inset 0 0 0 1px rgba(255, 255, 255, 0.42);
}
#infoButton:active { background: var(--accent-strong); }

.volume-cluster {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
/* The slider needs both room and a settable volume (iOS ignores video.volume).
   On narrow phones it would push the row past the edge, and hardware volume
   keys cover it there anyway — so the mute button stands alone. */
.volume-slider { display: none; }
@media (min-width: 480px) {
  .app.has-volume .volume-slider { display: block; }
}

.volume-slider {
  width: 88px;
  height: 40px;
  margin: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}
.volume-slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent-light));
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  margin-top: -6px;
  border-radius: 50%;
  border: 2px solid rgba(143, 70, 8, 0.2);
  background: #fffdf9;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.volume-slider::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent-light));
}
.volume-slider::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(143, 70, 8, 0.2);
  background: #fffdf9;
}

@media (min-width: 560px) {
  .icon-btn { width: 54px; height: 54px; }
  .icon-btn svg { width: 27px; height: 27px; }
  .volume-slider { width: 150px; }
  .now-title { font-size: 1rem; }
}

/* Hide the pointer with the UI on desktop */
.app:not(.ui-awake) .stage,
.app:not(.ui-awake) .stage * { cursor: none; }

/* ── Schedule sheet ──────────────────────────────────────────────── */

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 6;
  opacity: 0;
  transition: opacity 0.28s ease;
}
.sheet-backdrop[hidden] { display: none; }
.app.sheet-open .sheet-backdrop { opacity: 1; }

.sheet {
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  z-index: 7;
  max-height: min(76%, 560px);
  display: flex;
  flex-direction: column;
  padding: 0 0 var(--safe-b);
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  color: var(--ink);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
  transform: translateY(101%);
  transition: transform 0.32s cubic-bezier(0.22, 0.68, 0.24, 1);
  will-change: transform;
}
.app.sheet-open .sheet { transform: translateY(0); }
.sheet.is-dragging { transition: none; }

.sheet-grabber {
  flex: 0 0 auto;
  appearance: none;
  border: none;
  background: transparent;
  width: 100%;
  height: 26px;
  padding: 0;
  margin: 0;
  cursor: grab;
  touch-action: none;
}
.sheet-grabber::before {
  content: '';
  display: block;
  width: 44px;
  height: 4px;
  margin: 10px auto 0;
  border-radius: 999px;
  background: rgba(23, 19, 16, 0.26);
}

.sheet-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 4px 16px 18px;
}

.sheet-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 2px 0 16px;
}
/* Used for both <a> links and the Jututuba <button>, so it resets button UA styles. */
.link-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  padding: 10px 4px;
  border: none;
  border-radius: 14px;
  background: rgba(231, 162, 95, 0.18);
  color: var(--ink);
  text-decoration: none;
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.1;
  cursor: pointer;
}
.link-btn:active { background: rgba(231, 162, 95, 0.36); }
.link-btn svg { width: 22px; height: 22px; fill: #b8661f; }
.link-btn[aria-expanded="true"] {
  background: rgba(231, 162, 95, 0.44);
  box-shadow: inset 0 0 0 1px rgba(143, 70, 8, 0.22);
}

/* ── Chat preview ────────────────────────────────────────────────── */

.chat-panel[hidden],
.panel-block[hidden] { display: none; }

#toetaPanel { text-align: center; }

.stripe-block {
  display: flex;
  justify-content: center;
  min-height: 48px;
  margin-bottom: 16px;
}
/* Custom elements default to display:inline, which makes the host box measure a
   line height while Stripe's iframe renders far taller inside it. The width pair
   lets it fill a narrow phone but stay centred on a wider sheet. */
.stripe-block stripe-buy-button {
  display: block;
  width: 100%;
  max-width: 340px;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 16px;
}
.chat-msg {
  padding: 7px 11px;
  border-radius: 12px;
  /* White bubbles: the sheet behind them is warm cream, so they need a faint
     ring and shadow or the edges dissolve into the background. */
  background: #fff;
  box-shadow: 0 1px 3px rgba(143, 70, 8, 0.10), inset 0 0 0 1px rgba(143, 70, 8, 0.07);
  font-size: 0.88rem;
  line-height: 1.35;
}
.chat-msg-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 1px;
}
.chat-author {
  font-weight: 700;
  color: #8f4608;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-time {
  flex: 0 0 auto;
  margin-left: auto;
  font-size: 0.74rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.chat-text { word-break: break-word; }
.chat-note {
  margin: 0 0 16px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(231, 162, 95, 0.14);
  font-size: 0.86rem;
  color: var(--ink-soft);
}

/* ── Chat compose form ───────────────────────────────────────────── */

.chat-form {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 16px;
}
.chat-name,
.chat-input {
  width: 100%;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  background: #fff;
  border: none;
  border-radius: 12px;
  padding: 9px 12px;
  box-shadow: inset 0 0 0 1px rgba(143, 70, 8, 0.16);
  -webkit-user-select: text;
  user-select: text;
}
.chat-name::placeholder,
.chat-input::placeholder { color: #b09680; }
.chat-name:focus,
.chat-input:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent);
}
.chat-name { max-width: 190px; }
.chat-input {
  resize: none;
  min-height: 42px;
  max-height: 108px;
  line-height: 1.35;
}
.chat-send-row {
  display: flex;
  align-items: flex-end;
  gap: 7px;
}
.chat-send {
  flex: 0 0 auto;
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 11px 18px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  color: #211a13;
  background: var(--accent-light);
  cursor: pointer;
}
.chat-send:active { background: var(--accent-strong); }
.chat-send[disabled] { opacity: 0.55; cursor: default; }
.chat-status {
  margin: 0;
  min-height: 1em;
  font-size: 0.8rem;
  color: #8f4608;
}
.chat-status:empty { display: none; }

.sheet-title {
  margin: 0 0 10px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #8f4608;
  letter-spacing: 0.01em;
}

.schedule-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.schedule-empty {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(231, 162, 95, 0.16);
  font-size: 0.9rem;
}
.schedule-day + .schedule-day {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(143, 70, 8, 0.16);
}
.schedule-day-title {
  margin: 0 0 6px;
  font-size: 0.92rem;
  font-weight: 700;
  color: #b8661f;
}
.schedule-item {
  display: flex;
  gap: 9px;
  padding: 8px 11px;
  border-radius: 12px;
  background: rgba(231, 162, 95, 0.14);
  font-size: 0.9rem;
  line-height: 1.3;
}
.schedule-item .time {
  flex: 0 0 auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #8f4608;
}
.schedule-item .label {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #b8661f;
  margin-bottom: 1px;
}
.schedule-item.current {
  background: rgba(231, 162, 95, 0.42);
  box-shadow: inset 0 0 0 1px rgba(143, 70, 8, 0.2);
}
.schedule-item.next { background: rgba(231, 162, 95, 0.26); }

.sheet-footer {
  margin: 16px 0 0;
  text-align: center;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--ink-soft);
}
.sheet-footer a { color: #8f4608; }

@media (min-width: 560px) {
  .sheet { left: 50%; right: auto; width: min(520px, 100%); transform: translate(-50%, 101%); }
  .app.sheet-open .sheet { transform: translate(-50%, 0); }
  .sheet-links { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ── Install bar ─────────────────────────────────────────────────── */

.install-bar {
  position: absolute;
  left: calc(12px + var(--safe-l));
  right: calc(12px + var(--safe-r));
  top: calc(12px + var(--safe-t));
  z-index: 8;
  padding: 12px 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--panel), var(--panel-2));
  color: var(--ink);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.install-bar[hidden] { display: none; }
.install-text {
  flex: 1 1 180px;
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.35;
}
.install-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.install-actions .text-btn { padding: 8px 14px; font-size: 0.84rem; }
.install-actions #installDismiss {
  background: transparent;
  color: var(--ink-soft);
  font-weight: 600;
}

@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
  .install-bar { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.05s !important; }
}
