/* Tema "pubblico esercizio": legno scuro, ambra, schiuma e cartone da sottobicchiere.
   I colori della serie del grafico restano quelli validati per ciascuna superficie. */
:root {
  color-scheme: dark;
  --surface-0: #130d08;   /* il bancone */
  --surface-1: #1e1611;   /* il sottobicchiere */
  --surface-2: #2a201a;
  --border:    #3d2d20;
  --hairline:  rgba(246, 236, 219, .06);

  --text-primary:   #f6ecdb;
  --text-secondary: #cbb79a;
  --text-muted:     #96866f;

  --series-1: #c98500;    /* barre del grafico, validato su superficie scura */
  --gold:     #ffc65c;    /* inchiostro del numero principale */
  --good:     #4ec38a;

  --beer-top:    #e5a21c;
  --beer-bottom: #b06f04;
  --foam:        #f7efdd;
  --glass-bg:    #221a14;
  --glass-edge:  #4a3728;
  --hero-wash:   #2c1f14;

  --glow: 0 0 46px rgba(255, 198, 92, .22);
  --shadow: 0 1px 2px rgba(0,0,0,.55), 0 10px 26px rgba(0,0,0,.4);
  --radius: 16px;

  --font-display: 'Alfa Slab One', Georgia, serif;
  --font-number: 'Anton', 'Barlow', system-ui, sans-serif;
  --font-body: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --surface-0: #f2e8d6;   /* carta da imballo */
    --surface-1: #fffaf0;
    --surface-2: #f6ecda;
    --border:    #e0cfae;
    --hairline:  rgba(60, 40, 16, .07);

    --text-primary:   #241a10;
    --text-secondary: #5c4a34;
    --text-muted:     #8a7559;

    --series-1: #c07f00;
    --gold:     #8a5600;
    --good:     #0f7a51;

    --beer-top:    #f0b429;
    --beer-bottom: #c07f00;
    --foam:        #fffdf6;
    --glass-bg:    #f0e4cc;
    --glass-edge:  #cbb287;
    --hero-wash:   #f7e2b8;

    --glow: none;
    --shadow: 0 1px 2px rgba(80,55,20,.10), 0 8px 22px rgba(80,55,20,.08);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-color: var(--surface-0);
  /* venatura del legno + alone caldo della lampada sopra il bancone */
  background-image:
    repeating-linear-gradient(90deg, var(--hairline) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(90deg, transparent 0 37px, var(--hairline) 37px 38px),
    radial-gradient(120% 70% at 50% -10%, rgba(201, 133, 0, .16), transparent 62%);
  background-attachment: fixed;
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 24px 16px 48px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Sottobicchiere: bordo spesso, cartoncino, riga interna stampata */
.card {
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 0 0 1px var(--hairline);
  padding: 20px;
}

.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 {
  margin: 0; font-family: var(--font-display); font-weight: 400;
  font-size: 16px; letter-spacing: .01em; line-height: 1.2;
}
.card-head h2::before {
  content: ''; display: inline-block; width: 4px; height: 15px; margin-right: 9px;
  border-radius: 2px; background: var(--series-1); vertical-align: -2px;
}
.card-note { color: var(--text-muted); font-size: 13px; }

/* Insegna */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.brand {
  display: flex; align-items: center; gap: 11px;
  font-family: var(--font-display); font-weight: 400; font-size: 21px; letter-spacing: .005em;
}
.brand-mug { font-size: 26px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); }
.live {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-muted); background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 999px; padding: 7px 14px;
}
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.live[data-state="on"] { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, var(--border)); }
.live[data-state="static"] { color: var(--text-secondary); }
.live[data-state="static"] .dot { background: var(--series-1); }
.live[data-state="on"] .dot { background: var(--good); animation: pulse 2.4s infinite; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(78,195,138,.45); }
  70%  { box-shadow: 0 0 0 7px rgba(78,195,138,0); }
  100% { box-shadow: 0 0 0 0 rgba(78,195,138,0); }
}

