/* ===== BASICS ===== */
:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --text: #1d1b19;
  --muted: #625c56;
  --line: #e2ddd6;
  --accent: #b4441b;
  --accent-hover: #933615;
  --new: #1f7a3d;
  --new-bg: #e2f2e7;
  --soft: #ebe7e1;
  --soft-text: #554e47;
  --photo: #eeebe6;
  --topbar: rgba(255, 255, 255, 0.95);
  --show-moon: block;
  --show-sun: none;
  color-scheme: light;
}

/* dark theme: chosen with the button, or automatic from the browser */
:root[data-theme="dark"] {
  --bg: #161412;
  --card: #201d1a;
  --text: #f1ede8;
  --muted: #a8a097;
  --line: #36312c;
  --new: #5cc27e;
  --new-bg: #1d3325;
  --soft: #2e2a26;
  --soft-text: #cfc7be;
  --photo: #2a2622;
  --topbar: rgba(22, 20, 18, 0.95);
  --show-moon: none;
  --show-sun: block;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161412;
    --card: #201d1a;
    --text: #f1ede8;
    --muted: #a8a097;
    --line: #36312c;
    --new: #5cc27e;
    --new-bg: #1d3325;
    --soft: #2e2a26;
    --soft-text: #cfc7be;
    --photo: #2a2622;
    --topbar: rgba(22, 20, 18, 0.95);
    --show-moon: none;
    --show-sun: block;
    color-scheme: dark;
  }
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  transition: background 0.3s, color 0.3s;
}

a {
  color: inherit;
  text-decoration: none;
}

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

/* ===== TOP BAR ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--topbar);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0.75rem 1rem;
}

.logo {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.menu {
  display: flex;
  gap: 1.4rem;
}

.menu a {
  position: relative;
  color: var(--muted);
  font-weight: 500;
  padding: 0.25rem 0;
  transition: color 0.2s;
}

.menu a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform 0.25s ease;
}

.menu a:hover {
  color: var(--text);
}

.menu a:hover::after {
  transform: scaleX(1);
}

.right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* socials */
.socials {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.social {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: 38px;
  padding: 0 0.9rem 0 0.5rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
}

.social svg,
.social img {
  width: 20px;
  height: 20px;
  display: block;
}

.social:hover {
  border-color: var(--text);
  transform: translateY(-2px);
}

/* theme button */
.theme-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.3s;
}

.theme-toggle:hover {
  border-color: var(--text);
  transform: rotate(20deg);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.icon-moon { display: var(--show-moon); }
.icon-sun  { display: var(--show-sun); }

/* language switch */
.lang {
  display: flex;
  gap: 0.2rem;
}

.lang a {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
}

.lang a:hover {
  color: var(--text);
}

.lang a[aria-current="page"] {
  color: var(--text);
  background: var(--soft);
}

/* ===== SECTIONS ===== */
.hero,
.section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.75rem 1rem;
}

.hero {
  padding-top: 2.5rem;
}

.section {
  border-top: 1px solid var(--line);
}

.hero > * {
  animation: fade-up 0.6s ease backwards;
}
.hero > :nth-child(2) { animation-delay: 0.1s; }
.hero > :nth-child(3) { animation-delay: 0.2s; }

.hero h1 {
  font-size: clamp(1.9rem, 5vw, 3rem);
  line-height: 1.15;
  max-width: 700px;
}

.hero p {
  color: var(--muted);
  font-size: 1.1rem;
  max-width: 560px;
  margin: 1rem 0 1.5rem;
}

.btn {
  display: inline-block;
  padding: 0.75rem 1.4rem;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  transition: background 0.2s, transform 0.2s;
}

.btn:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

h2 {
  font-size: 1.8rem;
  margin-bottom: 0.6rem;
}

.intro {
  color: var(--muted);
  max-width: 640px;
  margin-bottom: 1rem;
}

/* ===== PRODUCTS ===== */
.catalog {
  position: relative;
}

