/*
 * Revised Responsive CSS for CodedByAle Portfolio
 *
 * Questo aggiornamento risolve il problema dello scorrimento orizzontale su dispositivi mobili
 * e ottimizza ulteriormente la dimensione del testo per schermi molto piccoli.
 */

/* === Base & Utilities (Nessun cambiamento necessario, già ottimizzato) === */
/* Scrollbar Customization */
::-webkit-scrollbar {
    display: none;
    /* For Webkit browsers */
}

*,
html,
body {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    background: #fdfcfb;
    color: #333;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-top: 70px;
    transition: background-color 0.3s ease-in-out, color 0.3s ease-in-out;
    width: 100%;
    /* Explicitly set body width */
}

main.container {
    /* Target main container specifically */
    flex-grow: 1;
    /* Allow main content to take available space */
    width: 100%;
    /* Ensure it spans full width */
    margin-left: auto;
    /* Re-affirm centering */
    margin-right: auto;
    padding: 0 16px;
    /* Already set by media query, but for clarity */
}

/* Utilities */
.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 16px;
    width: 100%;
    /* Ensure the container always takes available width */
}

.text-center {
    text-align: center;
}

.mb-4 {
    margin-bottom: 1.5rem;
}

.mt-8 {
    margin-top: 3rem;
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-4 {
    gap: 1rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* === Header Section === */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #fdfcfb;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: padding 0.3s ease-in-out, background-color 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
    width: 100%;
    /* Ensure fixed header spans full width */
}

header .container {
    padding: 0 24px;
    width: 100%;
    /* Ensure container within header also takes full width */
    margin: 0 auto;
    /* Ensure it's centered */
}

.logo {
    font-family: 'Playfair Display', serif;
    font-size: 1.8em;
    font-weight: 700;
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease-in-out;
    max-width: 100%;
    /* Prevent logo from overflowing */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

nav a {
    color: #555;
    text-decoration: none;
    padding: 8px 15px;
    transition: color 0.2s ease-in-out;
    position: relative;
    overflow: hidden;
    max-width: 100%;
    /* Prevent nav links from overflowing */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

nav a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 1px;
    background: #000;
    transition: all 0.3s ease-in-out;
    transform: translateX(-50%);
}

nav a:hover::after,
nav a:focus::after {
    width: 100%;
}

nav a:hover,
nav a:focus {
    color: #000;
    outline: none;
}

.mobile-menu-toggle {
    display: none;
    font-size: 1.5em;
    background: none;
    border: none;
    color: #333;
    cursor: pointer;
    transition: color 0.3s ease-in-out;
}

/* === Mobile Navigation Overlay === */
.mobile-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.98);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0s 0.3s;
    width: 100%;
    /* Ensure full width */
}

.mobile-nav-overlay.open {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease-in-out, visibility 0s;
}

.mobile-nav-overlay a {
    color: #333;
    font-size: 1.8em;
    margin: 15px 0;
    text-decoration: none;
    font-family: 'Playfair Display', serif;
    position: relative;
    overflow: hidden;
    transition: color 0.3s ease-in-out;
    max-width: 100%;
    /* Prevent links from overflowing */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.mobile-nav-overlay a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: #000;
    transition: all 0.3s ease-in-out;
    transform: translateX(-50%);
}

.mobile-nav-overlay a:hover::after,
.mobile-nav-overlay a:focus::after {
    width: 100%;
}

.mobile-nav-overlay a:hover,
.mobile-nav-overlay a:focus {
    color: #000;
    outline: none;
}

.close-button {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 2.5em;
    color: #333;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s ease-in-out;
}

.close-button:hover {
    color: #000;
}

/* === Hero Section === */
.hero {
    text-align: center;
    padding: 80px 0;
    margin-bottom: 60px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    /* Ensure hero takes full width of its parent */
}

