/**
 * Main Stylesheet - Sito Vetrina Domenico Simone Marsella
 * Design System con CSS Custom Properties
 */

/* ========================================
   1. CSS CUSTOM PROPERTIES (Design Tokens)
   ======================================== */
:root {
    /* Palette Colori */
    --color-primary: #1e3a5f;
    --color-primary-light: #2c5282;
    --color-primary-dark: #0d1b2a;
    --color-secondary: #3182ce;
    --color-accent: #f6ad55;
    --color-accent-dark: #dd6b20;

    --color-success: #38a169;
    --color-warning: #d69e2e;
    --color-error: #e53e3e;

    --color-text: #1a202c;
    --color-text-secondary: #4a5568;
    --color-text-muted: #718096;
    --color-text-inverse: #ffffff;

    --color-background: #f7fafc;
    --color-surface: #ffffff;
    --color-surface-alt: #edf2f7;
    --color-border: #e2e8f0;

    /* Tipografia */
    --font-family-base: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-family-heading: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-family-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;

    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;
    --font-size-5xl: 3rem;
    --font-size-6xl: 3.75rem;

    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    --line-height-tight: 1.25;
    --line-height-base: 1.6;
    --line-height-relaxed: 1.75;

    /* Spaziatura */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;
    --space-24: 6rem;

    /* Layout */
    --container-sm: 640px;
    --container-md: 768px;
    --container-lg: 1024px;
    --container-xl: 1200px;
    --container-2xl: 1400px;

    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);

    /* Transizioni */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;
    --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Z-Index Scale */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-fixed: 300;
    --z-modal-backdrop: 400;
    --z-modal: 500;
    --z-tooltip: 600;
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    :root {
        --color-text: #f7fafc;
        --color-text-secondary: #cbd5e0;
        --color-text-muted: #a0aec0;
        --color-background: #0d1b2a;
        --color-surface: #1a365d;
        --color-surface-alt: #2c5282;
        --color-border: #2d3748;
    }
}

/* ========================================
   2. RESET E BASE
   ======================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

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

    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

body {
    font-family: var(--font-family-base);
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
    color: var(--color-text);
    background-color: var(--color-background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

/* ========================================
   3. TIPOGRAFIA
   ======================================== */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-family-heading);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
    color: var(--color-text);
}

h1 {
    font-size: var(--font-size-4xl);
    letter-spacing: -0.02em;
}

h2 {
    font-size: var(--font-size-3xl);
    letter-spacing: -0.01em;
}

h3 {
    font-size: var(--font-size-2xl);
}

h4 {
    font-size: var(--font-size-xl);
}

h5 {
    font-size: var(--font-size-lg);
}

h6 {
    font-size: var(--font-size-base);
}

p {
    margin-bottom: var(--space-4);
}

a {
    color: var(--color-secondary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

strong, b {
    font-weight: var(--font-weight-semibold);
}

small {
    font-size: var(--font-size-sm);
}

code, pre {
    font-family: var(--font-family-mono);
}

code {
    background: var(--color-surface-alt);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
}

pre {
    background: var(--color-primary-dark);
    color: var(--color-text-inverse);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    overflow-x: auto;
}

pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

/* ========================================
   4. ACCESSIBILITA
   ======================================== */
.skip-link {
    position: absolute;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-primary);
    color: var(--color-text-inverse);
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-md);
    z-index: var(--z-tooltip);
    transition: top var(--transition-fast);
    font-weight: var(--font-weight-medium);
}

.skip-link:focus {
    top: var(--space-2);
}

:focus-visible {
    outline: 3px solid var(--color-secondary);
    outline-offset: 2px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ========================================
   5. LAYOUT
   ======================================== */
.container {
    width: 100%;
    max-width: var(--container-xl);
    margin-inline: auto;
    padding-inline: var(--space-4);
}

.container--sm { max-width: var(--container-sm); }
.container--md { max-width: var(--container-md); }
.container--lg { max-width: var(--container-lg); }
.container--2xl { max-width: var(--container-2xl); }

.section {
    padding-block: var(--space-16);
}

.section--lg {
    padding-block: var(--space-24);
}

.grid {
    display: grid;
    gap: var(--space-6);
}

.grid--2 {
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
}

.grid--3 {
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
}

.flex {
    display: flex;
}

.flex--center {
    align-items: center;
    justify-content: center;
}

.flex--between {
    align-items: center;
    justify-content: space-between;
}

/* ========================================
   6. HEADER & NAVIGATION
   ======================================== */
.site-header {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.site-header.is-scrolled {
    box-shadow: var(--shadow-md);
}

.site-header.is-hidden {
    transform: translateY(-100%);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-block: var(--space-4);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-decoration: none;
}

.logo__image {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    object-fit: cover;
}

.logo__text {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    color: var(--color-primary);
    letter-spacing: -0.01em;
}

@media (max-width: 640px) {
    .logo__text {
        font-size: var(--font-size-base);
    }
}

.main-nav {
    display: flex;
    align-items: center;
    gap: var(--space-6);
}

.nav-link {
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
    transition: color var(--transition-fast);
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--color-secondary);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform var(--transition-base);
}

.nav-link:hover {
    color: var(--color-primary);
    text-decoration: none;
}

.nav-link:hover::after {
    transform: scaleX(1);
    transform-origin: left;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-2);
}

@media (max-width: 768px) {
    .nav-toggle {
        display: block;
    }

    .main-nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        background: var(--color-surface);
        flex-direction: column;
        align-items: flex-start;
        padding: var(--space-16) var(--space-6);
        gap: var(--space-4);
        box-shadow: var(--shadow-2xl);
        transition: right var(--transition-base);
    }

    .main-nav.is-open {
        right: 0;
    }
}

