/* Typography */
.page-shell {
  padding-top: 6rem;
  padding-bottom: 4rem;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  margin-left: auto;
  margin-right: auto;
  max-width: 56rem;
}

@media (min-width: 768px) {
  .page-shell {
    padding-left: 2.5rem;
    padding-right: 2.5rem;
  }
}

.page-shell-wide {
  padding-top: 6rem;
  padding-bottom: 6rem;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  margin-left: auto;
  margin-right: auto;
  max-width: 80rem;
}

@media (min-width: 768px) {
  .page-shell-wide {
    padding-left: 2.5rem;
    padding-right: 2.5rem;
  }
}

.page-h1 {
  font-weight: 300;
  font-size: 1.875rem;
  line-height: 2.25rem;
  letter-spacing: -0.025em;
  margin-bottom: 2rem;
}

@media (min-width: 768px) {
  .page-h1 {
    font-size: 2.25rem;
    line-height: 2.5rem;
    margin-bottom: 2.5rem;
  }
}

.page-body {
  font-weight: 300;
  font-size: 1rem;
  line-height: 1.625;
  color: rgb(255 255 255 / 0.6);
}

@media (min-width: 768px) {
  .page-body {
    font-size: 1.05rem;
  }
}

.page-lead {
  font-weight: 300;
  font-size: 1rem;
  line-height: 1.625;
  color: rgb(255 255 255 / 0.7);
}

@media (min-width: 768px) {
  .page-lead {
    font-size: 1.05rem;
  }
}

.page-caption {
  font-weight: 300;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: rgb(255 255 255 / 0.5);
}

.page-project-desc {
  font-weight: 300;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: rgb(255 255 255 / 0.32);
}

.page-project-credit {
  font-weight: 300;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: rgb(255 255 255 / 0.22);
}

.page-section-h2 {
  font-weight: 300;
  font-size: 0.875rem;
  line-height: 1.25rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgb(255 255 255 / 0.4);
  margin-bottom: 1.5rem;
}

.page-eyebrow {
  font-weight: 300;
  font-size: 0.6875rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.page-link {
  font-weight: 300;
  color: rgb(255 255 255 / 0.5);
  text-decoration-line: underline;
  text-underline-offset: 4px;
  text-decoration-color: rgb(255 255 255 / 0.3);
  transition: color 200ms ease, text-decoration-color 200ms ease;
}

.page-link:hover {
  color: rgb(255 255 255 / 0.8);
  text-decoration-color: rgb(255 255 255 / 0.6);
}

.page-card-title {
  font-weight: 300;
  font-size: 1.25rem;
  line-height: 1.75rem;
  color: #fff;
}

.page-card-meta {
  font-weight: 300;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: rgb(255 255 255 / 0.5);
  margin-top: 0.25rem;
}

/* Smooth scroll and canvas bg (html has a color, so body bg does not propagate) */
html {
  scroll-behavior: smooth;
  min-height: 100%;
  background-color: #0a0a0a;
  background-image: url('../img/bg.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

/* Firefox scrollbar fallback */
@supports (-moz-appearance: none) {
  html {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) #0a0a0a;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* Webkit scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #0a0a0a;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: #10224d;
}

/* Hero scroll hint */
@keyframes nudge {
  0%, 100% {
    transform: translateY(0);
    opacity: 0.8;
  }
  50% {
    transform: translateY(6px);
    opacity: 1;
  }
}

.animate-nudge {
  animation: nudge 2.4s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .animate-nudge {
    animation: none;
  }
}

/* Grid reveal */
.reveal.is-visible {
  opacity: 1 !important;
  transform: translateY(0) !important;
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* Touch devices: show title overlay without hover */
@media (hover: none) {
  .group .group-hover\:opacity-100 {
    opacity: 1 !important;
    transform: translateY(0) !important;
  }

  .group .group-hover\:bg-black\/55 {
    background-color: rgb(0 0 0 / 0.35) !important;
  }

  .group img {
    filter: none !important;
    transform: none !important;
  }
}

/* Focus visible for keyboard navigation */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible {
  outline: 1px solid rgba(245, 245, 244, 0.8);
  outline-offset: 3px;
}

/* View transitions (Chrome/Edge) */
@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 300ms;
}

/* Overlay blu — lightbox e modale testo (bg.png, come landing) */
#lightbox,
.text-modal,
.text-modal::backdrop {
  background-color: #0a0a0a;
  background-image: url('../img/bg.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

#lightbox {
  opacity: 0;
  transition: opacity 0.5s ease;
}

#lightbox.is-open {
  display: block;
}

#lightbox.is-open.is-visible {
  opacity: 1;
}

body.lightbox-open {
  overflow: hidden;
}

.lightbox-viewport {
  box-sizing: border-box;
}

#lightbox-img {
  max-height: calc(100vh - 10rem);
  opacity: 0;
  transition: opacity 0.5s ease;
}

#lightbox-img.is-visible {
  opacity: 1;
}

