
/* Prevent padding from causing overflow */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body { margin:0; font-family: 'Poppins', sans-serif; height: 100%; }




header h1 {
    margin-bottom: 20px;
    font-family: 'Poppins', sans-serif;
    font-size: 1.2rem; /* 40px/16=2.5em */
    font-weight: normal;
    letter-spacing: 8px;
    text-align: center;
}

header h2 {
    font-family: 'Poppins', sans-serif;
    font-size: 0.8rem; /* 40px/16=2.5em */
    font-weight: normal;
    letter-spacing: 2px;
}

header button {
    margin-top: 1rem;
    padding: 0.8rem 1rem;
    background: #0077cc;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    align-items: center;
}

h1 {
  
    font-family: 'Poppins', sans-serif;
    font-size: 1.2rem; /* 40px/16=2.5em */
    font-weight: bold;
    letter-spacing: 8px;
    text-align: center;
}

h2 {
    margin: 0 0 0.5rem 0;
    font-family: 'Poppins', sans-serif;
    font-size: 1.0rem; /* 40px/16=2.5em */
    font-weight: normal;
    letter-spacing: 2px;
    text-align: center;
}

.top-bar a:hover, .top-bar button:hover {
    background: #ccc;
}

section {
    background: transparent;
    padding: 1.0rem;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

section img {
    max-width: 100%;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.menu-toggle {
  font-size:2rem;
  color: black;
  background:none;
  border:none;
  cursor:pointer;
  
  margin-top: 40px;
  position: absolute;
  left: 1rem;
}

/* Base nav menu (mobile dropdown) */
#navMenu {
  display: none;
  position: absolute;
  top:3rem;
  left:1rem;
  background: rgba(255,255,255,0.95);
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
#navMenu.active { display: block; }
#navMenu ul {
  list-style:none;
  margin:0;
  padding:0;
}
#navMenu li { padding:0.5rem 1rem; }
#navMenu a {
  color:black;
  text-decoration:none;
}

/* Desktop: horizontal bar */
@media (min-width:768px) {
  .menu-toggle { display:none; }
  #navMenu {
    display:block;
    position:static;
    background:transparent;
    box-shadow:none;
  }
  #navMenu ul {
    display:flex;
    gap:2rem;
  }
  #navMenu li { padding:0; }
}


/* Main area: vertically centered when there's extra height, but scrolls when taller */
.page-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    background: transparent;
}

/* This block is what gets centered vertically when there is extra space */
.center-when-room {
    margin-block: auto;             /* pushes block to vertical center if there's room */
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;            /* keep inner content centered horizontally wrapper-wise */
    gap: 1rem;
}



main {
    width: 100%;
    max-width: 800px;               /* desktop reading width */
    margin: auto;
    background: transparent;/* horizontal centering */
    /*text-align: left;*/
}

main img {
    display: block;
    max-width: 100%;                /* never exceed container */
    height: auto;
    margin-bottom: 1rem;
    border-radius: 6px;
}

main p {
    font-size: 1.1rem;
    line-height: 1.6;
    overflow-wrap: anywhere;        /* prevent long words/URLs from causing overflow */
    margin: 0;
}

main a {
    display: inline-block;
    margin-top: 1rem;
    color: white;
    text-decoration: none;
}

#langBtn {
margin:2rem auto;
padding:0.5rem 1rem;
font-size:0.8rem;
cursor:pointer;
display:block;
}


/* Mobile: hamburger + dropdown below, no overflow */
@media (max-width: 768px) {
    
    header {
        
        justify-content: flex-start;
    }
    
    .menu-toggle {
        display: block;
    }
    
    .menu-bar {
        justify-content:flex-start;
    }
    
    
    #navMenu ul {
        display: none;                       /* hidden until toggle */
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        background: #f9f9f9;
        width: 180px);             /* fit within viewport */
        border-radius: 4px;
        padding: 0.5rem 0;
        box-shadow: 0 4px 12px rgba(0,0,0,0.12);
        
    }
    
    #navMenu.active ul {
        
        display: flex;
    }
    
    #navMenu a {
        padding: 0.5rem 1rem;
        display: block;
        text-decoration:none;
        font-weight:500;
    }
    
}

