/* =========================================
    1. TOKENS (Variables)
========================================= */
:root {
    /* Palette */
    --c-bg: #121212;
    --c-panel: #16161c70;
    --c-border: #26262b;
    --c-input: var(--c-panel);
    --c-console: var(--c-border);
    
    --c-text-main: #E4E4E7;
    --c-text-muted: #A1A1AA;
    --c-text-dim: #71717A;
    
    --c-accent: #AFAFFF;
    --c-accent-glow: #a78bfa26;

    /* Spacing Scale */
    --sp-xs: 0.5rem;   /* 8px */
    --sp-sm: 1rem;     /* 16px */
    --sp-md: 2rem;     /* 32px */
    --sp-lg: 4rem;     /* 64px */
    
    /* UI Elements */
    --radius: 12px; 
    --blur: 12px;
    --box-shadow: 0 20px 40px -10px #00000080;
    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

/* =========================================
    2. BASE & RESET
========================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background-color: var(--c-bg);
    background-image: 
        url('/assets/images/avatar.svg'),
        radial-gradient(circle at 100% 100%, #AFAFFF0D 0%, transparent 40%),
        linear-gradient(135deg, #1a1a20 0%, #050505 100%);
        
    background-attachment: fixed; 
    /* Posiziono l'SVG fuori dallo schermo parzialmente a sinistra e centrato verticalmente */
    background-position: 60% center, center, center; 
    background-repeat: no-repeat, no-repeat, no-repeat;
    /* Dimensione dell'SVG adattiva all'altezza della viewport */
    background-size: 100vh auto, cover, cover;       
    color: var(--c-text-main);
    font-family: var(--font-sans);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh; 
}

@media (min-width: 650px) {
    body {
        background-position: 30% center, center, center; 
        background-size: 180vh auto, cover, cover;   
    }
}


a {
    color: var(--c-text-main);
    text-decoration: none;
    border-bottom: 1px solid var(--c-accent);
    transition: all 0.2s ease;
}

a:hover,
a:focus {
    color: var(--c-accent);
    background-color: var(--c-accent-glow);
    border-radius: 2px;
    border-color: transparent;
}

ul { list-style: none; }

/* =========================================
    3. LAYOUT SYSTEM
========================================= */
.container {
    max-width: 1100px; 
    margin: 0 auto;
    padding: 0 var(--sp-sm);
}

/* Generic Header Layout */
.header-layout {
    padding: var(--sp-md) 0;
    display: flex;
    align-items: center;
    justify-content: space-between; 
    flex-wrap: wrap;
    gap: var(--sp-md);
    margin-bottom: var(--sp-md);
}

/* Generic Sidebar Layout (Main + Aside) */
.layout-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--sp-lg);
    * {
        min-width: 0;
    }
}

@media (min-width: 850px) {
    .layout-grid {
        grid-template-columns: 2.5fr 1fr; 

        aside.floating {
            position: sticky;
            position: -webkit-sticky;
            top: var(--sp-md);
            height: fit-content;
            max-height: calc(100vh - var(--sp-lg));
            overflow-y: auto;
        }
    }
}

/* =========================================
    4. UTILITIES
========================================= */

/* Flex Utils */
.u-flex { display: flex; }
.u-flex-col { display: flex; flex-direction: column; }
.u-items-center { align-items: center; }
.u-justify-between { justify-content: space-between; }
.u-wrap { flex-wrap: wrap; }

/* Typography Utils */
.u-text-center { text-align: center; }
.u-font-mono { font-family: var(--font-mono); }
.u-text-dim { color: var(--c-text-dim); }
.u-text-muted { color: var(--c-text-muted); }
.u-text-main { color: var(--c-text-main); }
.u-text-accent { color: var(--c-accent); }
.u-text-sm { font-size: 0.875rem; }
.u-text-lg { font-size: 1.25rem; }
.u-text-bg { font-size: 1.2rem; }
.u-text-hg { font-size: 1.56rem; }
.u-bold { font-weight: 700; }
.u-italic { font-style: italic; }
.u-uppercase { text-transform: uppercase; letter-spacing: 0.05em; }
.u-block { display: block; }

/* Spacing Utils */
.u-mt-xs { margin-top: var(--sp-xs); }
.u-mt-sm { margin-top: var(--sp-sm); }
.u-mt-md { margin-top: var(--sp-md); }
.u-mt-lg { margin-top: var(--sp-lg); }
.u-mb-xs { margin-bottom: var(--sp-xs); }
.u-mb-sm { margin-bottom: var(--sp-sm); }
.u-mb-md { margin-bottom: var(--sp-md); }
.u-mb-lg { margin-bottom: var(--sp-lg); }

/* Gap Utils */
.u-gap-xs { gap: 8px; }
.u-gap-sm { gap: var(--sp-sm); }
.u-gap-md { gap: var(--sp-md); }

.u-bg-blur {
    background-color: var(--c-panel);
    backdrop-filter: blur(var(--blur));
}