/* the radio buttons are hidden, their labels are the filter buttons */
.filter-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.filters label {
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.filters label:hover {
  border-color: var(--text);
}

/* selected filter */
#f-all:checked ~ .filters [for="f-all"],
#f-electric:checked ~ .filters [for="f-electric"],
#f-acoustic:checked ~ .filters [for="f-acoustic"],
#f-bass:checked ~ .filters [for="f-bass"],
#f-amps:checked ~ .filters [for="f-amps"],
#f-pedals:checked ~ .filters [for="f-pedals"],
#f-accessories:checked ~ .filters [for="f-accessories"],
#f-speakers:checked ~ .filters [for="f-speakers"],
#f-mixers:checked ~ .filters [for="f-mixers"],
#f-mics:checked ~ .filters [for="f-mics"],
#f-turntables:checked ~ .filters [for="f-turntables"] {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

/* keyboard focus on a filter */
#f-all:focus-visible ~ .filters [for="f-all"],
#f-electric:focus-visible ~ .filters [for="f-electric"],
#f-acoustic:focus-visible ~ .filters [for="f-acoustic"],
#f-bass:focus-visible ~ .filters [for="f-bass"],
#f-amps:focus-visible ~ .filters [for="f-amps"],
#f-pedals:focus-visible ~ .filters [for="f-pedals"],
#f-accessories:focus-visible ~ .filters [for="f-accessories"],
#f-speakers:focus-visible ~ .filters [for="f-speakers"],
#f-mixers:focus-visible ~ .filters [for="f-mixers"],
#f-mics:focus-visible ~ .filters [for="f-mics"],
#f-turntables:focus-visible ~ .filters [for="f-turntables"] {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* hide products that don't match the selected filter */
#f-electric:checked ~ .grid .item:not(.electric),
#f-acoustic:checked ~ .grid .item:not(.acoustic),
#f-bass:checked ~ .grid .item:not(.bass),
#f-amps:checked ~ .grid .item:not(.amps),
#f-pedals:checked ~ .grid .item:not(.pedals),
#f-accessories:checked ~ .grid .item:not(.accessories),
#f-speakers:checked ~ .grid .item:not(.speakers),
#f-mixers:checked ~ .grid .item:not(.mixers),
#f-mics:checked ~ .grid .item:not(.mics),
#f-turntables:checked ~ .grid .item:not(.turntables) {
  display: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  align-items: start; /* each card only as tall as its own content */
  gap: 1rem;
}

.item {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  /* plays on load and every time a filter shows the item */
  animation: fade-up 0.35s ease backwards;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.item:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
}

.photo {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--photo);
  font-size: 3rem;
}

/* every photo fills the same 4:3 frame, whatever its own size */
.photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* icon shown while a product has no photo */
.photo:not(:has(img))::before              { content: "🎸"; }
.amps .photo:not(:has(img))::before        { content: "🔊"; }
.pedals .photo:not(:has(img))::before      { content: "🎛️"; }
.accessories .photo:not(:has(img))::before { content: "🧰"; }
.speakers .photo:not(:has(img))::before    { content: "📢"; }
.mixers .photo:not(:has(img))::before      { content: "🎚️"; }
.mics .photo:not(:has(img))::before        { content: "🎤"; }
.turntables .photo:not(:has(img))::before  { content: "💿"; }

.item h3 {
  font-size: 1rem;
  padding: 0.9rem 1rem 0;
  margin-bottom: 0.8rem;
}

