@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Lora:ital,wght@0,600;0,700;1,400&display=swap');

:root {
    /* Typography */
    --font-serif: 'Lora', serif;
    --font-sans: 'Inter', sans-serif;

    /* Colors - Refined palette */
    --bg-color: #ffffff;
    --bg-secondary: #f8f6f3;
    --text-color: #2c2825;
    --text-secondary: #5a5450;
    --link-color: #2c2825;
    --link-hover-color: #a67c52;
    --muted-color: #4a4540;

    /* Accent colors */
    --accent-sage: #3d5a48;
    --accent-warm: #a67c52;
    --accent-light: #e8e3dc;

    /* Borders */
    --border-color: #d5cfc8;
    --border-light: #ebe7e2;

    /* Layout */
    --max-width: 1100px;
    --content-width: 720px;
    --sidebar-width: 280px;

    /* Spacing system */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 2rem;
    --space-lg: 3rem;
    --space-xl: 4.5rem;
    --space-2xl: 7rem;
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 1.0625rem;
    /* 17px */
    line-height: 1.75;
    letter-spacing: -0.003em;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 100vh;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 4rem 2rem;
    flex: 1;
}

header {
    margin-bottom: 4rem;
}

h1 {
    font-family: var(--font-serif);
    font-size: 2.75rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

h2 {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: var(--space-md);
}

p {
    margin-bottom: 1.25rem;
}

a {
    color: var(--link-color);
    text-decoration: none;
    transition: all 0.2s ease;
}

a:hover {
    color: var(--link-hover-color);
}

.content-link {
    position: relative;
    padding-bottom: 2px;
}

.content-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 1px;
    bottom: 0;
    left: 0;
    background-color: var(--link-hover-color);
    transition: width 0.3s ease;
}

.content-link:hover::after {
    width: 100%;
}

ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.date {
    font-size: 0.85rem;
    color: var(--muted-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    display: block;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 2rem 0;
    border-radius: 2px;
    /* Sharper editorial look */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

/* Home Grid */
.home-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4rem;
    align-items: start;
    flex: 1;
}

@media (min-width: 1024px) {
    .home-grid {
        grid-template-columns: 1fr 300px;
    }
}

.home-main-content {
    max-width: var(--content-width);
}

.home-sidebar {
    position: sticky;
    top: 2rem;
}

/* Article List styling */
.article-list li {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.article-list li:last-child {
    border-bottom: none;
}

.article-list a {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
}

.tag {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    margin-top: 0.5rem;
}

/* Portfolio Stats Box */
.stats-box {
    background-color: #fff;
    padding: 2rem;
    border: 1px solid var(--border-color);
    margin-top: 2rem;
}

.stats-box h3 {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    margin-top: 0;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.stat-item {
    margin-bottom: 1rem;
}

.stat-value {
    display: block;
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-sage);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--muted-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Article Template refinements */
.article-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4rem;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 4rem 1.5rem;
    flex: 1;
    /* Allow to grow and push footer */
}

@media (min-width: 1024px) {
    .article-grid {
        grid-template-columns: var(--sidebar-width) 1fr;
    }
}

.sidebar-title {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    display: block;
}

.toc-link {
    font-size: 0.9rem;
    color: var(--muted-color);
    margin-bottom: 0.5rem;
    display: block;
}

.toc-link:hover {
    color: var(--text-color);
    padding-left: 5px;
}

.content {
    font-size: 1.1rem;
}

/* Article Hero Section */
.article-hero {
    position: relative;
    width: 100%;
    height: 50vh;
    overflow: hidden;
    margin-bottom: 0;
}

/* Back to Home Link */
.back-home {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(8px);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 2rem;
    width: fit-content;
}

.back-home:hover {
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.article-hero .hero-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    margin: 0;
    box-shadow: none;
    border-radius: 0;
}

.article-hero::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Gradiente più fluido: parte molto piano da sopra, si intensifica verso il testo */
    background: linear-gradient(to bottom,
            transparent 0%,
            rgba(0, 0, 0, 0.1) 30%,
            rgba(0, 0, 0, 0.4) 60%,
            rgba(0, 0, 0, 0.8) 100%);
    pointer-events: none;
    z-index: 1;
}

.article-hero::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 25%;
    /* Sfumatura bianca multi-step per evitare stacchi harsh */
    background: linear-gradient(to bottom,
            transparent 0%,
            rgba(255, 255, 255, 0.2) 40%,
            rgba(255, 255, 255, 0.6) 70%,
            var(--bg-color) 100%);
    pointer-events: none;
    z-index: 2;
}

