/* ============================================================
   1. RESET + VARIABILI GLOBALI — stessa palette di castello.css/chiese.css
   ============================================================ */
* {
  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);
}

/* ============================================================
   2. BODY
   ============================================================ */
html, body {
  width: 100%;
  min-height: 100vh;
  color: var(--ink);
  background: var(--stone) !important;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(60, 40, 20, 0.16) 100%);
}

/* ============================================================
   3. DASHBOARD
   ============================================================ */
.dashboard {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background: rgba(15, 25, 34, 0.92);
  border-bottom: 2px solid var(--gold);
  backdrop-filter: blur(18px) saturate(200%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  gap: 12px;
  z-index: 999;
  box-shadow: 0 2px 0 rgba(212, 175, 106, 0.25);
  box-sizing: border-box;
}

.dashboard .logo-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 1.5px;
}

.nav-desktop {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.nav-desktop a {
  color: var(--stone);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.3px;
  padding: 6px 16px;
  border-radius: 2px;
  background: rgba(239, 230, 211, 0.08);
  border: 1px solid rgba(239, 230, 211, 0.4);
  transition: all 0.3s ease;
}

.nav-desktop a:hover {
  background: rgba(193, 98, 45, 0.25);
  border-color: var(--terracotta);
  color: #fff;
}

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

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

.lang-switcher button {
  width: 36px;
  height: 36px;
  font-size: 0.9rem;
  font-weight: bold;
  border-radius: 2px;
  background: rgba(239, 230, 211, 0.08);
  border: 1px solid rgba(239, 230, 211, 0.4);
  color: var(--stone);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.lang-switcher button:hover {
  background: rgba(193, 98, 45, 0.25);
}

@media screen and (max-width: 899px) {
  .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;
  }
}

/* ============================================================
   4. HERO CENTRALE & POESIA
   ============================================================ */
.hero {
  margin-top: 190px;
  text-align: center;
  padding: 1.5rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.hero-text h1 {
  font-family: 'Playfair Display', serif;
  font-size: 2.2rem;
  color: var(--sea);
  margin-bottom: 0.5rem;
}

.hero-text::after {
  content: "❧";
  display: block;
  margin: 0.6rem auto 1.5rem;
  color: var(--gold);
  font-size: 15px;
}

.poesia-intro {
  font-family: 'Cormorant Garamond', 'Playfair Display', serif;
  font-style: italic;
  font-size: 1.2rem;
  line-height: 1.6;
  color: var(--ink);
  max-width: 560px;
  margin: 0 auto 0.6rem;
}

.poesia-outro {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 1.15rem;
  color: var(--terracotta-dark);
  text-align: center;
  margin-top: 2.5rem;
}

.click-hint {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 700;
  color: var(--terracotta-dark);
  opacity: 0.95;
  font-size: 1.1rem;
  text-align: center;
  letter-spacing: 0.3px;
  display: block;
}

/* ============================================================
   5. IL SENTIERO
   ============================================================ */
.path-wrap {
  position: relative;
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 24px 190px;
}

.path-line {
  position: absolute;
  left: 50%;
  top: 10px;
  bottom: 140px;
  width: 3px;
  transform: translateX(-50%);
  background: repeating-linear-gradient(
    to bottom,
    var(--terracotta) 0px, var(--terracotta) 10px,
    transparent 10px, transparent 20px
  );
  opacity: 0.55;
}

.stop {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 50px 1fr;
  align-items: center;
  margin-bottom: 46px;
}

.stop:last-of-type { margin-bottom: 0; }

.waypoint {
  grid-column: 2;
  justify-self: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--stone);
  border: 3px solid var(--gold);
  z-index: 2;
}

.card {
  background: var(--stone-dim);
  border: 1px solid var(--terracotta);
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  box-shadow: 0 6px 16px var(--shadow-soft);
  cursor: pointer;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.card:hover {
  border-color: var(--gold);
  box-shadow: 0 10px 22px var(--shadow-soft);
}

.card.side-left  { grid-column: 1; justify-self: end; flex-direction: row-reverse; text-align: right; }
.card.side-right { grid-column: 3; justify-self: start; text-align: left; }

.card-frame {
  position: relative;
  flex: 0 0 130px;
  width: 130px;
  height: 130px;
  overflow: hidden;
  background: var(--stone);
  border: 1px solid var(--gold);
}

.card-frame::after {
  content: "🔍";
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  background: var(--terracotta);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  pointer-events: none;
}

.card-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  animation: gentleBreathe 3.5s ease-in-out infinite;
}

.card:hover .card-frame img {
  animation-play-state: paused;
  transform: scale(1.08);
}

.card-text { max-width: 260px; }

.card-route-label {
  display: block;
  font-size: 0.65rem;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--terracotta);
  margin-bottom: 3px;
}

