/* Habitat Edizioni — ottobre 2026 */
:root {
  --forest: #173326;
  --forest-deep: #0e2018;
  --sage: #7f9a86;
  --stone: #ecede7;
  --paper: #f8f8f3;
  --brass: #b88a3e;
  --brass-light: #d9b675;
  --ink: #17201b;
  --muted: #55625b;
  --on-dark: #eef0e8;
  --on-dark-muted: #b9c4bb;
  --serif: "Bodoni Moda", "Didot", Georgia, serif;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --max: 1180px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 130px; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--stone);
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 500; line-height: 1.08; margin: 0; }
p { margin: 0 0 1em; }
.wrap { width: min(100% - 2.5rem, var(--max)); margin-inline: auto; }
.narrow { max-width: 640px; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; border-radius: 4px; }

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

/* ---------- Header ---------- */
.site-header {
  position: fixed; inset: 0 0 auto; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: .8rem clamp(1rem, 3vw, 2rem);
  color: var(--on-dark);
  transition: background .3s, color .3s, box-shadow .3s;
}
.site-header.scrolled {
  background: rgba(236, 237, 231, .92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(23, 51, 38, .12);
}
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1.5px solid currentColor;
}
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-text strong { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; }
.brand-text em { font-style: normal; font-size: .78rem; letter-spacing: .14em; opacity: .75; margin-top: .2rem; }
.site-nav { display: flex; align-items: center; gap: 1.8rem; font-size: .98rem; }
.site-nav a { text-decoration: none; }
.site-nav > a:hover { text-decoration: underline; text-underline-offset: 5px; text-decoration-color: var(--brass); }
.lang-switch { display: flex; gap: .2rem; border: 1px solid currentColor; border-radius: 99px; padding: .15rem; }
.lang-switch a { padding: .15rem .6rem; border-radius: 99px; font-size: .85rem; font-weight: 600; }
.lang-switch a[aria-current] { background: currentColor; }
.site-header .lang-switch a[aria-current] { color: var(--forest); background: var(--on-dark); }
.site-header.scrolled .lang-switch a[aria-current] { color: var(--paper); background: var(--forest); }
.nav-toggle { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .85rem 1.6rem; border-radius: 99px;
  background: var(--brass); color: var(--forest-deep);
  font: 600 1rem var(--sans); text-decoration: none; border: 0; cursor: pointer;
  transition: background .2s, transform .2s;
}
.btn:hover { background: var(--brass-light); transform: translateY(-1px); }
.btn-line { background: transparent; color: inherit; box-shadow: inset 0 0 0 1.5px currentColor; }
.btn-line:hover { background: rgba(255, 255, 255, .08); }

