/* LEGGO - stili dell'applicazione (sopra UIkit) */

/* Lexend variabile (OFL), servito localmente: vedi public/fonts/lexend/OFL.txt */
@font-face {
	font-family: 'Lexend';
	font-style: normal;
	font-display: swap;
	font-weight: 100 900;
	src: url('../fonts/lexend/lexend-latin-ext-wght-normal.woff2') format('woff2-variations');
	unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
	font-family: 'Lexend';
	font-style: normal;
	font-display: swap;
	font-weight: 100 900;
	src: url('../fonts/lexend/lexend-latin-wght-normal.woff2') format('woff2-variations');
	unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
	/* Cambiare font del reader = cambiare questa riga. */
	--reader-font: 'Lexend', system-ui, -apple-system, 'Segoe UI', sans-serif;
	/* I colori del tema arrivano da assets/scss/custom.scss (variabili --leggo-*) */
	--word-current-bg: var(--leggo-highlight, #ffd43b);
	--word-current-fg: #000;
	--word-hover-bg: rgba(255, 212, 59, 0.35);
	--toolbar-height: 5.5rem;
}

/* Sotto i 960px la barra comandi del reader va su due righe */
@media (max-width: 959px) {
	:root {
		--toolbar-height: 9.5rem;
	}
}

/* Font di interfaccia e stile dei componenti: tema UIkit (assets/scss/custom.scss) */

/* Struttura di pagina: footer sempre in fondo anche sulle pagine corte */
.leggo-page {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

.leggo-page > main {
	flex: 1 0 auto;
}

/* Le ancore e la parola centrata durante la lettura non finiscono sotto la barra fissa */
html {
	scroll-padding-top: 5rem;
}

/* Barra di navigazione unica (catalogo, lettura, gestione), fissa in alto */
.leggo-navbar {
	position: sticky;
	top: 0;
	z-index: 980;
	border-bottom: 1px solid var(--leggo-border);
}

.leggo-navbar .uk-logo {
	font-weight: 800;
	color: var(--leggo-primary);
	letter-spacing: -0.02em;
	
}

/* Pulsante hamburger (sotto i 1200px) */
.leggo-menu-toggle {
	background: none;
	border: 0;
	cursor: pointer;
	min-width: 44px;
	padding-left: 0;
	color: var(--leggo-secondary);
}

/* Menu a scomparsa: voci raggruppate, grandi da toccare */
.leggo-menu .uk-offcanvas-bar {
	padding-top: calc(20px + env(safe-area-inset-top, 0px));
	padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

.leggo-menu-user {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px 0 20px;
	margin-bottom: 8px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.15);
	color: #fff;
}

.leggo-menu-avatar {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: var(--leggo-primary);
	color: #fff;
	font-weight: 700;
	font-size: 1.2rem;
}

.leggo-menu-role {
	color: rgba(255, 255, 255, 0.7);
}

.leggo-menu-nav > li.uk-nav-header {
	margin-top: 16px;
	padding: 4px 14px;
	font-size: 0.75rem;
	letter-spacing: 0.06em;
	color: rgba(255, 255, 255, 0.6);
}

.leggo-menu-nav > li > a {
	display: flex;
	align-items: center;
	gap: 12px;
	min-height: 48px;
	padding: 0 14px;
	border-radius: 12px;
	font-size: 1.1rem;
	color: rgba(255, 255, 255, 0.9);
}

.leggo-menu-nav > li > a:hover,
.leggo-menu-nav > li > a:focus-visible {
	background: rgba(255, 255, 255, 0.1);
	color: #fff;
}

.leggo-menu-nav > li.uk-active > a {
	background: var(--leggo-primary);
	color: #fff;
	font-weight: 600;
}

/* Footer unico */
.leggo-footer {
	border-top: 1px solid var(--leggo-border);
}

/* Nella pagina di lettura la barra comandi è fissa in basso: il footer le resta sopra */
.leggo-page:has(.reader-toolbar) .leggo-footer {
	padding-bottom: calc(var(--toolbar-height) + 1.5rem + env(safe-area-inset-bottom, 0px));
}

/* ------------------------------------------------------------------
   Pagina iniziale: schede degli ambiti
   ------------------------------------------------------------------ */

.scope-card {
	position: relative;
	border-top: 6px solid var(--scope-color, var(--leggo-primary));
}

.scope-card-initial {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	border-radius: 16px;
	background: var(--scope-color, var(--leggo-primary));
	color: #fff;
	font-size: 1.6rem;
	font-weight: 800;
}

.scope-card .uk-card-title {
	font-size: 1.5rem;
}

.scope-card-0 { --scope-color: var(--leggo-primary); }
.scope-card-1 { --scope-color: #0b7d61; }
.scope-card-2 { --scope-color: #c2410c; }
.scope-card-3 { --scope-color: var(--leggo-secondary); }
.scope-card-unassigned { --scope-color: #6b6a80; border-top-style: dashed; }

/* ------------------------------------------------------------------
   Catalogo
   ------------------------------------------------------------------ */

.catalog-card .uk-card-title {
	font-size: 1.25rem;
	line-height: 1.3;
}

.catalog-cover {
	aspect-ratio: 1 / 1;
	object-fit: cover;
	width: 100%;
	display: block;
}

/* ------------------------------------------------------------------
   Reader
   ------------------------------------------------------------------ */

.reader {
	/* A− / A+: moltiplicatore scelto dall'utente (vedi reader.js) */
	--reader-scale: 1;
	font-size: calc(clamp(1.6rem, 1.05rem + 2.2vw, 3rem) * var(--reader-scale));
	line-height: 1.65;
	letter-spacing: 0.02em;
	word-spacing: 0.15em;
	color: #111;
	padding-bottom: 2rem;
}

/* UIkit imposta text-transform: none sui titoli: nel reader seguono la scelta Aa del contenitore */
.reader h1,
.reader h2 {
	text-transform: inherit;
	font-family: inherit;
}

.reader-title {
	font-size: 1.2em;
	font-weight: 700;
	line-height: 1.35;
	margin: 0 0 0.8em;
	text-align: center;
}

.reader-section-title {
	font-size: 0.85em;
	font-weight: 700;
	margin: 1.2em 0 0.5em;
	color: #444;
}

.reader-section + .reader-section {
	margin-top: 1.5em;
}

.reader p {
	margin: 0 0 0.9em;
}

.reader strong {
	font-weight: 800;
}

/* Elenco puntato: il pulsante ▶ sopra, voci con pallini grandi e ben distanziate */
.reader-list {
	margin: 0 0 0.9em;
}

.reader-list ul {
	margin: 0.2em 0 0;
	padding-left: 1.2em;
	list-style: none;
}

.reader-list li {
	position: relative;
	margin-bottom: 0.3em;
}

.reader-list li::before {
	content: "";
	position: absolute;
	left: -0.85em;
	top: 0.62em;
	width: 0.36em;
	height: 0.36em;
	border-radius: 50%;
	background: var(--leggo-primary);
}

.reader-cover,
.reader-image {
	border-radius: 12px;
	display: block;
	max-width: 100%;
	height: auto;
}

.reader-cover {
	margin: 0 auto 1em;
}

/* Parola + punteggiatura adiacente non vanno a capo separatamente. */
.reader .chunk {
	white-space: nowrap;
}

.reader .w {
	cursor: pointer;
	border-radius: 0.15em;
	padding: 0 0.04em;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
	transition: background-color 0.15s ease;
}

.reader .w.is-current {
	background: var(--word-current-bg);
	color: var(--word-current-fg);
	box-shadow: 0 0 0 0.08em var(--word-current-bg);
}

@media (hover: hover) {
	.reader .w:not(.is-current):hover {
		background: var(--word-hover-bg);
	}
}

.reader-hint {
	font-size: 1rem;
	letter-spacing: normal;
	word-spacing: normal;
}

/* Velocità e voce, sopra il testo */
.reader-settings {
	gap: 12px 20px;
}

/* Barra strumenti fissa in basso */
.reader-toolbar {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 980;
	padding: 0.75rem 0 calc(0.75rem + env(safe-area-inset-bottom, 0px));
	box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.15);
}

.reader-toolbar .uk-button {
	min-height: 3.5rem;
	font-size: 1.1rem;
	line-height: 1.2;
	touch-action: manipulation;
	text-transform: none;
}

.reader-toolbar .uk-button:not(.uk-width-1-1) {
	padding: 0 14px;
}

.reader-toolbar .uk-button:disabled {
	opacity: 0.4;
}

.reader-toolbar .reader-larger {
	font-size: 1.35rem;
}

.reader-toolbar .uk-button[aria-pressed="true"] {
	background: var(--word-current-bg);
	color: var(--word-current-fg);
}

@media (prefers-reduced-motion: reduce) {
	.reader .w {
		transition: none;
	}
}

/* ------------------------------------------------------------------
   Audio (TTS)
   ------------------------------------------------------------------ */

.reader-play {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.75rem;
	height: 2.75rem;
	margin-right: 0.35em;
	vertical-align: middle;
	border: 0;
	border-radius: 50%;
	background: var(--leggo-primary-soft);
	color: var(--leggo-primary);
	cursor: pointer;
	touch-action: manipulation;
	font-size: 1rem;
}

.reader-play:hover,
.reader-play:focus-visible {
	background: var(--leggo-primary);
	color: #fff;
}

.reader-section-head {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 0.4em;
}

.reader-section-head .reader-section-title {
	margin: 0;
}

/* Blocco (titolo, paragrafo, parola) in lettura */
.reader .is-speaking:not(.w) {
	background: var(--leggo-primary-soft);
	border-radius: 10px;
	box-shadow: 0 0 0 0.25em var(--leggo-primary-soft);
}

.reader .is-speaking > .reader-play,
.reader-play.is-speaking {
	background: var(--leggo-primary);
	color: #fff;
}

/* Parola pronunciata durante la lettura di un blocco */
.reader .w.is-spoken {
	background: var(--word-current-bg);
	color: var(--word-current-fg);
	box-shadow: 0 0 0 0.08em var(--word-current-bg);
}

/* In attesa dell'audio (prima generazione) */
.reader .is-loading {
	animation: leggo-pulse 1s ease-in-out infinite;
}

@keyframes leggo-pulse {
	50% { opacity: 0.45; }
}

@media (prefers-reduced-motion: reduce) {
	.reader .is-loading {
		animation: none;
		opacity: 0.6;
	}
}

/* ------------------------------------------------------------------
   Pronuncia sbagliata? (finestra condivisa da reader e gestione)
   ------------------------------------------------------------------ */

.pronunciation-label {
	font-family: var(--reader-font);
	font-size: 1.3rem;
	font-weight: 600;
}

.pronunciation-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

[data-pronunciation].is-busy .uk-modal-dialog {
	cursor: progress;
}
