
:root {
  --main-font-family: 'Palatino Linotype', Times, serif;
}

body.accessible-mode, .accessible-mode {
  --main-font-family: 'OpenDyslexic', 'Comic Sans MS', 'Arial', Helvetica, sans-serif;
}

body.accessible-mode p, .accessible-mode p,
body.accessible-mode .justify, .accessible-mode .justify {
  text-align: left !important;
}

/* Stili per l'intestazione e la navigazione */
header {
  background: linear-gradient(135deg, #1c3d5a, #2a5c85);
  color: white;
  padding: 0;
  /* top = 0, right = 30, bottom = 0, left = 0 */
  /*position: sticky;*/
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  font-family: var(--main-font-family);
}

.header-grid {
  display: grid;
  grid-template-columns: 460px 1fr;
  /* Left image | Title + Nav */
  grid-template-rows: auto auto;
  /* Title on top, nav below */
  grid-template-areas:
    "left title"
    "left nav";
  background: linear-gradient(135deg, #1c3d5a, #2a5c85);
  padding: 0;
  gap: 10px;
}

/* Immagine di sinistra (verticale) */
.left-image {
  margin: 0;
  padding: 0;
  grid-area: left;
}

.left-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Titolo principale */
.title {
  grid-area: title;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.title h1 {
  font-size: 4rem;
  margin: 0;
  color: white;
  font-family: var(--main-font-family);
  margin-top: 5%;
}

/* Navigazione */
.navigation {
  grid-area: nav;
}


/* Contenitore principale del layout */
.nav-container {
  max-width: 100%;
  margin: 0 auto;
  padding: 0;
  display: flex;
}

.nav-list .logo {
  margin: 0;
  padding: 0;
}

.nav-list .logo img {
  display: block;
  margin: 0;
  padding: 0;
}

.nav-list li:not(.logo) a {
  padding: 8px 10px;
}

nav {
  margin-left: 0;
}

.nav-list {
  list-style: none;
  display: flex;
  margin: 0;
  padding: 0;
  align-items: flex-end;
  justify-content: flex-end;
  /* <-- This pushes the menu to the RIGHT */
}


.nav-list>li {
  position: relative;
  margin: 0;
  padding: 0.5% 1%;
}

.nav-list a {
  text-decoration: none;
  color: white;
  font-weight: 600;
  font-size: 1.05rem;
  padding: 8px 12px;
  border-radius: 4px;
  transition: background-color 0.3s ease;
}

.nav-list a:hover,
.nav-list .dropbtn:hover {
  background-color: #3a4e62;
  transform: scale(1.02);
}

.dropdown .dropbtn {
  font-size: 1.05rem;
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  line-height: 1;
}

/* Contenuto del menu a tendina */
.dropdown-content {
  display: none;
  position: absolute;
  background-color: #1c3d5a;
  min-width: 200px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  top: 100%;
  left: 0;
  z-index: 200;
}

.dropdown-content li {
  padding: 0;
  margin: 0;
}

.dropdown-content li a {
  padding: 12px 18px;
  display: block;
  font-weight: 500;
  font-size: 1.05rem;
}

.dropdown-content li a:hover {
  background-color: #3b536a;
  border-radius: 0;
}

/* Show dropdown on hover */
.dropdown:hover .dropdown-content {
  display: block;
}

.site-title {
  font-size: 4rem;
  color: white;
  margin: 0;
  float: right;
  font-family: var(--main-font-family);
}


body {
  font-family: var(--main-font-family);
  background-color: #faf8f5;
  color: #2a3b4c;
  margin: 0;
  padding: 0;
  line-height: 1.8;
  letter-spacing: 0.05em;
  word-spacing: 0.1em;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}


button {
  padding: 10px 20px;
  margin: 0 10px;
  cursor: pointer;
}

p {
  text-align: justify;
}

/* Nasconde di default i visualizzatori */
#viewer_facs {
  display: none;
}

/* Show the active viewer */
#viewer_facs.active {
  display: block;
}


/* parent viewer is a flex row */
#viewer_text {
  display: flex;
  flex-wrap: nowrap;
  /* keep side-by-side; change to wrap if you want multi-row for many boxes */
  align-items: flex-start;
  gap: 15px;
  align-items: stretch;
  padding: 0 15px;
}

