/* =====================================================================
   DINOBOT — Design System
   Tema: il dinosauro-robot che organizza la tua fiera Play 2026
   Palette: "feltro da tavolo" — verde profondo + crema + accenti caldi
   Tipografia: Fraunces (display) + Inter (UI)
   ===================================================================== */

:root {
  /* surfaces */
  --bg:          #FAF6EE;      /* crema caldo (un'idea di pagina ingiallita) */
  --bg-alt:      #F2EBDA;      /* sezioni alternate */
  --surface:     #FFFFFF;      /* card */
  --ink:         #1B1B1F;      /* testo principale */
  --ink-soft:    #4A4A52;      /* testo secondario */
  --ink-mute:    #888384;      /* placeholder */
  --line:        #E8DFC9;      /* bordi sottili */

  /* brand & status */
  --brand:       #0F766E;      /* verde-tavolo */
  --brand-deep:  #134E4A;
  --brand-soft:  #CCE7E1;
  --accent:      #D4A017;      /* oro (rating BGG) */

  --watch:       #2563EB;      /* blu — guarda */
  --watch-soft:  #DBEAFE;
  --play:        #EA580C;      /* arancio — gioca */
  --play-soft:   #FED7AA;
  --buy:         #DB2777;      /* magenta — compra */
  --buy-soft:    #FBCFE8;
  --free:        #16A34A;
  --free-soft:   #BBF7D0;

  /* shape */
  --r-sm: 8px;
  --r:    14px;
  --r-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(20,20,20,.04), 0 1px 3px rgba(20,20,20,.04);
  --shadow:    0 4px 14px rgba(20,20,20,.08);
  --shadow-lg: 0 14px 40px rgba(20,20,20,.14);

  /* type */
  --f-display: "Fraunces", Georgia, serif;
  --f-ui:      "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* motion */
  --ease: cubic-bezier(.2,.7,.2,1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:       #14141A;
    --bg-alt:   #1B1B22;
    --surface:  #1F1F28;
    --ink:      #F0EBDC;
    --ink-soft: #B7B1A1;
    --ink-mute: #6E6A5E;
    --line:     #2C2C36;
    --brand:    #38B2A6;
    --brand-deep:#0F766E;
    --brand-soft: rgba(56,178,166,.12);
    --watch-soft:rgba(37,99,235,.18);
    --play-soft: rgba(234,88,12,.20);
    --buy-soft:  rgba(219,39,119,.20);
    --free-soft: rgba(22,163,74,.18);
    --shadow-sm:0 1px 2px rgba(0,0,0,.4);
    --shadow:   0 6px 22px rgba(0,0,0,.5);
    --shadow-lg:0 16px 48px rgba(0,0,0,.6);
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  /* SAFETY NET: previene scroll orizzontale per qualunque elemento extra-wide */
  overflow-x: hidden;
  max-width: 100%;
}
body {
  font-family: var(--f-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* Ogni immagine non puo' eccedere la sua colonna */
img { max-width: 100%; height: auto; }
h1, h2, h3, h4 { font-family: var(--f-display); font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: clamp(1.7rem, 1.5rem + 1vw, 2.6rem); font-variation-settings: "SOFT" 100, "WONK" 1; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
a  { color: inherit; }
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }
[x-cloak] { display: none !important; }  /* Alpine: nasconde il template fino a init */

/* ====== Layout shell ====== */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: .8rem 1.2rem;
  display: flex; align-items: center; gap: 1rem;
}
.brand {
  display: flex; align-items: center; gap: .6rem;
  font-family: var(--f-display); font-weight: 600;
  text-decoration: none; color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
.brand .logo {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
  color: #fff;
  font-size: 26px;             /* emoji ben proporzionata al box */
  line-height: 1;
  box-shadow: 0 4px 10px rgba(15, 118, 110, 0.35);
  flex-shrink: 0;
}
.brand .logo svg { width: 22px; height: 22px; }
/* Le due righe (DINOBOT + Play 2026) sono "stacked" con line-height stretto
   per non sembrare scollegate */
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1;              /* niente extra height: le due righe sono vicine */
  gap: 2px;
}
.brand-name {
  font-family: var(--f-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.brand-sub {
  font-family: var(--f-ui);
  font-weight: 500;
  color: var(--ink-soft);
  font-size: 11.5px;
  letter-spacing: .02em;
}

.nav-tabs { display: flex; gap: .25rem; margin-left: 1.2rem; }
.nav-tab {
  padding: .55rem 1rem; border-radius: 999px; border: none;
  background: transparent; color: var(--ink-soft);
  font-weight: 500; font-size: .95rem; cursor: pointer;
  display: inline-flex; align-items: center; gap: .4rem;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.nav-tab:hover { background: var(--bg-alt); color: var(--ink); }
.nav-tab.is-active { background: var(--brand); color: #fff; }
.nav-tab .count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px;
  font-size: 12px; font-weight: 700; border-radius: 11px;
  background: rgba(255,255,255,.25);
}
.nav-tab:not(.is-active) .count { background: var(--line); color: var(--ink-soft); }

.topbar .spacer { flex: 1; }

.user-chip {
  display: inline-flex; align-items: center; gap: .55rem;
  padding: .35rem .9rem .35rem .35rem;
  border-radius: 999px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  cursor: pointer; user-select: none;
  font: inherit; color: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s var(--ease);
}
.user-chip:active { transform: scale(.95); }
.user-chip img { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; object-fit: cover; }
.user-chip .name { font-weight: 500; font-size: .9rem; }

main { padding: 1.2rem; max-width: 1400px; margin: 0 auto; width: 100%; }

footer.tiny {
  padding: 2rem 1rem; text-align: center;
  color: var(--ink-mute); font-size: 13px;
}

/* ====== Login splash ====== */
.login-screen {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 2rem;
  background:
    radial-gradient(ellipse 60% 60% at 20% 0%, rgba(15, 118, 110, .12), transparent 60%),
    radial-gradient(ellipse 50% 50% at 80% 100%, rgba(212, 160, 23, .12), transparent 60%),
    var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 3rem 2.5rem;
  max-width: 460px; width: 100%;
  text-align: center;
}
.login-card h1 { margin-bottom: .5rem; font-size: 2.2rem; }
.login-card p { color: var(--ink-soft); margin: .5rem 0 1.4rem; }
.login-features {
  list-style: none; padding: 0; margin: 1.6rem 0 1.4rem;
  text-align: left; display: grid; gap: .55rem;
}
.login-features li {
  display: flex; align-items: center; gap: .6rem;
  font-size: .92rem; color: var(--ink-soft);
}
.login-features svg { color: var(--brand); flex-shrink: 0; }

.dino-decoration {
  font-size: 4rem; margin-bottom: .5rem;
  display: inline-block; transform-origin: 50% 80%;
  animation: dino-wave 2.8s ease-in-out infinite;
  filter: drop-shadow(0 6px 14px rgba(15, 118, 110, .25));
}
@keyframes dino-wave {
  0%, 100% { transform: rotate(-6deg) translateY(0); }
  40%      { transform: rotate(6deg)  translateY(-4px); }
  60%      { transform: rotate(6deg)  translateY(-4px); }
}

/* ====== Hero / dashboard ====== */
.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 1.5rem; margin-bottom: 1.5rem;
}
@media (max-width: 780px) {
  .dash-grid { grid-template-columns: 1fr; }
}
.hello-card {
  background: linear-gradient(135deg, var(--brand-deep), var(--brand));
  color: #fff;
  border-radius: var(--r-lg);
  padding: 1.6rem 1.8rem;
  position: relative;
  overflow: hidden;
}
.hello-card::after {
  content: ""; position: absolute; right: -40px; bottom: -40px;
  width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(212,160,23,.35), transparent 60%);
}
.hello-card h2 {
  font-family: var(--f-display); font-size: 1.7rem; margin-bottom: .3rem;
  font-variation-settings: "SOFT" 100;
}
.hello-card p { opacity: .82; margin: 0; }
.hello-stats {
  display: flex; gap: 1.5rem; margin-top: 1.3rem; flex-wrap: wrap;
}
.stat {
  display: flex; align-items: baseline; gap: .4rem;
}
.stat .num {
  font-family: var(--f-display); font-size: 2.2rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-variation-settings: "SOFT" 50;
}
.stat .lbl { opacity: .8; font-size: .85rem; }

.upcoming-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.2rem 1.4rem;
}
.upcoming-card h3 {
  font-size: 1rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-soft); font-family: var(--f-ui); font-weight: 600;
  margin-bottom: .6rem;
}
.appt-mini {
  display: flex; gap: .65rem; padding: .55rem 0;
  border-bottom: 1px dashed var(--line);
}
.appt-mini:last-child { border-bottom: none; }
.appt-mini .when {
  flex-shrink: 0; width: 56px;
  font-family: var(--f-display); font-weight: 600; line-height: 1.1;
  color: var(--brand);
}
.appt-mini .when .big { font-size: 1.4rem; }
.appt-mini .where { font-size: .85rem; color: var(--ink-soft); }
.appt-empty { color: var(--ink-mute); font-size: .9rem; padding: .8rem 0; }

/* ====== Filters bar ====== */
.filters {
  display: flex; gap: .6rem; flex-wrap: wrap;
  margin-bottom: 1rem; align-items: center;
}
.search-box {
  position: relative; flex: 1; min-width: 220px;
}
.search-box input {
  width: 100%; padding: .7rem 1rem .7rem 2.6rem;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  font-size: .95rem; font-family: inherit;
  transition: border-color .2s, box-shadow .2s;
}
.search-box input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}
.search-box svg {
  position: absolute; left: .85rem; top: 50%; transform: translateY(-50%);
  color: var(--ink-mute);
}

