/* =============================================================================
   THEMING — contratto delle variabili
   Il tema di default (:root) è Mothership: terminale sci-fi horror. Gli altri
   temi sono blocchi [data-theme="..."] in fondo al file che sovrascrivono
   SOLO variabili (+ qualche ritocco scoped). Il tema attivo è impostato su
   <html data-theme="..."> da uno snippet inline in ogni pagina (anti-flash)
   e da js/theme.js (selettore in nav, persistito in localStorage).
   ========================================================================== */
:root {
  /* superfici e testo */
  --bg: #050607;
  --panel: #0c0e10;
  --panel-2: #131619;
  --line: #23282c;
  --ink: #e6e9ea;
  --muted: #6e7679;
  /* semantici */
  --accent: #ff3b3b;      /* colore identitario del tema */
  --accent-ink: #0a0a0a;  /* testo sopra --accent */
  --danger: #ff3b3b;      /* azioni distruttive (in mothership = accent) */
  --ok: #35d68f;          /* conferme / vincitori */
  --ok-ink: #0a0a0a;
  --warn: #e0a83e;        /* stati in sospeso */
  --focus: var(--accent);
  /* tipografia */
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-label: 'JetBrains Mono', 'SF Mono', ui-monospace, Consolas, monospace;
  --font-title: var(--font-label);
  --label-transform: uppercase;
  /* geometria */
  --radius: 4px;       /* card */
  --radius-sm: 3px;    /* bottoni, input, chip */
  --radius-chip: 3px;  /* pillole opt */
  /* decorazioni d'identità */
  --h1-prefix: '// ';
  --h1-prefix-color: var(--accent);
  --nav-prefix: '▓ ';
  --nav-title-color: var(--accent);
  --tag-open: '[';
  --tag-close: ']';
  --card-tick-color: rgba(255, 59, 59, .55); /* tacche HUD agli angoli card */
  --nav-shadow: 0 1px 0 rgba(255, 59, 59, .15);
  --body-bg:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.012) 0px, rgba(255,255,255,0.012) 1px, transparent 1px, transparent 3px),
    radial-gradient(ellipse at top, #0a0c0e 0%, var(--bg) 60%);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--body-bg);
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  padding-bottom: 60px;
}
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }

/* nav -- barra terminale */
#nav {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  margin-bottom: 26px;
  box-shadow: var(--nav-shadow);
}
.nav-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.nav-title {
  font-family: var(--font-label);
  font-weight: 700;
  letter-spacing: .08em;
  font-size: 12px;
  color: var(--nav-title-color);
  flex: none;
}
.nav-title::before { content: var(--nav-prefix); }
.nav-links {
  display: flex;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-family: var(--font-label);
  font-size: 12px;
  letter-spacing: .03em;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  flex: none;
  text-transform: var(--label-transform);
}
.nav-links a:hover { color: var(--ink); background: var(--panel-2); }
.nav-links a.active { color: var(--ink); background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--accent); }

@media (max-width: 560px) {
  .nav-title { display: none; }
}

/* identità giocatore + selettore tema */
#identity, #themePicker {
  font-family: var(--font-label);
  font-size: 11.5px;
  color: var(--muted);
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
#nav select {
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font-label);
  font-size: 11.5px;
  padding: 5px 6px;
}

h1 { font-size: 21px; font-weight: 700; margin: 0 0 4px; letter-spacing: -.01em; }
h1.page-title { margin-bottom: 4px; font-family: var(--font-title); text-transform: var(--label-transform); letter-spacing: .03em; }
h1.page-title::before { content: var(--h1-prefix); color: var(--h1-prefix-color); }
.page-sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }

/* card = pannello con "tacche" da HUD agli angoli */
.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card::before, .card::after {
  content: '';
  position: absolute;
  width: 9px;
  height: 9px;
  border-top: 2px solid var(--card-tick-color);
  top: -1px;
}
.card::before { left: -1px; border-left: 2px solid var(--card-tick-color); }
.card::after { right: -1px; border-right: 2px solid var(--card-tick-color); }
.card h2 {
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 4px;
  font-family: var(--font-title);
  text-transform: var(--label-transform);
  letter-spacing: .05em;
  color: var(--ink);
}
.card .hint { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; line-height: 1.5; }

/* badge/stat */
.summary-row { display: flex; flex-wrap: wrap; gap: 10px; }
.badge-stat {
  flex: 1 1 130px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; margin-right: 2px; vertical-align: -1px; }
.badge-stat .n { font-family: var(--font-label); font-size: 18px; font-weight: 700; }
.badge-stat .l { font-size: 10.5px; color: var(--muted); line-height: 1.2; text-transform: var(--label-transform); letter-spacing: .03em; }

