/* Claudio l'Amministratore — interfaccia.
   Il condominio in 3D occupa tutto lo schermo; sopra ci sono pochi elementi,
   nei colori dello Studio CAI (carta, bordeaux, ocra). */
@font-face { font-family: "Fraunces"; src: url("../fonts/fraunces-latin-opsz-normal.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("../fonts/manrope-latin-wght-normal.woff2") format("woff2"); font-weight: 200 800; font-style: normal; font-display: swap; }

:root {
  color-scheme: light;
  --carta: #F6EEDD;
  --carta-2: #EDE2CB;
  --inchiostro: #2B1F22;
  --inchiostro-2: #6A5A58;
  --bordeaux: #8B1538;
  --ocra: #D9A441;
  --salvia: #4E7A62;
  --mattone: #B4472E;
  --riga: rgba(43, 31, 34, .16);
  --titoli: "Fraunces", "Iowan Old Style", Georgia, serif;
  --testo: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ombra: 0 8px 24px rgba(43, 20, 15, .26);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: #CFE9F2; color: var(--inchiostro); font-family: var(--testo); font-size: 16px; line-height: 1.45; overflow: hidden; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; -webkit-user-select: none; user-select: none; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--ocra); outline-offset: 2px; }
[hidden] { display: none !important; }

#scena { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------- barra in alto ---------- */
#hud { position: fixed; top: 0; left: 0; right: 0; z-index: 5; display: none; flex-direction: column; gap: 6px; padding: calc(8px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) 0 calc(10px + env(safe-area-inset-left)); pointer-events: none; }
body.gioca #hud { display: flex; }
.hud-r { display: flex; gap: 6px; align-items: stretch; }
.pillola { background: #FFFDF6; border: 1px solid var(--riga); border-radius: 16px; box-shadow: 0 3px 12px rgba(43, 20, 15, .18); min-height: 46px; padding: 5px 12px; display: flex; align-items: center; gap: 8px; font-weight: 800; pointer-events: auto; }
.pillola svg { width: 22px; height: 22px; flex: none; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#h-soldi-p svg { stroke: #2F6B49; } #h-soldi-p .h-num { color: #2F6B49; }
#h-studio-p svg { stroke: var(--bordeaux); } #h-studio-p .h-num { color: var(--bordeaux); }
.h-col { display: flex; flex-direction: column; min-width: 0; }
.h-num { font-family: var(--titoli); font-size: 22px; font-weight: 600; line-height: 1.05; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pillola.salta { animation: salta .22s ease-out; }
@keyframes salta { 50% { transform: scale(1.07); } }
.h-et { font-size: 10px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--inchiostro-2); white-space: nowrap; }
#h-grad-p { min-height: 34px; flex: 1; max-width: 250px; min-width: 0; padding: 4px 12px; border-radius: 999px; }
#b-pratiche, #b-guasti { min-height: 34px; padding: 4px 8px 4px 12px; border-radius: 999px; }
#h-prat, #h-guasti { min-width: 24px; height: 24px; border-radius: 50%; background: var(--carta-2); display: grid; place-items: center; font-size: 13px; font-variant-numeric: tabular-nums; }
#b-pratiche.accesa, #b-guasti.accesa { border-color: var(--mattone); }
#b-pratiche.accesa #h-prat, #b-guasti.accesa #h-guasti { background: var(--mattone); color: #fff; }
.pista { display: block; flex: 1; min-width: 24px; height: 9px; border-radius: 5px; background: var(--carta-2); border: 1px solid var(--riga); overflow: hidden; }
#h-grad-b { display: block; height: 100%; width: 70%; background: #4FA873; transition: width .4s ease, background .4s; }
#h-grad-p.medio #h-grad-b { background: var(--ocra); }
#h-grad-p.basso #h-grad-b { background: var(--mattone); }
#h-grad { font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; font-size: 14px; }
button.pillola { text-align: left; }
/* in sede non c'è una cassa del condominio: restano il compenso dello studio e il menu */
body.in-sede #h-soldi-p, body.in-sede #h-grad-p, body.in-sede #b-pratiche, body.in-sede #b-guasti { display: none; }
#h-studio-p.rosso .h-num { color: var(--mattone); }
#b-menu { margin-left: auto; width: 46px; padding: 0; justify-content: center; }
#b-menu svg { stroke: var(--inchiostro); }
@media (max-width: 400px) { .h-num { font-size: 19px; } .pillola { padding: 5px 9px; gap: 6px; } .pillola svg { width: 19px; height: 19px; } }

/* ---------- suggerimento ---------- */
#suggerimento { position: fixed; z-index: 5; top: calc(98px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: max-content; max-width: min(94vw, 540px); background: rgba(43, 31, 34, .88); color: #FFFDF6; border-radius: 14px; padding: 6px 14px 8px; box-shadow: var(--ombra); display: flex; flex-direction: column; pointer-events: none; text-align: center; }
#suggerimento .h-et { color: #F2C98A; }
#s-testo { font-weight: 700; line-height: 1.25; text-wrap: balance; }
@media (min-width: 1180px) { #suggerimento { top: calc(14px + env(safe-area-inset-top)); } }
@media (max-height: 460px) { #piani { bottom: calc(12px + env(safe-area-inset-bottom)); } #pi-b { flex-direction: row; } .pi-v { flex: 1; } }

/* ---------- avvisi rapidi ---------- */
#avvisi { position: fixed; z-index: 30; bottom: calc(22px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: 92vw; }
.avviso { background: var(--inchiostro); color: var(--carta); font-size: 14px; font-weight: 700; padding: 8px 14px; border-radius: 10px; border-left: 5px solid var(--ocra); box-shadow: 0 4px 12px rgba(0, 0, 0, .3); animation: entra-avviso .25s ease-out; transition: opacity .5s, transform .5s; max-width: 100%; }
.avviso.bene { border-left-color: #7FC29B; }
.avviso.male { border-left-color: #F08A6B; }
.avviso.via { opacity: 0; transform: translateY(8px); }
@keyframes entra-avviso { from { opacity: 0; transform: translateY(12px); } }

/* ---------- numeri che salgono ---------- */
#fluttui { position: fixed; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; }
.fluttua { position: absolute; transform: translate(-50%, -50%); font-family: var(--titoli); font-weight: 700; font-size: 22px; color: #2F6B49; background: rgba(255, 253, 246, .92); border-radius: 999px; padding: 1px 11px 3px; box-shadow: 0 2px 8px rgba(43, 20, 15, .2); animation: sale-via 1.5s ease-out forwards; white-space: nowrap; }
.fluttua.studio { color: var(--bordeaux); font-size: 19px; }
.fluttua.nota { color: var(--inchiostro); font-size: 17px; }
@keyframes sale-via { from { opacity: 0; margin-top: 10px; } 12% { opacity: 1; } 75% { opacity: 1; } to { opacity: 0; margin-top: -50px; } }

/* ---------- scelta del piano (scale e ascensore) ---------- */
#piani { position: fixed; z-index: 7; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(92vw, 340px); background: #FFFDF6; border: 1px solid var(--riga); border-top: 4px solid #3D7FB5; border-radius: 16px; box-shadow: var(--ombra); padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 6px; animation: sale .18s ease-out; }
#pi-b { display: flex; flex-direction: column; gap: 6px; }
.pi-v { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 12px; text-align: left; background: #F3F7FA; border: 1.5px solid #3D7FB5; border-radius: 12px; font-weight: 700; }
.pi-v strong { flex: none; width: 34px; height: 34px; border-radius: 50%; background: #3D7FB5; color: #fff; display: grid; place-items: center; font-size: 15px; }
.pi-v.qui { border-color: var(--riga); background: var(--carta-2); color: var(--inchiostro-2); }
.pi-v.qui strong { background: var(--inchiostro-2); }

/* ---------- leva di movimento ---------- */
#leva { position: fixed; z-index: 6; width: 116px; height: 116px; margin: -58px 0 0 -58px; border-radius: 50%; background: rgba(246, 238, 221, .28); border: 2px solid rgba(246, 238, 221, .75); pointer-events: none; }
#leva-p { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: rgba(246, 238, 221, .92); box-shadow: 0 3px 10px rgba(43, 20, 15, .35); }

#velo { position: fixed; inset: 0; z-index: 40; background: #2B1F22; opacity: 0; pointer-events: none; transition: opacity .25s; }
#velo.su { opacity: 1; }

/* ---------- pannello del menu ---------- */
#pannello { position: fixed; inset: 0; z-index: 45; background: rgba(43, 20, 15, .45); display: flex; justify-content: center; align-items: flex-end; padding: calc(40px + env(safe-area-inset-top)) 8px calc(8px + env(safe-area-inset-bottom)); }
.pannello-f { width: 100%; max-width: 520px; max-height: 100%; background: var(--carta); border-radius: 16px; border-top: 4px solid var(--bordeaux); box-shadow: var(--ombra); display: flex; flex-direction: column; animation: sale .2s ease-out; }
@keyframes sale { from { transform: translateY(24px); opacity: 0; } }
.pannello-t { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px 8px; }
#p-titolo { font-family: var(--titoli); font-size: 24px; line-height: 1.15; font-weight: 600; margin: 0; text-wrap: balance; }
.pannello-t { gap: 12px; } #p-chiudi { flex: none; }
#p-chiudi { background: none; border: 1.5px solid var(--riga); border-radius: 999px; padding: 8px 16px; font-weight: 800; font-size: 13px; min-height: 40px; }
#p-corpo { overflow-y: auto; padding: 4px 16px 18px; display: flex; flex-direction: column; gap: 8px; }
#p-corpo > * { flex: none; }   /* i pannelli lunghi scorrono: le voci non si schiacciano */
#p-corpo p { margin: 0 0 4px; }
#p-corpo h3 { font-family: var(--titoli); font-size: 19px; font-weight: 600; margin: 8px 0 0; padding-top: 8px; border-top: 1px solid var(--riga); }
.voce.ico { display: grid; grid-template-columns: 30px 1fr; column-gap: 10px; align-items: center; }
.voce.ico .ic { grid-row: 1 / span 2; font-size: 23px; line-height: 1; text-align: center; }
.voce.ico small { grid-column: 2; }
.voce.pericolo { border-color: var(--mattone); background: #FFF1EA; color: var(--inchiostro); }
.voce.pericolo small { color: var(--mattone); font-weight: 700; }
.voce.pericolo:not(.ico) { background: #FFFAF0; color: var(--mattone); }
#p-corpo .voce[style*="--set"] { border-left: 6px solid var(--set); }
.tessere { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tessera { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; background: #FFFAF0; border: 1.5px solid var(--riga); border-top: 6px solid var(--set); border-radius: 12px; padding: 10px 12px 12px; min-height: 104px; }
.tessera .ic { font-size: 28px; line-height: 1.1; }
.tessera strong { font-family: var(--titoli); font-size: 16px; font-weight: 600; line-height: 1.15; }
.tessera small { font-size: 12.5px; font-weight: 600; color: var(--inchiostro-2); }
.tessera.attiva { border-color: var(--set); background: #fff; box-shadow: 0 2px 0 var(--set); }
.tessera.attiva small { color: var(--mattone); font-weight: 800; }
.tessera .quanti { position: absolute; top: 8px; right: 8px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; background: var(--mattone); color: #fff; font-size: 13px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
#p-corpo p.spiega { margin: 0 0 6px; padding: 10px 12px; background: #FFFAF0; border: 1.5px dashed var(--riga); border-left: 5px solid var(--set, var(--riga)); border-radius: 12px; font-size: 14.5px; line-height: 1.45; }
#p-corpo p.detto { font-family: var(--titoli); font-size: 19px; line-height: 1.3; font-weight: 600; margin: 2px 0 6px; padding: 8px 12px; background: #FFFAF0; border-left: 4px solid var(--bordeaux); border-radius: 0 10px 10px 0; }
#p-corpo h3:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.righe { list-style: none; margin: 0 0 8px; padding: 0; border-top: 1px solid var(--riga); }
.righe li { display: flex; gap: 10px; justify-content: space-between; padding: 6px 2px; border-bottom: 1px solid var(--riga); font-size: 14.5px; }
.righe li span:last-child { font-weight: 800; font-variant-numeric: tabular-nums; }
.voce { text-align: left; background: #FFFAF0; border: 1.5px solid var(--bordeaux); border-radius: 10px; padding: 10px 14px; min-height: 48px; font-weight: 700; }
.voce small { display: block; font-size: 12.5px; font-weight: 600; color: var(--inchiostro-2); }
.voce:disabled { opacity: .62; cursor: default; }
.voce.secondaria { border-color: var(--riga); font-weight: 600; }
.voce.studio { background: var(--bordeaux); color: #FBF3E4; }
.voce.studio small { color: #EBC9A0; }
.voce.studio:disabled { background: #FFFAF0; color: var(--inchiostro); opacity: .8; }
.voce.studio:disabled small { color: var(--inchiostro-2); }

/* ---------- titolo ---------- */
#titolo { position: fixed; inset: 0; z-index: 50; overflow-y: auto; display: flex; flex-direction: column; justify-content: flex-end; background: linear-gradient(180deg, rgba(246, 238, 221, 0) 0%, rgba(246, 238, 221, .45) 30%, rgba(246, 238, 221, .96) 60%); padding: calc(24px + env(safe-area-inset-top)) calc(22px + env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) calc(22px + env(safe-area-inset-left)); }
.titolo-c { width: 100%; max-width: 620px; margin: 0 auto; }
.bollo { display: inline-block; font-size: 11.5px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--bordeaux); border: 2.5px solid var(--bordeaux); border-radius: 5px; padding: 2px 9px; transform: rotate(-3deg); background: rgba(246, 238, 221, .8); }
#titolo h1 { font-family: var(--titoli); font-weight: 600; font-size: clamp(44px, 13vw, 84px); line-height: .92; letter-spacing: -.02em; margin: 10px 0 12px; text-wrap: balance; font-variation-settings: "opsz" 144; }
#titolo h1 span { color: var(--bordeaux); }
.sottotitolo { font-size: 17px; font-weight: 600; max-width: 46ch; margin: 0 0 18px; }
.t-scelte { display: flex; flex-direction: column; gap: 8px; }
.t-b { text-align: left; border-radius: 12px; padding: 12px 16px; border: 1.5px solid var(--bordeaux); background: #FFFAF0; display: flex; flex-direction: column; min-height: 56px; justify-content: center; }
.t-b strong { font-size: 17px; }
.t-b span { font-size: 13px; color: var(--inchiostro-2); font-weight: 600; }
.t-b.pieno { background: var(--bordeaux); color: #FBF3E4; }
.t-b.pieno span { color: #EBC9A0; }
.carica { font-size: 14px; font-weight: 700; color: var(--mattone); margin: 12px 0 0; }
#titolo footer { font-size: 12px; color: var(--inchiostro-2); margin-top: 18px; padding-top: 10px; border-top: 1px solid var(--riga); max-width: 620px; width: 100%; margin-left: auto; margin-right: auto; }
#titolo footer a { color: inherit; }

/* ---------- accesso con codice ---------- */
#blocco { position: fixed; inset: 0; z-index: 60; background: var(--carta); display: flex; align-items: center; justify-content: center; padding: calc(20px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom)); overflow-y: auto; -webkit-user-select: text; user-select: text; }
.blocco-c { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.blocco-c .bollo { align-self: flex-start; }
.blocco-c h2 { font-family: var(--titoli); font-size: 34px; font-weight: 600; line-height: 1; margin: 6px 0 0; }
.blocco-c p { margin: 0; font-weight: 600; }
#bl-codice { font: 600 34px var(--titoli); letter-spacing: .35em; text-align: center; padding: 12px 8px 12px calc(8px + .35em); border: 1.5px solid var(--bordeaux); border-radius: 12px; background: #FFFAF0; color: var(--inchiostro); width: 100%; min-height: 64px; }
#bl-codice:focus-visible { outline: 3px solid var(--ocra); outline-offset: 2px; }
.blocco-c .t-b { align-items: center; }
.blocco-c .carica { margin: 0; }

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