/* =====================================================================
   Mondo: il globo della geopolitica
   Notte di default (un globo si guarda sul nero), giorno se il sistema
   lo chiede. I colori del globo stanno qui come variabili: app.js li
   legge e li ridisegna quando cambia il tema.
   ===================================================================== */
:root {
  --sfondo: #070b14;
  --sfondo-2: #0b1220;
  --pannello: rgba(12, 19, 33, 0.86);
  --pannello-pieno: #0e1626;
  --bordo: rgba(255, 255, 255, 0.09);
  --bordo-forte: rgba(255, 255, 255, 0.16);
  --testo: #e9eef6;
  --testo-2: #a3afc2;
  --testo-3: #6f7c93;
  --accento: #8bb8ff;
  --accento-2: #5d93f0;
  --ombra: 0 18px 50px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.3);

  /* il globo */
  --oceano-1: #13284a;
  --oceano-2: #060d1a;
  --alone: rgba(96, 156, 255, 0.28);
  --griglia: rgba(160, 190, 255, 0.07);
  --confine: rgba(6, 12, 24, 0.85);
  --contorno: rgba(150, 190, 255, 0.4);
  --scelto: #ffffff;
  --liv-0: #2f7666;
  --liv-1: #a98b3e;
  --liv-2: #da6a30;
  --liv-3: #e24646;
  --nessuno: #3a4559;
  --not-0: #2a3446;
  --not-1: #284f82;
  --not-2: #3a77c8;
  --not-3: #6aa3fb;
  --not-4: #cfe2ff;

  --raggio: 16px;
  --carattere: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --sfondo: #e9eef5;
    --sfondo-2: #dfe6f0;
    --pannello: rgba(255, 255, 255, 0.9);
    --pannello-pieno: #ffffff;
    --bordo: rgba(15, 30, 60, 0.1);
    --bordo-forte: rgba(15, 30, 60, 0.18);
    --testo: #101a2b;
    --testo-2: #46566d;
    --testo-3: #74839a;
    --accento: #2f6fd6;
    --accento-2: #2a62bd;
    --ombra: 0 18px 50px rgba(30, 50, 90, 0.18), 0 2px 8px rgba(30, 50, 90, 0.1);
    --oceano-1: #d6e6fa;
    --oceano-2: #a5c1e6;
    --alone: rgba(70, 130, 230, 0.22);
    --griglia: rgba(20, 50, 110, 0.08);
    --confine: rgba(255, 255, 255, 0.95);
    --contorno: rgba(40, 90, 170, 0.35);
    --scelto: #0b1424;
    --liv-0: #6fb7a0;
    --liv-1: #e8c25f;
    --liv-2: #ee8d52;
    --liv-3: #e05656;
    --nessuno: #c3ccd9;
    --not-0: #cfd7e3;
    --not-1: #9fc0ea;
    --not-2: #5f97e0;
    --not-3: #2f6fd6;
    --not-4: #163f86;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(ellipse at 50% 40%, var(--sfondo-2), var(--sfondo) 70%) fixed, var(--sfondo);
  color: var(--testo);
  font: 15px/1.5 var(--carattere);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
a { color: var(--accento); }
[hidden] { display: none !important; }
.salta { position: absolute; left: -9999px; }
.salta:focus { left: 12px; top: 12px; z-index: 50; background: var(--pannello-pieno); padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }

