/* ============================================================
 * feed.css - Stili per la home/feed degli attacchi.
 * Layout: lista verticale di "card attacco" 
 *
 * @author Giannino
 * ============================================================ */

/* Header del feed con tab "Per te" / "Più popolari" */
.feed-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}
.feed-tab {
    flex: 1;
    padding: 16px;
    text-align: center;
    background: none;
    border: none;
    color: var(--text-muted);
    font-weight: 700;
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
    position: relative;
}
.feed-tab:hover { background: var(--surface-2); color: var(--text); }
.feed-tab.active { color: var(--text-strong); }
.feed-tab.active::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 56px;
    height: 4px;
    background: var(--accent);
    border-radius: 2px;
}

/* Card singolo attacco */
.attack-card {
    display: flex;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    transition: background var(--t-fast);
    cursor: pointer;
}
.attack-card:hover { background: rgba(255, 255, 255, 0.02); }

.attack-card__avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--surface-3);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-weight: 800;
    overflow: hidden;
}
.attack-card__avatar img {
    width: 100%; height: 100%; object-fit: cover;
}

.attack-card__body {
    flex: 1;
    min-width: 0;
}

.attack-card__head {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.attack-card__author {
    font-weight: 700;
    color: var(--text-strong);
}
.attack-card__handle,
.attack-card__time {
    color: var(--text-muted);
    font-size: 0.9rem;
}
.attack-card__sep {
    color: var(--text-muted);
}
.attack-card__badge {
    background: var(--accent-soft);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: var(--r-pill);
    font-size: 0.75rem;
    font-weight: 700;
    margin-left: auto;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.attack-card__title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-strong);
    margin-bottom: 4px;
}
.attack-card__desc {
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1.45;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Meta info: difficoltà, tempo */
.attack-card__meta {
    display: flex;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.attack-card__meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Barra azioni: like, segnalazione, condividi, simula */
.attack-card__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 480px;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: var(--r-pill);
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
    background: none;
    border: none;
}
.action-btn svg { width: 18px; height: 18px; }

.action-btn:hover { background: var(--surface-2); color: var(--text); }

.action-btn.like:hover { color: var(--danger); background: var(--danger-soft); }
.action-btn.like.liked { color: var(--danger); }
.action-btn.like.liked svg { fill: currentColor; }

.action-btn.report:hover { color: var(--warning); background: rgba(255, 173, 31, 0.12); }

.action-btn.simulate:hover { color: var(--accent); background: var(--accent-soft); }

/* "Componi" composer in cima al feed (per chi può creare attacchi) */
.composer {
    display: flex;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}
.composer__avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    flex-shrink: 0;
}
.composer__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.composer__hint {
    color: var(--text-muted);
    font-size: 1.1rem;
    padding: 12px 0;
    cursor: pointer;
}
.composer__hint:hover { color: var(--text); }
.composer__actions {
    display: flex;
    justify-content: flex-end;
}

/* Skeleton loader (mostrato mentre carica il feed) */
.skeleton-card {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 12px;
}
.skel-avatar, .skel-line {
    background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
    background-size: 200% 100%;
    animation: skel-shimmer 1.4s ease-in-out infinite;
    border-radius: var(--r-md);
}
.skel-avatar { width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; }
.skel-line   { height: 12px; margin-bottom: 8px; }
.skel-line.short { width: 40%; }
.skel-line.long  { width: 100%; }

@keyframes skel-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Mobile */
@media (max-width: 720px) {
    .attack-card { padding: 12px; }
    .attack-card__avatar { width: 40px; height: 40px; }
}

/* ---- Commenti -------------------------------------------------------- */
.action-btn.comment.active {
    color: var(--accent);
}
.action-btn.comment.active svg {
    fill: rgba(0, 212, 255, 0.2);
    stroke: var(--accent);
}
.comment-count {
    font-variant-numeric: tabular-nums;
}

.attack-card__comments {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    animation: fade-in-down 0.2s ease;
}
@keyframes fade-in-down {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Lista commenti */
.comments-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 4px;
}
.comments-list::-webkit-scrollbar { width: 4px; }
.comments-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.comments-empty {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 12px 0;
    margin: 0;
    font-style: italic;
}

/* Singolo commento */
.comment-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    position: relative;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.comment-item__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--accent);
    flex-shrink: 0;
    font-family: var(--font-mono);
}
.comment-item__body {
    flex: 1;
    min-width: 0;
}
.comment-item__author {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    font-family: var(--font-mono);
}
.comment-item__time {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 8px;
}
.comment-item__text {
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--text);
    line-height: 1.5;
    word-break: break-word;
}
.comment-item__delete {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
}
.comment-item__delete:hover {
    color: var(--danger);
    background: rgba(244, 33, 46, 0.1);
}

/* Form nuovo commento */
.comments-form {
    display: flex;
    gap: 8px;
    align-items: center;
}
.comments-input {
    flex: 1;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 13px;
    color: var(--text);
    font-family: inherit;
    transition: border-color 0.15s;
    min-width: 0;
}
.comments-input:focus {
    outline: none;
    border-color: var(--accent);
}
.comments-input::placeholder { color: var(--text-muted); }
.comments-submit {
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    transition: filter 0.15s;
    font-family: inherit;
}
.comments-submit:hover { filter: brightness(1.1); }
.comments-submit:disabled { opacity: 0.5; cursor: not-allowed; }
/* ── Pulsante elimina — solo icona, tooltip "Elimina" sull'hover ── */
.action-btn--delete {
    position: relative;
}
.action-btn--delete span.del-label {
    display: none;
}
.action-btn--delete::after {
    content: 'Elimina';
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    font-family: var(--font-mono);
}
.action-btn--delete:hover::after {
    opacity: 1;
}

/* ── Feed mobile piccolo (< 480px) ── */
@media (max-width: 480px) {

    /* Card padding ridotto */
    .attack-card {
        padding: 10px 12px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    /* Avatar più piccolo */
    .attack-card__avatar {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    /* Titolo */
    .attack-card__title {
        font-size: 0.95rem;
    }

    /* Body */
    .attack-card__body {
        font-size: 0.85rem;
    }

    /* Action buttons: su mobile mostra solo icone, nascondi testo */
    .attack-card__actions {
        gap: 2px;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .attack-card__actions::-webkit-scrollbar { display: none; }

    .action-btn {
        padding: 6px 8px;
        font-size: 0.75rem;
        min-width: 36px;
        flex-shrink: 0;
    }
    .action-btn span {
        display: none; /* nascondi testo, mostra solo icona */
    }
    .action-btn .like-count,
    .action-btn .comment-count {
        display: inline; /* ma mostra i contatori */
        font-size: 0.75rem;
    }

    /* Composer */
    .composer {
        padding: 10px 12px;
    }
    .composer__input {
        font-size: 0.9rem;
    }

    /* Code viewer modal */
    #code-modal > div {
        max-height: 95vh;
        border-radius: 12px 12px 0 0;
        margin-top: auto;
    }
}