#lightbox-img.is-fading {
  opacity: 0;
  transition: opacity 0.5s ease;
}

@media (prefers-reduced-motion: reduce) {
  #lightbox,
  #lightbox-img,
  #lightbox-img.is-fading {
    transition: none;
  }
}

.lightbox-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  font-size: 1.25rem;
  line-height: 1;
  color: rgba(255, 255, 255, 0.3);
  background: transparent;
  border: none;
  transition: color 200ms ease, transform 200ms ease;
}

.lightbox-nav:hover {
  color: rgba(255, 255, 255, 0.8);
  transform: scale(1.1);
}

@media (min-width: 768px) {
  .lightbox-nav {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.5rem;
  }

  #lightbox-img {
    max-height: calc(100vh - 12rem);
  }
}

/* Lightbox — pubblicazioni: mobile pinch */
.lightbox--loupe .lightbox-hint--desktop {
  display: none;
}

.lightbox--loupe .lightbox-desktop-pane {
  display: none;
}

.lightbox--loupe .lightbox-mobile-pane {
  display: flex;
  height: 100%;
}

.lightbox--loupe .lightbox-stage-content {
  height: 100%;
}

.lightbox--loupe #lightbox-img.lightbox-img--zoomable {
  max-height: min(90vh, 2400px);
  max-width: min(92vw, 2400px);
  width: auto;
  height: auto;
  transform-origin: center center;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
}

.lightbox-zoom-surface {
  overflow: hidden;
  touch-action: none;
  max-height: calc(100vh - 10rem);
  min-height: 12rem;
  cursor: grab;
}

.lightbox-zoom-surface.is-grabbing {
  cursor: grabbing;
}

.lightbox-hint {
  transition: opacity 0.4s ease;
}

.lightbox-hint.is-hidden {
  opacity: 0;
}

/* Lightbox — pubblicazioni: desktop lente dual-pane */
@media (min-width: 1024px) and (pointer: fine) {
  .lightbox--loupe .lightbox-hint--mobile {
    display: none;
  }

  .lightbox--loupe .lightbox-hint--desktop {
    display: block;
  }

  .lightbox--loupe .lightbox-mobile-pane {
    display: none;
  }

  .lightbox--loupe .lightbox-desktop-pane {
    display: flex;
  }

  .lightbox--loupe .loupe-split {
    max-height: calc(100vh - 11rem);
  }

  .lightbox--loupe .loupe-preview {
    flex: 2 1 0;
  }

  .lightbox--loupe .loupe-detail {
    flex: 3 1 0;
  }

  .lightbox--loupe #lightbox-stage .lightbox-nav {
    top: 50%;
    transform: translateY(-50%);
  }
}

.loupe-preview {
  cursor: zoom-in;
}

.loupe-preview:focus {
  outline: 2px solid rgba(255, 255, 255, 0.35);
  outline-offset: 2px;
}

