/*
Theme Name: Meteo Webcam
Theme URI: https://www.meteo-webcam.it
Author: Luca Ciccarelli
Description: Tema leggero per directory di webcam meteo e blog di viaggio: home a griglia di card 16:9, articolo singolo con immagine in evidenza e webcam live servite dal plugin Meteo Webcam Proxy. JavaScript minimo inline (ricerca, preferenze cookie), un solo foglio di stile, nessuna richiesta esterna. Compatibile con Google Site Kit / AdSense.
Version: 2.9.7
Requires at least: 6.0
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: meteo-webcam
Tags: blog, news, one-column, grid-layout, featured-images, custom-menu, translation-ready
*/

/* ============ Base ============ */
:root {
  --bg: #ffffff;
  --bg-alt: #f2f5f8;
  --text: #1c2733;
  --text-soft: #5b6b7a;
  --accent: #0a6ebd;
  --accent-dark: #085a9b;
  --border: #dce3ea;
  --radius: 10px;
  --wrap: 1080px;
  --content: 740px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
}

img, video { max-width: 100%; height: auto; }

a { color: var(--accent); text-decoration: none; }
a:hover, a:focus { color: var(--accent-dark); text-decoration: underline; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }

/* ============ Header ============ */
.site-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  flex-wrap: wrap;
  padding-top: 6px;
  padding-bottom: 6px;
}

.site-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.site-nav { display: flex; align-items: center; gap: 18px; } /* v2.8: menu e lente sulla stessa riga */
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.site-nav a { color: var(--text-soft); font-size: 0.95rem; font-weight: 500; }

/* ============ Ricerca nell'header (v2.6) ============ */
.search-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 9px;
  cursor: pointer;
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.search-toggle svg { display: block; width: 18px; height: 18px; }
.search-toggle:hover, .search-toggle:focus { color: var(--accent); border-color: var(--accent); }

.search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(28, 39, 51, 0.10);
  padding: 18px 0;
}
.search-overlay[hidden] { display: none; }
.search-overlay .search-form { max-width: 560px; margin: 0 auto; }
.search-overlay .search-form input[type="search"] { font-size: 1.05rem; }

/* ============ Griglia articoli (home/archivi) ============ */
.page-title {
  font-size: 1.3rem;
  margin: 24px 0 8px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin: 16px 0 24px;
}

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease;
}

.card:hover, .card:focus-within { border-color: var(--accent); }

.card-thumb { display: block; aspect-ratio: 16 / 9; overflow: hidden; background: var(--bg-alt); }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-title { font-size: 1.05rem; font-weight: 700; margin: 0; line-height: 1.35; }
.card-title a { color: var(--text); }
.card-title a:hover { text-decoration: none; color: var(--accent); }
.card-excerpt { margin: 0; color: var(--text-soft); font-size: 0.92rem; flex: 1; }
.card-meta { font-size: 0.82rem; color: var(--text-soft); }

/* ============ Sottocategorie (v2.9) ============ */
.subcats { margin: 8px 0 28px; }
.subcats-title, .subcats-all { font-size: 1.1rem; margin: 16px 0 12px; }
.subcats-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.subcat {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--text);
  transition: border-color 0.15s ease;
}
.subcat:hover, .subcat:focus-visible { border-color: var(--accent); text-decoration: none; }
.subcat-thumb { display: block; aspect-ratio: 16 / 9; background: var(--bg-alt); overflow: hidden; }
.subcat-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.subcat-name { padding: 8px 10px 0; font-weight: 700; font-size: 0.95rem; line-height: 1.3; }
.subcat:hover .subcat-name { color: var(--accent); }
.subcat-count { padding: 2px 10px 10px; font-size: 0.8rem; color: var(--text-soft); }

/* ============ Articolo singolo ============ */
.post { max-width: var(--content); margin: 0 auto; }

.post-title {
  font-size: 1.7rem;
  line-height: 1.25;
  margin: 28px 0 4px;
  letter-spacing: -0.015em;
}

.post-meta { color: var(--text-soft); font-size: 0.88rem; margin-bottom: 16px; }

.featured-img {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  display: block;
  margin: 0 0 20px;
}

.post-content { font-size: 1.02rem; }
.post-content h2 { font-size: 1.35rem; margin-top: 1.6em; }
.post-content h3 { font-size: 1.15rem; margin-top: 1.4em; }
.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}
/* Immagini hotlink legacy con width/height espliciti o inline: mai deformate */
.post-content img[width],
.post-content img[height] { height: auto; }
.post-content img[style*="height"] { height: auto !important; }
.post-content figure > a { display: block; }

/* Didascalie WordPress: la figure porta una width inline dal shortcode
   caption (es. [caption width="1920"]) e sfora il contenitore del post,
   trascinando con sé l'img (che è max-width:100% della figure, non della
   pagina). Riconduci la figure alla larghezza del contenuto. */