/* forms */
label.field-label {
  display: block;
  font-family: var(--font-label);
  font-size: 11px;
  color: var(--muted);
  margin: 14px 0 6px;
  text-transform: var(--label-transform);
  letter-spacing: .06em;
}
input[type=text], input[type=number], input[type=date], input[type=url], select, textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  font-size: 16px; /* iOS: sotto 16px Safari zooma sul focus */
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--focus); outline-offset: 1px; }
textarea { resize: vertical; min-height: 60px; }

.opt-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { position: relative; }
.opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; width: 100%; height: 100%; }
.opt > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: var(--radius-chip);
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-family: var(--font-label);
  font-size: 13px;
  color: var(--muted);
  transition: .12s;
  touch-action: manipulation;
}
.opt input:checked + span {
  background: var(--chip-bg, var(--panel-2));
  border-color: var(--chip-c, var(--accent));
  color: var(--ink);
  font-weight: 600;
}
.opt input:focus-visible + span { outline: 1px solid var(--ink); outline-offset: 2px; }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > * { flex: 1 1 160px; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
button {
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: .02em;
  text-transform: var(--label-transform);
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  min-height: 42px;
  cursor: pointer;
  transition: .12s;
  touch-action: manipulation;
}
button:focus-visible { outline: 1px solid var(--ink); outline-offset: 2px; }
button:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ok { background: var(--ok); color: var(--ok-ink); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-ghost:hover { color: var(--ink); border-color: var(--muted); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-small { padding: 9px 14px; min-height: 36px; font-size: 11.5px; border-radius: var(--radius-sm); }

/* liste (giochi / sessioni / poll) */
.list-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.list-row:last-child { border-bottom: none; }
.list-main { display: flex; flex-direction: column; gap: 5px; flex: 1 1 240px; }
.list-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-weight: 700; }
.tag {
  font-family: var(--font-label);
  font-size: 10px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  text-transform: var(--label-transform);
  letter-spacing: .04em;
  border: 1px solid currentColor;
}
.tag::before { content: var(--tag-open); }
.tag::after { content: var(--tag-close); }
.tag.status-planned { color: var(--warn); }
.tag.status-played { color: var(--ok); }
.tag.status-cancelled, .tag.status-open-danger { color: var(--danger); }
.tag.status-postponed { color: var(--muted); }
.tag.status-open { color: var(--warn); }
.tag.status-closed { color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-label);
  font-size: 11px;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: var(--radius-chip);
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
  touch-action: manipulation;
}
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* barre voto sondaggio */
.poll-row { margin-bottom: 18px; }
.poll-row .poll-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; gap: 8px; }
.poll-row .poll-label .n { font-family: var(--font-label); color: var(--muted); font-size: 11.5px; }
.poll-row .poll-track { height: 7px; border-radius: 2px; background: var(--panel-2); overflow: hidden; margin-bottom: 10px; }
.poll-row .poll-fill { height: 100%; background: var(--accent); }
.poll-row.is-winner .poll-fill { background: var(--ok); }

/* rating a chip numerate (niente stelline: readout da terminale) */
.rating-grid { display: flex; gap: 6px; }
.rating-grid .opt > span { min-width: 38px; justify-content: center; }

.empty { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 13px; font-family: var(--font-label); }
.empty b { color: var(--ink); }
.status-msg { font-size: 11.5px; color: var(--muted); min-height: 16px; margin-top: 8px; font-family: var(--font-label); }
.status-msg.is-error { color: var(--danger); }

footer.page-footer {
  text-align: center;
  color: var(--muted);
  font-size: 10.5px;
  margin-top: 30px;
  font-family: var(--font-label);
  letter-spacing: .04em;
  text-transform: var(--label-transform);
}

@media (max-width: 480px) {
  .card { padding: 14px 14px; }
  h1 { font-size: 18px; }
  .form-actions { flex-direction: column; }
  .form-actions button { width: 100%; }
  .row-actions { width: 100%; }
  .row-actions button { flex: 1 1 auto; }
}

/* =============================================================================
   TEMI — override del contratto qui sopra. Un blocco per gioco.
   ========================================================================== */

