/* Kuressaare Pereraadio — the radio as an app of its own (/raadio/).
   The radio page below is copied from the Pildiraadio app (/app/app.css, "Radio page"),
   so the two look the same; a change to one should go to the other too. */
:root {
  --accent: #e7a25f;
  --accent-strong: #d98b46;
  --accent-light: #f0b97a;
  --ink: #171310;
  --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: #fffaf4;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  overscroll-behavior: none;
}
html.is-dark, html.is-dark body { background: #1d140c; }

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

/* ── Radio page ──────────────────────────────────────────────────── */

/* A page of its own over the picture (and over the install bar), with the
   Kuressaare Pereraadio audio stream: one big button, and under it what the
   website shows under its live player. Two backgrounds, "Hele" (the default)
   and "Tume", chosen in the settings menu under the gear at the top right.
   Every colour on the page comes from the --rp-* values below, so the light
   theme only redefines those. */
.radio-page {
  /* Plain gradient, no orange glow: a glow around the orange button blurred its
     edge (the user's complaint). */
  --rp-bg: linear-gradient(180deg, #1d140c 0%, #0b0805 100%);
  --rp-strong: #fff;            /* title, programme names */
  --rp-text: #e8d9c8;           /* status, label text */
  --rp-extra: #d4bfa8;          /* "(alates 20:00)", "kell 21:00" */
  --rp-label: var(--accent-light);
  --rp-logo: #f0b97a;
  --rp-logo-opacity: 0.1;
  --rp-chip: rgba(255, 247, 237, 0.12);
  --rp-chip-line: rgba(255, 247, 237, 0.16);
  --rp-chip-ink: #e8d9c8;
  --rp-menu-bg: #2a1d12;
  --rp-menu-line: rgba(255, 247, 237, 0.14);
  /* The play button: the background's own colour, raised by a dark shadow
     below right and a light one above left (design 8, "Pehme reljeef"). */
  --rp-btn: #1a120b;
  --rp-btn-icon: #f0a35a;
  --rp-btn-out: 9px 9px 20px rgba(0, 0, 0, 0.7), -7px -7px 18px rgba(255, 220, 180, 0.07);
  --rp-btn-in: inset 7px 7px 16px rgba(0, 0, 0, 0.7), inset -6px -6px 14px rgba(255, 220, 180, 0.06);

  /* Fixed to the screen rather than to .app: .app can end up scrolled (its
     off-screen sheet gives it room to), and the page must cover it all the same. */
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: calc(12px + var(--safe-t)) calc(14px + var(--safe-r)) calc(16px + var(--safe-b)) calc(14px + var(--safe-l));
  background: var(--rp-bg);
  color: var(--rp-text);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.radio-page[hidden] { display: none; }

.radio-page.is-light {
  --rp-bg: linear-gradient(180deg, #fffaf4 0%, #ffe9cf 100%);
  --rp-strong: #171310;
  --rp-text: #4a3a2c;
  --rp-extra: #6b5442;
  --rp-label: #b8661f;
  /* The logo's blue, washed out. A solid pale blue rather than the real blue
     made faint: faint blue over this warm cream mixes to a muddy grey. */
  --rp-logo: #d2def3;
  --rp-logo-opacity: 1;
  --rp-chip: rgba(23, 19, 16, 0.07);
  --rp-chip-line: rgba(23, 19, 16, 0.1);
  --rp-chip-ink: #4a3a2c;
  --rp-menu-bg: #fffdf9;
  --rp-menu-line: rgba(23, 19, 16, 0.1);
  --rp-btn: #fff4e7;
  --rp-btn-icon: #e2852f;
  --rp-btn-out: 10px 10px 24px rgba(166, 112, 62, 0.32), -10px -10px 24px rgba(255, 255, 255, 0.95);
  --rp-btn-in: inset 8px 8px 18px rgba(166, 112, 62, 0.3), inset -8px -8px 18px rgba(255, 255, 255, 0.9);
}


/* The Pereraadio logo, faint, standing on the bottom edge like a horizon. It
   is a mask, so one picture takes the colour of either background. */
.radio-page::before {
  content: '';
  position: fixed;
  left: 50%;
  bottom: 0;
  width: min(94vw, 560px, 92vh);
  aspect-ratio: 1184 / 976;
  transform: translateX(-50%);
  background: var(--rp-logo);
  opacity: var(--rp-logo-opacity);
  -webkit-mask: url('icons/pereraadio-logo.png?v=1') center bottom / contain no-repeat;
  mask: url('icons/pereraadio-logo.png?v=1') center bottom / contain no-repeat;
  pointer-events: none;
  z-index: 0;
}
.radio-top,
.radio-body,
.radio-bottom { position: relative; z-index: 1; }

.radio-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 3;   /* above the body, so the settings menu opens over it */
}
.radio-title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 1.45rem;   /* bigger by the user's request; two lines on a phone */
  font-weight: 700;
  line-height: 1.15;
  color: var(--rp-strong);
  overflow-wrap: anywhere;
}

/* Settings: a half-transparent gear at the top right; the menu under it holds
   the background choice. */
.radio-settings {
  position: relative;
  flex: 0 0 auto;
}
.radio-gear {
  appearance: none;
  border: none;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--rp-strong);
  opacity: 0.5;
  cursor: pointer;
  transition: opacity 0.18s ease, background 0.18s ease;
}
.radio-gear svg { width: 26px; height: 26px; fill: currentColor; }
.radio-gear:active,
.radio-gear[aria-expanded="true"] { opacity: 0.85; background: var(--rp-chip); }

.radio-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  padding: 10px 12px 12px;
  border-radius: 16px;
  background: var(--rp-menu-bg);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3), inset 0 0 0 1px var(--rp-menu-line);
  white-space: nowrap;
}
.radio-menu[hidden] { display: none; }
.radio-menu-title {
  margin: 0 2px 8px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rp-label);
}

