/* =========================================================
   SALOTTO ITALIA — stile VHS / vaporwave / web 1.0
   ========================================================= */

:root {
  --bg: #1e2131;           /* blu notte del logo */
  --amber: #e2bd72;         /* giallo "televideo" */
  /* colori del logo: viola -> blu -> verde acqua, con il rosso della scritta */
  --logo-violet: #5b3a9e;
  --logo-blue: #4d63c9;
  --logo-teal: #3d9e9a;
  --logo-red: #e8262b;
  --accent: #7fd3d6;        /* azzurro, meno acceso della prima versione */
  --accent-2: #d985c4;      /* rosa, meno acceso della prima versione */
  --osd: #ecebe4;
  --osd-green: #9fd8a8;
  --panel: rgba(18, 16, 14, 0.78);
  --gray: #bdbab0;          /* grigio finestra anni '90, un po' ingiallito */
  --pixel: "VT323", "Courier New", monospace;
  --pixel-hard: "Press Start 2P", "VT323", monospace;

  /* --- Sfondo desktop 16:9 (1672×941) --- */
  --img-ratio: 1.7768;            /* larghezza / altezza */
  --tv-left: 47.4%;               /* posizione dello schermo trasparente */
  --tv-top: 28.2%;
  --tv-width: 16.8%;
  --tv-height: 21.8%;
  --focus-x: 0.558;               /* punto da tenere al centro quando lo sfondo viene ritagliato */
  /* posizione del "buco" dell'effetto CRT = left/(100-width), top/(100-height) */
  --tv-mask-x: 56.97%;
  --tv-mask-y: 36.06%;
}

/* --- Sfondo tablet 4:3 (1448×1086): schermi tra 3:4 e 3:2 --- */
@media (min-aspect-ratio: 3/4) and (max-aspect-ratio: 3/2) {
  :root {
    --img-ratio: 1.3333;
    --tv-left: 46.1%;
    --tv-top: 26.6%;
    --tv-width: 18.0%;
    --tv-height: 19.2%;
    --focus-x: 0.551;
    --tv-mask-x: 56.22%;
    --tv-mask-y: 32.92%;
  }
}

/* --- Sfondo smartphone 9:16 (941×1672): schermi più stretti di 3:4 --- */
@media (max-aspect-ratio: 3/4) {
  :root {
    --img-ratio: 0.5628;
    --tv-left: 30.2%;
    --tv-top: 27.6%;
    --tv-width: 45.0%;
    --tv-height: 20.5%;
    --focus-x: 0.42;                /* spostato a sinistra per lasciar vedere la finestra con il Duomo */
    --tv-mask-x: 54.91%;
    --tv-mask-y: 34.72%;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--osd);
  font-family: var(--pixel);
  overflow: hidden;
  -webkit-font-smoothing: none;
}

/* ---------------------------------------------------------
   Stanza: lo sfondo copre tutto lo schermo mantenendo le
   proporzioni, così lo schermo della TV non si sposta mai
   --------------------------------------------------------- */
.room {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.stage {
  --vw: 100vw;
  --vh: 100dvh;
  position: absolute;
  width: max(var(--vw), calc(var(--vh) * var(--img-ratio)));
  aspect-ratio: var(--img-ratio);
  /* centra sul punto focale (la TV) senza mai lasciare bordi vuoti */
  left: clamp(calc(var(--vw) - max(var(--vw), calc(var(--vh) * var(--img-ratio)))),
              calc(var(--vw) / 2 - max(var(--vw), calc(var(--vh) * var(--img-ratio))) * var(--focus-x)),
              0px);
  top: 50%;
  transform: translateY(-50%);
}

.stage picture,
.stage__bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 2;
  pointer-events: none;
  user-select: none;
  filter: saturate(.98) contrast(1) sepia(.05) blur(.3px);   /* foto un po' "lavata", come una VHS registrata più volte */
}

/* ---------------------------------------------------------
   La TV: il video sta dietro lo sfondo
   --------------------------------------------------------- */
.tv {
  position: absolute;
  left: calc(var(--tv-left) - 0.4%);
  top: calc(var(--tv-top) - 0.4%);
  width: calc(var(--tv-width) + 0.8%);
  height: calc(var(--tv-height) + 0.8%);
  z-index: 1;
  background: #000;
  overflow: hidden;
  container-type: size;
}

.tv iframe,
#player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none;           /* niente interfaccia YouTube al passaggio del mouse */
  filter: none;                   /* nessun effetto CRT sul video: immagine pulita */
}

/* neve tra un canale e l'altro */
.tv__static {
  position: absolute;
  inset: -50%;
  opacity: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 160px 160px;
  transition: opacity .25s;
}
.tv__static.is-on {
  opacity: 1;
  animation: static-move .12s steps(3) infinite;
}

