/* Gli umori. Ogni classe .umore-* porta due cose:
   - i colori del logo e della pagina (tratto, sole, luna, nuvola, sfondo: la tabella del brief);
   - l'atmosfera della foto (filtro, tinta, luce, meteo) quando la classe sta su un .quadro.
   La foto resta una sola: cambia il tempo che fa. */

:root {
  --tratto: #8a4a06;
  --sole: #f2a007;
  --luna: transparent;
  --nuvola: #ffffff;
  --sfondo: #fff1da;
}

.quadro {
  --filtro: none;
  --tinta: transparent;
  --tinta-fusione: normal;
  --tinta-forza: 0;
  --luce: none;
  --luce-fusione: normal;
  --luce-forza: 0;
  --meteo: none;
  --meteo-misura: auto;
  --meteo-posto: 0 0;
  --meteo-ripeti: repeat;
  --meteo-forza: 0;
  position: absolute;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
  background: #17171b;
}

.quadro__foto {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--fuoco, 50% 50%);
  filter: var(--filtro);
}

.quadro__velo {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.quadro__tinta {
  background: var(--tinta);
  mix-blend-mode: var(--tinta-fusione);
  opacity: var(--tinta-forza);
}

.quadro__luce {
  background: var(--luce);
  mix-blend-mode: var(--luce-fusione);
  opacity: var(--luce-forza);
}

.quadro__meteo {
  background-image: var(--meteo);
  background-size: var(--meteo-misura);
  background-position: var(--meteo-posto);
  background-repeat: var(--meteo-ripeti);
  opacity: var(--meteo-forza);
}

/* Felice: sole pieno, colori caldi, un bagliore in alto a destra */
.umore-felice {
  --tratto: #8a4a06;
  --sole: #f2a007;
  --luna: transparent;
  --nuvola: #ffffff;
  --sfondo: #fff1da;
  --filtro: saturate(1.4) contrast(1.06) brightness(1.08);
  --tinta: linear-gradient(160deg, #ffd27a 0%, #ff8a2a 100%);
  --tinta-fusione: soft-light;
  --tinta-forza: 0.85;
  --luce: radial-gradient(120% 95% at 88% 0%, rgba(255, 221, 140, 0.9) 0%, rgba(255, 170, 60, 0.35) 38%, rgba(255, 170, 60, 0) 70%);
  --luce-fusione: screen;
  --luce-forza: 0.9;
}

/* Sereno: cielo limpido, luce morbida */
.umore-sereno {
  --tratto: #1f5f7e;
  --sole: #ffd970;
  --luna: transparent;
  --nuvola: #ffffff;
  --sfondo: #e8f3f8;
  --filtro: saturate(0.95) brightness(1.12) contrast(0.93) hue-rotate(-8deg);
  --tinta: linear-gradient(180deg, #6fcdf7 0%, #bfeedd 100%);
  --tinta-fusione: soft-light;
  --tinta-forza: 0.9;
  --luce: linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 55%);
  --luce-fusione: screen;
  --luce-forza: 0.8;
}

/* Malinconico: sera, l'ultimo chiaro del tramonto in basso, uno spicchio di luna nel cielo libero */
.umore-malinconico {
  --tratto: #4e4378;
  --sole: transparent;
  --luna: #b9aedd;
  --nuvola: #ffffff;
  --sfondo: #eeeaf6;
  --filtro: saturate(0.55) contrast(0.95) brightness(0.8);
  --tinta: linear-gradient(180deg, #3d3468 0%, #a97fa8 62%, #d99a8c 100%);
  --tinta-fusione: color;
  --tinta-forza: 0.66;
  --luce: linear-gradient(0deg, rgba(232, 196, 208, 0.5) 0%, rgba(226, 216, 240, 0) 58%),
    linear-gradient(180deg, rgba(22, 16, 44, 0.62) 0%, rgba(22, 16, 44, 0) 55%);
  --luce-forza: 1;
  --meteo: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M50 12 A38 38 0 0 0 50 88 A21 38 0 0 1 50 12 Z' fill='%23f3eeff'/%3E%3C/svg%3E");
  --meteo-misura: clamp(44px, 6vw, 84px);
  --meteo-posto: var(--cielo, 86% 10%);
  --meteo-ripeti: no-repeat;
  --meteo-forza: 0.95;
}

/* Stanco: notte di nebbia, luci spente, la palpebra che scende dall'alto */
.umore-stanco {
  --tratto: #4a4f5c;
  --sole: transparent;
  --luna: transparent;
  --nuvola: #ffffff;
  --sfondo: #edeef0;
  --filtro: grayscale(0.88) contrast(0.82) brightness(0.6) blur(0.7px);
  --tinta: #39405a;
  --tinta-fusione: color;
  --tinta-forza: 0.5;
  --luce: linear-gradient(0deg, rgba(176, 182, 196, 0.55) 0%, rgba(176, 182, 196, 0.18) 45%, rgba(176, 182, 196, 0) 70%),
    linear-gradient(180deg, rgba(8, 10, 18, 0.8) 0%, rgba(8, 10, 18, 0.15) 46%, rgba(8, 10, 18, 0) 62%);
  --luce-forza: 1;
  --meteo: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23g)'/%3E%3C/svg%3E");
  --meteo-misura: 240px 240px;
  --meteo-forza: 0.2;
}

/* Triste: blu freddo, cielo che pesa, pioggia */
.umore-triste {
  --tratto: #2b4e78;
  --sole: transparent;
  --luna: transparent;
  --nuvola: #9db4cf;
  --sfondo: #e6edf5;
  --filtro: saturate(0.45) brightness(0.84) contrast(1.05);
  --tinta: #2b4e78;
  --tinta-fusione: color;
  --tinta-forza: 0.72;
  --luce: linear-gradient(180deg, rgba(8, 22, 46, 0.62) 0%, rgba(8, 22, 46, 0.12) 60%, rgba(8, 22, 46, 0.3) 100%);
  --luce-fusione: multiply;
  --luce-forza: 1;
  --meteo: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' stroke='%23dbe8ff' stroke-linecap='round'%3E%3Cpath stroke-width='1.2' opacity='.55' d='M30 10l-4 22M110 40l-4 22M170 5l-4 22M70 90l-4 22M150 120l-4 22M20 150l-4 22M95 165l-4 22'/%3E%3Cpath stroke-width='.8' opacity='.35' d='M55 30l-3 16M135 80l-3 16M185 150l-3 16M10 85l-3 16M120 180l-3 16'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' stroke='%23dbe8ff' stroke-linecap='round'%3E%3Cpath stroke-width='1.6' opacity='.5' d='M40 20l-6 32M140 100l-6 32M90 150l-6 32M180 40l-6 32'/%3E%3C/svg%3E");
  --meteo-misura: 200px 200px, 340px 340px;
  --meteo-forza: 0.9;
}

/* Arrabbiato: temporale, rosso cupo, contrasto duro, bordi che si chiudono */
.umore-arrabbiato {
  --tratto: #9e2a16;
  --sole: transparent;
  --luna: transparent;
  --nuvola: #5b2a24;
  --sfondo: #f8e6e1;
  --filtro: grayscale(0.55) contrast(1.55) brightness(0.92);
  --tinta: linear-gradient(180deg, #e23a1e 0%, #8a160c 100%);
  --tinta-fusione: multiply;
  --tinta-forza: 0.88;
  --luce: radial-gradient(110% 95% at 50% 50%, rgba(20, 2, 0, 0) 35%, rgba(20, 2, 0, 0.82) 100%);
  --luce-fusione: multiply;
  --luce-forza: 1;
}

.quadro.umore-triste .quadro__meteo {
  animation: pioggia 0.7s linear infinite;
}

.quadro.umore-arrabbiato .quadro__luce {
  animation: pulsa 2.4s ease-in-out infinite alternate;
}

/* Una variante generata ha già la sua luce e il suo meteo: sopra non va nessun velo.
   (Due classi: vince sulle regole .umore-* qui sopra, che ne hanno una.) */
.quadro.quadro--generata {
  --filtro: none;
  --tinta-forza: 0;
  --luce-forza: 0;
  --meteo-forza: 0;
}

.quadro.quadro--generata .quadro__luce,
.quadro.quadro--generata .quadro__meteo {
  animation: none;
}

/* La foto viva: una clip muta a ciclo sopra la foto ferma, visibile solo da quando si muove davvero */
.quadro__clip {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--fuoco, 50% 50%);
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
}

.quadro__clip--parte {
  opacity: 1;
}

@keyframes pioggia {
  to {
    background-position: -36px 200px, -64px 340px;
  }
}

@keyframes pulsa {
  from {
    opacity: 0.82;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .quadro__meteo,
  .quadro__luce {
    animation: none !important;
  }

  .quadro__clip {
    display: none;
  }
}
