:root {
    --bg: #0a0608;
    --bg-soft: #170e11;
    --accent: #ff1f3d;
    --accent-2: #8b0000;
    --gold: #d4a017;
    --text: #f5eeee;
    --text-dim: #bfaaaa;
    --nav-h: 76px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Crimson Text', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(160deg, #120a0c 0%, #0a0608 55%, #150a0a 100%);
    color: var(--text);
    overflow-x: hidden;
}

/* ---------- Particelle di sfondo (braci) ---------- */

.background-animation {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.floating-particles { position: absolute; width: 100%; height: 100%; }

.floating-particle {
    position: absolute;
    bottom: -10px;
    border-radius: 50%;
    animation: ember-rise linear infinite;
    filter: blur(0.5px);
}

/* Varianti di particella via classi JS */
.floating-particle--sm  { width: 3px; height: 3px; }
.floating-particle--md  { width: 5px; height: 5px; }
.floating-particle--lg  { width: 7px; height: 7px; }

.floating-particle--red  { background: rgba(255, 31, 61, 0.6); box-shadow: 0 0 6px rgba(255, 31, 61, 0.4); }
.floating-particle--gold { background: rgba(212, 160, 23, 0.55); box-shadow: 0 0 6px rgba(212, 160, 23, 0.35); }
.floating-particle--pale { background: rgba(255, 200, 140, 0.35); box-shadow: 0 0 4px rgba(255, 200, 140, 0.2); }

@keyframes ember-rise {
    0%   { transform: translateY(0) translateX(0) scale(1); opacity: 0; }
    8%   { opacity: 1; }
    50%  { transform: translateY(-50vh) translateX(var(--drift, 20px)) scale(0.8); opacity: 0.85; }
    100% { transform: translateY(-105vh) translateX(calc(var(--drift, 20px) * -0.5)) scale(0.3); opacity: 0; }
}

/* ---------- Navbar ---------- */

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--nav-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 3rem;
    z-index: 100;
    background: linear-gradient(to bottom, rgba(10, 6, 8, 0.92), transparent);
    transition: background 0.4s ease, box-shadow 0.4s ease;
}

.navbar.scrolled {
    background: rgba(10, 6, 8, 0.94);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-family: 'Pirata One', cursive;
    font-size: 1.9rem;
    color: var(--accent);
    text-decoration: none;
    text-shadow: 0 0 18px rgba(255, 31, 61, 0.45);
    animation: brand-flicker 4s ease-in-out infinite;
}

.brand i { animation: pulse 2.4s ease-in-out infinite; }

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); }
}

@keyframes brand-flicker {
    0%, 100% { text-shadow: 0 0 18px rgba(255, 31, 61, 0.45); opacity: 1; }
    30%      { text-shadow: 0 0 24px rgba(255, 31, 61, 0.7), 0 0 60px rgba(139, 0, 0, 0.3); opacity: 1; }
    32%      { opacity: 0.85; text-shadow: 0 0 8px rgba(255, 31, 61, 0.25); }
    34%      { opacity: 1; text-shadow: 0 0 24px rgba(255, 31, 61, 0.7), 0 0 60px rgba(139, 0, 0, 0.3); }
    70%      { text-shadow: 0 0 22px rgba(255, 31, 61, 0.5); }
}

.nav-links {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 2.25rem;
}

.nav-links a {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: color 0.2s ease;
    position: relative;
}

.nav-links > li > a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -6px;
    width: 0;
    height: 2px;
    background: linear-gradient(120deg, var(--accent), var(--gold));
    transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.nav-links a:hover { color: var(--text); }
.nav-links > li > a:hover::after { width: 100%; }

.nav-auth {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-sm {
    padding: 0.55rem 1.4rem;
    font-size: 0.9rem;
}

.nav-username {
    font-size: 0.9rem;
    color: var(--text-dim);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.nav-toggle span {
    width: 26px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Hamburger -> X animation */
.nav-toggle.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.active span:nth-child(2) { opacity: 0; }
.nav-toggle.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Hero ---------- */

.hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 1.5rem;
    background:
        radial-gradient(ellipse at 30% 15%, rgba(139, 0, 0, 0.35), transparent 55%),
        radial-gradient(ellipse at 75% 80%, rgba(255, 31, 61, 0.2), transparent 55%);
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: var(--hero-image, none);
    background-size: cover;
    background-position: center;
    opacity: 0.5;
    z-index: 0;
}

.hero-vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 35%, rgba(5, 3, 4, 0.9) 100%);
    z-index: 1;
}

/* ---------- Rune circle (decorazione hero) ---------- */

