/**
 * Geographic Pages CSS - Optimized for Italian Tourism Portal
 * 
 * Ottimizzato per:
 * - Core Web Vitals (CLS, LCP, FID)
 * - Performance (minimal CSS, efficient selectors)
 * - Design italiano moderno
 * - Responsive design
 * - Accessibilità
 * - VISUAL PERCEPTION of geographic hierarchy
 */

/* ==========================================================================
   GEOGRAPHIC HEADER - Prominent Level Badges
   ========================================================================== */

/* Hero Section - ULTRA COMPACT Above-the-Fold */
/* CRITICAL: Minimal height - maximum content visibility */
.ti-hero-editorial {
    height: 120px; /* Ultra compact: was 180px */
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    margin: 15px 0 20px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.ti-hero-content {
    text-align: center;
    z-index: 2;
    padding: 15px 20px; /* Minimal padding */
    max-width: 800px;
}

.ti-hero-title {
    font-size: 1.8rem; /* Compact: was 2.2rem */
    color: #222;
    margin: 0 0 8px 0;
    font-weight: 700;
    line-height: 1.2;
}

.ti-hero-subtitle {
    font-size: 1rem; /* Compact: was 1.1rem */
    color: #666;
    margin: 0;
    line-height: 1.4;
    font-weight: 400;
}

@media (max-width: 968px) {
    .ti-hero-editorial {
        height: 100px; /* Compact tablet */
    }
    
    .ti-hero-title {
        font-size: 1.6rem;
    }
    
    .ti-hero-subtitle {
        font-size: 0.95rem;
    }
}

@media (max-width: 768px) {
    .ti-hero-editorial {
        height: 100px; /* Ultra compact mobile */
        margin: 10px 0 15px 0;
    }
    
    .ti-hero-content {
        padding: 12px 15px;
    }
    
    .ti-hero-title {
        font-size: 1.4rem;
    }
    
    .ti-hero-subtitle {
        font-size: 0.9rem;
    }
}

.ti-geo-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 15px 20px; /* Ultra compact: was 40px 30px */
    border-radius: 12px;
    margin: 30px 0;
    border-left: 6px solid #009246;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.ti-geo-header-top {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.ti-geo-badge {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
    animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Color-coded badges for each level */
.ti-geo-badge.badge-comune {
    background: #2196F3;
    color: #fff;
}

.ti-geo-badge.badge-provincia {
    background: #4CAF50;
    color: #fff;
}

.ti-geo-badge.badge-regione {
    background: #F44336;
    color: #fff;
}

.ti-geo-badge.badge-italia {
    background: #009246;
    color: #fff;
}

/* Header Statistics Badges */
.ti-header-stats {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.ti-stat-badge {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    background: #fff;
    color: #333;
    border: 2px solid #e9ecef;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    white-space: nowrap;
}

.ti-stat-badge.ti-stat-content {
    border-color: #2196F3;
    color: #2196F3;
}

.ti-stat-badge.ti-stat-children {
    border-color: #4CAF50;
    color: #4CAF50;
}

.ti-stat-badge.ti-stat-istat {
    border-color: #FF9800;
    color: #FF9800;
}

/* ==========================================================================
   SECTION VISUAL SEPARATION - Clear Content Boundaries
   ========================================================================== */

.ti-section {
    background: #fff;
    border-radius: 12px;
    padding: 30px;
    margin: 30px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-left: 6px solid #dee2e6;
}

/* Different colors for different section types */
.ti-section-local {
    border-left-color: #2196F3;
    background: linear-gradient(to right, rgba(33,150,243,0.03) 0%, #fff 100%);
}

.ti-section-provincia {
    border-left-color: #4CAF50;
    background: linear-gradient(to right, rgba(76,175,80,0.03) 0%, #fff 100%);
}

.ti-section-regione {
    border-left-color: #F44336;
    background: linear-gradient(to right, rgba(244,67,54,0.03) 0%, #fff 100%);
}

.ti-section-navigation {
    border-left-color: #009246;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

/* Section Headers with Icons */
.ti-section-header {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e9ecef;
}

.ti-section-title {
    font-size: 1.8rem;
    color: #222;
    margin: 0 0 10px 0;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
}

.ti-section-icon {
    font-size: 2rem;
    display: inline-block;
}

.ti-section-description {
    color: #666;
    font-size: 1.05rem;
    line-height: 1.6;
    margin: 0;
}

/* ==========================================================================
   FALLBACK ALERTS - Impossible to Miss
   ========================================================================== */

.ti-fallback-alert {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    padding: 25px 30px;
    border-radius: 12px;
    margin: 25px 0;
    border: 3px solid;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: alert-attention 3s ease-in-out infinite;
}

@keyframes alert-attention {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.ti-fallback-alert.alert-provincia {
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

.ti-fallback-alert.alert-regione {
    background: #ffe5e5;
    border-color: #ff9800;
    color: #8b3a00;
}

.ti-fallback-alert.alert-proximity {
    background: #e3f2fd;
    border-color: #2196F3;
    color: #0d47a1;
}

.ti-fallback-icon {
    font-size: 3rem;
    flex-shrink: 0;
    animation: icon-bounce 2s ease-in-out infinite;
}

@keyframes icon-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.ti-fallback-content h3 {
    font-size: 1.4rem;
    margin: 0 0 10px 0;
    font-weight: 700;
}

.ti-fallback-content p {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.6;
}

.ti-fallback-content strong {
    font-weight: 700;
    text-decoration: underline;
}

/* ==========================================================================
   Layout & Grid System
   ========================================================================== */

.ti-content-wrapper {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
    margin: 40px 0;
}

@media (min-width: 992px) {
    .ti-content-wrapper {
        grid-template-columns: 2fr 1fr;
        gap: 40px;
    }
}

/* ==========================================================================
   Navigation Links (Province, Comuni) - Enhanced Visual Separation
   ========================================================================== */

.ti-nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
}

.ti-nav-link {
    display: inline-block;
    padding: 12px 20px;
    background: #fff;
    border: 2px solid #009246;
    border-radius: 25px;
    color: #009246;
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0,146,70,0.2);
}

.ti-nav-link:hover,
.ti-nav-link:focus {
    background: #009246;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,146,70,0.4);
    outline: none;
}

.ti-nav-link small {
    display: block;
    font-size: 12px;
    opacity: 0.9;
    margin-top: 3px;
    font-weight: 500;
}

/* ==========================================================================
   Province Grid with Images - Rich Visual Cards
   ========================================================================== */

.ti-province-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    margin-top: 25px;
}

@media (max-width: 768px) {
    .ti-province-grid {
        grid-template-columns: 1fr;
    }
}

.ti-province-card {
    position: relative;
    display: block;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-decoration: none;
    height: 280px;
}

.ti-province-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.ti-province-card-image {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.ti-province-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.ti-province-card:hover .ti-province-card-image img {
    transform: scale(1.1);
}

.ti-province-card-no-image {
    background: linear-gradient(135deg, #009246 0%, #00b359 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ti-province-card-icon {
    font-size: 5rem;
    opacity: 0.3;
    color: #fff;
}

.ti-province-card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.4) 50%, transparent 100%);
    height: 100%;
    pointer-events: none;
}

.ti-province-card-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    color: #fff;
    z-index: 1;
}

.ti-province-card-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0 0 5px 0;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.ti-province-card-meta {
    font-size: 0.9rem;
    margin: 0;
    opacity: 0.9;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* ==========================================================================
   Content Cards Grid - Enhanced Visual Hierarchy
   ========================================================================== */
.ti-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    margin: 25px 0;
}

@media (max-width: 768px) {
    .ti-cards-grid {
        grid-template-columns: 1fr;
    }
}

/* Card Component */
.ti-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ti-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

/* Card Image - Aspect ratio per CLS */
.ti-card-image {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: #e9ecef;
}

.ti-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.ti-card:hover .ti-card-image img {
    transform: scale(1.05);
}

/* Location Badge */
.ti-location-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Card Body */
.ti-card-body {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.ti-card-title {
    font-size: 1.2rem;
    color: #222;
    margin: 0 0 12px 0;
    font-weight: 700;
    line-height: 1.4;
}

.ti-card-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.ti-card-title a:hover {
    color: #009246;
}

.ti-card-excerpt {
    color: #666;
    font-size: 15px;
    line-height: 1.6;
    margin: 0 0 15px 0;
    flex: 1;
}

/* Card Footer */
.ti-card-footer {
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
}

.ti-card-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #009246;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    transition: gap 0.2s ease;
}

.ti-card-link:hover {
    gap: 10px;
}

.ti-card-link::after {
    content: '→';
    font-size: 18px;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.ti-empty-state {
    text-align: center;
    padding: 60px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    margin: 30px 0;
}

.ti-empty-state-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.ti-empty-state h3 {
    font-size: 1.5rem;
    color: #495057;
    margin: 0 0 15px 0;
}

.ti-empty-state p {
    font-size: 1.1rem;
    color: #6c757d;
    margin: 10px 0;
    line-height: 1.6;
}

/* ==========================================================================
   Sidebar Widgets - Enhanced Visual Hierarchy + Sticky Behavior
   ========================================================================== */

.ti-sidebar {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* CRITICAL: Sticky sidebar - follows scroll properly */
.ti-sidebar-widgets {
    position: sticky !important; /* Force sticky, never fixed */
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
    /* Hide scrollbar but keep functionality */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

/* Hide scrollbar for Chrome/Safari/Opera */
.ti-sidebar-widgets::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

/* CRITICAL: Ensure parent containers don't break sticky */
.ti-content-wrapper,
.ti-main-content,
.ti-geo-container {
    overflow: visible !important; /* Never use overflow: hidden/auto/scroll on sticky parents */
}

.ti-widget {
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-top: 4px solid #009246;
    border-left: 2px solid #e9ecef;
}

.ti-widget-title {
    font-size: 1.3rem;
    color: #222;
    margin: 0 0 20px 0;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

.ti-widget-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ti-widget-list li {
    padding: 12px 0;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ti-widget-list li:last-child {
    border-bottom: none;
}

.ti-widget-list a {
    color: #495057;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.ti-widget-list a:hover {
    color: #009246;
}

.ti-widget-meta {
    color: #6c757d;
    font-size: 13px;
    background: #f8f9fa;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
}

/* Statistics Widget */
.ti-stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
}

.ti-stat-label {
    font-weight: 600;
    color: #495057;
}

.ti-stat-value {
    background: #009246;
    color: #fff;
    padding: 6px 14px;
    border-radius: 15px;
    font-weight: 700;
    font-size: 14px;
}

/* ==========================================================================
   Responsive Design - Mobile Optimizations
   ========================================================================== */

@media (max-width: 768px) {
    .ti-geo-header {
        padding: 12px 15px; /* Ultra compact mobile */
    }
    
    .ti-geo-header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .ti-header-stats {
        width: 100%;
        gap: 8px;
    }
    
    .ti-stat-badge {
        font-size: 13px;
        padding: 6px 12px;
    }
    
    .ti-geo-badge {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .ti-header-title {
        font-size: 2rem;
    }
    
    .ti-section {
        padding: 20px;
    }
    
    .ti-section-title {
        font-size: 1.5rem;
    }
    
    /* Disable sticky sidebar on mobile for better UX */
    .ti-sidebar-widgets {
        position: static;
        max-height: none;
        overflow-y: visible;
    }
    
    .ti-fallback-alert {
        flex-direction: column;
        padding: 20px;
        gap: 15px;
    }
    
    .ti-fallback-icon {
        font-size: 2.5rem;
    }
    
    .ti-nav-links {
        flex-direction: column;
    }
    
    .ti-nav-link {
        text-align: center;
        width: 100%;
    }
    
    .ti-regioni-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* Focus styles */
a:focus,
button:focus {
    outline: 3px solid #009246;
    outline-offset: 2px;
}

/* Skip to content */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: #009246;
    color: #fff;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 100;
}

.skip-to-content:focus {
    top: 0;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .ti-nav-section,
    .ti-sidebar,
    .ti-breadcrumb {
        display: none;
    }
    
    .ti-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* ==========================================================================
   Performance Optimizations
   ========================================================================== */

/* GPU acceleration for transforms */
.ti-card,
.ti-nav-link,
.ti-regione-card {
    will-change: transform;
}

/* Contain layout shifts */
.ti-card-image {
    contain: layout;
}

/* Optimize font rendering */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ==========================================================================
   Stemma Widget
   ========================================================================== */

.ti-widget-stemma {
    text-align: center;
}

.ti-stemma-container {
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    margin: 15px 0;
}

.ti-stemma-image {
    max-width: 150px;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: transform 0.3s ease;
}

.ti-stemma-image:hover {
    transform: scale(1.05);
}

/* ==========================================================================
   Map Widget
   ========================================================================== */

.ti-widget-map {
    overflow: hidden;
}

.ti-map-container {
    width: 100%;
    height: 250px;
    border-radius: 8px;
    overflow: hidden;
    margin: 15px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.ti-coordinates {
    text-align: center;
    color: #6c757d;
    font-size: 12px;
    margin: 10px 0 0 0;
}

/* ==========================================================================
   Category Groups
   ========================================================================== */

.ti-category-group {
    margin: 40px 0;
    padding: 30px;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 12px;
    border-left: 4px solid #009246;
}

.ti-category-title {
    font-size: 1.6rem;
    color: #222;
    margin: 0 0 25px 0;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

/* ==========================================================================
   AOS Animations Support
   ========================================================================== */

[data-aos] {
    opacity: 0;
    transition-property: opacity, transform;
}

[data-aos].aos-animate {
    opacity: 1;
}

[data-aos="fade-up"] {
    transform: translateY(30px);
}

[data-aos="fade-up"].aos-animate {
    transform: translateY(0);
}

[data-aos="fade-left"] {
    transform: translateX(30px);
}

[data-aos="fade-left"].aos-animate {
    transform: translateX(0);
}

[data-aos="zoom-in"] {
    transform: scale(0.9);
}

[data-aos="zoom-in"].aos-animate {
    transform: scale(1);
}


/* ==========================================================================
   FIX: Prevent Horizontal Overflow on Regione Pages
   ========================================================================== */

/* Ensure body and main containers don't overflow */
body {
    overflow-x: hidden;
    max-width: 100vw;
}

.site-content,
.content-area,
.site-main {
    overflow-x: hidden;
    max-width: 100%;
}

/* Fix map container overflow */
#regione-map,
#provincia-map,
#comune-map,
.leaflet-container {
    max-width: 100%;
    overflow: hidden;
}

/* Fix grid containers - CRITICAL */
.ti-province-grid,
.ti-cards-grid,
.ti-nav-links,
.ti-top-grid {
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Fix inline grid styles that might cause overflow */
.ti-province-grid[style*="grid-template-columns"],
.ti-cards-grid[style*="grid-template-columns"],
.ti-top-grid[style*="grid-template-columns"] {
    grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)) !important;
}

/* Fix section containers */
.ti-section,
.ti-geo-header,
.ti-category-group,
.ti-widget,
.ti-province-section,
.ti-top-content,
.ti-regione-content,
.ti-eventi-section,
.ti-monumenti-section,
.ti-musei-section,
.ti-map-section {
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* CRITICAL: Fix carousel containers causing overflow */
.ti-carousel-wrapper {
    max-width: 100%;
    overflow: hidden !important;
    box-sizing: border-box;
}

.ti-eventi-carousel,
.ti-monumenti-carousel,
.ti-musei-carousel {
    max-width: none; /* Allow carousel to be wider than container */
    overflow: visible; /* But parent wrapper clips it */
}

/* Fix carousel cards */
.ti-evento-card,
.ti-monumento-card,
.ti-museo-card,
.ti-top-card {
    min-width: 280px;
    max-width: 320px;
    box-sizing: border-box;
}

/* Ensure images don't overflow */
img {
    max-width: 100%;
    height: auto;
}

/* Fix content wrapper */
.ti-content-wrapper {
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Fix any absolute positioned elements */
.ti-location-badge,
.ti-province-card-overlay,
.ti-province-card-content {
    max-width: 100%;
}

/* Fix provincia cards */
.ti-provincia-card,
.ti-province-card {
    max-width: 100%;
    box-sizing: border-box;
}

/* Fix long text in titles and headings */
.ti-provincia-card h3,
.ti-province-card-title,
.ti-card-title,
.ti-header-title {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Fix section headers with flex layout */
.ti-section-header {
    max-width: 100%;
    overflow: hidden;
}

/* Responsive container fix */
@media (max-width: 1200px) {
    .container,
    .site-content,
    .content-area {
        padding-left: 15px;
        padding-right: 15px;
        max-width: 100%;
    }
    
    /* Adjust grid columns for medium screens */
    .ti-province-grid,
    .ti-cards-grid,
    .ti-top-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)) !important;
    }
}

@media (max-width: 968px) {
    /* Force single column on tablets */
    .ti-province-grid,
    .ti-cards-grid,
    .ti-top-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Stack carousel nav buttons */
    .ti-section-header {
        flex-direction: column !important;
        align-items: flex-start !important;
    }
    
    .ti-carousel-nav {
        margin-top: 15px;
    }
}

@media (max-width: 768px) {
    /* Force single column on mobile */
    .ti-province-grid,
    .ti-cards-grid,
    .ti-top-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Reduce carousel card size on mobile */
    .ti-evento-card,
    .ti-monumento-card,
    .ti-museo-card {
        flex: 0 0 280px !important;
        min-width: 280px !important;
    }
}

/* Fix for WordPress admin bar */
html {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Ensure no negative margins cause overflow */
* {
    box-sizing: border-box;
}

.ti-province-grid,
.ti-cards-grid,
.ti-top-grid {
    margin-left: 0;
    margin-right: 0;
}

/* Fix any elements with fixed width */
.ti-regione-content > * {
    max-width: 100%;
}

/* Prevent map from causing overflow */
.leaflet-container,
.leaflet-pane,
.leaflet-map-pane {
    max-width: 100%;
}

/* Fix layout wrapper (main container) */
.ti-layout-wrapper {
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

.ti-main-content {
    max-width: 100%;
    overflow-x: hidden;
    min-width: 0; /* Important for flex/grid children */
}

/* Fix geo container */
.ti-geo-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Ensure all direct children respect container width */
.ti-geo-container > *,
.ti-main-content > * {
    max-width: 100%;
    box-sizing: border-box;
}



/* ==========================================================================
   MODERN EDITORIAL CARDS - Task 18 Redesign
   ========================================================================== */

.ti-editorial-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    margin: 0;
}

.ti-editorial-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ti-editorial-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.ti-editorial-card img {
    transition: transform 0.3s ease;
}

.ti-editorial-card:hover img {
    transform: scale(1.05);
}

.ti-editorial-card h3 a {
    transition: color 0.2s ease;
}

.ti-editorial-card h3 a:hover {
    color: #009246;
}

/* Link Arrow Animation */
.ti-card-link-arrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: gap 0.2s ease;
}

.ti-card-link-arrow:hover {
    gap: 10px !important;
}

.ti-card-link-arrow span {
    transition: transform 0.2s ease;
}

.ti-card-link-arrow:hover span {
    transform: translateX(4px);
}

/* Featured Cards */
.ti-featured {
    border: 2px solid #ffc107;
}

/* Section Backgrounds */
.ti-eventi-oggi {
    background: #FFF3E0;
}

.ti-da-non-perdere {
    background: #FFF8E1;
}

.ti-nei-dintorni {
    background: #E3F2FD;
}

.ti-category-section {
    background: #F8F9FA;
}

/* ==========================================================================
   RESPONSIVE DESIGN - Modern Editorial
   ========================================================================== */

@media (max-width: 1200px) {
    .ti-editorial-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 25px;
    }
}

@media (max-width: 968px) {
    .ti-editorial-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 20px;
    }
    
    .ti-eventi-oggi,
    .ti-da-non-perdere,
    .ti-nei-dintorni,
    .ti-category-section {
        padding: 30px 20px;
        margin: 40px 0;
    }
}

@media (max-width: 768px) {
    .ti-editorial-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .ti-eventi-oggi,
    .ti-da-non-perdere,
    .ti-nei-dintorni,
    .ti-category-section {
        padding: 25px 15px;
        margin: 30px 0;
    }
}

/* ==========================================================================
   ACCESSIBILITY - Reduced Motion Support (Task 18)
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .ti-editorial-card,
    .ti-editorial-card img,
    .ti-card-link-arrow,
    .ti-card-link-arrow span {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}


/* ==========================================================================
   SIDEBAR STEMMA - Coat of Arms Display
   ========================================================================== */

.ti-widget-stemma {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-align: center;
}

.ti-widget-stemma h3 {
    font-size: 1.1rem;
    margin: 0 0 15px 0;
    color: #222;
}

.ti-sidebar-stemma {
    max-width: 100px;
    height: auto;
    display: inline-block;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
    transition: transform 0.3s ease;
}

.ti-sidebar-stemma:hover {
    transform: scale(1.05);
}

@media (max-width: 768px) {
    .ti-widget-stemma {
        padding: 15px;
    }
    
    .ti-sidebar-stemma {
        max-width: 80px;
    }
}
