/* ==========================================================================
   RGA MAINFRAME — STYLE CORE V.5.0
   Riscrittura completa, mobile-first, componenti unificati.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* --------------------------------------------------------------------------
   1. RESET & DESIGN TOKENS
   -------------------------------------------------------------------------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colore */
    --void: #060606;
    --panel: #0d0d0d;
    --panel-raised: #131313;
    --red: #ff1e1e;
    --red-deep: #5a0000;
    --red-dim: #8f0000;
    --red-glow: rgba(255, 30, 30, 0.45);
    --green: #00ff7f;
    --amber: #ffcc00;
    --text: #e6e6e6;
    --text-dim: #8a8a8a;
    --text-faint: #4a4a4a;

    /* Tipografia */
    --font-display: 'Share Tech Mono', 'Courier New', monospace;
    --font-body: 'JetBrains Mono', 'Courier New', monospace;

    /* Layout */
    --max-width: 1200px;
    --nav-breakpoint: 1100px;
}

html, body {
    width: 100%;
    min-height: 100%;
    background-color: var(--void);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.7;
    overflow-x: hidden;
}

a { color: inherit; }

ul { list-style: none; }

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

/* Focus visibile per accessibilità da tastiera */
a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--red);
    outline-offset: 3px;
}

/* Rispetta la preferenza utente per motion ridotto */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* --------------------------------------------------------------------------
   2. TEXTURE DI SFONNO — scanline + grid, molto tenue, solo atmosfera
   -------------------------------------------------------------------------- */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background-image:
        repeating-linear-gradient(
            0deg,
            rgba(255, 255, 255, 0.015) 0px,
            rgba(255, 255, 255, 0.015) 1px,
            transparent 1px,
            transparent 3px
        ),
        linear-gradient(
            rgba(255, 30, 30, 0.03) 1px,
            transparent 1px
        ),
        linear-gradient(
            90deg,
            rgba(255, 30, 30, 0.03) 1px,
            transparent 1px
        );
    background-size: 100% 3px, 48px 48px, 48px 48px;
}

/* --------------------------------------------------------------------------
   3. TERMINAL CONTAINER — wrapper unico, niente doppi div
   -------------------------------------------------------------------------- */
.terminal-container {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(160deg, var(--void) 0%, #150000 100%);
    border-left: 3px solid var(--red);
    border-right: 3px solid var(--red);
}

@media (max-width: 768px) {
    .terminal-container { border-left: none; border-right: none; }
}

/* --------------------------------------------------------------------------
   4. HEADER & NAVIGAZIONE
   -------------------------------------------------------------------------- */
.header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(6, 6, 6, 0.92);
    border-bottom: 2px solid var(--red);
    padding: 18px 0;
    backdrop-filter: blur(8px);
}

.header-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.title {
    font-family: var(--font-display);
    font-size: 15px;
    letter-spacing: 2px;
    color: var(--red);
    text-shadow: 0 0 12px var(--red-glow);
    white-space: nowrap;
}

/* Nav: desktop = riga orizzontale */
.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    justify-content: flex-end;
}

.nav-link {
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    padding: 6px 4px;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s, text-shadow 0.2s;
}

.nav-link:hover,
.nav-link:focus-visible {
    color: var(--red);
    text-shadow: 0 0 8px var(--red-glow);
}

.nav-link.active {
    color: var(--red);
    border-color: var(--red);
    text-shadow: 0 0 8px var(--red-glow);
}

/* Hamburger: nascosto su desktop */
.nav-toggle {
    display: none;
    background: none;
    border: 1px solid var(--red-dim);
    color: var(--red);
    font-family: var(--font-display);
    font-size: 20px;
    line-height: 1;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 3px;
}

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

    .nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        gap: 0;
        background: rgba(6, 6, 6, 0.97);
        border-bottom: 2px solid var(--red);
        padding: 10px 24px 18px;
    }

    .nav.open { display: flex; }

    .nav-link {
        padding: 12px 4px;
        border-bottom: 1px solid #1a1a1a;
        width: 100%;
    }

    .nav-link.active { border-bottom: 1px solid var(--red); }
}

/* --------------------------------------------------------------------------
   5. HERO (solo Home)
   -------------------------------------------------------------------------- */
.hero-section {
    position: relative;
    z-index: 2;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 32px 20px 8px;
}

.hero-image {
    display: block;
    width: 100%;
    height: auto;
    max-width: 320px;
    border: 2px solid var(--red);
    box-shadow: 0 0 30px var(--red-glow);
    animation: hero-pulse 4s ease-in-out infinite;
}

@keyframes hero-pulse {
    0%, 100% { box-shadow: 0 0 20px var(--red-glow); }
    50% { box-shadow: 0 0 38px var(--red-glow); }
}

