/* =============================================================
   ALCAMPETTO · style.css · v0.3.0
   Foglio di stile condiviso da tutte le pagine del progetto.

   DIPENDENZE ESTERNE:
   Google Fonts — caricato nell'<head> di ogni pagina HTML con:
     <link href="https://fonts.googleapis.com/css2?family=Bebas+Neue
               &family=IBM+Plex+Mono:wght@400;600
               &family=IBM+Plex+Sans:ital,wght@0,400;0,600;1,400
               &display=swap" rel="stylesheet">
   Senza connessione a internet il browser usa i font di sistema
   come fallback (sans-serif e monospace).
   ============================================================= */


/* -------------------------------------------------------------
   VARIABILI GLOBALI (CSS custom properties)
   Modificare qui per cambiare l'aspetto dell'intero sito.

   Colori principali:
   --orange : colore accentuato, usato per loghi, bordi attivi,
              link e pulsanti in evidenza. Modificare per cambiare
              il colore dominante del sito.
   --black  : sfondo della pagina
   --dark   : sfondo di header, footer e card
   --mid    : sfondo di elementi secondari (input, placeholder)
   --line   : colore di bordi e linee di separazione
   --text   : testo principale
   --muted  : testo secondario (etichette, metadati)
   --green  : pill booleane "sì" e indicatore freschezza verde
   --yellow : indicatore freschezza giallo

   Font:
   --font-display : Bebas Neue · titoli e numeri grandi
   --font-mono    : IBM Plex Mono · etichette e metadati
   --font-body    : IBM Plex Sans · testo corrente
   ------------------------------------------------------------- */
:root {
  --orange:       #FF5F1F;
  --black:        #0d0d0d;
  --dark:         #161616;
  --mid:          #242424;
  --line:         #2e2e2e;
  --text:         #e8e8e8;
  --muted:        #888;
  --green:        #4ade80;
  --yellow:       #fbbf24;
  --font-display: 'Bebas Neue', sans-serif;
  --font-mono:    'IBM Plex Mono', monospace;
  --font-body:    'IBM Plex Sans', sans-serif;
}


/* -------------------------------------------------------------
   RESET BASE
   Azzera margini e padding su tutti gli elementi.
   box-sizing: border-box fa sì che padding e bordi siano
   inclusi nella larghezza dichiarata — più intuitivo.
   ------------------------------------------------------------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--black);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden; /* evita scroll orizzontale accidentale */
}


/* -------------------------------------------------------------
   SFONDO A GRIGLIA
   Griglia decorativa fissa dietro a tutto il contenuto.
   Generata con due gradienti lineari sovrapposti.
   · Per cambiare la spaziatura: background-size (default 48px)
   · Per renderla più/meno visibile: opacity (default 0.4)
   ------------------------------------------------------------- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.4;
  pointer-events: none;
  z-index: 0;
}


/* -------------------------------------------------------------
   HEADER
   Barra superiore presente su tutte le pagine.
   Contiene: logo, tagline, pulsanti About e cambio lingua.
   ------------------------------------------------------------- */
header {
  position: relative;
  z-index: 1;
  border-bottom: 3px solid var(--orange);
  background: var(--dark);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem 0;
}

/* Logo — è un link <a> verso la homepage.
   Contiene un SVG inline con il logotipo vettoriale
   (semicerchio al posto della C, linea di centrocampo). */
.logo {
  display: inline-block;
  text-decoration: none;
  line-height: 0;
  flex-shrink: 0;
}
.logo svg {
  height: clamp(2.8rem, 6.5vw, 4.5rem);
  width: auto;
}

.tagline {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-left: 2px solid var(--line);
  padding-left: 1rem;
  line-height: 1.6;
}

/* Gruppo pulsanti destra header (About, IT/EN) */
.lang-switch {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-decoration: none;
  background: var(--mid);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 0.4rem 0.8rem;
  border-radius: 2px;
  transition: all 0.15s;
  white-space: nowrap;
}
.lang-btn:hover  { border-color: var(--orange); color: var(--text); }
/* Pagina corrente: bordo e testo arancione */
.lang-btn.active { border-color: var(--orange); color: var(--orange); }
.lang-btn .flag  { font-size: 1rem; line-height: 1; }