/* ---------- Book object (the 3D cover) ---------- */
.book {
  --rx: 0deg; --ry: 0deg; --lift: 0px; --gx: 50%; --gy: 30%;
  position: relative; display: block;
  width: 100%;
  border-radius: 2px 5px 5px 2px;
  transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry)) translateY(var(--lift));
  transform-style: preserve-3d;
  transition: transform .55s var(--ease), box-shadow .55s var(--ease);
  box-shadow:
    1px 0 0 #f1eee4, 2px 1px 0 #d6d0c0, 3px 1px 0 #f1eee4, 4px 2px 0 #cfc8b6,
    0 2px 3px rgba(0, 0, 0, .18),
    0 16px 26px -14px rgba(0, 0, 0, .55);
  will-change: transform;
}
.book img { width: 100%; border-radius: inherit; }
.book::before { /* dorso: piega della copertina */
  content: ""; position: absolute; inset: 0 auto 0 0; width: 9%;
  border-radius: 2px 0 0 2px;
  background: linear-gradient(90deg, rgba(0,0,0,.28), rgba(255,255,255,.22) 28%, rgba(0,0,0,.12) 55%, transparent);
  pointer-events: none;
}
.glare {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(circle at var(--gx) var(--gy), rgba(255,255,255,.45), rgba(255,255,255,0) 55%);
  opacity: 0; transition: opacity .4s;
  mix-blend-mode: soft-light;
}
.is-tilting .book, .book.is-tilting { transition: transform .12s linear, box-shadow .4s var(--ease); }
.book.is-up, .b-card:hover .book {
  --lift: -12px;
  box-shadow:
    1px 0 0 #f1eee4, 2px 1px 0 #d6d0c0, 3px 1px 0 #f1eee4, 4px 2px 0 #cfc8b6,
    0 4px 6px rgba(0, 0, 0, .15),
    0 34px 40px -18px rgba(0, 0, 0, .55);
}
.book.is-up .glare, .b-card:hover .glare { opacity: 1; }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  min-height: min(100vh, 860px);
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  align-items: center; gap: 2rem;
  padding: 7.5rem clamp(1.25rem, 5vw, 5rem) 4rem;
  background:
    radial-gradient(ellipse 70% 60% at 72% 55%, rgba(184, 138, 62, .16), transparent 70%),
    var(--forest);
  color: var(--on-dark);
}
.hero h1 {
  font-size: clamp(2.9rem, 6.2vw, 5.6rem);
  font-weight: 450;
  letter-spacing: -.015em;
  max-width: 10ch;
  margin-bottom: 1.6rem;
}
.lede { font-size: 1.15rem; color: var(--on-dark-muted); max-width: 44ch; margin-bottom: 2.2rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .8rem; }

.hero-stage { position: relative; padding: 2rem 0 3rem; perspective: 1400px; }
.hero-fan {
  --fy: 0deg;
  display: flex; align-items: flex-end; justify-content: center;
  transform: rotateY(var(--fy));
  transform-style: preserve-3d;
  transition: transform .8s var(--ease);
  padding-bottom: 14px;
}
.hero > * { min-width: 0; }
.hero-book { flex: 0 0 auto; width: clamp(100px, 10.5vw, 160px); margin: 0 -16px; }
.hb0 { --tilt: -9deg; z-index: 1; }
.hb1 { --tilt: -4deg; z-index: 2; }
.hb2 { --tilt: 0deg;  z-index: 3; width: clamp(120px, 13vw, 192px); }
.hb3 { --tilt: 4deg;  z-index: 2; }
.hb4 { --tilt: 9deg;  z-index: 1; }
.hero-book { transform: perspective(900px) rotateZ(var(--tilt)) rotateX(var(--rx)) rotateY(var(--ry)) translateY(var(--lift)); transform-origin: 50% 100%; }
.hero-book.is-up { z-index: 5; --tilt: 0deg; --lift: -22px; }
.hero-shelf {
  height: 14px; margin: 0 6%;
  border-radius: 2px;
  background: linear-gradient(#e2c58c, var(--brass) 45%, #7d5c26);
  box-shadow: 0 18px 30px -10px rgba(0, 0, 0, .6);
}
.hero-hint { text-align: center; color: var(--on-dark-muted); font-size: .9rem; margin: 1.2rem 0 0; }

/* page-load: i libri si posano sulla mensola, uno dopo l'altro */
@media (prefers-reduced-motion: no-preference) {
  .hero-book { animation: drop .9s var(--ease) both; }
  .hb0 { animation-delay: .15s; } .hb1 { animation-delay: .25s; } .hb2 { animation-delay: .05s; }
  .hb3 { animation-delay: .35s; } .hb4 { animation-delay: .45s; }
  @keyframes drop { from { opacity: 0; translate: 0 -60px; } to { opacity: 1; translate: 0 0; } }
}

/* ---------- Catalogo ---------- */
.catalogo { padding: 6rem 0 4rem; }
.cat-head { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; align-items: end; margin-bottom: 2rem; }
.cat-head h2 { font-size: clamp(2.4rem, 5vw, 4rem); color: var(--forest); }
.cat-head p { color: var(--muted); max-width: 42ch; margin: 0; }

.chips {
  position: sticky; top: 66px; z-index: 20;
  display: flex; gap: .5rem; overflow-x: auto;
  padding: .9rem 0; margin-bottom: 1rem;
  background: var(--stone);
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  font: 500 .95rem var(--sans); color: var(--forest);
  background: transparent; border: 1.5px solid rgba(23, 51, 38, .25);
  border-radius: 99px; padding: .5rem 1rem; cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
}
.chip span { opacity: .6; margin-left: .2rem; font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--forest); }
.chip[aria-pressed="true"] { background: var(--forest); color: var(--paper); border-color: var(--forest); }

