/*
 * public/assets/css/article.css | Ultima modifica: 07/05/2026 | v1.0
 *
 * PURPOSE:
 *   Single article page styles.
 *   Covers: article header (title, meta, share), cover image,
 *   body typography, inline course box, tags, related articles grid.
 *
 * DEPENDS ON: base.css, layout.css, components.css
 *
 * CHANGELOG:
 *   - 07/05/2026 v1.0: initial implementation
 */

/* =============================================================================
   BLOCK: Article wrapper card
   White card containing the full article content.
   ============================================================================= */
.article-wrapper {
    background: var(--color-bg-card);
    border: 0.5px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

/* =============================================================================
   BLOCK: Article header
   Category pill + title + author/date/share row.
   ============================================================================= */
.article-header {
    margin-bottom: var(--space-md);
}

.article-header__category {
    margin-bottom: var(--space-sm);
}

.article-title {
    font-size: var(--font-size-2xl);
    font-weight: 600;
    line-height: var(--line-height-heading);
    color: var(--color-text-primary);
    margin-bottom: var(--space-md);
}

/* Row: author avatar + name/date on left, share buttons on right */
.article-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: var(--space-md);
    border-bottom: 0.5px solid var(--color-border-light);
    margin-bottom: var(--space-md);
}

.article-meta-row__author {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.article-meta-row__name {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-primary);
}

.article-read-count {
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    font-weight: 400;
    white-space: nowrap;
}

/* =============================================================================
   BLOCK: Article cover image
   Full-width image below the meta row.
   ============================================================================= */
.article-cover {
    width: 100%;
    height: 220px;
    object-fit: cover;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
}

/* Cover specifica: immagine intera, centrata nel riquadro (non ritagliata) */
.article-cover[src*="emigrazione-o-fuga-dei-cervelli"] {
    object-fit: contain;
    object-position: center;
    background: var(--color-bg-placeholder);
}

/* Placeholder when no cover image is set */
.article-cover-ph {
    width: 100%;
    height: 220px;
    background: var(--color-bg-placeholder);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-lg);
}

.article-cover-ph i {
    font-size: 42px;
    color: var(--color-text-muted);
}

.article-cover-ph .image-ph__icon {
    height: 48px;
    width: auto;
    opacity: .45;
}

/* =============================================================================
   BLOCK: Article body typography
   Long-form reading styles. Applied to the container that holds the
   HTML body content from the database.
   WARNING: $article['body'] is output directly (no escape) — it is
   set only by authenticated editors via the admin panel.
   ============================================================================= */
.article-body {
    font-size: var(--font-size-base);
    line-height: var(--line-height-body);
    color: var(--color-text-primary);
}

.article-body p {
    margin-bottom: var(--space-sm);
}

.article-body h2 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin: var(--space-lg) 0 var(--space-xs);
    color: var(--color-text-primary);
}

.article-body h3 {
    font-size: var(--font-size-md);
    font-weight: 600;
    margin: var(--space-md) 0 var(--space-xs);
    color: var(--color-text-primary);
}

.article-body ul,
.article-body ol {
    margin: var(--space-sm) 0 var(--space-sm) var(--space-lg);
    list-style: disc;
}

.article-body ol {
    list-style: decimal;
}

.article-body li {
    margin-bottom: var(--space-xs);
}

.article-body a {
    color: var(--color-accent);
    text-decoration: underline;
}

.article-body a:hover {
    color: var(--color-accent-dark);
}

.article-body blockquote {
    border-left: 3px solid var(--color-accent);
    padding-left: var(--space-md);
    margin: var(--space-md) 0;
    color: var(--color-text-secondary);
    font-style: italic;
}

.article-body strong {
    font-weight: 600;
    color: var(--color-text-primary);
}

/* -----------------------------------------------------------------------------
   Tables (GFM tables rendered by App\Services\MarkdownParser).
   Horizontal scroll on narrow viewports, header row with brand accent.
   ----------------------------------------------------------------------------- */
.article-body table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--space-md) 0;
    font-size: 0.95em;
    line-height: 1.5;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.article-body table thead {
    background: var(--color-accent-light, #E6F1FB);
}

.article-body table th {
    text-align: left;
    font-weight: 600;
    color: var(--color-accent-dark, #0C447C);
    padding: 0.6em 0.9em;
    border-bottom: 2px solid var(--color-accent, #185FA5);
    white-space: nowrap;
}

.article-body table td {
    padding: 0.55em 0.9em;
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: top;
}

.article-body table tbody tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.02);
}

.article-body table tbody tr:hover {
    background: var(--color-accent-light, #E6F1FB);
}

.article-body table code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.1em 0.35em;
    border-radius: 3px;
    font-size: 0.9em;
}

/* =============================================================================
   BLOCK: Article tags footer
   Tag pills row at the bottom of the article body.
   ============================================================================= */
.article-tags {
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 0.5px solid var(--color-border-light);
}

/* =============================================================================
   BLOCK: Related articles grid
   3-column grid below the article card.
   ============================================================================= */
.related-articles {
    margin-top: var(--space-md);
}

.related-articles__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-sm);
}

.related-articles__grid .article-card__image,
.related-articles__grid .article-card__image-ph {
    height: 90px;
    aspect-ratio: unset;
}

/* =============================================================================
   BLOCK: Article banner row
   Promotional / related content cards below the related articles block.
   ============================================================================= */
.article-promo-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-sm);
    margin-top: 24px;
    grid-column: 1 / -1;
}