.hero h1 {
    font-family: 'Playfair Display', serif;
    font-size: 4.2em;
    color: #1a1a1a;
    margin: 0 0 20px;
    line-height: 1.1;
    letter-spacing: -1px;
    transition: color 0.3s ease-in-out;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.hero h1 span {
    display: block;
    font-size: 0.4em;
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    color: #555;
    margin-top: 10px;
    letter-spacing: 0.5px;
    transition: color 0.3s ease-in-out;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.hero p {
    font-size: 1.15em;
    max-width: 800px;
    margin: 0 auto 30px;
    color: #555;
    line-height: 1.8;
    transition: color 0.3s ease-in-out;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.btn {
    display: inline-block;
    padding: 12px 30px;
    background: #000;
    color: #fff;
    text-decoration: none;
    border: 1px solid #000;
    border-radius: 4px;
    font-size: 1.05em;
    font-weight: 500;
    transition: all 0.3s ease-in-out;
    letter-spacing: 0.5px;
    cursor: pointer;
}

.btn:hover,
.btn:focus {
    background: #fff;
    color: #000;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    outline: none;
}

.btn-ghost {
    background: transparent;
    color: #333;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.btn-ghost:hover,
.btn-ghost:focus {
    background: rgba(0, 0, 0, 0.05);
    color: #000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* === Section Styling === */
section {
    padding: 80px 0;
    border-top: 1px dashed rgba(0, 0, 0, 0.08);
    margin-bottom: 48px;
    transition: border-top-color 0.3s ease-in-out;
    width: 100%;
    /* Ensure sections take full width */
}

section:first-of-type {
    border-top: none;
}

section h2 {
    font-family: 'Playfair Display', serif;
    font-size: 3em;
    color: #1a1a1a;
    margin-bottom: 40px;
    text-align: center;
    letter-spacing: -0.5px;
    transition: color 0.3s ease-in-out;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* === About Section === */
.about-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    font-size: 1.05em;
    color: #555;
    line-height: 1.8;
    transition: color 0.3s ease-in-out;
    width: 100%;
    /* Ensure grid takes full width */
}

.about-content p strong {
    color: #333;
    transition: color 0.3s ease-in-out;
}

.about-image {
    min-height: 280px;
    border-radius: 6px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: box-shadow 0.3s ease-in-out;
    width: 100%;
    /* Ensure image container takes full width */
}

.about-image img {
    max-width: 100%;
    /* Ensure images are responsive */
    height: auto;
    object-fit: cover;
    display: block;
}

/* === Tech Stack Section === */
.tech-stack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    max-width: 900px;
    margin: 0 auto;
    text-align: center;
    width: 100%;
    /* Ensure grid takes full width */
}

.tech-item {
    background: #fff;
    padding: 15px 10px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 6px;
    font-weight: 500;
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out, background-color 0.3s ease-in-out, color 0.3s ease-in-out, border-color 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 90px;
    min-width: 0;
    /* Allow flex items to shrink */
}

.tech-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    background-color: #f5f5f5;
}

.tech-icon {
    width: 1em;
    height: 1em;
    margin-bottom: 8px;
    font-size: 2em;
    color: #555;
    transition: color 0.3s ease-in-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.tech-item:hover .tech-icon {
    color: #000;
}

/* === Projects Section === */
.projects-content {
    position: relative;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    /* Ensure projects content takes full width */
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    width: 100%;
    overflow-x: hidden;
}

.project-card {
    display: block;
    text-decoration: none;
    color: inherit;
    background: #fff;
    padding: 28px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out, background-color 0.3s ease-in-out, border-color 0.3s ease-in-out;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    min-width: 0;
    /* Allow grid items to shrink */
}

.project-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);
    background-color: #fcfcfc;
}

.project-card-image {
    width: 100%;
    height: 260px;
    border-radius: 4px;
    margin-bottom: 15px;
    overflow: hidden;
    background-color: #f0f0f0;
}

.project-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.project-card h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.8em;
    color: #1a1a1a;
    margin-top: 0;
    margin-bottom: 12px;
    transition: color 0.3s ease-in-out;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.project-card p {
    font-size: 0.95em;
    color: #555;
    margin-bottom: 20px;
    line-height: 1.7;
    transition: color 0.3s ease-in-out;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.project-card .tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 15px;
}

.project-card .tag {
    background: #eee;
    color: #444;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.8em;
    border: 1px solid rgba(0, 0, 0, 0.08);
    transition: background-color 0.3s ease-in-out, color 0.3s ease-in-out, border-color 0.3s ease-in-out;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.no-projects-message {
    padding: 40px;
    font-size: 1.2em;
    color: #777;
    margin: auto;
    transition: color 0.3s ease-in-out;
}

/* === Contact Section === */
.contact-info {
    width: 100%;
    /* Ensure contact info takes full width */
}

.contact-info a {
    color: #333;
    text-decoration: none;
    display: block;
    margin-bottom: 10px;
    font-size: 1.15em;
    transition: color 0.2s ease-in-out;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.contact-info a:hover,
.contact-info a:focus {
    color: #000;
    outline: none;
}

.contact-info p {
    color: #555;
    font-size: 1em;
    line-height: 1.7;
    transition: color 0.3s ease-in-out;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
    flex-wrap: wrap;
    width: 100%;
    /* Ensure social links take full width */
}

.social-links a {
    color: #555;
    font-size: 1.1em;
    text-decoration: none;
    transition: color 0.2s ease-in-out;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    min-width: 0;
}

.social-links a:hover,
.social-links a:focus {
    color: #000;
}

/* === Footer === */
footer {
    padding: 24px 0;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    margin-top: 48px;
    color: #777;
    font-size: 0.9em;
    text-align: center;
    transition: border-top-color 0.3s ease-in-out, color 0.3s ease-in-out;
    width: 100%;
    /* Ensure footer takes full width */
}

/* === Back to Top Button === */
.back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #000;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    z-index: 999;
    transform: translateY(20px);
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out, visibility 0s 0.3s;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out, visibility 0s;
}

.back-to-top:hover {
    background-color: #333;
    transform: translateY(-3px);
}

/* === Cookies Button === */
.cookies-button {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background-color: #000;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s, transform 0.3s;
    z-index: 999;
}

.cookies-button:hover {
    background-color: #333;
    transform: translateY(-3px);
}

/* === Cookie Modal Styles === */
.cookie-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    /* Crucial: Disable interaction when hidden */
    transition: opacity 0.3s ease-in-out, visibility 0s 0.3s;
    /* Hide visibility after opacity */
}

.cookie-modal.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    /* Enable interaction when visible */
    transition: opacity 0.3s ease-in-out, visibility 0s;
    /* Show visibility immediately */
}

.cookie-modal-content {
    background: #fff;
    border-radius: 8px;
    width: 500px;
    /* Fixed width, adjusted for better fit */
    height: 450px;
    /* Fixed height, adjusted to fit content */
    max-width: 90%;
    /* Ensure responsiveness */
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    transform: translateY(20px);
    transition: transform 0.3s ease-in-out;
    position: relative;
    overflow: hidden;
    /* Important for inner view transitions */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.cookie-modal.show .cookie-modal-content {
    transform: translateY(0);
}

/* Cookie View Transitions */
.cookie-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 30px;
    /* Padding applied to each inner view */
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out, visibility 0s 0.3s;
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* Center content vertically within the view */
    align-items: center;
    /* Center content horizontally within the view */
    text-align: center;
}

.cookie-view.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out, visibility 0s;
}