/* boxes start hidden by default and only shown when .active */
#viewer_text .box {
  display: none;
  /* hide by default */
  flex: 1 1 0;
  /* equal-share when active */
  min-width: 0;
  /* prevents overflow due to long content */
}

/* active boxes become flex columns and share width equally */
#viewer_text .box.active {
  display: flex;
  flex-direction: column;
}


/* Ensure boxes are hidden by default */
.container {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  width: 100%;
  /* overflow-x: auto; Removed so that position: sticky works */
  gap: 15px;
  /* Equal spacing between boxes */
  padding: 0 15px;
  /* Space before first and after last */
  box-sizing: border-box;
  margin-top: 1.5%;
}

.box {
  flex: 1 1 auto;
  min-width: 0;
  background-color: #8aa4c821;
  border: 1px solid #ccc;
  padding: 20px;
  display: none;
  border-radius: 10px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.05);
}

.box.active {
  display: flex;
  flex-direction: column;
  max-height: auto;
}

/* Ensure images and text boxes are styled correctly */
.box-image,
.box-text-facs {
  flex: 1 1 auto;
  background-color: #8aa4c821;
  border: 1px solid #ccc;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.05);
}

.box-image {
  flex: 1 1 0%;
  position: sticky;
  top: 20px;
  align-self: flex-start;
  max-height: 90vh;
  overflow: auto;
}

.box-image img {
  max-height: 85vh;
  object-fit: contain;
  transition: width 0.2s ease, max-height 0.2s ease;
}

/* Image zoom overlay */
.image-zoom-overlay {
  position: sticky;
  top: 10px;
  z-index: 10;
  display: flex;
  justify-content: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.85);
  padding: 8px 15px;
  border-radius: 25px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  width: max-content;
  margin: 0 auto 10px auto;
}

.image-zoom-overlay button {
  background: #57a99a;
  color: white;
  border: none;
  border-radius: 50%;
  width: 35px;
  height: 35px;
  padding: 0;
  margin: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background-color 0.2s ease;
}

.image-zoom-overlay button:hover {
  background: #77c9d4;
}

.box-text-facs {
  flex: 1 1 0%;
  line-height: 2.2;
  height: max-content;
}

img {
  max-width: 100%;
  max-height: auto;
  display: block;
  margin: auto;
}

.controls {
  padding: 15px;
  background-color: transparent;
  text-align: center;
  width: auto;
  margin: 15px auto 15px;
}

.controls button {
  height: 48px;
  background-color: #57a99a;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.controls button {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}

.controls button:hover .select-btn {
  background-color: #77c9d4;
}

.controls button:hover {
  transform: scale(1.02);
}

.dropdown-wrapper {
  position: relative;
  display: inline-block;
}

.select-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  background-color: #57a99a;
}

.select-btn:hover {
  background-color: #77c9d400;
}

.select-btn .btn-text {
  font-size: 17px;
  font-weight: 500;
  color: white;
}

.select-btn .arrow-dwn {
  display: flex;
  height: 21px;
  width: 21px;
  color: #57a99a;
  font-size: 14px;
  border-radius: 50%;
  background: #fff;
  align-items: center;
  justify-content: center;
  transition: 0.3s;
  margin-left: 8px;
}

.select-btn.open .arrow-dwn {
  transform: rotate(-180deg);
}

.list-items {
  display: none;
  position: absolute;
  z-index: 1000;
  background-color: white;
  padding: 10px;
  border-radius: 8px;
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
  top: 100%;
  left: 0;
  margin-top: 5px;
}

.list-items.show {
  display: block;
  /* Show the dropdown when 'show' class is added */
}

.list-items .item {
  display: flex;
  align-items: center;
  list-style: none;
  height: 50px;
  cursor: pointer;
  transition: 0.3s;
  padding: 0 15px;
  border-radius: 8px;
}

.list-items .item:hover {
  background-color: #f9e79f;
}

.item .item-text {
  font-size: 16px;
  font-weight: 400;
  color: #333;
}

.item .checkbox {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 16px;
  width: 16px;
  border-radius: 4px;
  margin-right: 12px;
  border: 1.5px solid #c0c0c0;
  transition: all 0.3s ease-in-out;
}

