/* Ambient music button and panel (templates/_ambient.html, static/js/ambient.js). Same gold-on-dark as Liora's
   emblems; sits in the bottom-right corner of every page, above everything but modals. */
.ambient {
    --amb-gold: #ffb800;
    --amb-gold-soft: rgba(255, 184, 0, 0.35);
    --amb-bg: rgba(22, 17, 10, 0.88);
    position: fixed; right: 16px; bottom: 16px; z-index: 150;
    display: flex; align-items: flex-end; gap: 8px;
    font-family: inherit;
}
.ambient[hidden] { display: none; }

/* #ambient in front: the dashboard styles every button (and its hover) with more specific rules than a class */
#ambient .ambient-toggle, #ambient .ambient-more {
    display: grid; place-items: center; border-radius: 50%; cursor: pointer; padding: 0;
    background: var(--amb-bg); border: 1px solid var(--amb-gold-soft); color: var(--amb-gold);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
#ambient .ambient-toggle { width: 46px; height: 46px; }
#ambient .ambient-more { width: 32px; height: 32px; margin-bottom: 7px; opacity: 0; pointer-events: none; transform: translateY(4px); }
#ambient.is-on .ambient-more { opacity: 1; pointer-events: auto; transform: none; }
#ambient .ambient-toggle:hover, #ambient .ambient-more:hover { background: var(--amb-bg); border-color: var(--amb-gold); transform: translateY(-1px); }
.ambient-toggle:focus-visible, .ambient-more:focus-visible, .ambient-chip:focus-visible, .ambient-volume input:focus-visible {
    outline: 2px solid var(--amb-gold); outline-offset: 2px;
}
.ambient svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ambient-more svg { width: 16px; height: 16px; transition: transform 0.2s ease; }
.ambient-more[aria-expanded="true"] svg { transform: rotate(180deg); }
.ambient-speaker { fill: rgba(255, 184, 0, 0.22); }

/* off: a speaker with a cross; on: the waves breathe softly */
.ambient-waves { display: none; }
.ambient.is-on .ambient-waves { display: inline; animation: amb-breathe 3.2s ease-in-out infinite; }
.ambient.is-on .ambient-off { display: none; }
#ambient.is-on .ambient-toggle { border-color: var(--amb-gold); box-shadow: 0 0 0 4px rgba(255, 184, 0, 0.12), 0 6px 18px rgba(0, 0, 0, 0.35); }
/* turned on, but the browser wants a tap on the page first */
#ambient.is-waiting .ambient-toggle { animation: amb-pulse 1.6s ease-in-out infinite; }

.ambient-panel {
    position: absolute; right: 0; bottom: 56px; width: min(260px, calc(100vw - 32px));
    padding: 14px 16px; border-radius: 16px; background: var(--amb-bg); border: 1px solid var(--amb-gold-soft);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45); color: #f6efe4;
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    animation: amb-rise 0.22s ease;
}
.ambient-panel[hidden] { display: none; }
.ambient-title { margin: 0 0 10px; font-weight: 700; color: var(--amb-gold); font-size: 0.95rem; }
.ambient-volume { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; color: #d9cdb8; }
.ambient-volume input { flex: 1; accent-color: var(--amb-gold); }
.ambient-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
#ambient .ambient-chip {
    border: 1px solid var(--amb-gold-soft); background: transparent; color: var(--amb-gold); border-radius: 999px;
    padding: 6px 12px; font: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer;
}
#ambient .ambient-chip:hover { border-color: var(--amb-gold); background: rgba(255, 184, 0, 0.08); }
.ambient-chip[hidden] { display: none; }
.ambient-credit { margin: 12px 0 0; font-size: 0.72rem; color: #a99a83; }

/* the dashboard's save message lives in the same corner: it steps aside */
body.has-ambient .status { right: 78px; }

@keyframes amb-breathe { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
@keyframes amb-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 184, 0, 0.45); } 50% { box-shadow: 0 0 0 9px rgba(255, 184, 0, 0); } }
@keyframes amb-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
    .ambient.is-on .ambient-waves, .ambient.is-waiting .ambient-toggle, .ambient-panel { animation: none; }
}
@media (max-width: 480px) {
    .ambient { right: 12px; bottom: 12px; }
}
