/* ============================================================
   main.css — Stile principale del sito Puzzle Party Ravensburger
   Mobile-first: base per mobile, media query per desktop
   ============================================================ */

/* ---- FONT CUSTOM ---- */
@font-face {
  font-family: 'Quebec Serial Heavy';
  src: url('../fonts/Quebec-Serial-Heavy.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---- VARIABILI CSS ---- */
:root {
  /* Colori primari — Ravensburger blu */
  --rosso:        #195aa9;
  --rosso-scuro:  #0f3d7a;
  --rosso-chiaro: #dce8f7;

  /* Colori neutri */
  --bianco:       #FFFFFF;
  --grigio-chiar: #F5F5F5;
  --grigio-med:   #E0E0E0;
  --grigio:       #E0E0E0;
  --grigio-scuro: #666666;
  --nero:         #222222;

  /* Colori stato */
  --verde:        #2E7D32;
  --verde-bg:     #E8F5E9;
  --arancione:    #E65100;
  --arancione-bg: #FFF3E0;
  --blu:          #195aa9;
  --blu-bg:       #dce8f7;

  /* Header (sovrascrivibili da CSS inline nel layout) */
  --header-bg:    #195aa9;
  --header-color: #FFFFFF;

  /* Tipografia */
  --font-titoli:  'Quebec Serial Heavy', Georgia, serif;
  --font-base:    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-base: 16px;
  --line-height:  1.6;

  /* Spaziatura */
  --gap:          1.5rem;
  --radius:       6px;
  --radius-lg:    12px;

  /* Ombre */
  --ombra-sm:     0 1px 3px rgba(0,0,0,.12);
  --ombra-md:     0 4px 12px rgba(0,0,0,.15);
}

/* ---- RESET BASE ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: var(--font-size-base); scroll-behavior: smooth; }

body {
  font-family: var(--font-base);
  color: var(--nero);
  background: var(--grigio-chiar);
  line-height: var(--line-height);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main.main-content { flex: 1; }

h1, h2, h3, h4, h5, h6 { font-family: var(--font-titoli); font-weight: normal; }

a { color: var(--rosso); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

ul, ol { list-style: none; }

/* ---- CONTAINER ---- */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ---- HEADER ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--ombra-md);
}

/* Riga 1: titolo del sito */
.header-title-bar {
  background: var(--header-bg);
  color: var(--header-color);
  padding: .75rem 0;
}

.header-title-link {
  font-family: var(--font-titoli);
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  font-weight: bold;
  color: var(--header-color);
  text-decoration: none;
  letter-spacing: .02em;
}

.header-title-link:hover { text-decoration: none; opacity: .9; }

/* Riga 2: navigazione — leggermente più scura della riga 1 */
.header-nav-bar {
  background: #114079;
  border-top: 1px solid rgba(255,255,255,.12);
}

.header-nav-container {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding-top: .5rem;
  padding-bottom: .5rem;
}

/* ---- NAVIGAZIONE PRINCIPALE ---- */
.main-nav { flex: 1; }

.nav-list {
  display: flex;
  gap: .25rem;
  align-items: center;
}

.nav-link {
  color: rgba(255,255,255,.9);
  padding: .5rem .75rem;
  border-radius: var(--radius);
  font-size: .95rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255,255,255,.2);
  color: var(--bianco);
  text-decoration: none;
}


/* ---- AREA UTENTE HEADER ---- */
.header-user-area {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

.header-user-nome {
  color: rgba(255,255,255,.85);
  font-size: .85rem;
  white-space: nowrap;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hamburger (mobile) */
.nav-hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: .4rem;
  margin-left: auto;
}
.nav-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--bianco);
  border-radius: 2px;
  transition: transform .2s;
}