/* --------------------------------------------------------- testata --- */
.testata {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: max(12px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left));
  background: linear-gradient(to bottom, var(--sfondo) 20%, transparent);
  pointer-events: none;
}
.testata > * { pointer-events: auto; }
.marchio { display: flex; align-items: center; gap: 9px; color: var(--testo); text-decoration: none; }
.marchio-ic { width: 26px; height: 26px; fill: none; stroke: var(--accento); stroke-width: 1.6; }
.marchio-t { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.sottotitolo { margin: 0; color: var(--testo-3); font-size: 13px; white-space: nowrap; }

.cerca { position: relative; margin-left: auto; width: min(380px, 40vw); }
.cerca svg { position: absolute; z-index: 1; pointer-events: none; left: 12px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); fill: none; stroke: var(--testo-3); stroke-width: 2; stroke-linecap: round; }
.cerca input {
  width: 100%; height: 40px; padding: 0 38px 0 38px;
  border: 1px solid var(--bordo-forte); border-radius: 12px;
  background: var(--pannello); color: var(--testo); font: inherit;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: border-color .15s, box-shadow .15s;
}
.cerca input::placeholder { color: var(--testo-3); }
.cerca input:focus { outline: none; border-color: var(--accento); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accento) 25%, transparent); }
.cerca input::-webkit-search-cancel-button { display: none; }
.cerca kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font: 11px var(--carattere); color: var(--testo-3); border: 1px solid var(--bordo-forte); border-radius: 5px; padding: 1px 6px; }
.cerca input:focus ~ kbd { display: none; }
.suggerimenti {
  position: absolute; top: 46px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none;
  background: var(--pannello-pieno); border: 1px solid var(--bordo-forte); border-radius: 12px; box-shadow: var(--ombra);
  max-height: 60vh; overflow: auto;
}
.suggerimenti li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.suggerimenti li[aria-selected="true"], .suggerimenti li:hover { background: color-mix(in srgb, var(--accento) 16%, transparent); }
.suggerimenti .perche { margin-left: auto; color: var(--testo-3); font-size: 12px; }

.modo { display: flex; padding: 3px; border: 1px solid var(--bordo-forte); border-radius: 12px; background: var(--pannello); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.modo button { border: 0; background: none; padding: 6px 12px; border-radius: 9px; font-size: 13px; color: var(--testo-2); cursor: pointer; transition: background .2s, color .2s; }
.modo button[aria-checked="true"] { background: color-mix(in srgb, var(--accento) 22%, transparent); color: var(--testo); }

/* ----------------------------------------------------------- globo --- */
.palco { position: fixed; inset: 0; }
.globo { position: absolute; inset: 0; }
#tela { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#tela.trascina { cursor: grabbing; }
#tela.sopra { cursor: pointer; }
#tela:focus { outline: none; }
#tela:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accento); }

.punti { position: absolute; inset: 0; pointer-events: none; }
.punto {
  position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; padding: 0;
  border: 2px solid #fff; border-radius: 50%; background: var(--accento-2);
  pointer-events: auto; cursor: pointer;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accento) 70%, transparent);
}
.punto.grande { width: 14px; height: 14px; margin: -7px 0 0 -7px; }
.punto::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 2px solid var(--accento); opacity: 0;
  animation: pulsa 2.4s ease-out infinite;
}
.punto.dietro { display: none; }
@keyframes pulsa { 0% { transform: scale(.4); opacity: .9; } 100% { transform: scale(1.9); opacity: 0; } }

.etichetta {
  position: absolute; z-index: 5; pointer-events: none; transform: translate(14px, -50%);
  padding: 6px 10px; border-radius: 9px; background: var(--pannello-pieno); border: 1px solid var(--bordo-forte);
  box-shadow: var(--ombra); font-size: 13px; white-space: nowrap;
}
.etichetta b { font-weight: 600; }
.etichetta .tag { display: inline-flex; align-items: center; gap: 5px; margin-left: 8px; color: var(--testo-2); font-size: 12px; }
.pallino { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.p-0 { background: var(--liv-0); } .p-1 { background: var(--liv-1); } .p-2 { background: var(--liv-2); } .p-3 { background: var(--liv-3); }

.caricamento { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 10px; color: var(--testo-2); }
.ruota { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--bordo-forte); border-top-color: var(--accento); animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }

.comandi { position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); z-index: 10; display: flex; flex-direction: column; gap: 8px; }
.comandi button {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--bordo-forte);
  background: var(--pannello); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  font-size: 20px; line-height: 1; cursor: pointer; display: grid; place-items: center; transition: background .15s, transform .1s;
}
.comandi button:hover { background: var(--pannello-pieno); }
.comandi button:active { transform: scale(.94); }
.comandi svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.comandi button[aria-pressed="true"] { border-color: var(--accento); color: var(--accento); }

