:root {
    --primary-color: #003366; /* Institutional Blue */
    --secondary-color: #D4AF37; /* Gold Accent */
    --text-color: #333333;
    --light-bg: #f4f6f9;
    --white: #ffffff;
    --dark-bg: #1a1a1a;
    --transition-speed: 0.3s;
    --font-heading: 'Georgia', serif; /* Authoritative */
    --font-body: 'Helvetica Neue', Helvetica, Arial, sans-serif; /* Readable */
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    overflow-wrap: break-word; /* Prevent long words from breaking layout */
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
    overflow-x: hidden;
}

body {
    font-family: var(--font-body);
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--white);
    overflow-x: hidden;
    position: relative;
}

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

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition-speed);
}

ul {
    list-style: none;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Typography */
h1, h2, h3 {
    font-family: var(--font-heading);
    color: var(--primary-color);
    margin-bottom: 1rem;
}

h1 { font-size: 2.5rem; line-height: 1.2; }
h2 { font-size: 2rem; border-bottom: 3px solid var(--secondary-color); display: inline-block; padding-bottom: 5px; margin-bottom: 2rem; }
h3 { font-size: 1.5rem; }

/* Navigation */
.navbar {
    background: var(--white);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 70px;
    display: flex;
    align-items: center;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.logo {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.nav-links {
    display: flex;
    gap: 20px;
}

.nav-links li a {
    font-weight: 500;
    color: var(--text-color);
    padding: 5px 10px;
}

.nav-links li a:hover, .nav-links li a.active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--secondary-color);
}

.btn-cta {
    background-color: var(--primary-color);
    color: var(--white) !important;
    padding: 8px 16px !important;
    border-radius: 4px;
}

.btn-cta:hover {
    background-color: #002244;
}

/* Mobile Menu */
.menu-toggle {
    display: none;
    cursor: pointer;
    flex-direction: column;
    gap: 5px;
}

.bar {
    width: 25px;
    height: 3px;
    background-color: var(--primary-color);
}

/* Hero Section */
.hero {
    height: 100vh;
    background: url('../../images/Chiesa San Pietro Apostolo/San pietro vernotico veduta aerea.jpg') no-repeat center center/cover;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--white);
    margin-top: 0;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 51, 102, 0.6); /* Blue tint overlay */
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 800px;
    padding: 20px;
    animation: fadeInUp 1s ease-out;
}

.hero-content h1 {
    color: var(--white);
    font-size: 3rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    margin-bottom: 1rem;
}

.hero-content p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

.scroll-down {
    display: inline-block;
    padding: 12px 30px;
    background: var(--secondary-color);
    color: var(--primary-color);
    font-weight: bold;
    border-radius: 5px;
    transition: transform 0.3s;
}

.scroll-down:hover {
    transform: translateY(-3px);
}

/* Sections General */
.section {
    padding: 80px 0;
}

.bg-light {
    background-color: var(--light-bg);
}

.bg-dark {
    background-color: var(--primary-color);
    color: var(--white);
}

.bg-dark h2 {
    color: var(--white);
}

/* Content Grid (History) */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: start;
}

.timeline {
    border-left: 3px solid var(--secondary-color);
    padding-left: 20px;
}

.timeline-item {
    margin-bottom: 30px;
    position: relative;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -28px;
    top: 5px;
    width: 14px;
    height: 14px;
    background: var(--secondary-color);
    border-radius: 50%;
}

.date {
    font-weight: bold;
    color: var(--primary-color);
    display: block;
    margin-bottom: 5px;
}

/* Territory */
.territorio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
}

.info-card {
    background: var(--white);
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    text-align: center;
}

/* Places */
.places-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.place-card {
    background: var(--white);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s;
}

.place-card:hover {
    transform: translateY(-5px);
}

.place-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.card-content {
    padding: 20px;
}

.box-highlight {
    background: #fff8e1; /* Light yellow */
    padding: 25px;
    border-radius: 8px;
    border-left: 5px solid var(--secondary-color);
}

/* Economy */
.economy-flex {
    display: flex;
    flex-wrap: wrap;
    gap: 40px;
    align-items: center;
}

.economy-text {
    flex: 2;
}