/* category label above the name, written from the class (EN / IT) */
.item h3::before {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.electric h3::before    { content: "Electric guitar"; }
.acoustic h3::before    { content: "Acoustic guitar"; }
.bass h3::before        { content: "Bass"; }
.amps h3::before        { content: "Amp"; }
.pedals h3::before      { content: "Pedal"; }
.accessories h3::before { content: "Accessories"; }
.speakers h3::before    { content: "Speaker"; }
.mixers h3::before      { content: "Mixer"; }
.mics h3::before        { content: "Microphone"; }
.turntables h3::before  { content: "DJ & Hi-Fi"; }

:lang(it) .electric h3::before    { content: "Chitarra elettrica"; }
:lang(it) .acoustic h3::before    { content: "Chitarra acustica"; }
:lang(it) .bass h3::before        { content: "Basso"; }
:lang(it) .amps h3::before        { content: "Amplificatore"; }
:lang(it) .pedals h3::before      { content: "Pedale"; }
:lang(it) .accessories h3::before { content: "Accessori"; }
:lang(it) .speakers h3::before    { content: "Cassa"; }
:lang(it) .mixers h3::before      { content: "Mixer"; }
:lang(it) .mics h3::before        { content: "Microfono"; }
:lang(it) .turntables h3::before  { content: "DJ e Hi-Fi"; }

/* short description, cut after 2 lines (the full text is on the marketplace) */
.item .desc {
  padding: 0 1rem;
  margin: -0.4rem 0 0.9rem;
  font-size: 0.85rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

/* price row, with the New / Used tag on the left */
.price {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0 1rem 1rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.price::before {
  margin-right: auto;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}

.new .price::before  { content: "New";  background: var(--new-bg); color: var(--new); }
.used .price::before { content: "Used"; background: var(--soft);   color: var(--soft-text); }

:lang(it) .new .price::before  { content: "Nuovo"; }
:lang(it) .used .price::before { content: "Usato"; }

/* marketplace the product comes from, links to the original listing */
.source {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  transition: color 0.2s, background 0.2s;
}

.source img {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  display: block;
}

.source::after {
  content: "↗";
  margin-left: auto;
}

.source:hover {
  color: var(--text);
  background: var(--soft);
}

/* ===== CONTACT ===== */
/* each box is as wide as its text (a long email stays on one line);
   it only breaks the text if the screen is narrower than the email */
.boxes {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.box {
  flex: 0 1 auto;
  min-width: 240px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  overflow-wrap: anywhere;
}

.box h3,
.box-title {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

/* email: tap or click to write an email */
.mail:hover {
  text-decoration: underline;
}

/* chat button */
.chat-btn {
  display: block;
  text-align: left;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.chat-btn .box-title {
  color: rgba(255, 255, 255, 0.8);
}

.chat-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

/* ===== CHAT (full screen, built by site.js) ===== */
.chat-fab {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  transition: background 0.2s, transform 0.2s;
}

.chat-fab:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

.chat-fab svg {
  width: 26px;
  height: 26px;
}

/* computers: a box in the middle of the screen, the page dimmed behind it */
.chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.55);
}

.chat-overlay.open {
  display: flex;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 420px;
  height: min(640px, 100%);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  animation: fade-up 0.25s ease;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--topbar);
  border-bottom: 1px solid var(--line);
}

.chat-title {
  color: var(--muted);
  font-weight: 600;
}

.chat-close {
  margin-left: auto;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s;
}

.chat-close:hover {
  border-color: var(--text);
}

.chat-close svg {
  width: 18px;
  height: 18px;
}

.chat-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: var(--bg);
}

/* the page behind doesn't scroll while the chat is open */
body.chat-open {
  overflow: hidden;
}

/* ===== ANIMATION ===== */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== PHONES ===== */
@media (max-width: 700px) {
  html {
    scroll-padding-top: 6.5rem;
  }

  /* top bar: logo + theme + language, menu below */
  .topbar-inner {
    flex-wrap: wrap;
    row-gap: 0.5rem;
    column-gap: 0.75rem;
  }

  .logo {
    font-size: 1.1rem;
    white-space: nowrap;
  }

  .right {
    gap: 0.6rem;
  }

  .menu {
    order: 3;
    width: 100%;
    justify-content: space-between;
  }

  /* compact intro and contacts so the products show up sooner */
  .hero,
  .section {
    padding: 1.25rem 1rem;
  }

  .hero h1 {
    font-size: 1.45rem;
  }

  .hero p {
    font-size: 1rem;
    margin: 0.5rem 0 1rem;
  }

  h2 {
    font-size: 1.4rem;
    margin-bottom: 0.6rem;
  }

  .intro {
    font-size: 0.9rem;
    margin-bottom: 0.8rem;
  }

  .boxes {
    gap: 0.5rem;
  }

  /* boxes fill the row; a long email moves to its own row */
  .box {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.55rem 0.7rem;
    font-size: 0.85rem;
  }

  .box h3,
  .box-title {
    font-size: 0.68rem;
    margin-bottom: 0.1rem;
  }

  /* socials on one line */
  .socials {
    flex-wrap: nowrap;
    gap: 0.3rem;
    margin-top: 0.6rem;
  }

  .social {
    height: 30px;
    gap: 0.3rem;
    padding: 0 0.55rem 0 0.35rem;
    font-size: 0.7rem;
  }

  .social svg,
  .social img {
    width: 16px;
    height: 16px;
  }

  /* filters on one row you can swipe */
  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 0.4rem;
    margin: 0 -1rem 0.8rem;
    padding: 0 1rem;
  }

  .filters label {
    flex: none;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
  }

  /* two products per row on phones, so people see more stock at once */
  .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
  }

  .item h3 {
    font-size: 0.9rem;
    padding: 0.7rem 0.75rem 0;
    margin-bottom: 0.6rem;
  }

  .price {
    flex-wrap: wrap;
    padding: 0 0.75rem 0.8rem;
  }

  .item .desc {
    padding: 0 0.75rem;
    margin: -0.3rem 0 0.7rem;
    font-size: 0.78rem;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  .source {
    gap: 0.35rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.7rem;
  }

  .source img {
    width: 15px;
    height: 15px;
  }

  /* room at the end of the page so the chat button doesn't cover the last text */
  main {
    padding-bottom: 4rem;
  }

  /* the chat takes the whole screen */
  .chat-overlay {
    padding: 0;
  }

  .chat-panel {
    max-width: none;
    height: 100%;
    border: 0;
    border-radius: 0;
  }

  .chat-fab {
    right: 0.75rem;
    bottom: 0.75rem;
    width: 48px;
    height: 48px;
  }

  .chat-fab svg {
    width: 22px;
    height: 22px;
  }
}

/* very small phones: the marketplace buttons go on two lines */
@media (max-width: 359px) {
  .socials {
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
