/* =========================================================
   STYLE.CSS — Sala Giochi Vintage
   Stili comuni a hub e giochi.
   ========================================================= */

/* ---------- Reset minimale ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html, body { height: 100%; }
img, svg, canvas { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; }

/* ---------- Palette e font ---------- */
:root {
  --legno: #3a2418;
  --legno-chiaro: #6b4a2f;
  --ottone: #c9a961;
  --rosso: #d4362b;
  --blu: #1a2740;
  --giallo: #f2c744;
  --avorio: #f4ecd8;

  /* Derivati */
  --ottone-scuro: #8f7639;
  --ombra: rgba(0, 0, 0, 0.45);

  --font-titolo: "Rockwell", "Roboto Slab", "Georgia", "Times New Roman", serif;
  --font-testo: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Courier New", monospace;

  --raggio: 14px;
}

body {
  font-family: var(--font-testo);
  color: var(--avorio);
  background-color: var(--legno);
  /* Venatura del legno simulata con gradienti */
  background-image:
    repeating-linear-gradient(92deg, rgba(255,255,255,0.025) 0 2px, transparent 2px 9px),
    repeating-linear-gradient(88deg, rgba(0,0,0,0.08) 0 1px, transparent 1px 23px),
    radial-gradient(ellipse at top, var(--legno-chiaro), var(--legno) 70%);
  background-attachment: fixed;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* =========================================================
   HUB
   ========================================================= */
.sala {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------- Insegna ---------- */
.insegna {
  position: relative;
  text-align: center;
  margin: 0 auto 2.5rem;
  padding: 1.5rem 2.5rem 1.75rem;
  background: var(--blu);
  border: 6px solid var(--ottone);
  border-radius: 18px;
  box-shadow: 0 0 0 3px var(--legno), 0 10px 30px var(--ombra), inset 0 0 30px rgba(0,0,0,0.6);
}
.insegna h1 {
  font-family: var(--font-titolo);
  font-size: clamp(1.8rem, 6vw, 3.4rem);
  letter-spacing: 0.12em;
  line-height: 1.1;
  color: var(--giallo);
  text-shadow:
    0 0 4px var(--giallo),
    0 0 12px rgba(242, 199, 68, 0.8),
    0 0 28px rgba(212, 54, 43, 0.7);
  animation: bagliore 3.5s ease-in-out infinite;
}
.insegna p {
  margin-top: 0.35rem;
  font-size: 0.95rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ottone);
}

/* Luci decorative: file di lampadine sopra e sotto l'insegna */
.insegna::before,
.insegna::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  height: 10px;
  background: radial-gradient(circle, var(--giallo) 0 3px, rgba(242,199,68,0.25) 4px, transparent 5px) 0 0 / 22px 10px repeat-x;
  filter: drop-shadow(0 0 4px var(--giallo));
  animation: lampeggio 1.2s steps(2, jump-none) infinite;
}
.insegna::before { top: 6px; }
.insegna::after  { bottom: 6px; animation-delay: 0.6s; }

@keyframes bagliore {
  0%, 100% { opacity: 1; }
  45% { opacity: 0.92; }
  50% { opacity: 0.7; }
  55% { opacity: 0.95; }
}
@keyframes lampeggio {
  0%   { opacity: 1; }
  100% { opacity: 0.45; }
}

/* ---------- Griglia card ---------- */
.griglia {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  flex: 1;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  background: linear-gradient(160deg, var(--legno-chiaro), var(--legno));
  border: 3px solid var(--ottone);
  border-radius: var(--raggio);
  box-shadow: 0 4px 0 var(--ottone-scuro), 0 8px 18px var(--ombra);
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.card:hover,
.card:focus-visible {
  transform: translateY(-4px);
  box-shadow: 0 8px 0 var(--ottone-scuro), 0 16px 28px var(--ombra);
}
.card:focus-visible { outline: 3px solid var(--giallo); outline-offset: 3px; }
.card:active { transform: translateY(0); }

/* Viti d'ottone negli angoli */
.card::before,
.card::after {
  content: "";
  position: absolute;
  top: 8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--avorio), var(--ottone) 45%, var(--ottone-scuro));
  z-index: 1;
}
.card::before { left: 8px; }
.card::after  { right: 8px; }

