/* Radio SKYE — style. Paleta: zieleń pola po zmroku + żółć rzepaku. */
:root {
  --bg: #0d1a15;
  --surface: #15271f;
  --surface-hi: #1d352a;
  --line: rgba(238, 242, 230, .13);
  --text: #eef2e6;
  --muted: #9bb0a2;
  --accent: #f6c619;
  --on-accent: #14200c;
  --danger: #ff8a65;

  --font-body: system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --font-title: ui-serif, "New York", "Iowan Old Style", Georgia, "Times New Roman", serif;

  --pad-x: 22px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}
body { overflow-x: hidden; overflow-y: auto; }
button { font: inherit; color: inherit; touch-action: manipulation; }

/* ---------- tło: rozmyta okładka ---------- */
.backdrop {
  position: fixed;
  inset: -20%;
  background-size: cover;
  background-position: center;
  filter: blur(70px) saturate(1.2);
  opacity: 0;
  transition: opacity .8s ease;
  pointer-events: none;
}
.backdrop.is-on { opacity: .3; }

/* ---------- układ ---------- */
.app {
  position: relative;
  height: 100dvh;
  min-height: 680px;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto minmax(140px, 1fr) auto auto auto auto;
  grid-template-areas: "top" "note" "stage" "meta" "controls" "admin" "footer";
  row-gap: 14px;
  padding:
    max(18px, env(safe-area-inset-top))
    max(var(--pad-x), env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom))
    max(var(--pad-x), env(safe-area-inset-left));
  max-width: 560px;
  margin: 0 auto;
}

.topbar { grid-area: top; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; }
.wordmark {
  margin: 0;
  font-family: var(--font-title);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.01em;
}

/* ---------- status ---------- */
.status {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 13px 7px 11px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 14px; font-weight: 600;
  color: var(--muted);
}
.status__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
[data-state="playing"] .status { color: var(--text); }
[data-state="playing"] .status__dot { background: var(--accent); animation: pulse 1.8s ease-in-out infinite; }
[data-state="connecting"] .status { color: var(--text); }
[data-state="connecting"] .status__dot {
  width: 12px; height: 12px; background: none;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
[data-state="offline"] .status { color: var(--danger); border-color: rgba(255, 138, 101, .4); }
[data-state="offline"] .status__dot { background: var(--danger); }

.demo-note {
  grid-area: note; margin: 0;
  padding: 9px 14px;
  border: 1px dashed rgba(246, 198, 25, .55);
  border-radius: 14px;
  color: var(--accent);
  font-size: 13.5px; line-height: 1.35;
}

/* ---------- okładka ---------- */
.stage { grid-area: stage; position: relative; min-height: 0; }
.stage__box { position: absolute; inset: 0; display: grid; place-items: center; container-type: size; }
.cover {
  position: relative;
  width: min(100%, 52vh);
  aspect-ratio: 1;
  border-radius: 30px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 34px 60px -26px rgba(0, 0, 0, .75), 0 0 0 1px var(--line);
  transition: transform .5s cubic-bezier(.2, .8, .2, 1), filter .4s ease;
}
@supports (width: 1cqw) { .cover { width: min(100cqw, 100cqh); } }
.cover__img, .cover__placeholder { position: absolute; inset: 0; width: 100%; height: 100%; }
.cover__placeholder { z-index: 0; }
.cover__img { z-index: 1; }
.cover__img { object-fit: cover; opacity: 1; transition: opacity .22s ease; }
.cover__img.is-swapping { opacity: 0; }
.cover__placeholder {
  display: grid; place-items: center;
  color: var(--accent);
  background: radial-gradient(120% 90% at 50% 20%, var(--surface-hi), var(--surface));
}
[data-state="offline"] .cover { filter: grayscale(1) brightness(.55); }
[data-state="playing"] .cover { transform: scale(1); }
[data-state="paused"] .cover, [data-state="ready"] .cover { transform: scale(.965); }

.toast {
  position: absolute; left: 50%; bottom: 10px;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 8px);
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(10, 20, 16, .92);
  border: 1px solid var(--line);
  font-size: 15px; font-weight: 600; text-align: center;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  animation: toast-in .22s ease-out;
  z-index: 2;
}
.toast[data-kind="error"] { border-color: rgba(255, 138, 101, .55); color: var(--danger); }

/* ---------- tytuł i wykonawca ---------- */
.meta { grid-area: meta; min-width: 0; }
.meta__title {
  margin: 0;
  font-family: var(--font-title);
  font-size: clamp(26px, 8.2vw, 34px);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -.012em;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  overflow: hidden;
  text-wrap: balance;
}
.meta__artist {
  margin: 6px 0 0;
  font-size: 18px; line-height: 1.3;
  color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-height: 1.3em;
}
[data-state="offline"] .meta__artist, .meta__artist.is-note { white-space: normal; font-size: 16px; }
.progress { margin-top: 16px; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); transform-origin: left center; transform: scaleX(0); }
.progress[hidden] { display: none; }

