/**
 * Area riservata — stile front-end.
 *
 * Coerente con i token del tema (theme.json): Montserrat, palette taupe/oro,
 * bottoni squadrati. Caricato solo sulle pagine dell'area (vedi enqueue.php).
 * I colori usano le CSS custom properties generate da theme.json con fallback.
 */

.ar {
	--ar-primary: var(--wp--preset--color--primary, #b4aca4);
	--ar-accent: var(--wp--preset--color--accent, #f1c92f);
	--ar-contrast: var(--wp--preset--color--contrast, #202020);
	--ar-text: var(--wp--preset--color--text, #575959);
	--ar-surface: var(--wp--preset--color--surface, #ececec);
	--ar-base: var(--wp--preset--color--base, #fff);
	--ar-border: #ded9d3;
	--ar-danger: #c0392b;
	--ar-success: #3c8f57;

	font-family: var(--wp--preset--font-family--montserrat, inherit);
	color: var(--ar-text);
	/* Il gap superiore arriva dallo standard di pagina (--aglaya-page-top,
	   applicato al primo figlio di .site-main): qui solo il respiro inferiore,
	   così le pagine dell'area riservata sono allineate a tutte le altre. */
	padding-bottom: clamp(2.5rem, 6vw, 5rem);
	box-sizing: border-box;
}

.ar *,
.ar *::before,
.ar *::after {
	box-sizing: border-box;
}

.ar--narrow > .ar-card,
.ar--narrow > .ar-alert {
	max-width: 520px;
	margin-inline: auto;
}

/* ---------- Intestazione pagine auth (registrati) ----------
   Titolo + testo introduttivo mostrati sopra alla card del form, fuori dal box.
   Il titolo usa la dimensione standard di pagina (--aglaya-title-size). */
.ar-auth-head {
	margin-bottom: clamp(1.5rem, 3vw, 2.25rem);
}

.ar-auth-head__title {
	margin: 0 0 1rem;
	font-size: var(--aglaya-title-size, clamp(2.25rem, 5vw + 0.5rem, 3.75rem));
	font-weight: 300;
	line-height: 1.2;
	text-transform: uppercase;
	letter-spacing: 1px;
	text-align: center;
	color: var(--ar-contrast);
}

.ar-auth-head p {
	margin: 0 0 0.5em;
}

.ar-auth-head p:last-child {
	margin-bottom: 0;
}

/* ---------- Card ---------- */
.ar-card {
	background: var(--ar-base);
	border: 1px solid var(--ar-border);
	box-shadow: 0 10px 40px rgba(32, 32, 32, 0.06);
	padding: clamp(1.5rem, 4vw, 2.75rem);
	margin-bottom: 1.75rem;
}

/* Form dentro un popup: nessun "box" (bordo, padding, ombra, sfondo): il
   contenitore e la spaziatura li fornisce già il dialog del popup. */
.aglaya-popup__content .aglaya-cf__card {
	background: transparent;
	border: 0;
	box-shadow: none;
	padding: 0;
}

.ar-card--danger {
	border-color: rgba(192, 57, 43, 0.35);
}

.ar-card__title {
	margin: 0 0 0.5rem;
	font-size: 1.5rem;
	font-weight: 500;
	color: var(--ar-contrast);
	line-height: 1.25;
}

.ar-card__lead {
	margin: 0 0 1.5rem;
	font-size: 0.95rem;
	line-height: 1.6;
}

.ar-card__foot {
	margin: 1.5rem 0 0;
	text-align: center;
	font-size: 0.9rem;
}

.ar-card__foot a {
	color: var(--ar-contrast);
	font-weight: 600;
	text-decoration: none;
}

.ar-card__foot a:hover {
	color: var(--ar-primary);
}

/* ---------- Form ---------- */
.ar-form {
	display: flex;
	flex-direction: column;
	gap: 1.1rem;
}

.ar-form--step {
	margin-top: 1.25rem;
	padding-top: 1.25rem;
	border-top: 1px dashed var(--ar-border);
}

.ar-form[hidden] {
	display: none;
}

.ar-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1.1rem;
}

@media (max-width: 540px) {
	.ar-grid {
		grid-template-columns: 1fr;
	}
}

.ar-field {
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
}

.ar-field label {
	font-size: 0.8rem;
	font-weight: 600;
	letter-spacing: 0.3px;
	color: var(--ar-contrast);
	text-transform: uppercase;
}

.ar-field input {
	width: 100%;
	padding: 0.85rem 1rem;
	font-size: 1rem;
	font-family: inherit;
	color: var(--ar-contrast);
	background: var(--ar-base);
	border: 1px solid var(--ar-border);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ar-field input::placeholder {
	color: #b9b4ad;
	letter-spacing: 0.35em;
}

.ar-field input:focus {
	outline: none;
	border-color: var(--ar-primary);
	box-shadow: 0 0 0 3px rgba(180, 172, 164, 0.28);
}

.ar-field input:user-invalid {
	border-color: var(--ar-danger);
}

/* Password + toggle */
.ar-pass {
	position: relative;
}

.ar-pass input {
	padding-right: 3rem;
	width: 100%;
}

.ar-pass__toggle {
	position: absolute;
	top: 50%;
	right: 0.6rem;
	transform: translateY(-50%);
	width: 2rem;
	height: 2rem;
	padding: 0;
	border: 0;
	cursor: pointer;
	background: transparent no-repeat center / 20px 20px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23575959' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 12s4-7 11-7 11 7 11 7-4 7-11 7-11-7-11-7z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
	opacity: 0.65;
}

.ar-pass__toggle:hover {
	opacity: 1;
}

.ar-pass__toggle.is-on {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b4aca4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24'/%3E%3Cline x1='1' y1='1' x2='23' y2='23'/%3E%3C/svg%3E");
	opacity: 1;
}

/* Checkbox */
.ar-check {
	display: flex;
	align-items: flex-start;
	gap: 0.6rem;
	font-size: 0.9rem;
	line-height: 1.5;
	cursor: pointer;
}

.ar-check input {
	margin-top: 0.15rem;
	width: 1.05rem;
	height: 1.05rem;
	accent-color: var(--ar-primary);
	flex: 0 0 auto;
}

.ar-check a {
	color: var(--ar-contrast);
	font-weight: 600;
}

.ar-hint {
	margin: 0;
	font-size: 0.82rem;
	color: #9a948c;
	min-height: 1em;
}

/* ---------- Buttons ---------- */
.ar-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: 0.95rem 2rem;
	font-family: inherit;
	font-size: 0.78rem;
	font-weight: 400;
	letter-spacing: 0.5px;
	text-transform: uppercase;
	text-decoration: none;
	cursor: pointer;
	border: 1px solid transparent;
	transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.ar-btn--primary {
	background: var(--ar-primary);
	color: var(--ar-base);
}

.ar-btn--primary:hover,
.ar-btn--primary:focus-visible {
	background: var(--ar-contrast);
	color: var(--ar-base);
}

.ar-btn--ghost {
	background: transparent;
	color: var(--ar-contrast);
	border-color: var(--ar-border);
	padding: 0.7rem 1.3rem;
}

.ar-btn--ghost:hover {
	background: var(--ar-contrast);
	color: var(--ar-base);
	border-color: var(--ar-contrast);
}

.ar-btn--danger {
	background: var(--ar-danger);
	color: #fff;
}

.ar-btn--danger:hover {
	background: #97281c;
}

.ar-btn[disabled] {
	opacity: 0.6;
	cursor: default;
}

.ar-link {
	background: none;
	border: 0;
	padding: 0;
	font: inherit;
	font-size: 0.88rem;
	color: var(--ar-text);
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

.ar-link:hover {
	color: var(--ar-primary);
}

.ar-switch {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 0.75rem;
	margin: 0.25rem 0 0;
}

/* ---------- Alerts ---------- */
.ar-alert {
	margin: 0 0 1.25rem;
	padding: 0.9rem 1.1rem;
	border-left: 4px solid;
	font-size: 0.9rem;
	line-height: 1.5;
	background: var(--ar-surface);
}

.ar-alert ul {
	margin: 0;
	padding-left: 1.1rem;
}

.ar-alert--success {
	border-color: var(--ar-success);
	background: rgba(60, 143, 87, 0.1);
	color: #24603a;
}

.ar-alert--error {
	border-color: var(--ar-danger);
	background: rgba(192, 57, 43, 0.08);
	color: #8a271c;
}

.ar-alert--info {
	border-color: var(--ar-primary);
	background: rgba(180, 172, 164, 0.15);
	color: var(--ar-contrast);
}

/* ---------- OTP a 6 caselle ---------- */
.ar-otp {
	display: flex;
	gap: 0.55rem;
}

.ar-otp__native {
	font-size: 1.6rem;
	letter-spacing: 0.9em;
	text-align: center;
	font-variant-numeric: tabular-nums;
	padding-left: 1rem;
}

.ar-otp.is-enhanced .ar-otp__native {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	opacity: 0;
	pointer-events: none;
}

.ar-otp__box {
	width: 100%;
	max-width: 3.4rem;
	aspect-ratio: 3 / 4;
	text-align: center;
	font-size: 1.5rem;
	font-weight: 600;
	color: var(--ar-contrast);
	border: 1px solid var(--ar-border);
	background: var(--ar-base);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ar-otp__box:focus {
	outline: none;
	border-color: var(--ar-primary);
	box-shadow: 0 0 0 3px rgba(180, 172, 164, 0.28);
}

/* ---------- Strength meter ---------- */
.ar-strength {
	height: 6px;
	background: var(--ar-surface);
	overflow: hidden;
}

.ar-strength__bar {
	display: block;
	height: 100%;
	width: 0;
	transition: width 0.25s ease, background-color 0.25s ease;
}

.ar-strength.is-weak .ar-strength__bar {
	width: 33%;
	background: var(--ar-danger);
}

.ar-strength.is-medium .ar-strength__bar {
	width: 66%;
	background: var(--ar-accent);
}

.ar-strength.is-strong .ar-strength__bar {
	width: 100%;
	background: var(--ar-success);
}

.ar-strength__label {
	margin: 0.35rem 0 0;
	font-size: 0.78rem;
	min-height: 1em;
	color: #9a948c;
}

.ar-strength__label.is-error {
	color: var(--ar-danger);
	font-weight: 600;
}

/* Honeypot */
.ar-hp {
	position: absolute !important;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* ---------- Hero (area + profilo) ---------- */
.ar-hero {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 1.25rem;
	margin-bottom: 2.5rem;
	padding-bottom: 1.5rem;
	border-bottom: 1px solid var(--ar-border);
}

.ar-hero__hello {
	margin: 0 0 0.25rem;
	font-size: 0.8rem;
	text-transform: uppercase;
	letter-spacing: 1.5px;
	color: var(--ar-primary);
}

.ar-hero__title {
	margin: 0;
	font-size: clamp(1.8rem, 1rem + 2.5vw, 2.6rem);
	font-weight: 300;
	text-transform: uppercase;
	letter-spacing: 1px;
	color: var(--ar-contrast);
}

.ar-hero__nav {
	display: flex;
	gap: 0.6rem;
	flex-wrap: wrap;
}

.ar-intro {
	margin-bottom: 2.5rem;
	font-size: 1rem;
	line-height: 1.7;
	max-width: 70ch;
}

/* ---------- Materiale ---------- */
.ar-group {
	margin-bottom: 3rem;
}

.ar-group__title {
	margin: 0 0 1.4rem;
	font-size: 1.35rem;
	font-weight: 500;
	color: var(--ar-contrast);
	padding-bottom: 0.6rem;
	border-bottom: 2px solid var(--ar-accent);
	display: inline-block;
}

.ar-mat-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: 1.5rem;
}

.ar-mat {
	display: flex;
	flex-direction: column;
	background: var(--ar-base);
	border: 1px solid var(--ar-border);
	overflow: hidden;
	box-shadow: 0 8px 30px rgba(32, 32, 32, 0.05);
}

.ar-mat__media img {
	display: block;
	width: 100%;
	height: 190px;
	object-fit: cover;
}

.ar-mat__body {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	padding: 1.4rem;
	flex: 1;
}

.ar-mat__title {
	margin: 0;
	font-size: 1.1rem;
	font-weight: 600;
	color: var(--ar-contrast);
}

.ar-mat__desc {
	margin: 0;
	font-size: 0.9rem;
	line-height: 1.55;
	color: var(--ar-text);
}

.ar-mat__files {
	list-style: none;
	margin: 0.25rem 0 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.ar-file-link {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	width: 100%;
	padding: 0.75rem 0.9rem;
	border: 0;
	margin: 0;
	background: var(--ar-surface);
	text-align: left;
	text-decoration: none;
	color: var(--ar-contrast);
	font: inherit;
	cursor: pointer;
	transition: background-color 0.15s ease, transform 0.15s ease;
}

.ar-file-link.is-loading {
	opacity: 0.6;
	cursor: progress;
}

.ar-file-link::after {
	content: "";
	width: 18px;
	height: 18px;
	flex: 0 0 auto;
	background: no-repeat center / contain;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23202020' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='7 10 12 15 17 10'/%3E%3Cline x1='12' y1='15' x2='12' y2='3'/%3E%3C/svg%3E");
}

.ar-file-link:hover {
	background: var(--ar-accent);
}

.ar-file-link__name {
	font-size: 0.88rem;
	font-weight: 600;
	word-break: break-word;
}

.ar-file-link__meta {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	flex: 0 0 auto;
}

.ar-file-badge {
	font-size: 0.65rem;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	padding: 0.15rem 0.45rem;
	background: var(--ar-contrast);
	color: var(--ar-base);
}

.ar-file-size {
	font-size: 0.72rem;
	color: #8a857d;
}

.ar-empty {
	padding: 3rem 1rem;
	text-align: center;
	color: #9a948c;
	background: var(--ar-surface);
}