/* ---- BOTTONI ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .6rem 1.2rem;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  border: 2px solid transparent;
  text-decoration: none;
  transition: background .15s, color .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; opacity: .9; }

.btn-sm  { padding: .35rem .8rem; font-size: .85rem; }
.btn-lg  { padding: .8rem 1.8rem; font-size: 1.1rem; }

.btn-primary       { background: var(--rosso);    color: var(--bianco); }
.btn-primary:hover { background: var(--rosso-scuro); opacity: 1; }

.btn-outline       { border-color: var(--rosso); color: var(--rosso); background: transparent; }
.btn-outline:hover { background: var(--rosso); color: var(--bianco); opacity: 1; }

.btn-outline-white       { border-color: rgba(255,255,255,.7); color: var(--bianco); background: transparent; }
.btn-outline-white:hover { background: rgba(255,255,255,.2); opacity: 1; }

.btn-white       { background: var(--bianco); color: #195aa9; font-weight: 700; }
.btn-white:hover { background: #f0f6ff; opacity: 1; }

.btn-ghost       { background: transparent; color: var(--grigio-scuro); border-color: var(--grigio-med); }
.btn-ghost:hover { background: var(--grigio-med); opacity: 1; }

.btn-ghost-white       { background: transparent; color: rgba(255,255,255,.8); }
.btn-ghost-white:hover { color: var(--bianco); text-decoration: underline; }

.btn-danger       { background: #B71C1C; color: var(--bianco); }
.btn-danger:hover { background: #7F0000; opacity: 1; }

/* ---- SEZIONI E TITOLI ---- */
.section { padding: 3rem 0; }
.section-title {
  font-size: clamp(1.4rem, 3vw, 2rem);
  color: var(--nero);
  margin-bottom: 2rem;
  position: relative;
  padding-bottom: .75rem;
}
.section-title::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  width: 50px; height: 3px;
  background: var(--rosso);
  border-radius: 2px;
}

.page-header { margin-bottom: 2rem; }
.page-title  { font-size: clamp(1.5rem, 4vw, 2.2rem); color: var(--nero); }

/* ---- HERO ---- */
.hero {
  background: linear-gradient(135deg, var(--rosso) 0%, var(--rosso-scuro) 100%);
  color: var(--bianco);
  padding: 4rem 0;
}

.hero-content { max-width: 700px; }
.hero-content h1, .hero-content h2 { color: var(--bianco); margin-bottom: 1rem; font-size: clamp(1.5rem, 4vw, 2.5rem); }
.hero-content p  { color: rgba(255,255,255,.9); margin-bottom: 1.5rem; font-size: 1.1rem; }

/* ---- CARDS ---- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--gap);
}

.card {
  background: var(--bianco);
  border-radius: var(--radius-lg);
  box-shadow: var(--ombra-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--grigio-med);
}

.card-body   { padding: 1.25rem; flex: 1; }
.card-title  { font-size: 1.1rem; font-weight: 700; margin-bottom: .5rem; color: var(--nero); }
.card-meta   { font-size: .85rem; color: var(--grigio-scuro); margin-bottom: .25rem; }
.card-footer { padding: .75rem 1.25rem; border-top: 1px solid var(--grigio-med); display: flex; gap: .5rem; justify-content: flex-end; }

/* ---- FLASH MESSAGES ---- */
.flash-messages { padding: 0 1rem; margin: 1rem 0; }

.flash {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: .5rem;
  font-size: .95rem;
}

