/**
 * Tema scuro — attivato con html[data-theme="dark"]
 * (preferenza OS o toggle manuale)
 */

html[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #121517;
  --color-text: #FFFCF5;
  /* Verde solo per accenti (sottolineature); CTA primarie = crema */
  --color-primary: #CCFF66;
  --color-secondary: #A8D4C0;
  --color-line: #7A8A84;
  --btn-primary-bg: #FFFCF5;
  --btn-primary-bg-hover: #ffffff;
  --btn-primary-text: #121517;
  --btn-secondary-bg: transparent;
  --btn-secondary-bg-hover: rgba(255, 252, 245, 0.08);
  --btn-secondary-text: #FFFCF5;
  --btn-secondary-border: #FFFCF5;
  --btn-light-bg: #1B2023;
  --btn-light-bg-hover: #242A2E;
  --btn-light-text: #FFFCF5;
  --btn-light-border: #2E363B;
  --btn-shadow: 0 10px 28px -14px rgba(0, 0, 0, 0.55);
  --btn-shadow-hover: 0 14px 34px -14px rgba(0, 0, 0, 0.7);
}

html[data-theme="dark"] body {
  background-color: var(--color-bg);
  color: var(--color-text);
}

/* Superfici / testi Tailwind hardcoded sulla homepage */
html[data-theme="dark"] [class*="bg-[#FFFCF5]"],
html[data-theme="dark"] [class*="bg-[#FFFDF5]"],
html[data-theme="dark"] [class*="bg-[#fffcf5]"],
html[data-theme="dark"] [class*="bg-[#fffdf5]"] {
  background-color: var(--color-bg) !important;
}

html[data-theme="dark"] [class*="text-[#141A18]"],
html[data-theme="dark"] [class*="text-[#053021]"] {
  color: var(--color-text) !important;
}
/* Sublines mute (#3d4743): su dark diventano crema leggibile */
html[data-theme="dark"] [class*="text-[#3d4743]"],
html[data-theme="dark"] [class*="text-[#3D4743]"] {
  color: rgba(255, 252, 245, 0.78) !important;
}

html[data-theme="dark"] [class*="border-[#141A18]"] {
  border-color: rgba(255, 252, 245, 0.12) !important;
}

html[data-theme="dark"] [class*="hover:text-[#053021]"]:hover {
  color: var(--color-primary) !important;
}

html[data-theme="dark"] [class*="bg-[#141A18]"] {
  background-color: rgba(255, 252, 245, 0.9) !important;
}

/* Barra legale (404, grazie, ecc.): resta nera con testo chiaro */
html[data-theme="dark"] footer[role="contentinfo"] {
  background-color: #141a18 !important;
  color: #fffcf5 !important;
}

html[data-theme="dark"] #main-header .logo,
html[data-theme="dark"] .site-logo-mark {
  filter: invert(1) brightness(1.05);
}

html[data-theme="dark"] .clients-marquee img {
  filter: invert(1) grayscale(1) brightness(1.15);
  opacity: 0.72;
}

html[data-theme="dark"] .clients-marquee .group:hover img,
html[data-theme="dark"] .clients-marquee.group:hover img {
  filter: invert(1) grayscale(0) brightness(1.05);
  opacity: 1;
}

/* Sezioni con bg cream in CSS inline */
html[data-theme="dark"] #riconoscersi-scroll,
html[data-theme="dark"] .riconoscersi-header,
html[data-theme="dark"] .about-section,
html[data-theme="dark"] .home-faq,
html[data-theme="dark"] .services-band,
html[data-theme="dark"] .portfolio-entered,
html[data-theme="dark"] #portfolio {
  background-color: var(--color-bg);
  background: var(--color-bg);
}

html[data-theme="dark"] #riconoscersi-scroll {
  background: #121517;
}

/* Override CSS hardcoded cream/ink nella pagina */
html[data-theme="dark"] .riconoscersi-title,
html[data-theme="dark"] .services-note--dark .services-note__title,
html[data-theme="dark"] .services-note--dark .services-note__text,
html[data-theme="dark"] .services-editorial-title h2,
html[data-theme="dark"] .services-editorial-lead,
html[data-theme="dark"] .services-editorial-footer__prompt,
html[data-theme="dark"] .about-section__headline,
html[data-theme="dark"] .about-section__copy-title,
html[data-theme="dark"] .about-section__copy-col p,
html[data-theme="dark"] .about-section__contact-link,
html[data-theme="dark"] .about-section__meta,
html[data-theme="dark"] .home-faq__title,
html[data-theme="dark"] .home-faq__item,
html[data-theme="dark"] .home-faq summary,
html[data-theme="dark"] .home-faq p,
html[data-theme="dark"] .portfolio-work-list__title,
html[data-theme="dark"] .portfolio-work-list__title-text,
html[data-theme="dark"] .portfolio-work-list__tagline,
html[data-theme="dark"] .portfolio-work-list__heading,
html[data-theme="dark"] .hero-main-title,
html[data-theme="dark"] .hero-main-title__answer,
html[data-theme="dark"] .hero-text-col p,
html[data-theme="dark"] #mobile-menu-button {
  color: var(--color-text);
}
/*
 * Inchiostro su carta chiara (foglietti Ti riconosci + card servizi 1/3).
 * Stesso trattamento: non ereditano il cream del tema scuro.
 */