@media (min-width: 600px) {
    .hero-image { max-width: 460px; }
}

@media (min-width: 1000px) {
    .hero-image { max-width: 620px; }
}

/* --------------------------------------------------------------------------
   6. MAIN CONTENT / INTRO (Home)
   -------------------------------------------------------------------------- */
.main-content {
    position: relative;
    z-index: 2;
    flex: 1;
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
    padding: 0 24px 60px;
}

.main-title {
    font-family: var(--font-display);
    font-size: clamp(28px, 6vw, 48px);
    text-align: center;
    letter-spacing: 3px;
    color: var(--text);
    text-shadow: 0 0 18px var(--red-glow);
    margin-bottom: 20px;
}

.intro-text {
    text-align: center;
    color: var(--text-dim);
    margin: 20px 0 36px;
    font-size: 14px;
}

/* --------------------------------------------------------------------------
   7. STATUS BAR (indicatore "online" ecc.)
   -------------------------------------------------------------------------- */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--panel);
    border: 1px solid var(--red-deep);
    border-radius: 3px;
    padding: 10px 16px;
    max-width: 460px;
    margin: 0 auto;
}

.status-indicator {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
    animation: blink 1.8s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.status-text {
    font-size: 11px;
    letter-spacing: 1px;
    color: var(--green);
    text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   8. MODULES GRID (card dashboard Home)
   -------------------------------------------------------------------------- */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin: 40px 0;
}

.module-card {
    position: relative;
    background: rgba(255, 30, 30, 0.04);
    border: 2px solid var(--red-dim);
    padding: 26px 20px;
    text-decoration: none;
    color: var(--text);
    text-align: center;
    border-radius: 4px;
    overflow: hidden;
    transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s;

    /* reveal animation, CSS-only */
    opacity: 0;
    animation: card-reveal 0.5s ease-out forwards;
}

.module-card:nth-child(1) { animation-delay: 0.05s; }
.module-card:nth-child(2) { animation-delay: 0.12s; }
.module-card:nth-child(3) { animation-delay: 0.19s; }
.module-card:nth-child(4) { animation-delay: 0.26s; }
.module-card:nth-child(5) { animation-delay: 0.33s; }
.module-card:nth-child(6) { animation-delay: 0.40s; }
.module-card:nth-child(7) { animation-delay: 0.47s; }
.module-card:nth-child(8) { animation-delay: 0.54s; }

@keyframes card-reveal {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

.module-card:hover,
.module-card:focus-visible {
    border-color: var(--red);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--red-glow);
}

.module-icon { font-size: 30px; margin-bottom: 10px; }

.module-title {
    font-family: var(--font-display);
    font-size: 14px;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
}

.module-desc {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 14px;
}

.module-status {
    display: inline-block;
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--red);
    border: 1px solid var(--red-dim);
    padding: 4px 10px;
    border-radius: 2px;
}

/* --------------------------------------------------------------------------
   9. SYSTEM INFO (statistiche Home)
   -------------------------------------------------------------------------- */
.system-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-top: 30px;
    padding: 20px;
    border: 1px solid var(--red-deep);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.4);
}

.info-box {
    text-align: center;
    border: 1px solid rgba(255, 30, 30, 0.15);
    border-radius: 3px;
    padding: 12px 8px;
}

