/* ==========================================================================
   Samuele Santini — foglio di stile principale
   Palette chiara con accenti "pisani" (rosso della croce di Pisa su marmo)
   ========================================================================== */

:root {
  --bg: #FAF7F0;          /* avorio / marmo */
  --bg-alt: #EFE8DA;      /* avorio intenso (footer, fasce) */
  --card: #FFFFFF;
  --red: #B0182B;         /* rosso pisano */
  --red-dark: #8C1222;
  --gold: #C9A227;        /* oro / pietra */
  --text: #2B2B2B;
  --muted: #6B6B6B;
  --border: #E2DACB;

  --font-title: "Lora", Georgia, "Times New Roman", serif;
  --font-body: "Source Sans 3", "Segoe UI", Roboto, Arial, sans-serif;

  --radius: 6px;
  --shadow: 0 1px 3px rgba(60, 40, 20, .08), 0 4px 14px rgba(60, 40, 20, .06);
  --max: 1140px;
}

/* ---------- Reset essenziale ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.7;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--red); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--red-dark); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

h1, h2, h3, h4 {
  font-family: var(--font-title);
  line-height: 1.25;
  color: var(--text);
  margin: 0 0 .6em;
}
h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.4rem, 3vw, 1.8rem); }
h3, .h3 { font-size: 1.25rem; }
p { margin: 0 0 1.1em; }

.text-center { text-align: center; }

.container { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 1.25rem; }

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--red); color: #fff; padding: .5rem 1rem; z-index: 100;
}
.skip-link:focus { left: 1rem; }

/* ---------- Header (stile WordPress) ---------- */
.site-header {
  background: var(--card);
  border-top: 5px solid var(--red);
  border-bottom: 1px solid var(--border);
}
.branding {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.5rem 0 1.1rem;
}
.branding img { width: 72px; height: 72px; flex-shrink: 0; }
.site-title {
  font-family: var(--font-title);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 700;
  margin: 0; line-height: 1.1;
}
.site-title a { color: var(--text); text-decoration: none; }
.site-description {
  margin: .2rem 0 0; color: var(--muted);
  font-style: italic; letter-spacing: .02em;
}

/* ---------- Navigazione ---------- */
.main-nav { border-top: 1px solid var(--border); }
.main-nav ul {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap;
}
.main-nav a {
  display: block; padding: .85rem 1rem;
  color: var(--text); text-decoration: none;
  font-weight: 600; font-size: .95rem;
  text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 3px solid transparent;
}
.main-nav a:hover { color: var(--red); }
.main-nav a[aria-current="page"] { color: var(--red); border-bottom-color: var(--red); }

.nav-toggle {
  display: none;
  margin-left: auto;
  background: none; border: 1px solid var(--border); border-radius: var(--radius);
  padding: .5rem .7rem; cursor: pointer; color: var(--text);
  font: 600 .9rem var(--font-body);
}
.nav-toggle span[aria-hidden] { font-size: 1.2rem; vertical-align: middle; margin-right: .3rem; }

/* ---------- Layout contenuto + sidebar ---------- */
.site-main { padding: 2.5rem 0 3rem; }
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 2.5rem;
}
.layout--full { grid-template-columns: minmax(0, 1fr); }

.content > * + * { margin-top: 2rem; }

.box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
}

.section-title {
  font-size: 1.35rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--border);
  position: relative;
  margin-bottom: 1.25rem;
}
.section-title::after {
  content: ""; position: absolute; left: 0; bottom: -2px;
  width: 60px; height: 2px; background: var(--red);
}

.page-header { margin-bottom: 1.5rem; }
.page-header p { color: var(--muted); font-size: 1.1rem; margin: 0; }

/* ---------- Sidebar / widget ---------- */
.sidebar > * + * { margin-top: 1.75rem; }
.widget h2 {
  font-size: 1rem; text-transform: uppercase; letter-spacing: .08em;
  border-bottom: 2px solid var(--red); padding-bottom: .4rem; margin-bottom: 1rem;
}
.widget ul { list-style: none; margin: 0; padding: 0; }
.widget li { padding: .5rem 0; border-bottom: 1px dashed var(--border); }
.widget li:last-child { border-bottom: 0; }
.widget .cover-small { width: 140px; margin: 0 auto 1rem; box-shadow: var(--shadow); }
.widget-date { display: block; font-size: .85rem; color: var(--muted); }
.widget-empty { color: var(--muted); font-style: italic; margin: 0; }