.chip-row { display: flex; gap: .45rem; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .45rem .85rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: .85rem; color: var(--ink-soft); cursor: pointer;
  font-weight: 500;
  transition: all .15s var(--ease);
  user-select: none;
}
.chip:hover { border-color: var(--ink-mute); color: var(--ink); }
.chip.is-on {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
}
.chip.is-on.watch { background: var(--watch); color: #fff; border-color: var(--watch); }
.chip.is-on.play  { background: var(--play);  color: #fff; border-color: var(--play);  }
.chip.is-on.buy   { background: var(--buy);   color: #fff; border-color: var(--buy);   }
.chip .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor; opacity: .6;
}

.advanced-toggle {
  margin-left: auto;
  background: transparent; border: none; color: var(--ink-soft);
  font-size: .9rem; cursor: pointer; padding: .45rem;
  display: inline-flex; align-items: center; gap: .35rem;
}
.advanced-toggle:hover { color: var(--ink); }

.advanced-panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 1.1rem 1.3rem;
  margin-bottom: 1rem;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.1rem;
}
.adv-group h4 {
  font-family: var(--f-ui); text-transform: uppercase;
  font-size: .75rem; letter-spacing: .08em;
  color: var(--ink-mute); margin-bottom: .55rem; font-weight: 600;
}
.adv-group select, .adv-group input[type=range] {
  width: 100%; padding: .5rem .6rem;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--bg); color: var(--ink); font: inherit;
}
.range-row { display: flex; align-items: center; gap: .5rem; }
.range-row output { font-variant-numeric: tabular-nums; min-width: 30px; }