.hero-rune-circle {
    position: absolute;
    width: clamp(280px, 50vw, 550px);
    height: clamp(280px, 50vw, 550px);
    border: 1px solid rgba(255, 31, 61, 0.12);
    border-radius: 50%;
    z-index: 1;
    animation: rune-spin 90s linear infinite;
    pointer-events: none;
}

.hero-rune-circle::before,
.hero-rune-circle::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(212, 160, 23, 0.1);
}

.hero-rune-circle::before {
    inset: 15%;
    animation: rune-spin-reverse 60s linear infinite;
    border-style: dashed;
}

.hero-rune-circle::after {
    inset: 35%;
    border-color: rgba(255, 31, 61, 0.08);
    animation: rune-spin 45s linear infinite;
}

@keyframes rune-spin { to { transform: rotate(360deg); } }
@keyframes rune-spin-reverse { to { transform: rotate(-360deg); } }

/* ---------- Hero content animations ---------- */

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 780px;
}

/* Staggered entrance animations */
.hero-title {
    font-family: 'Almendra Display', 'Pirata One', cursive;
    font-size: clamp(3.5rem, 10vw, 6.5rem);
    letter-spacing: 0.05em;
    color: var(--accent);
    text-shadow: 0 0 40px rgba(255, 31, 61, 0.5), 0 0 90px rgba(139, 0, 0, 0.4);
    opacity: 0;
    animation: title-emerge 1.2s cubic-bezier(0.22, 1, 0.36, 1) 0.3s forwards,
               title-glow 3s ease-in-out 1.5s infinite;
}

