html { scroll-behavior: smooth; }

body {
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(201,169,97,0.04) 0%, transparent 60%),
    #0a0a0a;
}

/* ============================================================
   Nav classica — sottolineatura oro per link attivi
   ============================================================ */
.nav-link-active::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  bottom: -1px;
  height: 1px;
  background: #c9a961;
}

/* ============================================================
   HOME / PORTALE
   ============================================================ */

.page-home main { padding: 0; }
.portal {
  min-height: calc(100vh - 80px);
}
.portal-img {
  filter: contrast(1.05) brightness(0.85);
}
.portal-veil {
  background:
    linear-gradient(180deg, rgba(10,10,10,0.65) 0%, rgba(10,10,10,0.25) 35%, rgba(10,10,10,0.45) 65%, rgba(10,10,10,0.95) 100%),
    radial-gradient(ellipse 70% 50% at 50% 50%, rgba(0,0,0,0) 0%, rgba(0,0,0,0.45) 100%);
}

.portal-content {
  min-height: calc(100vh - 80px);
}

/* Hotspot SVG — invisibili ma attraggono il cursore */
.portal-hotspots {
  pointer-events: none;
}
.portal-hot {
  pointer-events: all;
  cursor: pointer;
  transition: opacity 250ms ease;
}
.portal-hot polygon {
  transition: fill 250ms ease;
}
.portal-hot:hover polygon {
  fill: rgba(201, 169, 97, 0.08);
}

/* Scelte esplicite (le card "I" e "II") */
.portal-choices { z-index: 5; position: relative; }
.portal-choice {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.4rem;
  background: rgba(20, 20, 20, 0.78);
  border: 1px solid rgba(201, 169, 97, 0.22);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  text-decoration: none;
  transition: all 250ms cubic-bezier(.2,.7,.2,1);
}
.portal-choice:hover {
  border-color: #c9a961;
  background: rgba(20, 20, 20, 0.92);
  transform: translateY(-2px);
}
.choice-num {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  color: #c9a961;
  line-height: 1;
  flex-shrink: 0;
  width: 2rem;
  text-align: center;
}
.choice-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.choice-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.15rem;
  color: #f5f0e8;
  line-height: 1.2;
}
.choice-sub {
  font-size: 0.8rem;
  color: rgba(245, 240, 232, 0.55);
}
.choice-arrow {
  color: rgba(201, 169, 97, 0.6);
  transition: transform 250ms ease, color 250ms ease;
  flex-shrink: 0;
}
.portal-choice:hover .choice-arrow {
  transform: translateX(4px);
  color: #c9a961;
}

/* ============================================================
   SPACCATO MECCANICA (mechanism.php)
   Diagramma storico Britannica 1911 (PD) come base + SVG hotspot sopra
   ============================================================ */

.mech {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
}

.mech-stage {
  position: relative;
  width: 100%;
  background: transparent;
}

/* L'immagine PNG è nera su bianco. Inverte → diventa bianca su nero (sfondo
   trasparente che si fonde col body), con leggero sepia per scaldare il bianco
   verso un avorio coerente col resto del sito. */
.mech-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: invert(1) sepia(0.18) saturate(0.5) hue-rotate(-8deg) brightness(0.96);
  /* mix-blend-mode aiuta lo sfondo bianco residuo a scomparire */
  mix-blend-mode: screen;
  opacity: 0.92;
}

.mech-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* gli hotspot riattivano i pointer-events */
}

/* Numeri cliccabili — il SOLO modo per accedere alle pagine dal diagramma */
.mech-num {
  cursor: pointer;
  pointer-events: all;
  outline: none;
}
.mech-num:focus-visible .mech-num-bg {
  stroke: #e0c585;
  stroke-width: 2.5;
}
.mech-num-bg, .mech-num-text, .mech-target, .mech-leader {
  transition: fill 200ms ease, stroke 200ms ease, r 200ms ease, opacity 200ms ease;
}
/* Hover sul numero: cerchio si riempie d'oro, testo nero, dot di mira si ingrandisce, leader più visibile */
.mech-num:hover .mech-num-bg,
.mech-num:focus .mech-num-bg {
  fill: #c9a961;
  stroke: #e0c585;
}
.mech-num:hover .mech-num-text,
.mech-num:focus .mech-num-text {
  fill: #0a0a0a;
}
.mech-num:hover .mech-target,
.mech-num:focus .mech-target {
  r: 6;
  fill: #e0c585;
  filter: drop-shadow(0 0 6px rgba(224, 197, 133, 0.85));
}
.mech-num:hover .mech-leader,
.mech-num:focus .mech-leader {
  stroke: #e0c585;
  stroke-width: 1.2;
}

