/* Dark-mode contract — loaded last so it always wins over component stylesheets.
   Component CSS was written against a light palette; where a colour cannot be expressed
   as a theme token (status chips, tinted alerts, solid accent buttons) the rule below
   gives the dark theme its own value instead of leaving light-on-light text. */

/* Accent buttons: the accent lightens in dark mode, so the label must darken with it. */
button, .button { color: var(--accent-text, #171b17); }
.button.dark, .cta .button.dark { color: var(--paper, #fff); }
.button.outline { color: var(--ink); border-color: var(--border-strong, #cdd0c5); }

/* Status chips and semantic tints: light pastel fills need their ink inverted. */
html[data-theme=dark] .status-pill,
html[data-theme=dark] .bg-status,
html[data-theme=dark] .pill,
html[data-theme=dark] .tag {
  color: var(--ink);
  background: var(--surface-soft);
  border-color: var(--line);
}
html[data-theme=dark] .status-pill.available,
html[data-theme=dark] .status-pill.active,
html[data-theme=dark] .bg-status-active {
  background: #1d3323; color: #b9e6c4; border-color: #2f5b3a;
}
html[data-theme=dark] .status-pill.maintenance,
html[data-theme=dark] .bg-status-completed {
  background: #3a2f1c; color: #edc98a; border-color: #5c4a2a;
}
html[data-theme=dark] .status-pill.archived,
html[data-theme=dark] .bg-expired {
  background: #3d2421; color: #ffbfb3; border-color: #66332c;
}
html[data-theme=dark] .bg-status-confirmed {
  background: #1e2f3a; color: #b6dcf0; border-color: #35566b;
}
html[data-theme=dark] .notice-warn,
html[data-theme=dark] .bg-legal,
html[data-theme=dark] .bg-emergency {
  background: var(--surface-alt);
  color: var(--ink);
  border-color: var(--line);
}
html[data-theme=dark] .errorlist,
html[data-theme=dark] .notice.error {
  background: var(--error-bg);
  color: var(--error-text);
}

/* Light-tinted badge sets in v4.css (packages, statuses, alerts). */
html[data-theme=dark] .badge,
html[data-theme=dark] .chip,
html[data-theme=dark] .pkg-chip {
  background: var(--surface-soft);
  color: var(--ink);
  border-color: var(--line);
}

/* Areas that stay dark in both themes keep light text by design. */
html[data-theme=dark] .bg-sos-panel,
html[data-theme=dark] .bg-sos-panel .bg-small,
html[data-theme=dark] .bg-sos-fallback .button,
html[data-theme=dark] .bg-amenity-actions .button.outline,
html[data-theme=dark] .cta,
html[data-theme=dark] .topline,
html[data-theme=dark] .showcase-banner {
  color: #f6f4ec;
}

/* ============================================================================
   Task 27 — dark-mode legibility sweep (client complaint: "text is not clear").
   Found by audit_readability.py, which composites the real painted background and
   measures AA contrast (4.5:1 body / 3:1 large) on rendered pixels.
   Two root causes, both fixed here:
     1. Surfaces that hard-code a light fill (#fff, #fbfaf7, #f6f1ea …) but let the
        text colour come from the theme, so in dark mode a light ink lands on a
        light card.
     2. De-emphasis by `opacity` (th, .footer-copy, .bubble small, arrows). At 60%
        a light ink over a dark surface loses more luminance than a dark ink over
        a light surface, so headings that read fine in light mode vanish in dark.
   ========================================================================== */

/* 1. Light-mode surfaces -> dark tokens. */
html[data-theme=dark] .aa-row,
html[data-theme=dark] .aa-file,
html[data-theme=dark] .aa-photo img,
html[data-theme=dark] .pm-thumb,
html[data-theme=dark] .pkg-repeat-row,
html[data-theme=dark] .wd-admin-section,
html[data-theme=dark] .wd-tab,
html[data-theme=dark] .wd-addon-picker,
html[data-theme=dark] .wd-addon.is-included,
html[data-theme=dark] .wd-addon-choice.is-included,
html[data-theme=dark] .wd-progress,
html[data-theme=dark] .bg-photo-field,
html[data-theme=dark] .bg-alert-card,
html[data-theme=dark] .bg-alert-card.bg-alert-acknowledged,
html[data-theme=dark] .bg-alert-card.bg-alert-responding,
html[data-theme=dark] .bg-chip,
html[data-theme=dark] .bg-status-completed,
html[data-theme=dark] .ra-row-pending,
html[data-theme=dark] .ra-stat-alert,
html[data-theme=dark] .av-day-booked,
html[data-theme=dark] .av-day-workshop,
html[data-theme=dark] .av-dot-booked,
html[data-theme=dark] .av-dot-workshop,
html[data-theme=dark] .fs-dot-free,
html[data-theme=dark] .fs-dot-booked,
html[data-theme=dark] .fs-dot-workshop,
html[data-theme=dark] .soc-mini.is-on {
  background: var(--surface-soft, #292624);
  color: var(--ink, #f2eeea);
  border-color: var(--line, #393532);
}

/* Form controls inside those light cards keep the themed input colours. */
html[data-theme=dark] .wd-filter-form input,
html[data-theme=dark] .wd-filter-form select,
html[data-theme=dark] .wd-grid-form input,
html[data-theme=dark] .wd-grid-form select,
html[data-theme=dark] .pkg-repeat-row input,
html[data-theme=dark] .pkg-repeat-row select,
html[data-theme=dark] .pkg-repeat-row textarea,
html[data-theme=dark] .aa-row input,
html[data-theme=dark] .aa-row select,
html[data-theme=dark] .aa-row textarea,
html[data-theme=dark] .wd-admin-section input,
html[data-theme=dark] .wd-admin-section select,
html[data-theme=dark] .wd-admin-section textarea {
  background: var(--input, #182016);
  color: var(--ink, #f2eeea);
  border-color: var(--input-line, #475140);
}

/* Amber "attention" notices need an amber-tinted dark surface, not a white one. */
html[data-theme=dark] .notice-warn,
html[data-theme=dark] .aud-status.is-warn {
  background: #3a2f1c;
  color: #f0d49a;
  border-color: #5c4a2a;
}
html[data-theme=dark] .aud-status.is-bad {
  background: #3d2020;
  color: #ffb4a8;
  border-color: #6b3230;
}
html[data-theme=dark] .bg-dropzone.is-dragging {
  background: #33291c;
  border-color: var(--orange, #ff915b);
}

/* 2. Opacity-based de-emphasis: raise it and let a token carry the tone instead. */
html[data-theme=dark] th,
html[data-theme=dark] .soc-table th,
html[data-theme=dark] .aud-table th,
html[data-theme=dark] .ops th {
  opacity: 1;
  color: var(--muted, #bdb6ae);
}
html[data-theme=dark] th[style*="opacity"],
html[data-theme=dark] .admin-page th {
  opacity: 1;
}
html[data-theme=dark] .drawer-group a span { opacity: .8; }
html[data-theme=dark] .drawer-person small,
html[data-theme=dark] .drawer-search { color: #c3cfd8; }
html[data-theme=dark] .avatar,
html[data-theme=dark] .ops-avatar { background: #d98a4f; color: #1b1206; }
html[data-theme=dark] .footer-copy { opacity: 1; color: var(--muted, #bdb6ae); }
html[data-theme=dark] .bubble small { opacity: 1; color: var(--muted, #bdb6ae); }
html[data-theme=dark] .site-dock-list a small { opacity: 1; color: inherit; }
html[data-theme=dark] .site-dock-panel .site-dock-note { opacity: 1; color: var(--muted, #bdb6ae); }

/* 3. Verified one-off offenders. */
html[data-theme=dark] .notif-gone { color: #a29a90; }
html[data-theme=dark] .notif-tab span { opacity: 1; color: inherit; }
html[data-theme=dark] .page-step.is-disabled { opacity: 1; color: #a8a19a; border-color: var(--line, #393532); }
html[data-theme=dark] .faq-chevron,
html[data-theme=dark] .site-dock-glyph { color: var(--orange, #ff915b); }
html[data-theme=dark] .ra-tabs a.is-active,
html[data-theme=dark] .admin-tabs a[aria-current] {
  background: var(--orange, #ff915b);
  border-color: var(--orange, #ff915b);
  color: var(--accent-text, #211810);
}

/* 4. Danger ink: #a51f1f / #b3261e are dark reds — they disappear on a dark card.
      The accent-button rule at the top of this file also forced dark ink onto these
      buttons, so the label is restored explicitly. */
html[data-theme=dark] .bg-danger,
html[data-theme=dark] .bg-danger-summary,
html[data-theme=dark] .fs-danger,
html[data-theme=dark] .ra-danger,
html[data-theme=dark] .danger,
html[data-theme=dark] .soc-danger,
html[data-theme=dark] .aa-remove,
html[data-theme=dark] .pm-remove,
html[data-theme=dark] .field-error,
html[data-theme=dark] .ops .danger { color: #ff9d8a; border-color: #7f4030; }
html[data-theme=dark] button.pm-danger,
html[data-theme=dark] .bg-danger-button,
html[data-theme=dark] .button.danger {
  background: #c22b17;
  border-color: #c22b17;
  color: #fff8f5;
}
html[data-theme=dark] .bg-danger-zone { border-color: #ff9d8a; }
html[data-theme=dark] .bg-danger-zone p { color: var(--muted, #bdb6ae); }

/* Both themes: the WhatsApp chip in the dock was #fff on #126d43 = 4.0:1 (needs 4.5). */
.site-dock-list a.is-whatsapp { background: #0b5c38; color: #ffffff; border-color: #0b5c38; }
.site-dock-list a.is-whatsapp small { opacity: 1; }

/* 5. Light theme: the brand orange (#eb642c) is 3.3:1 on white, so any *small* text in
      it fails AA — eyebrows, categories, prices, numerals, the current nav item. The
      logo and large display headings keep the true brand orange; small text uses a
      deeper burnt orange (5.3:1 on white, 4.6:1 on the warm page tint) that still reads
      as the same brand. */
html:not([data-theme=dark]) {
  --accent-ink: #b04a17;
  --wa-ink: #0d6b5f;
}
html:not([data-theme=dark]) .eyebrow,
html:not([data-theme=dark]) .category,
html:not([data-theme=dark]) .wd-addon-price,
html:not([data-theme=dark]) .about-value-number,
html:not([data-theme=dark]) .about-role,
html:not([data-theme=dark]) .booking-path b,
html:not([data-theme=dark]) .service-description summary,
html:not([data-theme=dark]) header nav li a[aria-current],
html:not([data-theme=dark]) header nav li a.is-active,
html:not([data-theme=dark]) .car small,
html:not([data-theme=dark]) .text-link.accent {
  color: var(--accent-ink);
}
html:not([data-theme=dark]) .pkg-chip.is-active {
  background: #b8461b;
  border-color: #b8461b;
  color: #fff;
}

/* WhatsApp teal: #128c7e is 4.1:1 on white — a shade deeper in light, lighter in dark. */
.wa-card { color: var(--wa-ink, #0d6b5f); border-color: color-mix(in srgb, var(--wa-ink, #0d6b5f) 30%, transparent); }
html[data-theme=dark] .wa-card { color: #3fc7b4; border-color: #3fc7b455; }
html[data-theme=dark] .wa-card:hover,
html[data-theme=dark] .wa-card:focus-visible { background: #0f6b60; color: #ffffff; border-color: #0f6b60; }

/* 6. The floating contact dock: its summary is filled with --ink, which is *light* in
      dark mode while the glyph stays white — an invisible button on every page. */
html[data-theme=dark] .site-dock > summary { color: var(--paper, #141813); }
html[data-theme=dark] .site-dock[open] > summary { color: var(--accent-text, #211810); }

/* 7. Remaining light-theme accent text found by the sweep. */
html:not([data-theme=dark]) .amount small,
html:not([data-theme=dark]) .car-bottom small,
html:not([data-theme=dark]) .consent-line a,
html:not([data-theme=dark]) .contact-form label.consent-line a {
  color: var(--accent-ink, #b04a17);
}
/* Eyebrows that sit on a deliberately dark panel keep the bright brand orange —
   darkening them there would drop them to 3:1 on the dark fill. */
html:not([data-theme=dark]) .cta .eyebrow,
html:not([data-theme=dark]) .showcase-banner .eyebrow,
html:not([data-theme=dark]) .home-cta .eyebrow,
html:not([data-theme=dark]) .bg-amenity-feature .eyebrow {
  color: var(--orange, #eb642c);
}
html:not([data-theme=dark]) .home-amenity-grid small,
html:not([data-theme=dark]) .amenities-catalogue small,
html:not([data-theme=dark]) .journey-price small,
html:not([data-theme=dark]) .assistant-result small {
  color: var(--accent-ink, #b04a17);
}

/* 8. Danger buttons keep white labels in both themes. The accent-button rule at the top
      of this file sets --accent-text on every button, which on a dark red fill is 2.3:1. */
button.pm-danger, button.bg-danger-button, button.button.danger,
.bg-danger-button, .pm-danger, .button.danger { color: #fff8f5; }
html[data-theme=dark] button.pm-danger,
html[data-theme=dark] button.bg-danger-button,
html[data-theme=dark] .bg-danger-button,
html[data-theme=dark] .pm-danger { color: #fff8f5; }

/* 9. Accent-coloured text buttons in the light admin. */
html:not([data-theme=dark]) .link-button,
html:not([data-theme=dark]) .text-link.accent,
html:not([data-theme=dark]) .launch-status strong {
  color: var(--accent-ink, #b04a17);
}

/* 10. The SOS panel keeps its own dark maroon fill in *both* themes, so its outline
       buttons must not inherit the page ink (our .button.outline rule was winning). */
.bg-sos-panel .button,
.bg-sos-panel .button.outline,
.bg-sos-fallback .button,
.bg-sos-fallback .button.outline {
  color: #fff6f2;
  border-color: #f0c3b6;
  background: transparent;
}
.bg-sos-panel .button:hover,
.bg-sos-fallback .button:hover { background: #ffffff1a; color: #ffffff; }

/* Timeline labels inside the engagement record. */
html[data-theme=dark] .bg-timeline-kind { color: #edc98a; }
html[data-theme=dark] .bg-timeline-sos .bg-timeline-kind,
html[data-theme=dark] .bg-timeline-incident .bg-timeline-kind { color: #ff9d8a; }

/* Footer dark-mode: the base stylesheet hardcodes a light footer (#eceee6) with
   dim gray links (#717767). Give dark mode a dark footer with readable links so
   every footer word (incl. "Queries & complaints") is clear in dark mode. */
html[data-theme=dark] footer { background: var(--surface-footer, #1a2118); border-top: 1px solid var(--line, #343c32); }
html[data-theme=dark] .footer-grid p,
html[data-theme=dark] .footer-grid a { color: var(--muted, #adb3a7); }
html[data-theme=dark] .footer-grid a:hover { color: var(--orange, #eb642c); }
html[data-theme=dark] .footer-grid h4 { color: var(--ink, #edece5); }
html[data-theme=dark] .footer-grid p strong { color: var(--ink, #edece5); }
html[data-theme=dark] .footer-bottom { border-top-color: var(--line, #343c32); color: var(--muted, #adb3a7); }