html[data-theme="dark"] .riconoscersi-card-name,
html[data-theme="dark"] .riconoscersi-card-quote p,
html[data-theme="dark"] .services-note:not(.services-note--dark) .services-note__title {
  color: #141a18;
}
html[data-theme="dark"] .riconoscersi-card-role {
  color: rgba(20, 26, 24, 0.55);
}
html[data-theme="dark"] .services-note:not(.services-note--dark) .services-note__text {
  color: #2a322f;
}
html[data-theme="dark"] .riconoscersi-quote-mark img {
  filter: brightness(0) opacity(0.82);
}
html[data-theme="dark"] .hero-main-title__question {
  color: rgba(255, 252, 245, 0.72);
  font-weight: 300;
}

html[data-theme="dark"] .about-section__contact-link:hover {
  color: var(--color-primary);
}

/* Badge CPACC: card chiara anche in dark, testo nero */
html[data-theme="dark"] .hero-cpacc__content {
  background: transparent;
}
html[data-theme="dark"] .hero-cpacc__title {
  color: #141a18;
}
html[data-theme="dark"] .hero-cpacc__subtitle {
  color: #5a635f;
}

html[data-theme="dark"] .booking-modal-panel,
html[data-theme="dark"] .booking-modal-header,
html[data-theme="dark"] .booking-modal-body {
  background: #1b2023;
  color: var(--color-text);
}

html[data-theme="dark"] .booking-modal-title,
html[data-theme="dark"] .booking-modal-close,
html[data-theme="dark"] .booking-modal-fallback {
  color: var(--color-text);
}

html[data-theme="dark"] .section-pattern {
  opacity: 0.22;
  filter: invert(1) brightness(1.4);
}

/* Hero: swap light/dark (picture elements) */
.hero-portrait-img--dark {
  display: none !important;
}
html[data-theme="dark"] .hero-portrait-img--light {
  display: none !important;
}
html[data-theme="dark"] .hero-portrait-img--dark {
  display: block !important;
}
.hero-portrait-frame {
  position: relative;
}
html[data-theme="dark"] .hero-portrait-img--dark img {
  position: relative;
}

/* FAQ / accordion tipici */
html[data-theme="dark"] .home-faq details,
html[data-theme="dark"] .home-faq__item {
  border-color: rgba(255, 252, 245, 0.14);
}

html[data-theme="dark"] .about-section__rule {
  background-color: rgba(255, 252, 245, 0.18);
}

html[data-theme="dark"] .about-section__meta-item {
  border-color: rgba(255, 252, 245, 0.12);
}

/* Portfolio media placeholder */
html[data-theme="dark"] .portfolio-work-list__media-inner {
  background: #1b2023;
}

/* Bottom CTA banner (se chiaro) */
html[data-theme="dark"] #bottom-cta-banner,
html[data-theme="dark"] #mobile-bottom-sheet {
  background-color: #1b2023;
  color: #fffcf5;
  border-color: rgba(255, 252, 245, 0.14);
}

/* Toggle tema — nascosto finché DARK_ENABLED = false in js/theme.js */
.theme-toggle[hidden] {
  display: none !important;
}
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: 999px;
  border: 1.5px solid rgba(20, 26, 24, 0.22);
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.theme-toggle:hover {
  background: rgba(20, 26, 24, 0.06);
  transform: translateY(-1px);
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
html[data-theme="dark"] .theme-toggle {
  border-color: #fffcf5;
  color: #fffcf5;
}
html[data-theme="dark"] .theme-toggle:hover {
  background: rgba(255, 252, 245, 0.08);
}
.theme-toggle__icon {
  width: 1.25rem;
  height: 1.25rem;
  display: block;
  object-fit: contain;
}
.theme-toggle__icon--sun { display: none; }
.theme-toggle__icon--moon { display: block; }
html[data-theme="dark"] .theme-toggle__icon--sun { display: block; }
html[data-theme="dark"] .theme-toggle__icon--moon { display: none; }

@media (max-width: 1023px) {
  .theme-toggle {
    margin-right: 0.35rem;
  }
}