.card-text h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  color: var(--sea);
  margin-bottom: 4px;
}

.card-text p {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--ink);
}

.card-text p strong {
  color: var(--terracotta-dark);
  font-style: normal;
  font-weight: 600;
}

.card-esoterico {
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  min-height: 130px;
  border-style: dashed;
}

.card-esoterico:hover {
  background: rgba(184, 135, 59, 0.08);
}

.card-esoterico .card-text { max-width: none; }

@media screen and (max-width: 899px) {
  .path-line { left: 22px; transform: none; }

  .stop {
    grid-template-columns: 44px 1fr;
    margin-bottom: 34px;
  }

  .waypoint { grid-column: 1; justify-self: start; margin-left: 12px; }

  .card.side-left,
  .card.side-right {
    grid-column: 2;
    justify-self: stretch;
    flex-direction: row;
    text-align: left;
  }

  .card-text { max-width: none; }
}

/* ============================================================
   6. MODAL LIGHTBOX
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 34, 0.93);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  z-index: 999999;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.modal.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content-wrapper {
  max-width: 90%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: scale(0.9);
  transition: transform 0.4s ease;
}

.modal.active .modal-content-wrapper {
  transform: scale(1);
}

/* Contenitore immagine + frecce del carosello. Su card senza
   galleria collegata, le frecce restano semplicemente nascoste
   (display:none impostato via JS) e questo blocco si comporta
   come prima: una singola immagine centrata. */
.modal-image-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 70vh;
}

.modal-img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 2px;
  border: 1px solid var(--gold);
  box-shadow: 0 0 30px var(--shadow-strong);
}

.modal-gallery-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(15, 25, 34, 0.55);
  border: 1px solid var(--gold);
  color: var(--stone);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.2s ease;
}

.modal-gallery-arrow:hover {
  background: rgba(184, 135, 59, 0.55);
}

.modal-gallery-arrow-left { left: 12px; }
.modal-gallery-arrow-right { right: 12px; }

.modal-gallery-counter {
  display: none;
  color: var(--gold-light);
  font-family: 'Playfair Display', serif;
  font-size: 0.95rem;
  margin-top: 12px;
}

.modal-title {
  font-family: 'Playfair Display', serif;
  color: var(--stone);
  font-size: 1.8rem;
  margin-top: 15px;
  text-align: center;
}

.modal-close {
  position: absolute;
  top: 25px;
  right: 25px;
  background: rgba(239, 230, 211, 0.1);
  border: 1px solid var(--gold);
  color: var(--stone);
  width: 45px;
  height: 45px;
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.modal-close:hover {
  background: var(--gold);
  color: var(--sea);
}

/* ============================================================
   7. CASTELLANA WIDGET E CHAT
   ============================================================ */
.castellana-widget-area {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.castellana-video-wrapper {
  width: 78px;
  height: 78px;
  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: dimensioni base (mobile). Su desktop (min-width:900px)
   vengono ingrandite più sotto — prima mancava del tutto un
   ingrandimento per schermi grandi, la finestra restava sempre
   piccola (320x350) anche su desktop. */
.chat-desktop {
  position: fixed;
  bottom: 150px;
  right: 3%;
  width: 320px;
  height: 350px;
  background: rgba(15, 25, 34, 0.96);
  backdrop-filter: blur(10px);
  border: 1px solid var(--gold);
  border-radius: 4px;
  padding: 16px;
  display: none;
  z-index: 99999;
  box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.5);
}

.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: 4px 4px 0 0;
  border-bottom: 1px solid var(--gold);
}

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

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

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

.close-chat-btn:hover {
  color: var(--gold-light);
}

.premium-status-bar {
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
  padding: 4px 8px;
  margin: -6px 0 10px 0;
  border-radius: 2px;
  letter-spacing: 0.2px;
}

.premium-status-bar.premium-active {
  background: rgba(184, 135, 59, 0.18);
  color: var(--gold-light);
  border: 1px solid rgba(184, 135, 59, 0.4);
}

.premium-status-bar.premium-free {
  background: rgba(239, 230, 211, 0.08);
  color: var(--cream-text);
  border: 1px solid rgba(239, 230, 211, 0.25);
}

.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: 2px;
  margin-bottom: 8px;
  max-width: 90%;
  border-left: 2px solid var(--gold);
}

.chat-link-btn {
  display: block;
  background: var(--terracotta);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 2px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  margin: -2px 0 8px 0;
  transition: background 0.2s;
}

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

