/* ============================================================
   LEGGENDE E TRADIZIONI — DESKTOP OTTIMIZZATO
   ============================================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

:root {
  --sky: #5B8FAE;
  --sea: #1B4965;
  --sea-ink: #14283A;
  --stone: #EFE6D3;
  --stone-dim: #DCCFAF;
  --terracotta: #C1622D;
  --terracotta-dark: #9C4C22;
  --gold: #B8873B;
  --gold-light: #D4AF6A;
  --wine: #6B1F2A;
  --ink: #22303B;
  --ink-soft: #465563;
  --cream-text: #F3ECDC;
  --shadow-strong: rgba(0, 0, 0, 0.35);
  --shadow-soft: rgba(0, 0, 0, 0.18);
}

html, body {
  width: 100%;
  min-height: 100vh;
  color: var(--ink);
  background: var(--stone) !important;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(239,230,211,0.9), rgba(239,230,211,0.94)),
    url('img/sfondocaccamo.jpeg') center/cover no-repeat;
  z-index: -2;
}

/* ============================================================
   HEADER
   ============================================================ */
.dashboard {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 78px;
  background: rgba(15, 25, 34, 0.94);
  border-bottom: 2px solid var(--gold);
  backdrop-filter: blur(16px) saturate(180%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 36px;
  z-index: 9999;
}

.logo-title {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 1.3px;
  white-space: nowrap;
}

.header-right-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.nav-desktop {
  display: flex;
  align-items: center;
  gap: 14px;
}

.nav-desktop a {
  text-decoration: none;
  color: var(--cream-text);
  border: 1px solid rgba(184, 135, 59, 0.7);
  background: rgba(20, 40, 58, 0.52);
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 0.9rem;
  transition: all 0.25s ease;
}

.nav-desktop a:hover {
  background: rgba(184, 135, 59, 0.14);
  color: var(--gold-light);
}

.lang-switcher {
  display: flex;
  gap: 6px;
}

.lang-switcher button {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(184, 135, 59, 0.75);
  background: rgba(20, 40, 58, 0.6);
  color: var(--gold);
  border-radius: 4px;
  cursor: pointer;
  font-weight: 700;
}

.lang-switcher button.active {
  border: 2px solid #B8873B !important;
  background: rgba(184, 135, 59, 0.2) !important;
}

/* ============================================================
   HERO + LAYOUT DESKTOP
   ============================================================ */
.hero {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 120px 48px 220px 48px;
}

/* Blocco titolo: un unico contenitore centrato, niente più
   testi sovrapposti (prima categoria/titolo/sottotitolo si
   accavallavano perché condividevano la stessa area di griglia) */
.hero-intro {
  text-align: center;
  max-width: 760px;
  margin: 0 auto 3rem;
}

/* Le due colonne: sinistra (tracce + leggenda), destra (player).
   Flexbox invece di grid-area condivise: ogni colonna scorre in
   verticale in modo indipendente, senza incastrarsi con l'altra. */
.hero-columns {
  display: flex;
  align-items: flex-start;
  gap: 44px;
}

.hero-col-left {
  flex: 0 0 420px;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.hero-col-right {
  flex: 1 1 460px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.category-tag {
  display: inline-block;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  color: var(--terracotta);
  font-weight: 700;
  margin-bottom: 10px;
  text-shadow: 0 2px 10px rgba(255,255,255,0.35);
}

.hero h1 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(2.2rem, 4vw, 3rem);
  color: var(--sea);
  margin-bottom: 10px;
  text-shadow: 0 2px 12px rgba(255,255,255,0.4);
}

.subtitle {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.25rem;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

/* ============================================================
   TRACCE
   ============================================================ */
.track-groups {
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: 100%;
}

.track-group {
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(184, 135, 59, 0.45);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 10px 26px var(--shadow-soft);
}

.group-label {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  color: var(--sea);
  margin-bottom: 14px;
}

.track-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  border: 1px solid rgba(184, 135, 59, 0.25);
  background: rgba(255,255,255,0.88);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  margin-bottom: 12px;
  transition: all 0.25s ease;
}

.track-item:last-child {
  margin-bottom: 0;
}

.track-item:hover,
.track-item.active {
  border-color: var(--gold);
  box-shadow: 0 8px 20px rgba(184, 135, 59, 0.18);
  transform: translateY(-1px);
}

.track-play {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--sea);
  color: #fff;
  font-size: 0.95rem;
}

.track-meta {
  display: flex;
  flex-direction: column;
}

.track-title {
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}

.track-who {
  font-size: 0.92rem;
  color: var(--ink-soft);
  margin-top: 3px;
}

/* ============================================================
   PLAYER + TRASCRIZIONE
   ============================================================ */
/* ============================================================
   TESTO IN DIALETTO — effetto karaoke: la riga in ascolto
   si illumina a tempo con l'audio
   ============================================================ */
.dialect-lyrics {
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--gold);
  border-radius: 18px;
  padding: 22px 26px;
  margin-top: 18px;
  box-shadow: 0 10px 26px var(--shadow-soft);
  font-family: 'Playfair Display', serif;
  font-size: 1.35rem;
  line-height: 2;
  color: var(--ink-soft);
  text-align: center;
}