.post-content .wp-caption,
.post-content figure[style*="width"] {
    width: auto !important;
    max-width: 100% !important;
}
.post-content p, .post-content ul, .post-content ol { margin: 0 0 1em; }
.post-content blockquote { margin: 1.2em 0; padding: 8px 16px; border-left: 4px solid var(--accent); background: var(--bg-alt); border-radius: 0 var(--radius) var(--radius) 0; }
.post-content figcaption { font-size: 0.85rem; color: var(--text-soft); text-align: center; }

/* Le webcam live del plugin Meteo Webcam Proxy: full-width, niente CLS */
.post-content .mwp-webcam img,
.post-content img.mwp-img {
  width: 100%;
  height: auto;
}

/* Embed video (YouTube, windy, panomax…): mai più larghi del contenuto.
   Gli iframe incollati con l'editor classico hanno width="560" fissa e su mobile
   sforano la colonna del post; add_theme_support('responsive-embeds') copre solo
   i blocchi Gutenberg (che qui non si usano). */
.post-content iframe,
.post-content object,
.post-content embed {
  max-width: 100%;
}

/* YouTube: full-width e proporzione 16:9 su ogni schermo */
.post-content iframe[src*="youtube"],
.post-content iframe[src*="youtu.be"],
.post-content iframe[src*="youtube-nocookie"] {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  display: block;
  border: 0;
  border-radius: var(--radius);
}

/* Video del lettore WordPress ([video] / .mp4 incollato): stesso spazio sotto dei
   paragrafi, altrimenti la webcam del plugin che segue resta attaccata (v2.9.1) */
.post-content .wp-video,
.post-content > video {
  margin: 0 0 1em;
}

/* Il lettore WordPress senza width nello shortcode usa i 640x360 di default e
   scrive "width: 640px" inline sul div.wp-video: lo portiamo a tutta colonna
   come le webcam. MediaElement (stretching "responsive") ricalcola l'altezza
   dalla proporzione width/height del video (v2.9.2) */
.post-content .wp-video {
  width: 100% !important;
}

/* AdSense (inseriti da Site Kit): centra gli annunci automatici/in-manuali */
.post-content ins.adsbygoogle { margin: 1.2em 0; }

/* Webcam precedente/successiva + ricerca nel post singolo (v2.6) */
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin: 28px 0 0;
  font-size: 0.95rem;
}
.post-nav a {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  max-width: 100%;
}
.post-nav a:hover { border-color: var(--accent); text-decoration: none; }
.post-nav .nav-next { margin-left: auto; text-align: right; }
.post-search { margin-top: 24px; }
.post-search .search-form { max-width: 480px; }

/* ============ Navigazione e commenti ============ */
.pagination { margin: 24px 0; }
.pagination .nav-links { display: flex; gap: 10px; flex-wrap: wrap; font-size: 0.95rem; }
.pagination .current { font-weight: 700; color: var(--text); }
.pagination a, .pagination span {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.pagination span.dots { border: none; background: none; padding: 6px 2px; }

.comments-area { max-width: var(--content); margin: 32px auto 0; border-top: 1px solid var(--border); padding-top: 20px; }
.comment-list { list-style: none; padding: 0; margin: 0 0 20px; }
.comment-list .comment-body { padding: 12px 0; border-bottom: 1px solid var(--border); }
.comment-form label { display: block; font-size: 0.88rem; color: var(--text-soft); margin-bottom: 4px; }
.comment-form input[type="text"], .comment-form input[type="email"], .comment-form input[type="url"], .comment-form textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}
.comment-form .submit {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* ============ Sidebar / widget opzionali ============ */
.widget-area { margin: 24px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.widget { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.widget-title { font-size: 1rem; margin: 0 0 10px; }

/* ============ Ricerca e 404 ============ */
.search-form { display: flex; gap: 8px; max-width: 480px; margin: 16px 0; }
.search-form input[type="search"] { flex: 1; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.search-form button { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 9px 16px; font: inherit; cursor: pointer; }

.no-results { max-width: var(--content); margin: 0 auto; padding: 32px 0; }

/* ============ Footer ============ */
.site-footer {
  margin-top: 40px;
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text-soft);
  font-size: 0.9rem;
}

.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 18px;
  padding-bottom: 18px;
}

.footer-legal { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.footer-legal a, .cookie-prefs { color: var(--text-soft); }
.cookie-prefs {
  background: none; border: 0; padding: 0; margin: 0;
  font: inherit; cursor: pointer;
}
.footer-legal a:hover, .footer-legal a:focus,
.cookie-prefs:hover, .cookie-prefs:focus { color: var(--accent-dark); text-decoration: underline; }

/* ============ Accessibilità ============ */
.screen-reader-text {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============ Media query ============ */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .post-title { font-size: 1.45rem; }
  /* v2.8: titolo centrato in alto, lente in alto a destra, voci di menu
     su una riga sotto il titolo (testo un po' piu' compatto) */
  .site-header-inner { justify-content: center; position: relative; row-gap: 4px; }
  .site-nav { position: static; }
  .site-nav ul { justify-content: center; gap: 4px 14px; }
  .site-nav a { font-size: 0.9rem; }
  .search-toggle { position: absolute; top: 8px; right: 16px; }
  .post-nav a { flex: 1 1 auto; }
}
