/* BD Members 1.3.19 */
.bdm, .bdm-modal {
	--bdm-bg: #ffffff;
	--bdm-surface: #f6f7f9;
	--bdm-text: #1f2328;
	--bdm-muted: #646b75;
	--bdm-border: #d9dde3;
	--bdm-input: #ffffff;
	--bdm-accent: #1e66f5;
	--bdm-accent-text: #ffffff;
	--bdm-ok-bg: #e8f6ee;
	--bdm-ok-text: #145c32;
	--bdm-err-bg: #fdecec;
	--bdm-err-text: #8a1c1c;
	--bdm-danger: #c62828;
	--bdm-radius: 10px;
}
.custom-dark .bdm, .custom-dark .bdm-modal, .custom-dark.bdm-modal {
	--bdm-bg: #1b1e23;
	--bdm-surface: #23272e;
	--bdm-text: #e7e9ec;
	--bdm-muted: #a2a9b3;
	--bdm-border: #3a404a;
	--bdm-input: #14171b;
	--bdm-accent: #5b8cff;
	--bdm-accent-text: #0d1117;
	--bdm-ok-bg: #12331f;
	--bdm-ok-text: #9ee2b5;
	--bdm-err-bg: #3a1717;
	--bdm-err-text: #ffb4b4;
	--bdm-danger: #ff6b6b;
}

.bdm { color: var(--bdm-text); font-size: 1rem; line-height: 1.5; }
.bdm *, .bdm *::before, .bdm *::after { box-sizing: border-box; }
.bdm-box { max-width: 460px; margin: 0 auto; }

