/**
 * @file
 * Dark mode styles for Gutenberg Base theme.
 *
 * Preset color variable overrides for dark mode are injected at runtime
 * via gutenberg_base_page_attachments_alter() from palette.dark in
 * gutenberg_base.gutenberg.yml, using the html.dark-mode body selector.
 */

/* --- Semantic UI colors (messages, status indicators) --- */

:root {
  --color-status: #4caf50;
  --color-warning: #ff9800;
}

html.dark-mode {
  --color-status: #66bb6a;
  --color-warning: #ffa726;
}

/* --- Native UI color scheme (scrollbars, form controls) --- */

html.dark-mode {
  color-scheme: dark;
}

/* --- Logo: use brightness filter to make black paths visible on dark bg --- */

html.dark-mode .site-branding__logo img {
  filter: brightness(0) invert(1);
}

/* --- Dark mode toggle button --- */

.dark-mode-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: none;
  border: 1px solid var(--wp--preset--color--border, #dcdcde);
  border-radius: 0.25rem;
  cursor: pointer;
  color: var(--wp--preset--color--dark, #1a1a1a);
  flex-shrink: 0;
}

.dark-mode-toggle:hover {
  background-color: var(--wp--preset--color--light, #f0f0f0);
  border-color: var(--wp--preset--color--muted, #757575);
}

.dark-mode-toggle:focus-visible {
  outline: 2px solid var(--wp--preset--color--primary, #0073aa);
  outline-offset: 2px;
}

/* Toggle icon via CSS mask — override in child themes to change icons */
.dark-mode-toggle::before {
  content: '';
  display: block;
  width: 18px;
  height: 18px;
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'/%3E%3C/svg%3E");
  mask-size: contain;
  mask-repeat: no-repeat;
}

html.dark-mode .dark-mode-toggle::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='5'/%3E%3Cline x1='12' y1='1' x2='12' y2='3'/%3E%3Cline x1='12' y1='21' x2='12' y2='23'/%3E%3Cline x1='4.22' y1='4.22' x2='5.64' y2='5.64'/%3E%3Cline x1='18.36' y1='18.36' x2='19.78' y2='19.78'/%3E%3Cline x1='1' y1='12' x2='3' y2='12'/%3E%3Cline x1='21' y1='12' x2='23' y2='12'/%3E%3Cline x1='4.22' y1='19.78' x2='5.64' y2='18.36'/%3E%3Cline x1='18.36' y1='5.64' x2='19.78' y2='4.22'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='5'/%3E%3Cline x1='12' y1='1' x2='12' y2='3'/%3E%3Cline x1='12' y1='21' x2='12' y2='23'/%3E%3Cline x1='4.22' y1='4.22' x2='5.64' y2='5.64'/%3E%3Cline x1='18.36' y1='18.36' x2='19.78' y2='19.78'/%3E%3Cline x1='1' y1='12' x2='3' y2='12'/%3E%3Cline x1='21' y1='12' x2='23' y2='12'/%3E%3Cline x1='4.22' y1='19.78' x2='5.64' y2='18.36'/%3E%3Cline x1='18.36' y1='5.64' x2='19.78' y2='4.22'/%3E%3C/svg%3E");
}

/* --- Smooth transition when toggling (not on initial load) --- */
/* Scoped to structural elements to avoid matching thousands of nodes. */

html.dark-mode-transition,
html.dark-mode-transition * {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease !important;
  transition-delay: 0s !important;
}

/* Search icon override for dark mode (hardcoded fill in data URI). */
html.dark-mode .header-search input[type="submit"],
html.dark-mode .header-search button[type="submit"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
}
