/* Theme controls share one preference across the desktop and mobile headers. */
:root { color-scheme: light; }
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 40px;
  width: 40px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
}
.theme-toggle:hover { border-color: var(--orange-dark); color: var(--orange-dark); }
.theme-toggle svg { flex-shrink: 0; pointer-events: none; }
@media (max-width: 600px) {
  .mobile-menu { gap: 4px; }
  .mobile-menu .theme-toggle { flex-basis: 36px; width: 36px; }
}
@media print {
  .theme-toggle { display: none !important; }
  html, body { background: #fff !important; color: #242724 !important; }
}

/* Existing light styling remains the default, including the print palette. */
@media screen {
  html[data-theme="dark"] {
    color-scheme: dark;
    --paper: #101713;
    --surface: #19251e;
    --paper-alt: #162019;
    --paper-muted: #223027;
    --ink: #edf2ed;
    --muted: #b9c6bc;
    --line: #435649;
    --orange: #ef8b4d;
    --orange-dark: #ffb47d;
    --orange-deep: #ffa05d;
    --orange-light: #ffc28e;
    --dark: #162019;
    --dark-deep: #0c120e;
  }

  html[data-theme="dark"] .site-header { background: rgb(16 23 19 / 96%); }
  html[data-theme="dark"] :is(
    .mobile-menu nav, .expertise-card, .editorial-panel, .product-card,
    .service-photo-figure, .service-side, .service-caution,
    .expertise-catalog-card, .expertise-approach-action,
    .company-service-card, .resources-checklist-card,
    .resources-doc-links, .visual-gallery-card, .partner-note,
    .form-layout, .form-success, .contact-success, .contact-form,
    .contact-grid aside, .contact-method, .contact-channels,
    .case-facts, .project-photo-frame, .products-index a,
    .shop-entry, .shop-families > a,
    .shop-search input, .commerce-price-panel, .catalog-family-nav button,
    .company-buying-topic, .portfolio-filters button, .portfolio-empty,
    .sales-showcase, .sales-surface-label, .sales-surface-field input,
    .company-new-intro, .company-new-product, .company-new-services,
    .company-new-projects .expertise-card,
    .company-new-location-grid .contact-address,
    .expertise-new-shop, .expertise-new-complementary
  ) { background-color: var(--surface); }

  html[data-theme="dark"] :is(
    .clients-section, .company-services-section, .resources-guide-section,
    .expertise-approach-section, .company-location-section,
    .company-new-trade, .company-new-locations,
    .commerce-product-image, .project-photo-slide, .case-card-image,
    .company-new-project-photo
  ) { background-color: var(--paper-alt); }

  html[data-theme="dark"] :is(.field input, .field select, .field textarea, .shop-search input, .sales-surface-field input) {
    background: #111c15;
    color: var(--ink);
    border-color: #6a7f70;
  }
  html[data-theme="dark"] :is(input, textarea)::placeholder { color: #a8b9ad; opacity: 1; }
  html[data-theme="dark"] :is(.field input, .field select, .field textarea):focus { border-color: var(--orange-dark); }

  /* Keep the orange actions readable when the accent becomes brighter. */
  html[data-theme="dark"] .button {
    background: #ef8b4d;
    border-color: #ef8b4d;
    color: #181c18;
  }
  html[data-theme="dark"] .button:hover { background: #ffac70; border-color: #ffac70; }
  html[data-theme="dark"] .button-light { background: var(--surface); border-color: var(--line); color: var(--ink); }
  html[data-theme="dark"] .button-light:hover { background: #293c30; border-color: var(--orange-dark); }
  html[data-theme="dark"] :is(.commerce-cart-count, .success-check, .form-steps li.done > span, .mobile-project-link) { color: #181c18; }
  html[data-theme="dark"] .portfolio-filters button[aria-pressed="true"] { background: #ef8b4d; border-color: #ef8b4d; color: #181c18; }
  html[data-theme="dark"] .catalog-family-nav button[aria-pressed="true"] { background: #38281d; }
  html[data-theme="dark"] .sales-product-tabs button[aria-pressed="true"] { background: var(--surface); }
  html[data-theme="dark"] .sales-product-stage { background: radial-gradient(ellipse at center, #2b3b30, #18221c); }

  html[data-theme="dark"] .form-error { background: #3d241d; color: #ffd3c4; border-color: #f0a58d; }
  html[data-theme="dark"] :is(.form-success-note, .cart-add-confirmation, .whatsapp-receipt) { background: #173423; color: #c2ecd0; border-color: #669a76; }
  html[data-theme="dark"] .whatsapp-receipt p { color: #c2ecd0; }
  html[data-theme="dark"] .catalog-quick-add p { color: #a9e0b9 !important; }
  html[data-theme="dark"] .navbar-whatsapp { color: #9bd8ac; }
  html[data-theme="dark"] .navbar-whatsapp:hover { color: #c2ecd0; }
  html[data-theme="dark"] .whatsapp-receipt-links .button { background: #166b3c; border-color: #669a76; color: #fff; }

  /* Photograph veils follow the reading palette; photo files stay untouched. */
  html[data-theme="dark"] .page-with-photos > .section:last-of-type:not(.cta-section) {
    background-image: linear-gradient(90deg, #101713f5, #101713e6), var(--closing-photo);
  }
  html[data-theme="dark"] .page-with-photos > .section:only-of-type:not(.inner-hero):not(.cta-section) {
    background-image: linear-gradient(90deg, #101713f5, #101713e6), var(--opening-photo), var(--closing-photo);
  }
  html[data-theme="dark"] .page-with-photos > .products-section {
    background-image: linear-gradient(0deg, #101713e6, #101713f0 60%, var(--paper) 100%), var(--closing-photo);
  }
  html[data-theme="dark"] .page-with-photos > .products-section .catalog-main > .commerce-note:last-child { background: #19251eeb; }

  /* Neutral mats preserve the original colors and legibility of brand images. */
  html[data-theme="dark"] .client-card { background: var(--surface); }
  html[data-theme="dark"] .client-card:not(.client-card--dark) img { background: #fff; border-radius: 3px; padding: 6px; }
  html[data-theme="dark"] .client-card--dark { background: var(--dark-deep); }
  html[data-theme="dark"] :is(.commerce-product-image img, .company-new-product img, .expertise-new-shop-photo) { background: #e6e8e1; }
  html[data-theme="dark"] .product-card-media > span { background: #19251e; }
  html[data-theme="dark"] .product-card-media > small { color: #38463d; }
  html[data-theme="dark"] .waterproofing-demo { background: linear-gradient(145deg, #19251e, #101713); }
  html[data-theme="dark"] .water-demo-visual { --orange: #df681f; --orange-dark: #a6400b; }
  html[data-theme="dark"] .water-demo-button { color: var(--orange-dark); }
  html[data-theme="dark"] .water-demo-button:hover { background: #ef8b4d; color: #181c18; }
}