.hero-content-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding-bottom: 4rem;
    z-index: 10;
}

.hero-content-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

.hero-content-inner h1 {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
    line-height: 1.1;
    color: #ffffff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8), 0 4px 20px rgba(0, 0, 0, 0.5);
}

.hero-content-inner .subtitle {
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
    max-width: 800px;
    margin-bottom: 0;
}

.hero-content-inner .date {
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

@media (max-width: 768px) {
    .article-hero {
        height: 50vh;
    }

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

    .hero-content-inner .subtitle {
        font-size: 1.1rem;
    }
}

/* Single column article layout (no sidebar) */
.article-content-centered {
    max-width: 720px;
    margin: 0 auto;
    padding: 4rem 1.5rem;
}

/* Footer - compact and sticky at bottom */
footer {
    background-color: #fff;
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
    margin-top: auto;
}

.footer-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.social-icon {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--muted-color);
    transition: color 0.3s ease;
}

.social-icon:hover {
    color: var(--link-hover-color);
}

.social-icon svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.instagram-embed {
    margin: 3rem 0;
    padding: 1rem;
    background: #fff;
    border: 1px solid var(--border-color);
}

/* === CLASSI AGGIUNTE PER UI MIGLIORATA === */

/* Lightbox container */
.flashbox-container {
    margin: var(--space-xl) 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.flashbox-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

.flashbox-container img {
    display: block;
    width: 100%;
    height: auto;
}

.flashbox-container figcaption {
    padding: var(--space-sm);
    background: white;
    font-size: 0.9rem;
    color: var(--muted-color);
    text-align: center;
}

/* Sidebar navigation */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Social links container */
.social-links {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* Article text container */
.article-text p {
    margin-bottom: var(--space-md);
}

/* Monospace font utility */
.font-mono {
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
}

/* Content improvements */
.content {
    font-size: 1.125rem;
    /* 18px */
    line-height: 1.8;
    max-width: 680px;
}

/* Blockquotes */
.content blockquote {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-style: italic;
    padding-left: 2rem;
    border-left: 3px solid var(--accent-sage);
    margin: var(--space-lg) 0;
    color: var(--text-secondary);
}

/* Smooth scroll */
html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

/* Focus states for accessibility */
a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent-sage);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Skip link for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--accent-sage);
    color: white;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    z-index: 100;
}

.skip-link:focus {
    top: 0;
}

/* Breadcrumb navigation */
.breadcrumb {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.9rem;
}

.breadcrumb ol {
    display: flex;
    gap: var(--space-xs);
    list-style: none;
    padding: 0;
    margin: 0;
}

.breadcrumb li:not(:last-child)::after {
    content: '/';
    margin-left: var(--space-xs);
    color: var(--text-secondary);
}

/* Itinerary Box */
.itinerary-box {
    margin: 2.5rem 0;
    padding: 2rem;
    background: linear-gradient(135deg, #f0ebe5 0%, #e8e3dc 100%);
    border-left: 4px solid var(--accent-warm);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.itinerary-box h3 {
    font-family: var(--font-serif);
    font-size: 1.3rem;
    color: var(--accent-warm);
    margin-top: 0;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.itinerary-box h3::before {
    content: "📍";
    font-size: 1.2em;
}

.itinerary-box ol {
    list-style: none;
    counter-reset: itinerary-counter;
    padding: 0;
    margin: 0;
}

.itinerary-box ol li {
    counter-increment: itinerary-counter;
    padding-left: 2.5rem;
    margin-bottom: 0.75rem;
    position: relative;
    line-height: 1.6;
    color: var(--text-color);
}

.itinerary-box ol li::before {
    content: counter(itinerary-counter);
    position: absolute;
    left: 0;
    top: 0;
    background: var(--accent-warm);
    color: white;
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.itinerary-box ol li:last-child {
    margin-bottom: 0;
}

/* Related Articles Section */
.related-articles {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding: 1.5rem;
    background-color: var(--bg-secondary);
    border-left: 3px solid var(--accent-sage);
    border-radius: 4px;
}

.related-link {
    font-family: var(--font-sans);
    font-size: 0.95rem;
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.2s ease;
    padding: 0.5rem 0;
    display: block;
}

.related-link:hover {
    color: var(--accent-warm);
    padding-left: 0.5rem;
}

@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    .footer-content {
        flex-direction: column;
        gap: 1.5rem;
        text-align: center;
    }
}