/* ===========================================================
   Stem Player — identità "banco mixer": pannelli scuri, LED
   ambra/oro per lo stato dei canali, cifre in monospazio.
   =========================================================== */

:root {
  --bg: #14110f;
  --panel: #1c1815;
  --panel-raised: #221d19;
  --line: #332c26;
  --text: #f1e9dc;
  --text-dim: #a89c8a;
  --text-faint: #6f665a;

  --amber: #e0a94a;
  --amber-dim: #7a5f2e;
  --solo: #e8b23d;
  --mute: #e2544a;
  --teal: #5fb3a3;

  --radius: 10px;
  --font-display: "Big Shoulders Display", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

/* L'attributo [hidden] va sempre rispettato anche quando un selettore più
   specifico (es. display:flex su .stage__placeholder) verrebbe altrimenti
   applicato dopo di lui nel foglio di stile. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

body {
  background-image:
    radial-gradient(circle at 15% 0%, rgba(224, 169, 74, 0.05), transparent 40%),
    radial-gradient(circle at 85% 100%, rgba(95, 179, 163, 0.04), transparent 45%);
}

button { font-family: inherit; }

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===================== Sidebar ===================== */

.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar__header {
  padding: 28px 24px 20px;
  border-bottom: 1px solid var(--line);
}

.sidebar__eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--amber);
}

.sidebar__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 34px;
  line-height: 0.92;
  letter-spacing: 0.01em;
  margin: 8px 0 0;
  color: var(--text);
}

.song-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.song-list__empty {
  color: var(--text-faint);
  font-size: 13px;
  padding: 12px;
}

.song-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-dim);
  padding: 12px 14px;
  margin-bottom: 4px;
  cursor: pointer;
  font-size: 14.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.song-item:hover {
  background: var(--panel-raised);
  color: var(--text);
}

.song-item__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line);
  flex-shrink: 0;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.song-item.is-active {
  background: var(--panel-raised);
  border-color: var(--amber-dim);
  color: var(--text);
}

.song-item.is-active .song-item__dot {
  background: var(--amber);
  box-shadow: 0 0 8px rgba(224, 169, 74, 0.7);
}

/* ===================== Stage ===================== */

.stage {
  flex: 1;
  overflow-y: auto;
  padding: 40px 48px 80px;
  position: relative;
}

.stage__placeholder {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-faint);
  text-align: center;
}

.stage__placeholder-mark {
  font-size: 30px;
  color: var(--amber-dim);
}

.stage__header {
  margin-bottom: 28px;
}

.stage__eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.stage__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 46px;
  line-height: 1;
  margin: 6px 0 0;
  color: var(--text);
}

/* ===================== Sezione 1: trasporto ===================== */

.transport {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.transport__play {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--amber-dim);
  background: var(--panel-raised);
  color: var(--amber);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.1s ease;
}
.transport__play:hover { background: #2a231d; }
.transport__play:active { transform: scale(0.95); }

.transport__scrub {
  flex: 1;
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.transport__time {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  min-width: 42px;
  text-align: center;
}

.transport__downloads {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

/* range input generico (seek, volume): il riempimento colorato fino alla
   manopola viene applicato via JS (applyRangeFill) per Chrome/Edge/Safari;
   Firefox lo gestisce nativamente con ::-moz-range-progress. */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--amber);
  border: 2px solid #14110f;
  box-shadow: 0 0 0 1px var(--amber-dim);
  margin-top: -5px;
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--amber);
  border: 2px solid #14110f;
  box-shadow: 0 0 0 1px var(--amber-dim);
}
/* Webkit/Blink: la track resta trasparente, il colore visibile è il
   gradient applicato via JS come background dell'elemento stesso. */
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: transparent;
}
/* Firefox: riempimento nativo tramite lo pseudo-elemento -progress. */
input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--line);
}
input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--amber);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-raised);
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.btn:hover { color: var(--text); border-color: var(--amber-dim); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--ghost svg { color: var(--amber); flex-shrink: 0; }

/* ===================== Sezione 2: channel strips ===================== */

.channels {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}

.channel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 18px;
  position: relative;
  overflow: hidden;
}

.channel__head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
}

/* Indicatore di livello del segnale: risponde in tempo reale al segnale
   audio post-fader dello stem (riflette quindi anche mute/solo). */
.channel__meter {
  height: 5px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
  margin-bottom: 14px;
}

.channel__meter-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--teal);
  transition: width 60ms linear, background-color 120ms ease;
}

.channel__index {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

.channel__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: 0.01em;
  color: var(--text);
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.channel__fader {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.channel__fader input[type="range"] { flex: 1; }

.channel__vol-value {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-dim);
  min-width: 30px;
  text-align: right;
}

.channel__buttons {
  display: flex;
  gap: 8px;
}

.chip {
  flex: 1;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--panel-raised);
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 7px 0;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chip:hover { color: var(--text); }

.chip--mute.is-on {
  background: rgba(226, 84, 74, 0.16);
  border-color: var(--mute);
  color: var(--mute);
}
.chip--solo.is-on {
  background: rgba(232, 178, 61, 0.16);
  border-color: var(--solo);
  color: var(--solo);
}

.channel__download {
  width: 34px;
  flex: 0 0 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--panel-raised);
  color: var(--text-faint);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}
.channel__download:hover { color: var(--amber); border-color: var(--amber-dim); }

/* ===================== Sezione 3: allegati ===================== */

.attachments {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.attachments__title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 12px;
  font-weight: 500;
}

.attachments__list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.attachments__empty {
  color: var(--text-faint);
  font-size: 13px;
  margin: 0;
}

.attachment-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-raised);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.15s ease;
}
.attachment-link:hover { color: var(--text); border-color: var(--teal); }
.attachment-link svg { color: var(--teal); flex-shrink: 0; }

/* ===================== Toast ===================== */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-raised);
  border: 1px solid var(--amber-dim);
  color: var(--text);
  padding: 11px 20px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

/* ===================== Mobile top bar / hamburger ===================== */

.mobile-topbar {
  display: none; /* visibile solo sotto il breakpoint mobile */
  align-items: center;
  gap: 14px;
  margin: -8px 0 24px;
}

.mobile-menu-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--amber);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.mobile-menu-btn:hover { border-color: var(--amber-dim); }

.mobile-topbar__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 8, 6, 0.6);
  z-index: 35;
}

/* ===================== Responsive ===================== */

@media (max-width: 760px) {
  .app { height: 100vh; }

  .mobile-topbar { display: flex; }

  /* la sidebar diventa un drawer che scorre da sinistra sopra il contenuto */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 84%;
    max-width: 320px;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 12px 0 28px rgba(0, 0, 0, 0.4);
  }
  .sidebar.is-open { transform: translateX(0); }

  .stage { padding: 20px 18px 60px; }
  .stage__title { font-size: 32px; }
  .transport { flex-direction: column; align-items: stretch; }
  .transport__downloads { justify-content: stretch; }
  .transport__downloads .btn { flex: 1; justify-content: center; }
}

/* Focus visibile per accessibilità da tastiera */
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