.article-banner-card {
    background: var(--color-bg-card);
    border: 0.5px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    min-width: 0;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}

.article-banner-card__media {
    background: var(--color-bg-placeholder);
    width: 112px;
    min-width: 112px;
    flex-shrink: 0;
}

.article-banner-card__media img {
    width: 100%;
    display: block;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    height: 100%;
}

.article-banner-card__body {
    padding: var(--space-sm);
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.article-banner-card__label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-accent);
}

.article-banner-card__title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text-primary);
    line-height: 1.35;
    word-break: break-word;
}

.article-banner-card__text {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    line-height: 1.45;
}

.article-banner-card__cta {
    display: inline-flex;
    align-self: flex-start;
    margin-top: 2px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-accent-dark);
    background: var(--color-accent-light);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

@media (max-width: 700px) {
    .article-promo-strip {
        grid-template-columns: minmax(0, 1fr);
    }

    .article-banner-card {
        flex-direction: column;
    }

    .article-banner-card__media {
        width: 100%;
        min-width: 0;
    }

    .article-banner-card__media img {
        aspect-ratio: 16 / 9;
    }
}

/* =============================================================================
   BLOCK: Mobile article
   Keep long-form pages readable on portrait phones.
   ============================================================================= */
@media (max-width: 900px) {
    .related-articles__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .article-wrapper {
        padding: var(--space-md);
    }

    .article-title {
        font-size: var(--font-size-xl);
    }

    .article-meta-row {
        align-items: flex-start;
        flex-direction: column;
        gap: var(--space-sm);
    }

    .share-bar {
        width: 100%;
        flex-wrap: wrap;
    }

    .share-bar__btn {
        min-height: 34px;
    }

    .article-cover,
    .article-cover-ph {
        height: 170px;
    }

    .related-articles__grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .course-box--inline {
        align-items: flex-start;
        flex-direction: column;
    }

    .course-box--inline .course-box__btn {
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 520px) {
    .article-wrapper {
        border-radius: var(--radius-md);
        padding: var(--space-md) 10px;
    }

    .article-title {
        font-size: var(--font-size-lg);
    }

    .article-body {
        font-size: var(--font-size-base);
        line-height: 1.75;
    }

    .article-body ul,
    .article-body ol {
        margin-left: var(--space-md);
    }

    .article-cover,
    .article-cover-ph {
        height: 145px;
    }
}

/* =============================================================================
   BLOCK: Commenti
   Thread nidificato sotto l'articolo. Ogni livello di risposta e' rientrato
   e delimitato da una barra laterale: si vede a colpo d'occhio chi risponde
   a chi. Form unico in fondo (solo soci approvati).
   ============================================================================= */
.comments {
    margin-top: 28px;
}

.comments__empty {
    color: var(--color-text-muted);
}

.comment {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-light);
    border-radius: 8px;
    padding: 12px 14px;
    margin-top: 12px;
}

/* Risposta: rientro + barra laterale blu che "aggancia" al padre */
.comment--reply {
    margin-left: 22px;
    border-left: 3px solid var(--color-accent-border);
}

@media (max-width: 560px) {
    .comment--reply { margin-left: 12px; }
}

.comment__head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.comment__avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-accent-light);
    color: var(--color-accent);
    font-weight: 700;
    font-size: var(--font-size-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.comment__who {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.comment__username {
    color: var(--color-accent);
}

.comment__details {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

.comment__date {
    margin-left: auto;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    white-space: nowrap;
}

.comment__body {
    margin-top: 8px;
    line-height: var(--line-height-body);
    overflow-wrap: break-word;
}

.comment__removed {
    color: var(--color-text-muted);
    font-style: italic;
}

.comment__reply-btn {
    margin-top: 8px;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-accent);
    cursor: pointer;
}

.comment__reply-btn:hover { text-decoration: underline; }

/* --- Form commento ---------------------------------------------------------- */
.comment-form {
    margin-top: 18px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-light);
    border-radius: 8px;
    padding: 14px;
}

.comment-form label {
    display: block;
    font-weight: 600;
    font-size: var(--font-size-sm);
    margin-bottom: 6px;
}

.comment-form__quota {
    font-weight: 400;
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
}

.comment-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border-medium);
    border-radius: 6px;
    background: var(--color-bg-input);
    font: inherit;
    resize: vertical;
    margin-bottom: 10px;
}

.comment-form textarea:focus {
    outline: 2px solid var(--color-accent);
    border-color: var(--color-accent);
}

.comment-form__replying {
    background: var(--color-accent-light);
    border-radius: 6px;
    padding: 6px 10px;
    margin-bottom: 10px;
    font-size: var(--font-size-sm);
}

.comment-form__replying button {
    background: none;
    border: none;
    color: var(--color-accent);
    font: inherit;
    font-size: var(--font-size-xs);
    text-decoration: underline;
    cursor: pointer;
    margin-left: 8px;
}

/* Bottone submit: riusa lo stile dei form soci (definito in member.css ma
   qui serve standalone perche' article.css non carica member.css) */
.comment-form .member-form__submit {
    display: inline-block;
    padding: 10px 22px;
    background: var(--color-accent);
    color: var(--color-white);
    border: none;
    border-radius: 6px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.comment-form .member-form__submit:hover { background: var(--color-accent-dark); }

.comments__cta {
    margin-top: 16px;
    background: var(--color-accent-light);
    border: 1px solid var(--color-accent-border);
    border-radius: 8px;
    padding: 12px 14px;
}

.comments__cta p { margin: 0; }
