/* ===========================================
   Alessandro Francia — CV Website
   Editorial/Architectural Design
   =========================================== */

/* --- CUSTOM PROPERTIES --- */
:root {
    /* Light theme */
    --bg: #F5F0EB;
    --surface: #FFFFFF;
    --text: #1A1A1A;
    --text-secondary: #6B6560;
    --accent: #C45A3C;
    --accent-hover: #A8482E;
    --accent-muted: #E8D5CC;
    --border: #E0D8D0;
    --shadow: rgba(0, 0, 0, 0.06);
    --shadow-lg: rgba(0, 0, 0, 0.1);
    --grain-opacity: 0.3;

    /* Typography */
    --font-display: 'Instrument Serif', Georgia, serif;
    --font-body: 'DM Sans', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2.5rem;
    --space-2xl: 4rem;

    /* Layout */
    --content-max: 1120px;
    --sidebar-width: 340px;
    --radius: 6px;
}

[data-theme="dark"] {
    --bg: #131211;
    --surface: #1E1D1B;
    --text: #E8E4DF;
    --text-secondary: #8A8580;
    --accent: #D4785E;
    --accent-hover: #E08A6E;
    --accent-muted: #2A2420;
    --border: #2E2B28;
    --shadow: rgba(0, 0, 0, 0.2);
    --shadow-lg: rgba(0, 0, 0, 0.4);
    --grain-opacity: 0.15;
}

/* --- RESET & BASE --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    transition: background 0.4s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Subtle grain texture */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: var(--grain-opacity);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

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

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

img {
    display: block;
    max-width: 100%;
}

ul {
    list-style: none;
}

/* --- SCROLLBAR --- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* --- PAGE CONTAINER --- */
.page {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
}

/* --- THEME TOGGLE --- */
.theme-toggle {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: 100;
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--shadow);
}

.theme-toggle:hover {
    border-color: var(--accent);
    transform: scale(1.05);
}

.theme-toggle svg {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.icon-moon { display: none; }
.icon-sun { display: block; }

[data-theme="dark"] .icon-moon { display: block; }
[data-theme="dark"] .icon-sun { display: none; }

/* --- HEADER --- */
.header {
    padding-bottom: var(--space-2xl);
    margin-bottom: var(--space-xl);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: flex-start;
    gap: var(--space-xl);
}

.avatar-wrap {
    flex-shrink: 0;
}

.avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border);
    box-shadow: 0 4px 20px var(--shadow-lg);
    transition: border-color 0.3s ease;
}

.name {
    font-family: var(--font-display);
    font-size: 3.5rem;
    font-weight: 400;
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: var(--text);
    margin-bottom: var(--space-sm);
}

.tagline {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
    max-width: 480px;
    margin-top: var(--space-md);
}

/* --- LAYOUT --- */
.layout {
    display: grid;
    grid-template-columns: 1fr var(--sidebar-width);
    gap: var(--space-2xl);
    align-items: start;
}

/* --- CONTENT (LEFT) --- */
.content {
    min-width: 0;
}

.section {
    margin-bottom: var(--space-2xl);
}

.section-title {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 400;
    color: var(--text);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-sm);
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}

/* Summary */
.summary-text {
    font-size: 0.95rem;
    line-height: 1.75;
    color: var(--text-secondary);
    border-left: 3px solid var(--accent-muted);
    padding-left: var(--space-lg);
}

/* Experience */
.job {
    position: relative;
    padding-left: var(--space-lg);
    padding-bottom: var(--space-xl);
    border-left: 1px solid var(--border);
}

.job:last-child {
    padding-bottom: 0;
    border-left-color: transparent;
}

.job::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 6px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--bg);
}

.job-header {
    margin-bottom: var(--space-sm);
}

.job-title {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 400;
    color: var(--text);
    line-height: 1.3;
}

.job-meta {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-xs);
}

.job-company {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}