/* ---------- sterowanie (strefa kciuka) ---------- */
.controls { grid-area: controls; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 4px; align-items: start; }
.has-admin .controls { grid-template-columns: minmax(0, 1fr) 84px; }
.play, .skip {
  height: 84px; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .12s ease, background-color .2s ease, opacity .2s ease;
}
.play:active, .skip:active { transform: scale(.965); }

.play {
  gap: 14px; padding: 0 26px;
  border-radius: 42px;
  background: var(--accent); color: var(--on-accent);
  font-size: 22px; font-weight: 700; letter-spacing: -.005em; white-space: nowrap;
}
.play__icon svg, .skip__icon svg { width: 32px; height: 32px; display: block; }
.skip {
  width: 84px; border-radius: 42px;
  background: var(--surface-hi);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--text);
}
.skip:disabled { opacity: .38; cursor: default; }
.skip:disabled:active { transform: none; }
[data-state="offline"] .play { background: var(--surface-hi); color: var(--text); box-shadow: inset 0 0 0 1px rgba(255, 138, 101, .5); }

.eq { display: none; align-items: flex-end; gap: 3px; height: 22px; margin-left: 2px; }
.eq i { width: 4px; height: 100%; border-radius: 2px; background: currentColor; transform-origin: bottom; animation: eq 1s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -.35s; }
.eq i:nth-child(3) { animation-delay: -.7s; }
[data-state="playing"] .eq { display: inline-flex; }

.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3.5px solid currentColor; border-right-color: transparent; opacity: .85;
  animation: spin .8s linear infinite;
}

.hint { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; text-align: center; text-wrap: balance; }

/* ---------- focus ---------- */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* ---------- iPhone poziomo / niski ekran ---------- */
@media (orientation: landscape) and (max-height: 520px) {
  .app {
    max-width: none;
    min-height: 440px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
    grid-template-areas: "top top" "note note" "stage meta" "stage controls" "stage admin" "footer footer";
    column-gap: 28px; row-gap: 10px;
  }
  .meta { align-self: end; }
  .cover { width: min(100cqw, 100cqh); }
  .play, .skip { height: 72px; border-radius: 36px; }
  .skip { width: 72px; }
  .has-admin .controls { grid-template-columns: minmax(0, 1fr) 72px; }
}

/* ---------- animacje ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(246, 198, 25, .55); } 50% { box-shadow: 0 0 0 6px rgba(246, 198, 25, 0); } }
@keyframes eq { 0%, 100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
[hidden] { display: none !important; }
.admin-panel { grid-area:admin; width:100%; max-width:380px; margin:0 auto; text-align:center; }
.admin-link { border:0; background:transparent; color:#bad3c5; text-decoration:underline; cursor:pointer; padding:12px; font:inherit; font-size:14px; }
.admin-panel form { margin-top:12px; text-align:left; }
.admin-panel label { display:block; font-size:14px; margin:10px 0; }
.admin-panel input { display:block; width:100%; box-sizing:border-box; font:inherit; padding:12px; margin-top:6px; border:1px solid #547565; border-radius:10px; color:#fff; background:#142c22; }
.admin-submit { font:inherit; padding:12px 20px; border:0; border-radius:10px; background:#b6e99c; color:#10231c; cursor:pointer; }
#adminMessage { font-size:13px; line-height:1.5; color:#bad3c5; }
.station-controls { border:1px solid var(--line); border-radius:16px; padding:12px; background:var(--surface); }
.station-controls p { margin:0 0 10px; }
.station-actions { display:flex; flex-wrap:wrap; gap:8px; }
.station-actions button { flex:1 1 130px; min-height:46px; padding:10px; border:1px solid var(--line); border-radius:10px; cursor:pointer; }
.station-stop { color:var(--danger); background:#33241f; }
.station-start { color:var(--text); background:var(--surface-hi); }
.station-actions button:disabled { opacity:.4; cursor:default; }
.station-controls .station-note { font-size:12px; line-height:1.4; color:var(--muted); margin:10px 0 0; }
#stationMessage { font-size:13px; line-height:1.4; margin:8px 0 0; }
#stationMessage:empty, #adminMessage:empty { display:none; }
.volume-control { grid-column:1 / -1; padding:10px 14px 0; border:1px solid var(--line); border-radius:16px; background:rgba(21,39,31,.65); }
.volume-control__heading { display:flex; align-items:center; justify-content:space-between; gap:12px; color:var(--muted); font-size:13px; }
.volume-control output { color:var(--accent); font-weight:600; font-variant-numeric:tabular-nums; min-width:4ch; text-align:right; }
#volumeSlider { display:block; width:100%; height:38px; margin:0; padding:0; accent-color:var(--accent); cursor:pointer; touch-action:pan-y; }
#volumeSlider:disabled { cursor:default; opacity:.4; }
.volume-note { margin:0 0 12px; font-size:12px; line-height:1.4; color:var(--muted); }
.license-footer { grid-area:footer; display:flex; flex-wrap:wrap; align-items:baseline; justify-content:center; gap:4px 7px; border-top:1px solid var(--line); padding:13px 8px 2px; text-align:center; font-size:11px; line-height:1.5; }
.license-footer__label { color:var(--muted); }
.license-footer__name { color:var(--text); font-weight:600; letter-spacing:.02em; }
