/* ===== Custom Overrides & Tweaks ===== */

:root {
  --accent-color: #1a6b4e;
  --accent-hover: #13503b;
  --link-color: #1a6b4e;
}

[data-bs-theme="dark"] {
  --accent-color: #3ecf8e;
  --accent-hover: #5edba5;
  --link-color: #3ecf8e;
}

/* Body base */
body {
  font-family: 'Source Sans 3', 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  position: relative;
}

/* Boetti Mappa watermark background (same on all pages) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: url('images/wallpaper-alighiero-boetti16.jpg') center center / cover no-repeat;
  opacity: 0.04;
  pointer-events: none;
}

[data-bs-theme="dark"] body::before {
  opacity: 0.02;
}

/* Desktop: the ::before with z-index:-1 gets hidden by Bootstrap's opaque
   body background on wide viewports. Switch to body background-image with
   a white overlay so the watermark can't be covered. Mobile keeps ::before. */
@media (min-width: 768px) {
  body::before {
    display: none;
  }
  body {
    background-image:
      linear-gradient(rgba(255,255,255,0.92), rgba(255,255,255,0.92)),
      url('images/wallpaper-alighiero-boetti16.jpg');
    background-size: cover;
    background-position: center center;
    background-attachment: fixed;
    background-repeat: no-repeat;
  }
  [data-bs-theme="dark"] body {
    background-image:
      linear-gradient(rgba(33,37,41,0.96), rgba(33,37,41,0.96)),
      url('images/wallpaper-alighiero-boetti16.jpg');
  }
}

/* Links use accent */
a {
  color: var(--link-color);
}
a:hover {
  color: var(--accent-hover);
}

/* ===== Navbar tweaks ===== */
.navbar {
  background-color: var(--bs-body-bg, #fff) !important;
  border-bottom: 1px solid rgba(0,0,0,0.12);
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
  z-index: 1030;
}

[data-bs-theme="dark"] .navbar {
  border-bottom-color: rgba(255,255,255,0.12);
}

.navbar .navbar-brand {
  font-weight: 600;
  font-size: 1.12rem;
  letter-spacing: 0.01em;
  color: inherit;
}

.navbar .nav-link {
  font-size: 0.95rem;
  font-weight: 500;
  padding-left: 0.9rem !important;
  padding-right: 0.9rem !important;
  color: rgba(0,0,0,0.65);
}

.navbar .nav-link:hover {
  color: rgba(0,0,0,0.9);
}

.navbar .nav-link.active {
  font-weight: 600;
  color: rgba(0,0,0,0.9);
}

[data-bs-theme="dark"] .navbar .nav-link {
  color: rgba(255,255,255,0.65);
}

[data-bs-theme="dark"] .navbar .nav-link:hover,
[data-bs-theme="dark"] .navbar .nav-link.active {
  color: rgba(255,255,255,0.9);
}

/* Navbar toggler icon color */
.navbar-toggler {
  border-color: rgba(0,0,0,0.2);
}

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%280,0,0,0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
}

[data-bs-theme="dark"] .navbar-toggler {
  border-color: rgba(255,255,255,0.2);
}

[data-bs-theme="dark"] .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255,255,255,0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
}

/* Navbar tools (search + dark toggle) */
.navbar-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.navbar-tools .nav-tool {
  color: rgba(0,0,0,0.55);
  background: none;
  border: none;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  transition: color 0.2s;
}

.navbar-tools .nav-tool:hover {
  color: rgba(0,0,0,0.9);
}

[data-bs-theme="dark"] .navbar-tools .nav-tool {
  color: rgba(255,255,255,0.55);
}

[data-bs-theme="dark"] .navbar-tools .nav-tool:hover {
  color: rgba(255,255,255,0.9);
}

.navbar-tools .nav-tool-text {
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
}

/* ===== Solana About Layout ===== */
.about-solana {
  display: flex;
  flex-direction: column;
  padding-top: 3em;
  padding-bottom: 1em;
}

