/* QBA Live — colori presi dal logo Quality Beer Academy */
:root {
  --amber: #F9B000;
  --amber-dark: #D99A00;
  --amber-soft: #FFF4D6;
  --wine: #A21C3C;
  --wine-dark: #7E1530;
  --ink: #141414;
  --ink-2: #3a3a3a;
  --muted: #6b6760;
  --line: #e7e2d8;
  --bg: #F7F4EE;
  --card: #ffffff;
  --ok: #2E9D5B;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 20, 20, .06), 0 4px 16px rgba(20, 20, 20, .06);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Montserrat", "Arial Black", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.01em; }
a { color: var(--wine); }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .06em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.center-img { display: block; margin: 0 auto; }
[hidden] { display: none !important; }

/* ---------- Componenti ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  font: 600 .95rem/1 var(--font);
  padding: .7em 1.1em; border-radius: 10px;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: var(--wine); border-color: var(--wine); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(0, 0, 0, .05); }
.btn.danger { color: var(--wine); }
.btn.small { font-size: .82rem; padding: .5em .75em; }
.btn.big { font-size: 1.05rem; padding: .85em 1.4em; }
.btn.block { width: 100%; }

input[type=text], input[type=password], input:not([type]), textarea, select {
  width: 100%; font: inherit; color: inherit;
  padding: .7em .85em; border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px rgba(249, 176, 0, .25); }
textarea { resize: vertical; }
label { display: block; font-weight: 600; font-size: .9rem; }
label > input, label > textarea, label > select { margin-top: .35em; font-weight: 400; }
label.check { display: flex; align-items: center; gap: .5em; font-weight: 500; }
label.check input { width: 1.1em; height: 1.1em; accent-color: var(--wine); }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.row form { margin: 0; }
.alert { padding: .75em 1em; border-radius: 10px; font-weight: 500; margin: 0 0 1rem; }
.alert.ok { background: #e6f5ec; color: #1d6b3d; }
.alert.error { background: #fbe9ed; color: var(--wine-dark); }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: .25em .6em; border-radius: 99px; background: #f0ece4; color: var(--ink-2); margin-right: .3em; }
.tag-choice { background: var(--amber-soft); color: #7a5600; }
.tag-yesno { background: #e6f5ec; color: #1d6b3d; }
.tag-open { background: #f8e4e9; color: var(--wine-dark); }
.tag.live { background: var(--wine); color: #fff; }

/* ---------- Admin ---------- */
.admin-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1.5rem; background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.admin-brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); font: 800 1.1rem var(--font-display); }
.admin-brand span { background: var(--wine); color: #fff; padding: .15em .5em; border-radius: 6px; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; }
.admin-bar nav { display: flex; gap: 1.25rem; }
.admin-bar nav a { color: var(--ink-2); text-decoration: none; font-weight: 600; }
.admin-bar nav a.active { color: var(--wine); }
main.wide { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
main.narrow { max-width: 440px; margin: 0 auto; padding: 3rem 1rem; }
.login-page main.narrow { padding-top: 12vh; }
.page-title { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-title h1 { margin: 0; }
.inline-form { display: flex; gap: .5rem; flex: 1; max-width: 520px; }
.empty { text-align: center; color: var(--muted); padding: 3rem 1.5rem; }
.checks { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.checks li { padding: .3em 0 .3em 1.6em; position: relative; }
.checks li::before { position: absolute; left: 0; font-weight: 800; }
.checks li.ok::before { content: "✓"; color: var(--ok); }
.checks li.ko::before { content: "✕"; color: var(--wine); }

.event-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.event-card { position: relative; border-top: 5px solid var(--amber); }
.event-card h2 { font-size: 1.25rem; margin-right: 5.5rem; }
.event-card h2 a { color: var(--ink); text-decoration: none; }
.event-code { position: absolute; top: 1.25rem; right: 1.25rem; font: 700 .85rem ui-monospace, Menlo, monospace; background: var(--ink); color: var(--amber); padding: .3em .6em; border-radius: 6px; letter-spacing: .1em; }

.title-form { display: flex; gap: .5rem; align-items: center; flex: 1; min-width: 260px; }
.title-input { font: 800 1.6rem var(--font-display) !important; border-color: transparent !important; background: transparent !important; padding: .2em .3em !important; }
.title-input:hover { border-color: var(--line) !important; }
.title-input:focus { background: #fff !important; border-color: var(--amber) !important; }

.event-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.5rem; align-items: start; }
.section-title { font-size: 1.05rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.q-list { list-style: none; margin: 0 0 1.5rem; padding: 0; display: grid; gap: .75rem; }
.q-item { padding: 1.1rem 1.25rem; }
.q-head { display: flex; gap: 1rem; align-items: flex-start; }
.q-num { flex: none; width: 2rem; height: 2rem; border-radius: 50%; background: var(--amber); color: var(--ink); display: grid; place-items: center; font-weight: 800; }
.q-main { flex: 1; min-width: 0; }
.q-text { font-size: 1.1rem; font-weight: 600; margin: .4em 0 .2em; }
.q-count { text-align: center; min-width: 4rem; }
.q-count strong { display: block; font-size: 1.5rem; font-family: var(--font-display); }
.q-count span { font-size: .75rem; color: var(--muted); }
.q-actions { display: flex; gap: .25rem; flex-wrap: wrap; margin-top: .75rem; padding-top: .5rem; border-top: 1px dashed var(--line); }
.q-actions form { margin: 0; }
.q-edit summary { cursor: pointer; font-weight: 600; color: var(--wine); margin-top: .5rem; font-size: .9rem; }
.q-edit form { margin-top: 1rem; }
.q-form > * + * { margin-top: 1rem; }
.type-picker { display: flex; gap: .5rem; flex-wrap: wrap; }
.type-opt { flex: 1; min-width: 140px; }
.type-opt input { position: absolute; opacity: 0; pointer-events: none; }
.type-opt span { display: block; text-align: center; padding: .75em; border: 1.5px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 600; transition: all .15s; }
.type-opt input:checked + span { border-color: var(--ink); background: var(--ink); color: #fff; }
.type-opt input:focus-visible + span { box-shadow: 0 0 0 3px rgba(249, 176, 0, .4); }
.danger-zone { margin-top: 2rem; text-align: right; }

.qr-panel { position: sticky; top: 5rem; text-align: center; }
.qr-box { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .5rem; }
.qr-box svg { display: block; width: 100%; height: auto; }
.join-url { font-weight: 700; font-size: 1.05rem; word-break: break-all; margin: .75rem 0 .25rem; }
.join-url a { color: var(--ink); text-decoration: none; }
.qr-panel .stack { margin: 1rem 0; }
.qr-panel .btn { width: 100%; }

@media (max-width: 900px) {
  .event-layout { grid-template-columns: 1fr; }
  .qr-panel { position: static; order: -1; }
  .inline-form { max-width: none; flex-basis: 100%; }
}
@media (max-width: 520px) {
  main.wide { padding: 1.25rem 1rem 3rem; }
  .inline-form { flex-direction: column; }
  .event-grid { grid-template-columns: 1fr; }
  .admin-bar { padding: .6rem 1rem; }
}

/* ---------- Partecipante (mobile) ---------- */
body.participant { background: var(--ink); min-height: 100vh; min-height: 100dvh; }
.p-wrap { max-width: 520px; margin: 0 auto; padding: max(1rem, env(safe-area-inset-top)) 1rem 2rem; min-height: 100dvh; display: flex; flex-direction: column; }
.p-header { display: flex; flex-direction: column; align-items: center; gap: .5rem; padding: .5rem 0 1.25rem; }
.p-logo { height: 54px; width: auto; background: #fff; padding: 8px 12px; border-radius: 12px; }
.p-event { color: rgba(255, 255, 255, .75); font-weight: 600; font-size: .9rem; text-align: center; }
.p-card { background: #fff; border-radius: 20px; padding: 1.5rem 1.25rem; box-shadow: 0 10px 40px rgba(0, 0, 0, .3); border-top: 6px solid var(--amber); }
.p-card.join { text-align: center; margin-top: 4vh; }
.code-input { text-align: center; font: 800 2rem/1 ui-monospace, Menlo, monospace !important; letter-spacing: .25em; text-transform: uppercase; margin: 1rem 0; padding: .6em !important; }
.p-foot { color: rgba(255, 255, 255, .6); text-align: center; font-size: .85rem; min-height: 1.2em; }
.p-qtext { font-size: 1.35rem; margin-bottom: 1rem; }
.p-options { display: grid; gap: .6rem; margin-bottom: 1rem; }
.p-options.yesno { grid-template-columns: 1fr 1fr; }
.p-opt { position: relative; display: flex; align-items: center; gap: .75rem; padding: .9rem 1rem; border: 2px solid var(--line); border-radius: 14px; cursor: pointer; font-weight: 600; font-size: 1.05rem; transition: all .12s; -webkit-tap-highlight-color: transparent; }
.p-opt input { position: absolute; opacity: 0; pointer-events: none; }
.p-opt-letter { flex: none; width: 2.1rem; height: 2.1rem; border-radius: 9px; background: #f0ece4; display: grid; place-items: center; font-weight: 800; }
.p-opt-text { flex: 1; }
.p-opt:has(input:checked) { border-color: var(--ink); background: var(--amber-soft); }
.p-opt:has(input:checked) .p-opt-letter { background: var(--amber); }
.p-opt:has(input:focus-visible) { box-shadow: 0 0 0 3px rgba(249, 176, 0, .4); }
.p-options.yesno .p-opt { flex-direction: column; text-align: center; padding: 1.3rem .5rem; font-size: 1.2rem; }
.p-options.yesno .p-opt-letter { width: 3rem; height: 3rem; font-size: 1.6rem; background: transparent; }
.p-question textarea { font-size: 1.1rem; min-height: 7rem; }
.counter { text-align: right; font-size: .8rem; color: var(--muted); margin: .25rem 0 1rem; }
.p-waiting, .p-done { text-align: center; padding: 2rem .5rem; }
.p-waiting h1, .p-done h1 { font-size: 1.6rem; }
.pulse { width: 64px; height: 64px; margin: 0 auto 1.25rem; border-radius: 50%; background: var(--amber); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(.85); box-shadow: 0 0 0 0 rgba(249, 176, 0, .6); } 50% { transform: scale(1); box-shadow: 0 0 0 18px rgba(249, 176, 0, 0); } }
.check-circle { width: 84px; height: 84px; margin: 0 auto 1.25rem; border-radius: 50%; background: var(--ok); color: #fff; font-size: 2.6rem; display: grid; place-items: center; animation: pop .35s cubic-bezier(.2, 1.6, .4, 1); }
.check-circle.closed { background: var(--muted); }
@keyframes pop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Schermo presentatore ---------- */
body.presenter { background: #fff; overflow: hidden; height: 100vh; }
.stage { height: 100vh; display: grid; grid-template-rows: auto 1fr auto; padding: 2vh 3vw; gap: 1.5vh; position: relative; }
.stage::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 8px; background: linear-gradient(90deg, var(--ink) 0 33.3%, var(--amber) 33.3% 66.6%, var(--wine) 66.6%); }
.st-top { display: flex; justify-content: space-between; align-items: center; gap: 2rem; }
.st-logo { height: clamp(40px, 7vh, 80px); width: auto; }
.st-join { display: flex; align-items: center; gap: 1rem; background: var(--ink); color: #fff; border-radius: 16px; padding: .6rem .6rem .6rem 1.25rem; font-size: clamp(14px, 1.6vw, 26px); }
.st-join-text { display: flex; flex-direction: column; line-height: 1.25; }
.st-join strong { color: var(--amber); }
.st-code { font-size: 1.2em; }
.st-qr-mini { width: clamp(64px, 10vh, 120px); background: #fff; border-radius: 8px; padding: 3px; cursor: zoom-in; }
.st-qr-mini svg, #qr-big svg, .lobby-qr svg { display: block; width: 100%; height: auto; }
.stage.is-lobby .st-join { visibility: hidden; }

.st-body { min-height: 0; display: flex; flex-direction: column; position: relative; }
.st-question { font-size: clamp(24px, 3.6vw, 64px); margin: 1vh 0 .5vh; max-width: 90%; }
.st-question.long { font-size: clamp(20px, 2.6vw, 46px); }
.st-hint { color: var(--muted); font-weight: 600; font-size: clamp(14px, 1.3vw, 22px); margin: 0; }
.st-chart { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; padding: 2vh 0; }
.st-hidden { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; color: var(--muted); font-size: clamp(16px, 2vw, 32px); }
.big-num { font: 900 clamp(80px, 18vh, 220px)/1 var(--font-display); color: var(--ink); }
.st-closed-badge { position: absolute; top: 0; right: 0; background: var(--wine); color: #fff; font-weight: 800; padding: .4em 1em; border-radius: 99px; font-size: clamp(12px, 1.2vw, 20px); text-transform: uppercase; letter-spacing: .06em; }

.st-bottom { display: flex; justify-content: space-between; align-items: center; font-size: clamp(16px, 1.8vw, 30px); color: var(--ink-2); }
.st-count strong { font-family: var(--font-display); font-size: 1.3em; }
.st-progress { color: var(--muted); font-weight: 600; }
.pulse-dot { display: inline-block; width: .55em; height: .55em; border-radius: 50%; background: var(--ok); margin-right: .5em; vertical-align: middle; animation: blink 1.4s infinite; }
.pulse-dot.off { background: var(--muted); animation: none; }
@keyframes blink { 50% { opacity: .3; } }

.st-controls { position: fixed; left: 50%; bottom: 1.5vh; transform: translateX(-50%); display: flex; gap: 2px; align-items: center; background: rgba(20, 20, 20, .92); padding: 6px; border-radius: 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); transition: opacity .4s, transform .4s; z-index: 20; }
.st-controls button, .st-controls a { background: transparent; color: #fff; border: 0; font: 600 14px var(--font); padding: .6em .85em; border-radius: 9px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.st-controls button:hover, .st-controls a:hover { background: rgba(255, 255, 255, .15); }
.st-controls button:disabled { opacity: .3; cursor: default; background: transparent; }
.st-controls button.off { color: var(--amber); }
.st-controls .sep { width: 1px; height: 22px; background: rgba(255, 255, 255, .2); margin: 0 4px; }
body.idle .st-controls { opacity: 0; transform: translate(-50%, 20px); pointer-events: none; }
body.idle { cursor: none; }

.st-overlay { position: fixed; inset: 0; background: rgba(20, 20, 20, .94); display: grid; place-items: center; z-index: 30; cursor: zoom-out; }
.st-overlay.light { background: rgba(247, 244, 238, .97); cursor: default; }
.st-overlay-inner { text-align: center; color: #fff; font-size: clamp(18px, 2.2vw, 36px); }
.st-overlay-inner strong { color: var(--amber); }
#qr-big { width: min(70vh, 70vw); margin: 0 auto 2vh; background: #fff; padding: 1.5vh; border-radius: 20px; }
.st-list { width: min(900px, 90vw); max-height: 85vh; overflow: auto; }
.st-list ol { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.st-list li { background: #fff; padding: 1rem 1.25rem; border-radius: 12px; cursor: pointer; font-size: 1.15rem; font-weight: 600; box-shadow: var(--shadow); display: flex; gap: 1rem; align-items: center; }
.st-list li span { flex: none; width: 2rem; height: 2rem; border-radius: 50%; background: #f0ece4; display: grid; place-items: center; font-size: .9rem; }
.st-list li:hover { outline: 2px solid var(--amber); }
.st-list li.cur { background: var(--ink); color: #fff; }
.st-list li.cur span { background: var(--amber); color: var(--ink); }

.st-toast { position: fixed; top: 3vh; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .7em 1.4em; border-radius: 99px; font-weight: 700; z-index: 40; transition: opacity .4s; }
.st-toast.out { opacity: 0; }

/* Benvenuto */
.lobby { flex: 1; display: flex; align-items: center; justify-content: center; gap: 5vw; }
.lobby-qr { width: min(58vh, 40vw); background: #fff; padding: 1vh; border-radius: 20px; box-shadow: 0 10px 50px rgba(0, 0, 0, .12); border: 6px solid var(--amber); }
.lobby-text { max-width: 40vw; font-size: clamp(18px, 2vw, 34px); }
.lobby-text h1 { font-size: clamp(32px, 4.4vw, 80px); }
.lobby-kicker { color: var(--wine); font-weight: 800; text-transform: uppercase; letter-spacing: .08em; margin: 0 0 .5em; font-size: .75em; }
.lobby-text ol { padding-left: 1.2em; margin: 0 0 1em; }
.lobby-text li { margin: .3em 0; }
.lobby-text strong { color: var(--wine); }

/* Barre */
.ch-bars { display: flex; flex-direction: column; justify-content: center; gap: clamp(8px, 2vh, 28px); height: 100%; }
.bar-row { display: grid; grid-template-columns: minmax(180px, 32%) 1fr 7.5em; align-items: center; gap: 1.5vw; font-size: clamp(16px, 2vw, 34px); }
.bar-label { display: flex; align-items: center; gap: .6em; font-weight: 700; min-width: 0; }
.bar-label span:last-child { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bar-letter { flex: none; width: 1.7em; height: 1.7em; border-radius: .35em; color: #fff; display: grid; place-items: center; font-weight: 800; font-size: .85em; }
.bar-track { height: clamp(26px, 6vh, 72px); background: #f2efe9; border-radius: 10px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 10px; transition: width .7s cubic-bezier(.2, .8, .2, 1); }
.bar-val { display: flex; flex-direction: column; line-height: 1.1; }
.bar-val strong { font-family: var(--font-display); font-size: 1.2em; }
.bar-val small { color: var(--muted); font-size: .6em; }
.bar-row.winner .bar-val strong { color: var(--wine); }

/* Torta */
.ch-pie { display: flex; align-items: center; justify-content: center; gap: 5vw; height: 100%; }
.pie-wrap { position: relative; height: min(56vh, 42vw); aspect-ratio: 1; }
.pie-svg { width: 100%; height: 100%; display: block; }
.pie-lbl { fill: #fff; font: 800 11px var(--font); text-anchor: middle; dominant-baseline: central; paint-order: stroke; stroke: rgba(0, 0, 0, .25); stroke-width: 2px; }
.pie-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.pie-center strong { font: 900 clamp(28px, 6vh, 80px)/1 var(--font-display); }
.pie-center span { color: var(--muted); font-size: clamp(12px, 1.4vw, 22px); }
.pie-legend { list-style: none; padding: 0; margin: 0; display: grid; gap: 1.6vh; font-size: clamp(16px, 1.9vw, 32px); max-width: 40vw; }
.pie-legend li { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: .6em; font-weight: 600; }
.pie-legend .dot { width: .9em; height: .9em; border-radius: 4px; }
.lg-pct { font-family: var(--font-display); }
.lg-n { color: var(--muted); font-size: .65em; min-width: 2.5em; }
.pie-legend li.winner .lg-pct { color: var(--wine); }

/* Word cloud */
.ch-cloud { position: relative; height: 100%; min-height: 200px; }
.cloud-inner { position: absolute; inset: 0; overflow: hidden; }
.cw { position: absolute; white-space: nowrap; font-family: var(--font-display); font-weight: 800; line-height: 1; transition: left .7s cubic-bezier(.2, .8, .2, 1), top .7s cubic-bezier(.2, .8, .2, 1), font-size .7s cubic-bezier(.2, .8, .2, 1), opacity .5s; letter-spacing: -.01em; }
.cw.ghost { visibility: hidden; transition: none; left: -9999px; top: -9999px; }
.cloud-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #c9c3b8; font-size: clamp(18px, 2.4vw, 40px); font-weight: 700; }

/* Elenco risposte */
.ch-list { position: relative; height: 100%; overflow: hidden; }
.list-grid { columns: 3 280px; column-gap: 1.2vw; }
.list-item { break-inside: avoid; background: var(--amber-soft); border-left: 6px solid var(--amber); padding: .8em 1em; border-radius: 10px; margin-bottom: 1.2vw; font-size: clamp(15px, 1.6vw, 28px); font-weight: 600; }
.list-item:nth-child(3n+2) { background: #f8e4e9; border-color: var(--wine); }
.list-item:nth-child(3n) { background: #efefef; border-color: var(--ink); }
.list-item.fresh { animation: pop .4s cubic-bezier(.2, 1.4, .4, 1); }

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