/* МК ТВ — dark theme, sized for older eyes: big type, big targets, AAA contrast */

:root {
  --bg: #0E1116;
  --surface: #1A2230;
  --surface-pressed: #2A3548;
  --border: #4A5568;
  --text: #F5F7FA;        /* ~15:1 on --bg */
  --text-soft: #C7D0DC;   /* ~9:1 on --bg  */
  --accent: #E3001B;
  --focus: #7FB5FF;
}

* { box-sizing: border-box; }

html { font-size: 100%; } /* respect system text size — all sizes in rem */

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.25rem; /* 20px base */
  line-height: 1.4;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- Grid view ---------- */

#grid-view {
  max-width: 34rem;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

header { text-align: center; padding: 0.5rem 0 1rem; }

h1 { font-size: 2.25rem; margin: 0; letter-spacing: 0.05em; }

.subtitle { color: var(--text-soft); margin: 0.25rem 0 0; font-size: 1.125rem; }

#status-message {
  text-align: center;
  color: var(--text-soft);
  font-size: 1.25rem;
  padding: 1rem;
  margin: 0;
}

#status-message.error { color: var(--text); }

.channel-section { margin-bottom: 1.5rem; }

.section-heading {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 1.25rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--border);
}

.channel-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.channel-button {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  width: 100%;
  min-height: 5.5rem; /* 88px */
  padding: 1rem 1.25rem;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 1rem;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.channel-button:active {
  background: var(--surface-pressed);
  border-color: var(--text-soft);
}

.channel-button:focus-visible,
#back-button:focus-visible,
#reload-button:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 2px;
}

.channel-logo {
  width: 4rem;
  height: 4rem;
  flex-shrink: 0;
  border-radius: 0.75rem;
}

.channel-text { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }

.channel-name {
  font-size: 1.75rem; /* 28px */
  font-weight: 700;
  overflow-wrap: anywhere;
}

.channel-status {
  font-size: 1.125rem;
  color: var(--text-soft);
}

.channel-status.direct { color: #8CE99A; } /* label text carries the meaning; colour is a bonus */

.channel-last {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 1rem;
  color: var(--text-soft);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.25rem 0.5rem;
}

footer {
  text-align: center;
  color: var(--text-soft);
  font-size: 1rem;
  padding-top: 2rem;
}

#reload-button {
  display: block;
  margin: 1rem auto;
  min-height: 4rem;
  padding: 1rem 2rem;
  font: inherit;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 1rem;
  cursor: pointer;
}

/* ---------- Player view ---------- */

#player-view {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#player-view[hidden] { display: none; }

.player-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
}

#back-button {
  min-height: 4rem;
  padding: 0.75rem 1.5rem;
  font: inherit;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 1rem;
  cursor: pointer;
  flex-shrink: 0;
}

#back-button:active { background: var(--surface-pressed); }

#player-channel-name {
  font-size: 1.5rem;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#player-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#player-video {
  flex: 1;
  width: 100%;
  min-height: 0;
  background: #000;
}

/* Radio: station card fills the stage, the video shrinks to a control strip
   so the native play/pause/AirPlay controls stay visible and tappable. */
#player-stage.stage-radio #player-video {
  flex: 0 0 auto;
  height: 4.5rem;
  background: var(--surface);
}

#radio-poster {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: var(--bg);
  padding: 1.5rem;
  text-align: center;
}

#radio-poster[hidden] { display: none; }

#radio-poster-logo {
  width: 40vw;
  max-width: 12rem;
  height: auto;
  border-radius: 1.5rem;
}

#radio-poster-name {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}

#radio-poster-tag {
  font-size: 1.25rem;
  margin: 0;
  color: var(--text-soft);
}

#airplay-hint,
#player-message {
  margin: 0;
  padding: 1rem 1.25rem;
  font-size: 1.25rem;
  text-align: center;
  color: var(--text);
  background: var(--surface);
}

.airplay-glyph { font-size: 1.5rem; }

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  #player-view { animation: fade-in 200ms ease-out; }
  @keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
}
