/* ==========================================================================
   CITTADINO DEL BORGO — VERSIONE DESKTOP OTTIMIZZATA
   ========================================================================= */

:root {
    --sky: #5B8FAE;
    --sea: #1B4965;
    --sea-ink: #14283A;
    --stone: #EFE6D3;
    --stone-dim: #DCCFAF;
    --terracotta: #C1622D;
    --terracotta-dark: #9C4C22;
    --gold: #B8873B;
    --gold-light: #D4AF6A;
    --wine: #6B1F2A;
    --ink: #22303B;
    --cream-text: #F3ECDC;
}

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

html, body {
    width: 100%;
    min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--cream-text);
    overflow-x: hidden;
    background-image:
        linear-gradient(rgba(10, 18, 26, 0.35), rgba(10, 18, 26, 0.35)),
        url('img/sfondocaccamo.jpeg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

/* ==========================================================================
   2. SFONDO
   Lo sfondo è applicato direttamente al body (vedi sezione 1) —
   niente più div/elementi separati da gestire qui.
   ========================================================================== */

/* ==========================================================================
   3. HEADER
   ========================================================================== */
.dashboard {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 75px;
    background: rgba(15, 25, 34, 0.92);
    border-bottom: 2px solid var(--gold);
    backdrop-filter: blur(18px) saturate(200%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    z-index: 9999;
    box-shadow: 0 2px 0 rgba(212, 175, 106, 0.25);
}

.dashboard .logo-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 1.5px;
    text-shadow: 0 0 6px rgba(184, 135, 59, 0.4);
    white-space: nowrap;
}

.nav-right-group {
    display: flex;
    align-items: center;
    gap: 20px;
}

.dashboard .home-btn {
    color: var(--cream-text);
    font-weight: 600;
    text-decoration: none;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    padding: 8px 20px;
    border-radius: 2px;
    background: rgba(20, 40, 58, 0.5);
    border: 1px solid rgba(184, 135, 59, 0.6);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s ease;
}

.dashboard .home-btn:hover {
    background: rgba(184, 135, 59, 0.15);
    border-color: var(--gold);
    color: var(--gold-light);
}

.lang-switcher {
    display: flex;
    gap: 6px;
    align-items: center;
}

.lang-switcher button {
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
    font-weight: bold;
    border-radius: 2px;
    background: rgba(20, 40, 58, 0.6);
    border: 1px solid rgba(184, 135, 59, 0.75);
    color: var(--gold);
    cursor: pointer;
    transition: all 0.25s ease;
}

.lang-switcher button:hover {
    background: rgba(184, 135, 59, 0.15);
}

.lang-switcher button.active {
    border: 2px solid #B8873B !important;
    background: rgba(184, 135, 59, 0.2) !important;
    font-weight: bold;
}

/* ==========================================================================
   4. INTRO
   ========================================================================== */
.citizen-frame-layout {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 125px 48px 0 48px;
    display: flex;
    justify-content: center;
    background: linear-gradient(180deg, rgba(10, 18, 26, 0.55) 0%, rgba(10, 18, 26, 0.15) 100%);
}

.citizen-intro-container {
    max-width: 620px;
    text-align: center;
}

.category-tag {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 2.5px;
    color: var(--gold-light);
    font-weight: 700;
    margin-bottom: 8px;
    display: inline-block;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.62);
}

.main-title {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-size: clamp(2.2rem, 4vw, 3rem);
    color: var(--cream-text);
    margin: 0 0 14px 0;
    font-weight: 600;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.72);
}

.gold-divider {
    border: none;
    height: 1px;
    background: var(--gold);
    width: 60px;
    margin: 0 auto 20px auto;
    position: relative;
}

.gold-divider::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 7px;
    height: 7px;
    background: var(--gold);
    transform: translate(-50%, -50%) rotate(45deg);
}

.text-paragraph {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: clamp(1.08rem, 2vw, 1.24rem);
    line-height: 1.7;
    color: #fff;
    margin: 0;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.62);
}

/* ==========================================================================
   5. GRIGLIA CARD
   ========================================================================== */
.citizen-centered-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(280px, 1fr));
    gap: 24px;
    width: 100%;
    max-width: 980px;
    margin: 38px auto 70px auto;
    padding: 0 40px 200px 40px;
}

