/* PatientBox v7 — integrazioni al design (form, spinner, tooltip, scrollbar)
   Il design approvato resta in design.css: qui solo cio' che serve in piu'. */

/* ---------- scrollbar sottile ---------- */
html { scrollbar-gutter: stable; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-soft); }

/* ---------- contenitore stretto (pagine testuali, 404) ---------- */
.ct.pb-narrow { max-width: 780px; }
.pb-entry-content { color: var(--fg-muted); line-height: 1.7; }
.pb-entry-content h2,
.pb-entry-content h3 { color: var(--fg); margin: 34px 0 12px; }
.pb-entry-content p { margin: 0 0 16px; }
.pb-entry-content ul,
.pb-entry-content ol { margin: 0 0 16px 22px; }
.pb-entry-content li { margin-bottom: 8px; }
.pb-entry-content a { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }
.pb-entry-content img { max-width: 100%; height: auto; border-radius: var(--r-sm); }
.pb-entry-content table { width: 100%; border-collapse: collapse; margin: 0 0 18px; }
.pb-entry-content th,
.pb-entry-content td { padding: 10px 12px; border: 1px solid var(--border); text-align: left; }

/* ---------- accessibilita' ---------- */
.screen-reader-text {
	position: absolute !important; width: 1px; height: 1px; overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px); clip-path: inset(50%); white-space: nowrap;
}
.skip-link:focus {
	position: fixed; top: 12px; left: 12px; z-index: 9999; width: auto; height: auto;
	clip: auto; clip-path: none; padding: 12px 18px; border-radius: var(--r-sm);
	background: var(--blue); color: #fff; font-weight: 600;
}

/* ---------- stati di validazione form ---------- */
.field { position: relative; }
.pb-err {
	display: block; margin-top: 6px; font-size: 12.5px; line-height: 1.4;
	color: #E5484D; min-height: 0;
}
[data-theme="dark"] .pb-err { color: #FF6369; }
.pb-err:empty { margin-top: 0; }
.field input.has-error,
.field textarea.has-error,
.field select.has-error {
	border-color: #E5484D;
	box-shadow: 0 0 0 3px rgba(229, 72, 77, 0.14);
}

.pb-formerr {
	margin-top: 14px; padding: 12px 16px; border-radius: var(--r-sm);
	background: rgba(229, 72, 77, 0.10); border: 1px solid rgba(229, 72, 77, 0.3);
	color: #C62A2F; font-size: 14px; line-height: 1.5;
}
[data-theme="dark"] .pb-formerr { color: #FF8A8E; }

/* ---------- consenso privacy ---------- */
.pb-consent {
	display: flex; align-items: flex-start; gap: 10px;
	margin-top: 20px; font-size: 14px; line-height: 1.55; color: var(--fg-muted);
	cursor: pointer;
}
.pb-consent input[type="checkbox"] {
	width: 18px; height: 18px; margin-top: 1px; flex: 0 0 auto;
	accent-color: var(--blue); cursor: pointer;
}
.pb-consent a { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }

/* ---------- bottone con spinner (12 lame, stile iOS) ---------- */
.pb-submit { position: relative; }
.pb-submit .pb-spinner { display: none; }
.pb-submit.is-loading { pointer-events: none; }
.pb-submit.is-loading > .btn-arrow { visibility: hidden; }
.pb-submit.is-loading .pb-spinner {
	display: block; position: absolute; top: 50%; left: 50%;
	width: 20px; height: 20px; margin: -10px 0 0 -10px;
}
.pb-spinner i,
.pb-spinner::before { display: none; }
.pb-submit.is-loading .pb-spinner {
	background:
		repeating-conic-gradient(from 0deg,
			currentColor 0deg 6deg, transparent 6deg 30deg);
	-webkit-mask: radial-gradient(circle, transparent 0 5px, #000 5.5px);
	        mask: radial-gradient(circle, transparent 0 5px, #000 5.5px);
	color: #fff;
	animation: pb-spin 0.9s steps(12) infinite;
	opacity: 0.9;
}
/* bottoni chiari -> lame scure */
.btn-ghost.pb-submit.is-loading .pb-spinner,
.btn-light.pb-submit.is-loading .pb-spinner { color: var(--ink-base); }

@keyframes pb-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
	.pb-submit.is-loading .pb-spinner { animation-duration: 2.4s; }
}

/* ---------- tooltip stile Google ---------- */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
	content: attr(data-tooltip);
	position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(4px);
	background: #fff; color: #1F2937; font-size: 12px; font-weight: 500; line-height: 1.4;
	padding: 7px 10px; border-radius: 8px; white-space: nowrap;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); border: 1px solid rgba(0, 0, 0, 0.06);
	opacity: 0; pointer-events: none; transition: opacity 0.16s ease, transform 0.16s ease;
	z-index: 60;
}
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after { opacity: 1; transform: translateX(-50%) translateY(0); }
[data-tooltip-pos="bottom"]::after { bottom: auto; top: calc(100% + 8px); }
[data-tooltip-pos="left"]::after { bottom: auto; top: 50%; left: auto; right: calc(100% + 8px); transform: translateY(-50%); }
[data-tooltip-pos="right"]::after { bottom: auto; top: 50%; left: calc(100% + 8px); transform: translateY(-50%); }

/* ---------- no-js: mostra comunque i contenuti animati ---------- */
.no-js .reveal { opacity: 1 !important; transform: none !important; }