.map-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: #000;
}

.map-overlay iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.map-overlay-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(15, 25, 34, 0.85);
  color: var(--cream-text);
  border: 1px solid var(--gold);
  font-size: 1.2rem;
  cursor: pointer;
}

.topic-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 2px 0 10px 0;
}

.topic-btn {
  background: #fff;
  border: 1px solid var(--gold);
  color: var(--sea);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.topic-btn:hover {
  background: var(--gold);
  color: #fff;
}

.topic-group-btn {
  border-color: var(--terracotta);
  color: var(--terracotta);
  font-weight: 600;
}

.topic-group-btn:hover {
  background: var(--terracotta);
  color: #fff;
}

.topic-subitems {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  margin-top: 4px;
  padding-left: 10px;
}

.chat-input-row {
  display: flex;
  gap: 10px;
}

.chat-input-row input {
  flex-grow: 1;
  background: #fff;
  border: 1px solid rgba(184, 135, 59, 0.5);
  padding: 10px 14px;
  border-radius: 2px;
  color: var(--ink);
  font-size: 0.85rem;
  outline: none;
}

.chat-input-row input:focus {
  border-color: var(--gold);
}

.mic-btn {
  background: var(--wine);
  border: none;
  border-radius: 2px;
  padding: 0 14px;
  cursor: pointer;
  transition: background 0.2s;
  color: #fff;
  font-size: 1.1rem;
}

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

/* ============================================================
   8. OTTIMIZZAZIONE DESKTOP (DA 900PX IN SU)
   ============================================================ */
@media screen and (min-width: 900px) {

  .dashboard {
    height: 75px;
    flex-direction: row;
    padding: 0 40px;
    gap: 0;
  }

  .dashboard .logo-title {
    font-size: 1.55rem;
  }

  .nav-desktop {
    gap: 22px;
  }

  .nav-desktop a {
    font-size: 1rem;
    padding: 10px 18px;
  }

  .hero {
    margin-top: 110px;
  }

  .hero-text h1 {
    font-size: 3.2rem;
  }

  .poesia-container {
    background: transparent;
    border: 1px solid transparent;
    box-shadow: none;
    padding: 24px 40px;
  }

  .poesia-container:hover {
    background: rgba(220, 207, 175, 0.5);
    border: 1px solid var(--terracotta);
    box-shadow: 0 8px 24px var(--shadow-soft);
    backdrop-filter: blur(6px) saturate(120%);
    -webkit-backdrop-filter: blur(6px) saturate(120%);
  }

  .poesia-intro {
    font-size: 1.4rem;
  }

  .poesia-outro {
    font-size: 1.3rem;
  }

  .path-wrap {
    max-width: 860px;
  }

  .card-frame {
    flex: 0 0 190px;
    width: 190px;
    height: 190px;
  }

  .card-frame::after {
    width: 32px;
    height: 32px;
    font-size: 15px;
  }

  .card-text {
    max-width: 300px;
  }

  .castellana-widget-area {
    right: 2rem;
    bottom: 2rem;
    gap: 8px;
  }

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

  .modal-img {
    max-height: 75vh;
  }

  /* Chat più grande su desktop: prima usava sempre le stesse
     dimensioni ridotte pensate per mobile (320x350). Altezza e
     posizione ("bottom") leggermente ridotte rispetto al primo
     tentativo, perché risultava troppo in alto sullo schermo. */
  .chat-desktop {
    width: 640px;
    max-width: 85vw;
    height: 640px;
    max-height: 74vh;
    bottom: 90px;
  }
}

/* SCENARIO INTERMEDIO TABLET */
@media (min-width: 601px) and (max-width: 899px) {
  .hero {
    margin-top: 150px;
  }
  .castellana-video-wrapper {
    width: 95px;
    height: 95px;
  }
}

/* Chat più stretta sui piccoli schermi (stessa soglia di cittadino.html) */
@media screen and (max-width: 950px) {
  .chat-desktop {
    bottom: 110px;
    left: 10px;
    right: 10px;
    width: calc(100% - 20px);
  }
}

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

@keyframes gentleBreathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}

.send-btn {
    background: var(--sea);
    border: none;
    border-radius: 2px;
    padding: 0 12px;
    cursor: pointer;
    color: #fff;
    font-size: 1rem;
    transition: background 0.2s;
}

.send-btn:hover {
    background: var(--terracotta);
}

.chat-messages .message.user-msg {
    background: var(--sea);
    color: #fff;
    margin-left: auto;
    border-left: none;
    border-right: 2px solid var(--gold);
    text-align: right;
}