.collana { padding-top: 3.5rem; }
.collana[hidden] { display: none; }
.collana-head {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2rem; align-items: baseline;
  border-top: 1px solid rgba(23, 51, 38, .2); padding-top: 1.2rem; margin-bottom: 1.5rem;
}
.collana-head h3 { font-size: clamp(1.8rem, 3.2vw, 2.5rem); color: var(--forest); }
.collana-head p { color: var(--muted); margin: 0; max-width: 46ch; }

.b-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  column-gap: 0; row-gap: 2.8rem;
}
.b-card { display: flex; flex-direction: column; }
.b-shelf {
  position: relative;
  height: 300px;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0 1.6rem 12px;
}
.b-shelf::after { /* la mensola: continua da una card all'altra */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 12px;
  background: linear-gradient(#e7d3a8, #c7a565 50%, #9a7638);
  box-shadow: 0 14px 20px -10px rgba(40, 30, 10, .45);
}
.b-shelf .book { width: 158px; max-height: 270px; }
.b-shelf .book img { max-height: 270px; object-fit: cover; }
.badge {
  position: absolute; top: -10px; right: -12px; z-index: 4; white-space: nowrap;
  box-shadow: 0 4px 10px rgba(0,0,0,.18);
  font: 600 .78rem var(--sans); letter-spacing: .02em;
  background: var(--brass); color: var(--forest-deep);
  padding: .25rem .6rem; border-radius: 99px;
}
.badge-soon { background: var(--paper); color: var(--forest); box-shadow: inset 0 0 0 1px rgba(23,51,38,.3); }
.badge-adult { background: #7a1f24; color: #fff; }

.b-info { text-align: center; padding: 1.2rem 1rem 0; display: flex; flex-direction: column; align-items: center; flex: 1; }
.b-info h4 { font-size: 1.32rem; font-weight: 600; color: var(--ink); margin-bottom: .3rem; }
.b-sub { font-size: .95rem; color: var(--muted); margin: 0 0 .2rem; max-width: 26ch; line-height: 1.45; }
.b-author { font-family: var(--serif); font-style: italic; font-size: 1rem; color: var(--forest); margin: 0; }
.b-buy {
  margin-top: auto; padding-top: .9rem;
  font-weight: 600; font-size: .95rem; color: var(--forest);
  text-decoration: underline; text-decoration-color: var(--brass); text-decoration-thickness: 2px; text-underline-offset: 5px;
}
.b-buy:hover { color: var(--brass); }
.b-buy.is-off { text-decoration: none; color: var(--muted); font-weight: 500; }

/* ---------- Chi siamo ---------- */
.about { background: var(--paper); padding: 6rem 0; border-top: 1px solid rgba(23,51,38,.1); }
.about-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 3rem; align-items: start; }
.about h2 { font-size: clamp(2.2rem, 4.4vw, 3.6rem); color: var(--forest); max-width: 14ch; }
.about-copy { font-size: 1.12rem; max-width: 58ch; padding-top: .6rem; }
.about-copy p:first-child::first-letter {
  font-family: var(--serif); float: left; font-size: 4.2em; line-height: .85; padding: .05em .1em 0 0; color: var(--brass);
}

/* ---------- Contatti ---------- */
.contact { background: var(--forest); color: var(--on-dark); padding: 6rem 0; }
.contact h2 { font-size: clamp(2.2rem, 4.4vw, 3.4rem); margin-bottom: 1rem; }
.contact > .wrap > p { color: var(--on-dark-muted); }
.contact-form { display: grid; gap: 1rem; margin-top: 2rem; }
.contact-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.contact-form label { display: grid; gap: .35rem; font-size: .9rem; color: var(--on-dark-muted); }
.contact-form input, .contact-form textarea {
  font: inherit; font-size: 1rem; color: var(--on-dark);
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.22);
  border-radius: 10px; padding: .8rem 1rem;
}
.contact-form input:focus, .contact-form textarea:focus { outline: none; border-color: var(--brass-light); background: rgba(255,255,255,.1); }
.contact-form .btn { justify-self: start; margin-top: .4rem; }
.contact-note { margin-top: 1.6rem; font-size: .95rem; color: var(--on-dark-muted); }
.contact-note a { color: var(--brass-light); }

