/* ==========================================================================
   Radiolog Lightbox — base: token, reset, componenti condivisi
   ========================================================================== */

:root {
	/* Brand */
	--rl-brand: #0071bc;          /* blu del logo */
	--rl-brand-strong: #005a96;
	--rl-cyan: #5ce1e6;           /* glow radiografico */
	--rl-blue: #2f7bff;
	--rl-coral: #ff6b4a;

	/* Schema chiaro (blog) */
	--bg: #ffffff;
	--surface: #f7f7f7;
	--surface-2: #efefef;
	--heading: #0a0a0a;
	--text: #555555;
	--muted: #8a8a8a;
	--border: #ececec;
	--accent: var(--rl-brand);
	--accent-ink: #ffffff;
	--overlay: rgba(10, 10, 10, .55);

	/* Tipografia */
	--font-head: "Jost", system-ui, sans-serif;
	--font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	--font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

	/* Layout */
	--container: 1140px;
	--gutter: clamp(16px, 4vw, 32px);
	--radius: 8px;
	--header-h: 64px;
	--ease: cubic-bezier(.2, .7, .1, 1);

	color-scheme: light;
}

/* Schema scuro: landing sempre, blog su richiesta */
:root[data-scheme="dark"],
.is-landing {
	--bg: #0a0e14;
	--surface: #111821;
	--surface-2: #18212d;
	--heading: #e6edf3;
	--text: #b4bfca;
	--muted: #8b98a5;
	--border: rgba(92, 225, 230, .14);
	--accent: var(--rl-cyan);
	--accent-ink: #032527;
	--overlay: rgba(4, 8, 12, .6);
	color-scheme: dark;
}

.is-landing {
	--font-head: "Space Grotesk", system-ui, sans-serif;
	--font-body: "Inter", system-ui, sans-serif;
	--container: 1240px;
}

/* --------------------------------------------------------------------------
   Reset essenziale
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 400 16px/1.7 var(--font-body);
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
	overflow-x: hidden;
}
img, svg, video, canvas, iframe { max-width: 100%; display: block; }
img { height: auto; }
a { color: inherit; text-decoration: none; transition: color .2s, opacity .2s; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, h4, h5, h6 { font-family: var(--font-head); color: var(--heading); font-weight: 500; line-height: 1.2; margin: 0 0 .6em; }
p { margin: 0 0 1.2em; }
ul, ol { padding-left: 1.2em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
::selection { background: var(--accent); color: var(--accent-ink); }

.screen-reader-text {
	position: absolute !important; width: 1px; height: 1px; overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px); white-space: nowrap;
}
.skip-link:focus {
	clip: auto; width: auto; height: auto; z-index: 1000; top: 8px; left: 8px;
	padding: 10px 16px; background: var(--bg); color: var(--heading);
}

.container { width: 100%; max-width: calc(var(--container) + var(--gutter) * 2); margin-inline: auto; padding-inline: var(--gutter); }
.container--narrow { max-width: calc(720px + var(--gutter) * 2); }
.container--content { max-width: calc(760px + var(--gutter) * 2); }

.mono { font-family: var(--font-mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.small { font-size: 12px; }
.gradient-text {
	background: linear-gradient(90deg, var(--rl-cyan), var(--rl-blue));
	-webkit-background-clip: text; background-clip: text; color: transparent;
}
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); vertical-align: middle; }

/* --------------------------------------------------------------------------
   Pulsanti
   -------------------------------------------------------------------------- */
.btn {
	display: inline-flex; align-items: center; gap: .55em;
	padding: .9em 1.5em; border: 1px solid transparent; border-radius: 4px;
	font: 600 12px/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase;
	transition: transform .25s var(--ease), background-color .25s, border-color .25s, color .25s, box-shadow .25s;
	white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); }