/* Grids */
.grid {
    display: grid;
    grid-template-columns: repeat(3, 2fr);
    gap: 0.5rem;
    margin-top: 1rem;
    /*background: transparent;*/
    background: url("") center/cover no-repeat;
    justify-content: center;
}

.grid img {
    width: 100%;
    display: block;
}

.grid2 {
    width: 100%;
    display: block;
}

.caption_home_thumbnail {
    text-decoration: none;
    font-family: 'Poppins', sans-serif;
    font-size: 0.5rem;
    text-align: center;
    font-weight: normal;
    letter-spacing: 2px;
}

.static-img {
display: flex;
justify-content: center;


}

/* Photo overlay */
.photo-page {
display: none;
position: fixed;
inset: 0;
background: #111;
overflow: auto;
z-index: 9999;

}
.photo-page.active { display: flex; }

.photo-page.active {
opacity: 1;
pointer-events: auto;
transition: opacity 0.45s ease-in;
}

/* Disable size transitions while swapping photos (prevents jump) */
.photo-page.no-anim #fullImage {
transition: none !important;
}

/* Container to center image in Fit mode */
.photo-container {
display: grid;
place-items: center;
min-width: 100%;
min-height: 100vh; /* use viewport height for stable centering */
min-height: 100dvh; /* overrides 100vh in browsers that support it */
}

/*
#fullImage {
display: block;
max-width: none;
height: auto;
opacity: 0;
transition: opacity 0.4s ease;
}

/* when image is visible */
#fullImage.show {
opacity: 1;
}

/* the image itself must never be forced to fill width */
#fullImage {
display: block;
max-width: none;
height: auto;
transition: width 0.4s ease, height 0.4s ease;
will-change: width, height;  /* Add this */
}


.photo-page, #fullImage {
touch-action: pan-x pan-y; /* allow scrolling, block pinch-zoom */
transition: width 0.3s ease, height 0.3s ease, transform 0.3s ease;
}

/* Fixed buttons stay at viewport corners */
.photo-btn {
position: fixed;
top: 1rem;
font-size: 1.0rem;
font-weight: bold;
color: white;
background: rgba(0, 0, 0, 0.35);
border: none;
border-radius: 4px;
padding: 0.3rem 0.8rem;
cursor: pointer;
z-index: 1001;
transition: background 0.2s ease;
text-decoration: none;
/* Add this to ensure position is never recalculated: */
transform: translateZ(0);
}
.photo-btn.back { left: 1rem; }
.photo-btn.toggle { right: 1rem; }

/* === Photo overlay navigation buttons === */
.photo-btn.prev,
.photo-btn.next {
position: fixed;
top: 50%;
transform: translateY(-50%);
width: 4rem;
font-size: 2.0rem;
font-weight: bold;
color: white;
background: rgba(0, 0, 0, 0.35);
border: none;
border-radius: 4px;
padding: 0.3rem 0.8rem;
cursor: pointer;
z-index: 1001; /* Make sure they appear above the image */
transition: background 0.2s ease;
}

/* Left and right placement */
.photo-btn.prev {
left: 10px;
}
.photo-btn.next {
right: 10px;
}

/* Hover / active states for desktop */
.photo-btn.prev:hover,
.photo-btn.next:hover {
background: rgba(0, 0, 0, 0.6);
}

/* Hide text selection when tapping */
.photo-btn.prev,
.photo-btn.next {
-webkit-user-select: none;
user-select: none;
}

/* Optional: make them larger & easier to tap on mobile */
@media (max-width: 768px) {
.photo-btn.prev,
.photo-btn.next {
font-size: 2rem;
padding: 0.6rem 1rem;
background: rgba(0,0,0,0.45);
}
}

#fullImage {
display: block;
max-width: none;
height: auto;
opacity: 0;
transition: opacity 0.3s ease, width 0.4s ease, height 0.4s ease;
}

.photo-page.active #fullImage[src] {
opacity: 1;
}


