/* assets/css/site.css */

/* =========================================================
   THEME / VARIABILI (modifica qui e cambia tutto)
   ========================================================= */
:root{
  /* accent (coerente col banner rosso/arancio) */
  --accent: #f04a1c;
  --accent-hover: #d93f16;

  /* testo */
  --text: #111;
  --text-on-dark: #fff;

  /* bordi/ombre: tono caldo */
  --border: #2a120c;
  --border-accent: #7a2510;
  --shadow: rgba(0,0,0,.25);

  /* neri per bottoni argomenti */
  --black: #0f1116;
  --black-2: #171a22;

  /* layout */
  --maxw: 980px;
  --radius: 12px;
  --outer-pad: 18px;

  /* sfondo esterno */
  --bg-image: url("../img/bg.jpg");
  --bg-overlay: rgba(42, 18, 12, .42); /* overlay caldo */
}

/* =========================================================
   BASE
   ========================================================= */
*{ box-sizing: border-box; }
html, body{ height: 100%; }

body{
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);

  background: var(--bg-image) no-repeat center center fixed;
  background-size: cover;

  padding: var(--outer-pad);
}

/* overlay sullo sfondo esterno */
body::before{
  content: "";
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  pointer-events: none;
  z-index: -1;
}

/* =========================================================
   CORNICE PRINCIPALE (contiene banner + contenuti)
   ========================================================= */
.page{
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;

  background: #ffffff;
  border: 2px solid var(--border);

  box-shadow:
    0 0 0 6px var(--black),
    0 12px 28px rgba(0,0,0,.45);

  padding: 12px 16px 40px;
}

/* =========================================================
   BANNER / HEADER
   (immagine impostata inline in header.php)
   ========================================================= */
.banner{
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;

  min-height: 150px;
  padding: 0;

  border: 2px solid var(--border);
  box-shadow: 0 2px 0 var(--shadow);

  display: flex;
  align-items: center;

  position: relative;
  overflow: hidden;
}

/* overlay leggero sopra l’immagine del banner */
.banner::before{
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.12);
  pointer-events: none;
}

/* banner cliccabile */
.banner-link{
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
}

/* contenuto testuale “di scorta” */
.banner-inner{
  position: relative;
  z-index: 3;

  display: none; /* per riattivarlo: display: grid; */
  grid-template-columns: 90px 1fr 220px;
  gap: 12px;
  align-items: center;
}

.logo{
  width: 90px;
  height: 90px;
  background: #fff;
  border: 2px solid var(--border);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 12px;
  text-align: center;
  line-height: 1.1;
}

.title{ text-align: center; }

.title h1{
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
  letter-spacing: .5px;
  font-weight: 900;
  color: #111;
  text-shadow: 1px 1px 0 #fff;
}

.quote{
  background: rgba(255,255,255,.55);
  border: 2px solid var(--border);
  padding: 10px;
  font-size: 12px;
  line-height: 1.25;
}
.quote em{ font-style: italic; }
.quote .author{
  display: block;
  margin-top: 6px;
  font-weight: 700;
  text-align: right;
}

.siteurl{
  text-align: center;
  margin: 10px 0 16px;
  font-weight: 700;
}

/* =========================================================
   NAVBAR (bottoni arancio/rosso)
   ========================================================= */
.nav{
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 16px;
  justify-content: center;
  margin: 0 auto 22px;
  max-width: 720px;
}

.btn-yellow{
  display: inline-flex;
  justify-content: center;
  align-items: center;
  height: 36px;

  background: var(--accent);
  border: 2px solid var(--border-accent);
  color: #111;
  font-weight: 800;
  text-decoration: none;

  box-shadow: 0 2px 0 var(--shadow);
  transition: transform .05s ease, background .15s ease, filter .15s ease;
}

.btn-yellow:hover{
  background: var(--accent-hover);
  filter: brightness(1.02);
}

.btn-yellow:active{
  transform: translateY(1px);
  filter: brightness(.98);
}

.btn-yellow.is-active{
  outline: 2px solid var(--border-accent);
  outline-offset: 2px;
}

/* =========================================================
   CONTENUTO GENERICO
   ========================================================= */
.content{
  max-width: 860px;
  margin: 0 auto;
  padding: 10px 0 0;
}

.card{
  border: 1px solid #e6e6e6;
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 8px 18px rgba(0,0,0,.06);
  background: #fff;
}

.h1{ font-size: 24px; margin: 0 0 10px; font-weight: 900; }
.p{ margin: 0 0 10px; line-height: 1.5; }

/* =========================================================
   HOME: griglia argomenti (bottoni neri)
   ========================================================= */
.topics{
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 18px 22px;
  max-width: 860px;
  margin: 0 auto;
  padding-top: 10px;
}