.results-info {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  margin-bottom: .8rem; color: var(--ink-soft); font-size: .9rem;
}
.results-info .count { font-weight: 600; color: var(--ink); }
.sort-select {
  padding: .35rem .7rem; border: 1px solid var(--line);
  border-radius: var(--r-sm); background: var(--surface);
  color: var(--ink); font: inherit;
}

/* ====== Game grid ====== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.1rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease);
  position: relative;
  cursor: pointer;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: var(--ink-mute);
}
.card .img-wrap {
  aspect-ratio: 4 / 3;
  background:
    linear-gradient(135deg, var(--bg-alt) 0%, var(--line) 100%);
  display: grid; place-items: center;
  position: relative; overflow: hidden;
}
.card .img-wrap img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .5s var(--ease);
}
.card:hover .img-wrap img { transform: scale(1.06); }
.card .placeholder {
  font-family: var(--f-display); font-size: 2.6rem;
  color: var(--ink-mute); opacity: .35;
}
.card .img-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 55%, rgba(0,0,0,.55) 100%);
  pointer-events: none;
}
.card .badges {
  position: absolute; top: .55rem; right: .55rem;
  display: flex; gap: .3rem; flex-direction: column;
  align-items: flex-end;
}
.badge {
  font-size: 11px; padding: .25rem .55rem;
  border-radius: 999px; background: rgba(0,0,0,.65); color: #fff;
  font-weight: 600; backdrop-filter: blur(4px);
}
.badge.rank { background: var(--accent); color: #2a1f00; }
.badge.rank::before { content: "#"; opacity: .65; }
.badge.free { background: var(--free); color: #fff; }
.badge.free::before { content: "🎁 "; }

.status-chips {
  position: absolute; top: .55rem; left: .55rem;
  display: flex; gap: .25rem;
}
.status-chip {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.95);
  border-radius: 50%;
  color: var(--ink-soft);
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  font-size: 14px;
}
.status-chip.on.watch { background: var(--watch); color: #fff; }
.status-chip.on.play  { background: var(--play);  color: #fff; }
.status-chip.on.buy   { background: var(--buy);   color: #fff; }
.status-chip.off { opacity: .35; }

.card .body { padding: .9rem 1rem 1rem; flex: 1; display: flex; flex-direction: column; }
.card h3 {
  font-family: var(--f-display); font-size: 1.05rem;
  font-weight: 600; line-height: 1.2; margin-bottom: .15rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .publisher {
  font-size: 11px; color: var(--ink-mute);
  text-transform: uppercase; letter-spacing: .06em;
  font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.card .meta {
  display: flex; gap: .8rem; margin-top: .6rem; flex-wrap: wrap;
  font-size: .82rem; color: var(--ink-soft);
}
.card .meta span { display: inline-flex; align-items: center; gap: .25rem; }
.card .actions {
  margin-top: auto; padding-top: .9rem;
  display: flex; gap: .35rem;
}
.act-btn {
  flex: 1; padding: .5rem .25rem;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink-soft);
  border-radius: var(--r-sm); cursor: pointer;
  font: inherit; font-size: .82rem; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
  transition: all .15s var(--ease);
}
.act-btn:hover { transform: translateY(-1px); }
.act-btn.watch.is-on { background: var(--watch); color: #fff; border-color: var(--watch); }
.act-btn.play.is-on  { background: var(--play);  color: #fff; border-color: var(--play);  }
.act-btn.buy.is-on   { background: var(--buy);   color: #fff; border-color: var(--buy);   }
.act-btn.is-on { box-shadow: 0 4px 14px rgba(0,0,0,.15); animation: pop .35s var(--ease); }
@keyframes pop {
  0%   { transform: scale(.92); }
  60%  { transform: scale(1.07); }
  100% { transform: scale(1); }
}
.act-btn.disabled { opacity: .35; pointer-events: none; }
/* Bottone "non disponibile in fiera": stile sbiadito + line-through visivo */
.act-btn.is-unavailable:not(.is-on) {
  opacity: .35;
  text-decoration: line-through;
}
.act-btn.is-unavailable:not(.is-on):hover { opacity: .65; }

