/* Begambeli Radio
   ----------------------------------------------------------------------------
   A photograph, and glass floating on top of it. Everything that is not the
   photograph or the video is a frosted panel: white type, pill shapes, system
   font, one warm gradient. The station's own colour — bougainvillea magenta,
   which is what begambeli means — is the live dot and the hot end of that
   gradient, and it is the only hue that carries meaning.
   -------------------------------------------------------------------------- */

:root {
  --sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;

  --ink: #0a0a0a;
  --glass: rgba(12, 9, 14, 0.55);
  --glass-solid: rgba(12, 9, 14, 0.88);
  --edge: rgba(255, 255, 255, 0.18);

  --live: #e0407a;
  --warm-a: #e0407a;
  --warm-b: #f0546a;
  --warm-c: #f99c00;

  --text: #fff;
  --text-2: rgba(255, 255, 255, 0.7);
  --text-3: rgba(255, 255, 255, 0.55);

  --lift: drop-shadow(0 1px 6px rgba(0, 0, 0, 0.5));
  --gap: clamp(1rem, 3.5vw, 1.75rem);
}

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

html {
  background: var(--ink);
}

body {
  margin: 0;
  min-height: 100dvh;
  /* Transparent on purpose. body does not create a stacking context, so the
     backdrop's negative z-index puts it in the root context — behind an opaque
     body background, which would hide the photograph entirely. The dark base
     lives on html instead. */
  background: transparent;
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body.is-closed {
  overflow: hidden;
}

h1,
h2,
p {
  margin: 0;
}

/* Swap assets/bg.jpg for a photograph and the whole page re-tunes to it. The
   scrim is a separate layer so it keeps working whatever goes underneath. */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-color: var(--ink);
  background-image: url(../bg.jpg);
  background-size: cover;
  background-position: 50% 50%;
  background-repeat: no-repeat;
}

.backdrop::after {
  content: '';
  position: absolute;
  inset: 0;
  /* Two layers: a flat darkening so white type is legible over any photograph,
     and a vertical gradient that weights the top and bottom where the UI sits. */
  background:
    linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.42) 0%,
      rgba(0, 0, 0, 0.06) 40%,
      rgba(0, 0, 0, 0.6) 100%
    ),
    rgba(0, 0, 0, 0.12);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Two rings so focus reads against both the dark glass and a bright photo. */
:focus-visible {
  outline: 2px solid var(--live);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.35);
}

.glass {
  background: var(--glass);
  backdrop-filter: blur(40px) saturate(150%);
  -webkit-backdrop-filter: blur(40px) saturate(150%);
  border: 1px solid var(--edge);
  box-shadow:
    0 8px 40px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

/* Firefox with backdrop-filter disabled would otherwise show unreadable text
   over the photograph. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass {
    background: var(--glass-solid);
  }
}

/* -- the front door ------------------------------------------------------- */

.gate {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: var(--gap);
  text-align: center;
}

.gate[hidden] {
  display: none;
}

.gate__inner {
  max-width: 30rem;
}

.gate__title {
  font-size: clamp(2rem, 8vw, 3.25rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.02em;
  filter: drop-shadow(0 4px 24px rgba(0, 0, 0, 0.55));
}

.gate__lede {
  margin-top: 0.9rem;
  color: var(--text-2);
  filter: var(--lift);
}

.gate__button {
  margin-top: 1.75rem;
  padding: 0.85rem 2.25rem;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #0a0a0a;
  background: rgba(255, 255, 255, 0.92);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  transition: transform 150ms ease, background 150ms ease;
}

.gate__button:hover:not(:disabled) {
  background: #fff;
  transform: scale(1.04);
}

.gate__button:active:not(:disabled) {
  transform: scale(0.96);
}

.gate__button:disabled {
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--edge);
  cursor: progress;
}

.gate__now {
  margin-top: 1.1rem;
  font-size: 0.8125rem;
  color: var(--text-3);
  filter: var(--lift);
}

/* -- the station ---------------------------------------------------------- */

.station {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: var(--gap);
  min-height: 100dvh;
  padding: var(--gap);
}

/* Before anyone tunes in there is no player and nothing playing, so an empty
   video panel and a dead set of controls would just sit behind the gate. The
   masthead stays — it is honestly reporting "off air". */
.station[inert] .stage,
.station[inert] .deck {
  display: none;
}

/* Grid and flex children default to a min-content minimum. The video's is
   derived from its 200px floor, which without this pushes the whole page wider
   than a narrow phone. */
.station,
.station > *,
.topbar,
.topbar > *,
.deck,
.deck__head,
.now {
  min-width: 0;
}

/* Three tracks rather than space-between, so the live pill sits on the true
   centre of the page and not merely between two items of unequal width. */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.75rem;
  align-items: center;
}

.topbar > :last-child {
  justify-self: end;
}

.signal {
  display: inline-flex;
  gap: 0.5em;
  align-items: center;
  padding: 0.35rem 0.85rem 0.35rem 0.7rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 999px;
  filter: var(--lift);
  white-space: nowrap;
}

.signal__dot {
  position: relative;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  flex: none;
}

.signal[data-state='live'] .signal__dot {
  background: var(--live);
  box-shadow: 0 0 10px rgba(224, 64, 122, 0.9);
}

.signal[data-state='live'] .signal__dot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--live);
  animation: ping 1.9s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {
  75%,
  100% {
    opacity: 0;
    transform: scale(2.4);
  }
}

.homelink {
  display: inline-flex;
  gap: 0.4em;
  align-items: center;
  padding: 0.35rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  border-radius: 999px;
  filter: var(--lift);
  white-space: nowrap;
  transition: opacity 150ms ease;
}