.tv__osd {
  position: absolute;
  font-family: var(--pixel);
  color: var(--osd-green);
  text-shadow: 2px 2px 0 #000, 0 0 5px rgba(159,216,168,.55);
  pointer-events: none;
  letter-spacing: .05em;
  line-height: 1;
}
.tv__osd--ch {
  top: 9cqh;
  right: 10cqw;
  font-size: 14cqh;
  opacity: 0;
  transition: opacity .3s;
}
.tv__osd--ch.is-on { opacity: 1; }
.tv__msg {
  position: absolute;
  inset: 18cqh 10cqw;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 8.5cqh;
  line-height: 1.1;
  color: #fff;
  background: #0018a8;            /* il classico blu "nessun segnale" */
  padding: 4cqh 4cqw;
  text-shadow: 2px 2px 0 #000;
}
.tv__msg[hidden] { display: none; }

/* bottone audio, sopra lo schermo */
.unmute {
  position: absolute;
  z-index: 3;
  left: calc(var(--tv-left) + var(--tv-width) / 2);
  top: calc(var(--tv-top) + var(--tv-height) * 0.78);
  transform: translateX(-50%);
  font: inherit;
  font-size: clamp(14px, 1.3vw, 22px);
  color: #fff;
  background: rgba(0, 0, 0, .7);
  border: 1px solid var(--accent);
  padding: .2em .6em;
  cursor: pointer;
  white-space: nowrap;
  animation: blink 1.6s steps(1) infinite;
}
.unmute[hidden] { display: none; }

/* ---------------------------------------------------------
   Barra in alto (tipo vecchio sistema operativo)
   --------------------------------------------------------- */
.topbar {
  position: fixed;
  z-index: 10;
  top: 0; left: 0; right: 0;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  padding-top: env(safe-area-inset-top);
  font-size: 20px;
  color: #fff;
  background: linear-gradient(90deg, var(--logo-violet), var(--logo-blue) 55%, var(--logo-teal));
  border-bottom: 2px solid var(--bg);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 2px 0 rgba(0,0,0,.35);
  white-space: nowrap;
}
.topbar__logo { width: 22px; height: 22px; border-radius: 50%; image-rendering: pixelated; }

/* menu a tendina sul logo, tipo menu Mela dei vecchi Mac */
.menu { position: relative; height: 100%; display: flex; align-items: center; }
.menu__btn {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 100%;
  padding: 0 6px;
  margin-left: -6px;
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}
.menu__arrow { font-size: 14px; line-height: 1; }
.menu__btn:hover,
.menu__btn[aria-expanded="true"] { background: rgba(30,33,49,.55); }
.menu__list {
  position: absolute;
  top: 100%;
  left: -6px;
  margin: 2px 0 0;
  padding: 3px 0;
  min-width: 220px;
  list-style: none;
  background: var(--bg);
  border: 1px solid #000;
  box-shadow: 0 0 0 2px var(--logo-blue), 4px 4px 0 rgba(0,0,0,.55);
  font-size: 20px;
  z-index: 30;
}
.menu__list[hidden] { display: none; }
.menu__list a {
  display: block;
  padding: 3px 16px;
  color: var(--osd);
  text-decoration: none;
}
.menu__list a:hover,
.menu__list a:focus-visible {
  background: linear-gradient(90deg, var(--logo-violet), var(--logo-blue));
  color: #fff;
  outline: none;
}
.menu__sep { height: 1px; margin: 4px 8px; background: rgba(255,255,255,.2); }
.topbar__title { font-family: var(--pixel-hard); font-size: 10px; letter-spacing: .05em; text-shadow: 2px 2px 0 var(--bg); }
.topbar__title::after { content: " ミラノ²"; font-family: var(--pixel); font-size: 18px; color: var(--logo-red); text-shadow: 1px 1px 0 var(--bg); }
.topbar__sep { opacity: .6; }
.topbar__now { flex: 1; overflow: hidden; text-overflow: ellipsis; text-shadow: 1px 1px 0 var(--bg); }
.topbar__clock {
  font-variant-numeric: tabular-nums;
  padding: 0 8px;
  background: rgba(30,33,49,.45);
  border: 1px solid; border-color: rgba(0,0,0,.45) rgba(255,255,255,.35) rgba(255,255,255,.35) rgba(0,0,0,.45);   /* orologio "incassato" */
}

/* ---------------------------------------------------------
   Telecomando + social
   --------------------------------------------------------- */