.legenda {
  position: fixed; left: max(18px, env(safe-area-inset-left)); bottom: max(18px, env(safe-area-inset-bottom)); z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; max-width: calc(100vw - 100px);
  padding: 9px 13px; border-radius: 12px; border: 1px solid var(--bordo); background: var(--pannello);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); font-size: 12px; color: var(--testo-2);
}
.legenda span { display: inline-flex; align-items: center; gap: 6px; }
.legenda .scala { display: inline-flex; align-items: stretch; gap: 0; width: 110px; height: 9px; border-radius: 5px; overflow: hidden; }
.legenda .scala i { flex: 1; }
.legenda .quando { color: var(--testo-3); }

/* -------------------------------------------------------- laterale --- */
.laterale {
  position: fixed; left: max(18px, env(safe-area-inset-left)); top: 76px; bottom: 74px; z-index: 10;
  width: 268px; display: flex; flex-direction: column;
  border: 1px solid var(--bordo); border-radius: var(--raggio); background: var(--pannello);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: var(--ombra);
}
.laterale-apri { display: none; }
.laterale-corpo { overflow: auto; padding: 14px 10px 12px; scrollbar-width: thin; }
.laterale h2 { margin: 6px 8px 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--testo-3); }
.laterale section + section { margin-top: 12px; }
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { margin: 0; }
.lista button {
  width: 100%; display: flex; align-items: center; gap: 9px; padding: 7px 8px; border: 0; border-radius: 9px;
  background: none; text-align: left; cursor: pointer; transition: background .15s;
}
.lista button:hover, .lista button:focus-visible { background: color-mix(in srgb, var(--accento) 13%, transparent); }
.lista .nome { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lista .conta { font-size: 12px; color: var(--testo-2); font-variant-numeric: tabular-nums; }
.lista .conta b { color: var(--testo); font-weight: 600; }
.lista .barra { width: 34px; height: 4px; border-radius: 2px; background: var(--bordo); overflow: hidden; }
.lista .barra i { display: block; height: 100%; background: var(--accento-2); }
.lista.compatta { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 4px; }
.lista.compatta button { width: auto; padding: 4px 9px; border: 1px solid var(--bordo); font-size: 13px; gap: 6px; }
.lista .vuoto { padding: 6px 8px; color: var(--testo-3); font-size: 13px; }
.fonte-dati { margin: 16px 8px 2px; color: var(--testo-3); font-size: 11.5px; line-height: 1.45; }

/* ---------------------------------------------- la mini finestra --- */
.scheda {
  position: fixed; right: max(18px, env(safe-area-inset-right)); top: 76px; bottom: 18px; z-index: 30;
  width: min(430px, calc(100vw - 36px)); display: flex; flex-direction: column;
  border: 1px solid var(--bordo-forte); border-radius: var(--raggio); background: var(--pannello);
  backdrop-filter: blur(20px) saturate(1.2); -webkit-backdrop-filter: blur(20px) saturate(1.2);
  box-shadow: var(--ombra);
  animation: entra .26s cubic-bezier(.2, .8, .2, 1);
}
@keyframes entra { from { opacity: 0; transform: translateX(18px) scale(.985); } }
.scheda.cambia .scheda-corpo { animation: sfuma .25s ease; }
@keyframes sfuma { from { opacity: .2; } }
.scheda-maniglia { display: none; }
.scheda-testa { display: flex; align-items: flex-start; gap: 12px; padding: 16px 16px 12px 18px; border-bottom: 1px solid var(--bordo); }
.bandiera { font-size: 34px; line-height: 1; margin-top: 1px; }
.bandiera:empty { display: none; }
.scheda-titoli { flex: 1; min-width: 0; }
.scheda h2 { margin: 0; font-size: 22px; line-height: 1.2; letter-spacing: -0.01em; }
.scheda-sotto { margin: 3px 0 0; color: var(--testo-2); font-size: 13px; }
.chiudi { flex: none; width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--bordo); background: none; cursor: pointer; display: grid; place-items: center; }
.chiudi:hover { background: color-mix(in srgb, var(--testo) 8%, transparent); }
.chiudi svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.scheda-corpo { overflow: auto; padding: 14px 18px 18px; overscroll-behavior: contain; scrollbar-width: thin; }

