/*  ═══════════════════════════════════════════════════════
    AcusMagic — Blog Styles
    ═══════════════════════════════════════════════════════ */

.am-blog {
    padding-top: calc(var(--am-header-h) + 40px);
    min-height: 100vh;
}

.am-blog__header {
    text-align: center;
    margin-bottom: 48px;
}

.am-blog__header h1 { margin-bottom: 12px; }

.am-blog__header p {
    color: var(--am-text-muted);
    max-width: 600px;
    margin: 0 auto;
}

.am-blog__categories {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.am-blog__grid {
    display: grid;
    gap: 28px;
}

.am-blog__results {
    transition: opacity var(--am-duration) var(--am-ease), transform var(--am-duration) var(--am-ease);
}

.am-blog__results.is-loading {
    opacity: 0.35;
    transform: translateY(8px);
    pointer-events: none;
}

@media (max-width: 768px) {
    .am-blog__grid {
        grid-template-columns: 1fr !important;
    }
}

/* ─── Pagination ─── */
.am-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 48px;
    flex-wrap: wrap;
}

.am-pagination__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--am-text);
    background: var(--am-surface);
    border: 1px solid var(--am-surface-border);
    border-radius: var(--am-radius-sm);
    text-decoration: none;
    transition: all var(--am-duration) var(--am-ease);
}

.am-pagination__btn:hover {
    background: var(--am-surface-hover);
    border-color: var(--am-primary);
    color: var(--am-primary);
}

.am-pagination__btn--disabled {
    opacity: 0.35;
    pointer-events: none;
    cursor: default;
}

.am-pagination__pages {
    display: flex;
    align-items: center;
    gap: 4px;
}

.am-pagination__page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    font-size: 0.85rem;
    color: var(--am-text-muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--am-radius-sm);
    text-decoration: none;
    transition: all var(--am-duration) var(--am-ease);
}

.am-pagination__page:hover {
    color: var(--am-text);
    background: var(--am-surface);
    border-color: var(--am-surface-border);
}

.am-pagination__page--active {
    color: #fff;
    background: var(--am-primary);
    border-color: var(--am-primary);
    font-weight: 600;
}

.am-pagination__dots {
    color: var(--am-text-muted);
    padding: 0 4px;
    font-size: 0.9rem;
}

.am-pagination__info {
    text-align: center;
    margin-top: 12px;
    font-size: 0.8rem;
    color: var(--am-text-muted);
}

/* ─── Article Page ─── */
.am-article {
    padding-top: calc(var(--am-header-h) + 40px);
    min-height: 100vh;
}

.am-article__hero {
    position: relative;
    aspect-ratio: 21 / 9;
    max-height: 400px;
    overflow: hidden;
    border-radius: var(--am-radius-lg);
    margin-bottom: 40px;
}

.am-article__hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.am-article__hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 50%, var(--am-bg) 100%);
}

.am-article__meta {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    font-size: 0.85rem;
    color: var(--am-text-muted);
    flex-wrap: wrap;
}

.am-article__meta a {
    color: var(--am-primary);
}

/* ─── Riga superiore articolo: breadcrumb a sinistra, lingua a destra ─── */
.am-article__topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.am-article__topbar .am-breadcrumb {
    margin-bottom: 0;
    min-width: 0;               /* permette il troncamento del titolo lungo */
}
.am-breadcrumb__current {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 44ch;
}

/* Switcher lingua: controllo segmentato compatto (una sola unità visiva) */
.am-lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    margin-left: auto;          /* resta a destra anche quando va a capo */
    background: var(--am-surface);
    border: 1px solid var(--am-surface-border);
    border-radius: 999px;
    flex-shrink: 0;
}
.am-lang-switch__opt {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    line-height: 1;
    color: var(--am-text-muted);
    text-decoration: none;
    transition: color var(--am-duration) var(--am-ease),
                background var(--am-duration) var(--am-ease);
}
.am-lang-switch__opt:hover {
    color: var(--am-primary-light);
}
.am-lang-switch__opt[aria-current="page"] {
    color: var(--am-primary);
    background: rgba(201, 168, 76, 0.14);
    cursor: default;
}
.am-lang-switch__opt:focus-visible {
    outline: 2px solid var(--am-primary);
    outline-offset: 2px;
}
/* Variante centrata (header della listing, che è a testo centrato) */
.am-lang-switch--center {
    margin: 22px auto 0;
    display: flex;
    width: fit-content;
}

