/* CIELO CGFA — atlante celeste da usare al buio */
@font-face { font-family: 'Instrument Sans'; src: url(font/sans.woff2) format('woff2'); font-weight: 400 700; font-display: swap; }
@font-face { font-family: 'Instrument Serif'; src: url(font/serif.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Instrument Serif'; src: url(font/serif-it.woff2) format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  --inchiostro: #05070d; --notte: #0a0f1c; --notte2: #131b2f; --filo: #24314f; --filo2: #33446a;
  --testo: #ece4d2; --tenue: #aaa18f; --ambra: #f2b45a; --ambra-fondo: #2c2214; --ghiaccio: #9fdcff; --corallo: #ff8a6a; --verde: #9fe0a8;
  --serif: 'Instrument Serif', Georgia, serif; --sans: 'Instrument Sans', system-ui, sans-serif;
  --sopra: env(safe-area-inset-top, 0px); --sotto: env(safe-area-inset-bottom, 0px);
  --tab: 64px; --r: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--inchiostro); color: var(--testo); font: 400 15px/1.45 var(--sans); overflow: hidden; overscroll-behavior: none; }
::selection { background: var(--ambra); color: var(--inchiostro); }
:focus-visible { outline: 2px solid var(--ambra); outline-offset: 2px; border-radius: 8px; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select { font: inherit; color: var(--testo); caret-color: var(--ambra); accent-color: var(--ambra); }
a { color: var(--ambra); text-underline-offset: 3px; }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.num { font-variant-numeric: tabular-nums; }

#cam { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
#cielo { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; touch-action: none; display: block; }

/* barra in alto */
.barra { position: fixed; z-index: 5; top: calc(var(--sopra) + 10px); left: 10px; right: 10px; display: flex; gap: 8px; align-items: center; pointer-events: none; }
.barra > * { pointer-events: auto; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 13px 0 11px; border-radius: 20px; background: rgba(10,15,28,.86); border: 1px solid var(--filo); font-weight: 600; font-size: 14px; max-width: 46vw; }
.pill span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill svg.i { width: 18px; height: 18px; color: var(--ambra); }
.live { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--verde); }
.live.passato { color: var(--corallo); }
.barra .dx { margin-left: auto; display: flex; gap: 8px; }
.ico { width: 40px; height: 40px; border-radius: 20px; display: grid; place-items: center; background: rgba(10,15,28,.86); border: 1px solid var(--filo); }
.ico[aria-pressed="true"] { background: var(--ambra); color: var(--inchiostro); border-color: var(--ambra); }

/* mirino AR e freccia */
.mirino { position: fixed; z-index: 4; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border: 1.5px solid rgba(242,180,90,.8); border-radius: 50%; pointer-events: none; }
.mirino::after { content: ''; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; border-radius: 50%; background: var(--ambra); }
.guardi { position: fixed; z-index: 4; left: 50%; top: calc(50% + 34px); transform: translateX(-50%); padding: 5px 12px; border-radius: 12px; background: rgba(10,15,28,.86); font: italic 400 19px/1.2 var(--serif); color: var(--ambra); white-space: nowrap; pointer-events: none; }
.freccia { position: fixed; z-index: 4; left: 50%; top: 50%; width: 120px; height: 120px; margin: -60px; pointer-events: none; }
.freccia svg { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px; color: var(--ambra); filter: drop-shadow(0 2px 6px rgba(0,0,0,.6)); }
.freccia b { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); font-size: 13px; font-weight: 600; white-space: nowrap; background: rgba(10,15,28,.86); padding: 3px 10px; border-radius: 10px; }

/* barra in basso */
.tab { position: fixed; z-index: 8; left: 0; right: 0; bottom: 0; height: calc(var(--tab) + var(--sotto)); padding-bottom: var(--sotto); display: grid; grid-template-columns: repeat(5, 1fr); background: var(--notte); border-top: 1px solid var(--filo); }
.tab button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; font-weight: 600; color: var(--tenue); }
.tab button[aria-current="true"] { color: var(--ambra); }
.tab button[aria-current="true"] svg.i { stroke-width: 2.1; }

/* pannello (foglio dal basso, a destra sui computer) */
.pannello { position: fixed; z-index: 7; left: 0; right: 0; bottom: calc(var(--tab) + var(--sotto)); max-height: calc(100% - var(--tab) - var(--sotto) - var(--sopra) - 64px); height: 72%;
  background: var(--notte); border-top: 1px solid var(--filo); border-radius: 22px 22px 0 0; display: flex; flex-direction: column; box-shadow: 0 -14px 40px rgba(0,0,0,.55);
  transform: translateY(0); transition: transform .32s cubic-bezier(.16,1,.3,1); }