@keyframes title-emerge {
    0%   { opacity: 0; transform: translateY(40px) scale(0.92); filter: blur(8px); }
    100% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

@keyframes title-glow {
    0%, 100% {
        text-shadow: 0 0 40px rgba(255, 31, 61, 0.5), 0 0 90px rgba(139, 0, 0, 0.4);
    }
    50% {
        text-shadow: 0 0 60px rgba(255, 31, 61, 0.7), 0 0 120px rgba(139, 0, 0, 0.55),
                     0 0 180px rgba(255, 31, 61, 0.15);
    }
}

.hero-subtitle {
    font-family: 'Almendra Display', 'Pirata One', cursive;
    font-size: clamp(1.5rem, 4vw, 2.25rem);
    color: var(--text);
    margin-top: 0.25rem;
    letter-spacing: 0.03em;
    opacity: 0;
    animation: subtitle-slide 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.9s forwards;
}

@keyframes subtitle-slide {
    0%   { opacity: 0; transform: translateY(20px); letter-spacing: 0.2em; }
    100% { opacity: 1; transform: translateY(0); letter-spacing: 0.03em; }
}

.hero-hook {
    margin-top: 1.5rem;
    font-size: 1.2rem;
    font-style: italic;
    color: var(--gold);
    opacity: 0;
    animation: hook-reveal 0.8s ease 1.4s forwards;
}

@keyframes hook-reveal {
    0%   { opacity: 0; transform: translateX(-15px); }
    100% { opacity: 0.9; transform: translateX(0); }
}

/* Typewriter cursor blink */
.hero-hook::after {
    content: '|';
    font-style: normal;
    color: var(--gold);
    animation: cursor-blink 0.7s step-end infinite;
    margin-left: 2px;
}

.hero-hook.typed::after {
    display: none;
}

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

.hero-desc {
    margin: 1.75rem auto 2.5rem;
    max-width: 620px;
    font-size: 1.1rem;
    line-height: 1.75;
    color: var(--text-dim);
    opacity: 0;
    animation: fade-up 0.8s ease 2s forwards;
}

@keyframes fade-up {
    0%   { opacity: 0; transform: translateY(18px); }
    100% { opacity: 1; transform: translateY(0); }
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    justify-content: center;
    opacity: 0;
    animation: fade-up 0.8s ease 2.4s forwards;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.95rem 2.1rem;
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    border-radius: 12px;
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
                box-shadow 0.3s ease,
                background 0.3s ease,
                color 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* Shine sweep on hover */
.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(
        120deg,
        transparent,
        rgba(255, 255, 255, 0.15),
        transparent
    );
    transition: left 0.5s ease;
}

.btn:hover::before {
    left: 120%;
}

.btn-primary {
    color: #fff;
    background: linear-gradient(45deg, var(--accent), var(--accent-2));
    border: 2px solid var(--accent);
    box-shadow: 0 10px 28px rgba(255, 31, 61, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(45deg, #fff, #ffd6d6);
    color: var(--accent-2);
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 16px 38px rgba(255, 31, 61, 0.4);
}

.btn-secondary {
    color: var(--text);
    background: rgba(23, 14, 17, 0.85);
    border: 1px solid rgba(212, 160, 23, 0.4);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn-secondary i {
    color: var(--gold);
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), color 0.3s ease;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, rgba(139, 0, 0, 0.55), rgba(212, 160, 23, 0.15));
    border-color: var(--gold);
    color: #fff;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(212, 160, 23, 0.3), 0 0 15px rgba(255, 31, 61, 0.15);
}

.btn-secondary:hover i {
    color: var(--accent);
    transform: rotate(90deg) scale(1.15);
}

/* ---------- Feature cards ---------- */

.features {
    position: relative;
    z-index: 1;
    padding: 5rem 1.5rem 6rem;
}

.features-grid {
    max-width: 1080px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.75rem;
}

.feature-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 2.25rem 2rem;
    background: rgba(23, 14, 17, 0.85);
    border: 1px solid rgba(255, 31, 61, 0.2);
    border-radius: 16px;
    text-decoration: none;
    color: var(--text);
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
                border-color 0.3s ease,
                box-shadow 0.4s ease;
    position: relative;
    overflow: hidden;

    /* Scroll-reveal initial state */
    opacity: 0;
    transform: translateY(50px);
}

/* Glow overlay on hover */
.feature-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(
        circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
        rgba(255, 31, 61, 0.12),
        transparent 60%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    border-radius: inherit;
}

.feature-card:hover::before { opacity: 1; }

.feature-card.revealed {
    animation: card-reveal 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes card-reveal {
    0%   { opacity: 0; transform: translateY(50px) scale(0.95); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.feature-card:hover {
    transform: translateY(-8px);
    border-color: var(--accent);
    box-shadow: 0 20px 50px rgba(139, 0, 0, 0.4), 0 0 30px rgba(255, 31, 61, 0.1);
}

.feature-icon {
    font-size: 2rem;
    color: var(--accent);
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), text-shadow 0.3s ease;
}

.feature-card:hover .feature-icon {
    transform: scale(1.2) rotate(-5deg);
    text-shadow: 0 0 20px rgba(255, 31, 61, 0.5);
}

.feature-title { font-family: 'Almendra Display', 'Pirata One', cursive; font-size: 1.5rem; letter-spacing: 0.02em; }

.feature-text { font-size: 0.98rem; color: var(--text-dim); line-height: 1.5; }

.feature-link {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--gold);
    transition: letter-spacing 0.3s ease, color 0.3s ease;
}

.feature-card:hover .feature-link {
    letter-spacing: 0.08em;
    color: #f0c030;
}

/* ---------- Footer ---------- */

.site-footer {
    position: relative;
    z-index: 1;
    padding: 2rem 1.5rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-dim);
    background: rgba(0, 0, 0, 0.5);
    border-top: 1px solid rgba(255, 31, 61, 0.15);

    /* Scroll-reveal */
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.site-footer.revealed {
    opacity: 1;
    transform: translateY(0);
}

.site-footer-domain { margin-top: 0.35rem; letter-spacing: 0.05em; }
.site-footer-domain a { color: var(--accent); text-decoration: none; }
.site-footer-domain a:hover { text-decoration: underline; }

.footer-legal {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1.25rem;
    margin-top: 1rem;
}

.footer-legal a {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.8rem;
    transition: color 0.2s ease;
}

.footer-legal a:hover { color: var(--text); text-decoration: underline; }

.footer-social {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.25rem;
}

.footer-social a {
    color: var(--text-dim);
    font-size: 1.1rem;
    transition: color 0.3s ease, transform 0.3s ease, text-shadow 0.3s ease;
}

.footer-social a:hover {
    color: var(--accent);
    transform: translateY(-3px) scale(1.15);
    text-shadow: 0 0 12px rgba(255, 31, 61, 0.4);
}

/* ---------- Scroll-reveal utility ---------- */

.scroll-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
    .features-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .navbar { padding: 0 1.25rem; }

    .nav-links {
        position: fixed;
        top: var(--nav-h);
        left: 0;
        width: 100%;
        flex-direction: column;
        gap: 0;
        background: rgba(10, 6, 8, 0.97);
        backdrop-filter: blur(10px);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    }

    .nav-links.open { max-height: 480px; }

    .nav-links > li > a {
        display: block;
        padding: 1rem 1.5rem;
        border-bottom: 1px solid rgba(255, 31, 61, 0.12);
    }

    .nav-auth {
        flex-wrap: wrap;
        justify-content: center;
        padding: 1.25rem 1.5rem;
    }

    .nav-username {
        width: 100%;
        justify-content: center;
        margin-bottom: 0.5rem;
    }

    .nav-auth a {
        flex: 1;
        justify-content: center;
        border-bottom: none;
    }

    .nav-toggle { display: flex; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