/* ─── Galleria immagini ([gallery] nel contenuto) ─── */
.am-gal {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 10px;
    margin: 32px 0;
}
.am-gal__cell {
    display: block;
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: var(--am-radius-sm);
    border: 1px solid var(--am-surface-border);
    background: var(--am-surface);
    cursor: zoom-in;
}
.am-gal__cell img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--am-duration) var(--am-ease), opacity var(--am-duration) var(--am-ease);
}
.am-gal__cell:hover img,
.am-gal__cell:focus-visible img { transform: scale(1.06); opacity: .88; }
.am-gal__cell:focus-visible { outline: 2px solid var(--am-primary); outline-offset: 3px; }

/* ─── Lightbox ─── */
/* Lock dello scroll: position:fixed regge anche su iOS, dove il solo
   overflow:hidden sul body non impedisce il rubber-band scrolling.
   Lo script salva e ripristina la posizione verticale. */
body.am-lb-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}
.am-lb {
    /* sopra il banner cookie (9999) e il FAB admin (10000), altrimenti restano
       cliccabili sopra il lightbox */
    position: fixed; inset: 0; z-index: 10050;
    display: flex; align-items: center; justify-content: center;
    background: rgba(6, 5, 8, 0.94);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    touch-action: none;
    overscroll-behavior: contain;
}
.am-lb[hidden] { display: none; }
.am-lb__stage {
    flex: 1; height: 100%;
    display: flex; align-items: center; justify-content: center;
    padding: 4vh 4vw 76px;
    overflow: hidden;
    touch-action: none;                 /* swipe e pan gestiti dallo script */
}
.am-lb__img {
    max-width: 100%; max-height: 100%;
    object-fit: contain;
    border-radius: var(--am-radius-sm);
    cursor: zoom-in;
    user-select: none; -webkit-user-drag: none;
}
.am-lb__img.is-zoomed { cursor: grab; }
.am-lb__stage.is-zoomed { cursor: grab; }
.am-lb__img:focus-visible { outline: 2px solid var(--am-primary); outline-offset: 4px; }
.am-lb__btn {
    position: absolute;
    display: inline-flex; align-items: center; justify-content: center;
    width: 46px; height: 46px;
    border-radius: 50%;
    border: 1px solid var(--am-surface-border);
    background: rgba(22, 19, 26, 0.82);
    color: var(--am-text);
    font-size: 1.5rem; line-height: 1;
    cursor: pointer;
    transition: color var(--am-duration) var(--am-ease), border-color var(--am-duration) var(--am-ease);
}
.am-lb__btn:hover { color: var(--am-primary); border-color: var(--am-primary); }
.am-lb__btn:focus-visible { outline: 2px solid var(--am-primary); outline-offset: 3px; }
.am-lb__close { top: 18px; right: 18px; font-size: 1.1rem; }
.am-lb__nav { top: 50%; transform: translateY(-50%); }
.am-lb__prev { left: 14px; }
.am-lb__next { right: 14px; }
.am-lb__nav[hidden] { display: none; }
.am-lb__bar {
    position: absolute; left: 0; right: 0; bottom: 0;
    display: flex; align-items: center; justify-content: center; gap: 14px;
    padding: 14px 68px;
    font-size: 0.8rem; color: var(--am-text-muted);
    text-align: center;
}
.am-lb__count { color: var(--am-primary); font-weight: 600; flex-shrink: 0; }
.am-lb__cap { max-width: 70ch; }
@media (max-width: 640px) {
    .am-gal { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 8px; }
    .am-lb__btn { width: 40px; height: 40px; }
    .am-lb__prev { left: 6px; } .am-lb__next { right: 6px; }
    .am-lb__stage { padding: 2vh 2vw 84px; }
    .am-lb__bar { flex-direction: column; gap: 4px; padding: 12px 20px; }
}
@media (prefers-reduced-motion: reduce) {
    .am-gal__cell img { transition: none; }
}
@media (max-width: 560px) {
    .am-breadcrumb__current { max-width: 14ch; }
}

.am-article__title {
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    margin-bottom: 32px;
    max-width: 720px;
}

.am-article__content {
    max-width: 720px;
}

