/* Barre di scorrimento e controlli del browser nel tema giusto (anche quando lo si sceglie col pulsante). */
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; } }

/* Pulsante del tema (chiaro/scuro) in alto a destra, su tutte le pagine del sito: lo crea tema.js. */
.theme-toggle {
  position: fixed; top: 12px; right: 12px; z-index: 10;
  width: 40px; height: 40px; border-radius: 50%; padding: 0;
  display: flex; align-items: center; justify-content: center;
  color: inherit; background: rgba(127, 127, 127, .12); border: 1px solid rgba(127, 127, 127, .25);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  cursor: pointer; transition: background .2s;
}
.theme-toggle:hover { background: rgba(127, 127, 127, .22); }
.theme-toggle:focus-visible { outline: 2px solid #1e6fdb; outline-offset: 2px; }

/* Cambio di tema graduale (tema.js aggiunge tema-in-cambio solo durante il cambio, circa un secondo): gli sfondi sfumano
   invece di cambiare di colpo, e dal basso passa la luce del tramonto (verso il tema scuro) o dell'alba (verso il chiaro).
   Il testo cambia colore più in fretta, a metà strada, quando lo sfondo è a metà: così resta sempre leggibile.
   I colori delle pagine sono tutti variabili su :root (--bg, --fg...): registrate qui come colori, sfumano solo su :root
   e la pagina intera le segue. (Far sfumare "color" su ogni elemento non va: in Chrome la sfumatura di un elemento
   riparte finché sfuma quella del genitore, e il titolo restava scuro sullo sfondo scuro per quasi un secondo.)
   Browser senza @property (Safari prima della 16.4): cambio immediato, con la luce del tramonto o dell'alba. */
@property --bg { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --card { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --line { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --box { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --pill-hover { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --fg { syntax: '<color>'; inherits: true; initial-value: CanvasText; }
@property --muted { syntax: '<color>'; inherits: true; initial-value: CanvasText; }
@property --link { syntax: '<color>'; inherits: true; initial-value: LinkText; }
@property --accent { syntax: '<color>'; inherits: true; initial-value: LinkText; }
@property --boxfg { syntax: '<color>'; inherits: true; initial-value: CanvasText; }
.tema-in-cambio {
  transition: --bg 1s ease-in-out, --card 1s ease-in-out, --line 1s ease-in-out, --box 1s ease-in-out, --pill-hover 1s ease-in-out,
    --fg .3s ease-in-out .38s, --muted .3s ease-in-out .38s, --link .3s ease-in-out .38s, --accent .3s ease-in-out .38s,
    --boxfg .3s ease-in-out .38s;
}
.tema-cielo { position: fixed; inset: 0; z-index: 5; pointer-events: none; opacity: 0; animation: tema-cielo 1.1s ease-in-out forwards; }
.tema-cielo.tramonto { background: linear-gradient(to top, rgba(255, 128, 64, .42), rgba(255, 170, 110, .2) 40%, rgba(255, 200, 150, 0) 75%); }
.tema-cielo.alba { background: linear-gradient(to top, rgba(255, 160, 185, .38), rgba(255, 205, 170, .18) 40%, rgba(255, 230, 200, 0) 75%); }
@keyframes tema-cielo { 0% { opacity: 0; } 40% { opacity: 1; } 100% { opacity: 0; } }
