html, body {
  margin: 0; padding: 0;
  background-color: #f8fafc;
  color: #1e293b;
  font-family: "geist", sans-serif;
  font-size: 16px;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.visual-background {
  position: absolute;
  top: 0; left: 64px;
  width: calc(100vw - 64px);
  height: 100vh;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.visual-background.shifted { transform: translateX(150px); }

.visual-background canvas, #map-canvas, #collectors-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  pointer-events: none;
}

#collectors-canvas { z-index: 9; pointer-events: auto; }
#collectorZone-canvas { z-index: 8; }
#map-canvas { z-index: 7; }
#oyster-canvas { z-index: 6; opacity: 0.6; }
#larvae-canvas { z-index: 5; }
#bathymetry-canvas { z-index: 2; opacity: 0.4; display: none;}
#currents-canvas { z-index: 1; opacity: 0.4; mix-blend-mode: multiply; }
#heatmap-canvas { z-index: 1; opacity: 0.4; mix-blend-mode: multiply; display:none;}


/* =========================================
   PANNELLI E STILE CONDIVISO
   ========================================= */
.rail-panel,
#floating-legend {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-right: 1px solid #000;
  border-radius: 0;
  box-sizing: border-box;
}

#floating-legend {
  border: 1px solid #000;
}

h4, .info-title {
  font-family: "geist", sans-serif;
  font-weight: black;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: #000;
  margin-top: 0;
  margin-bottom: 45px;
}

a {
  color: inherit;
  text-decoration: underline;
}

a:hover {
  color: inherit; 
  text-decoration: underline;
}


/* =========================================
   MENU LATERALE
   ========================================= */
#app-sidebar {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  display: flex;
}

.sidebar-rail {
  position: relative;
  width: 64px;
  height: 100%;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border-right: 1px solid #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 20px;
  gap: 16px;
  z-index: 10;
}

.rail-icon {
  width: 48px;
  height: 48px;
  border-radius: 0;
  background: transparent;
  border: 1px solid transparent;
  color: rgba(0, 0, 0, 0.5);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.2s;
}