.loupe-lens {
  box-sizing: border-box;
}

.loupe-detail-img {
  transform-origin: 0 0;
  will-change: transform;
}

.lightbox--loupe.is-static-loupe .loupe-lens {
  display: none !important;
}

.lightbox--loupe.is-static-loupe .loupe-preview {
  cursor: default;
}

@media (min-width: 768px) {
  .lightbox-zoom-surface {
    max-height: calc(100vh - 12rem);
  }

  .lightbox--loupe #lightbox-img.lightbox-img--zoomable {
    max-height: min(88vh, 2400px);
    max-width: min(85vw, 2400px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox--loupe #lightbox-img.lightbox-img--zoomable,
  .loupe-detail-img {
    will-change: auto;
  }
}

/* Homepage hero */
.home-hero {
  isolation: isolate;
}

/* Navbar readability */
#site-nav .nav-inner,
#site-nav .nav-inner a {
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.85);
}

#site-nav:not(.is-scrolled) {
  border-bottom: none;
}

#site-nav.nav-on-hero:not(.is-scrolled) {
  background: linear-gradient(
    to bottom,
    rgba(10, 10, 10, 0.72) 0%,
    rgba(10, 10, 10, 0.28) 70%,
    rgba(10, 10, 10, 0) 100%
  );
}

/* Nav scrolled state */
#site-nav.is-scrolled {
  background-color: rgba(10, 10, 10, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom-width: 1px;
  border-bottom-style: solid;
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

#site-nav.nav-on-hero.is-scrolled {
  background-color: rgba(10, 10, 10, 0.7);
  background-image: none;
}

/* Columns masonry */
.monografie-mosaic,
.pubblicazioni-mosaic {
  column-fill: balance;
}

.monografie-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem;
}

.monografie-cover {
  display: block;
  width: 100%;
}

.monografie-trigger {
  display: block;
}

@media (min-width: 640px) {
  .monografie-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .monografie-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
  }

  .monografie-card {
    display: flex;
    flex-direction: column;
    height: 100%;
  }

  button.monografie-trigger {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .monografie-cover {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    min-height: 0;
  }
}

#lightbox.is-single .lightbox-nav,
#lightbox.is-single #lightbox-thumbs-wrap {
  display: none;
}

/* Bio HTML content */
.bio-html-content p {
  margin-bottom: 1.5rem;
}

.bio-html-content p:last-child {
  margin-bottom: 0;
}

.bio-html-content a {
  color: rgb(255 255 255 / 0.5);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.bio-html-content a:hover {
  color: rgb(255 255 255 / 0.8);
}

/* Text modal — layout only (typography uses .page-h1 / .page-body) */
.text-modal {
  position: fixed;
  inset: 0;
  margin: 0;
  border: 0;
  padding: 0;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  overflow: hidden;
  color: inherit;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.text-modal.is-visible {
  opacity: 1;
}

.text-modal::backdrop {
  opacity: 0;
  transition: opacity 0.5s ease;
}

.text-modal.is-visible::backdrop {
  opacity: 1;
}

.text-modal__panel {
  box-sizing: border-box;
  max-width: 56rem;
  max-height: 100%;
  margin-left: auto;
  margin-right: auto;
  overflow-y: auto;
  padding-top: 6rem;
  padding-bottom: 4rem;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

@media (min-width: 768px) {
  .text-modal__panel {
    padding-left: 2.5rem;
    padding-right: 2.5rem;
  }
}

.text-modal__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  margin: 0;
  border: 0;
  background: transparent;
  color: rgb(255 255 255 / 0.7);
  cursor: pointer;
}

@media (min-width: 768px) {
  .text-modal__close {
    top: 1.5rem;
    right: 1.5rem;
  }
}

.text-modal__close:hover {
  color: #fff;
}

body.text-modal-open {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .text-modal,
  .text-modal::backdrop {
    transition: none;
  }
}

.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }
.scrollbar-hide::-webkit-scrollbar { display: none; }