/* Halo invisibile a riposo, si accende quando il numero corrispondente è in hover (via JS) */
.mech-hover-halo {
  transition: opacity 280ms ease;
}
.mech-hover-halo.is-active {
  opacity: 1;
}

/* Credit */
.mech-credit {
  margin: 0.75rem 0 0 0;
  text-align: center;
  font-size: 0.7rem;
  color: rgba(245, 240, 232, 0.4);
  font-style: italic;
}

/* Legenda numerata */
.mech-legend {
  list-style: none;
  margin: 2rem 0 0 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.mech-legend li { margin: 0; }
.mech-legend a {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1.1rem;
  background: rgba(20, 20, 20, 0.6);
  border: 1px solid rgba(201, 169, 97, 0.2);
  text-decoration: none;
  color: #f5f0e8;
  font-size: 0.9rem;
  transition: all 200ms ease;
}
.mech-legend a:hover {
  border-color: #c9a961;
  background: rgba(20, 20, 20, 0.92);
  color: #c9a961;
}
.mech-legend-num {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  color: #c9a961;
  width: 1.8rem;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
}
.mech-legend-label { flex: 1; }
.mech-legend-arrow {
  color: rgba(201, 169, 97, 0.5);
  font-size: 1.1rem;
  transition: transform 200ms ease, color 200ms ease;
}
.mech-legend a:hover .mech-legend-arrow {
  color: #c9a961;
  transform: translateX(3px);
}

/* ============================================================
   PANNELLO LATERALE (drawer) — usato per i 4 componenti tecnici
   ============================================================ */
.panel {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  pointer-events: none;
}
.panel.is-open { pointer-events: auto; }
.panel.hidden  { display: none; }

.panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 320ms ease;
}
.panel.is-open .panel-backdrop { opacity: 1; }

.panel-card {
  position: relative;
  width: 100%;
  max-width: 640px;
  height: 100%;
  background: linear-gradient(180deg, #141414 0%, #0a0a0a 100%);
  border-left: 1px solid rgba(201, 169, 97, 0.3);
  padding: clamp(1.75rem, 4vw, 3rem) clamp(1.5rem, 4vw, 3rem);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 420ms cubic-bezier(.2, .85, .25, 1);
  display: flex;
  flex-direction: column;
  outline: none;
}
.panel.is-open .panel-card { transform: translateX(0); }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.panel-meta {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: #c9a961;
}
.panel-close {
  width: 40px; height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(245, 240, 232, 0.18);
  border-radius: 50%;
  color: #f5f0e8;
  background: transparent;
  cursor: pointer;
  transition: all 200ms ease;
}
.panel-close:hover {
  border-color: #c9a961;
  color: #c9a961;
  transform: rotate(90deg);
}

.panel-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(1.7rem, 3.5vw, 2.6rem);
  line-height: 1.15;
  color: #f5f0e8;
  margin-bottom: 1.5rem;
}