.flash-success { background: var(--verde-bg);     color: var(--verde);     border: 1px solid #A5D6A7; }
.flash-error   { background: #FFEBEE;             color: #C62828;          border: 1px solid #EF9A9A; }
.flash-warning { background: var(--arancione-bg); color: var(--arancione); border: 1px solid #FFCC80; }
.flash-info    { background: var(--blu-bg);       color: var(--blu);       border: 1px solid #90CAF9; }

.flash-testo { flex: 1; }
.flash-chiudi {
  background: none; border: none; cursor: pointer;
  font-size: 1.2rem; line-height: 1; color: inherit; opacity: .6;
}
.flash-chiudi:hover { opacity: 1; }

/* ---- FORM ---- */
.form-group   { margin-bottom: 1.25rem; }
.form-row     { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-label   { display: block; font-weight: 600; margin-bottom: .4rem; font-size: .9rem; }
.form-control {
  width: 100%;
  padding: .6rem .9rem;
  border: 1.5px solid var(--grigio-med);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  background: var(--bianco);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--rosso);
  box-shadow: 0 0 0 3px rgba(200,16,46,.15);
}

.form-error   { display: block; color: #C62828; font-size: .82rem; margin-top: .3rem; }
.form-hint    { display: block; color: var(--grigio-scuro); font-size: .82rem; margin-top: .3rem; }
.form-control.is-error { border-color: #C62828; }

.form-check { display: flex; align-items: flex-start; gap: .5rem; margin-bottom: .75rem; }
.form-check input { margin-top: .2rem; width: 1rem; height: 1rem; flex-shrink: 0; cursor: pointer; }
.form-check-label { font-size: .9rem; cursor: pointer; }

/* ---- TABELLE ---- */
.table-responsive { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.table th {
  background: var(--grigio-chiar);
  font-weight: 700;
  text-align: left;
  padding: .75rem 1rem;
  border-bottom: 2px solid var(--grigio-med);
  white-space: nowrap;
}
.table td {
  padding: .6rem 1rem;
  border-bottom: 1px solid var(--grigio-med);
  vertical-align: middle;
}
.table tr:hover td { background: var(--grigio-chiar); }

/* ---- BADGE DI STATO ---- */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 700;
}
.badge-pending   { background: var(--arancione-bg); color: var(--arancione); }
.badge-confirmed { background: var(--verde-bg);     color: var(--verde); }
.badge-rejected  { background: #FFEBEE;             color: #C62828; }
.badge-open      { background: var(--verde-bg);     color: var(--verde); }
.badge-closed    { background: var(--arancione-bg); color: var(--arancione); }
.badge-finished  { background: var(--grigio-med);   color: var(--grigio-scuro); }
.badge-draft     { background: var(--blu-bg);       color: var(--blu); }

/* ---- PAGINE DI ERRORE ---- */
.error-page { text-align: center; padding: 5rem 0; }
.error-container { max-width: 500px; margin: 0 auto; }
.error-code  { font-size: 6rem; font-weight: 900; color: var(--rosso); line-height: 1; margin-bottom: 1rem; }
.error-title { font-size: 1.8rem; margin-bottom: 1rem; }
.error-text  { color: var(--grigio-scuro); margin-bottom: 2rem; }
.error-debug { text-align: left; background: #1e1e1e; color: #d4d4d4; padding: 1rem; border-radius: var(--radius); font-size: .8rem; margin-bottom: 1.5rem; overflow: auto; }

/* ---- PROSE (contenuto HTML da editor) ---- */
.prose { max-width: 800px; }
.prose h1, .prose h2, .prose h3 { margin: 1.5rem 0 .75rem; color: var(--nero); }
.prose p  { margin-bottom: 1rem; }
.prose ul, .prose ol { margin: 0 0 1rem 1.5rem; list-style: revert; }
.prose a  { color: var(--rosso); text-decoration: underline; }
.prose strong { font-weight: 700; }
.prose h4 { margin: 1.2rem 0 .5rem; color: var(--nero); font-size: 1rem; }
.prose table { width: 100%; border-collapse: collapse; margin-bottom: 1.25rem; font-size: .9rem; }
.prose table th, .prose table td { border: 1px solid #ddd; padding: .5rem .75rem; text-align: left; }
.prose table th { background: #f0f4fa; font-weight: 600; }
.prose code { background: #f0f4fa; padding: .1em .35em; border-radius: 3px; font-size: .88em; }

/* ---- ICONE SVG ---- */
.icon {
  display: inline-block;
  width: 1.2em;
  height: 1.2em;
  vertical-align: middle;
  flex-shrink: 0;
}
.icon-sm  { width: 1em;    height: 1em;   }
.icon-md  { width: 1.5em;  height: 1.5em; }
.icon-lg  { width: 2em;    height: 2em;   }
.icon-xl  { width: 2.5em;  height: 2.5em; }

/* Link social con icona: usati nel footer e ovunque serva */
.social-link {
  display: inline-flex;
  align-items: center;
  gap: .45em;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: .9rem;
  transition: color .15s;
}
.social-link:hover { color: #fff; text-decoration: none; }
.social-link .icon { color: currentColor; }

/* ---- FOOTER ---- */
.site-footer {
  background: #1a1a1a;
  color: rgba(255,255,255,.8);
  padding: 3rem 0 0;
  margin-top: auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer-heading { color: var(--bianco); font-size: 1rem; margin-bottom: .75rem; }
.footer-text    { font-size: .85rem; line-height: 1.7; margin-bottom: .5rem; }
.footer-credits { font-size: .82rem; color: rgba(255,255,255,.5); margin-top: .5rem; }
.footer-links   { display: flex; flex-direction: column; gap: .4rem; }
.footer-link    { color: rgba(255,255,255,.7); font-size: .85rem; text-decoration: none; transition: color .15s; }
.footer-link:hover { color: var(--bianco); }

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,.1);
  padding: 1rem 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
}

.footer-legal { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.footer-legal-link { color: rgba(255,255,255,.5); font-size: .8rem; }
.footer-legal-link:hover { color: var(--bianco); }
.footer-sep  { color: rgba(255,255,255,.3); }
.footer-copy { font-size: .8rem; color: rgba(255,255,255,.4); }

/* ---- COOKIE BANNER ---- */
.cookie-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 9000;
  background: #fefae8;
  box-shadow: 0 -4px 20px rgba(0,0,0,.18);
  border-top: 3px solid #e6c800;
}

.cookie-banner-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.25rem 1rem;
}

.cookie-titolo { font-size: 1.1rem; margin-bottom: .5rem; }
.cookie-testo  { font-size: .9rem; color: var(--grigio-scuro); margin-bottom: 1rem; }
.cookie-link   { color: var(--rosso); }

.cookie-opzioni { margin-bottom: 1rem; }
.cookie-categoria {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  margin-bottom: .5rem;
  font-size: .88rem;
  cursor: pointer;
}
.cookie-categoria input { margin-top: .15rem; flex-shrink: 0; }

.cookie-azioni { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* Pulsanti di scelta del banner: identici per forma e colore (GDPR — no dark pattern) */
.btn-cookie {
  background: #fff;
  color: #333;
  border: 2px solid #555;
  border-radius: var(--radius);
  padding: .4rem 1rem;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-cookie:hover {
  background: #f0f0f0;
  border-color: #333;
}

/* ---- AUTH PAGES ---- */
.auth-box {
  max-width: 420px;
  margin: 2rem auto;
  background: var(--bianco);
  border: 1px solid var(--grigio);
  border-radius: 8px;
  padding: 2rem 2rem 1.5rem;
  box-shadow: 0 2px 12px rgba(0,0,0,.07);
}

.auth-box-wide { max-width: 640px; }

.auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--rosso);
  margin: 0 0 1.25rem;
  text-align: center;
}

.auth-intro {
  font-size: .92rem;
  color: var(--grigio-scuro);
  text-align: center;
  margin: -.5rem 0 1.25rem;
  line-height: 1.5;
}

.auth-link {
  text-align: center;
  font-size: .88rem;
  color: var(--grigio-scuro);
  margin-top: 1rem;
}
.auth-link a { color: var(--rosso); }
.auth-link a:hover { text-decoration: underline; }

/* ---- PAGE TITLE ---- */
.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--blu-scuro, #1a1a2e);
  margin: 0 0 1.5rem;
}

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--grigio-scuro);
  font-size: 1rem;
}

/* ---- TABLE WRAPPER (alias) ---- */
.table-wrapper { overflow-x: auto; }

/* ---- BADGES ---- */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}
.badge-success   { background: #d1fae5; color: #065f46; }
.badge-warning   { background: #fef3c7; color: #92400e; }
.badge-danger    { background: #fee2e2; color: #991b1b; }
.badge-secondary { background: #e5e7eb; color: #374151; }


/* ---- CARD (header/body aggiuntivi per card con intestazione) ---- */
.card-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--grigio-med);
  background: #f8f9fb;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
  color: var(--nero);
}
.card-body { padding: 1.5rem; }

/* ---- TORNEI — griglia lista ---- */
.tornei-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.torneo-card {
  background: var(--bianco);
  border: 1px solid var(--grigio-med);
  border-radius: 10px;
  box-shadow: var(--ombra-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
}
.torneo-card:hover { box-shadow: var(--ombra-md); transform: translateY(-2px); }

.torneo-card-header { padding: .85rem 1.25rem .25rem; }

.torneo-card-body { padding: .5rem 1.25rem 1rem; flex: 1; }

.torneo-card-title {
  font-size: 1.15rem;
  margin-bottom: .75rem;
  color: var(--nero);
}

.torneo-card-meta {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: .88rem;
  color: var(--grigio-scuro);
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.torneo-card-meta li { display: flex; align-items: center; gap: .4rem; }
.meta-icon { font-size: .95rem; }

.torneo-card-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--grigio);
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
}

/* ---- TORNEI — pagina dettaglio ---- */
.torneo-detail { max-width: 760px; }

.torneo-detail-header { margin-bottom: 1.5rem; }

.torneo-detail-title {
  font-size: clamp(1.4rem, 3vw, 2rem);
  margin: 0;
}

.info-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .4rem 1.25rem;
  font-size: .92rem;
}
.info-list dt { font-weight: 600; color: var(--grigio-scuro); white-space: nowrap; }
.info-list dd { margin: 0; }

/* ---- PAGINA CONTATTACI ---- */
.page-intro {
  color: var(--grigio-scuro);
  margin-top: .25rem;
  margin-bottom: 2rem;
  line-height: 1.7;
}
.contact-form-wrap {
  max-width: 720px;
}
.required { color: #c0392b; font-weight: bold; }
.optional { color: var(--grigio-med); font-size: .85em; font-weight: normal; }
.form-hint { display: block; font-size: .82rem; color: var(--grigio-med); margin-top: .3rem; }
.form-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  margin-top: 1.5rem;
}
.form-required-note { font-size: .82rem; color: var(--grigio-med); }
.form-actions-btn { margin-top: 1.2rem; }

/* Box conferma invio */
.contact-success-box {
  max-width: 540px;
  text-align: center;
  padding: 3rem 2rem;
  border: 2px solid #d4edda;
  border-radius: 8px;
  background: #f0faf3;
}
.contact-success-icon {
  width: 60px; height: 60px; line-height: 60px;
  border-radius: 50%;
  background: #28a745;
  color: #fff;
  font-size: 1.8rem;
  margin: 0 auto 1.25rem;
}
.contact-success-title { color: #155724; margin: 0 0 .75rem; font-size: 1.4rem; }
.contact-success-text  { color: #2d6a4f; line-height: 1.7; margin: 0; }

/* ---- MOBILE RESPONSIVE ---- */
@media (max-width: 768px) {
  .header-nav-container { flex-wrap: wrap; }

  .main-nav {
    display: none;
    width: 100%;
    order: 3;
  }
  .main-nav.aperto { display: block; }

  .nav-list { flex-direction: column; align-items: stretch; gap: 0; padding: .5rem 0; }
  .nav-link { display: block; border-radius: 0; }

  .nav-hamburger { display: flex; }

  .header-user-area { order: 2; margin-left: auto; }
  .header-user-nome { display: none; }

  .hero { padding: 2.5rem 0; }
  .cards-grid { grid-template-columns: 1fr; }
  .footer-bottom { flex-direction: column; text-align: center; }
  .form-row { grid-template-columns: 1fr; }
}