/* ---------- Bottoni ---------- */
.btn {
  display: inline-block;
  background: var(--red); color: #fff;
  padding: .65rem 1.3rem;
  border-radius: var(--radius);
  text-decoration: none; font-weight: 600;
  border: 2px solid var(--red);
  transition: background .2s, color .2s;
}
.btn:hover { background: var(--red-dark); border-color: var(--red-dark); color: #fff; }
.btn--outline { background: transparent; color: var(--red); }
.btn--outline:hover { background: var(--red); color: #fff; }
.btn-row { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1rem; }

/* ---------- Hero (home) ---------- */
.hero {
  display: grid; grid-template-columns: 200px 1fr; gap: 2rem; align-items: center;
  background: linear-gradient(135deg, var(--card) 60%, var(--bg-alt));
  border-left: 5px solid var(--red);
}
.hero img { border-radius: 50%; border: 4px solid var(--card); box-shadow: var(--shadow); }
.hero h1 { margin-bottom: .3em; }
.hero .lead { font-size: 1.15rem; color: var(--muted); }

/* ---------- Libro in evidenza ---------- */
.featured-book {
  display: grid; grid-template-columns: 220px 1fr; gap: 2rem; align-items: start;
}
.featured-book .cover { box-shadow: 0 8px 24px rgba(60, 40, 20, .2); border-radius: 2px; }
.badge {
  display: inline-block; background: var(--bg-alt); color: var(--red);
  font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  padding: .2rem .6rem; border-radius: 3px; margin-bottom: .6rem;
}
.book-text { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.book-note { font-size: .92rem; color: var(--muted); font-style: italic; margin-top: 1.25rem; }
.book-meta { list-style: none; padding: 0; margin: 0 0 1.2rem; color: var(--muted); font-size: .95rem; }
.book-meta li { padding: .15rem 0; }
.book-meta strong { color: var(--text); }

/* ---------- Griglia libri / card ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1.5rem;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .2s, box-shadow .2s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(60, 40, 20, .12); }
.card img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; background: var(--bg-alt); }
.card-body { padding: 1rem 1.1rem 1.25rem; display: flex; flex-direction: column; flex: 1; }
.card-body h3 { margin-bottom: .2rem; }
.card-meta { font-size: .85rem; color: var(--muted); margin-bottom: .6rem; }
.card-body p { font-size: .95rem; }
.card-body .btn { margin-top: auto; align-self: flex-start; padding: .45rem 1rem; font-size: .9rem; }

/* ---------- Post / news (stile blog) ---------- */
.post { padding-bottom: 1.75rem; border-bottom: 1px solid var(--border); }
.post:last-child { border-bottom: 0; padding-bottom: 0; }
.post + .post { margin-top: 1.75rem; }
.post h3 { margin-bottom: .2rem; }
.post h3 a { color: var(--text); text-decoration: none; }
.post h3 a:hover { color: var(--red); }
.post-meta { font-size: .88rem; color: var(--muted); margin-bottom: .7rem; }
.post-meta .tag {
  color: var(--red); font-weight: 600; text-transform: uppercase; font-size: .78rem; letter-spacing: .06em;
}
.post img { border-radius: var(--radius); margin-bottom: 1rem; }

/* ---------- Chi sono ---------- */
.about-photo {
  float: right; width: 260px; margin: 0 0 1rem 1.75rem;
  border-radius: var(--radius); box-shadow: var(--shadow);
}
blockquote {
  margin: 1.75rem 0; padding: 1rem 1.5rem;
  border-left: 4px solid var(--red);
  background: var(--bg);
  font-family: var(--font-title); font-style: italic; font-size: 1.15rem;
}
blockquote footer, blockquote cite { display: block; margin-top: .5rem; font-size: .9rem; font-style: normal; color: var(--muted); font-family: var(--font-body); }

/* ---------- Pagina libro ---------- */
.excerpt {
  font-family: var(--font-title); font-size: 1.05rem;
  background: var(--bg); padding: 1.5rem; border-radius: var(--radius);
  border: 1px solid var(--border);
}
.reviews blockquote { margin: 1rem 0; }
.closing-line {
  font-family: var(--font-title); font-style: italic; font-size: 1.2rem;
  color: var(--red); margin-top: 1.5rem;
}

/* ---------- Tema "La parte che manca" (colori presi dalla copertina) ----------
   Si applica con class="theme-lpcm": ridefinisce le variabili solo dentro quel blocco,
   header e footer restano con il rosso pisano. */
.theme-lpcm {
  --bg: #F2EDE4;          /* pietra chiara */
  --bg-alt: #E6DDCC;      /* pietra della copertina */
  --red: #3F5F66;         /* ardesia / verde acqua scuro (accento) */
  --red-dark: #2E474D;
  --gold: #A9B3A0;        /* salvia */
  --text: #1C2230;        /* blu notte del titolo */
  --border: #DED5C5;
  color: var(--text);
}
main.theme-lpcm { background: var(--bg); }
.theme-lpcm .cover, .theme-lpcm .cover-small { border: 1px solid var(--border); }

/* ---------- Carosello "I testi della raccolta" ---------- */
.fleuron { text-align: center; color: var(--gold); font-size: 1.5rem; line-height: 1; margin: .25rem 0 1.25rem; }
.carousel { position: relative; }
.carousel-track {
  display: flex; gap: 1rem;
  list-style: none; margin: 0; padding: .25rem .25rem 1rem;
  overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: .25rem;
  scrollbar-width: thin; scrollbar-color: var(--gold) transparent;
}
.story-card { flex: 0 0 180px; scroll-snap-align: start; }
.story-card a {
  display: flex; flex-direction: column; height: 100%;
  background: var(--card); color: var(--text); text-decoration: none;
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}
.story-card a:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(60, 40, 20, .12); }
.story-card img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; background: var(--bg-alt); }
.story-info { padding: .7rem .8rem .9rem; display: flex; flex-direction: column; flex: 1; }
.story-num { font-size: .75rem; color: var(--muted); letter-spacing: .08em; }
.story-title { font-family: var(--font-title); font-weight: 700; line-height: 1.25; margin: .15rem 0 .35rem; }
.story-type { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--red); margin-top: auto; }
.story-award { font-size: .78rem; color: var(--muted); line-height: 1.35; margin-top: .3rem; }
.carousel-btn {
  position: absolute; top: 38%; transform: translateY(-50%); z-index: 2;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--card); color: var(--red);
  font-size: 1.6rem; line-height: 1; cursor: pointer; box-shadow: var(--shadow);
}
.carousel-btn:hover:not(:disabled) { background: var(--red); color: #fff; }
.carousel-btn:disabled { opacity: .35; cursor: default; }
.carousel-btn[hidden] { display: none; }
.carousel-prev { left: -16px; }
.carousel-next { right: -16px; }
.carousel-hint { font-size: .85rem; color: var(--muted); text-align: center; margin: .25rem 0 0; }

/* ---------- Dettaglio del singolo testo ---------- */
.breadcrumb { font-size: .9rem; color: var(--muted); }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--red); }
.story-detail { display: grid; grid-template-columns: 260px 1fr; gap: 2rem; align-items: start; }
.story-detail img { border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
.story-place { font-family: var(--font-title); font-style: italic; color: var(--muted); margin-top: -.3em; }
.award {
  display: flex; gap: .6rem; align-items: baseline;
  background: var(--bg); border-left: 3px solid var(--red);
  padding: .75rem 1rem; border-radius: 0 var(--radius) var(--radius) 0;
  font-size: .95rem;
}
.award span[aria-hidden] { color: var(--red); }
.story-nav { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; }
.story-nav a {
  display: flex; flex-direction: column; justify-content: center;
  padding: .9rem 1.1rem; min-height: 44px;
  background: var(--card); color: var(--text); text-decoration: none;
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.story-nav a:hover { border-color: var(--red); }
.story-nav small { color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; }
.story-nav strong { font-family: var(--font-title); color: var(--red); line-height: 1.3; }
.story-nav .next { text-align: right; }
.story-nav .all { text-align: center; }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--bg-alt);
  border-top: 4px solid var(--red);
  color: var(--text);
  font-size: .95rem;
}
.footer-widgets {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem;
  padding-top: 2.5rem; padding-bottom: 2rem;
}
.footer-widgets h2 {
  font-size: 1rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: .75rem;
}
.footer-widgets ul { list-style: none; margin: 0; padding: 0; }
.footer-widgets li { padding: .2rem 0; }
.footer-bottom {
  border-top: 1px solid var(--border);
  padding: 1rem 0; text-align: center; color: var(--muted); font-size: .88rem;
}