.item.checked .checkbox {
  background-color: #f0a500;
  border-color: #f0a500;
}

.checkbox .check-icon {
  color: #fff;
  font-size: 11px;
  transform: scale(0);
  transition: all 0.2s ease-in-out;
}

.item.checked .check-icon {
  transform: scale(1);
}

.hidden {
  display: none;
}

.text-options {
  margin-top: 1rem;
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.side-icons {
  display: flex;
  gap: 15px;
  /* space between icons */
  justify-content: flex-end;
  /* align icons to the right */
  padding: 10px 20px;
}

.side-icons i,
.side-icons div {
  font-size: 30px;
  cursor: pointer;
  color: #1c3d5a;
  /* matches header theme */
  display: flex;
  align-items: center;
  justify-content: center;
}


.settings-panel {
  position: fixed;
  top: 0;
  right: -320px;
  /* Start off-screen */
  width: 300px;
  max-width: 100vw;
  height: 100%;
  background-color: #fdf6e3;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
  overflow-y: auto;
  transition: right 0.3s ease;
  z-index: 9999;
}

.settings-panel.open {
  right: 0;
}

.settings-content {
  padding: 20px;
}

.settings-content h2 {
  margin-top: 0;
}

.close-btn {
  font-size: 28px;
  cursor: pointer;
  float: right;
}

/* Sliding panel default hidden */
.legend-panel {
  position: fixed;
  top: 0;
  right: -300px;
  /* hidden by default */
  width: 300px;
  max-width: 100vw;
  height: 100%;
  background-color: #f9f9f9;
  box-shadow: -2px 0 5px rgba(0, 0, 0, 0.2);
  transition: right 0.3s ease;
  z-index: 1000;
  overflow-y: auto;
}

/* Panel content */
.legend-content {
  padding: 20px;
}

/* Open state */
.legend-panel.open {
  right: 0;
}

/* Close button */
.legend-content .close-btn {
  float: right;
  cursor: pointer;
  font-weight: bold;
}


.pagination {
  margin-top: 1rem;
  margin-bottom: 2rem;
  text-align: center;
  font-family: sans-serif;
}

.pagination button,
.pagination input {
  margin: 0 0.25rem;
  padding: 0.5rem;
}

.footer {
  background: linear-gradient(135deg, #152d43, #1c3d5a);
  color: #e0e0e0;
  padding: 40px 20px;
  font-family: var(--main-font-family);
  font-size: 15px;
  margin-top: auto;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
}

/* Layout a griglia per il piè di pagina */
.footer-container {
  max-width: 1200px;
  margin: auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 30px;
}

/* Column headings */
.footer-col h5 {
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 1.1rem;
  border-bottom: 2px solid #57a99a;
  padding-bottom: 8px;
  color: #ffffff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Lists inside footer */
.footer-col ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.footer-col ul li {
  margin: 0;
  padding: 5px 0;
  transition: transform 0.2s ease;
}

.footer-col ul li:hover {
  transform: translateX(5px);
}

.footer-col p {
  margin: 8px 0;
  font-size: 14px;
}

/* Footer links */
.footer a {
  color: #88c9bb;
  text-decoration: none;
  transition: color 0.3s ease;
}

.footer a:hover {
  color: #ffffff;
}

/* Footer logos/images */
/* Footer logos column */
.footer-logos {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 15px;
}

/* Footer logos */
.footer-logo {
  max-width: 140px;
  height: auto;
  display: block;
  background: rgba(255, 255, 255, 0.9);
  padding: 8px;
  border-radius: 6px;
  transition: transform 0.3s ease;
}

.footer-logo:hover {
  transform: scale(1.05);
}

/* Small text */
.footer small {
  display: block;
  margin-top: 15px;
  font-size: 0.85rem;
  color: #a0aab5;
  line-height: 1.5;
}

.footer small img {
  vertical-align: middle;
  margin-bottom: 4px;
}

/* Stack columns only on small screens */
@media (max-width: 900px) {
  .footer-container {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .footer-container {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .footer-logos {
    align-items: center;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

h2 {
  font-size: 20px;
  text-align: center;
}

h3 {
  font-size: 18px;
  text-align: center;
}

h4 {
  font-size: 18px;
}

p {
  font-size: 16px;
}

.break {
  display: none;
}

.show-breaks .break {
  display: inline;
}

.foreign{
  font-style: italic;
}

.mod-intervento-1 {
  text-decoration: underline;
  text-decoration-color: #71e5fa;
  text-decoration-thickness: 2px;
}

.mod-intervento-2 {
  text-decoration: underline;
  text-decoration-color: #60b8f4;
  text-decoration-thickness: 2px;
}

.mod-intervento-3 {
  text-decoration: underline;
  text-decoration-color: #0d6efd;
  text-decoration-thickness: 2px;
}

.archivista {
  color: #ff5132;
}

.archivista-sotto,
.archivista-sotto u {
  text-decoration-line: underline !important;
  text-decoration-color: #ff5132 !important;
}

.pb {
  color: #888;
  font-size: 12px;
  display: inline-block;
  float: right;
  margin-top: 2%;
}

.intervento1{
    border-radius: 5px;
    border: 2px solid #71e5fa;
    background-color: beige !important;
    display: block;
    width: 55% !important;
    margin: 2px auto -15px 0 !important;
    padding: 5px !important;
    font-size: 0.9em;
    line-height: 1.3;
    text-decoration: none !important;
    box-sizing: border-box;
    text-align: left;
}

.intervento2{
    border-radius: 5px;
    border: 2px solid #60b8f4;
    background-color: beige !important;
    display: block;
    width: 55% !important;
    margin: 2px auto -15px 0 !important;
    padding: 5px !important;
    font-size: 0.9em;
    line-height: 1.3;
    text-decoration: none !important;
    box-sizing: border-box;
    text-align: left;
}

.intervento3{
    border-radius: 5px;
    border: 2px solid #0d6efd;
    background-color: beige !important;
    display: block;
    width: 55% !important;
    margin: 2px auto -15px 0 !important;
    padding: 5px !important;
    font-size: 0.9em;
    line-height: 1.3;
    text-decoration: none !important;
    box-sizing: border-box;
    text-align: left;
}

.missed-delation, .omitted-in-original, .omitted-accent, .omitted-apostrophe, .missed-in-the-original{
  text-decoration-color: red;
}

.omitted-in-original, .omitted-accent, .omitted-apostrophe, .missed-in-the-original{
  color: red;
}

.archivista{
  color: #ffa632;
}

a{
  color: rgb(97, 96, 96);
}

/* Touch Targets and Global Mobile Constraints */
.select-btn, .pagination button, .pagination input {
  min-height: 44px;
  min-width: 44px;
}

#viewer_text .box.active {
  width: 100%;
  margin-bottom: 20px;
}

.dropdown-content {
  max-width: 90vw;
  white-space: normal;
}

/* Layout responsivo (adattabile su dispositivi mobili) */
@media (max-width: 1024px) {
  .header-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "left"
      "title"
      "nav";
  }

  .left-image img {
    max-height: 250px;
    width: 100%;
    object-fit: cover;
  }

  .title h1 {
    font-size: 3rem;
    margin-top: 2%;
  }

  .nav-list {
    flex-wrap: wrap;
    justify-content: center;
  }

  .nav-list>li {
    padding: 2%;
  }

  .nav-list a, .dropdown .dropbtn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .container {
    flex-direction: column;
  }

  .box-image {
    position: static;
    width: 100%;
    max-height: 60vh;
  }

  #viewer_text {
    flex-direction: column;
  }
  
  .box-text-facs, #viewer_text .box.active {
    width: 100%;
    box-sizing: border-box;
    overflow-wrap: break-word;
  }
}

@media (max-width: 480px) {
  .title h1 {
    font-size: 2rem;
  }
}


/*Per le citazioni*/

/* Stile per la citazione */
.citazione {
    position: relative;
    border-bottom: 1px dotted #ccc;
    cursor: help;
    display: inline-block;
    font-style: italic; /* Testo della citazione in corsivo */
}

/* Stile per il tooltip */
.tooltip-text {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #f9f9f9;
    border: 1px solid #ccc;
    padding: 5px 10px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-size: 0.9em;
    font-style: normal; /* **Sovrascrive il corsivo ereditato** */
}

/* Mostra il tooltip al passaggio del mouse */
.citazione:hover .tooltip-text {
    display: block;
}

/* Mantiene il corsivo per i tag <i> all'interno del tooltip */
.tooltip-text i {
    font-style: italic; /* **Forza il corsivo per i tag <i>** */
}

/* Note */

/* Stile per il link alla nota */
sup a {
    text-decoration: none; /* Rimuove la sottolineatura */
    color: inherit; /* Mantiene il colore del testo */
    cursor: pointer; /* Cambia il cursore in mano al passaggio */
}

/* Stile per il paragrafo della nota */
.footnote {
    font-size: 0.9em; /* Dimensione più piccola */
    margin-top: 1em; /* Spaziatura sopra */
    border-top: 1px solid #ccc; /* Linea separatrice */
    padding-top: 0.5em; /* Spaziatura interna */
    font-style: italic; /* Testo in corsivo (opzionale) */
}

/* TEI Choice Tooltips */
.choice-tooltip-container {
    position: relative;
    display: inline-block;
    cursor: help;
    border-bottom: 2px dotted #888;
}

.choice-tooltip-cloud {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    z-index: 100;
    white-space: nowrap;
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    font-size: 0.95em;
    font-style: normal;
    text-align: center;
}



.choice-tooltip-cloud span {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    color: #fff;
    font-weight: 500;
    position: relative;
}

/* Pseudo-element for the tooltip arrow attached to the colored span */
.choice-tooltip-cloud span::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: transparent;
}

.choice-tooltip-container:hover .choice-tooltip-cloud {
    display: block;
}

/* Colors for specific TEI elements */
.corr {
    background-color: #57a99a; 
}
.corr::after {
    border-top-color: #57a99a;
}

.expan {
    background-color: #d883b7; 
}
.expan::after {
    border-top-color: #d883b7;
}


/* Make sure inner elements match parent background for arrow */
.choice-tooltip-cloud .corr { background-color: #86da5f; }
.choice-tooltip-cloud .expan { background-color: #d883b7; }

/* ========================================= */
/* CRONOLOGIA SCRITTURA (Writing Chronology) */
/* ========================================= */

/* 1. Prima stesura (First Draft) */
body.chrono-1 .tei-del,
body.chrono-1 .missed-delation {
    text-decoration: none !important;
}
body.chrono-1 .tei-add {
    display: none !important;
}

/* 2. Primo intervento (First Intervention) */
body.chrono-2 .mod-intervento-2 .tei-add,
body.chrono-2 .mod-intervento-3 .tei-add {
    display: none !important;
}
/* Deletions from level 2, 3 remain normal */
body.chrono-2 .mod-intervento-2 .tei-del,
body.chrono-2 .mod-intervento-3 .tei-del {
    text-decoration: none !important;
}
/* If text was added in level 1 and deleted later, it is marked as a deletion INSIDE a level 1 addition. 
   In Primo intervento, it should still be visible and NOT struck (it gets struck in Secondo intervento). */
body.chrono-2 .mod-intervento-1 .tei-add .tei-del {
    text-decoration: none !important;
}

/* 3. Secondo intervento (Second Intervention) */
body.chrono-3 .mod-intervento-3 .tei-add {
    display: none !important;
}
body.chrono-3 .mod-intervento-3 .tei-del {
    text-decoration: none !important;
}
/* Text added in level 2 and deleted later should not be struck yet */
body.chrono-3 .mod-intervento-2 .tei-add .tei-del {
    text-decoration: none !important;
}

/* Visibility logic for full span blocks (.intervento1, 2, 3) */
body.chrono-1 .intervento1,
body.chrono-1 .intervento2,
body.chrono-1 .intervento3 {
    display: none !important;
}

body.chrono-2 .intervento2,
body.chrono-2 .intervento3 {
    display: none !important;
}

body.chrono-3 .intervento3 {
    display: none !important;
}

/* Surplus logic */
body.hide-surplus-strike .missed-delation,
body.hide-surplus-strike .tei-del:has(.missed-delation) {
    text-decoration: none !important;
    background-color: transparent !important;
}