.territorio { margin: 0 0 12px; padding: 9px 12px; border-radius: 10px; background: color-mix(in srgb, var(--accento) 12%, transparent); font-size: 13.5px; }
.livello { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px 4px 9px; border-radius: 99px; font-size: 12.5px; font-weight: 600; border: 1px solid var(--bordo-forte); }
.livello.l-0 { color: var(--liv-0); } .livello.l-1 { color: var(--liv-1); } .livello.l-2 { color: var(--liv-2); } .livello.l-3 { color: var(--liv-3); }
.livello .pallino { box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent); background: currentColor; }
.sintesi { margin: 12px 0 4px; font-size: 16.5px; line-height: 1.5; font-weight: 500; text-wrap: pretty; }

.scheda section { margin-top: 18px; }
.scheda h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 11.5px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--testo-3); }
.scheda h3 .nota { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 500; }
.testo p { margin: 0 0 10px; color: var(--testo); line-height: 1.6; text-wrap: pretty; }
.testo p:last-child { margin-bottom: 0; }

.oggi { padding: 13px 14px; border-radius: 13px; border: 1px solid color-mix(in srgb, var(--accento) 35%, var(--bordo)); background: color-mix(in srgb, var(--accento) 8%, transparent); }
.oggi h3 { color: var(--accento); margin-bottom: 9px; }
.oggi-pallino { width: 7px; height: 7px; border-radius: 50%; background: var(--accento); box-shadow: 0 0 0 0 var(--accento); animation: respira 2s ease-in-out infinite; }
@keyframes respira { 50% { box-shadow: 0 0 0 5px transparent; opacity: .55; } }
.oggi-quando { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--testo-3); }
.oggi ul { margin: 0 0 10px; padding-left: 18px; }
.oggi li { margin-bottom: 5px; line-height: 1.5; }
.oggi p { margin: 0; line-height: 1.6; }
.oggi .tendenza { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 9px; font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 99px; }
.tendenza.peggiora { color: var(--liv-3); background: color-mix(in srgb, var(--liv-3) 14%, transparent); }
.tendenza.stabile { color: var(--testo-2); background: color-mix(in srgb, var(--testo-2) 12%, transparent); }
.tendenza.migliora { color: var(--liv-0); background: color-mix(in srgb, var(--liv-0) 16%, transparent); }
.oggi .piccolo { margin-top: 10px; font-size: 12px; color: var(--testo-3); }
.oggi .attesa { display: flex; align-items: center; gap: 10px; color: var(--testo-2); }
.oggi .vecchio { opacity: .75; }

.fronti { margin: 0; padding: 0; list-style: none; counter-reset: f; }
.fronti li { counter-increment: f; display: flex; gap: 10px; padding: 7px 0; border-top: 1px solid var(--bordo); line-height: 1.4; }
.fronti li:first-child { border-top: 0; }
.fronti li::before { content: counter(f); flex: none; width: 21px; height: 21px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; font-weight: 700; color: var(--testo-2); border: 1px solid var(--bordo-forte); }