/* Hele | Tume: both choices in view, the current one in orange. */
.theme-switch {
  flex: 0 0 auto;
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--rp-chip);
  box-shadow: inset 0 0 0 1px var(--rp-chip-line);
}
.theme-opt {
  appearance: none;
  border: none;
  min-height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  background: transparent;
  color: var(--rp-chip-ink);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.theme-opt[aria-pressed="true"] {
  background: var(--accent);
  color: #2a1a0c;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
}

.radio-body {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* The button sits at a fixed height near the top, and the text flows under
     it. (Centring the whole group put the button lower whenever the programme
     names were short; the user wants it higher up.) */
  justify-content: flex-start;
  gap: 18px;
  padding: clamp(12px, 7vh, 64px) 0 16px;
  text-align: center;
}

.radio-play {
  position: relative;
  flex: 0 0 auto;
  width: 172px;
  height: 172px;
  /* "Pehme reljeef" (the user's pick from 20 designs on nupud.html): the
     button is the background's colour, raised off the page by its shadows,
     with an orange sign. While the radio plays it sinks in, so it reads as
     pressed down; a tap presses it in for a moment. Nothing moves or glows. */
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--rp-btn);
  color: var(--rp-btn-icon);
  box-shadow: var(--rp-btn-out);
  cursor: pointer;
  transition: box-shadow 0.18s ease;
}
.radio-play.is-playing,
.radio-play:active { box-shadow: var(--rp-btn-in); }
.radio-play svg { width: 88px; height: 88px; fill: currentColor; }
/* Only the sign and the shadows change; "Ühendan…" under the button says
   when it is still connecting. */

/* One line under the button for the status text. Fixed height, so nothing
   below it jumps when the text comes and goes. */
.radio-state {
  min-height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.radio-status {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--rp-text);
}
.radio-status:empty { display: none; }

/* The same lines as under the website's player: a small capitalised label,
   then the name, with the start time after it. */
.radio-shows {
  width: min(100%, 460px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.radio-show {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.35;
  color: var(--rp-text);
  overflow-wrap: anywhere;
}
.radio-show[hidden],
.radio-show:empty { display: none; }
.radio-show .label {
  display: block;
  margin-bottom: 3px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rp-label);
}
.radio-show .show-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--rp-strong);
}
/* What is on now (the programme, or the song in its place) is larger than
   what comes next. */
.radio-show.is-now .show-title {
  font-size: 1.5rem;
  line-height: 1.25;
}
.radio-show .show-extra {
  margin-left: 0.35rem;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--rp-extra);
  white-space: nowrap;   /* "kell 21:00" stays on one line */
}
.radio-show .np-prefix { font-size: 0.85em; font-weight: 500; }
/* A song with no name: just "muusika", in regular weight as on the website,
   but still larger than the next programme. */
.radio-show.is-now .show-title.np-unnamed { font-size: 1.3rem; font-weight: 400; }

/* The way over to the picture: the Pildiraadio app icon, small, on the right
   and lifted a little off the bottom edge. */
.radio-bottom {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  padding: 6px 0 28px;
}
.radio-switch {
  text-decoration: none;
  appearance: none;
  border: none;
  background: transparent;
  padding: 4px 8px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--rp-text);
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.radio-switch img {
  display: block;
  width: 44px;
  height: 44px;
  border-radius: 11px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.32), inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}
.radio-switch:active { background: var(--rp-chip); }

/* A phone on its side: button and text side by side, so both fit; the
   Pildiraadio icon sits in the bottom-right corner instead of a row of its own. */
@media (orientation: landscape) and (max-height: 520px) {
  .radio-body {
    display: grid;
    grid-template-columns: auto minmax(0, 460px);
    column-gap: 30px;
    row-gap: 8px;
    align-content: center;
    justify-content: center;
    padding: 12px 0 4px;
    text-align: left;
  }
  .radio-play { grid-column: 1; grid-row: 1 / span 2; align-self: center; width: 128px; height: 128px; }
  .radio-play svg { width: 64px; height: 64px; }
  .radio-shows { grid-column: 2; grid-row: 1; align-self: end; }
  .radio-state { grid-column: 2; grid-row: 2; justify-content: flex-start; }
  .radio-bottom {
    position: absolute;
    right: calc(14px + var(--safe-r));
    bottom: calc(26px + var(--safe-b));
    padding: 0;
  }
}


/* ── Install card (browser tab only) ─────────────────────────────── */

.install-card {
  position: relative;
  z-index: 2;
  margin: 12px auto 0;
  width: min(100%, 460px);
  padding: 10px 10px 10px 14px;
  border-radius: 16px;
  background: var(--rp-chip);
  box-shadow: inset 0 0 0 1px var(--rp-chip-line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.install-card[hidden] { display: none; }
.install-text {
  flex: 1 1 auto;
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.35;
  color: var(--rp-text);
}
.install-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 4px; }
.install-btn {
  appearance: none;
  border: none;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--accent);
  color: #2a1a0c;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}
.install-btn[hidden] { display: none; }
.install-btn:active { background: var(--accent-strong); }
.install-close {
  appearance: none;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  color: var(--rp-text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
  .install-card { display: none !important; }
}

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