/* Variante "non disponibile" per i bottoni grandi nella modal */
.btn.is-unavailable:not(.watch):not(.play):not(.buy):not(.primary) { opacity: .55; }
.btn.watch.is-unavailable.ghost,
.btn.play.is-unavailable.ghost,
.btn.buy.is-unavailable.ghost {
  opacity: .5;
  border-style: dashed;
  text-decoration: line-through;
}
.btn.watch.is-unavailable.ghost:hover,
.btn.play.is-unavailable.ghost:hover,
.btn.buy.is-unavailable.ghost:hover { opacity: .75; text-decoration: none; }

/* ====== Detail modal ====== */
.modal-bg {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 10, 15, .6);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  padding: 1rem;
  animation: fade .2s var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  max-width: 800px; width: 100%;
  max-height: 92vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slide-up .3s var(--ease);
}
@keyframes slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: none; }
}
.modal .hero {
  height: 240px;
  background: var(--bg-alt);
  position: relative; overflow: hidden;
  display: grid; place-items: center;
}
.modal .hero img {
  width: 100%; height: 100%; object-fit: cover;
}
.modal .close {
  position: absolute; top: 1rem; right: 1rem;
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(0,0,0,.5); color: #fff; border: none;
  display: grid; place-items: center; cursor: pointer;
  backdrop-filter: blur(4px);
}
.modal .content { padding: 1.5rem 2rem 2rem; }
.modal h2 { font-size: 1.8rem; margin-bottom: .25rem; }
.modal .sub { color: var(--ink-soft); font-size: .95rem; margin-bottom: 1.3rem; }
.modal .info-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 1rem; padding: 1rem 0; margin-bottom: 1rem;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.modal .info-row .item .lbl {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--ink-mute); font-weight: 600;
}
.modal .info-row .item .val {
  font-family: var(--f-display); font-size: 1.3rem; margin-top: .15rem;
  font-variant-numeric: tabular-nums;
}
.modal .desc {
  font-size: .95rem; line-height: 1.65;
  color: var(--ink-soft);
  max-height: 280px; overflow-y: auto;
  padding-right: .5rem;
}
.modal .desc p { margin-bottom: 1em; }
.modal .modal-actions {
  display: flex; gap: .5rem; margin-top: 1.3rem; flex-wrap: wrap;
}
.btn {
  padding: .65rem 1.2rem; border-radius: var(--r-sm);
  font: inherit; font-weight: 600; font-size: .9rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: .4rem;
  transition: all .15s var(--ease);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-deep); }
