/*
 * IL BORGO DEL CASTELLO - Design System
 * Guest House Cremolino, Alto Monferrato
 * ilborgodelcastello.it
 */

/* ========================================
   CSS VARIABLES (Design Tokens)
   ======================================== */
:root {
    /* Colors - Shabby Chic Palette */
    --color-primary: #8B7355;        /* Marrone pietra */
    --color-primary-dark: #6B5544;   /* Marrone scuro */
    --color-accent: #C4A77D;         /* Oro antico */
    --color-accent-light: #D4BC9A;   /* Oro chiaro */
    --color-background: #FAF7F2;     /* Crema caldo */
    --color-surface: #FFFFFF;        /* Bianco */
    --color-text: #2C2C2C;           /* Testo scuro */
    --color-text-light: #666666;     /* Testo secondario */
    --color-border: #E8E4DE;         /* Bordi leggeri */
    
    /* Semantic Colors */
    --color-success: #7D9B76;
    --color-warning: #D4A574;
    --color-error: #C47C7C;
    
    /* Typography */
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    
    /* Font Sizes - Fluid Typography */
    --fs-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
    --fs-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
    --fs-base: clamp(1rem, 0.9rem + 0.5vw, 1.125rem);
    --fs-lg: clamp(1.125rem, 1rem + 0.6vw, 1.25rem);
    --fs-xl: clamp(1.25rem, 1.1rem + 0.75vw, 1.5rem);
    --fs-2xl: clamp(1.5rem, 1.25rem + 1.25vw, 2rem);
    --fs-3xl: clamp(2rem, 1.5rem + 2.5vw, 3rem);
    --fs-4xl: clamp(2.5rem, 2rem + 3vw, 4rem);
    --fs-hero: clamp(3rem, 2rem + 5vw, 6rem);
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;
    --space-4xl: 6rem;
    --space-section: clamp(4rem, 3rem + 5vw, 8rem);
    
    /* Layout */
    --container-max: 1200px;
    --container-narrow: 800px;
    --header-height: 80px;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.15);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 300ms ease;
    --transition-slow: 500ms ease;
    --transition-smooth: 600ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   RESET & BASE STYLES
   ======================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    font-size: var(--fs-base);
    line-height: 1.7;
    color: var(--color-text);
    background-color: var(--color-background);
}

/* CLS Fix: Reserve space for images and videos */
img, video {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-accent);
}

/* ========================================
   TYPOGRAPHY
   ======================================== */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 500;
    line-height: 1.2;
    color: var(--color-text);
}

h1 { font-size: var(--fs-4xl); }
h2 { font-size: var(--fs-3xl); }
h3 { font-size: var(--fs-2xl); }
h4 { font-size: var(--fs-xl); }
h5 { font-size: var(--fs-lg); }
h6 { font-size: var(--fs-base); }

.text-accent {
    color: var(--color-accent);
}

.text-light {
    color: #595959; /* Improved contrast ratio from #666666 */
}

.text-center { text-align: center; }

/* ========================================
   LAYOUT UTILITIES
   ======================================== */
.container {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.container--narrow {
    max-width: var(--container-narrow);
}

.section {
    padding: var(--space-section) 0;
}

.grid {
    display: grid;
    gap: var(--space-xl);
}

.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
    .grid--2, .grid--3, .grid--4 {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-xl);
    font-family: var(--font-body);
    font-size: var(--fs-sm);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn--primary {
    background: var(--color-primary);
    color: var(--color-surface);
    border-color: var(--color-primary);
}

.btn--primary:hover {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn--secondary {
    background: transparent;
    color: var(--color-primary);
    border-color: var(--color-primary);
}

.btn--secondary:hover {
    background: var(--color-primary);
    color: var(--color-surface);
}

.btn--accent {
    background: var(--color-accent);
    color: var(--color-text);
    border-color: var(--color-accent);
}

.btn--accent:hover {
    background: var(--color-accent-light);
    border-color: var(--color-accent-light);
}

.btn--large {
    padding: var(--space-lg) var(--space-2xl);
    font-size: var(--fs-base);
}

/* ========================================
   HEADER & NAVIGATION
   ======================================== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: var(--header-height);
    display: flex;
    align-items: center;
    background: rgba(250, 247, 242, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border);
    transition: all var(--transition-base);
}

.header--transparent {
    background: transparent;
    border-bottom-color: transparent;
}

.header--scrolled {
    background: rgba(250, 247, 242, 0.98);
    box-shadow: var(--shadow-sm);
}

.header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.header__logo img {
    height: 50px;
    width: auto;
}

.nav {
    display: flex;
    align-items: center;
    gap: var(--space-xl);
}

.nav__link {
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: relative;
}

.nav__link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--color-accent);
    transition: width var(--transition-base);
}

.nav__link:hover::after,
.nav__link--active::after {
    width: 100%;
}

/* Mobile Menu Toggle */
.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-sm);
}