/* Campi */
.bdm-form { margin: 0; }
.bdm-field { margin: 0 0 14px; }
.bdm-field label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 5px; color: var(--bdm-text); }
/* Le etichette restano sopra il campo, ferme: annulla effetti "etichetta flottante" o transizioni del tema. */
.bdm .bdm-field label, .bdm-modal .bdm-field label { position: static !important; inset: auto !important; transform: none !important; transition: none !important; float: none !important; }
.bdm .bdm-field input, .bdm-modal .bdm-field input, .bdm .bdm-field textarea, .bdm-modal .bdm-field textarea { transition: none !important; }
.bdm-field input, .bdm-field textarea, .bdm-dir-search input {
	width: 100%; padding: 10px 12px; font: inherit; color: var(--bdm-text);
	background: var(--bdm-input); border: 1px solid var(--bdm-border); border-radius: 8px; box-shadow: none;
}
.bdm-field input:focus, .bdm-field textarea:focus, .bdm-dir-search input:focus { outline: 2px solid var(--bdm-accent); outline-offset: 1px; border-color: var(--bdm-accent); }
.bdm-field input[aria-invalid="true"], .bdm-field textarea[aria-invalid="true"] { border-color: var(--bdm-danger); }
.bdm-field small, .bdm-photo-form small { display: block; color: var(--bdm-muted); font-size: .82rem; margin-top: 4px; }
.bdm-field-err { display: block; color: var(--bdm-danger) !important; font-size: .82rem; margin-top: 4px; }
.bdm-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.bdm-row--wrap { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
@media (max-width: 520px) { .bdm-row { grid-template-columns: 1fr; } }
.bdm-check { margin: 0 0 14px; font-size: .92rem; }
.bdm-check label { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.bdm-check input { margin-top: 4px; flex: none; }
.bdm-check a, .bdm-links a, .bdm a:not(.bdm-btn):not(.bdm-dir-card):not(.bdm-post-link):not(.bdm-social) { color: var(--bdm-accent); }
.bdm-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }
.bdm-pass { position: relative; display: block; }
.bdm-pass input { padding-right: 84px; }
.bdm-pass-toggle {
	position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
	background: transparent; border: 0; color: var(--bdm-accent); font: inherit; font-size: .85rem; padding: 6px 8px; cursor: pointer;
}
.bdm-meter { height: 4px; background: var(--bdm-border); border-radius: 4px; margin: -8px 0 14px; overflow: hidden; }
.bdm-meter span { display: block; height: 100%; width: 0; transition: width .2s, background .2s; }
.bdm-meter[data-level="0"] span, .bdm-meter[data-level="1"] span { width: 25%; background: #d93025; }
.bdm-meter[data-level="2"] span { width: 50%; background: #f29900; }
.bdm-meter[data-level="3"] span { width: 75%; background: #7cb342; }
.bdm-meter[data-level="4"] span { width: 100%; background: #1e8e3e; }
.bdm-captcha { margin: 0 0 14px; min-height: 65px; }
.bdm-intro { color: var(--bdm-muted); margin: 0 0 14px; }

/* Pulsanti */
.bdm-btn, .bdm .bdm-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	padding: 10px 18px; border-radius: 8px; border: 1px solid var(--bdm-accent);
	background: var(--bdm-accent); color: var(--bdm-accent-text); font: inherit; font-weight: 600;
	text-decoration: none; cursor: pointer; line-height: 1.2;
}
.bdm-btn:hover { filter: brightness(1.08); color: var(--bdm-accent-text); }
.bdm-btn--full { width: 100%; }
.bdm-btn--ghost, .bdm .bdm-btn--ghost { background: transparent; color: var(--bdm-accent); }
.bdm-btn--ghost:hover, .bdm .bdm-btn--ghost:hover { color: var(--bdm-accent); background: var(--bdm-surface); filter: none; }
.bdm-btn--danger, .bdm .bdm-btn--danger { background: var(--bdm-danger); border-color: var(--bdm-danger); color: #fff; }
.bdm-btn[disabled], .bdm-form.is-busy .bdm-btn { opacity: .6; cursor: wait; }
.bdm-file { position: relative; overflow: hidden; }
.bdm-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.bdm-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }

.bdm-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: .9rem; margin: 4px 0 0; }
.bdm-sep { display: flex; align-items: center; gap: 10px; color: var(--bdm-muted); font-size: .85rem; margin: 12px 0 16px; }
.bdm-sep::before, .bdm-sep::after { content: ""; flex: 1; height: 1px; background: var(--bdm-border); }
/* Spazio riservato al pulsante Google: arriva dopo e non deve spostare il resto del modulo. */
.bdm-social-login { display: flex; justify-content: center; align-items: center; min-height: 44px; }

/* Avvisi */
.bdm-notice { padding: 10px 14px; border-radius: 8px; margin: 0 0 14px; font-size: .95rem; }
.bdm-notice--ok { background: var(--bdm-ok-bg); color: var(--bdm-ok-text); }
.bdm-notice--err { background: var(--bdm-err-bg); color: var(--bdm-err-text); }
.bdm-notice a { color: inherit !important; font-weight: 600; text-decoration: underline; }

/* Popup */
html.bdm-modal-open { overflow: hidden; }
.bdm-modal { position: fixed; inset: 0; z-index: 100000; display: flex; align-items: flex-start; justify-content: center; padding: min(12vh, 110px) 16px 16px; }
.bdm-modal[hidden] { display: none; }
.bdm-modal-backdrop { position: absolute; inset: 0; background: rgba(10, 12, 16, .6); }
.bdm-modal-dialog {
	position: relative; width: 100%; max-width: 440px; max-height: calc(100vh - min(12vh, 110px) - 16px); overflow: auto; scrollbar-gutter: stable;
	background: var(--bdm-bg); color: var(--bdm-text); border-radius: 14px; padding: 26px 24px 20px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, .35); outline: none;
}
.bdm-modal-close {
	position: absolute; top: 8px; right: 10px; width: 36px; height: 36px; border: 0; border-radius: 50%;
	background: transparent; color: var(--bdm-muted); font-size: 26px; line-height: 1; cursor: pointer;
}
.bdm-modal-close:hover { background: var(--bdm-surface); color: var(--bdm-text); }
.bdm-modal-title { font-size: 1.3rem; margin: 0 0 16px; color: var(--bdm-text); }
.bdm-loading { display: flex; justify-content: center; padding: 48px 0; }
.bdm-loading::before { content: ""; width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--bdm-border, rgba(128,128,128,.35)); border-top-color: var(--bdm-accent, #1e66f5); animation: bdm-spin .7s linear infinite; }
@keyframes bdm-spin { to { transform: rotate(360deg); } }
.bdm-modal.is-busy .bdm-modal-body { opacity: .6; pointer-events: none; transition: opacity .15s; }
@media (prefers-reduced-motion: reduce) { .bdm-loading::before { animation-duration: 2s; } }
@media (max-width: 520px) {
	.bdm-modal { align-items: flex-end; padding: 0; }
	.bdm-modal-dialog { max-width: none; border-radius: 16px 16px 0 0; max-height: 92vh; }
}

/* Schede */
.bdm-tabs, .bdm-account-tabs { display: flex; gap: 4px; border: 0; box-shadow: inset 0 -1px 0 var(--bdm-border); margin: 0 0 18px; padding: 0; }
.bdm-tabs { overflow: visible; }
.bdm-account-tabs { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.bdm-account-tabs::-webkit-scrollbar { display: none; }
.bdm-modal-body .bdm-tabs { margin-right: 36px; }
.bdm-tab {
	background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; margin: 0; border-radius: 0; box-shadow: none;
	font: inherit; font-weight: 600; color: var(--bdm-muted) !important; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.bdm-tab.is-active { color: var(--bdm-text) !important; border-bottom-color: var(--bdm-accent); }

/* Profilo */
.bdm-profile { max-width: 1100px; margin: 0 auto; }
.bdm-profile-head { display: flex; gap: 24px; align-items: flex-start; padding: 24px; background: var(--bdm-surface); border-radius: var(--bdm-radius); margin-bottom: 28px; }
.bdm-avatar { border-radius: 50%; object-fit: cover; flex: none; background: var(--bdm-border); }
.bdm-profile-info { min-width: 0; flex: 1; }
.bdm-profile-name { margin: 0 0 4px; font-size: 1.7rem; line-height: 1.2; color: var(--bdm-text); }
.bdm-profile-meta { color: var(--bdm-muted); margin: 0 0 12px; font-size: .92rem; }
.bdm-profile-bio p { margin: 0 0 8px; }
.bdm-socials { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.bdm-social {
	display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%;
	background: var(--bdm-bg); color: var(--bdm-text); border: 1px solid var(--bdm-border); transition: color .15s, border-color .15s;
}
.bdm-social:hover { color: var(--bdm-accent); border-color: var(--bdm-accent); }
@media (max-width: 640px) {
	.bdm-profile-head { flex-direction: column; align-items: center; text-align: center; padding: 20px 16px; }
	.bdm-socials, .bdm-profile .bdm-actions { justify-content: center; }
}
.bdm-section-title { font-size: 1.3rem; margin: 0 0 16px; color: var(--bdm-text); }
.bdm-posts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.bdm-post { display: flex; }
.bdm-post-link { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; text-decoration: none; color: var(--bdm-text); background: var(--bdm-surface); border-radius: var(--bdm-radius); overflow: hidden; transition: transform .15s; }
.bdm-post-link:hover { transform: translateY(-2px); color: var(--bdm-text); }
.bdm-post-thumb { position: relative; display: block; flex: none; width: 100%; aspect-ratio: 1280 / 680; overflow: hidden; background: var(--bdm-border); }
.bdm-post-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: contain; display: block; } /* Riquadro uniforme 1280x680: l'immagine resta intera, mai ritagliata. */
.bdm-fit-riempi .bdm-post-thumb img { object-fit: cover; }
.bdm-fit-naturale .bdm-post-thumb { aspect-ratio: auto; overflow: visible; }
.bdm-fit-naturale .bdm-post-thumb img { position: static; height: auto; }
.bdm-post-body { display: flex; flex-direction: column; flex: 1 1 auto; gap: 6px; padding: 14px 16px 16px; }
.bdm-post-cat { color: var(--bdm-accent); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.bdm-post-title { font-weight: 700; line-height: 1.35; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--bdm-lines, 2); overflow: hidden; }
.bdm-posts-grid--full .bdm-post-title { display: block; -webkit-line-clamp: unset; overflow: visible; }
.bdm-post-excerpt { color: var(--bdm-muted); font-size: .92rem; line-height: 1.45; }
.bdm-post-meta { padding-top: 4px; color: var(--bdm-muted); font-size: .85rem; }
.bdm-post-meta:last-child { margin-top: auto; } /* La riga della data resta ancorata in fondo alla scheda. */
.bdm-more-wrap { text-align: center; margin: 24px 0 0; }
.bdm-more[hidden] { display: none; }
.bdm-post-date { color: var(--bdm-muted); font-size: .85rem; }
.bdm-pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 26px 0 0; color: var(--bdm-muted); }
.bdm-empty { color: var(--bdm-muted); }

/* Account */
.bdm-account { max-width: 760px; margin: 0 auto; }
.bdm-account-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.bdm-account-head .bdm-logout { margin-left: auto; }
.bdm-card { background: var(--bdm-surface); border-radius: var(--bdm-radius); padding: 20px; margin-bottom: 18px; }
.bdm-card h3 { margin: 0 0 14px; font-size: 1.1rem; color: var(--bdm-text); }
.bdm-card h4 { margin: 6px 0 10px; font-size: 1rem; color: var(--bdm-text); }
.bdm-card--danger { border: 1px solid var(--bdm-danger); }
.bdm-photo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.bdm-photo-row .bdm-form { margin: 0; }

/* Elenco utenti */
.bdm-dir-search { display: flex; gap: 8px; max-width: 520px; margin: 0 auto 22px; }
.bdm-dir-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.bdm-dir-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 20px 12px; text-align: center; background: var(--bdm-surface); border-radius: var(--bdm-radius); color: var(--bdm-text); text-decoration: none; }
.bdm-dir-card:hover { color: var(--bdm-accent); }
.bdm-dir-name { font-weight: 700; }
.bdm-dir-count { color: var(--bdm-muted); font-size: .85rem; }

/* Ritaglio foto */
.bdm-crop-stage { position: relative; width: 280px; max-width: 100%; aspect-ratio: 1; margin: 0 auto 16px; border-radius: 12px; overflow: hidden; background: var(--bdm-surface); touch-action: none; }
.bdm-crop-stage canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.bdm-crop-stage canvas:active { cursor: grabbing; }
.bdm-crop-ring { position: absolute; inset: 0; pointer-events: none; border-radius: 50%; box-shadow: 0 0 0 999px rgba(0, 0, 0, .45); }
.bdm-crop-zoom { width: 100%; }
.bdm-cropper .bdm-modal-dialog { text-align: left; }

/* Accedi con Google (BD Guard) */
.bdm-social-login { margin-bottom: 6px; }
.bdm-social-login .bdg-glogin { width: 100%; }
.bdm-social-login .bdg-glogin-or { color: var(--bdm-muted); }

.bdm-cropper--wide { max-width: 520px; }

/* Copertina */
.bdm-cover { margin: 0 0 -60px; border-radius: var(--bdm-radius) var(--bdm-radius) 0 0; overflow: hidden; background: var(--bdm-surface); }
.bdm-cover img { display: block; width: 100%; height: auto; }
.bdm-cover + .bdm-profile-head { position: relative; border-radius: 0 0 var(--bdm-radius) var(--bdm-radius); margin-top: 60px; padding-top: 0; background: transparent; }
.bdm-cover + .bdm-profile-head .bdm-avatar--xl { margin-top: -50px; border: 4px solid var(--bdm-bg); box-sizing: content-box; }
.bdm-cover + .bdm-profile-head .bdm-profile-info { padding-top: 16px; }
.bdm-cover-preview { display: block; width: 100%; max-width: 520px; height: auto; border-radius: 8px; margin: 0 0 12px; }

/* Campi personalizzati */
.bdm-field select { width: 100%; padding: 10px 12px; font: inherit; color: var(--bdm-text); background: var(--bdm-input); border: 1px solid var(--bdm-border); border-radius: 8px; }
.bdm-choices { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.bdm-choices legend { font-weight: 600; font-size: .92rem; margin-bottom: 6px; padding: 0; color: var(--bdm-text); }
.bdm-choices label { display: inline-flex; align-items: center; gap: 6px; margin: 0 16px 6px 0; font-weight: 400; cursor: pointer; }
.bdm-optional { font-weight: 400; color: var(--bdm-muted); }
.bdm-profile-fields { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 12px; font-size: .95rem; }
.bdm-pf-row { display: contents; }
.bdm-profile-fields dt { color: var(--bdm-muted); font-weight: 600; }
.bdm-profile-fields dd { margin: 0; }
@media (max-width: 640px) { .bdm-profile-fields { grid-template-columns: 1fr; text-align: center; } .bdm-profile-fields dd { margin-bottom: 6px; } }
.bdm-field label .bdm-optional, .bdm-choices legend .bdm-optional { display: inline; margin: 0; font-size: .85em; }

/* 1.1.2 campi obbligatori */
.bdm-req { color: var(--bdm-danger); font-weight: 700; margin-left: 2px; }
.bdm-req-note { margin: 0 0 12px; font-size: .8rem; color: var(--bdm-muted); }
.bdm-req-note span { color: var(--bdm-danger); font-weight: 700; }

/* Contenuto riservato (stili: minimal, callout, card) */
.bdm-gate { margin: 1.5em 0; color: var(--bdm-text); box-sizing: border-box; }
.bdm-gate *, .bdm-gate *::before, .bdm-gate *::after { box-sizing: border-box; }
.bdm-gate__icon { display: inline-flex; flex: none; color: var(--bdm-accent); }
.bdm-gate__body { min-width: 0; }
.bdm-gate__title { margin: 0 0 4px; font-weight: 700; font-size: 1.05rem; line-height: 1.3; color: var(--bdm-text); }
.bdm-gate__text { color: var(--bdm-muted); font-size: .97rem; line-height: 1.5; }
.bdm-gate__text > :first-child { margin-top: 0; }
.bdm-gate__text > :last-child { margin-bottom: 0; }
.bdm-gate .bdm-actions { margin-top: 14px; }

.bdm-gate--minimal { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--bdm-border); border-radius: var(--bdm-radius); background: transparent; }
.bdm-gate--minimal .bdm-gate__icon { color: var(--bdm-muted); margin-top: 1px; }
.bdm-gate--minimal .bdm-gate__title { font-size: 1rem; }
.bdm-gate--minimal .bdm-btn { padding: 6px 14px; font-size: .9rem; }

.bdm-gate--callout { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; background: var(--bdm-surface); border: 1px solid var(--bdm-border); border-left: 4px solid var(--bdm-accent); border-radius: 6px; }
.bdm-gate--callout .bdm-gate__icon { margin-top: 1px; }
.bdm-gate--callout .bdm-btn { padding: 7px 16px; font-size: .92rem; }

.bdm-gate--card { display: block; max-width: 480px; margin: 2em auto; padding: 28px 24px; text-align: center; background: var(--bdm-surface); border: 1px solid var(--bdm-border); border-radius: 16px; box-shadow: 0 6px 24px rgba(0, 0, 0, .06); }
.bdm-gate--card .bdm-gate__icon { width: 54px; height: 54px; border-radius: 50%; justify-content: center; align-items: center; margin-bottom: 14px; background: rgba(30, 102, 245, .12); background: color-mix(in srgb, var(--bdm-accent) 14%, transparent); }
.bdm-gate--card .bdm-gate__title { font-size: 1.2rem; margin-bottom: 6px; }
.bdm-gate--card .bdm-actions { justify-content: center; margin-top: 18px; }
@media (max-width: 480px) {
	.bdm-gate--card { padding: 22px 16px; }
	.bdm-gate--card .bdm-actions .bdm-btn { flex: 1 1 100%; }
}

/* Contenuto riservato: compatto, anche se il messaggio contiene titoli o blocchi grandi */
.bdm-gate { margin: 1em 0; }
.bdm-gate--minimal, .bdm-gate--callout { padding: 12px 14px; gap: 10px; }
.bdm-gate--card { max-width: 440px; margin: 1.2em auto; padding: 20px 18px; }
.bdm-gate--card .bdm-gate__icon { width: 44px; height: 44px; margin-bottom: 10px; }
.bdm-gate__title { font-size: 1rem; margin: 0 0 2px; }
.bdm-gate--card .bdm-gate__title { font-size: 1.1rem; }
.bdm-gate .bdm-actions { margin-top: 10px; }
.bdm-gate--card .bdm-actions { margin-top: 14px; }
.bdm-gate__text, .bdm-gate__text * { min-height: 0 !important; height: auto !important; }
.bdm-gate__text :is(h1, h2, h3, h4, h5, h6, p, div, ul, ol, blockquote, figure) {
	font-size: inherit !important; line-height: 1.45 !important; margin: 0 0 .4em !important; padding: 0 !important;
	font-family: inherit !important; text-align: inherit !important; max-width: none !important; color: inherit !important;
}
.bdm-gate__text :is(h1, h2, h3, h4, h5, h6) { font-weight: 600 !important; }
.bdm-gate__text > :last-child { margin-bottom: 0 !important; }
.bdm-gate__text img { max-width: 100%; max-height: 120px; width: auto; }
@media (max-width: 480px) {
	.bdm-gate--minimal, .bdm-gate--callout { padding: 10px 12px; }
	.bdm-gate--card { padding: 16px 14px; }
	.bdm-gate .bdm-btn { padding: 8px 14px; font-size: .9rem; }
}
