/* stile.css  —  Triangolo Viola  —  restyling 2026 */

/* ── RESET BASE ── */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  line-height: 1.65;
  color: #000;
  background: #fff;
  max-width: 960px;
  margin-left: auto;
  margin-right: auto;
}

/* ── HEADER con CSS Grid (replica rowspan="2" originale) ── */
#tv-header {
  width: 100%;
  background: #000;
}

#tv-header-grid {
  display: grid;
  /* colonne: triangolo fisso | titolo flessibile | gif fissa */
  grid-template-columns: 89px 1fr 130px;
  /* righe: riga sottotitolo (26px) | riga titolo (68px) = 94px totali
     come il td height="94" dell'originale */
  grid-template-rows: 26px 68px;
  grid-template-areas:
    "logo  subtitle  subtitle"
    "logo  titlebar  animazione";
  background: #000;
}

#tv-logo {
  grid-area: logo;
  background: #000;
  line-height: 0;
  overflow: hidden;
  /* Il logo e' 89x73px: la cella e' 94px quindi aggiungiamo
     padding in basso per centrarlo verticalmente */
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

#tv-logo img {
  display: block;
  width: 89px;
  height: 73px;
  flex-shrink: 0;
}

#tv-supertitle {
  grid-area: subtitle;
  background: #000;
  color: #fff;
  font-size: 13px;
  font-weight: bold;
  padding: 4px 12px;
  font-family: Geneva, Arial, Helvetica, sans-serif;
  text-align: left;
  display: flex;
  align-items: center;
}

#tv-titlebar {
  grid-area: titlebar;
  overflow: hidden;
  line-height: 0;
}

#tv-testa03 {
  display: block;
  width: 100%;
  height: 68px;      /* piu' alto dell'originale: da spazio sopra e sotto */
  object-fit: fill;  /* stira l'immagine per riempire l'altezza aumentata */
}

#tv-animazione {
  grid-area: animazione;
  overflow: hidden;
  line-height: 0;
}

#tv-animgif {
  display: block;
  width: 130px;
  height: 68px;
  object-fit: cover;
}

/* ── NAVBAR ── */
#tv-navbar {
  background: #000;
  border-top: 2px solid #7700aa;
  border-bottom: 2px solid #7700aa;
  padding: 4px 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  align-items: center;
}

#tv-navbar a {
  color: #fff;
  text-decoration: none;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

#tv-navbar a:hover {
  background: #7700aa;
  color: #fff;
}

/* ── FOOTER ── */
/* Padding laterale minimo per il contenuto */
body > table, body > div:not(#tv-header) {
  padding-left: 8px;
  padding-right: 8px;
}

#tv-footer {
  border-top: 1px solid #ccc;
  margin-top: 24px;
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
  color: #555;
}

#tv-footer a { color: #7700aa; }

/* ── CONTENUTO: migliorie tipografiche ── */
/* Le tabelle del contenuto restano intatte, migliorano solo
   leggibilità e comportamento su schermi moderni */

/* impedisce che le tabelle del contenuto escano dallo schermo */
table {
  max-width: 100%;
}

/* le immagini non escono dal loro contenitore */
img {
  max-width: 100%;
  height: auto;
}

/* link standard */
a { color: #0000EE; }
a:visited { color: #551A8B; }

/* font-size minimo leggibile (alcune pagine usano size=1) */
font[size="1"] { font-size: 11px !important; }

/* ── TABELLA BASE (layout esterno originale) ── */
/* La table id="base" wrappa il contenuto - la rendiamo fluida */
table#base {
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
}

/* Le tabelle di contenuto seguono la larghezza del body */
table#base table {
  max-width: 100% !important;
}

/* Il td che conteneva il vecchio header ha width=793 e height=94 fissi.
   Li azzeriamo cosi' non crea spazio bianco ne' stringe il contenuto. */
table#base > tbody > tr:first-child > td,
table#base > tr:first-child > td {
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
}

table#base td {
  width: auto !important;
}

/* Nasconde esplicitamente il vecchio header (ridondante ma sicuro) */
table#testa { display: none !important; }

/* Azzera anche i td con height="94" che restano vuoti dopo aver nascosto testa */
td[height="94"] {
  height: auto !important;
  min-height: 0 !important;
  padding: 0 !important;
  line-height: 0 !important;
  font-size: 0 !important;
}

/* ══════════════════════════════════════
   RESPONSIVE — TABLET (max 900px)
════════════════════════════════════════ */
@media (max-width: 900px) {

  /* Header: riduce leggermente */
  #tv-header-grid {
    grid-template-columns: 70px 1fr 90px;
    grid-template-rows: 22px 54px;
  }
  #tv-logo img { width: 70px; height: 57px; }
  #tv-testa03   { height: 54px; }
  #tv-animgif   { width: 90px; height: 54px; }

  /* Navbar: va a capo pulita */
  #tv-navbar a { padding: 5px 8px; font-size: 11px; }
}

/* ══════════════════════════════════════
   RESPONSIVE — MOBILE (max 600px)
══════════════════════════════════════ */
@media (max-width: 600px) {

  /* Header mobile compatto */
  #tv-header-grid {
    grid-template-columns: 54px 1fr 0px;
    grid-template-rows: 20px 50px;
    grid-template-areas:
      "logo subtitle subtitle"
      "logo titlebar titlebar";
  }
  #tv-animazione { display: none; }
  #tv-logo img   { width: 54px; height: 44px; }
  #tv-testa03    { height: 50px; }
  #tv-supertitle { font-size: 11px; padding: 2px 8px; }

  /* Navbar mobile */
  #tv-navbar { padding: 2px 4px; justify-content: center; }
  #tv-navbar a  { padding: 7px 8px; font-size: 11px; letter-spacing: 0.04em; }

  /* Corpo pagina */
  body { font-size: 15px; overflow-x: hidden; }

  /* Tutte le tabelle di contenuto: ogni cella diventa un blocco */
  table#base, table#base tbody,
  table#base tr, table#base td {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    box-sizing: border-box;
  }

  /* Separatore visivo tra sezioni impilate */
  table#base > tbody > tr > td {
    border-bottom: 1px solid #ddd;
    padding: 6px 8px;
  }

  /* Forza allineamento a sinistra su tutte le celle:
     alcune celle avevano align=center nell'HTML originale
     (es. la sezione EVENTI) che su mobile appare centrata */
  table#base td {
    text-align: left !important;
  }

  /* Le immagini nelle celle di sezione: allineate a sinistra */
  table#base td img {
    display: block;
    margin-left: 0 !important;
    margin-right: auto !important;
  }

  /* Immagini adattive */
  table#base img {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Testo leggibile senza zoom */
  p, li, td, th     { font-size: 15px !important; line-height: 1.65 !important; }
  font[size="6"], font[size="5"] { font-size: 22px !important; }
  font[size="4"]     { font-size: 18px !important; }
  font[size="3"]     { font-size: 16px !important; }
  font[size="2"]     { font-size: 14px !important; }
  font[size="1"]     { font-size: 12px !important; }

  /* Larghezze fisse rimosse */
  td[width], th[width] { width: auto !important; }

  /* Footer */
  #tv-footer { flex-direction: column; gap: 4px; font-size: 12px; text-align: center; }
}