.topic{
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 56px;
  padding: 10px 12px;
  text-align: center;
  line-height: 1.15;

  white-space: normal;
  word-break: break-word;

  background: linear-gradient(180deg, var(--black-2), var(--black));
  border: 1px solid #2a2f3a;
  border-radius: var(--radius);
  color: #fff;
  font-weight: 800;
  text-decoration: none;

  box-shadow: 0 8px 18px rgba(0,0,0,.18);
  transition: transform .06s ease, box-shadow .15s ease, border-color .15s ease;
}

.topic:hover{
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(0,0,0,.22);
  border-color: rgba(240, 74, 28, .55);
}

.topic:active{
  transform: translateY(0);
}

/* =========================================================
   INDEX: hero con immagine + login leggibile
   ========================================================= */
.index-hero{
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;

  border: 2px solid var(--border);
  border-radius: 12px;
  overflow: hidden;

  padding: 22px;
  min-height: 320px;

  position: relative;
  display: grid;
  place-items: center;
}

.index-hero::before{
  content:"";
  position:absolute;
  inset:0;
  background: rgba(0,0,0,.22);
  pointer-events:none;
}

.auth-panel{
  position: relative;
  z-index: 2;

  width: min(520px, 100%);
  background: rgba(255,255,255,.92);
  border: 2px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(0,0,0,.25);

  padding: 16px 16px 14px;
  backdrop-filter: blur(2px);
}

.auth-tabs{
  display: flex;
  gap: 10px;
  margin: 10px 0 14px;
}
.auth-tab{
  flex: 1;
  text-align: center;
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid var(--border-accent, var(--border));
  text-decoration: none;
  font-weight: 800;
  color: #111;
  background: #fff;
}
.auth-tab.active{
  background: var(--accent);
}

.auth-field{ margin: 10px 0; }
.auth-field label{ display:block; font-weight:700; margin-bottom:6px; }

.auth-field input{
  width: 100%;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid #d8d8d8;
  outline: none;
}
.auth-field input:focus{
  border-color: rgba(240,74,28,.65);
  box-shadow: 0 0 0 3px rgba(240,74,28,.14);
}

.auth-hint{ font-size: 12px; opacity: .85; margin-top: 6px; }

.auth-btn{
  width: 100%;
  height: 40px;
  border-radius: 12px;
  border: 2px solid var(--border-accent, var(--border));
  background: var(--accent);
  font-weight: 900;
  cursor: pointer;
}

.auth-msg{
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #ddd;
}
.auth-ok{ background:#f3fff3; border-color:#bfe5bf; }
.auth-err{ background:#fff3f3; border-color:#e5bfbf; }

/* =========================================================
   BUSTA PAGA: indice + gallery + lightbox (UNICA VERSIONE)
   ========================================================= */
.busta-index{
  margin: 16px 0 24px;
  padding: 12px;
  border: 1px solid #e3e3e3;
  border-radius: 12px;
  background: #fafafa;
}
.busta-index ol{ padding-left: 18px; }
.busta-index a{ font-weight: 800; text-decoration: none; }
.busta-index a:hover{ text-decoration: underline; }

.gallery{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.card-img{
  border: 1px solid #e3e3e3;
  border-radius: 12px;
  background: #fafafa;
  padding: 10px;
}

/* Preview nella griglia: limite anti-sgranatura */
.card-img img{
  width: 100%;
  max-width: 1400px;
  height: auto;
  margin: 0 auto;
  border-radius: 8px;
  display: block;
  background: #fff;
}

.card-img a img{ cursor: zoom-in; }

.caption{
  margin-top: 8px;
  font-weight: 800;
  text-align: center;
}

/* Lightbox: fondamentale per NON vedere "doppio" */
.lightbox{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  display: none;              /* << nasconde sempre */
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.lightbox:target{
  display: flex;              /* << appare solo quando apri #img-... */
}

.lightbox .close{
  position: absolute;
  inset: 0;
}

/* Stage gestito da JS per zoom/pinch */
.lightbox .lb-stage{
  width: min(95vw, 3000px);
  height: 95vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 10px;
  touch-action: none;
}

.lightbox .lb-img{
  max-width: 100%;
  max-height: 100%;
  transform-origin: 0 0;
  user-select: none;
  -webkit-user-drag: none;
}

/* Toolbar */
.lightbox .lb-toolbar{
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(20,20,20,.55);
  backdrop-filter: blur(6px);
}

.lightbox .lb-btn{
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.12);
  color: #fff;
  font-weight: 900;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}

.lightbox .lb-btn:active{
  transform: translateY(1px);
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 860px){
  .nav{ grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .topics{ grid-template-columns: repeat(2, minmax(150px, 1fr)); }

  .banner-inner{
    grid-template-columns: 70px 1fr;
    grid-template-rows: auto auto;
  }
  .quote{ grid-column: 1 / -1; }
  .logo{ width: 70px; height: 70px; }
}

@media (max-width: 420px){
  .topics{ grid-template-columns: 1fr; }
}

@media (max-width: 600px){
  .banner{
    min-height: 110px;
    background-position: center top;
  }

  .index-hero{
    padding: 14px;
    min-height: 260px;
    background-position: center top;
  }
}