/* ========================================
   7. HERO SECTION
   ======================================== */
.hero {
    min-height: 70vh;
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary) 100%);
    color: var(--color-text-inverse);
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.5;
}

.hero__content {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.hero__title {
    font-size: clamp(var(--font-size-3xl), 5vw, var(--font-size-6xl));
    margin-bottom: var(--space-4);
    color: var(--color-text-inverse);
}

.hero__subtitle {
    font-size: var(--font-size-xl);
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: var(--space-8);
    font-weight: var(--font-weight-normal);
}

/* ========================================
   8. CARDS
   ======================================== */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.card__title {
    font-size: var(--font-size-xl);
    margin-bottom: var(--space-3);
    color: var(--color-primary);
}

.card__content {
    flex: 1;
    color: var(--color-text-secondary);
}

.card__footer {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
}

.card--highlight {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: var(--color-text-inverse);
}

.card--highlight .card__title {
    color: var(--color-text-inverse);
}

.card--highlight .card__content {
    color: rgba(255, 255, 255, 0.9);
}

/* Feature Cards */
.feature-card {
    padding: var(--space-8);
    text-align: center;
}

.feature-card__icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--space-4);
    background: var(--color-surface-alt);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-secondary);
}

/* ========================================
   9. BUTTONS
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-family: inherit;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    text-decoration: none;
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn--primary {
    background: var(--color-secondary);
    color: var(--color-text-inverse);
}

.btn--primary:hover {
    background: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    text-decoration: none;
}

.btn--secondary {
    background: transparent;
    color: var(--color-secondary);
    border-color: var(--color-secondary);
}

.btn--secondary:hover {
    background: var(--color-secondary);
    color: var(--color-text-inverse);
    text-decoration: none;
}

.btn--ghost {
    background: transparent;
    color: var(--color-text-inverse);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn--ghost:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
}

.btn--lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--font-size-lg);
}

.btn--sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
}

/* ========================================
   10. FORMS
   ======================================== */
.form-group {
    margin-bottom: var(--space-4);
}

.form-label {
    display: block;
    font-weight: var(--font-weight-medium);
    margin-bottom: var(--space-2);
    color: var(--color-text);
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-family: inherit;
    font-size: var(--font-size-base);
    color: var(--color-text);
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-secondary);
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.2);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
}

/* ========================================
   11. MODALS
   ======================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: var(--z-modal-backdrop);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base);
}

.modal-backdrop.is-active {
    opacity: 1;
    visibility: visible;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    z-index: var(--z-modal);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.modal.is-active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.modal__close {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    background: none;
    border: none;
    font-size: var(--font-size-2xl);
    cursor: pointer;
    color: var(--color-text-muted);
    transition: color var(--transition-fast);
}

.modal__close:hover {
    color: var(--color-text);
}

/* ========================================
   12. SECTION SPECIFICHE
   ======================================== */

/* Book Section */
.book-section {
    background: var(--color-surface);
}

.book-showcase {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: var(--space-8);
    align-items: center;
}

@media (max-width: 768px) {
    .book-showcase {
        grid-template-columns: 1fr;
        text-align: center;
    }
}

.book-cover {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2xl);
    max-width: 300px;
}

/* Media Player */
.media-player {
    background: var(--color-surface-alt);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-top: var(--space-4);
}

.media-player audio,
.media-player video {
    width: 100%;
    border-radius: var(--radius-md);
}

/* Chat Section */
.chat-container {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.chat-header {
    background: var(--color-primary);
    color: var(--color-text-inverse);
    padding: var(--space-4) var(--space-6);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.chat-status {
    width: 12px;
    height: 12px;
    border-radius: var(--radius-full);
    background: var(--color-text-muted);
}

.chat-status.online {
    background: var(--color-success);
}

.chat-status.offline {
    background: var(--color-error);
}

.chat-messages {
    height: 350px;
    overflow-y: auto;
    padding: var(--space-4);
    background: var(--color-background);
}

.chat-input-wrapper {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-4);
    border-top: 1px solid var(--color-border);
}

.chat-input {
    flex: 1;
}

/* ========================================
   13. FOOTER
   ======================================== */
.site-footer {
    background: var(--color-primary-dark);
    color: var(--color-text-inverse);
    padding-block: var(--space-12);
    margin-top: auto;
}

.footer-content {
    text-align: center;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: var(--space-6);
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
}

.footer-link {
    color: rgba(255, 255, 255, 0.7);
    transition: color var(--transition-fast);
}

.footer-link:hover {
    color: var(--color-text-inverse);
}

.footer-social {
    display: flex;
    justify-content: center;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    color: var(--color-text-inverse);
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.social-link:hover {
    background: var(--color-secondary);
    transform: translateY(-2px);
}

.footer-copy {
    color: rgba(255, 255, 255, 0.5);
    font-size: var(--font-size-sm);
}

/* ========================================
   14. UTILITIES
   ======================================== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--color-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-muted { color: var(--color-text-muted); }

.bg-surface { background: var(--color-surface); }
.bg-alt { background: var(--color-surface-alt); }

.mt-4 { margin-top: var(--space-4); }
.mt-8 { margin-top: var(--space-8); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-8 { margin-bottom: var(--space-8); }

.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }

.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }

.shadow { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

/* ========================================
   15. RESPONSIVE
   ======================================== */
@media (max-width: 640px) {
    :root {
        --font-size-4xl: 2rem;
        --font-size-3xl: 1.5rem;
        --font-size-2xl: 1.25rem;
    }

    .section {
        padding-block: var(--space-10);
    }

    h1 { font-size: var(--font-size-3xl); }
    h2 { font-size: var(--font-size-2xl); }
}