/* =========================================
    5. COMPONENTS
========================================= */

/* --- UI: INPUTS --- */
.input {
    background-color: var(--c-input);
    backdrop-filter: blur(var(--blur));
    box-shadow: var(--box-shadow);
    border: 1px solid var(--c-border);
    color: var(--c-text-main);
    padding: 10px 16px;
    border-radius: 50px;
    font-family: var(--font-sans);
    width: 100%;
    transition: border-color 0.2s, width 0.2s;
}
.input:focus {
    outline: none;
    border-color: var(--c-accent);
}
/* Modifier for Header Search */
.input--search { width: 100%; }
@media (min-width: 650px) {
    .input--search { width: 250px; }
    .input--search:focus { width: 280px; }
}

/* --- COMPONENT: SEARCH WRAPPER (Layout Helper) --- */
.search-wrapper {
    width: 100%;
}
@media (min-width: 650px) {
    .search-wrapper {
        width: auto;
    }
}

/* --- UI: AVATAR --- */
.avatar {
    width: 80px; 
    height: 80px;
    
    background-color: var(--c-accent);
    
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    
    transition: all 0.4s ease-in-out;
    position: relative;
    z-index: 10; 
}

@media (min-width: 768px) {
    .avatar {
        width: 145px;
        height: 145px;
    }
}

.avatar img {
    width: 80%;
    height: 80%;
    transition: transform 0.3s ease;
}

.avatar:hover { 
    transform: scale(1.05) rotate(-3deg); 
    box-shadow: 0 0 140px 40px rgba(120, 120, 130, 0.35);
}

.avatar:hover img {
    transform: scale(1.1);
}

/* --- UI: PANELS & CARDS --- */
.panel {
    background-color: var(--c-panel);
    backdrop-filter: blur(var(--blur));
    padding: var(--sp-md);
    border-radius: var(--radius);
    box-shadow: var(--box-shadow);
    border: 1px solid var(--c-border);
}

.panel-header {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--c-accent);
    margin-bottom: var(--sp-sm);
    display: flex;
    align-items: center;
}

.panel-header--lined::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--c-border);
    margin-left: 10px;
}

/* --- UI: BADGES (Tags) --- */
.badge {
    display: inline-block;
    color: var(--c-text-muted);
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-family: var(--font-mono);
    border: 1px solid var(--c-border);
    background-color: var(--c-panel); 
    padding: var(--sp-xs);
    backdrop-filter: blur(var(--blur));
}

a.badge:hover,
a.badge:focus,
a.badge.active {
    color: var(--c-accent);
    background-color: var(--c-accent-glow);
    border-color: var(--c-accent);
    border-radius: var(--radius);
}

/* --- COMPONENT: ARTICLE PREVIEW --- */
.item-preview h3 {
    font-size: 1.75rem;
    margin-bottom: var(--sp-xs);
    letter-spacing: -0.02em;
}
.item-preview p {
    color: var(--c-text-muted);
    font-size: 1.05rem;
    line-height: 1.7;
}

/* --- COMPONENT: TERMINAL HERO --- */
.terminal {
    /*background-color: var(--c-console);*/
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    border: 1px solid var(--c-border);
    box-shadow: var(--box-shadow);
    backdrop-filter: blur(var(--blur));
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.terminal__bar {
    background-color: var(--c-console);
    padding: 10px 16px;
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--c-border);
}

.terminal__dot { width: 12px; height: 12px; border-radius: 50%; }
.bg-red { background-color: #ff5f56; }
.bg-yellow { background-color: #ffbd2e; }
.bg-green { background-color: #27c93f; }

.terminal__body {
    background-color: var(--c-panel); 
    padding: var(--sp-sm);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

/* Animation specific CSS */
@keyframes typing-anim { from { width: 0 } to { width: 12ch; } }
@keyframes blink-caret { from, to { border-color: transparent } 50% { border-color: #ffffff; } }
@keyframes fade-in-anim { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes blink-block { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.cmd-line { display: flex; align-items: center; width: 100%; }

.cmd-input {
    display: inline-block; overflow: hidden; white-space: nowrap;
    box-sizing: content-box;
    border-right: 10px solid #ffffff; 
    width: 0; vertical-align: bottom;
    animation: typing-anim 1s steps(12, end) forwards, blink-caret .75s step-end 2 forwards;
}

.cmd-output {
    opacity: 0; width: 100%;
    animation: fade-in-anim 0.6s ease forwards; animation-delay: 1.5s;
}

.cursor-block {
    display: inline-block; width: 10px; height: 1.2em;
    background-color: #ffffff; 
    margin-left: 8px;
    animation: blink-block 1s infinite;
}

/* --- UI: FOOTER --- */
.site-footer {
    border-top: 1px solid #222;
    padding: var(--sp-md) 0;
    margin-top: var(--sp-lg);
    text-align: center;
    color: var(--c-text-dim);
}