/* ---------- Il boccale grande ---------- */

.hero {
  text-align: center; padding: 34px 20px 26px; margin-bottom: 16px; overflow: hidden;
  /* velatura ambrata sotto la schiuma: senza, nel tema chiaro la schiuma sparirebbe */
  background: linear-gradient(180deg, var(--hero-wash) 0, var(--surface-1) 34%);
}

/* schiuma che cola dal bordo superiore del sottobicchiere */
.hero::before {
  content: ''; position: absolute; left: 0; right: 0; top: -1px; height: 15px; pointer-events: none;
  background:
    radial-gradient(circle at 11px 0, var(--foam) 9.5px, transparent 10px) 0 0 / 22px 15px repeat-x,
    linear-gradient(var(--foam), var(--foam)) 0 0 / 100% 6px repeat-x;
  opacity: .92;
}

.bubbles { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.bubbles span {
  position: absolute; bottom: -16px; border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, rgba(255,255,255,.55), rgba(255,198,92,.16));
  animation: rise linear infinite;
}
@keyframes rise {
  0%   { transform: translateY(0) scale(.6); opacity: 0; }
  12%  { opacity: .7; }
  100% { transform: translateY(-300px) scale(1.2); opacity: 0; }
}
.bubbles span:nth-child(1)  { left:  4%; width:  7px; height:  7px; animation-duration: 9s;  animation-delay: 0s; }
.bubbles span:nth-child(2)  { left: 11%; width: 11px; height: 11px; animation-duration: 12s; animation-delay: 1.4s; }
.bubbles span:nth-child(3)  { left: 19%; width:  5px; height:  5px; animation-duration: 7.5s; animation-delay: 3s; }
.bubbles span:nth-child(4)  { left: 27%; width:  9px; height:  9px; animation-duration: 11s; animation-delay: .6s; }
.bubbles span:nth-child(5)  { left: 35%; width:  6px; height:  6px; animation-duration: 8.5s; animation-delay: 4.2s; }
.bubbles span:nth-child(6)  { left: 44%; width: 12px; height: 12px; animation-duration: 13s; animation-delay: 2.1s; }
.bubbles span:nth-child(7)  { left: 56%; width:  7px; height:  7px; animation-duration: 9.5s; animation-delay: 5s; }
.bubbles span:nth-child(8)  { left: 64%; width: 10px; height: 10px; animation-duration: 12.5s; animation-delay: .9s; }
.bubbles span:nth-child(9)  { left: 72%; width:  5px; height:  5px; animation-duration: 7s;  animation-delay: 3.6s; }
.bubbles span:nth-child(10) { left: 81%; width:  9px; height:  9px; animation-duration: 10.5s; animation-delay: 1.8s; }
.bubbles span:nth-child(11) { left: 89%; width:  6px; height:  6px; animation-duration: 8s;  animation-delay: 4.8s; }
.bubbles span:nth-child(12) { left: 96%; width: 11px; height: 11px; animation-duration: 14s; animation-delay: 2.6s; }

.hero-label {
  position: relative; margin: 0;
  font-size: 12px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase;
  color: var(--text-muted);
}
.hero-number {
  position: relative; margin: 8px 0 6px; color: var(--gold);
  font-family: var(--font-number); font-weight: 400;
  font-size: clamp(64px, 17vw, 132px); line-height: .92; letter-spacing: .005em;
  font-variant-numeric: tabular-nums;
  text-shadow: var(--glow);
}
.hero-sub { position: relative; margin: 0 0 22px; color: var(--text-secondary); font-size: 15px; }
.hero-sub strong { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }

/* il bicchiere: vetro, birra, schiuma in cima alla colonna */
.glass {
  position: relative; height: 34px; overflow: hidden;
  border: 2px solid var(--glass-edge);
  border-radius: 8px 8px 13px 13px;
  background: var(--glass-bg);
  box-shadow: inset 0 -10px 14px rgba(0,0,0,.25);
}
.glass::after {                      /* luce sul bordo alto, ombra sul fondo */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255,255,255,.16) 0, rgba(255,255,255,.04) 26%, transparent 46%),
    linear-gradient(0deg, rgba(0,0,0,.22) 0, transparent 34%);
}
.beer {
  position: relative; height: 100%; min-width: 16px;
  background: linear-gradient(180deg, var(--beer-top), var(--beer-bottom));
  transition: width .9s cubic-bezier(.22, 1, .36, 1);
}
.beer .foam {
  /* con il conteggio ancora basso la colonna e' sottile: la schiuma non deve coprirla tutta */
  position: absolute; top: 0; right: 0; bottom: 0; width: min(11px, 40%);
  border-radius: 0 5px 5px 0;
  background: linear-gradient(180deg, var(--foam), color-mix(in srgb, var(--foam) 80%, var(--beer-top)));
}
.meter-caption { margin: 12px 0 0; font-size: 13px; color: var(--text-muted); }
.meter-caption strong { color: var(--text-secondary); font-weight: 600; font-variant-numeric: tabular-nums; }
.meter-caption .sep { margin: 0 8px; opacity: .5; }

/* ---------- Riquadri ---------- */

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.tile { padding: 16px 18px; }
.tile-label {
  margin: 0; font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-muted);
}
.tile-value {
  margin: 8px 0 3px; font-family: var(--font-number); font-weight: 400;
  font-size: 38px; line-height: 1; letter-spacing: .01em; font-variant-numeric: tabular-nums;
}
.tile-value.small { font-size: 26px; }
.tile-foot { margin: 0; font-size: 12px; color: var(--text-muted); }

.columns { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; align-items: start; }
.stack { display: grid; gap: 16px; }

/* ---------- Classifica ---------- */

.tabs { display: inline-flex; gap: 3px; background: var(--surface-2); border-radius: 999px; padding: 3px; border: 1px solid var(--border); }
.tab {
  border: 0; background: transparent; color: var(--text-secondary);
  font: inherit; font-size: 12px; font-weight: 600; letter-spacing: .03em;
  padding: 6px 13px; border-radius: 999px; cursor: pointer;
}
.tab:hover { color: var(--text-primary); }
.tab.is-active { background: var(--surface-1); color: var(--text-primary); box-shadow: 0 1px 3px rgba(0,0,0,.3); }

.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; align-items: end; }
.podium:empty { display: none; }
.pod {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 13px;
  padding: 15px 10px 13px; text-align: center;
}
.pod--1 {
  border-color: var(--series-1);
  box-shadow: inset 0 0 0 1px var(--series-1), 0 4px 16px rgba(201,133,0,.16);
  padding-top: 19px;
}

