/* Shared player chrome for every demo.
   Link this AFTER a page's own style.css. It styles the controls that
   _shared/audio.js binds by data attribute, so older pages pick it up without
   markup changes. New pages also use .chrome-bar for the padded bar.

   Theme per page by overriding the --chrome-* properties. Defaults are a dark
   frosted bar; every pairing below clears WCAG AA (most clear AAA). */

:root {
  --chrome-bg: rgb(12 19 29 / 0.78);
  --chrome-edge: rgb(244 239 230 / 0.16);
  --chrome-ink: #F4EFE6;          /* on --chrome-bg ≈ 15:1 */
  --chrome-muted: #C9CFD4;        /* on --chrome-bg ≈ 10:1 */
  --chrome-dim: #A3ADB5;          /* disabled text, still ≈ 7:1 */
  --chrome-primary-bg: #F4EFE6;
  --chrome-primary-ink: #142030;  /* ≈ 14:1 */
  --chrome-track: rgb(244 239 230 / 0.28);
  --chrome-fill: #F2CB8C;
  --chrome-focus: #F2CB8C;
  --chrome-sans: system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

/* ---- the bar ------------------------------------------------------------- */
.chrome-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--chrome-edge);
  border-radius: 1.6rem;
  background: var(--chrome-bg);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  backdrop-filter: blur(18px) saturate(1.1);
  color: var(--chrome-ink);
  font: 400 15px/1.3 var(--chrome-sans);
}
.chrome-bar .chrome-seek { flex: 1 1 12rem; }

/* ---- buttons --------------------------------------------------------------- */
button[data-ctl],
.chrome-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0 1.15rem;
  border: 1px solid var(--chrome-edge);
  border-radius: 999px;
  background: transparent;
  color: var(--chrome-ink);
  font: 500 15px/1 var(--chrome-sans);
  letter-spacing: 0.005em;
  text-transform: none;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
button[data-ctl]:hover:not(:disabled),
.chrome-btn:hover:not(:disabled) {
  border-color: var(--chrome-ink);
}
button[data-ctl="play"] {
  min-width: 5.5rem;
  text-align: center;
  background: var(--chrome-primary-bg);
  border-color: var(--chrome-primary-bg);
  color: var(--chrome-primary-ink);
}
button[data-ctl="play"]:hover:not(:disabled) {
  background: var(--chrome-fill);
  border-color: var(--chrome-fill);
  color: var(--chrome-primary-ink);
}
button[data-ctl="mute"][aria-pressed="true"] {
  border-color: var(--chrome-fill);
  color: var(--chrome-fill);
}
button[data-ctl]:disabled,
.chrome-btn:disabled {
  background: transparent;
  border-color: var(--chrome-edge);
  color: var(--chrome-dim);
  cursor: not-allowed;
}

/* ---- focus: always visible, never removed -------------------------------- */
button[data-ctl]:focus-visible,
.chrome-btn:focus-visible,
input[data-ctl="seek"]:focus-visible,
.chrome-back:focus-visible,
a.back:focus-visible {
  outline: 3px solid var(--chrome-focus);
  outline-offset: 3px;
}

/* ---- time ------------------------------------------------------------------ */
[data-ctl="time"] {
  min-width: 6.5em;
  color: var(--chrome-muted);
  font: 400 15px/1 var(--chrome-sans);
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}

/* ---- seek ------------------------------------------------------------------ */
input[data-ctl="seek"] {
  --p: 0;
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  height: 44px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
input[data-ctl="seek"]:disabled { cursor: not-allowed; }
input[data-ctl="seek"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--chrome-fill) calc(var(--p) * 100%), var(--chrome-track) calc(var(--p) * 100%));
}
input[data-ctl="seek"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--chrome-track); }
input[data-ctl="seek"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--chrome-fill); }
input[data-ctl="seek"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px; margin-top: -7px;
  border: 2px solid var(--chrome-primary-ink);
  border-radius: 50%;
  background: var(--chrome-primary-bg);
  box-shadow: none;
}
input[data-ctl="seek"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border: 2px solid var(--chrome-primary-ink);
  border-radius: 50%;
  background: var(--chrome-primary-bg);
  box-shadow: none;
}
input[data-ctl="seek"]:disabled::-webkit-slider-thumb { background: var(--chrome-dim); }
input[data-ctl="seek"]:disabled::-moz-range-thumb { background: var(--chrome-dim); }

/* ---- status copy ----------------------------------------------------------- */
.chrome-status {
  margin: 0;
  max-width: 34rem;
  color: var(--chrome-muted);
  font: 400 15px/1.45 var(--chrome-sans);
}
.chrome-status strong { color: var(--chrome-ink); font-weight: 600; }

/* ---- back link --------------------------------------------------------------- */
.chrome-back,
a.back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 1rem;
  border-radius: 999px;
  background: var(--chrome-bg);
  color: var(--chrome-ink);
  font: 500 15px/1 var(--chrome-sans);
  text-decoration: none;
  text-transform: none;
  letter-spacing: 0;
}
.chrome-back:hover,
a.back:hover { text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 640px) {
  .chrome-bar { flex-wrap: wrap; border-radius: 1.2rem; }
  .chrome-bar .chrome-seek { order: -1; flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  button[data-ctl], .chrome-btn { transition: none; }
}

@media (forced-colors: active) {
  .chrome-bar { border: 1px solid CanvasText; }
  button[data-ctl="play"] { forced-color-adjust: auto; }
}

/* ---- status banner (04/05+) --------------------------------------------------
   Always says something: "waiting", "ready", or "playing". The dot carries the
   state colour; the words carry the meaning, so colour is never the only cue. */
.chrome-banner {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  margin: 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--chrome-edge);
  border-radius: 1rem;
  background: var(--chrome-bg);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  backdrop-filter: blur(18px) saturate(1.1);
  color: var(--chrome-muted);
  font: 400 15px/1.45 var(--chrome-sans);
}
.chrome-banner::before {
  content: "";
  flex: none;
  width: 10px; height: 10px;
  margin-top: 0.42em;
  border-radius: 50%;
  background: var(--chrome-dim);
}
.chrome-banner p { margin: 0; }
.chrome-banner [data-ctl="status-title"] { color: var(--chrome-ink); font-weight: 600; }
.chrome-banner [data-ctl="status-body"]:empty { display: none; }
html[data-audio="ready"] .chrome-banner::before { background: #8FD3B0; }
html[data-audio="ready"][data-playing="yes"] .chrome-banner::before { background: var(--chrome-fill); }
html[data-audio="missing"] .chrome-banner::before,
html[data-audio="unplayable"] .chrome-banner::before,
html[data-audio="file-protocol"] .chrome-banner::before { background: #F0A86A; }

/* Visually hidden but read by screen readers. */
.chrome-sr {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

@media (forced-colors: active) {
  .chrome-banner { border: 1px solid CanvasText; }
}