.homelink:hover {
  opacity: 0.75;
}

.homelink svg {
  opacity: 0.6;
}

/* -- the middle: the photograph, and the station's name on it ------------- */

.stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 1rem 0;
}

/* The name is the only thing standing on the bare photograph, and a
   photograph can be any brightness — this frame has sunlit stone right where
   the text falls. A soft pool of shade under the middle keeps it legible
   whatever gets swapped in, without flattening the picture everywhere else. */
.stage::before {
  content: '';
  position: absolute;
  pointer-events: none;
  /* The ellipse fills its box, so the fade finishes exactly at the edges and
     there is no rim. Sized smaller than this it reaches transparent partway
     across and reads as a smudge on the photograph, which is very obvious on
     a short screen. Kept inside the stage: this element is positioned, so
     anything spilling out of it would paint over the deck below. */
  inset: 0;
  background: radial-gradient(
    100% 78% at 50% 50%,
    rgba(0, 0, 0, 0.72) 0%,
    rgba(0, 0, 0, 0.62) 32%,
    rgba(0, 0, 0, 0.38) 56%,
    rgba(0, 0, 0, 0.15) 80%,
    transparent 100%
  );
}

.hero {
  position: relative;
  font-size: clamp(2.25rem, 8vw, 4.75rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.035em;
  text-align: center;
  text-wrap: balance;
  filter: drop-shadow(0 6px 30px rgba(0, 0, 0, 0.6));
}

.window__glass {
  position: relative;
  /* Width from the container, height from the ratio, with a hard floor so the
     player clears YouTube's 200x200 minimum at any width. Stating the width
     explicitly stops the ratio being solved backwards off the min-height. */
  width: 100%;
  aspect-ratio: 16 / 9;
  min-width: 200px;
  min-height: 200px;
  background: #000;
}

.window__glass > div,
.window__glass iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* -- the deck ------------------------------------------------------------- */

.deck {
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: 1rem 1.15rem 1.1rem;
  border-radius: 22px;
}

.deck__head {
  display: flex;
  gap: 1.15rem;
  align-items: stretch;
}

/* 356px wide is exactly 200px tall at 16:9 — the smallest the player is
   allowed to be, which is the right size for a sleeve. */
.deck__art {
  flex: none;
  width: 356px;
  max-width: 100%;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.deck__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  min-width: 0;
}

.deck__row {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  min-width: 0;
}

.loop {
  flex: 1 1 auto;
  min-width: 0;
}

.now {
  min-width: 0;
}

.now__title {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.now__artist {
  font-size: 0.8125rem;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deck__toggle {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: #0a0a0a;
  background: rgba(255, 255, 255, 0.92);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease;
}

.deck__toggle:hover {
  background: #fff;
  transform: scale(1.06);
}

.deck__toggle:active {
  transform: scale(0.94);
}

/* One button, two glyphs — swapped on state so the label can stay a real
   accessible name rather than text nodes that would overwrite the icons. */
.deck__toggle .icon-pause {
  display: none;
}

.deck__toggle[aria-pressed='true'] .icon-play {
  display: none;
}

.deck__toggle[aria-pressed='true'] .icon-pause {
  display: block;
}

.deck__volume {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  width: 100%;
  max-width: 11rem;
}

.deck__volume svg {
  flex: none;
  opacity: 0.6;
}

/* -- the loop: the whole broadcast, and where it has got to --------------- */

.rail {
  position: relative;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.rail__fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--warm-a), var(--warm-b) 55%, var(--warm-c));
  transition: width 1s linear;
}

/* Track boundaries, so the loop reads as a sequence rather than one long bar. */
.rail__segment {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.3);
}

/* The fill is a span too, so :first-of-type would match that instead. The
   segment right after it is the one sitting at the very start of the loop. */
.rail__fill + .rail__segment {
  border-left-color: transparent;
}

.rail__tick {
  position: absolute;
  top: 50%;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.22), 0 2px 8px rgba(0, 0, 0, 0.5);
  transition: left 1s linear;
}

.loop__meta {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 0.55rem;
  font-size: 0.75rem;
  color: var(--text-3);
}

.loop__time {
  font-variant-numeric: tabular-nums;
  flex: none;
}

.loop__caption {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deck__note {
  margin-top: 0.85rem;
  padding-top: 0.8rem;
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--text-3);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.notice {
  margin-top: 0.85rem;
  padding: 0.6rem 0.8rem;
  font-size: 0.8125rem;
  border-radius: 12px;
  background: rgba(224, 64, 122, 0.16);
  border: 1px solid rgba(224, 64, 122, 0.4);
}

.notice[hidden] {
  display: none;
}

/* -- one control, styled by hand -------------------------------------------- */

input[type='range'] {
  flex: 1 1 auto;
  min-width: 0;
  height: 18px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
}

input[type='range']::-moz-range-track {
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
}

input[type='range']::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  margin-top: -4.5px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  -webkit-appearance: none;
  appearance: none;
}

input[type='range']::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* -- narrow --------------------------------------------------------------- */

/* Below the width where a 356px sleeve and a column of text can sit side by
   side, the bar stacks and the artwork spans it. */
@media (max-width: 44rem) {
  .deck__head {
    flex-direction: column;
  }

  .deck__art {
    width: 100%;
  }
}

@media (max-width: 34rem) {
  .homelink span {
    display: none;
  }

  .homelink {
    padding: 0.35rem 0.55rem;
  }

  .deck__volume {
    width: 4.5rem;
  }
}

/* The "On air" label always stays. It is the whole status, it fits at 320px,
   and a lone dot in a pill says nothing. */

/* -- stillness ------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