.rail-icon svg { width: 24px; height: 24px; }
.rail-icon:hover { color: #000; border: 1px solid #000; }
.rail-icon.active { color: #000; border: 1px solid #000; }

.rail-panel {
  position: absolute;
  left: 64px; 
  top: 0; bottom: 0;
  width: 0;   
  border-left: none;
  overflow: hidden;
  transition: width 0.35s cubic-bezier(0.25, 1, 0.5, 1);
  z-index: 5;
}

.rail-panel.open { width: 390px;}

.panel-content {
  width: 350px; padding: 20px;
  color: #000;
}


/* =========================================
   CONTROLLI SIMULATORE
   ========================================= */
.sim-date { font-size: 1.2rem; font-weight: bold; margin-bottom: 4px; }
.sim-temp { font-size: 1rem; color: #000; font-weight: 600; margin-bottom: 12px; }

.sim-captures { 
  font-size: 0.95rem; 
  border-top: 1px solid #000;
  padding-top: 10px; 
}
.capture-count { color: #ff3c00; font-weight: bold; float: right; }

.sim-controls { margin-top: 15px; display: flex; align-items: center; gap: 10px; }

/* Bottoni unificati */
.btn-control { 
  background: transparent; 
  color: #000; 
  border: 1px solid #000; 
  padding: 6px 12px; 
  border-radius: 0; 
  cursor: pointer; 
  font-weight: bold; 
  font-size: 0.8rem;
  text-transform: uppercase;
  transition: all 0.2s;
}
.btn-control:hover { background: #000; color: #fff; }

.slider-control { flex-grow: 1; cursor: pointer; accent-color: #000; }

.speed-select { 
  background: transparent; 
  color: #000; 
  border: 1px solid #000; 
  padding: 6px; 
  border-radius: 0; 
  outline: none; 
  cursor: pointer; 
  font-family: inherit;
  font-size: 0.8rem;
}


/* =========================================
   DRAG & DROP COLLETTORI
   ========================================= */
.collectors-dock {
  margin-top: 25px;
  border-top: 1px solid #000;
  padding-top: 15px;
}

.dock-instructions { font-size: 0.85rem; margin-bottom: 12px; color: #666; margin-top: 0; }
.collectors-container { display: flex; gap: 12px; flex-wrap: wrap; }

.collector-item {
  width: 25px;
  height: 25px;
  background: rgba(255, 60, 0, 0.1);
  border: 1.5px solid #ff3c00;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #ff3c00;
  font-size: 0.7rem;
  font-weight: bold;
  cursor: grab;
  transition: background 0.2s, transform 0.2s;
  user-select: none;
}
.collector-item:hover { background: rgba(255, 60, 0, 0.4); transform: scale(1.1); }
.collector-item:active { cursor: grabbing; }
.collector-item.is-dragging { opacity: 0.5; transform: scale(0.9); }

.sim-stats {
  margin-top: 25px;
  border-top: 1px solid #000;
  padding-top: 15px;
}

.sim-row-total {
  font-size: 0.95rem;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px dashed #000;
}
.empty-stats { font-size: 0.8rem; color: #666; font-style: italic; }


/* =========================================
   FLOATING LEGENDA E TOGGLES
   ========================================= */
#legend-container {
  position: absolute;
  top: 20px; right: 20px;
  z-index: 200;
  display: flex; flex-direction: column; align-items: flex-end;
  pointer-events: none;
}

.hamburger-btn {
  display: flex; align-items: center; justify-content: center;
  padding: 5px; background: transparent; cursor: pointer;
  border: 1px solid #000; border-radius: 0;
  pointer-events: auto;
  transition: all 0.2s;
}

.hamburger-btn svg { width: 20px; height: 20px; }

#legend-toggle {
  pointer-events: auto;
  padding: 8px 16px;
  border-radius: 0;
  cursor: pointer; transition: all 0.2s;
  border: 1px solid transparent;
}

#legend-toggle:hover, #legend-toggle.active {
  border: 1px solid #000;
}

#floating-legend {
  margin-top: 10px;
  width: 320px;
  pointer-events: auto;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transform: translateY(-10px);
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  border: 1px solid transparent;
}

#floating-legend.open { 
  opacity: 1; 
  pointer-events: auto; 
  transform: translateY(0); 
  border: 1px solid #000; 
}

.info-text { font-size: 0.9rem; line-height: 1.4; margin-bottom: 0; }
.legenda-box { display: flex; flex-direction: column; gap: 10px; }
.legenda-item { display: flex; align-items: center; gap: 12px; font-size: 0.9rem; }

/* Box colori della legenda */
.color-box { 
  display: inline-block; 
  width: 14px; 
  height: 14px; 
  flex-shrink: 0; 
  border: 1px solid #000; 
}
.box-land { 
  background: #ffffff; 
  border: 1px solid #000000; 
}
.box-reef { 
  background: rgba(0, 102, 255, 0.05); 
  border: 1px solid rgba(0, 102, 255); 
}
.box-sensor { 
  width: 0; 
  height: 0; 
  background: transparent; 
  border-left: 7px solid transparent; 
  border-right: 7px solid transparent; 
  border-bottom: 12px solid rgba(0, 102, 255); 
  border-top: none; 
  border-radius: 0; 
}

.box-oysters-pop { 
  background: rgba(255, 60, 0, 0.5); 
  border: none; 
  border-radius: 50%; 
}
.box-collector-zone { 
  background: transparent; 
  border: 1px solid #ff3c00; 
}

.box-pelagic { 
  background: #ffa200; 
  border: none; 
  border-radius: 50%; 
}

.box-oysters { 
  background: #ff3c00; 
  border: none; 
  border-radius: 50%; 
}

/* Stile Toggle Switch per simulatore */
.toggle-switch { position: relative; display: inline-block; width: 34px; height: 16px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: transparent; border: 1px solid #000; transition: .4s; }
.slider:before { position: absolute; content: ""; height: 10px; width: 10px; left: 2px; bottom: 2px; background-color: #000; transition: .4s; }
input:checked + .slider { background-color: #000; }
input:checked + .slider:before { transform: translateX(18px); background-color: #fff; }


/* =========================================
   OVERRIDE LARGHEZZE PANNELLI E CONTENUTO
   ========================================= */
#panel-sim.open { width: 420px; }
#panel-info.open { width: 750px; }

.wide-content { 
  position: relative;
  width: 100%; 
  height: 100vh;
  padding: 20px; 
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}


/* =========================================
   STILE ARTICOLO E COLONNE (SCROLL ORIZZONTALE)
   ========================================= */
.article-header {
  flex-shrink: 0;
  border-bottom: 1px solid #000;
  padding-bottom: 20px;
  margin-bottom: 20px;
}

.editorial-title {
  font-family: "Times New Roman", serif;
  font-size: 2.8rem; 
  margin-bottom: 10px;
}

.article-subtitle {
  font-family: "geist", sans-serif;
  font-size: 1rem;
  font-weight: bold;
  color: #000000;
  margin: 0;
  padding-bottom: 20px;
  line-height: 1.4;
}

.article-scroll-area {
  flex-grow: 1;
  column-width: 300px;
  column-gap: 50px;
  column-fill: auto;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 40px;
  font-family: "geist", sans-serif;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #000000;
  text-align: justify;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.article-scroll-area::-webkit-scrollbar {
  display: none; 
}

.article-scroll-area p {
  margin-top: 0;
  margin-bottom: 20px;
}

.article-dropcap::first-letter {
  float: left;
  font-family: "Times New Roman", serif;
  font-size: 4.5rem;
  line-height: 0.75;
  padding-top: 8px;
  padding-right: 12px;
  color: rgb(0, 0, 0);
}


/* =========================================
   IMMAGINI EDITORIALI NELL'ARTICOLO
   ========================================= */
.article-figure {
  margin: 20px 0;
  padding: 0;
  width: 100%;
  display: block; 
  break-inside: avoid;
  page-break-inside: avoid; 
}

.article-figure img {
  width: 80%;
  height: auto;
  display: block;
  margin-left: auto;
  margin-right: auto;
  border-radius: 2px;
}

.article-figure figcaption {
  font-family: "geist", sans-serif;
  font-size: 0.7rem;
  line-height: 1.4;
  color: #64748b;
  margin-top: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}


/* =========================================
   FRECCIA 
   ========================================= */
.simple-arrow {
  position: absolute;
  bottom: 25px; 
  right: 40px;  
  cursor: pointer;
  padding: 10px; 
  display: flex;
  align-items: center;
  transition: transform 0.2s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.3s ease;
  z-index: 10;
}

.simple-arrow svg {
  width: 45px; 
  height: 12px;
}

.simple-arrow:hover {
  transform: translateX(8px); 
}

.simple-arrow.hidden {
  opacity: 0;
  pointer-events: none;
}


/* =========================================
   MOBILE RESPONSIVE LAYOUT (DEFINTIVO)
   ========================================= */
@media (max-width: 768px) {
  html, body { width: 100%; height: 100dvh; margin: 0; overflow: hidden; }
  *, *::before, *::after { box-sizing: border-box; }

  #app-sidebar { position: static; width: 0; height: 0; pointer-events: none; }

  .sidebar-rail {
    position: fixed; top: auto; bottom: 0; left: 0;
    width: 100%; height: 60px;
    flex-direction: row; justify-content: space-evenly; padding: 0;
    background: #fff; border-top: 1px solid #000; border-right: none;
    z-index: 10000; pointer-events: auto;
  }

  .rail-panel {
    position: fixed; top: auto; bottom: 60px; left: 0;
    width: 100% !important; height: 0;
    border: none; background: #fff;
    transition: height .35s cubic-bezier(.25,1,.5,1);
    z-index: 9999; pointer-events: auto;
  }
  .rail-panel.open { border-top: 1px solid #000; }
  #panel-info.open { height: calc(100dvh - 60px); overflow-y: auto; overflow-x: hidden; }
  #panel-sim.open  { height: 50dvh; overflow-y: auto; overflow-x: hidden; }

  .panel-content, .wide-content { width: 100% !important; max-width: 100%; padding: 20px; }

  .wide-content { height: auto !important; min-height: 100%; }
  .article-scroll-area {
    flex: none; height: auto !important;
    column-count: 1; column-width: auto;
    overflow: visible !important; padding-bottom: 20px;
  }
  .article-figure img { width: 100%; }
  .simple-arrow { display: none; }

  .sim-controls { flex-wrap: wrap; }
  .slider-control { width: 100%; margin: 10px 0; }

  .visual-background {
    position: fixed; top: 0; left: 0; width: 100%;
    height: calc(100svh - 60px);
    transform: none !important;
  }
  body:has(#panel-sim.open) .visual-background {
    transform: translateY(-25svh) !important;
  }

  #legend-container { top: 10px; right: 10px; z-index: 9998; }
  #floating-legend { width: calc(100vw - 20px); max-width: 250px; }
}