.about-entity {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.entity-contents {
  display: flex;
  flex-direction: column;
}

/* Title */
.about-solana .about-title {
  font-size: 2.4rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.about-solana .about-subtitle {
  font-size: 1.05rem;
  line-height: 1.65;
  margin-bottom: 1rem;
  opacity: 0.78;
}

/* Social Links */
.about-links {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  column-gap: 0.7em;
  row-gap: 0.6em;
  padding-bottom: 1.3em;
}

.about-link {
  color: #6c757d;
  text-decoration: none;
  border: 1px solid #6c757d;
  font-size: 0.82em;
  padding: 0.28em 0.55em;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  transition: color 0.2s, border-color 0.2s;
}

.about-link:hover {
  color: var(--accent-color);
  border-color: var(--accent-color);
  text-decoration: none;
}

/* About Contents (bio, sections) */
.about-contents {
  padding-right: 1.5em;
  flex-basis: 0;
  flex-grow: 1;
}

.about-contents p {
  line-height: 1.75;
  margin-bottom: 1rem;
}

.about-contents h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-top: 1.5rem;
  margin-bottom: 0.7rem;
  border-bottom: none;
}

.about-contents ul {
  padding-left: 1.2rem;
}

.about-contents ul li {
  margin-bottom: 0.6rem;
  line-height: 1.6;
}

/* Profile image */
.about-image {
  width: 15em;
  height: 15em;
  object-fit: cover;
  flex-shrink: 0;
}

.about-image.round {
  border-radius: 50%;
}

/* Desktop: show standalone image, hide mobile one */
.about-image-mobile {
  display: none;
}

.about-image-desktop {
  display: block;
}

/* About header (for mobile layout) */
.about-header {
  display: contents;
}

/* ===== Responsive (mobile) ===== */
@media (max-width: 991.98px) {
  .about-entity {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }

  .entity-contents {
    width: 100%;
  }

  /* Show mobile image, hide desktop image */
  .about-image-mobile {
    display: block !important;
    width: 7em;
    height: 7em;
    margin-left: 1em;
    flex-shrink: 0;
  }

  .about-image-desktop {
    display: none !important;
  }

  /* Header: name + photo side by side */
  .about-header {
    display: flex !important;
    align-items: flex-start;
    justify-content: space-between;
  }

  .about-solana .about-title {
    font-size: 1.8rem;
  }

  .about-links {
    flex-direction: row;
    flex-wrap: wrap;
    row-gap: 0.5em;
    column-gap: 0.5em;
    width: 100%;
    padding-bottom: 1.2em;
  }

  .about-link {
    font-size: 0.82em;
    padding: 0.28em 0.55em;
    border-radius: 4px;
  }

  .about-contents {
    padding-right: 0;
    width: 100%;
  }

  /* Hide Research from mobile dropdown (it's shown outside) */
  .navbar-nav .nav-item-research {
    display: none;
  }

  /* Style for Research link outside collapse on mobile */
  .nav-research-mobile {
    color: rgba(0,0,0,0.65) !important;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 0.3rem 0.5rem;
    text-decoration: none;
    margin-left: auto;
  }

  .nav-research-mobile:hover,
  .nav-research-mobile.active {
    color: rgba(0,0,0,0.9) !important;
  }

  [data-bs-theme="dark"] .nav-research-mobile {
    color: rgba(255,255,255,0.65) !important;
  }

  [data-bs-theme="dark"] .nav-research-mobile:hover,
  [data-bs-theme="dark"] .nav-research-mobile.active {
    color: rgba(255,255,255,0.9) !important;
  }

  /* Show "In the Media" inside the mobile menu */
  .navbar-nav .nav-item-media-mobile {
    display: block !important;
  }

  /* Hide "In the Media" from navbar tools on mobile */
  .navbar-tools .nav-tool-text {
    display: none;
  }

  /* Keep search + theme toggle visible on mobile */
  .navbar-tools {
    display: flex !important;
    align-items: center;
    gap: 0.3rem;
    order: 3;
  }
}

/* ===== Standard page content (Research, CV) ===== */
.page-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

.page-content h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.page-content h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 0.8rem;
}

.page-content ul {
  padding-left: 1.2rem;
}

.page-content ul li {
  margin-bottom: 0.8rem;
  line-height: 1.65;
}

/* CV embedded PDF */
.cv-iframe {
  width: 100%;
  height: 650px;
  border: 1px solid rgba(128,128,128,0.25);
  border-radius: 4px;
}

.cv-mobile-link {
  display: none;
}

@media (max-width: 768px) {
  .cv-iframe {
    display: none;
  }
  .cv-mobile-link {
    display: block;
  }
}

/* ===== Search Overlay ===== */
.search-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 9999;
  justify-content: center;
  padding-top: 12vh;
}

.search-overlay.active {
  display: flex;
}

.search-box {
  width: 550px;
  max-width: 90vw;
  background: var(--bs-body-bg, #fff);
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
  padding: 1rem;
  height: fit-content;
}

[data-bs-theme="dark"] .search-box {
  background: #1e1e2e;
}

.search-box input {
  width: 100%;
  border: 1px solid rgba(128,128,128,0.3);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  font-size: 1rem;
  background: transparent;
  color: inherit;
  outline: none;
}

.search-box input:focus {
  border-color: var(--accent-color);
}

.search-results {
  margin-top: 0.7rem;
  max-height: 300px;
  overflow-y: auto;
}

.search-result-item {
  display: block;
  padding: 0.5rem 0.6rem;
  border-radius: 4px;
  color: inherit;
  text-decoration: none;
}

.search-result-item:hover {
  background: rgba(128,128,128,0.1);
  text-decoration: none;
  color: var(--accent-color);
}

.search-result-item .result-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.search-result-item .result-section {
  font-size: 0.8rem;
  opacity: 0.6;
}

/* ===== Abstract toggle ===== */
.abstract-toggle {
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  margin-left: 0.4em;
}

.abstract-text {
  margin-top: 0.5rem;
  padding: 0.8rem 1rem;
  font-size: 0.92rem;
  line-height: 1.7;
  text-align: justify;
  hyphens: auto;
  background: rgba(128,128,128,0.06);
  border-left: 3px solid var(--accent-color);
  border-radius: 2px;
}

/* ===== Journal name ===== */
.journal-name {
  color: #3a3a3a;
}

[data-bs-theme="dark"] .journal-name {
  color: #fff;
}

/* ===== Coverage (press / blogs) ===== */
.coverage {
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 2px solid var(--accent-color);
  font-size: 0.92rem;
  line-height: 1.6;
}

.coverage-label {
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #3a3a3a;
  margin-right: 0.35em;
}

[data-bs-theme="dark"] .coverage-label {
  color: #fff;
}

/* ===== Upcoming talks title ===== */
.upcoming-title {
  color: #c0392b;
  font-weight: 700;
}

[data-bs-theme="dark"] .upcoming-title {
  color: #ff7a70;
}

/* ===== Footer ===== */
.site-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 3.5em;
  font-size: 0.825em;
  padding: 0.5rem 1rem;
  opacity: 0.6;
}

/* ===== Min height ===== */
.quarto-container {
  min-height: calc(100vh - 132px);
}