.quadrant {
    position: relative;
    background: rgba(20, 40, 58, 0.68);
    border: 1px solid rgba(184, 135, 59, 0.62);
    border-radius: 8px;
    width: 100%;
    min-height: 132px;
    text-align: left;
    padding: 28px 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 0 18px rgba(184, 135, 59, 0.14);
    cursor: pointer;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

.quadrant:hover,
.quadrant:focus-visible {
    border-color: var(--gold);
    background: rgba(20, 40, 58, 0.82);
    box-shadow: 0 0 26px rgba(184, 135, 59, 0.35);
}

.card-text-block h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.75rem;
    color: var(--cream-text);
    margin-bottom: 10px;
}

.card-description {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.14rem;
    line-height: 1.55;
    color: var(--stone-dim);
    max-width: 92%;
}

/* ==========================================================================
   6. CASTELLANA
   ========================================================================== */
.castellana-video-wrapper {
    position: fixed;
    bottom: 0;
    right: 18px;
    width: 160px;
    z-index: 100;
    transition: transform 0.3s ease;
    cursor: pointer;
}

.castellana-video-wrapper:hover {
    transform: translateY(-4px);
}

.castellana-video {
    width: 100%;
    height: auto;
    max-height: 36vh;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.58));
}

.castellana-tooltip {
    position: absolute;
    top: -36px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 14px;
    background: rgba(20, 40, 58, 0.88);
    border: 1px solid var(--gold);
    border-radius: 4px;
    color: var(--gold);
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    z-index: 9999;
    transition: opacity 0.25s ease;
}

.castellana-video-wrapper:hover .castellana-tooltip {
    opacity: 1;
}

/* ==========================================================================
   7. CHAT — ACCANTO ALLA CASTELLANA
   Dimensioni raddoppiate (360x410 -> 720x820) e posizione alzata
   (bottom: 24px -> 200px) perché prima la finestra, aprendosi,
   copriva/tagliava la testa dell'avatar della Castellana: ora la
   chat si apre più in alto, lasciando l'avatar visibile sotto di sé.
   max-width/max-height di sicurezza per schermi più piccoli.
   ========================================================================== */
.chat-desktop {
    position: fixed;
    right: 40px;
    bottom: 200px;
    width: 440px;
    max-width: 88vw;
    height: 620px;
    max-height: 78vh;
    background: rgba(15, 25, 34, 0.97);
    backdrop-filter: blur(10px);
    border: 1px solid var(--gold);
    border-radius: 10px;
    padding: 16px;
    display: none;
    z-index: 999;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.52);
}

.chat-desktop::after {
    content: "";
    position: absolute;
    right: -12px;
    bottom: 62px;
    width: 0;
    height: 0;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-left: 12px solid var(--gold);
}

.chat-desktop.active {
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.28s ease forwards;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--cream-text);
    background: var(--sea-ink);
    margin: -16px -16px 15px -16px;
    padding: 12px 15px;
    border-radius: 10px 10px 0 0;
    border-bottom: 1px solid var(--gold);
}

.avatar-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #5FD068;
    box-shadow: 0 0 6px #5FD068;
}

.chat-header span {
    flex-grow: 1;
    font-weight: 600;
    font-size: 0.92rem;
}

.close-chat-btn {
    background: transparent;
    border: none;
    color: var(--cream-text);
    font-size: 1.1rem;
    cursor: pointer;
}

.close-chat-btn:hover {
    color: var(--gold-light);
}

.premium-status-bar {
    font-size: 0.72rem;
    font-weight: 600;
    text-align: center;
    padding: 4px 8px;
    margin: -6px 0 10px 0;
    border-radius: 4px;
    letter-spacing: 0.2px;
}

.premium-status-bar.premium-active {
    background: rgba(184, 135, 59, 0.18);
    color: var(--gold-light);
    border: 1px solid rgba(184, 135, 59, 0.4);
}

.premium-status-bar.premium-free {
    background: rgba(239, 230, 211, 0.08);
    color: var(--stone-dim, #cbbfa0);
    border: 1px solid rgba(239, 230, 211, 0.25);
}

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    margin-bottom: 10px;
    padding-right: 4px;
}