/* --- Fiasco: carta crema + arancio caper, retro anni '50-'60, chiaro --- */
[data-theme="fiasco"] {
  /* superfici e testo */
  --bg: #f6eed9;
  --panel: #fdf8ea;
  --panel-2: #efe3c8;
  --line: #d9c9a6;
  --ink: #241a10;
  --muted: #6b5a45;
  /* semantici (warn/danger sono usati solo come testo/bordo: nessun *-ink nel contratto) */
  --accent: #b04310;
  --accent-ink: #fff6e3;
  --danger: #b02818;
  --ok: #3e6f34;
  --ok-ink: #fff6e3;
  --warn: #8a5000;
  /* --focus, --h1-prefix-color, --nav-title-color ereditano var(--accent) e seguono l'accent del tema */
  --font-body: 'Avenir Next', 'Trebuchet MS', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-label: 'Avenir Next', 'Trebuchet MS', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-title: var(--font-label);
  --label-transform: none;
  /* geometria */
  --radius: 8px;
  --radius-sm: 6px;
  --radius-chip: 6px;
  /* decorazioni d'identità */
  --h1-prefix: '';
  --nav-prefix: '';
  --tag-open: '';
  --tag-close: '';
  --card-tick-color: transparent;
  --nav-shadow: none;
  --body-bg: linear-gradient(180deg, #f9f3e1 0%, #f6eed9 55%, #f1e6ca 100%);
}
[data-theme="fiasco"] h1,
[data-theme="fiasco"] h2 {
  letter-spacing: 0.02em;
  text-transform: none;
}

/* --- Green Oaks: verde bosco + crema burro, morbido e accogliente, chiaro --- */
[data-theme="greenoaks"] {
  /* superfici e testo — crema burro, carta calda, verde bosco */
  --bg: #f3edda;
  --panel: #fbf7ea;
  --panel-2: #ece4cc;
  --line: #d6cbac;
  --ink: #33402a;
  --muted: #5d6a4e;
  /* semantici — verde bosco identitario, terracotta da tombola */
  --accent: #3f6b3d;
  --accent-ink: #fbf7ea;
  --danger: #a8432c;
  --ok: #3f6b3d;
  --ok-ink: #fbf7ea;
  --warn: #8a5a12;
  --focus: var(--accent);
  /* tipografia — umanista e rotonda, niente monospace, niente uppercase */
  --font-body: 'Seravek', 'Gill Sans Nova', Ubuntu, Calibri, 'DejaVu Sans', system-ui, sans-serif;
  --font-label: ui-rounded, 'SF Pro Rounded', 'Hiragino Maru Gothic ProN', 'Arial Rounded MT Bold', Calibri, system-ui, sans-serif;
  --font-title: var(--font-label);
  --label-transform: none;
  /* geometria — angoli morbidi, chip a pillola */
  --radius: 13px;
  --radius-sm: 10px;
  --radius-chip: 999px;
  /* identità — niente terminale: un fiorellino in nav e basta */
  --h1-prefix: '';
  --h1-prefix-color: var(--accent);
  --nav-prefix: '✿ ';
  --nav-title-color: var(--accent);
  --tag-open: '';
  --tag-close: '';
  --card-tick-color: transparent;
  --nav-shadow: 0 2px 10px rgba(93, 76, 40, .10);
  --body-bg:
    radial-gradient(1100px 420px at 50% -120px, rgba(111, 138, 88, .14), transparent 70%),
    linear-gradient(#f7f1e0, #f3edda);
}
[data-theme="greenoaks"] .card {
  box-shadow: 0 1px 3px rgba(93, 76, 40, .06), 0 8px 20px rgba(93, 76, 40, .05);
}
[data-theme="greenoaks"] .tag {
  background: rgba(255, 255, 255, .45);
}

/* --- Vaesen: gotico nordico, blu-grigio nebbia + serif, scuro freddo --- */
[data-theme="vaesen"] {
  /* superfici e testo — nebbia nordica, blu-grigio profondo */
  --bg: #10151c;
  --panel: #171e27;
  --panel-2: #1f2833;
  --line: #303c49;
  --ink: #dde6ee;
  --muted: #9fb2c1;
  /* semantici — teal glaciale come identità, oro antico per gli stati sospesi */
  --accent: #8fcfc6;
  --accent-ink: #0d1319;
  --danger: #dd9199;
  --ok: #9cc9a4;
  --ok-ink: #0d1611;
  --warn: #cfae6f;
  --focus: var(--accent);
  /* tipografia — serif ottocentesco di sistema */
  --font-body: Georgia, 'Palatino Linotype', 'Book Antiqua', 'Times New Roman', serif;
  --font-label: Georgia, 'Palatino Linotype', Palatino, serif;
  --font-title: Georgia, 'Palatino Linotype', Palatino, serif;
  --label-transform: uppercase;
  /* geometria — angoli appena più morbidi, chip a pillola */
  --radius: 6px;
  --radius-sm: 4px;
  --radius-chip: 999px;
  /* decorazioni d'identità — silenzio: niente prefissi, niente brackets */
  --h1-prefix: '';
  --h1-prefix-color: var(--accent);
  --nav-prefix: '';
  --nav-title-color: var(--ink);
  --tag-open: '';
  --tag-close: '';
  --card-tick-color: rgba(205, 218, 229, .18);
  --nav-shadow: 0 1px 0 rgba(210, 224, 236, .07);
  --body-bg:
    radial-gradient(ellipse at 50% 118%, rgba(96, 118, 140, .28) 0%, rgba(96, 118, 140, 0) 62%),
    linear-gradient(180deg, #0b0f15 0%, #10151c 55%, #151d27 100%);
}
[data-theme="vaesen"] h1.page-title { letter-spacing: .09em; }
[data-theme="vaesen"] .nav-title,
[data-theme="vaesen"] label.field-label,
[data-theme="vaesen"] .tag { letter-spacing: .12em; }