/* ---------- 404 ---------- */
.notfound { text-align: center; padding: 3rem 1rem; }
.notfound .big { font-family: var(--font-title); font-size: 5rem; color: var(--red); margin: 0; line-height: 1; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .footer-widgets { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 800px) {
  .nav-toggle { display: inline-block; }
  .main-nav { display: none; }
  .main-nav.is-open { display: block; }
  .main-nav ul { flex-direction: column; }
  .main-nav a { border-bottom: 1px solid var(--border); border-left: 3px solid transparent; }
  .main-nav a[aria-current="page"] { border-bottom-color: var(--border); border-left-color: var(--red); }

  /* Link più facili da toccare col dito (area ~44px) */
  .widget li, .footer-widgets li { padding: 0; }
  .widget li a, .footer-widgets li a { display: block; padding: .6rem 0; }
  .widget li .widget-date { margin: -.5rem 0 .5rem; }
  .widget p a, .content p > a:only-child { display: inline-block; padding: .6rem 0; }
  .post h2 a, .post h3 a { display: inline-block; padding: .5rem 0; }
}

@media (max-width: 640px) {
  .hero, .featured-book { grid-template-columns: 1fr; text-align: center; }
  .hero img { width: 160px; margin: 0 auto; }
  .featured-book .cover { width: 200px; margin: 0 auto; }
  .featured-book .btn-row { justify-content: center; }
  .featured-book p:not(.story-place) { text-align: left; }
  .about-photo { float: none; width: 100%; max-width: 320px; margin: 0 auto 1.5rem; }
  .footer-widgets { grid-template-columns: 1fr; }
  .box { padding: 1.25rem; }
  .story-card { flex-basis: 62%; }
  .carousel-btn { display: none; }
  .story-detail { grid-template-columns: 1fr; }
  .story-detail img { max-width: 260px; margin: 0 auto; }
  .story-nav { grid-template-columns: 1fr 1fr; }
  .story-nav .all { grid-column: 1 / -1; order: 3; }
  .branding { gap: .75rem; }
  .branding img { width: 56px; height: 56px; }
}

/* Senza JavaScript il menu resta sempre visibile */
.no-js .main-nav { display: block; }
.no-js .nav-toggle { display: none; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