/* Large image with smooth transition
#fullImage {
display: block;
max-width: none;
height: auto;
transition: width 0.4s ease, height 0.4s ease;
}
*/

  /* Carousel */
.carousel {
position: relative;
overflow: hidden;
width: 100%;

/* Maintain aspect ratio (e.g. 16:9) */
aspect-ratio: 16 / 9;
}

/* Position all slides on top of each other */
.carousel img {
position: absolute;
inset: 0; /* shorthand for top:0; right:0; bottom:0; left:0 */
width: 100%;
height: 100%;
object-fit: cover;

opacity: 0;
transition: opacity 2s ease-in-out;
z-index: 0;
pointer-events: none;
}

/* Show active image */
.carousel img.active {
opacity: 1;
z-index: 1;
pointer-events: auto;
}

/* Prevent first active image from "jumping in" */
.carousel img.active:first-child {
transition: none;
}

/* Only for very first load */
.carousel img.initial {
transition: none !important;
}

.asym-gallery {
display: grid;
grid-template-columns: repeat(3, 2fr);
grid-template-rows: repeat(3, 2fr);
aspect-ratio: 1 / 1;
gap: 4px;

grid-template-areas:
"big big side1"
"big big side2"
"bottom1 bottom2 bottom3";
}

  

  .asym-gallery img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    cursor: pointer;
  }

  .big     { grid-area: big; }
  .side1   { grid-area: side1; }
  .side2   { grid-area: side2; }
  .bottom1 { grid-area: bottom1; }
  .bottom2 { grid-area: bottom2; }
  .bottom3 { grid-area: bottom3; }

  @media (max-width: 600px) {
    .asym-gallery { grid-auto-rows: 120px; }
  }
  @media (max-width: 400px) {
    .asym-gallery { grid-auto-rows: 90px; }
  }


.asym-gallery3 {
display: grid;
grid-template-columns: 80% 20%;  /* left = 40%, right = 60% */
gap: 8px;
max-width: 80%;
margin: 0 auto;

/* lock into a rectangle */
aspect-ratio: 3 / 2;
}

.asym-gallery3 .left {
height: 100%; /* force left to full gallery height */
}

.asym-gallery3 .right {
display: grid;
grid-template-rows: 1fr 1fr 1fr; /* 3 equal rows */
gap: 18px;
height: 100%;
}

/* All images fit their containers */
.asym-gallery3 img {
width: 100%;
height: auto;
object-fit: cover;
border-radius: 4px;
}

/* Mobile fallback */
@media (max-width: 768px) {
.asym-gallery3 {
grid-template-columns: 85% 15%;  /* stack */
aspect-ratio: auto;          /* no fixed rectangle */
}

.asym-gallery3 .right {
grid-template-rows: auto auto auto;
}

.asym-gallery3 .left,
.asym-gallery3 .right {
height: auto;
}

.asym-gallery3 img {
height: auto;
}
}

.backcontainer {
position: flex;
display: flex;
z-index: 4001;
margin-top: 1rem;
margin-bottom: 5rem;
justify-content: center;
}

.backcontainer.hidden {

opacity: 0;
pointer-events: none;
}

.links.hidden {

opacity: 0;
pointer-events: none;
}

.links {
position: flex;
display: flex;
z-index: 4000;
margin-top: 1rem;
margin-bottom: 5rem;
justify-content: center;
}

/* Back button */
.back-btn {
margin-top: 1rem;
margin-left: 1rem;
display: flex;
align-items: center;
justify-content: center;
width: 50px;
height: 50px;
border-radius: 50%;
background: rgba(0,0,0,0.5);
color: white;
cursor: pointer;
border: none;
text-decoration: none;
z-index: 6000;
gap: 30px;
}

.back-btn svg {
width: 1.8em;
height: 1.8em;
fill: currentColor;
}

.link-btn {
position: absolute;
color: white;
display: flex;
align-items: center;
justify-content: center;
width: 150px;
height: 36px;
border-radius: 8px;
background: gray;
color: white;
cursor: pointer;
border: none;
text-decoration: none;
z-index: 3000;
gap: 30px;

}