.economy-stats {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stat-item {
    background: var(--white);
    padding: 15px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.stat-item .icon {
    font-size: 2rem;
}

/* Gallery & Lightbox */
.gallery-category {
    margin-bottom: 50px;
}

.gallery-category h3 {
    border-left: 4px solid var(--secondary-color);
    padding-left: 10px;
    margin-bottom: 20px;
    color: var(--primary-color);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.gallery-item {
    overflow: hidden;
    border-radius: 8px;
    height: 180px;
    cursor: pointer;
    position: relative;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.gallery-item::after {
    content: '🔍';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 2;
}

.gallery-item:hover::after {
    opacity: 1;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s, filter 0.3s;
}

.gallery-item:hover img {
    transform: scale(1.1);
    filter: brightness(0.7);
}

/* Lightbox Modal */
.lightbox {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.lightbox.active {
    display: flex;
    animation: fadeIn 0.3s;
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 70vh;
    border: 2px solid var(--white);
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    object-fit: contain;
}

#lightbox-caption {
    margin-top: 15px;
    color: #fff;
    text-align: center;
    font-style: italic;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 15px;
    border-radius: 20px;
    max-width: 100%;
    font-size: 1rem;
    line-height: 1.4;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
    z-index: 2001;
}

.lightbox-close:hover {
    color: var(--secondary-color);
}

.lightbox-prev, .lightbox-next {
    cursor: pointer;
    position: absolute;
    top: 50%;
    width: auto;
    padding: 16px;
    margin-top: -50px;
    color: white;
    font-weight: bold;
    font-size: 30px;
    transition: 0.3s ease;
    border-radius: 0 3px 3px 0;
    user-select: none;
    background: transparent;
    border: none;
    z-index: 2001;
}

.lightbox-prev:hover, .lightbox-next:hover {
    background-color: rgba(0,0,0,0.8);
    color: var(--secondary-color);
}

.lightbox-next {
    right: 10px;
    border-radius: 3px 0 0 3px;
}

.lightbox-prev {
    left: 10px;
    border-radius: 3px 0 0 3px;
}


/* Contact Form */
.contact-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 50px;
}

.contact-info {
    color: #ddd;
}

.contact-form {
    background: var(--white);
    padding: 30px;
    border-radius: 8px;
    color: var(--text-color);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

.form-group input, .form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-group input {
    width: auto;
}

.btn-submit {
    background: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 12px 30px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    width: 100%;
    transition: background 0.3s;
}

.btn-submit:hover {
    background: #002244;
}

/* Footer */
footer {
    background: #111;
    color: #aaa;
    padding: 50px 0 20px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 40px;
    margin-bottom: 40px;
}

.footer-col h3, .footer-col h4 {
    color: var(--white);
    margin-bottom: 20px;
}

.footer-col ul li {
    margin-bottom: 10px;
}

.footer-col a:hover {
    color: var(--white);
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid #333;
}

/* Content Figures */
.text-content .content-figure {
    margin: 30px auto;
    max-width: 900px;
    background: var(--white);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}
.text-content .content-figure img {
    width: 100%;
    height: auto;
    aspect-ratio: 16/9;
    object-fit: cover;
    display: block;
}
.text-content .content-figure figcaption {
    padding: 10px 14px;
    font-size: 0.95rem;
    color: #666;
    background: #f7f7f7;
    text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 70px;
        left: 0;
        width: 100%;
        background: var(--white);
        padding: 20px;
        box-shadow: 0 5px 10px rgba(0,0,0,0.1);
        z-index: 1001; /* Ensure it's above everything */
        text-align: center;
    }

    .nav-links li {
        margin: 15px 0;
        width: 100%;
    }

    .nav-links li a {
        display: block;
        width: 100%;
        padding: 10px;
        font-size: 1.1rem;
    }

    .nav-links.active {
        display: flex;
    }

    .menu-toggle {
        display: flex;
        padding: 10px; /* Increase touch area */
    }

    .hero-content h1 {
        font-size: 2rem;
    }

    .content-grid, .contact-wrapper, .economy-flex {
        grid-template-columns: 1fr;
    }

    .timeline {
        border-left: none;
        padding-left: 0;
    }
    
    .timeline-item::before {
        display: none;
    }

    .lightbox-content img {
        max-width: 95%;
        max-height: 70vh;
    }
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