.pannello[hidden] { display: flex; transform: translateY(105%); visibility: hidden; transition: transform .25s ease-in, visibility 0s .25s; }
.pannello .testa { display: flex; align-items: center; gap: 10px; padding: 14px 16px 8px 20px; }
.pannello h2 { margin: 0; font: 400 30px/1.05 var(--serif); letter-spacing: -.01em; flex: 1; }
.pannello .chiudi { width: 40px; height: 40px; border-radius: 20px; display: grid; place-items: center; background: var(--notte2); }
.corpo { overflow-y: auto; padding: 4px 20px 28px; flex: 1; scrollbar-width: thin; scrollbar-color: var(--filo2) transparent; }
.corpo::-webkit-scrollbar { width: 8px; } .corpo::-webkit-scrollbar-thumb { background: var(--filo2); border-radius: 4px; }
@media (min-width: 900px) {
  .pannello { left: auto; right: 14px; top: calc(var(--sopra) + 64px); bottom: calc(var(--tab) + 14px); width: 420px; height: auto; max-height: none; border: 1px solid var(--filo); border-radius: 22px; }
  .pannello[hidden] { transform: translateX(110%); }
  .scheda { left: auto !important; right: 14px !important; width: 420px; }
}

/* elementi del pannello */
.sotto-tab { display: flex; gap: 6px; margin: 2px 0 14px; overflow-x: auto; scrollbar-width: none; }
.sotto-tab button { flex: none; height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--filo); color: var(--tenue); font-weight: 600; font-size: 14px; }
.sotto-tab button[aria-pressed="true"] { background: var(--ambra-fondo); border-color: var(--ambra); color: var(--ambra); }
h3 { font: 400 22px/1.15 var(--serif); margin: 22px 0 8px; }
h3:first-child { margin-top: 6px; }
.nota { color: var(--tenue); font-size: 13.5px; margin: 4px 0 12px; }
.riga { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--filo); width: 100%; text-align: left; }
.riga:last-child { border-bottom: 0; }
.riga .t { flex: 1; min-width: 0; }
.riga .t b { display: block; font-weight: 600; }
.riga .t small { display: block; color: var(--tenue); font-size: 13px; }
.riga .v { text-align: right; font-weight: 600; font-size: 14px; white-space: nowrap; }
.riga .v small { display: block; font-weight: 400; color: var(--tenue); font-size: 12px; }
button.riga:hover .t b { color: var(--ambra); }
.tappo { width: 36px; height: 36px; border-radius: 18px; display: grid; place-items: center; background: var(--notte2); color: var(--ambra); flex: none; }
.tappo.sat { color: var(--ghiaccio); }
.fascia { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--filo); border: 1px solid var(--filo); border-radius: var(--r); overflow: hidden; margin: 6px 0 4px; }
.fascia > div { background: var(--notte); padding: 10px 12px; }
.fascia > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
.fascia small { display: block; color: var(--tenue); font-size: 12px; }
.fascia b { font-size: 17px; font-weight: 600; }
.bottoni { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn { display: inline-flex; align-items: center; gap: 7px; height: 42px; padding: 0 16px; border-radius: 21px; border: 1px solid var(--filo2); font-weight: 600; font-size: 14px; }
.btn svg.i { width: 18px; height: 18px; }
.bottoni.mini { gap: 6px; } .bottoni.mini .btn { height: 36px; padding: 0 11px; font-size: 13px; gap: 5px; }
.btn.pri { background: var(--ambra); color: var(--inchiostro); border-color: var(--ambra); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:not(:disabled):hover { border-color: var(--ambra); }
.etichetta { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 8px; background: var(--notte2); color: var(--tenue); }
.etichetta.si { background: #1d3322; color: var(--verde); }
.etichetta.sat { background: #142a38; color: var(--ghiaccio); }
.cerca-campo { display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 16px; border-radius: 25px; background: var(--notte2); border: 1px solid var(--filo2); }
.cerca-campo:focus-within { border-color: var(--ambra); }
.cerca-campo input { flex: 1; background: none; border: 0; outline: 0; font-size: 16px; }
.cerca-campo input::placeholder { color: var(--tenue); }
.chip { height: 34px; padding: 0 13px; border-radius: 17px; border: 1px solid var(--filo); font-size: 14px; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.vuoto { padding: 26px 4px; color: var(--tenue); text-align: center; }
.caricamento { display: flex; gap: 10px; align-items: center; color: var(--tenue); padding: 18px 0; }
.caricamento::before { content: ''; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--filo2); border-top-color: var(--ambra); animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
.interruttore { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--filo); }
.interruttore small { display: block; color: var(--tenue); font-size: 13px; }
.interruttore input[type=checkbox] { appearance: none; width: 46px; height: 28px; border-radius: 14px; background: var(--filo); position: relative; flex: none; cursor: pointer; transition: background .2s; }
.interruttore input[type=checkbox]::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--testo); transition: transform .2s cubic-bezier(.16,1,.3,1); }
.interruttore input[type=checkbox]:checked { background: var(--ambra); }
.interruttore input[type=checkbox]:checked::after { transform: translateX(18px); background: var(--inchiostro); }
input[type=range] { width: 100%; }
.campo { width: 100%; height: 44px; padding: 0 12px; border-radius: 12px; background: var(--notte2); border: 1px solid var(--filo2); }
.mappa-mondo { width: 100%; aspect-ratio: 2 / 1; border-radius: var(--r); border: 1px solid var(--filo); display: block; background: #07101f; }
.funzione { padding: 12px 0; border-bottom: 1px solid var(--filo); }
.funzione b { display: block; font-weight: 600; } .funzione span { color: var(--tenue); font-size: 14px; }
.piede { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--filo); color: var(--tenue); font-size: 13px; }
.piede p { margin: 4px 0; }
.piede-admin { font-size: 12px; }
.piede-admin a { color: var(--tenue); }

/* scheda dell'oggetto toccato */
.scheda { position: fixed; z-index: 6; left: 10px; right: 10px; bottom: calc(var(--tab) + var(--sotto) + 10px); background: var(--notte); border: 1px solid var(--filo); border-radius: 20px; padding: 16px 16px 14px 18px;
  box-shadow: 0 12px 34px rgba(0,0,0,.6); max-height: 58%; overflow-y: auto; animation: sale .3s cubic-bezier(.16,1,.3,1); }
@keyframes sale { from { transform: translateY(16px); opacity: .4; } }
.scheda .tipo { font-size: 12.5px; color: var(--tenue); font-weight: 600; }
.scheda h2 { margin: 0 0 2px; font: 400 32px/1.05 var(--serif); padding-right: 44px; }
.scheda h2 em { font-size: 18px; color: var(--tenue); }
.scheda p { margin: 8px 0; max-width: 62ch; }
.scheda .chiudi { position: absolute; top: 10px; right: 10px; width: 38px; height: 38px; border-radius: 19px; display: grid; place-items: center; background: var(--notte2); }

/* pannello del tempo */
.tempo { position: fixed; z-index: 6; left: 10px; right: 10px; top: calc(var(--sopra) + 60px); background: var(--notte); border: 1px solid var(--filo); border-radius: 20px; padding: 14px 16px; box-shadow: 0 12px 34px rgba(0,0,0,.6); max-width: 520px; }
.tempo .quando { font: 400 26px/1.1 var(--serif); }
.tempo .righe2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }

/* guida all'apertura, novità */
.velo { position: fixed; inset: 0; z-index: 20; background: rgba(3,5,10,.9); display: grid; place-items: center; padding: 20px; }
.carta { width: min(440px, 100%); background: var(--notte); border: 1px solid var(--filo); border-radius: 24px; padding: 26px 24px 22px; box-shadow: 0 20px 50px rgba(0,0,0,.6); }
.carta h2 { font: 400 34px/1.05 var(--serif); margin: 0 0 10px; }
.carta p { margin: 0 0 14px; color: var(--testo); }
.punti { display: flex; gap: 6px; margin: 18px 0 4px; }
.punti i { width: 8px; height: 8px; border-radius: 4px; background: var(--filo2); transition: width .3s; }
.punti i.on { width: 22px; background: var(--ambra); }
.marchio { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; font-weight: 700; letter-spacing: .06em; font-size: 13px; color: var(--ambra); }
.marchio img { width: 34px; height: 34px; border-radius: 9px; }

.toast { position: fixed; z-index: 30; left: 50%; top: calc(var(--sopra) + 62px); transform: translateX(-50%); background: var(--notte2); border: 1px solid var(--filo2); padding: 10px 16px; border-radius: 14px; font-weight: 500; max-width: 92vw; box-shadow: 0 10px 30px rgba(0,0,0,.5); }

/* notte rossa: tutto in rosso per non perdere l'adattamento al buio */
#rosso { position: fixed; inset: 0; z-index: 50; pointer-events: none; background: #ff1e0a; mix-blend-mode: multiply; display: none; }
html.rossa #rosso { display: block; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