.info-label {
    display: block;
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.info-value {
    display: block;
    font-family: var(--font-display);
    font-size: 20px;
    color: var(--red);
}

/* --------------------------------------------------------------------------
   10. PAGE HEADER (pagine interne)
   -------------------------------------------------------------------------- */
.page-header {
    position: relative;
    z-index: 2;
    border-bottom: 1px solid var(--red-deep);
    background: linear-gradient(180deg, rgba(255, 30, 30, 0.06), transparent);
    padding: 40px 24px;
}

.page-header .header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.page-title {
    font-family: var(--font-display);
    font-size: clamp(22px, 4.5vw, 32px);
    letter-spacing: 2px;
    color: var(--text);
    text-shadow: 0 0 14px var(--red-glow);
}

.page-subtitle {
    font-size: 12px;
    letter-spacing: 1px;
    color: var(--text-dim);
    text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   11. PAGE CONTENT / SEZIONI — pattern unico per tutte le pagine
   -------------------------------------------------------------------------- */
.page-content {
    position: relative;
    z-index: 2;
    flex: 1;
    max-width: 860px;
    margin: 0 auto;
    width: 100%;
    padding: 40px 24px 20px;
}

.content-section {
    margin-bottom: 44px;
    opacity: 0;
    animation: card-reveal 0.5s ease-out forwards;
}

.content-section:nth-of-type(1) { animation-delay: 0.05s; }
.content-section:nth-of-type(2) { animation-delay: 0.12s; }
.content-section:nth-of-type(3) { animation-delay: 0.19s; }
.content-section:nth-of-type(4) { animation-delay: 0.26s; }
.content-section:nth-of-type(5) { animation-delay: 0.33s; }

.section-title {
    font-family: var(--font-display);
    font-size: 16px;
    letter-spacing: 1.5px;
    color: var(--red);
    text-shadow: 0 0 10px var(--red-glow);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--red-deep);
}

.subsection { margin-bottom: 18px; }

.subsection-text {
    color: var(--text);
    margin-bottom: 12px;
}

.subsection-list li {
    position: relative;
    padding-left: 20px;
    margin-bottom: 8px;
    color: var(--text-dim);
}

.subsection-list li::before {
    content: "›";
    position: absolute;
    left: 0;
    color: var(--red);
    font-weight: 700;
}

.quote {
    border-left: 3px solid var(--red);
    background: rgba(255, 30, 30, 0.05);
    padding: 16px 20px;
    margin: 24px 0;
    font-style: italic;
    color: var(--text-dim);
    border-radius: 0 3px 3px 0;
}

/* Blocchi "fase" numerati (usati in protocollo.html — qui l'ordine è reale) */
.phase-block {
    border-left: 4px solid var(--red);
    padding-left: 22px;
    margin-bottom: 28px;
}

.phase-block h3 {
    font-family: var(--font-display);
    font-size: 16px;
    letter-spacing: 1px;
    color: var(--red);
    margin-bottom: 10px;
}

/* Blocco codice (usato in segnalazioni.html per il formato dossier) */
.code-block {
    background: #000;
    border: 1px solid var(--red-dim);
    border-radius: 4px;
    padding: 18px;
    color: var(--green);
    font-family: var(--font-body);
    font-size: 12.5px;
    line-height: 1.9;
    margin: 18px 0;
}

/* --------------------------------------------------------------------------
   12. AZIONI / LINK / BOTTONI
   -------------------------------------------------------------------------- */
.action-link {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 12px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--text);
    border: 2px solid var(--red);
    background: rgba(255, 30, 30, 0.08);
    padding: 12px 22px;
    margin: 6px 8px 6px 0;
    border-radius: 3px;
    transition: background 0.2s, box-shadow 0.2s, transform 0.2s;
}

.action-link:hover,
.action-link:focus-visible {
    background: var(--red);
    color: #000;
    box-shadow: 0 0 22px var(--red-glow);
    transform: translateY(-2px);
}

.cta-row {
    text-align: center;
    margin-top: 36px;
    padding-bottom: 20px;
}

.back-link {
    display: inline-block;
    margin-top: 14px;
    color: var(--text-faint);
    text-decoration: none;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.back-link:hover, .back-link:focus-visible { color: var(--text-dim); }

/* --------------------------------------------------------------------------
   13. FOOTER
   -------------------------------------------------------------------------- */
.footer {
    position: relative;
    z-index: 2;
    border-top: 2px solid var(--red-deep);
    background: rgba(0, 0, 0, 0.5);
    padding: 22px 24px;
    margin-top: auto;
}

.footer-content {
    max-width: var(--max-width);
    margin: 0 auto;
    text-align: center;
}

.footer-text {
    font-size: 11px;
    letter-spacing: 1px;
    color: var(--text-faint);
}

.footer-status {
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--text-faint);
    margin-top: 4px;
}

/* --------------------------------------------------------------------------
   14. HUD DI STATO — elemento firma, fisso in basso a destra
   -------------------------------------------------------------------------- */
.system-hud {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 50;
    background: rgba(6, 6, 6, 0.9);
    border: 1px solid var(--red-dim);
    border-radius: 4px;
    padding: 8px 12px;
    font-family: var(--font-body);
    font-size: 10px;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    gap: 2px;
    pointer-events: none;
    user-select: none;
}

.system-hud .hud-line { white-space: nowrap; }
.system-hud .hud-green { color: var(--green); }
.system-hud .hud-red { color: var(--red); }

.hud-cursor {
    display: inline-block;
    width: 6px;
    height: 11px;
    background: var(--green);
    margin-left: 3px;
    animation: blink 1s steps(1) infinite;
    vertical-align: middle;
}

@media (max-width: 560px) {
    .system-hud { display: none; } /* su schermi piccoli lascia spazio ai contenuti */
}

/* --------------------------------------------------------------------------
   15. SCROLLBAR PERSONALIZZATA
   -------------------------------------------------------------------------- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--void); }
::-webkit-scrollbar-thumb {
    background: var(--red-dim);
    border-radius: 0;
    box-shadow: 0 0 8px var(--red-glow);
}