.nav-toggle span {
    width: 24px;
    height: 2px;
    background: var(--color-text);
    transition: all var(--transition-base);
}

@media (max-width: 768px) {
    .nav {
        position: fixed;
        top: 0; /* Full screen coverage */
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100vh;
        z-index: 999;
        flex-direction: column;
        justify-content: center; /* Center items vertically */
        align-items: center; /* Center items horizontally */
        gap: var(--space-xl);
        padding: var(--space-2xl);
        background: #FAF7F2; /* Solid cream background */
        transform: translateX(100%);
        transition: transform var(--transition-smooth);
    }
    
    .nav--open {
        transform: translateX(0);
    }
    
    .nav-toggle {
        display: flex;
        z-index: 1000; /* Ensure toggle is above menu */
    }
    
    .nav__link {
        font-size: 1.5rem; /* Larger text */
        padding: var(--space-sm) 0;
        color: var(--color-text);
        background: transparent; /* Clean look */
        border-radius: 0;
        margin: 0;
        text-align: center;
        font-weight: 600;
        width: 100%;
        display: block;
        border-bottom: 1px solid rgba(0,0,0,0.05); /* Subtle separator */
    }
    
    .nav__link:last-child {
        border-bottom: none;
        margin-top: var(--space-md);
    }
    
    .nav__link:hover,
    .nav__link:active {
        background: transparent;
        color: var(--color-primary);
        transform: translateX(5px);
    }
    
    /* Special styling for "Prenota" button in mobile */
    .nav .btn--primary {
        width: 100%;
        max-width: 300px;
        text-align: center;
        justify-content: center;
        margin-top: var(--space-lg);
    }
}

/* ========================================
   HERO SECTION
   ======================================== */
.hero {
    position: relative;
    height: 100vh;
    min-height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    /* CLS Fix: Contain layout to prevent shifts */
    contain: layout;
}

.hero__media {
    position: absolute;
    inset: 0;
    z-index: -1;
    /* CLS Fix: Contain layout */
    contain: strict;
}

.hero__media img,
.hero__media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* CLS Fix: Fixed aspect ratio */
    aspect-ratio: 16/9;
    /* Performance: Use GPU compositing */
    will-change: transform;
}

.hero__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.4) 0%,
        rgba(0, 0, 0, 0.2) 50%,
        rgba(0, 0, 0, 0.6) 100%
    );
    background-color: rgba(0,0,0,0.2);
}

/* Hero Variants */
.hero--page {
    height: 60vh;
    min-height: 500px;
    padding-top: 100px;
}

.hero--short {
    height: 50vh;
    min-height: 400px;
    padding-top: 100px;
}

/* Image Utilities */
.object-top {
    object-position: top;
}

.object-center {
    object-position: center;
}

/* Typography Utilities */
.text-subhead {
    text-transform: uppercase; 
    letter-spacing: 0.1em; 
    font-weight: 600;
}

/* Layout Utilities */
.items-center {
    align-items: center;
}

.w-full {
    width: 100%;
}

.w-full {
    width: 100%;
}

.max-w-text {
    max-width: 600px;
}

.mx-auto {
    margin-left: auto;
    margin-right: auto;
}

.max-w-logo {
    max-width: 200px;
    height: auto;
}

.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mt-3xl { margin-top: var(--space-3xl); }

.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.ml-0 { margin-left: 0; }

.grid-gap-3xl { gap: var(--space-3xl); }

.bg-gradient-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: var(--color-surface);
}

.text-surface { color: var(--color-surface); }
.opacity-90 { opacity: 0.9; }

.hero__content {
    position: relative;
    z-index: 1;
    text-align: center;
    color: var(--color-surface);
    max-width: 800px;
    padding: 0 var(--space-lg);
}

.hero__logo {
    width: 120px;
    height: auto;
    margin: 0 auto var(--space-xl);
    /* filter removed to show original logo colors */
}

.hero__title {
    font-size: var(--fs-hero);
    font-weight: 400;
    margin-bottom: var(--space-md);
    color: #FFFFFF; /* Force White */
    text-shadow: 0 4px 24px rgba(0, 0, 0, 0.7); /* Stronger shadow */
}

.hero__subtitle {
    font-size: var(--fs-xl);
    font-weight: 300;
    margin-bottom: var(--space-2xl);
    opacity: 1; /* Full opacity */
    color: #FFFFFF; /* Force White */
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7); /* Shadow for subtitle */
}