/* -------------------------------------------------------------
   BARRA CONTROLLI (index.html e index.en.html)
   Contiene: ricerca testuale, filtri booleani, ordinamento,
   contatore risultati.
   ------------------------------------------------------------- */
.controls {
  position: relative;
  z-index: 1;
  background: var(--dark);
  border-bottom: 1px solid var(--line);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 380px;
}

.search-wrap input {
  width: 100%;
  background: var(--mid);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.6rem 1rem 0.6rem 2.4rem;
  outline: none;
  border-radius: 2px;
  transition: border-color 0.2s;
}
.search-wrap input:focus        { border-color: var(--orange); }
.search-wrap input::placeholder { color: var(--muted); }

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.9rem;
}

.filter-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.filter-btn {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--mid);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.15s;
}
.filter-btn:hover  { border-color: var(--orange); color: var(--text); }
.filter-btn.active { background: var(--orange); color: white; border-color: var(--orange); }

.sort-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sort-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-right: 0.2rem;
}

.sort-btn {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--mid);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.15s;
}
.sort-btn:hover  { border-color: var(--orange); color: var(--text); }
.sort-btn.active { color: var(--orange); border-color: var(--orange); }

.count-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  margin-left: auto;
}
.count-label strong { color: var(--orange); }


/* -------------------------------------------------------------
   GRIGLIA CARD (index.html e index.en.html)
   Colonne automatiche: minimo 320px ciascuna.
   · Per card più larghe: aumentare 320px
   · Per card più strette: diminuire 320px
   ------------------------------------------------------------- */
main#grid {
  position: relative;
  z-index: 1;
  padding: 1.5rem 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}


/* -------------------------------------------------------------
   CARD
   La classe .visible viene aggiunta dall'IntersectionObserver
   in alcampetto.js quando la card entra nel viewport.
   ------------------------------------------------------------- */
.card {
  background: var(--dark);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s, transform 0.15s;
}
.card:hover { border-color: var(--orange); transform: translateY(-2px); }

.card.visible {
  animation: fadeIn 0.4s ease both;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Foto panoramica in cima alla card
   · Per foto più alte: aumentare height (default 160px) */
.card-photo {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
  background: var(--mid);
  cursor: zoom-in;
}

.card-photo-placeholder {
  width: 100%;
  height: 160px;
  background: var(--mid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--line);
  border-bottom: 1px solid var(--line);
}

.card-header {
  background: var(--mid);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.card-num {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--orange);
  line-height: 1;
  margin-right: 0.75rem;
  min-width: 2.5rem;
}

.card-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  line-height: 1.2;
  flex: 1;
}

.card-date {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--muted);
  white-space: nowrap;
  margin-left: 0.5rem;
}

.card-body {
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.info-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  font-size: 0.82rem;
}

.info-label {
  font-family: var(--font-mono);
  font-size: 0.63rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  min-width: 72px;
  padding-top: 0.15rem;
  flex-shrink: 0;
}

.info-val { color: var(--text); line-height: 1.4; }


/* -------------------------------------------------------------
   INDICATORE DI FRESCHEZZA
   Segnale visivo sull'aggiornamento dei dati.
   Le soglie temporali sono in alcampetto.js (freshnessClass).
   · Per cambiare i colori: modificare --green, --yellow, --muted
   ------------------------------------------------------------- */
.freshness {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-left: 0.4rem;
}

.freshness-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.freshness.fresh .freshness-dot { background: var(--green); }
.freshness.fresh                 { color: var(--green); }
.freshness.aging .freshness-dot  { background: var(--yellow); }
.freshness.aging                  { color: var(--yellow); }
.freshness.stale .freshness-dot  { background: var(--muted); }
.freshness.stale                  { color: var(--muted); }


/* -------------------------------------------------------------
   PILL BOOLEANE (illuminato / recintato / coperto)
   .yes = verde · .no = grigio scuro
   ------------------------------------------------------------- */