/* ─── Rich content generato da AcusMagic Writer ─── */
.am-article__content hr {
    height: 1px;
    border: 0;
    margin: 48px 0;
    background: linear-gradient(90deg, transparent, rgba(201,168,76,.68), transparent);
}

.am-article__content table {
    display: block;
    width: 100%;
    margin: 32px 0;
    border-collapse: collapse;
    overflow-x: auto;
    font-size: .94rem;
}

.am-article__content th,
.am-article__content td {
    min-width: 110px;
    padding: 12px 14px;
    border: 1px solid var(--am-surface-border);
    vertical-align: top;
}

.am-article__content th {
    background: rgba(201,168,76,.09);
    color: var(--am-primary-light);
    text-align: left;
}

.am-article__content pre {
    margin: 28px 0;
    padding: 18px 20px;
    overflow-x: auto;
    border: 1px solid var(--am-surface-border);
    border-radius: var(--am-radius);
    background: #0d0d11;
    color: #ddd9e2;
    font: .86rem/1.65 var(--am-font-mono);
}

.am-media { margin: 36px 0; }
.am-media img { display: block; width: 100%; height: auto; margin: 0 !important; }
.am-media--normal { max-width: 620px; margin-inline: auto; }
.am-media--wide { width: min(900px, calc(100% + 180px)); margin-left: max(-90px, calc((100% - 900px) / 2)); }
.am-media--full { width: 100%; }
.am-media figcaption,
.am-gallery figcaption { margin-top: 9px; color: var(--am-text-muted); font-size: .8rem; text-align: center; font-style: italic; }

.am-gallery { display: grid; gap: 14px; margin: 38px 0; }
.am-gallery--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.am-gallery--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.am-gallery figure { margin: 0; }
.am-gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; margin: 0 !important; }

.am-spacer--sm { height: 24px; }
.am-spacer--md { height: 52px; }
.am-spacer--lg { height: 92px; }

.am-callout {
    margin: 34px 0;
    padding: 22px 24px;
    border: 1px solid rgba(201,168,76,.27);
    border-left: 3px solid var(--am-primary);
    border-radius: 0 var(--am-radius) var(--am-radius) 0;
    background: linear-gradient(135deg, rgba(201,168,76,.075), rgba(201,168,76,.02));
}
.am-callout h3 { margin: 0 0 8px; color: var(--am-primary-light); }
.am-callout p:last-child { margin-bottom: 0; }
.am-anchor-target { display: block; scroll-margin-top: calc(var(--am-header-h) + 24px); }

@media (max-width: 900px) {
    .am-media--wide { width: 100%; margin-left: 0; }
}

@media (max-width: 640px) {
    .am-gallery--2,
    .am-gallery--3 { grid-template-columns: 1fr; }
}

.am-article__tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--am-surface-border);
}

.am-article__share {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 32px;
    padding: 20px;
    background: var(--am-surface);
    border: 1px solid var(--am-surface-border);
    border-radius: var(--am-radius);
}

.am-article__share-label {
    font-size: 0.85rem;
    color: var(--am-text-muted);
    font-weight: 500;
}

.am-article__share a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(201, 168, 76, 0.08);
    color: var(--am-text-muted);
    transition: all var(--am-duration) var(--am-ease);
}

.am-article__share a:hover {
    background: var(--am-primary);
    color: white;
}

/* ─── Related Posts ─── */
.am-related {
    margin-top: 80px;
    padding-top: 48px;
    border-top: 1px solid var(--am-surface-border);
}

.am-related h2 {
    margin-bottom: 32px;
}

.am-related__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

@media (max-width: 768px) {
    .am-related__grid {
        grid-template-columns: 1fr;
    }
}

/* ─── Author Box ─── */
.am-author-box {
    display: flex;
    gap: 20px;
    padding: 28px;
    background: var(--am-surface);
    border: 1px solid var(--am-surface-border);
    border-radius: var(--am-radius-lg);
    margin-top: 48px;
}

.am-author-box__avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid var(--am-primary);
}

.am-author-box__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.am-author-box__name {
    font-family: var(--am-font-heading);
    font-size: 1rem;
    color: var(--am-text-heading);
    margin-bottom: 4px;
}

.am-author-box__bio {
    font-size: 0.85rem;
    color: var(--am-text-muted);
    line-height: 1.6;
    margin: 0;
}