.panel-body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.7;
  color: rgba(245, 240, 232, 0.78);
}
.panel-body .lede {
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-size: 1.3rem;
  line-height: 1.45;
  color: #f5f0e8;
  margin-bottom: 1.4rem;
  padding-left: 1rem;
  border-left: 2px solid #c9a961;
}
.panel-body h3 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.2rem;
  color: #c9a961;
  margin-top: 1.7rem;
  margin-bottom: 0.6rem;
}
.panel-body p { margin-bottom: 0.9rem; }
.panel-body strong { color: #f5f0e8; }
.panel-body em { font-style: italic; }
.panel-body a {
  color: #e0c585;
  text-decoration: underline;
  text-decoration-color: rgba(201, 169, 97, 0.4);
  text-underline-offset: 3px;
}
.panel-body a:hover { color: #c9a961; }

.panel-body .simple-list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0;
}
.panel-body .simple-list li {
  padding: 0.5rem 0 0.5rem 1.5rem;
  position: relative;
  border-bottom: 1px solid rgba(245, 240, 232, 0.07);
}
.panel-body .simple-list li::before {
  content: '·';
  color: #c9a961;
  position: absolute;
  left: 0.5rem;
  top: 0.4rem;
  font-size: 1.4rem;
  line-height: 1;
}

.panel-body .cta-row {
  margin-top: 1.8rem;
  border-top: 1px solid rgba(245, 240, 232, 0.08);
  padding-top: 1.2rem;
}
.panel-body .cta-link {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  font-size: 0.72rem;
  text-decoration: none;
  padding: 0.7rem 1.4rem;
  border: 1px solid #c9a961;
  color: #c9a961;
  transition: background 200ms ease, color 200ms ease;
}
.panel-body .cta-link:hover {
  background: #c9a961;
  color: #0a0a0a;
}

@media (max-width: 640px) {
  .panel-card { max-width: 100%; }
}

/* ============================================================
   PROSE-CONTENT — testo lungo nelle pagine interne
   ============================================================ */
.prose-content {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.7;
  color: rgba(245, 240, 232, 0.78);
}
.prose-content h2 {
  color: #f5f0e8;
}
.prose-content p {
  margin-bottom: 1rem;
}
.prose-content strong { color: #f5f0e8; }
.prose-content em { font-style: italic; }
.prose-content a {
  color: #e0c585;
  text-decoration: underline;
  text-decoration-color: rgba(201,169,97,0.4);
  text-underline-offset: 3px;
}
.prose-content a:hover { color: #c9a961; }
.prose-content .muted { color: rgba(245, 240, 232, 0.5); }

.simple-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}
.simple-list li {
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(245, 240, 232, 0.08);
  position: relative;
  padding-left: 1.5rem;
}
.simple-list li::before {
  content: '·';
  color: #c9a961;
  position: absolute;
  left: 0.5rem;
  top: 0.5rem;
  font-size: 1.5rem;
  line-height: 1;
}

.cta-link {
  display: inline-block;
  margin-top: 0.75rem;
  color: #c9a961;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  font-size: 0.75rem;
  border-bottom: 1px solid rgba(201,169,97,0.4);
  padding-bottom: 2px;
}
.cta-link:hover { color: #e0c585; }

/* ============================================================
   TASTIERA (solo /pianista)
   ============================================================ */
.keyboard-wrap { width: 100%; max-width: 1000px; margin: 0 auto; }
.keyboard { user-select: none; -webkit-tap-highlight-color: transparent; }

.key { cursor: pointer; outline: none; text-decoration: none; }
.key:focus-visible { outline: 2px solid #c9a961; outline-offset: -3px; }

.key-white {
  background: linear-gradient(180deg, #f6f1e6 0%, #f1ead9 65%, #e1d8c0 100%);
  border-left: 1px solid #6a5d3f;
  border-right: 1px solid #2a2418;
  border-top: 1px solid #d8cfb6;
  border-bottom: 6px solid #2a2418;
  border-radius: 0 0 6px 6px;
  box-shadow:
    inset 0 -8px 18px -8px rgba(85, 70, 38, 0.45),
    inset 0 1px 0 rgba(255,255,255,0.6),
    0 4px 0 rgba(0,0,0,0.4),
    0 12px 24px -8px rgba(0,0,0,0.6);
  transition: transform 80ms ease-out, box-shadow 80ms ease-out, background 200ms ease;
}
.key-white:first-child { border-top-left-radius: 4px; }
.key-white:last-child { border-top-right-radius: 4px; }
.key-white:hover { background: linear-gradient(180deg, #fbf6ec 0%, #f4ede0 65%, #e6ddc6 100%); }
.key-white.is-pressed,
.key-white:active {
  background: linear-gradient(180deg, #e2dac4 0%, #d8d0b8 70%, #c9c0a4 100%);
  transform: translateY(2px);
  border-bottom-width: 3px;
  box-shadow:
    inset 0 -4px 12px -6px rgba(85, 70, 38, 0.6),
    inset 0 2px 8px rgba(85, 70, 38, 0.3),
    0 1px 0 rgba(0,0,0,0.4),
    0 4px 12px -4px rgba(0,0,0,0.5);
}

.key-black {
  height: 62%;
  background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 50%, #0a0a0a 100%);
  border-left: 1px solid #444;
  border-right: 1px solid #000;
  border-top: 1px solid #555;
  border-bottom: 4px solid #000;
  border-radius: 0 0 4px 4px;
  box-shadow:
    inset 0 -3px 6px -2px rgba(255,255,255,0.08),
    inset 0 1px 0 rgba(255,255,255,0.12),
    0 4px 8px rgba(0,0,0,0.7);
  z-index: 10;
  transition: transform 80ms ease-out, box-shadow 80ms ease-out, background 200ms ease;
}
.key-black:hover { background: linear-gradient(180deg, #353535 0%, #222 50%, #0e0e0e 100%); }
.key-black.is-pressed,
.key-black:active {
  background: linear-gradient(180deg, #1a1a1a 0%, #0a0a0a 50%, #000 100%);
  transform: translateY(2px);
  border-bottom-width: 2px;
}

.key-label, .key-label-black { pointer-events: none; }

/* ── Sezione tastiera sticky (solo /pianista) ─────────────────────────── */
.keyboard-section {
  position: sticky;
  top: 64px; /* sotto site-header (mobile) */
  z-index: 30;
  background: rgba(20, 20, 20, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
@media (min-width: 768px) {
  .keyboard-section { top: 80px; }
}

/* ============================================================
   TOAST (per i tasti neri in /pianista)
   ============================================================ */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 1rem 1.5rem;
  background: rgba(20, 20, 20, 0.95);
  border: 1px solid rgba(201, 169, 97, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  max-width: 380px;
  width: calc(100% - 2rem);
  z-index: 50;
  opacity: 0;
  transition: opacity 250ms ease, transform 350ms cubic-bezier(.2,.85,.2,1);
  pointer-events: none;
}
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast .toast-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  color: #c9a961;
  display: block;
  margin-bottom: 0.4rem;
}
.toast .toast-body {
  font-size: 0.9rem;
  color: rgba(245, 240, 232, 0.85);
  line-height: 1.5;
}

/* Sound toggle — solo /pianista */
.sound-toggle {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(201, 169, 97, 0.4);
  background: rgba(20, 20, 20, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #c9a961;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 40;
  transition: background 200ms ease, color 200ms ease;
}
.sound-toggle:hover { background: #c9a961; color: #0a0a0a; }

/* ============================================================
   FORM CONTATTI
   ============================================================ */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.contact-form label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: rgba(201, 169, 97, 0.85);
}
.contact-form .muted {
  color: rgba(245, 240, 232, 0.5);
  text-transform: none;
  letter-spacing: 0;
}
.contact-form input,
.contact-form select,
.contact-form textarea {
  background: #1f1f1f;
  border: 1px solid rgba(245, 240, 232, 0.15);
  color: #f5f0e8;
  padding: 0.75rem 0.9rem;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.95rem;
  text-transform: none;
  letter-spacing: 0;
  transition: border-color 180ms ease;
}
.contact-form input:focus,
.contact-form select:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: #c9a961;
}
.contact-form textarea { resize: vertical; min-height: 130px; }
.contact-form .err {
  color: #fca5a5;
  font-size: 0.7rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}
.cta-button {
  align-self: flex-start;
  padding: 0.85rem 1.75rem;
  background: #c9a961;
  color: #0a0a0a;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  border: none;
  cursor: pointer;
  transition: background 200ms ease;
  margin-top: 0.5rem;
}
.cta-button:hover { background: #e0c585; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