.btn.watch  { background: var(--watch); color: #fff; border-color: var(--watch); }
.btn.play   { background: var(--play);  color: #fff; border-color: var(--play);  }
.btn.buy    { background: var(--buy);   color: #fff; border-color: var(--buy);   }
.btn.ghost  { background: transparent; color: var(--ink); }
/* Variante ghost colorata: bordo + testo nel colore della lista, niente fondo */
.btn.watch.ghost { background: transparent; color: var(--watch); border-color: var(--watch); }
.btn.play.ghost  { background: transparent; color: var(--play);  border-color: var(--play);  }
.btn.buy.ghost   { background: transparent; color: var(--buy);   border-color: var(--buy);   }
/* Al hover, il ghost mostra un'anteprima dello stato attivo */
.btn.watch.ghost:hover { background: var(--watch-soft); }
.btn.play.ghost:hover  { background: var(--play-soft);  }
.btn.buy.ghost:hover   { background: var(--buy-soft);   }
.btn.danger { color: #b91c1c; }

.tags { display: flex; gap: .35rem; flex-wrap: wrap; margin: .55rem 0; }
.tag {
  font-size: .78rem; padding: .25rem .65rem;
  border-radius: 999px; background: var(--bg-alt);
  color: var(--ink-soft);
}

/* ====== Lists view ====== */
.list-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.4rem;
}
.list-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1.1rem 1.2rem; }
.list-section header {
  display: flex; align-items: baseline; gap: .5rem;
  margin-bottom: .8rem; padding-bottom: .7rem; border-bottom: 1px solid var(--line);
}
.list-section header h2 { font-size: 1.2rem; }
.list-section header .badge-count {
  margin-left: auto; background: var(--bg-alt); color: var(--ink-soft);
  padding: .2rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600;
}
.list-section.watch header h2 { color: var(--watch); }
.list-section.play  header h2 { color: var(--play);  }
.list-section.buy   header h2 { color: var(--buy);   }

.list-item {
  display: flex; gap: .8rem; padding: .7rem 0;
  border-bottom: 1px dashed var(--line);
  align-items: center;
}
.list-item:last-child { border-bottom: none; }
.list-item .thumb {
  width: 60px; height: 60px; border-radius: var(--r-sm); flex-shrink: 0;
  background: var(--bg-alt); overflow: hidden;
}
.list-item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.list-item .info { flex: 1; min-width: 0; }
.list-item .info h4 {
  font-family: var(--f-ui); font-size: .95rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-item .info small { color: var(--ink-soft); font-size: .8rem; }
.list-item.is-done { opacity: .5; }
.list-item.is-done .info h4 { text-decoration: line-through; }
.list-item .check {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--line); background: transparent;
  cursor: pointer; display: grid; place-items: center;
  transition: all .15s var(--ease);
}
.list-item .check:hover { border-color: var(--brand); }
.list-item.is-done .check { background: var(--brand); border-color: var(--brand); color: #fff; }

.empty {
  text-align: center; padding: 2rem 1rem; color: var(--ink-mute);
}
.empty .emoji { font-size: 2.5rem; margin-bottom: .5rem; }

/* ====== Appointments view ====== */
.appt-header {
  display: flex; align-items: center; gap: 1rem; margin-bottom: 1.2rem;
}
.appt-header h2 { flex: 1; }

.appt-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}
.appt-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 1.1rem 1.2rem;
  position: relative;
  border-left: 4px solid var(--brand);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease);
}
.appt-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.appt-card.past { opacity: .55; border-left-color: var(--ink-mute); }
.appt-card.today { border-left-color: var(--play); }
.appt-card .date-block {
  display: flex; align-items: baseline; gap: .8rem;
}
.appt-card .date-num {
  font-family: var(--f-display); font-size: 2.4rem; font-weight: 600;
  color: var(--brand); line-height: 1;
}
.appt-card.past .date-num { color: var(--ink-mute); }
.appt-card.today .date-num { color: var(--play); }
.appt-card .date-rest .month { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-mute); }
.appt-card .date-rest .time { font-weight: 600; font-size: 1.05rem; }
.appt-card h3 { margin-top: .6rem; font-size: 1.15rem; }
.appt-card .location,
.appt-card .attendees { display: inline-flex; align-items: center; gap: .3rem; color: var(--ink-soft); font-size: .85rem; margin-top: .25rem; margin-right: .8rem; }
.appt-card .attendees { font-weight: 500; }
.appt-card .notes { color: var(--ink-soft); font-size: .85rem; margin: .55rem 0; line-height: 1.5; }
.appt-card .row-actions { display: flex; gap: .35rem; margin-top: .8rem; flex-wrap: wrap; }
.appt-card .row-actions .btn { padding: .35rem .7rem; font-size: .8rem; }

/* ====== Form ====== */
.form-row {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: .8rem;
}
.form-field label {
  display: block; font-size: .82rem; font-weight: 600;
  color: var(--ink-soft); margin-bottom: .25rem;
  text-transform: uppercase; letter-spacing: .04em;
}
.form-field input, .form-field textarea, .form-field select {
  width: 100%; padding: .65rem .85rem;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font: inherit; background: var(--surface); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.form-field input:focus, .form-field textarea:focus, .form-field select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}
.form-field textarea { min-height: 80px; resize: vertical; }
.form-field.full { grid-column: 1 / -1; }

/* Pill informativo "gioco collegato" — mostrato quando l'appuntamento
   e' stato prenotato direttamente da un gioco, senza dropdown. */
.game-link-pill {
  display: inline-flex; align-items: center; gap: .55rem;
  padding: .55rem .9rem;
  background: var(--brand-soft); color: var(--brand-deep);
  border: 1px solid var(--brand);
  border-radius: 999px;
  font-weight: 500; font-size: .95rem;
}
.game-link-pill .link-unlink {
  border: none; background: transparent; cursor: pointer;
  color: var(--brand-deep); opacity: .6;
  font-size: 1rem; padding: 0 .2rem;
  margin-left: .3rem;
}
.game-link-pill .link-unlink:hover { opacity: 1; }

