/* Alpenhallodris-Player – Stil
   Aufbau nach dem Gletscherpiraten-Player, Gestaltung neu: Espresso-Dock, goldene Bedienelemente.
   Nutzt die Farb-Tokens der Seite und bringt Ersatzwerte mit. */

.ah-dock,
.ah-tracks {
  --ah-bg: rgba(33, 24, 21, .9);
  --ah-text: var(--elfenbein, #FFF9EF);
  --ah-muted: rgba(244, 232, 213, .66);
  --ah-gold: var(--bernstein, #E5B653);
  --ah-gold-hell: #f6dfa2;
  --ah-gold-dunkel: #b8843a;
  --ah-on-gold: #2b1d10;
  --ah-line: rgba(221, 182, 111, .34);
  --ah-serif: var(--serif, Georgia, 'Times New Roman', serif);
  --ah-gap: clamp(12px, 1.8vw, 26px);
}

.ah-dock *,
.ah-tracks * { box-sizing: border-box; }

.ah-dock svg,
.ah-tracks svg { display: block; width: 20px; height: 20px; fill: currentColor; }
.ah-dock svg.ah-stroke,
.ah-tracks svg.ah-stroke { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.ah-visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Dock: dauerhaft unten links ---------- */

.ah-dock {
  position: fixed;
  z-index: 60;
  left: var(--ah-gap);
  bottom: calc(var(--ah-gap) + env(safe-area-inset-bottom, 0px));
  width: min(43rem, calc(100vw - 2 * var(--ah-gap)));
  overflow: hidden;
  color: var(--ah-text);
  font-family: var(--sans, system-ui, sans-serif);
  font-size: 15px;
  line-height: 1.35;
  background: var(--ah-bg);
  border: 1px solid var(--ah-line);
  border-radius: 16px;
  box-shadow: 0 26px 60px -26px rgba(0, 0, 0, .85), 0 2px 10px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 236, 190, .08);
  animation: ah-rein .9s 1.25s cubic-bezier(.22, .8, .24, 1) both;
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .ah-dock {
    --ah-bg: rgba(33, 24, 21, .88);
    -webkit-backdrop-filter: blur(18px) saturate(1.3);
    backdrop-filter: blur(18px) saturate(1.3);
  }
}
/* feine Goldkante oben */
.ah-dock::before {
  content: "";
  position: absolute; left: 18px; right: 18px; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(246, 223, 162, .7), transparent);
  pointer-events: none;
}

.ah-dock button { font: inherit; color: inherit; }
.ah-dock :focus-visible,
.ah-tracks :focus-visible { outline: 2px solid var(--ah-gold-hell); outline-offset: 2px; }

.ah-bar {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 10px 12px;
}

/* Bildfeld mit Note, beim Abspielen Pegelbalken */
.ah-art {
  position: relative;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 11px;
  color: var(--ah-gold);
  background: linear-gradient(150deg, rgba(229, 182, 83, .22), rgba(73, 48, 37, .55));
  box-shadow: inset 0 0 0 1px rgba(229, 182, 83, .38), inset 0 1px 0 rgba(255, 240, 200, .18);
}
.ah-art svg { width: 22px; height: 22px; transition: opacity .3s, transform .3s; }
.ah-art .ah-eq { position: absolute; height: 18px; gap: 3px; opacity: 0; transition: opacity .3s; }
.ah-art .ah-eq i { width: 3px; }
.ah-dock[data-status="playing"] .ah-art svg,
.ah-dock[data-status="loading"] .ah-art svg { opacity: 0; transform: scale(.7); }
.ah-dock[data-status="playing"] .ah-art .ah-eq,
.ah-dock[data-status="loading"] .ah-art .ah-eq { opacity: 1; }

.ah-controls { display: flex; align-items: center; gap: 2px; }

/* Abspielen/Pause: goldener Knopf mit Fortschrittsring */
.ah-toggle {
  position: relative;
  width: 50px; height: 50px;
  display: grid; place-items: center;
  padding: 0; border: 0; border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.ah-toggle::before {
  content: "";
  position: absolute; inset: 5px;
  border-radius: 50%;
  background: linear-gradient(140deg, #f6dfa2 0%, #E5B653 40%, #c08a3b 78%, #e8c372 100%);
  box-shadow: 0 6px 16px -6px rgba(229, 182, 83, .8), inset 0 1px 0 rgba(255, 250, 230, .7), inset 0 -2px 0 rgba(120, 80, 25, .3);
  transition: transform .3s cubic-bezier(.22, .8, .24, 1), box-shadow .3s;
}
.ah-toggle:hover::before { transform: scale(1.06); box-shadow: 0 8px 22px -6px rgba(229, 182, 83, .95), inset 0 1px 0 rgba(255, 250, 230, .7), inset 0 -2px 0 rgba(120, 80, 25, .3); }
.ah-toggle:active::before { transform: scale(.97); }
.ah-ring { position: absolute; inset: 0; width: 100% !important; height: 100% !important; transform: rotate(-90deg); fill: none !important; }
.ah-ring circle { fill: none; stroke-width: 2; }
.ah-ring-track { stroke: rgba(229, 182, 83, .18); }
.ah-ring-fill {
  stroke: var(--ah-gold-hell);
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset .25s linear;
}
.ah-dock[data-status="loading"] .ah-ring-fill {
  stroke-dasharray: 22 78;
  stroke-dashoffset: 0 !important;
  transform-origin: 24px 24px;
  animation: ah-spin 1s linear infinite;
}
.ah-toggle-icon { position: relative; color: var(--ah-on-gold); }
.ah-toggle-icon svg { width: 22px; height: 22px; }

.ah-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  padding: 0; border: 0; border-radius: 10px;
  background: transparent;
  color: var(--ah-gold);
  cursor: pointer;
  transition: color .25s, background-color .25s, transform .25s;
}
.ah-btn:hover { color: var(--ah-gold-hell); background: rgba(229, 182, 83, .1); }
.ah-btn[aria-expanded="true"].ah-more { color: var(--ah-gold-hell); background: rgba(229, 182, 83, .16); }

/* Titel, Zeit und Tonwelle */
.ah-info { min-width: 0; display: grid; gap: 5px; padding-left: 12px; border-left: 1px solid rgba(221, 182, 111, .22); }
.ah-info-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; min-width: 0; }
.ah-title {
  margin: 0;
  min-width: 0;
  font-family: var(--ah-serif);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: .005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ah-time { flex: none; font-size: .74rem; color: var(--ah-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ah-dock[data-status="error"] .ah-time { color: var(--ah-text); }

.ah-wave {
  --ah-p: 0;
  --ah-hover: 0;
  position: relative;
  height: 26px;
  border-radius: 4px;
}
.ah-wave-layer { position: absolute; inset: 0; pointer-events: none; }
.ah-wave-layer svg { width: 100% !important; height: 100% !important; }
.ah-wave-base { color: rgba(229, 182, 83, .28); }
.ah-wave-hover { color: rgba(246, 223, 162, .45); clip-path: inset(0 calc((1 - var(--ah-hover)) * 100%) 0 0); opacity: 0; transition: opacity .2s; }
.ah-wave:hover .ah-wave-hover { opacity: 1; }
.ah-wave-played {
  color: var(--ah-gold);
  clip-path: inset(0 calc((1 - var(--ah-p)) * 100%) 0 0);
  transition: clip-path .25s linear;
  filter: drop-shadow(0 0 4px rgba(229, 182, 83, .45));
}
.ah-dock[data-status="playing"] .ah-wave-played { color: #ecc56a; }
.ah-seek {
  position: absolute; inset: -6px 0; z-index: 1;
  width: 100%; height: calc(100% + 12px);
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.ah-wave:has(.ah-seek:focus-visible) { outline: 2px solid var(--ah-gold-hell); outline-offset: 3px; }

/* Lautstärke */
.ah-tools { display: flex; align-items: center; gap: 2px; }
.ah-volume { display: flex; align-items: center; gap: 2px; margin-right: 4px; }
.ah-vol {
  --ah-v: .85;
  --ah-fill: calc(var(--ah-v) * 100%);
  -webkit-appearance: none; appearance: none;
  width: 64px; height: 22px; margin: 0;
  background: transparent;
  cursor: pointer;
}
.ah-vol::-webkit-slider-runnable-track {
  height: 3px; border-radius: 2px;
  background: linear-gradient(to right, var(--ah-gold) var(--ah-fill), rgba(244, 232, 213, .18) var(--ah-fill));
}
.ah-vol::-moz-range-track { height: 3px; border-radius: 2px; background: rgba(244, 232, 213, .18); }
.ah-vol::-moz-range-progress { height: 3px; border-radius: 2px; background: var(--ah-gold); }
.ah-vol::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px; margin-top: -5px;
  border: 0; border-radius: 50%;
  background: var(--ah-gold-hell);
  box-shadow: 0 0 0 3px rgba(33, 24, 21, .9), 0 0 8px rgba(229, 182, 83, .6);
}
.ah-vol::-moz-range-thumb {
  width: 13px; height: 13px; border: 0; border-radius: 50%;
  background: var(--ah-gold-hell);
  box-shadow: 0 0 0 3px rgba(33, 24, 21, .9), 0 0 8px rgba(229, 182, 83, .6);
}
.ah-no-volume .ah-vol { display: none; }

.ah-collapse svg { transition: transform .35s cubic-bezier(.22, .8, .24, 1); }

/* Pegelbalken als Lebenszeichen */
.ah-eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; flex: none; }
.ah-eq i { width: 3px; height: 100%; background: var(--ah-gold); border-radius: 1px; transform-origin: bottom; transform: scaleY(.3); }
.ah-eq i:nth-child(2) { transform: scaleY(.6); }
.ah-eq i:nth-child(3) { transform: scaleY(.45); }
.ah-eq i:nth-child(4) { transform: scaleY(.7); }
[data-status="playing"] .ah-eq i { animation: ah-eq 1.1s ease-in-out infinite; }
[data-status="playing"] .ah-eq i:nth-child(2) { animation-duration: .8s; animation-delay: -.3s; }
[data-status="playing"] .ah-eq i:nth-child(3) { animation-duration: 1.3s; animation-delay: -.6s; }
[data-status="playing"] .ah-eq i:nth-child(4) { animation-duration: .95s; animation-delay: -.15s; }

/* ---------- Titelauswahl ---------- */

.ah-panel {
  border-bottom: 1px solid rgba(221, 182, 111, .22);
  padding: 14px 12px 8px;
  max-height: min(24rem, 55vh);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.ah-panel[hidden] { display: none; }
.ah-panel-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 0 6px 8px;
  font-size: .7rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ah-gold);
}
.ah-panel-head span:last-child { letter-spacing: .04em; font-weight: 500; text-transform: none; color: var(--ah-muted); }

.ah-list { list-style: none; margin: 0; padding: 0; }
.ah-list-item {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: 1.9rem minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  border: 0; border-radius: 9px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color .2s;
}
.ah-list-item:hover { background: rgba(229, 182, 83, .08); }
.ah-list-no { font-size: .74rem; color: var(--ah-muted); font-variant-numeric: tabular-nums; }
.ah-list-text { min-width: 0; display: grid; }
.ah-list-title { font-family: var(--ah-serif); font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ah-list-note { font-size: .76rem; color: var(--ah-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ah-list-time { font-size: .76rem; color: var(--ah-muted); font-variant-numeric: tabular-nums; }
.ah-list-now { display: none; }
.ah-list-item[aria-current="true"] { background: rgba(229, 182, 83, .12); }
.ah-list-item[aria-current="true"]::before {
  content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 2px; border-radius: 1px; background: var(--ah-gold);
}
.ah-list-item[aria-current="true"] .ah-list-title { color: var(--ah-gold); }
.ah-dock:not([data-status="idle"]) .ah-list-item[aria-current="true"] .ah-list-now { display: inline-flex; }
.ah-dock:not([data-status="playing"]) .ah-list-now .ah-eq { opacity: .45; }

/* ---------- Eingeklappt: nur Abspielen, Titel, Ausklappen ---------- */

.ah-dock.is-collapsed { width: auto; max-width: min(19rem, calc(100vw - 2 * var(--ah-gap))); border-radius: 999px; }
.ah-dock.is-collapsed::before { left: 30px; right: 30px; }
.ah-dock.is-collapsed .ah-bar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; padding: 6px 6px 6px 6px; }
.ah-dock.is-collapsed .ah-art,
.ah-dock.is-collapsed .ah-prev,
.ah-dock.is-collapsed .ah-next,
.ah-dock.is-collapsed .ah-wave,
.ah-dock.is-collapsed .ah-volume,
.ah-dock.is-collapsed .ah-more { display: none; }
.ah-dock.is-collapsed .ah-info { border-left: 0; padding-left: 2px; gap: 0; }
.ah-dock.is-collapsed .ah-info-row { flex-direction: column; align-items: flex-start; gap: 0; }
.ah-dock.is-collapsed .ah-title { font-size: .92rem; max-width: 11rem; }
.ah-dock.is-collapsed .ah-collapse { border-radius: 50%; }
.ah-dock.is-collapsed .ah-collapse svg { transform: rotate(180deg); }

/* ---------- Titelliste im Seiteninhalt (für den Bereich „Hörproben“) ---------- */

.ah-tracks { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ah-line); }
.ah-track { position: relative; border-bottom: 1px solid var(--ah-line); }
.ah-track-btn {
  width: 100%;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 16px 4px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ah-track-icon {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  transition: background-color .2s, color .2s, border-color .2s;
}
.ah-track-btn:hover .ah-track-icon { border-color: var(--ah-gold); color: var(--ah-gold); }
.ah-track[data-state="playing"] .ah-track-icon,
.ah-track[data-state="loading"] .ah-track-icon { background: var(--ah-gold); border-color: var(--ah-gold); color: var(--ah-on-gold); }
.ah-track[data-state="paused"] .ah-track-icon { border-color: var(--ah-gold); color: var(--ah-gold); }
.ah-track-text { min-width: 0; display: grid; gap: 2px; }
.ah-track-title { font-family: var(--ah-serif); font-size: 1.12rem; display: flex; align-items: center; gap: 10px; }
.ah-track-note { font-size: .88rem; opacity: .75; }
.ah-track-time { font-size: .86rem; opacity: .75; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ah-track .ah-eq { display: none; }
.ah-track[data-state="playing"] .ah-eq,
.ah-track[data-state="paused"] .ah-eq { display: inline-flex; }
.ah-track[data-state="paused"] .ah-eq { opacity: .45; }
.ah-track-wave { position: relative; display: block; height: 22px; margin-top: 8px; max-width: 420px; }
.ah-track-wave > span { position: absolute; inset: 0; }
.ah-track-wave svg { width: 100% !important; height: 100% !important; }
.ah-track-wave-base { color: rgba(229, 182, 83, .25); }
.ah-track-wave-played { color: var(--ah-gold); clip-path: inset(0 calc((1 - var(--ah-p, 0)) * 100%) 0 0); transition: clip-path .25s linear; }
.ah-track[data-state="playing"] .ah-track-wave-played { filter: drop-shadow(0 0 4px rgba(229, 182, 83, .55)); }
.ah-track-bar {
  position: absolute; left: 0; bottom: -1px;
  height: 2px; width: calc(var(--ah-p, 0) * 100%);
  background: var(--ah-gold);
  transition: width .25s linear;
}

/* ---------- Schmale Bildschirme ---------- */

@media (max-width: 760px) {
  .ah-art { display: none; }
  .ah-volume { display: none; }
}

@media (max-width: 600px) {
  .ah-dock { left: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); width: calc(100vw - 20px); }
  .ah-bar { gap: 8px; padding: 8px 6px 8px 8px; }
  .ah-prev { display: none; }
  .ah-info { padding-left: 8px; }
  .ah-btn { width: 42px; height: 42px; }
  .ah-dock.is-collapsed { max-width: min(17rem, calc(100vw - 20px)); }
  .ah-dock.is-collapsed .ah-title { max-width: 9.5rem; }
}

@media (pointer: coarse) {
  .ah-btn { width: 44px; height: 44px; }
}

/* ---------- Bewegung ---------- */

@keyframes ah-rein { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }
@keyframes ah-eq { 0%, 100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }
@keyframes ah-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .ah-dock { animation: none; }
  .ah-ring-fill, .ah-track-bar, .ah-track-icon, .ah-wave-played, .ah-collapse svg { transition: none; }
  [data-status="playing"] .ah-eq i { animation: none; }
  .ah-dock[data-status="loading"] .ah-ring-fill { animation: none; stroke-dasharray: 3 3; }
}

@media (forced-colors: active) {
  .ah-dock { border: 1px solid CanvasText; }
  .ah-ring-fill, .ah-eq i, .ah-track-bar { stroke: Highlight; background: Highlight; }
  .ah-wave-played { color: Highlight; }
}