.card-miniatura {
  aspect-ratio: 16 / 10;
  background: var(--blu);
  border-bottom: 3px solid var(--ottone);
  display: grid;
  place-items: center;
}
.card-miniatura svg { width: 100%; height: 100%; }

.card-corpo { padding: 1rem 1.1rem 1.2rem; }
.card-titolo {
  font-family: var(--font-titolo);
  font-size: 1.3rem;
  color: var(--giallo);
  letter-spacing: 0.04em;
}
.card-sottotitolo {
  font-size: 0.92rem;
  color: var(--avorio);
  opacity: 0.85;
}

/* Card disabilitata ("Prossimamente") */
.card[aria-disabled="true"] {
  cursor: default;
  filter: grayscale(0.7) brightness(0.8);
  border-style: dashed;
}
.card[aria-disabled="true"]:hover { transform: none; box-shadow: 0 4px 0 var(--ottone-scuro), 0 8px 18px var(--ombra); }

.footer {
  margin-top: 2.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--ottone);
  opacity: 0.8;
}

/* =========================================================
   PAGINE GIOCO
   ========================================================= */
body.gioco {
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  touch-action: none;
}

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  gap: 0.75rem;
  padding: 0.45rem 0.8rem;
  background: rgba(26, 39, 64, 0.88);
  border: 2px solid var(--ottone);
  border-radius: 10px;
  box-shadow: 0 4px 12px var(--ombra);
  z-index: 10;
  pointer-events: none;
}
.hud-item { display: flex; flex-direction: column; align-items: center; min-width: 3.5rem; }
.hud-label {
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ottone);
}
.hud-value {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--giallo);
  font-variant-numeric: tabular-nums;
}

/* ---------- Pulsanti ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  min-height: 44px; /* area di tocco minima */
  font-weight: 600;
  text-decoration: none;
  color: var(--avorio);
  background: var(--legno-chiaro);
  border: 2px solid var(--ottone);
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--ottone-scuro);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.15s;
}
.btn:hover { background: var(--legno); }
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ottone-scuro); }
.btn:focus-visible { outline: 3px solid var(--giallo); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  color: var(--avorio);
  background: var(--rosso);
  border-color: var(--giallo);
  box-shadow: 0 3px 0 #8e1f18;
}
.btn-primary:hover { background: #b82c22; }

.btn-back {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  z-index: 10;
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
  background: rgba(58, 36, 24, 0.9);
}

/* ---------- Overlay vittoria / persa ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(10, 8, 6, 0.7);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 20;
  opacity: 1;
  transition: opacity 0.25s ease;
}
.overlay[hidden] { display: none; }

.overlay-card {
  width: min(92vw, 380px);
  text-align: center;
  padding: 1.75rem 1.5rem;
  background: var(--avorio);
  color: var(--legno);
  border: 5px solid var(--ottone);
  border-radius: 18px;
  box-shadow: 0 0 0 3px var(--legno), 0 20px 40px var(--ombra);
  animation: comparsa 0.3s cubic-bezier(.2,1.4,.4,1);
}
.overlay-card h2 {
  font-family: var(--font-titolo);
  font-size: 2rem;
  color: var(--rosso);
  margin-bottom: 0.5rem;
}
.overlay-card p { margin-bottom: 1.25rem; }
.overlay-card .azioni { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }
.overlay-card .btn { color: var(--avorio); }

@keyframes comparsa {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ---------- Utility ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
  .sala { padding: 1.25rem 0.9rem 2rem; }
  .insegna { padding: 1.2rem 1rem 1.4rem; border-width: 4px; margin-bottom: 1.5rem; }
  .insegna p { letter-spacing: 0.15em; font-size: 0.8rem; }
  .griglia { gap: 1rem; }
  .hud { gap: 0.5rem; padding: 0.35rem 0.6rem; }
  .hud-value { font-size: 1rem; }
  .btn-back { font-size: 0.8rem; padding: 0.35rem 0.8rem; }
}

/* Rispetto per chi riduce le animazioni */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