/* Adjustments for inner content within cookie-view */
.cookie-view h3 {
    font-family: 'Playfair Display', serif;
    font-size: 2em;
    color: #1a1a1a;
    margin-top: 0;
    /* Reset top margin */
    margin-bottom: 20px;
    width: 100%;
    /* Take full width of parent view */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.cookie-view p {
    font-size: 1em;
    color: #555;
    margin-bottom: 30px;
    line-height: 1.7;
    width: 100%;
    /* Take full width of parent view */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.cookie-view .cookie-modal-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin-top: auto;
    /* Push buttons to bottom if content is short */
    width: 100%;
    /* Take full width of parent view */
    max-width: 400px;
    /* Limit content width for better readability */
}

/* Custom Checkbox Styles (from Uiverse.io by kyle1dev - customized for black theme) */
.cookie-preferences {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
    text-align: left;
    width: 100%;
    /* Ensure preferences take full width */
    max-width: 300px;
    /* Limit width to keep it neat */
    margin-left: auto;
    margin-right: auto;
}

.ios-checkbox.black-theme {
    --checkbox-size: 24px;
    --checkbox-color: #000;
    --checkbox-bg: rgba(0, 0, 0, 0.05);
    --checkbox-border: #333;

    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    color: #444;
    font-size: 0.95em;
    transition: color 0.3s ease-in-out;
}

.ios-checkbox.black-theme input {
    display: none;
}

.checkbox-wrapper {
    position: relative;
    width: var(--checkbox-size);
    height: var(--checkbox-size);
    border-radius: 6px;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.checkbox-bg {
    position: absolute;
    inset: 0;
    border: 2px solid var(--checkbox-border);
    background: white;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.checkbox-icon {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 70%;
    height: 70%;
    color: white;
    transform: scale(0);
    transition: all 0.2s ease;
}

.check-path {
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
    transition: stroke-dashoffset 0.3s ease 0.1s;
}

/* Checked State */
.ios-checkbox.black-theme input:checked+.checkbox-wrapper .checkbox-bg {
    background: var(--checkbox-color);
    border-color: var(--checkbox-color);
}

.ios-checkbox.black-theme input:checked+.checkbox-wrapper .checkbox-icon {
    transform: scale(1);
}

.ios-checkbox.black-theme input:checked+.checkbox-wrapper .check-path {
    stroke-dashoffset: 0;
}

/* Hover Effects */
.ios-checkbox.black-theme:hover .checkbox-wrapper {
    transform: scale(1.05);
}

/* Active Animation */
.ios-checkbox.black-theme:active .checkbox-wrapper {
    transform: scale(0.95);
}

/* Focus Styles */
.ios-checkbox.black-theme input:focus+.checkbox-wrapper .checkbox-bg {
    box-shadow: 0 0 0 4px var(--checkbox-bg);
}

/* Disabled State */
.ios-checkbox.black-theme input:disabled+.checkbox-wrapper .checkbox-bg {
    background-color: #eee;
    border-color: #ccc;
}

.ios-checkbox.black-theme input:disabled+.checkbox-wrapper .checkbox-icon {
    color: #999;
}

.ios-checkbox.black-theme input:disabled {
    cursor: not-allowed;
}

.ios-checkbox.black-theme input:disabled+.checkbox-wrapper {
    cursor: not-allowed;
}

.ios-checkbox.black-theme input:disabled+.checkbox-wrapper+span {
    color: #999;
    cursor: not-allowed;
}

/* Animation */
@keyframes bounce {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.ios-checkbox.black-theme input:checked+.checkbox-wrapper {
    animation: bounce 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Custom Notification Styles === */
.notification-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-width: 100%;
    /* Ensure notification container doesn't overflow */
}

.notification {
    background-color: #000;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(100%);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    max-width: 300px;
    word-wrap: break-word;
    font-size: 0.9em;
    text-align: center;
}

.notification.show {
    opacity: 1;
    transform: translateY(0);
}


/* === Responsive Adjustments === */
@media (max-width:1024px) {
    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .project-card-image {
        height: 200px;
    }
}

@media (max-width:768px) {
    body {
        padding-top: 60px;
        width: 100vw;
        /* Explicitly set body width to viewport width */
        overflow-x: hidden;
        /* Re-affirm overflow-x hidden for body */
    }

    header {
        padding: 8px 0;
        width: 100%;
        /* Re-affirm header width */
    }

    /* Ensure header container padding is consistent with main container */
    header .container {
        padding: 0 16px;
        /* Match main container padding for consistency */
        width: 100%;
        margin: 0 auto;
    }

    nav {
        display: none;
    }

    .mobile-menu-toggle {
        display: block;
    }

    .hero h1 {
        font-size: 3em;
    }

    .hero h1 span {
        font-size: 0.35em;
    }

    .hero p {
        font-size: 1em;
    }

    section h2 {
        font-size: 2.2em;
    }

    .about-content {
        grid-template-columns: 1fr;
    }

    .about-image {
        order: -1;
        margin-bottom: 20px;
    }

    .projects-grid {
        grid-template-columns: 1fr;
    }

    .tech-stack-grid {
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    }

    .tech-item {
        min-height: 80px;
    }

    .tech-icon {
        width: 25px;
        height: 25px;
        margin-bottom: 6px;
        font-size: 1.8em;
    }

    body>.container {
        /* This targets main.container */
        padding: 0 16px;
        /* Ensure consistent horizontal padding */
        width: 100%;
        /* Ensure it takes full width */
        margin-left: auto;
        /* Explicitly center */
        margin-right: auto;
    }

    section {
        padding: 50px 0;
    }

    .back-to-top,
    .cookies-button {
        width: 45px;
        height: 45px;
        bottom: 15px;
        right: 15px;
    }

    .cookies-button {
        left: 15px;
    }

    .cookie-modal-actions .btn {
        width: 100%;
        flex: none;
    }

    .cookie-modal-content {
        width: 90%;
        height: auto;
        min-height: 280px;
        padding: 20px;
        max-width: 100%;
        /* Ensure it doesn't exceed 100% of parent */
    }

    .cookie-view {
        padding: 20px;
        width: 100%;
        /* Ensure it takes full width */
    }

    .cookie-view h3 {
        font-size: 1.8em;
        margin-bottom: 15px;
    }

    .cookie-view p {
        font-size: 0.9em;
        margin-bottom: 20px;
    }
}

@media (max-width:480px) {
    .hero h1 {
        font-size: 1.8em;
        /* Ulteriore riduzione per schermi molto piccoli */
    }

    .hero h1 span {
        font-size: 0.28em;
        /* Ulteriore riduzione per schermi molto piccoli */
    }

    .btn {
        padding: 10px 20px;
        font-size: 0.95em;
    }

    section h2 {
        font-size: 1.8em;
    }

    .project-card h3 {
        font-size: 1.5em;
    }

    .tech-stack-grid {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    }

    .tech-item {
        min-height: 70px;
        padding: 10px 5px;
    }
}