.dialect-line {
  display: inline-block;
  transition: color 0.35s ease, text-shadow 0.35s ease, transform 0.35s ease;
}

.dialect-line.active {
  color: var(--terracotta-dark, #9C4C22);
  font-weight: 700;
  text-shadow: 0 0 14px rgba(184, 135, 59, 0.55);
  transform: scale(1.06);
}

.player-card {
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--gold);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 12px 30px var(--shadow-soft);
}

.player-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.play-btn {
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  background: var(--terracotta);
  color: #fff;
  font-size: 1.15rem;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(193, 98, 45, 0.28);
}

.track-info .title {
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}

.track-info .who {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.waveform {
  height: 80px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(91,143,174,0.12), rgba(27,73,101,0.06));
  border: 1px solid rgba(91,143,174,0.22);
  margin-bottom: 14px;
}

.time-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink-soft);
  font-size: 0.92rem;
  margin-bottom: 14px;
}

.transcript {
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--gold);
  border-radius: 18px;
  padding: 18px;
  margin-top: 18px;
  box-shadow: 0 10px 26px var(--shadow-soft);
}

.note {
  background: rgba(255,255,255,0.82);
  border: 1px dashed rgba(184,135,59,0.55);
  border-radius: 14px;
  padding: 16px 18px;
  margin-top: 16px;
  color: var(--ink-soft);
  line-height: 1.55;
}

/* ============================================================
   CASTELLANA + CHAT
   ============================================================ */
.castellana-widget-area {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.castellana-video-wrapper {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--sea);
  background: #000;
  box-shadow: 0 4px 15px var(--shadow-strong);
  cursor: pointer;
  transition: transform 0.3s ease;
  position: relative;
}

.castellana-video-wrapper:hover {
  transform: scale(1.04);
}

.castellana-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 15%;
}

.castellana-tooltip {
  background: var(--sea);
  color: var(--stone);
  padding: 0.3rem 0.9rem;
  border-radius: 2px;
  font-weight: 700;
  font-size: 0.65rem;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  box-shadow: 0 4px 10px var(--shadow-strong);
  pointer-events: none;
}

.chat-desktop {
  position: fixed;
  right: 160px;
  bottom: 24px;
  width: 360px;
  height: 410px;
  background: rgba(15, 25, 34, 0.97);
  backdrop-filter: blur(10px);
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 16px;
  display: none;
  z-index: 99999;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.52);
}

.chat-desktop::after {
  content: "";
  position: absolute;
  right: -12px;
  bottom: 62px;
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 12px solid var(--gold);
}

.chat-desktop.active {
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s ease forwards;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--cream-text);
  background: var(--sea-ink);
  margin: -16px -16px 15px -16px;
  padding: 12px 15px;
  border-radius: 10px 10px 0 0;
  border-bottom: 1px solid var(--gold);
}

.avatar-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5FD068;
  box-shadow: 0 0 6px #5FD068;
}

.chat-header span {
  flex-grow: 1;
  font-weight: 600;
  font-size: 0.92rem;
}

.close-chat-btn {
  background: transparent;
  border: none;
  color: var(--cream-text);
  font-size: 1.1rem;
  cursor: pointer;
}

.chat-messages {
  flex-grow: 1;
  overflow-y: auto;
  margin-bottom: 10px;
}