.link-btn.scroll {
margin-right: 10rem;

}

.link-btn.grid {

margin-left: 10rem;

}



/* Hover & tap feedback */
.link-btn:hover {
background: rgba(0,0,0,0.8);
}
.link-btn:active {
transform: scale(0.95);
}

.centered-btn {
display: absolute;
left: 50%;
height: 40px;
border: 8px;
background: gray;
color: white;
border-radius: 4px;
margin-top: 1rem;
margin-bottom: 1rem;
font-family: 'Poppins', sans-serif;
font-size: 1rem;
text-align: center;
font-weight: normal;
padding-left: 1rem;
padding-right: 1rem;
justify-content: center;
}

/* Hide the "Back" text on small screens */
@media (max-width: 768px) {
.back-btn span {
display: none;
}

.link-btn span {
display: none;
}
}

#collage img:hover { transform: scale(1.04); }

.collage .wide { grid-column: span 2; }
.collage .tall { grid-row: span 2; }
.collage .big  { grid-column: span 2; grid-row: span 2; }

/* Irregular collage */
.collage {
display: grid;
grid-template-columns: repeat(var(--collage-columns, 2), 1fr);
grid-auto-rows: 120px;
gap: 8px;
padding: 20px;
grid-auto-flow: dense;
cursor: pointer;
background: #eee url("collage_images/caravaggi.jpg") center/cover no-repeat;
}

.collage img {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
border-radius: 6px;
cursor: zoom-in;
transition: transform 0.2s;
}






/* Viewer overlay */
#viewer {
position: fixed;
inset: 0;
background: rgba(0,0,0,0.9);
display: none;
align-items: center;
justify-content: center;
z-index: 9999;
overflow: hidden;
}
#viewer img {
max-width: 90%;
max-height: 90%;
cursor: grab;
transition: opacity 0.3s ease;
}
#viewer img:active {
cursor: grabbing;
}

#closeViewer {
position: absolute;
top: 20px;
right: 20px;
background: rgba(255, 255, 255, 0.8);
border: none;
font-size: 1.5rem;
cursor: pointer;
border-radius: 4px;
padding: 0.3rem 0.6rem;
z-index: 10000; /* above the image */
}

#closeViewer:hover {
background: rgba(255, 255, 255, 1);
}



/* Spinner */
#spinner {
width: 40px;
height: 40px;
border: 4px solid rgba(255,255,255,0.3);
border-top: 4px solid #fff;
border-radius: 50%;
animation: spin 1s linear infinite;
position: absolute;
display: none;
}
@keyframes spin {
0% { transform: rotate(0); }
100% { transform: rotate(360deg); }
}


figure {
float: left;
width: 200px;
margin: 0 25px 20px 0;
}

figure img {
width: 100%;
height: auto;
border-radius: 4px;
display: block;
padding-right: 1rem;
}

figure figcaption {
font-size: 0.8rem;
color: #555;
text-align: center;
margin-top: 4px;
line-height: 1.3;
}


.media-item {
flex: 1 1 220px;
max-width: auto;
text-align: center;
margin-top: 20;
}

.media-item img {
width: 100%;
height: auto;
cursor: pointer;
}

.media-item video {
width: 100%;           /* image/video fills container */
height: auto;
/*border: 2px solid #ccc;*/
display: block;
cursor: pointer;
}




/* BEGIN COLLAGE (auto-generated) */
:root { --collage-columns: 3; }

#collage img:hover { transform: scale(1.04); }

.collage .wide { grid-column: span 2; }
.collage .tall { grid-row: span 2; }
.collage .big  { grid-column: span 2; grid-row: span 2; }

/* Irregular collage */
.collage {
display: grid;
grid-template-columns: repeat(3, 2fr);
grid-auto-rows: 120px;
gap: 8px;
padding: 20px;
grid-auto-flow: dense;
cursor: pointer;
background: #eee url("collage_images/caravaggi.jpg") center/cover no-repeat;
}

.collage img {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
border-radius: 6px;
cursor: zoom-in;
transition: transform 0.2s;
}
/* END COLLAGE (auto-generated) */