.remote {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: calc(44px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px 12px 12px;
  background: rgba(30, 33, 49, .8);      /* il blu notte del logo */
  border: 1px solid #000;
  box-shadow: 0 0 0 2px var(--logo-blue), 4px 4px 0 rgba(0,0,0,.5);
  backdrop-filter: blur(2px);
  max-width: calc(100vw - 24px);
}

.remote__logo {
  width: 88px;
  height: 88px;
  flex: none;
  display: block;
}
.remote__body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.remote__row { display: flex; gap: 8px; }

.btn {
  font: inherit;
  font-size: 20px;
  color: #000;
  background: var(--gray);
  border: 2px solid;
  border-color: #f2f0e8 #5a574f #5a574f #f2f0e8;    /* bottone in rilievo anni '90 */
  padding: 2px 12px;
  cursor: pointer;
}
.btn:active { border-color: #5a574f #f2f0e8 #f2f0e8 #5a574f; transform: translateY(1px); }
.btn:hover { background: #cfccc2; }

.socials {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 10px;
}

.social {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 84px;
  padding: 8px 4px 6px;
  color: var(--osd);
  text-decoration: none;
  font-size: 17px;
  letter-spacing: .05em;
  border: 2px solid transparent;
  transition: transform .1s steps(2);
}
.social svg {
  width: 38px;
  height: 38px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
  filter: drop-shadow(2px 0 0 rgba(217,133,196,.7)) drop-shadow(-2px 0 0 rgba(127,211,214,.7));   /* sbavatura VHS */
}
.social svg path:not(.dot) { fill: currentColor; stroke: none; }
.social svg .dot { fill: currentColor; stroke: none; }
.social:hover,
.social:focus-visible {
  color: var(--accent);
  border-color: rgba(127,211,214,.55);
  background: rgba(127,211,214,.06);
  outline: none;
}
.social:hover span { text-decoration: underline; }

/* ---------------------------------------------------------
   Striscia scorrevole in fondo
   --------------------------------------------------------- */
.ticker {
  position: fixed;
  z-index: 10;
  left: 0; right: 0; bottom: 0;
  height: calc(30px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  overflow: hidden;
  background: #000;
  border-top: 2px solid var(--logo-blue);
  color: var(--amber);
  font-size: 22px;
  line-height: 28px;
  white-space: nowrap;
}
.ticker__track {
  display: inline-flex;
  animation: marquee 40s linear infinite;
}

/* ---------------------------------------------------------
   Effetti VHS a tutto schermo
   --------------------------------------------------------- */
.fx {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}
/* Righe CRT, banda e grana: solo sulla stanza, con un "buco" esatto sullo schermo della TV */
.crt {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,.10) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 50%, rgba(18,14,30,.5) 100%);   /* vignettatura ai bordi */
  -webkit-mask: linear-gradient(#000 0 0), linear-gradient(#000 0 0) var(--tv-mask-x) var(--tv-mask-y) / var(--tv-width) var(--tv-height) no-repeat;
  -webkit-mask-composite: xor;
          mask: linear-gradient(#000 0 0) exclude, linear-gradient(#000 0 0) var(--tv-mask-x) var(--tv-mask-y) / var(--tv-width) var(--tv-height) no-repeat;
}
.crt::after {          /* la banda che scorre del nastro, più tenue */
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 14%;
  background: linear-gradient(to bottom, transparent, rgba(255,255,255,.025) 45%, rgba(255,255,255,.045) 50%, transparent);
  animation: roll-crt 9s linear infinite;
}
.crt__noise {
  position: absolute;
  inset: -100%;
  opacity: .05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: static-move .3s steps(4) infinite;
}
.fx--vignette {
  background: radial-gradient(ellipse at center, transparent 50%, rgba(18,14,30,.6) 100%);
}

/* ---------------------------------------------------------
   Animazioni
   --------------------------------------------------------- */
@keyframes blink { 50% { opacity: 0; } }
@keyframes marquee { to { transform: translateX(-50%); } }
@keyframes roll-crt { from { top: -15%; } to { top: 110%; } }
@keyframes static-move {
  0% { transform: translate(0, 0); }
  33% { transform: translate(-7%, 4%); }
  66% { transform: translate(5%, -6%); }
  100% { transform: translate(-3%, 8%); }
}
/* piccolo "salto" del tracking ogni tanto */
@keyframes tracking {
  0%, 96%, 100% { filter: none; }
  97% { filter: hue-rotate(-6deg); margin-left: 2px; }
  98% { filter: hue-rotate(5deg); margin-left: -1px; }
}

@media (prefers-reduced-motion: reduce) {
  .stage, .crt__noise, .crt::after, .ticker__track, .tv__static.is-on { animation: none; }
}

/* ---------------------------------------------------------
   Smartphone
   --------------------------------------------------------- */
@media (max-width: 600px) {
  .topbar { font-size: 17px; gap: 8px; }
  .topbar__title, .topbar__sep { display: none; }
  .remote { bottom: calc(40px + env(safe-area-inset-bottom)); padding: 8px; gap: 8px; }
  .remote__logo { width: 54px; height: 54px; }
  .remote__body { gap: 6px; }
  .btn { font-size: 16px; padding: 1px 6px; }
  .socials { gap: 2px; }
  .social { width: 60px; font-size: 13px; padding: 5px 2px 4px; }
  .social svg { width: 26px; height: 26px; }
  .topbar__title::after { content: none; }
  .ticker { font-size: 19px; }
  .unmute { font-size: 13px; }
}