.toast-stack {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 200;
  display: flex; flex-direction: column; gap: .5rem;
}
.toast {
  background: var(--ink); color: var(--bg);
  padding: .8rem 1.2rem; border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg); font-size: .9rem;
  animation: toast-in .25s var(--ease);
}
.toast.success { background: var(--free); color: #fff; }
.toast.error   { background: #b91c1c; color: #fff; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: none; }
}

/* ====== Floating action button ====== */
.fab {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 30;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--brand); color: #fff;
  border: none; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(15, 118, 110, .4);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease);
}
.fab:hover { transform: scale(1.08); box-shadow: 0 12px 32px rgba(15, 118, 110, .5); }
.fab svg { width: 28px; height: 28px; }

/* ====== Skeleton loader ====== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-alt) 0%, var(--line) 50%, var(--bg-alt) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }
.card.skeleton-card { pointer-events: none; }
.card.skeleton-card .img-wrap { background: var(--bg-alt); }
.card.skeleton-card .body { height: 80px; }

/* ====== Confetti / sparkle ====== */
.spark {
  position: fixed; pointer-events: none; z-index: 1000;
  font-size: 1.5rem;
  animation: spark-fly 1.1s var(--ease) forwards;
}
@keyframes spark-fly {
  0%   { transform: translate(0, 0) scale(.5) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--dx), -120px) scale(1) rotate(360deg); opacity: 0; }
}

/* ====== Misc ====== */
.divider {
  height: 1px; background: var(--line); margin: 1.4rem 0;
}
.scroll-x { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .25rem; }
.scroll-x::-webkit-scrollbar { height: 6px; }
.scroll-x::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.muted { color: var(--ink-soft); }
.right { text-align: right; }

/* =====================================================================
   ELEMENTI SOLO-DESKTOP / SOLO-MOBILE
   ===================================================================== */
.section-title { display: none; }   /* nascosto di default, mostrato solo su mobile */
.bottom-tabs   { display: none; }   /* nascosto di default, mostrato solo su mobile */

/* =====================================================================
   MOBILE SHELL  (≤ 768px)
   Pattern: app nativa con top app bar + content area + bottom tab bar.
   - shell verticale a 3 livelli, ognuno con la propria area
   - safe-area-inset per iPhone con notch e gesture bar
   - press-feedback 0.97 scale (raccomandazione UX Pro)
   - flat: niente shadow (color-blocking), bordi sottili
   ===================================================================== */