.hero__scroll {
    position: absolute;
    bottom: var(--space-2xl);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    color: var(--color-surface);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateX(-50%) translateY(0); }
    40% { transform: translateX(-50%) translateY(-10px); }
    60% { transform: translateX(-50%) translateY(-5px); }
}

/* ========================================
   CARDS
   ======================================== */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
}

.card__image {
    position: relative;
    aspect-ratio: 4/3;
    overflow: hidden;
}

.card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.card:hover .card__image img {
    transform: scale(1.05);
}

.card__body {
    padding: var(--space-lg);
}

.card__title {
    font-size: var(--fs-xl);
    margin-bottom: var(--space-sm);
}

.card__text {
    color: var(--color-text-light);
    margin-bottom: var(--space-md);
}

/* Room Card Variant */
.card--room .card__badge {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    background: var(--color-accent);
    color: var(--color-text);
    padding: var(--space-xs) var(--space-md);
    font-size: var(--fs-xs);
    font-weight: 600;
    text-transform: uppercase;
    border-radius: var(--radius-full);
}

.card--room .card__features {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.card__feature {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--fs-xs);
    color: var(--color-text-light);
}

/* ========================================
   USP SECTION
   ======================================== */
.usp {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-xl);
}

.usp__icon {
    width: 64px;
    height: 64px;
    margin-bottom: var(--space-md);
    color: var(--color-accent);
}

.usp__title {
    font-size: var(--fs-lg);
    margin-bottom: var(--space-sm);
}

.usp__text {
    color: var(--color-text-light);
    max-width: 280px;
}

/* ========================================
   FOOTER
   ======================================== */
.footer {
    background: var(--color-primary-dark);
    color: var(--color-surface);
    padding: var(--space-3xl) 0 var(--space-lg);
}

.footer__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-2xl);
    margin-bottom: var(--space-2xl);
}

.footer__logo img {
    height: 60px;
    margin-bottom: var(--space-md);
    filter: brightness(0) invert(1);
}

.footer__title {
    font-size: var(--fs-sm);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-md);
    color: var(--color-accent);
}

.footer__links {
    list-style: none;
}

.footer__links li {
    margin-bottom: var(--space-sm);
}

.footer__links a {
    color: rgba(255, 255, 255, 0.8);
    font-size: var(--fs-sm);
}

.footer__links a:hover {
    color: var(--color-surface);
}

.footer__bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: var(--space-lg);
    text-align: center;
    font-size: var(--fs-xs);
    opacity: 0.7;
}

/* ========================================
   RESPONSIVE ROOMS LAYOUT
   ======================================== */
@media (max-width: 768px) {
    .rooms-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: var(--space-2xl) !important;
        margin-bottom: var(--space-2xl) !important;
    }
    
    .rooms-grid > div {
        display: flex !important;
        flex-direction: column !important;
        order: 0 !important;
    }
    
    .rooms-grid img {
        width: 100%;
        height: 250px;
        object-fit: cover;
    }
}

/* ========================================
   ANIMATIONS
   ======================================== */
/* CLS-Safe animations: Only use transform and opacity (GPU composited) */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from { 
        opacity: 0;
        transform: translateY(30px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from { 
        opacity: 0;
        transform: translateX(-30px);
    }
    to { 
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-fade-in {
    animation: fadeIn var(--transition-smooth) forwards;
    will-change: opacity;
}

.animate-fade-in-up {
    animation: fadeInUp var(--transition-smooth) forwards;
    will-change: opacity, transform;
}

/* CLS Fix: Reserve space for animated elements */
[data-animate] {
    opacity: 0;
    will-change: opacity, transform;
}

[data-animate].animated {
    animation: fadeInUp 0.8s ease forwards;
}

/* ========================================
   UTILITIES
   ======================================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.divider {
    width: 60px;
    height: 3px;
    background: var(--color-accent);
    margin: var(--space-lg) auto;
}

.bg-light {
    background: var(--color-background);
}

.bg-white {
    background: var(--color-surface);
}

/* Noble Title Tooltip */
.noble-title {
    position: relative;
    cursor: help;
    border-bottom: 1px dotted var(--color-text-light);
}

.noble-title::after {
    content: attr(data-title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-surface);
    color: var(--color-primary-dark);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-md);
    font-size: var(--fs-xs);
    font-family: var(--font-heading);
    white-space: pre-wrap;
    width: 250px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
    z-index: 100;
    pointer-events: none;
    margin-bottom: 10px;
}

.noble-title:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-5px);
}