.job-location {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.job-location::before {
    content: '\00b7';
    margin-right: var(--space-sm);
    color: var(--border);
}

.job-date {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    margin-top: var(--space-xs);
}

.job-details {
    margin-top: var(--space-md);
    padding-left: var(--space-md);
    list-style: none;
}

.job-details li {
    position: relative;
    padding-left: var(--space-md);
    margin-bottom: var(--space-sm);
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.65;
}

.job-details li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.6em;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent-muted);
}

[data-theme="dark"] .job-details li::before {
    background: var(--accent);
    opacity: 0.5;
}

/* Education */
.edu {
    padding-left: var(--space-lg);
    border-left: 1px solid var(--border);
    position: relative;
}

.edu::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 6px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--bg);
}

.edu-header {
    display: flex;
    align-items: baseline;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.edu-degree {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 400;
    color: var(--text);
}

.edu-date {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.edu-school {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-top: var(--space-xs);
}

.edu-detail {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: var(--space-xs);
    line-height: 1.6;
}

/* --- SIDEBAR (RIGHT) --- */
.sidebar {
    position: sticky;
    top: var(--space-xl);
}

.sidebar-section {
    margin-bottom: var(--space-xl);
}

.sidebar-title {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 400;
    color: var(--text);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-xs);
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}

/* Contact */
.contact-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.contact-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.contact-item svg {
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--accent);
    opacity: 0.7;
}

.contact-item a {
    color: var(--text-secondary);
}

.contact-item a:hover {
    color: var(--accent);
}

/* Skills */
.skill-group {
    margin-bottom: var(--space-md);
}

.skill-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin-bottom: var(--space-xs);
}

.skill-tags {
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* Languages */
.lang-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.lang-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.lang-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.lang-name {
    font-weight: 600;
    color: var(--text);
}

.lang-level {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Download Button */
.download-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-top: var(--space-sm);
}

.download-btn:hover {
    background: var(--accent);
    color: #fff;
}

.download-btn svg {
    transition: transform 0.2s ease;
}

.download-btn:hover svg {
    transform: translateY(2px);
}

/* --- FOOTER --- */
.footer {
    margin-top: var(--space-2xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border);
    text-align: center;
}

.footer p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.6;
}

/* --- ANIMATIONS --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    opacity: 0;
    transform: translateY(16px);
}

.fade-in.visible {
    animation: fadeInUp 0.6s ease forwards;
}

.header {
    animation: fadeInUp 0.6s ease forwards;
}

/* --- RESPONSIVE --- */
@media (max-width: 860px) {
    .layout {
        grid-template-columns: 1fr;
        gap: var(--space-xl);
    }

    .sidebar {
        position: static;
    }

    .header-inner {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .name {
        font-size: 2.8rem;
    }

    .tagline {
        max-width: 100%;
    }

    .theme-toggle {
        top: var(--space-md);
        right: var(--space-md);
    }
}

@media (max-width: 480px) {
    .page {
        padding: var(--space-lg) var(--space-md);
    }

    .name {
        font-size: 2.2rem;
    }

    .section-title,
    .sidebar-title {
        font-size: 1.2rem;
    }

    .job-title,
    .edu-degree {
        font-size: 1.1rem;
    }
}

/* --- PRINT --- */
@media print {
    body::after {
        display: none;
    }

    .theme-toggle,
    .download-btn {
        display: none;
    }

    .page {
        max-width: 100%;
        padding: 0;
    }

    .layout {
        grid-template-columns: 1fr 280px;
        gap: 2rem;
    }

    .fade-in {
        opacity: 1;
        transform: none;
    }

    .header {
        animation: none;
    }

    .sidebar {
        position: static;
    }

    body {
        font-size: 11px;
        background: white;
        color: #000;
    }

    .section-title,
    .sidebar-title {
        border-bottom-color: #000;
    }

    a {
        color: inherit;
    }

    .job {
        break-inside: avoid;
    }
}