@media (max-width: 768px) {

  /* L'APP diventa un layout flexbox a tutta altezza, non scrolla globalmente.
     Solo <main> scorre verticalmente, dentro la sua zona. */
  .app {
    grid-template-rows: auto 1fr auto auto;   /* topbar / main / bottom-tabs / footer */
    min-height: 100dvh;                       /* dvh = dynamic viewport height (rispetta address-bar mobile) */
    min-height: 100vh;                        /* fallback browser vecchi */
  }

  /* ── TOPBAR — slim, solo titolo + avatar ─────────────────────────── */
  .topbar {
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    /* safe area top per notch */
    padding-top: env(safe-area-inset-top, 0);
  }
  .topbar-inner {
    padding: .55rem .9rem;
    gap: .65rem;
    flex-wrap: nowrap;
    min-height: 52px;
  }

  /* Brand compatto: logo grande, "DINOBOT" piccolo, sottotitolo nascosto */
  .brand { gap: .55rem; }
  .brand .logo {
    width: 38px; height: 38px;
    font-size: 26px;           /* emoji bella grande dentro al box */
    border-radius: 11px;
  }
  .brand-text { display: flex; flex-direction: column; line-height: 1.05; }
  .brand-name { font-family: var(--f-display); font-size: 1.05rem; font-weight: 700; }
  .brand-sub  { display: none; }   /* nascondi "Play 2026" su mobile, gia in section-title */

  /* Mostra il titolo della sezione corrente */
  .section-title {
    display: block;
    font-family: var(--f-display);
    font-size: 1.1rem;
    font-weight: 600;
    margin-left: .6rem;
    color: var(--ink-soft);
    flex: 1;
    text-align: center;
  }

  /* Le tab orizzontali del desktop vanno via su mobile */
  .desktop-only { display: none !important; }

  /* Avatar: solo cerchio, niente nome */
  .user-chip {
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
  }
  .user-chip img { width: 34px; height: 34px; border: 2px solid var(--line); }
  .user-chip .name { display: none; }

  /* ── MAIN — area scrollabile ────────────────────────────────────── */
  main {
    padding: 1rem .9rem;
    /* Importante: lo padding-bottom deve lasciare spazio per la bottom-tab + safe-area */
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0));
  }

  /* ── BOTTOM TAB BAR — solo mobile, fixed in fondo ──────────────── */
  .bottom-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 100;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .b-tab {
    appearance: none;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--ink-mute);
    font-family: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 9px 4px 8px;
    font-size: 10.5px;
    font-weight: 600;
    position: relative;
    min-height: 56px;
    transition: color .15s var(--ease), transform .12s var(--ease);
    -webkit-tap-highlight-color: transparent;
  }
  .b-tab:active { transform: scale(.95); }   /* press feedback native-style */
  .b-tab .b-icon {
    width: 24px; height: 24px;
    transition: stroke-width .15s var(--ease);
  }
  .b-tab.is-active { color: var(--brand); }
  .b-tab.is-active .b-icon { stroke-width: 2.4; }
  /* Indicatore "selezionato" come barretta in alto sul tab attivo */
  .b-tab.is-active::before {
    content: '';
    position: absolute;
    top: 0; left: 30%; right: 30%;
    height: 3px;
    background: var(--brand);
    border-radius: 0 0 3px 3px;
  }
  /* Badge numerico in alto a destra dell'icona */
  .b-badge {
    position: absolute;
    top: 4px; right: 22%;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    background: var(--play);
    color: #fff;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    line-height: 1;
  }

  /* Footer testuale nascosto su mobile (info gia presenti altrove) */
  footer.tiny { display: none; }

  /* ── HOME / DASHBOARD ───────────────────────────────────────────── */
  .dash-grid { gap: .9rem; margin-bottom: 1rem; grid-template-columns: 1fr; }
  .hello-card {
    padding: 1.2rem 1.2rem;
    border-radius: 18px;
    box-shadow: none;        /* flat: nessuna ombra */
  }
  .hello-card h2 { font-size: 1.4rem; }
  .hello-card p  { font-size: .92rem; opacity: .92; }
  .hello-card::after { display: none; }    /* niente decorazione blob su mobile */
  .hello-stats { gap: 1.2rem; margin-top: 1rem; }
  .stat .num { font-size: 1.6rem; }
  .stat .lbl { font-size: .78rem; }

  .upcoming-card {
    padding: 1rem 1.1rem;
    border-radius: 18px;
    box-shadow: none;
  }

  /* ── FILTRI — chip e search-box adatte al mobile ─────────────────── */
  .filters {
    gap: .5rem;
    flex-direction: column;
    align-items: stretch;
    margin-bottom: .8rem;
  }
  .filters .search-box { width: 100%; min-width: 0; }
  .filters .chip-row {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
    border-left: none !important;
    padding-left: 0 !important;
  }
  .filters .chip-row::-webkit-scrollbar { display: none; }
  .filters .chip { flex-shrink: 0; font-size: .85rem; padding: .45rem .85rem; }
  .filters .chip:active { transform: scale(.95); }
  .advanced-toggle {
    margin-left: 0;
    align-self: flex-start;
    padding: .4rem 0;
  }
  .advanced-panel { grid-template-columns: 1fr; gap: .9rem; padding: 1rem; box-shadow: none; }
  .results-info { font-size: .85rem; gap: .55rem; flex-wrap: wrap; }

  /* ── GRID DI CARD GIOCHI ───────────────────────────────────────── */
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .7rem;
  }
  .card {
    box-shadow: none;                  /* flat */
    border-radius: 14px;
    border: 1px solid var(--line);
  }
  .card:hover { transform: none; box-shadow: none; border-color: var(--line); }
  .card:active { transform: scale(.97); }   /* press feedback */
  .card .body { padding: .6rem .7rem .7rem; }
  .card h3 { font-size: .92rem; line-height: 1.2; }
  .card .publisher { font-size: 10px; }
  .card .meta { font-size: .72rem; gap: .55rem; margin-top: .5rem; }
  .card .meta span { white-space: nowrap; }
  .card .actions { gap: .3rem; padding-top: .65rem; }
  .act-btn {
    padding: .42rem .15rem;
    font-size: 14px;
    border-width: 1px;
  }
  .act-btn:active { transform: scale(.95); }
  .status-chip { width: 24px; height: 24px; font-size: 12px; box-shadow: none; }
  .badge { font-size: 10px; padding: .2rem .45rem; }

  /* ── MODAL come BOTTOM SHEET ───────────────────────────────────── */
  .modal-bg { padding: 0; align-items: flex-end; }
  .modal {
    border-radius: 22px 22px 0 0;
    max-height: 92dvh;
    max-height: 92vh;
    height: auto;
    max-width: 100%;
    width: 100%;
    margin: 0;
    animation: sheet-up .28s cubic-bezier(.2,.85,.25,1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  /* drag-handle (la lineetta orizzontale che indica "sheet sotto") */
  .modal::before {
    content: '';
    display: block;
    width: 38px; height: 4px;
    background: var(--line);
    border-radius: 2px;
    margin: .6rem auto .3rem;
    flex-shrink: 0;
  }
  .modal > * { overflow-y: auto; }
  @keyframes sheet-up {
    from { transform: translateY(100%); }
    to   { transform: none; }
  }
  .modal .hero { height: 180px; flex-shrink: 0; }
  .modal .close {
    top: .65rem; right: .65rem;
    width: 34px; height: 34px;
  }
  .modal .content { padding: 1.1rem 1rem calc(1.4rem + env(safe-area-inset-bottom, 0)); }
  .modal h2 { font-size: 1.4rem; }
  .modal .sub { font-size: .88rem; margin-bottom: 1rem; }
  .modal .info-row {
    grid-template-columns: repeat(3, 1fr);
    gap: .55rem;
    padding: .75rem 0;
    margin-bottom: .9rem;
  }
  .modal .info-row .item .val { font-size: 1rem; }
  .modal .info-row .item .lbl { font-size: 10px; }
  .modal .desc { font-size: .9rem; max-height: 280px; }
  .modal .modal-actions { gap: .4rem; }
  .modal .modal-actions .btn { padding: .6rem .8rem; font-size: .85rem; flex: 1 1 100%; }
  .modal .modal-actions .btn:active { transform: scale(.97); }

  /* ── LISTE ────────────────────────────────────────────────────── */
  .list-sections { grid-template-columns: 1fr; gap: 1rem; }
  .list-section {
    padding: 1rem 1.1rem;
    border-radius: 16px;
    box-shadow: none;
  }
  .list-section header h2 { font-size: 1.1rem; }
  .list-item { padding: .65rem 0; gap: .65rem; }
  .list-item .thumb { width: 48px; height: 48px; border-radius: 10px; }
  .list-item .info h4 { font-size: .92rem; }
  .list-item .check { width: 30px; height: 30px; }

  /* ── APPUNTAMENTI ─────────────────────────────────────────────── */
  .appt-grid { grid-template-columns: 1fr; gap: .8rem; }
  .appt-header { gap: .6rem; }
  .appt-header h2 { font-size: 1.4rem; }
  .appt-header .btn { font-size: .85rem; padding: .55rem .85rem; }

  .appt-card {
    padding: 1rem 1.1rem;
    border-radius: 14px;
    box-shadow: none;
  }
  .appt-card:hover { transform: none; box-shadow: none; }
  .appt-card:active { transform: scale(.99); }
  .appt-card .date-num { font-size: 1.9rem; }
  .appt-card h3 { font-size: 1.05rem; margin-top: .45rem; }
  .appt-card .notes { font-size: .85rem; }
  .appt-card .row-actions { gap: .35rem; }
  .appt-card .row-actions .btn { font-size: .8rem; padding: .35rem .65rem; }

  /* ── FORM ──────────────────────────────────────────────────────── */
  .form-row { grid-template-columns: 1fr; gap: .8rem; }
  .form-field input, .form-field textarea, .form-field select {
    font-size: 16px;                  /* sotto questa soglia iOS Safari zooma */
    padding: .75rem .9rem;
    border-radius: 10px;
  }

  /* ── LOGIN ─────────────────────────────────────────────────────── */
  .login-screen { padding: 1.2rem; padding-top: max(1.2rem, env(safe-area-inset-top)); }
  .login-card {
    padding: 2rem 1.4rem;
    border-radius: 20px;
    box-shadow: none;
  }
  .login-card h1 { font-size: 1.8rem; }
  .dino-decoration { font-size: 3.6rem; }
  .login-features li { font-size: .88rem; }

  /* ── FAB ──────────────────────────────────────────────────────── */
  /* Importante: alzalo per non finire sotto la bottom-tab */
  .fab {
    width: 54px; height: 54px;
    bottom: calc(72px + env(safe-area-inset-bottom, 0));
    right: 1.1rem;
    box-shadow: 0 4px 14px rgba(15, 118, 110, .35);
  }
  .fab:active { transform: scale(.92); }

  /* ── TOAST ────────────────────────────────────────────────────── */
  .toast-stack {
    bottom: calc(72px + env(safe-area-inset-bottom, 0));
    left: 1rem; right: 1rem;
  }
  .toast {
    font-size: .88rem;
    padding: .75rem 1.1rem;
    text-align: center;
    border-radius: 12px;
  }
}

/* =====================================================================
   MOBILE PICCOLO (≤ 380px) — iPhone SE / Android low-end
   ===================================================================== */
@media (max-width: 380px) {
  .topbar-inner { padding: .45rem .65rem; gap: .5rem; }
  .brand .logo { width: 34px; height: 34px; font-size: 22px; }
  .brand-name  { font-size: .98rem; }
  .section-title { font-size: 1rem; margin-left: .35rem; }
  .user-chip img { width: 30px; height: 30px; }

  main { padding: .9rem .7rem; padding-bottom: calc(80px + env(safe-area-inset-bottom, 0)); }
  .hello-card { padding: 1rem; }
  .hello-card h2 { font-size: 1.25rem; }
  .stat .num { font-size: 1.4rem; }

  .b-tab { font-size: 9.5px; padding: 8px 2px 6px; }
  .b-tab .b-icon { width: 22px; height: 22px; }

  .card h3 { font-size: .88rem; }
  .card .publisher { font-size: 9.5px; }
  .card .meta { font-size: .68rem; gap: .4rem; }

  .modal .info-row { grid-template-columns: repeat(2, 1fr); }

  .appt-card .date-num { font-size: 1.65rem; }
}