.chat-messages .message {
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.5;
  background: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 8px;
  max-width: 92%;
  border-left: 2px solid var(--gold);
}

/* Messaggi dell'utente, distinti da quelli della Castellana */
.chat-messages .message.user-msg {
  background: rgba(184, 135, 59, 0.18);
  border-left: 2px solid var(--sea);
  margin-left: auto;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-input-row input {
  flex: 1;
  min-width: 0;
  padding: 11px 12px;
  border-radius: 6px;
  border: 1px solid rgba(184, 135, 59, 0.55);
  background: rgba(255,255,255,0.96);
  color: var(--ink);
  font-size: 0.9rem;
  outline: none;
}

.chat-input-row input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(184, 135, 59, 0.18);
}

.send-btn {
  border: none;
  background: var(--terracotta);
  color: #fff;
  width: 42px;
  height: 42px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
}

.mic-btn {
  border: none;
  background: var(--wine);
  color: #fff;
  width: 42px;
  height: 42px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.05rem;
  transition: background 0.2s ease, transform 0.2s ease;
}

.mic-btn:hover {
  background: #521720;
}

.mic-btn.listening {
  background: var(--terracotta);
  animation: mic-pulse 1s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

/* ============================================================
   MENU A PULSANTI DELLA CHAT (argomenti / gruppi)
   Senza queste regole il browser disegna i pulsanti con
   l'aspetto grezzo di sistema (grigio, bordo nero), invece dello
   stile oro/blu marino coerente con il resto del sito.
   ============================================================ */
.topic-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.topic-btn {
  border: 1px solid var(--gold);
  background: rgba(184, 135, 59, 0.14);
  color: var(--cream-text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.topic-btn:hover {
  background: rgba(184, 135, 59, 0.32);
}

.topic-group-btn {
  background: rgba(107, 31, 42, 0.35);
  border-color: var(--gold-light);
}

.chat-link-btn {
  display: inline-block;
  border: none;
  background: var(--terracotta);
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 4px;
}

.chat-link-btn:hover {
  background: var(--terracotta-dark);
}

/* Bottone "ascolta" accanto ai messaggi della Castellana */
.audio-btn {
  background: rgba(184, 135, 59, 0.15);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.audio-btn:hover {
  background: rgba(184, 135, 59, 0.35);
}

/* ============================================================
   ANIMAZIONE
   ============================================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   TABLET
   ============================================================ */
@media (min-width: 601px) and (max-width: 899px) {
  .hero {
    margin-top: 150px;
    max-width: 760px;
    padding: 0 24px 170px;
  }

  .hero-columns {
    flex-direction: column;
  }

  .hero-col-left {
    max-width: 100%;
    flex: 1 1 auto;
  }

  .castellana-video-wrapper {
    width: 95px;
    height: 95px;
  }
}

/* ============================================================
   DESKTOP (da 900px in su) — chat ingrandita.
   ============================================================ */
@media screen and (min-width: 900px) {
  .chat-desktop {
    width: 640px;
    max-width: 85vw;
    height: 640px;
    max-height: 74vh;
    bottom: 90px;
  }
}

/* ============================================================
   MOBILE
   ============================================================ */
@media screen and (max-width: 899px) {
  .dashboard {
    height: auto;
    min-height: 78px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 12px 16px;
    row-gap: 8px;
  }

  .header-right-actions {
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 8px;
  }

  .nav-desktop {
    flex: 1 1 100%;
    justify-content: center;
  }

  .lang-switcher {
    flex: 1 1 100%;
    justify-content: center;
  }

  .hero {
    margin-top: 190px;
    padding: 0 20px 160px;
    max-width: 620px;
  }

  .hero-columns {
    flex-direction: column;
  }

  .hero-col-left {
    max-width: 100%;
    flex: 1 1 auto;
  }

  .track-groups {
    display: flex;
    flex-direction: column;
    gap: 22px;
  }

  .castellana-widget-area {
    right: 12px;
    bottom: 12px;
  }

  .castellana-video-wrapper {
    width: 82px;
    height: 82px;
  }

  .chat-desktop {
    bottom: 110px;
    left: 10px;
    right: 10px;
    width: calc(100% - 20px);
    height: 360px;
  }

  .chat-desktop::after {
    display: none;
  }
}
