/* --- 0. UNIVERSAL RESET --- */
* {
    box-sizing: border-box;
}

/* --- 1. BRAND VARIABLES (Italian Flag Palette) --- */
:root {
    --brand-black: #1a1a1a;
    --brand-white: #ffffff;
    --italian-green: #008C45; /* Official Flag Green */
    --italian-red:   #CD212A; /* Official Flag Red */
    --brand-font: 'Libre Franklin', sans-serif;
}

/* --- 2. GLOBAL DEFAULTS (The "Paper" Look) --- */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--brand-white);
    color: #333333;
    font-family: var(--brand-font);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- 3. HOME PAGE EXCEPTION (The "Cinematic" Look) --- */
body.home-bg {
    background-image: url('../images/lupini.png'); 
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-color: #111; 
    color: var(--brand-white);
}

/* --- 4. THE FRAME (Header & Footer) --- */

header {
    background-color: var(--brand-black);
    color: var(--brand-white);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between; /* Logo Left, Nav Right */
    align-items: center;
    transition: background 0.3s ease;
}

/* Nav Links - Black & White Theme */
header nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 25px;
}

header nav a {
    color: var(--brand-white);
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 1px;
    font-weight: 600;
}

/* The "Italian Touch" on Header Hover */
header nav a:hover {
    color: var(--italian-green); /* Green highlight in header */
    text-decoration: none;
}

footer {
    background-color: var(--brand-black);
    color: var(--brand-white);
    padding: 20px;
    text-align: center;
    margin-top: auto;
    font-size: 0.8rem;
}

/* Override: Transparent Header ONLY on Home Page */
body.home-bg header {
    background-color: rgba(0, 0, 0, 0.4); /* Slightly darker tint for readability */
    position: absolute;
    width: 100%;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

/* --- 5. MOBILE FIXES (Responsive Header) --- */
@media (max-width: 768px) {
    header {
        flex-direction: column; /* Stack vertically */
        padding: 15px;
        gap: 15px;
    }
    
    header nav ul {
        gap: 15px;
        flex-wrap: wrap; /* Allow wrapping if screen is tiny */
        justify-content: center;
    }
}

/* --- 6. LAYOUT & HERO --- */
main {
    flex: 1;
    padding: 20px;
    position: relative;
}

.content-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.hero-text {
    text-align: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.hero-text h1 {
    font-size: 4rem;
    margin: 0;
    text-transform: lowercase;
    letter-spacing: -2px;
}

.hero-text p {
    font-size: 1.2rem;
    margin-top: 10px;
    font-weight: 300;
    opacity: 0.9;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* --- 7. LINKS & INTERACTIONS --- */

/* Standard Links (on white pages) -> ITALIAN RED */
a {
    color: var(--italian-red); 
    text-decoration: none;
    transition: 0.3s;
    font-weight: 600;
}
a:hover {
    color: #a00000; /* Darker red on hover */
    text-decoration: underline;
}

/* Home Page Links -> WHITE (Red Hover) */
body.home-bg a {
    color: var(--brand-white); 
    text-shadow: none;
    font-weight: normal;
}
body.home-bg a:hover {
    color: var(--italian-red);
}

/* --- 8. SHARED COMPONENTS (Buttons & Cards) --- */

/* Category Buttons */
.category-nav {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.cat-btn {
    padding: 8px 24px;
    background-color: var(--brand-white);
    border: 1px solid #ccc;
    border-radius: 30px; /* Pill shape */
    color: var(--brand-black);
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
    font-weight: 600;
}

/* Active/Hover State -> ITALIAN GREEN */
.cat-btn:hover, .cat-btn.active {
    background-color: var(--italian-green);
    color: var(--brand-white);
    border-color: var(--italian-green);
    box-shadow: 0 4px 6px rgba(0,140,69,0.3);
}

/* Card Grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
}

/* Cards */
.card {
    background-color: #fff;
    border: 1px solid #eee;
    border-radius: 4px; /* Slight rounding, keeps it sharp */
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: transform 0.3s, box-shadow 0.3s;
    display: block;
    color: inherit;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    border-bottom: 3px solid var(--italian-green); /* Subtle accent on hover */
}

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

.card-content {
    padding: 20px;
}

.card h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.25rem;
    color: var(--brand-black);
}

.card p {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0;
}

/* =========================================
   NEW GALLERY & LIGHTBOX STYLES
   ========================================= */

/* Gallery Grid Layout */
.aligngrid {
    display: grid;
    /* This creates a responsive grid that fits as many items as possible */
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    padding: 20px 0; 
    width: 100%;
}

.archive-gallery-item {
    background: white;
    padding: 10px;
    border: 1px solid #ddd;
    text-align: center;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
}

.archive-gallery-item:hover {
    transform: translateY(-5px);
}

.archive-gallery-item a {
    text-decoration: none;
    color: inherit; 
    display: block;
}

.archive-gallery-item img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    display: block; 
    margin: 0 auto;
}

.links-page-date {
    font-size: 0.85em;
    opacity: 0.7;
    display: block;
    margin-top: 8px;
    color: #666;
}

.links-page-span {
    font-weight: bold;
    font-size: 0.95em;
    display: block;
    margin-top: 5px;
    line-height: 1.4;
    color: #333;
}

/* LIGHTBOX (MODAL) STYLES */
.lightbox-overlay {
    display: none; 
    position: fixed;
    z-index: 9999; 
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.95); 
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

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

.lightbox-content {
    position: relative;
    width: auto;
    max-width: 90%;
    max-height: 90vh; 
    margin: auto;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.lightbox-content img, 
.lightbox-content video {
    max-width: 100%;
    max-height: 80vh; 
    border: 2px solid white;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    display: block;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 50px;
    font-weight: bold;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 10000;
    line-height: 1;
}

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