.booleans {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.bool-pill {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  padding: 0.2rem 0.55rem;
  border-radius: 1px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid;
}
.bool-pill.yes { background: #14532d; color: var(--green);  border-color: #166534; }
.bool-pill.no  { background: #1c1c1c; color: var(--muted);  border-color: var(--line); }


/* -------------------------------------------------------------
   THUMBNAIL FOTO DI DETTAGLIO
   · Per miniature più grandi: aumentare width e height (56px)
   ------------------------------------------------------------- */
.thumbs {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.1rem;
}
.thumbs img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 2px;
  border: 1px solid var(--line);
  flex-shrink: 0;
  cursor: zoom-in;
  transition: border-color 0.15s;
}
.thumbs img:hover { border-color: var(--orange); }


/* -------------------------------------------------------------
   PIÈ DI CARD
   ------------------------------------------------------------- */
.card-footer {
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.maps-btn {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  background: transparent;
  border: 1px solid var(--orange);
  color: var(--orange);
  padding: 0.35rem 0.75rem;
  border-radius: 2px;
  transition: all 0.15s;
}
.maps-btn:hover { background: var(--orange); color: white; }

.coord {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--muted);
  margin-left: auto;
}


/* -------------------------------------------------------------
   LIGHTBOX
   Si attiva con la classe .open aggiunta da alcampetto.js.
   ------------------------------------------------------------- */
#lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 100;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
#lightbox.open { display: flex; }

#lightbox img {
  max-width: 90vw;
  max-height: 88vh;
  border-radius: 3px;
  border: 1px solid var(--line);
  box-shadow: 0 0 80px rgba(255, 95, 31, 0.15);
}

#lightbox-close {
  position: absolute;
  top: 1.2rem;
  right: 1.5rem;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  font-family: var(--font-mono);
  line-height: 1;
  background: none;
  border: none;
}


/* -------------------------------------------------------------
   MESSAGGI DI STATO
   ------------------------------------------------------------- */
.state-msg {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}


/* -------------------------------------------------------------
   PAGINA ABOUT (about.html e about.en.html)
   · Per testo più largo o più stretto: modificare max-width
   ------------------------------------------------------------- */
main.about {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 3rem auto;
  padding: 0 2rem;
}

.page-title {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  color: var(--orange);
  letter-spacing: 0.04em;
  line-height: 1;
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1.25rem;
}

.section { margin-bottom: 2.5rem; }

.section-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: 0.06em;
  color: var(--text);
  margin-bottom: 0.9rem;
}

.section p,
.section ul {
  font-size: 0.95rem;
  line-height: 1.75;
  color: #c8c8c8;
  margin-bottom: 0.85rem;
}
.section ul       { margin-left: 2em; }
.section p:last-child { margin-bottom: 0; }

.section a {
  color: var(--orange);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}
.section a:hover { border-color: var(--orange); }

.meta-block {
  background: var(--dark);
  border: 1px solid var(--line);
  border-left: 3px solid var(--orange);
  padding: 1rem 1.25rem;
  margin-top: 1rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.8;
  border-radius: 0 2px 2px 0;
}
.meta-block strong { color: var(--text); font-weight: 600; }


/* -------------------------------------------------------------
   FOOTER
   ------------------------------------------------------------- */
footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--line);
  background: var(--dark);
  padding: 1.2rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

main.about ~ footer { margin-top: 4rem; }

.footer-meta {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  line-height: 1.8;
}
.footer-meta a { color: var(--orange); text-decoration: none; }

.json-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-decoration: none;
  background: var(--mid);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 2px;
  transition: all 0.15s;
}
.json-btn:hover { border-color: var(--orange); color: var(--orange); }


/* -------------------------------------------------------------
   RESPONSIVE — schermi stretti (max 600px)
   ------------------------------------------------------------- */
@media (max-width: 600px) {
  header,
  .controls,
  main#grid,
  footer     { padding-left: 1rem; padding-right: 1rem; }
  main.about { padding: 0 1rem; margin: 2rem auto; }
  .tagline   { display: none; }
}