/* tappo a corona: bordo zigrinato con conic-gradient, centro liscio */
.cap {
  width: 44px; height: 44px; margin: 0 auto 9px; border-radius: 50%;
  display: grid; place-items: center;
  background: repeating-conic-gradient(from 0deg, var(--cap-a) 0 7.5deg, var(--cap-b) 7.5deg 15deg);
  box-shadow: inset 0 0 0 4px var(--cap-a), 0 2px 5px rgba(0,0,0,.4);
  font-family: var(--font-number); font-size: 19px; line-height: 1; color: var(--cap-ink);
}
.pod--1 { --cap-a: #d9a441; --cap-b: #a97b24; --cap-ink: #3a2a08; }
.pod--2 { --cap-a: #cac6bd; --cap-b: #918d84; --cap-ink: #2e2c28; }
.pod--3 { --cap-a: #c08457; --cap-b: #8c5c38; --cap-ink: #2c1809; }
.pod--1 .cap { width: 52px; height: 52px; font-size: 22px; }

.pod-name { margin: 0 0 3px; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.pod-count { margin: 0; font-family: var(--font-number); font-size: 27px; line-height: 1; font-variant-numeric: tabular-nums; }
.pod--1 .pod-count { color: var(--gold); }
.pod-unit { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); }

.board { width: 100%; border-collapse: collapse; font-size: 14px; }
.board th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-muted); padding: 0 8px 9px; border-bottom: 1px solid var(--border);
}
.board td { padding: 9px 8px; border-bottom: 1px solid var(--hairline); }
.board tr:last-child td { border-bottom: 0; }
.board .num { text-align: right; font-variant-numeric: tabular-nums; }
.board .rank { color: var(--text-muted); width: 34px; font-variant-numeric: tabular-nums; }
.board .who { font-weight: 600; overflow-wrap: anywhere; }
.board .count { font-weight: 600; }
.board .share { color: var(--text-muted); width: 68px; }
.board.small td, .board.small th { padding: 5px 8px; font-size: 13px; }
.empty { color: var(--text-muted); font-size: 14px; text-align: center; padding: 18px 0 4px; margin: 0; }
.resto { margin: 12px 0 0; padding-top: 11px; border-top: 1px solid var(--hairline);
         color: var(--text-muted); font-size: 13px; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- Grafico ---------- */

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.bar { fill: var(--series-1); transition: fill .12s; }
.bar.is-hot { fill: var(--gold); }
.bar-hit { fill: transparent; cursor: pointer; }
.grid-line { stroke: var(--border); stroke-width: 1; }
.axis-text { fill: var(--text-muted); font-size: 10px; font-family: var(--font-body); letter-spacing: .04em; }
.peak-text { fill: var(--text-secondary); font-size: 10px; font-weight: 700; font-family: var(--font-body); }
.tooltip {
  position: absolute; transform: translate(-50%, -100%); pointer-events: none; z-index: 5;
  background: var(--surface-2); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 9px;
  padding: 6px 11px; font-size: 12px; white-space: nowrap; box-shadow: var(--shadow);
}
.tooltip b { font-variant-numeric: tabular-nums; }
.data-view { margin-top: 12px; }
.data-view summary { cursor: pointer; font-size: 13px; color: var(--text-muted); }
.data-view[open] summary { margin-bottom: 8px; }

/* ---------- Ultimo giro ---------- */

.recent { list-style: none; margin: 0; padding: 0; display: grid; }
.recent li {
  display: flex; align-items: baseline; gap: 10px; padding: 8px 0;
  border-bottom: 1px solid var(--hairline); font-size: 14px;
}
.recent li:last-child { border-bottom: 0; }
.recent .who { font-weight: 600; overflow-wrap: anywhere; }
.recent .when { margin-left: auto; color: var(--text-muted); font-size: 12px; white-space: nowrap; }

.foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 24px; color: var(--text-muted); font-size: 12px;
}
.foot-right { display: inline-flex; align-items: center; gap: 14px; }
.linkish {
  border: 0; background: none; padding: 0; font: inherit; color: var(--text-secondary);
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.linkish:hover { color: var(--text-primary); }
.linkish[disabled] { cursor: progress; opacity: .6; }

/* ---------- "Ne arriva un'altra!" ---------- */

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 16px);
  background: var(--surface-2); color: var(--text-primary);
  border: 2px solid var(--series-1); border-radius: 12px;
  padding: 12px 22px; font-family: var(--font-display); font-size: 16px; letter-spacing: .01em;
  box-shadow: var(--shadow); opacity: 0; transition: opacity .25s, transform .25s; z-index: 20;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 860px) {
  .columns { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .brand { font-size: 18px; }
  .tile-value { font-size: 32px; }
}
@media (max-width: 420px) {
  .tabs { width: 100%; justify-content: space-between; }
  .tab { flex: 1; padding: 6px 4px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .bubbles { display: none; }
}