/* ---------- Footer ---------- */
.site-footer { background: var(--forest-deep); color: var(--on-dark-muted); padding: 3rem 0 2rem; font-size: .95rem; }
.foot-grid { display: flex; justify-content: space-between; align-items: center; gap: 2rem; flex-wrap: wrap; }
.foot-brand { display: flex; gap: .9rem; align-items: center; color: var(--on-dark); }
.foot-brand strong { font-family: var(--serif); font-size: 1.2rem; }
.foot-brand p { margin: 0; color: var(--on-dark-muted); }
.foot-links { display: flex; gap: 1.6rem; flex-wrap: wrap; }
.foot-links a { text-decoration: none; }
.foot-links a:hover { color: var(--on-dark); }
.copyright { margin-top: 2rem; padding-top: 1.4rem; border-top: 1px solid rgba(255,255,255,.1); font-size: .85rem; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1fr); text-align: left; padding-top: 6.5rem; min-height: 0; }
  .hero-stage { padding-top: 0; }
  .hero-hint { display: none; }
  .cat-head, .collana-head, .about-grid { grid-template-columns: 1fr; gap: .8rem; }
}
@media (max-width: 760px) {
  .nav-toggle {
    display: grid; gap: 6px; width: 44px; height: 44px; place-content: center;
    background: transparent; border: 0; color: inherit; cursor: pointer;
  }
  .nav-toggle span { display: block; width: 22px; height: 2px; background: currentColor; transition: transform .25s; }
  .nav-toggle[aria-expanded="true"] span:first-child { transform: translateY(4px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] span:last-child { transform: translateY(-4px) rotate(-45deg); }
  .site-nav {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: flex-start; gap: 1.1rem;
    padding: 1.4rem 1.25rem 1.8rem; background: var(--stone); color: var(--ink);
    box-shadow: 0 12px 24px rgba(0,0,0,.12);
    display: none;
  }
  .site-nav.open { display: flex; }
  .site-nav .lang-switch a[aria-current] { color: var(--paper) !important; background: var(--forest) !important; }
  .site-header:has(.site-nav.open) { background: var(--stone); color: var(--ink); }
  .b-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 2.2rem; }
  .b-shelf { height: 220px; padding: 0 .9rem 10px; }
  .b-shelf .book { width: 118px; max-height: 196px; }
  .b-shelf .book img { max-height: 196px; }
  .b-info { padding: 1rem .5rem 0; }
  .b-info h4 { font-size: 1.12rem; }
  .b-sub { font-size: .88rem; }
  .badge { right: -8px; font-size: .72rem; }
  .contact-form .row { grid-template-columns: 1fr; }
  .hero-book { width: 22vw; margin: 0 -4vw; }
  .hb2 { width: 27vw; }
  .hero-shelf { margin: 0 2%; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .book, .hero-fan { transition: none !important; }
}