.btn[hidden] { display: none; }
.btn-sm { padding: .7em 1.1em; font-size: 11px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { box-shadow: 0 8px 28px -8px var(--accent); }
.is-landing .btn-primary, :root[data-scheme="dark"] .btn-primary { background: linear-gradient(90deg, var(--rl-cyan), #46c4f0); }
.btn-ghost { border-color: var(--border); color: var(--heading); background: transparent; }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-soft { background: var(--surface-2); color: var(--heading); }
.btn-soft:hover { background: var(--accent); color: var(--accent-ink); }
.btn-light { background: #fff; color: #111; }
.btn-support-solid { background: var(--accent); color: var(--accent-ink); }
.btn-support-solid:hover { box-shadow: 0 8px 22px -8px var(--accent); }
.header-top-right { display: flex; gap: 8px; }
.footer-support-text { margin: 0; max-width: 300px; color: var(--muted); font-size: 14px; }
.icon-btn {
	display: inline-grid; place-items: center; width: 40px; height: 40px;
	border: 0; border-radius: 50%; background: transparent; color: var(--heading);
	transition: background-color .2s, color .2s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--accent); }
.icon-btn.is-on { color: var(--accent); }
.link-arrow { color: var(--accent); }
.link-arrow:hover { opacity: .75; }

/* --------------------------------------------------------------------------
   Logo
   -------------------------------------------------------------------------- */
.site-logo { display: inline-flex; align-items: center; }
.site-logo img { height: 44px; width: auto; }
.site-logo-text { font: 600 24px/1 var(--font-head); color: var(--heading); }
.logo-dark { display: none; }
:root[data-scheme="dark"] .logo-light, .is-landing .logo-light { display: none; }
:root[data-scheme="dark"] .logo-dark, .is-landing .logo-dark { display: block; }

/* --------------------------------------------------------------------------
   Header — blog (layout storico)
   -------------------------------------------------------------------------- */
.site-header--blog { position: relative; z-index: 50; background: var(--bg); }
.header-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding-block: 22px; }
.header-top-center .site-logo img { height: 56px; }
.header-top-right { justify-self: end; }
.header-nav { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--bg); }
.header-nav-inner { display: flex; align-items: center; gap: 16px; height: var(--header-h); }
.header-nav-logo { display: none; }
.header-nav-logo .site-logo img { height: 34px; }
.header-nav .primary-nav { flex: 1; display: flex; justify-content: center; }
.header-nav-actions { display: flex; gap: 2px; margin-left: auto; }
.header-nav.is-stuck { position: fixed; inset: 0 0 auto; z-index: 60; box-shadow: 0 6px 24px -12px rgba(0, 0, 0, .2); animation: rl-drop .35s var(--ease); }
.header-nav.is-stuck .header-nav-logo { display: block; }
@keyframes rl-drop { from { transform: translateY(-100%); } to { transform: none; } }

.primary-nav .menu { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.primary-nav .menu > li { position: relative; }
.primary-nav .menu a {
	display: block; padding: 8px 14px; color: var(--heading);
	font: 500 13px/1.4 var(--font-body); letter-spacing: .04em; text-transform: uppercase;
}
.primary-nav .menu a:hover, .primary-nav .current-menu-item > a { color: var(--accent); }
.primary-nav .sub-menu {
	position: absolute; top: 100%; left: 0; min-width: 220px; padding: 8px 0; margin: 0; list-style: none;
	background: #161616; opacity: 0; visibility: hidden; transform: translateY(6px); transition: .2s var(--ease);
}
.primary-nav li:hover > .sub-menu, .primary-nav li:focus-within > .sub-menu { opacity: 1; visibility: visible; transform: none; }
.primary-nav .sub-menu a { color: #969696; text-transform: none; }
.primary-nav .sub-menu a:hover { color: #fff; }

.scheme-toggle .when-dark { display: none; }
:root[data-scheme="dark"] .scheme-toggle .when-dark { display: inline; }
:root[data-scheme="dark"] .scheme-toggle .when-light { display: none; }

.social-links { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.social-links a { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: var(--heading); }
.social-links a:hover { color: var(--accent); background: var(--surface-2); }
.social-links--boxed a { border-radius: 4px; background: var(--surface); width: 44px; height: 44px; }

/* --------------------------------------------------------------------------
   Header — landing
   -------------------------------------------------------------------------- */
.site-header--landing {
	position: fixed; inset: 0 0 auto; z-index: 60; height: var(--header-h);
	transition: background-color .35s, backdrop-filter .35s, border-color .35s;
	border-bottom: 1px solid transparent;
}
.site-header--landing.is-scrolled { background: rgba(10, 14, 20, .72); backdrop-filter: blur(14px) saturate(140%); border-color: var(--border); }
/* Barra di amministrazione WordPress (solo utenti loggati) */
.admin-bar .site-header--landing, .admin-bar .header-nav.is-stuck { top: 32px; }
@media (max-width: 782px) { .admin-bar .site-header--landing, .admin-bar .header-nav.is-stuck { top: 46px; } }
@media (max-width: 600px) { .admin-bar .site-header--landing, .admin-bar .header-nav.is-stuck { top: 0; } }
.header-bar { display: flex; align-items: center; gap: 24px; height: 100%; }
.header-brand { display: flex; align-items: center; gap: 12px; }
.header-brand .site-logo img { height: 34px; }
.tag-chip { padding: 4px 8px; border: 1px solid var(--border); border-radius: 3px; color: var(--muted); font-size: 10px; }
.site-header--landing .primary-nav { flex: 1; display: flex; justify-content: center; }
.site-header--landing .primary-nav .menu a { font: 500 12px/1.4 var(--font-mono); letter-spacing: .12em; color: var(--muted); position: relative; }
.site-header--landing .primary-nav .menu a::after {
	content: ""; position: absolute; left: 14px; right: 14px; bottom: 2px; height: 1px;
	background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .3s var(--ease);
}
.site-header--landing .primary-nav .menu a:hover { color: var(--heading); }
.site-header--landing .primary-nav .menu a:hover::after { transform: none; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.readout { padding: 6px 10px; border: 1px solid var(--border); border-radius: 3px; color: var(--muted); font-size: 10px; }
.site-header--landing [data-offcanvas-open] { display: none; }

/* --------------------------------------------------------------------------
   Offcanvas e ricerca
   -------------------------------------------------------------------------- */
.offcanvas { position: fixed; inset: 0; z-index: 100; }
.offcanvas[hidden] { display: none; }
.offcanvas-backdrop { position: absolute; inset: 0; background: var(--overlay); animation: rl-fade .3s; }
.offcanvas-panel {
	position: absolute; inset: 0 auto 0 0; width: min(360px, 88vw); overflow-y: auto;
	padding: 24px; background: var(--bg); color: var(--text);
	display: flex; flex-direction: column; gap: 24px; animation: rl-slide .35s var(--ease);
}
.offcanvas-head { display: flex; align-items: center; justify-content: space-between; }
.offcanvas-head .site-logo img { height: 36px; }
.offcanvas-nav .menu { list-style: none; margin: 0; padding: 0; }
.offcanvas-nav .menu a { display: block; padding: 10px 0; border-bottom: 1px solid var(--border); font: 500 18px/1.3 var(--font-head); color: var(--heading); }
.offcanvas-nav .sub-menu { list-style: none; padding-left: 14px; }
.offcanvas-nav .sub-menu a { font-size: 15px; }
.offcanvas-label { margin: 0; font: 500 11px/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.offcanvas-group { border-bottom: 1px solid var(--border); }
.offcanvas-group summary {
	display: flex; align-items: center; gap: 8px; padding: 12px 0; cursor: pointer; list-style: none; user-select: none;
}
.offcanvas-group summary::-webkit-details-marker { display: none; }
.offcanvas-group summary::after {
	content: ""; width: 8px; height: 8px; margin-left: auto; border: solid var(--heading); border-width: 0 1.5px 1.5px 0;
	transform: rotate(45deg) translateY(-2px); transition: transform .25s var(--ease);
}
.offcanvas-group[open] summary::after { transform: rotate(-135deg) translateY(-2px); }
.offcanvas-group summary:hover { color: var(--accent); }
.offcanvas-count { padding: 2px 6px; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 10px; letter-spacing: 0; }
.offcanvas-group[open] .offcanvas-cats { animation: rl-fade .3s; }
.offcanvas-cats { list-style: none; margin: 0 0 12px; padding: 0; }
.offcanvas-cats a { display: flex; justify-content: space-between; padding: 7px 0; color: var(--heading); font-size: 14px; }
.offcanvas-cats span { color: var(--muted); font-size: 12px; }
@keyframes rl-fade { from { opacity: 0; } }
@keyframes rl-slide { from { transform: translateX(-100%); } }

.search-overlay { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 96%, transparent); animation: rl-fade .25s; }
.search-overlay[hidden] { display: none; }
.search-close { position: absolute; top: 20px; right: 20px; }
.search-form { display: flex; align-items: center; border-bottom: 2px solid var(--heading); }
.search-field { flex: 1; min-width: 0; padding: 14px 0; border: 0; background: transparent; color: var(--heading); font: 500 clamp(20px, 3vw, 34px)/1.2 var(--font-head); outline: none; }
.search-submit { border: 0; background: none; padding: 8px; color: var(--heading); }
.archive-description .search-form .search-field, .no-results .search-field, .error-404 .search-field { font-size: 18px; }

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.site-footer { margin-top: 96px; padding-top: 64px; background: var(--surface); border-top: 1px solid var(--border); }
.is-landing .site-footer { margin-top: 0; background: #070a0f; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 40px; padding-bottom: 48px; }
.footer-tagline { margin: 14px 0; color: var(--muted); }
.footer-nav .menu { list-style: none; margin: 0; padding: 0; columns: 2; }
.footer-nav .menu a { display: block; padding: 5px 0; color: var(--heading); font-size: 14px; }
.footer-nav .menu a:hover { color: var(--accent); }
.footer-extra { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }
.footer-bottom { display: flex; align-items: center; gap: 20px; padding-block: 22px; border-top: 1px solid var(--border); color: var(--muted); }
.footer-bottom a:hover { color: var(--accent); }
.to-top { margin-left: auto; display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 4px; background: transparent; color: var(--heading); }
.to-top:hover { border-color: var(--accent); color: var(--accent); }

/* Segnaposto per contenuti senza immagine in evidenza */
.thumb-fallback {
	position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted);
	background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%), var(--surface);
}
.thumb-fallback .icon { opacity: .5; }

/* Il pulsante "torna su" di Powerkit duplica quello del footer */
.is-landing .pk-scroll-to-top { display: none !important; }

/* --------------------------------------------------------------------------
   Cornici "viewport" PACS
   -------------------------------------------------------------------------- */
.vp-corner { position: absolute; width: 14px; height: 14px; border: 0 solid var(--accent); opacity: .7; pointer-events: none; z-index: 2; }
.vp-corner.tl { top: -1px; left: -1px; border-top-width: 1px; border-left-width: 1px; }
.vp-corner.tr { top: -1px; right: -1px; border-top-width: 1px; border-right-width: 1px; }
.vp-corner.bl { bottom: -1px; left: -1px; border-bottom-width: 1px; border-left-width: 1px; }
.vp-corner.br { bottom: -1px; right: -1px; border-bottom-width: 1px; border-right-width: 1px; }

/* --------------------------------------------------------------------------
   Visore 3D (condiviso)
   -------------------------------------------------------------------------- */
.viewer {
	--v-bg: #0b1118;
	position: relative; display: grid; grid-template-rows: auto 1fr auto;
	min-height: 460px; border: 1px solid rgba(92, 225, 230, .18); border-radius: var(--radius);
	background: radial-gradient(120% 90% at 50% 40%, #12202b 0%, var(--v-bg) 60%);
	color: #b4bfca; overflow: hidden; isolation: isolate;
}
.viewer::before {
	content: ""; position: absolute; inset: 0; z-index: -1; opacity: .35;
	background-image: linear-gradient(rgba(92, 225, 230, .07) 1px, transparent 1px), linear-gradient(90deg, rgba(92, 225, 230, .07) 1px, transparent 1px);
	background-size: 32px 32px;
	mask-image: radial-gradient(circle at 50% 50%, #000 30%, transparent 75%);
}
.viewer .vp-corner { border-color: var(--rl-cyan); }
.viewer-head, .viewer-foot { display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px; font-size: 10px; color: #8b98a5; }
.viewer-head [data-viewer-title] { color: var(--rl-cyan); }
.viewer-foot { border-top: 1px solid rgba(92, 225, 230, .12); }
.viewer-foot .dot { background: var(--rl-cyan); box-shadow: 0 0 8px var(--rl-cyan); width: 6px; height: 6px; }
.viewer-stage { position: relative; min-height: 340px; cursor: grab; touch-action: none; }
.viewer-stage:active { cursor: grabbing; }
.viewer-stage canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.viewer-poster { position: absolute; inset: 0; display: grid; place-items: center; transition: opacity .5s; }
.viewer-poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .25; filter: grayscale(1); }
.viewer-poster.is-hidden { opacity: 0; pointer-events: none; }
.viewer-loading { position: relative; padding: 8px 12px; border: 1px solid rgba(92, 225, 230, .25); border-radius: 3px; background: rgba(10, 14, 20, .7); color: var(--rl-cyan); }
.viewer-hint { position: absolute; left: 16px; bottom: 54px; display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid rgba(92, 225, 230, .15); border-radius: 3px; background: rgba(10, 14, 20, .6); font-size: 10px; pointer-events: none; }
.viewer-hint .hint-touch { display: none; }
@media (hover: none) and (pointer: coarse) {
	.viewer-hint .hint-mouse { display: none; }
	.viewer-hint .hint-touch { display: inline; }
}
.viewer-tools { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 6px; padding: 6px; border: 1px solid rgba(92, 225, 230, .15); border-radius: 999px; background: rgba(10, 14, 20, .6); }
.viewer-tools .icon-btn { width: 34px; height: 34px; color: #b4bfca; }
.viewer-tools .icon-btn:hover { background: rgba(92, 225, 230, .12); color: var(--rl-cyan); }
.viewer-tools .icon-btn.is-on { color: var(--rl-cyan); background: rgba(92, 225, 230, .1); }

/* --------------------------------------------------------------------------
   Responsive comune
   -------------------------------------------------------------------------- */
@media (max-width: 960px) {
	.header-nav .primary-nav, .site-header--landing .primary-nav, .readout, .tag-chip { display: none; }
	.site-header--landing [data-offcanvas-open] { display: inline-grid; }
	.footer-grid { grid-template-columns: 1fr; gap: 28px; }
}
@media (max-width: 640px) {
	.header-top { grid-template-columns: 1fr auto; padding-block: 14px; }
	.header-top-left { display: none; }
	.header-top-center { justify-self: start; }
	.header-top-center .site-logo img { height: 40px; }
	.site-header--landing .btn-primary, .site-header--landing .btn-support { display: none; }
	.header-top-right .btn-soft { display: none; }
	.footer-bottom { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