.due { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.leader { margin: 0; padding: 0; list-style: none; font-size: 13.5px; }
.leader li { margin-bottom: 6px; line-height: 1.35; }
.leader .carica { display: block; color: var(--testo-3); font-size: 12px; }
.gettoni { display: flex; flex-wrap: wrap; gap: 5px; }
.gettoni span { padding: 3px 8px; border-radius: 7px; border: 1px solid var(--bordo-forte); font-size: 12px; color: var(--testo-2); }

.notizie ul { margin: 0; padding: 0; list-style: none; }
.notizie li { border-top: 1px solid var(--bordo); }
.notizie li:first-child { border-top: 0; }
.notizie a { display: block; padding: 9px 0; color: var(--testo); text-decoration: none; }
.notizie a:hover .tit { color: var(--accento); }
.notizie .tit { display: block; line-height: 1.4; font-size: 14px; }
.notizie .meta { display: flex; gap: 8px; margin-top: 3px; color: var(--testo-3); font-size: 12px; }
.notizie .lingua { border: 1px solid var(--bordo-forte); border-radius: 4px; padding: 0 4px; font-size: 10.5px; }
.notizie .nessuna { padding: 6px 0; color: var(--testo-3); font-size: 13.5px; }
.scheda-piede { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--bordo); color: var(--testo-3); font-size: 12px; line-height: 1.5; }

/* ----------------------------------------------------------- avviso --- */
.avviso {
  position: fixed; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 14px; padding: 10px 10px 10px 16px; border-radius: 14px;
  background: var(--pannello-pieno); border: 1px solid var(--bordo-forte); box-shadow: var(--ombra);
  animation: sale .3s ease;
}
@keyframes sale { from { transform: translate(-50%, 20px); opacity: 0; } }
.avviso button { border: 0; border-radius: 10px; padding: 7px 14px; background: var(--accento-2); color: #fff; font-weight: 600; cursor: pointer; }
.senza-js { position: fixed; inset: 40% 0 auto; text-align: center; }

/* --------------------------------------------------------- telefono --- */
@media (max-width: 860px) {
  .sottotitolo { display: none; }
  .testata { flex-wrap: wrap; gap: 10px; padding-bottom: 8px; }
  .cerca { order: 3; width: 100%; margin-left: 0; }
  .modo { margin-left: auto; }
  .modo button { padding: 5px 10px; }
  .legenda { top: 124px; bottom: auto; padding: 6px 10px; gap: 4px 10px; font-size: 11px; }
  .legenda .quando { display: none; }
  body:has(.scheda:not([hidden])) .legenda { display: none; }
  .comandi { bottom: 84px; }
  .comandi #centro { display: none; }

  .laterale { top: auto; bottom: max(14px, env(safe-area-inset-bottom)); left: 14px; right: 70px; width: auto; max-height: 56vh; }
  .laterale-apri { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border: 0; background: none; font-weight: 600; cursor: pointer; }
  .laterale-apri::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--testo-2); border-bottom: 2px solid var(--testo-2); transform: rotate(-135deg); margin-top: 4px; transition: transform .2s; }
  .laterale-apri[aria-expanded="true"]::after { transform: rotate(45deg); margin-top: -4px; }
  .laterale-conta { margin-left: auto; color: var(--testo-3); font-weight: 400; font-size: 13px; }
  .laterale-corpo { display: none; padding-top: 0; }
  .laterale.aperta .laterale-corpo { display: block; }

  .scheda {
    left: 0; right: 0; top: auto; bottom: 0; width: 100%; height: 58vh;
    border-radius: 20px 20px 0 0; border-bottom: 0;
    animation: alzati .3s cubic-bezier(.2, .8, .2, 1);
    padding-bottom: env(safe-area-inset-bottom);
    transition: height .28s cubic-bezier(.2, .8, .2, 1);
  }
  /* la testata resta sopra (sta fuori dal palco): la finestra alzata si ferma sotto */
  .scheda.alta { height: calc(100vh - 122px); height: calc(100dvh - 122px); }
  @keyframes alzati { from { transform: translateY(40%); opacity: 0; } }
  .scheda-maniglia { display: block; position: relative; z-index: 1; height: 24px; flex: none; cursor: grab; touch-action: none; }
  .scheda-maniglia::before { content: ""; position: absolute; left: 50%; top: 9px; width: 44px; height: 5px; border-radius: 3px; background: var(--bordo-forte); transform: translateX(-50%); }
  .scheda-testa { padding-top: 0; }
  .due { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .punto::after, .oggi-pallino { animation: none; }
  .scheda { animation: sfuma .2s ease; }
  .scheda.cambia .scheda-corpo { animation: none; }
}
