/* ----------------------------------------------------------------
	Canvas: Modern Blog — entry cards (estratto da demos/modern-blog,
	senza il layout split-screen che confligge con il sito)
-----------------------------------------------------------------*/

/* Video embed negli articoli: FitVids.js a volte calcola un'altezza errata
   (es. padding-top 18% → iframe schiacciato). Forziamo il 16:9 standard, ma
   se l'embed è già dentro un wrapper con aspect-ratio (es. Short dal pulsante)
   lasciamo che il wrapper di FitVids lo riempia rispettando quella proporzione. */
.mg-blog .fluid-width-video-wrapper {
    padding: 0 !important;
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
}
.mg-blog div[style*="aspect-ratio"] > .fluid-width-video-wrapper {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
}
.mg-blog .fluid-width-video-wrapper iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Combo "Scegli il tuo blog": larghezza piena della colonna (evita che eventuali
   regole del template Canvas su <select> la restringano). */
.mg-blog select[data-blog-select] {
    width: 100%;
    display: block;
}
/* Tabella articoli */
.mg-blog-table thead th { color: #14406e; border-bottom: 2px solid #dee2e6; white-space: nowrap; }
.mg-blog-table td a { color: #14406e; }
.mg-blog-table td a:hover { color: #A07828; }

.mg-blog .entry {
	background-color: #FFF;
	padding: 0;
	vertical-align: top;
	border-bottom: 0;
	border-radius: 4px;
	height: 100%;
	transform-origin: 50% 50% 0px;
	transition: all 250ms cubic-bezier(.02, .01, .5, 1);
}

.mg-blog .entry:hover {
	box-shadow: 0 10px 20px rgba(0,0,0,.08);
	transform: translate(0, -8px);
}

.mg-blog .entry-title,
.mg-blog .entry-meta,
.mg-blog .entry-content { padding: 0 20px; }

.mg-blog .entry-title h3 {
	font-size: 20px;
	line-height: 1.4;
	margin-bottom: 12px;
}

.mg-blog .entry-title a { color: #333; }
.mg-blog .entry-title a:hover { color: #A07828; }

.mg-blog .entry-content p {
	margin-bottom: 0;
	display: -webkit-box;
	-webkit-line-clamp: 4;
	-webkit-box-orient: vertical;
	overflow: hidden;
	text-overflow: ellipsis;
	font-size: 14px;
	line-height: 22px !important;
}

.mg-blog .entry-meta {
	font-size: 0.8125rem;
	text-transform: uppercase;
	border-top: 1px solid #E9EBEE;
	padding: 15px 0;
	margin: 15px 15px 0;
}

.mg-blog .entry-meta li {
	margin-left: 0;
	margin-right: 0;
}

.mg-blog .entry::after { display: none; }

.mg-blog .entry-meta li::before { content: none; }

.mg-blog .entry-meta.nohover,
.mg-blog .entry:hover .entry-meta.hover { display: block; }

.mg-blog .entry-meta.hover,
.mg-blog .entry:hover .entry-meta.nohover { display: none; }

/* Blocco categoria al posto dell'immagine (i contenuti non hanno foto) */
.mg-blog .entry-cat {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 130px;
	border-radius: 4px 4px 0 0;
	margin-bottom: 1rem;
	font-family: 'Cormorant Garamond', Georgia, serif;
	font-size: 1.9rem;
	font-weight: 700;
	letter-spacing: .06em;
	color: #fff;
	text-decoration: none;
}
.mg-blog .entry-cat small {
	display: block;
	font-family: 'Jost', system-ui, sans-serif;
	font-size: .68rem;
	font-weight: 600;
	letter-spacing: .2em;
	text-transform: uppercase;
	opacity: .65;
	text-align: center;
}
.mg-blog .entry-cat-0 { background: linear-gradient(135deg, #081D35, #14406e); }
.mg-blog .entry-cat-1 { background: linear-gradient(135deg, #0D2B4E, #2a6496); }
.mg-blog .entry-cat-2 { background: linear-gradient(135deg, #A07828, #C9A84C); }
.mg-blog .entry-cat-3 { background: linear-gradient(135deg, #1d3a2f, #2e6b50); }
.mg-blog .entry-cat-4 { background: linear-gradient(135deg, #4a1d35, #7e3a5e); }
.mg-blog .entry-cat-5 { background: linear-gradient(135deg, #33414a, #5c7585); }

/* Pagina dettaglio contenuto */
.mg-content-body {
	background: #fff;
	border-radius: 8px;
	padding: 2rem;
	box-shadow: 0 4px 16px rgba(0,0,0,.06);
	overflow-x: auto;
}
.mg-content-body pre {
	background: #0D2B4E;
	color: #e8eef5;
	padding: 1rem 1.25rem;
	border-radius: 6px;
	overflow-x: auto;
	font-size: .85rem;
}
.mg-content-body .dp-highlighter {
	background: #f4f6f9;
	border-left: 3px solid #C9A84C;
	padding: .75rem 1rem;
	border-radius: 4px;
	overflow-x: auto;
	font-family: Consolas, Monaco, monospace;
	font-size: .85rem;
}
.mg-content-body .dp-highlighter ol { margin: 0; padding-left: 2.2rem; }
.mg-content-body .dp-highlighter .keyword { color: #0D5BD7; font-weight: 600; }
.mg-content-body .dp-highlighter .string { color: #B02A37; }
.mg-content-body .dp-highlighter .comment { color: #6c757d; font-style: italic; }

/* Carousel citazioni (/sentences) */
.mg-sentences-slider { box-shadow: 0 12px 40px rgba(8,29,53,.15); border-radius: 10px; overflow: hidden; }

/* Navigazione pagine (Precedente / Successivo) sopra e sotto il carousel */
.mg-page-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.mg-page-btn {
    display: inline-block;
    font-family: 'Jost', system-ui, sans-serif;
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #0D2B4E;
    background: #fff;
    border: 1px solid rgba(13,43,78,.2);
    border-radius: 999px;
    padding: .5rem 1.2rem;
    text-decoration: none;
    transition: background .2s, color .2s, border-color .2s;
}
.mg-page-btn:hover { background: #C9A84C; border-color: #C9A84C; color: #0D2B4E; }
.mg-page-btn.disabled,
.mg-page-btn:disabled { opacity: .4; pointer-events: none; cursor: default; }
.mg-page-info {
    font-family: 'Jost', system-ui, sans-serif;
    font-size: .82rem;
    color: #607176;
    min-width: 120px;
    text-align: center;
}

/* ── Schema semantico della slide: <sentence><title><author><image><HtmlText><tags> ── */
.mg-sentences-slider sentence {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    min-height: 460px;
    padding: 2.75rem 2rem;
    text-align: center;
    color: #1d2b2f;
    background: #fff;
}
.mg-sentences-slider sentence > title {
    display: block;                 /* override del display:none di default per <title> nel body */
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: clamp(1.4rem, 2.6vw, 2.1rem);
    font-weight: 600;
    font-style: italic;
    line-height: 1.4;
    color: #14406e;
}
.mg-sentences-slider sentence > author {
    display: block;
    font-family: 'Jost', system-ui, sans-serif;
    font-size: .95rem;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #C9A84C;
}
.mg-sentences-slider sentence > .mg-sentence-image {
    display: block;
    /* altezza fissa: riserva lo spazio anche prima del caricamento, così l'altezza
       della slide è deterministica e FlexSlider non taglia il contenuto sotto. */
    height: 300px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.mg-sentences-slider sentence > .mg-sentence-image[visible="false"] { display: none; }
.mg-sentences-slider sentence > .mg-sentence-image { cursor: zoom-in; }

.mg-sentences-slider sentence > .mg-sentence-video {
    display: block;
    width: 100%;
    max-width: 720px;
    max-height: 420px;
    margin: 0 auto;
    background: #000;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
}

/* Lightbox immagine a tutto schermo (click o ESC per chiudere) */
.mg-lightbox {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: rgba(8,29,53,.93);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    cursor: zoom-out;
}
.mg-lightbox img,
.mg-lightbox video {
    max-width: 96vw;
    max-height: 92vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.mg-lightbox-close {
    position: fixed;
    top: .75rem;
    right: 1.5rem;
    color: #fff;
    font-size: 2.6rem;
    line-height: 1;
    cursor: pointer;
    opacity: .85;
}
.mg-lightbox-close:hover { opacity: 1; }
.mg-sentences-slider sentence > htmltext {
    display: block;
    /* La card è flex column con align-items:center: senza una larghezza esplicita
       htmltext si restringe al contenuto e gli embed con width:100% collassano a 0
       (il video non parte perché l'iframe è 0×0). Forziamo la larghezza piena. */
    width: 100%;
    align-self: stretch;
    max-width: 680px;
    margin-left: auto;
    margin-right: auto;
    text-align: left;
    font-family: 'Jost', system-ui, sans-serif;
    font-size: .95rem;
    line-height: 1.7;
    color: #3a464c;
}
.mg-sentences-slider sentence > htmltext p { margin: 0 0 .6rem; }
.mg-sentences-slider sentence > htmltext a { color: #A07828; }
.mg-sentences-slider sentence > htmltext h2,
.mg-sentences-slider sentence > htmltext h3 { color: #14406e; font-family: 'Cormorant Garamond', Georgia, serif; }
.mg-sentences-slider sentence > htmltext pre,
.mg-sentences-slider sentence > htmltext code {
    background: #f0f3f7; color: #0D2B4E; border-radius: 4px; padding: .1rem .35rem;
}
.mg-sentences-slider sentence > htmltext pre { padding: .75rem 1rem; overflow-x: auto; }
.mg-sentences-slider sentence > htmltext img { max-width: 100%; height: auto; border-radius: 6px; }
.mg-sentences-slider sentence > htmltext iframe { max-width: 100%; }
/* embed video (iframe in wrapper responsivo) centrati */
.mg-sentences-slider sentence > htmltext > div { margin-left: auto; margin-right: auto; }
/* FitVids.js (plugin Canvas) avvolge gli iframe in .fluid-width-video-wrapper e ne
   calcola l'altezza via padding-top dagli attributi width/height: i nostri embed
   non li hanno, così FitVids imposta altezza 0 e il video collassa (non parte).
   Il nostro wrapper con aspect-ratio gestisce già la proporzione: qui annulliamo
   il sizing di FitVids facendo riempire al suo wrapper il box con aspect-ratio. */
.mg-sentences-slider sentence > htmltext div[style*="aspect-ratio"] > .fluid-width-video-wrapper {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0 !important;
}
.mg-sentences-slider sentence > tags {
    display: block;
    font-size: .78rem;
    letter-spacing: .05em;
    color: #8a969c;
}

.mg-sentence-slide {
    position: relative;
    min-height: 460px;
    display: flex;
    overflow: hidden;
    /* Sfondo navy: visibile dietro le foto verticali (letterbox) e quando manca l'immagine */
    background: linear-gradient(135deg, #081D35 0%, #0D2B4E 60%, #14406e 100%);
}

/* Immagine reale: l'orientamento decide come viene mostrata (classi aggiunte via JS) */
.mg-sentence-img { display: block; }

/* ── Landscape (default): foto a tutto campo, testo sovrapposto ── */
.mg-sentence-slide.orient-landscape .mg-sentence-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.mg-sentence-slide.orient-landscape .mg-sentence-overlay {
    position: relative;
    width: 100%;
    background: linear-gradient(0deg, rgba(8,29,53,.78), rgba(8,29,53,.55));
}

/* ── Portrait: foto intera (no taglio) affiancata al testo ── */
.mg-sentence-slide.orient-portrait { flex-direction: row; }
.mg-sentence-slide.orient-portrait .mg-sentence-img {
    position: relative;
    width: 42%;
    height: auto;
    max-height: 520px;
    object-fit: contain;
    align-self: center;
    flex-shrink: 0;
}
.mg-sentence-slide.orient-portrait .mg-sentence-overlay {
    position: relative;
    width: 58%;
    background: transparent;
}

/* ── Quasi quadrata: foto intera (contain) centrata a tutta larghezza, testo sovrapposto ── */
.mg-sentence-slide.orient-square .mg-sentence-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.mg-sentence-slide.orient-square .mg-sentence-overlay {
    position: relative;
    width: 100%;
    background: linear-gradient(0deg, rgba(8,29,53,.55), rgba(8,29,53,.30));
}

/* ── Immagine + HTML: foto come banner in alto, citazione e testo HTML sotto ── */
.mg-sentence-slide.mg-sentence-stacked { flex-direction: column; min-height: 0; }
.mg-sentence-slide.mg-sentence-stacked .mg-sentence-img {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    max-height: 340px;
    object-fit: cover;
}
.mg-sentence-slide.mg-sentence-stacked .mg-sentence-overlay {
    position: relative;
    width: 100%;
    background: transparent;
}

/* Prima che il JS classifichi l'immagine: la nascondiamo per evitare un flash a piena larghezza
   (le slide "stacked" sono già pronte lato server, quindi escluse) */
.mg-sentence-slide:not(.orient-landscape):not(.orient-portrait):not(.orient-square):not(.mg-sentence-stacked) .mg-sentence-img { visibility: hidden; }

.mg-sentence-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
}
.mg-sentence-inner {
    max-width: 760px;
    text-align: center;
    color: #fff;
}

/* Su mobile il portrait torna impilato */
@media (max-width: 768px) {
    .mg-sentence-slide.orient-portrait { flex-direction: column; }
    .mg-sentence-slide.orient-portrait .mg-sentence-img { width: 100%; max-height: 260px; }
    .mg-sentence-slide.orient-portrait .mg-sentence-overlay { width: 100%; }
}
.mg-sentence-quote-mark {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 5rem;
    line-height: .6;
    color: #C9A84C;
    margin-bottom: 1rem;
}
.mg-sentence-text {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: clamp(1.4rem, 2.6vw, 2.1rem);
    font-weight: 600;
    font-style: italic;
    line-height: 1.4;
    color: #fff;
    border: none;
    padding: 0;
    margin: 0 0 1.5rem;
}
.mg-sentence-author {
    font-family: 'Jost', system-ui, sans-serif;
    font-size: .95rem;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #C9A84C;
}
.mg-sentence-tags {
    margin-top: .75rem;
    font-size: .78rem;
    letter-spacing: .05em;
    color: rgba(255,255,255,.55);
}

/* Testo HTML mostrato nelle slide senza immagine (default) */
.mg-sentence-html {
    margin: 1rem auto 1.25rem;
    max-width: 680px;
    font-family: 'Jost', system-ui, sans-serif;
    font-size: .95rem;
    line-height: 1.7;
    color: rgba(255,255,255,.82);
    text-align: left;
}
.mg-sentence-html p { margin: 0 0 .6rem; }
.mg-sentence-html a { color: #C9A84C; }
.mg-sentence-html h2, .mg-sentence-html h3 { color: #fff; font-family: 'Cormorant Garamond', Georgia, serif; }
.mg-sentence-html pre, .mg-sentence-html code {
    background: rgba(255,255,255,.1);
    color: #e8eef5;
    border-radius: 4px;
    padding: .1rem .35rem;
}
.mg-sentence-html pre { padding: .75rem 1rem; overflow-x: auto; }
.mg-sentence-html img { max-width: 100%; height: auto; border-radius: 6px; }

/* ── Galleria media pubblica (/media) ───────────────────────────────────── */
.mg-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
}
.mg-gallery-item {
    margin: 0;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 18px rgba(8,29,53,.08);
    display: flex;
    flex-direction: column;
    transition: transform .2s ease, box-shadow .2s ease;
}
.mg-gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 28px rgba(8,29,53,.16);
}
.mg-gallery-img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    display: block;
    background: #f1f4f8;
    cursor: zoom-in;
}
.mg-gallery-file {
    height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    background: #f1f4f8;
    text-decoration: none;
    color: #14406e;
}
.mg-gallery-file-icon { font-size: 3rem; }
.mg-gallery-file-name { font-size: .85rem; padding: 0 .75rem; text-align: center; }
.mg-gallery-caption {
    padding: .75rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .25rem;
}
.mg-gallery-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 700;
    color: #14406e;
    font-size: 1.1rem;
}
.mg-gallery-desc {
    font-size: .85rem;
    line-height: 1.5;
    color: #5a6b80;
}

/* Pulsanti di condivisione citazione (/sentences) */
.mg-share { }
.mg-share-label {
    display: block;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: #8a98a8;
    margin-bottom: .6rem;
}
.mg-share-btns {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    justify-content: center;
    align-items: center;
}
.mg-share-btn {
    border: 1px solid #d4dbe3;
    background: #fff;
    color: #14406e;
    border-radius: 999px;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, border-color .15s ease, transform .15s ease;
}
.mg-share-btn:hover { transform: translateY(-2px); color: #fff; }
.mg-share-btn.mg-share-cp {
    width: auto;
    padding: 0 1rem;
    gap: .4rem;
    font-size: .9rem;
}
.mg-share-fb:hover { background: #1877f2; border-color: #1877f2; }
.mg-share-x:hover  { background: #000;     border-color: #000; }
.mg-share-wa:hover { background: #25d366;  border-color: #25d366; }
.mg-share-tg:hover { background: #229ed9;  border-color: #229ed9; }
.mg-share-em:hover { background: #14406e;  border-color: #14406e; }
.mg-share-cp:hover { background: #C9A84C;  border-color: #C9A84C; }
.mg-share-btn.mg-share-copied { background: #25d366; border-color: #25d366; color: #fff; }

/* Galleria foto stile Canvas (flex-thumb-grid) negli articoli: l'immagine grande
   è cliccabile per aprirla a tutto schermo (lightbox). */
.mg-photo-gallery .entry img { cursor: zoom-in; }

/* Miniatura video nella galleria: primo fotogramma + badge play */
.mg-gallery-vid {
    position: relative;
    height: 220px;
    background: #0b1f38;
    cursor: pointer;
    overflow: hidden;
}
.mg-gallery-vid .mg-gallery-img {
    height: 220px;
    cursor: pointer;
    pointer-events: none;
}
.mg-gallery-vid-playing .mg-gallery-img { pointer-events: auto; }
.mg-gallery-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(8,29,53,.55);
    color: #fff;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 4px;
    pointer-events: none;
    transition: background .2s ease, transform .2s ease;
}
.mg-gallery-vid:hover .mg-gallery-play {
    background: #C9A84C;
    transform: translate(-50%, -50%) scale(1.08);
}
.mg-gallery-vid-playing .mg-gallery-play { display: none; }

/* Video YouTube in home: se FitVids avvolge l'iframe, fagli riempire il box 16:9 */
.mg-home-video > .fluid-width-video-wrapper {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0 !important;
}
.mg-home-video iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; }

/* Facade YouTube: copertina + tasto play (il player si carica al click) */
.mg-yt-facade { overflow: hidden; }
.mg-yt-facade .mg-yt-play {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 68px; height: 48px;
    border-radius: 12px;
    background: rgba(18,18,18,.75);
    display: flex; align-items: center; justify-content: center;
    transition: background .2s ease;
}
.mg-yt-facade .mg-yt-play::after {
    content: "";
    border-style: solid;
    border-width: 11px 0 11px 19px;
    border-color: transparent transparent transparent #fff;
    margin-left: 3px;
}
.mg-yt-facade:hover .mg-yt-play { background: #ff0000; }

/* Messaggio "accedi" sotto i video YouTube/Facebook */
.mg-video-note {
    text-align: center;
    font-size: .8rem;
    color: #8a98a8;
    margin: .4rem auto 0;
    max-width: 760px;
}
.mg-video-note a { color: #14406e; font-weight: 600; text-decoration: underline; }
.mg-video-note a:hover { color: #A07828; }