.chat-messages .message {
    color: var(--ink);
    font-size: 0.9rem;
    line-height: 1.5;
    background: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    max-width: 92%;
    border-left: 2px solid var(--gold);
}

.chat-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-input-row input {
    flex: 1;
    min-width: 0;
    padding: 11px 12px;
    border-radius: 6px;
    border: 1px solid rgba(184, 135, 59, 0.55);
    background: rgba(255, 255, 255, 0.96);
    color: var(--ink);
    font-size: 0.9rem;
    outline: none;
}

.chat-input-row input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(184, 135, 59, 0.18);
}

.send-btn {
    border: none;
    background: var(--terracotta);
    color: #fff;
    width: 42px;
    height: 42px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.25s ease, transform 0.2s ease;
}

.send-btn:hover {
    background: #a75027;
    transform: translateY(-1px);
}

.chat-link-btn {
    display: block;
    background: var(--terracotta);
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    margin-top: 8px;
    text-decoration: none;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
}

.chat-link-btn:hover {
    background: var(--terracotta-dark);
}

/* ==========================================================================
   7bis. MENU A PULSANTI DELLA CHAT (argomenti / gruppi)
   ========================================================================== */
.topic-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.topic-btn {
    border: 1px solid var(--gold);
    background: rgba(184, 135, 59, 0.14);
    color: var(--cream-text);
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.topic-btn:hover {
    background: rgba(184, 135, 59, 0.32);
}

.topic-group-btn {
    background: rgba(107, 31, 42, 0.35);
    border-color: var(--gold-light);
}

.chat-messages .message.user-msg {
    background: var(--sea);
    color: #fff;
    border-left: none;
    border-right: 2px solid var(--gold);
    margin-left: auto;
}

/* Bottone "ascolta" accanto ai messaggi della Castellana */
.audio-btn {
    background: rgba(184, 135, 59, 0.15);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
}

.audio-btn:hover {
    background: rgba(184, 135, 59, 0.35);
}

/* ==========================================================================
   8. ANIMAZIONE
   ========================================================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   9. RESPONSIVE TABLET
   ========================================================================== */
@media screen and (max-width: 1100px) {
    .citizen-frame-layout {
        padding: 120px 28px 0 28px;
    }

    .citizen-centered-grid {
        max-width: 900px;
        gap: 20px;
        padding: 0 28px 190px 28px;
    }

    .card-text-block h2 {
        font-size: 1.58rem;
    }

    .card-description {
        font-size: 1.05rem;
        max-width: 100%;
    }

    .chat-desktop {
        right: 24px;
        bottom: 180px;
        width: 380px;
        max-width: 90vw;
        height: 560px;
        max-height: 76vh;
    }

    .castellana-video-wrapper {
        width: 138px;
    }
}

/* ==========================================================================
   10. MOBILE
   Chat alzata (bottom: 110px -> 190px) per non coprire più la testa
   dell'avatar, che su mobile è più piccolo ma comunque presente sotto.
   ========================================================================== */
@media screen and (max-width: 900px) {
    .dashboard {
        height: auto;
        min-height: 75px;
        flex-direction: column;
        justify-content: center;
        gap: 10px;
        padding: 12px 16px;
    }

    .nav-right-group {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }

    .citizen-frame-layout {
        padding: 130px 20px 0 20px;
        text-align: center;
        justify-content: center;
    }

    .citizen-intro-container {
        max-width: 100%;
        text-align: center;
    }

    .gold-divider {
        margin: 0 auto 20px auto;
    }

    .citizen-centered-grid {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 0 16px 190px 16px;
        max-width: 100%;
        margin: 30px auto 40px auto;
    }

    .quadrant {
        padding: 24px 20px;
        text-align: center;
        min-height: auto;
    }

    .card-description {
        max-width: 100%;
    }

    .castellana-video-wrapper {
        width: 90px;
        right: 12px;
        bottom: 8px;
    }

    .castellana-video {
        max-height: none;
    }

    .chat-desktop {
        bottom: 190px;
        left: 10px;
        right: 10px;
        width: auto;
        height: 360px;
        max-height: 65vh;
    }

    .chat-desktop::after {
        display: none;
    }
}
