/**
 * WPC Bootstrap theme - replaces Bootstrap 5.3.3's default blue with the brand orange.
 *
 * Load this immediately AFTER bootstrap.min.css and BEFORE any page/layout CSS,
 * in every layout (public site and admin). Bootstrap ships precompiled here (no
 * Sass build), so retheming happens in two ways:
 *
 *   1. Repointing Bootstrap's own CSS variables - this reaches every component
 *      that reads them, including ones not written yet.
 *   2. Overriding rendered properties for the places Bootstrap hardcodes a blue
 *      hex instead of reading a variable. Those cannot be reached any other way
 *      without a Sass build; each is listed below with the component it fixes.
 *
 * Change --wpc-orange* here and the whole site follows.
 */

:root {
  --wpc-orange: #D47849;
  --wpc-orange-hover: #ef6603;
  --wpc-orange-rgb: 212, 120, 73;
  --wpc-orange-hover-rgb: 239, 102, 3;

  /* Tints/shades of --wpc-orange, standing in for Bootstrap's blue scale. */
  --wpc-orange-emphasis: #7a3f1f;
  --wpc-orange-bg-subtle: #f8e3d5;
  --wpc-orange-border-subtle: #ecc0a1;
  --wpc-orange-tint: #e9a982;

  --wpc-focus-ring: 0 0 0 0.25rem rgba(var(--wpc-orange-rgb), 0.25);
}

/*--------------------------------------------------------------
# 1. Bootstrap color tokens
--------------------------------------------------------------*/
:root,
[data-bs-theme="light"],
[data-bs-theme="dark"] {
  --bs-blue: var(--wpc-orange);

  --bs-primary: var(--wpc-orange);
  --bs-primary-rgb: var(--wpc-orange-rgb);
  --bs-primary-text-emphasis: var(--wpc-orange-emphasis);
  --bs-primary-bg-subtle: var(--wpc-orange-bg-subtle);
  --bs-primary-border-subtle: var(--wpc-orange-border-subtle);

  --bs-link-color: var(--wpc-orange);
  --bs-link-color-rgb: var(--wpc-orange-rgb);
  --bs-link-hover-color: var(--wpc-orange-hover);
  --bs-link-hover-color-rgb: var(--wpc-orange-hover-rgb);

  --bs-focus-ring-color: rgba(var(--wpc-orange-rgb), 0.25);

  --bs-dropdown-link-active-bg: var(--wpc-orange);
  --bs-nav-pills-link-active-bg: var(--wpc-orange);
  --bs-pagination-color: var(--wpc-orange);
  --bs-pagination-hover-color: var(--wpc-orange-hover);
  --bs-pagination-focus-color: var(--wpc-orange-hover);
  --bs-pagination-active-bg: var(--wpc-orange);
  --bs-pagination-active-border-color: var(--wpc-orange);
  --bs-pagination-focus-box-shadow: var(--wpc-focus-ring);
  --bs-progress-bar-bg: var(--wpc-orange);
  --bs-list-group-active-bg: var(--wpc-orange);
  --bs-list-group-active-border-color: var(--wpc-orange);
  --bs-accordion-btn-focus-box-shadow: var(--wpc-focus-ring);
  --bs-btn-close-focus-shadow: var(--wpc-focus-ring);
}

/*--------------------------------------------------------------
# 2. Components that hardcode blue
--------------------------------------------------------------*/

/* Form focus: border #86b7fe + blue ring, on inputs, selects and checkboxes. */
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: var(--wpc-orange);
  box-shadow: var(--wpc-focus-ring);
}

/* accent-color also covers the native focus tint on checkboxes/radios. */
.form-check-input {
  accent-color: var(--wpc-orange);
}

.form-check-input:checked,
.form-check-input[type="checkbox"]:indeterminate {
  background-color: var(--wpc-orange);
  border-color: var(--wpc-orange);
}

/* The switch knob is a background SVG with the blue baked into its fill, so it
   can only be recoloured by re-declaring the whole data URI. */
.form-switch .form-check-input:focus {
  --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23D47849'/%3e%3c/svg%3e");
}

.form-range::-webkit-slider-thumb {
  background-color: var(--wpc-orange);
}

.form-range::-moz-range-thumb {
  background-color: var(--wpc-orange);
}

.form-range::-webkit-slider-thumb:active {
  background-color: var(--wpc-orange-tint);
}

.form-range::-moz-range-thumb:active {
  background-color: var(--wpc-orange-tint);
}

.form-range:focus::-webkit-slider-thumb,
.form-range:focus::-moz-range-thumb {
  box-shadow: 0 0 0 1px #fff, var(--wpc-focus-ring);
}

.btn-primary {
  --bs-btn-bg: var(--wpc-orange);
  --bs-btn-border-color: var(--wpc-orange);
  --bs-btn-hover-bg: var(--wpc-orange-hover);
  --bs-btn-hover-border-color: var(--wpc-orange-hover);
  --bs-btn-active-bg: var(--wpc-orange-hover);
  --bs-btn-active-border-color: var(--wpc-orange-hover);
  --bs-btn-disabled-bg: var(--wpc-orange);
  --bs-btn-disabled-border-color: var(--wpc-orange);
  --bs-btn-focus-shadow-rgb: var(--wpc-orange-rgb);
}

.btn-outline-primary {
  --bs-btn-color: var(--wpc-orange);
  --bs-btn-border-color: var(--wpc-orange);
  --bs-btn-hover-bg: var(--wpc-orange);
  --bs-btn-hover-border-color: var(--wpc-orange);
  --bs-btn-active-bg: var(--wpc-orange);
  --bs-btn-active-border-color: var(--wpc-orange);
  --bs-btn-disabled-color: var(--wpc-orange);
  --bs-btn-disabled-border-color: var(--wpc-orange);
  --bs-btn-focus-shadow-rgb: var(--wpc-orange-rgb);
}

/* .btn and .page-link render their focus ring from --bs-btn-focus-shadow-rgb /
   their own box-shadow rather than --bs-focus-ring-color, so the rendered
   shadow has to win outright - this is the blue halo seen on mobile after a
   button is tapped, e.g. the OK button in a confirmation alert. */
.btn:focus-visible,
.btn-check:focus-visible + .btn,
.page-link:focus,
.nav-link:focus-visible,
.dropdown-item:focus-visible {
  box-shadow: var(--wpc-focus-ring) !important;
}

/* On touch screens :hover sticks after a tap, leaving outline buttons stuck in
   their filled state. Only apply the fill where hover is real. */
@media (hover: hover) {
  .btn-outline-danger:hover,
  .btn-outline-secondary:hover,
  .btn-outline-primary:hover {
    color: var(--bs-btn-hover-color);
    background-color: var(--bs-btn-hover-bg);
    border-color: var(--bs-btn-hover-border-color);
  }
}

@media (hover: none) {
  .btn-outline-danger:hover,
  .btn-outline-secondary:hover,
  .btn-outline-primary:hover {
    color: var(--bs-btn-color);
    background-color: var(--bs-btn-bg, transparent);
    border-color: var(--bs-btn-border-color);
  }
}

.page-item.active .page-link {
  background-color: var(--wpc-orange);
  border-color: var(--wpc-orange);
}

/* :active on a dropdown item reads --bs-dropdown-link-active-bg only for
   .active; the pressed state has its own rule. */
.dropdown-item:active,
.dropdown-item.active {
  background-color: var(--wpc-orange);
  color: #ffffff;
}

/* Elements outside Bootstrap's own components (plain buttons like the language
   selector toggle) fall back to the browser's blue focus outline. */
:focus-visible {
  outline-color: var(--wpc-orange);
}

/* Accordion chevron is a blue-stroked SVG when the panel is open. */
.accordion-button:not(.collapsed)::after {
  --bs-accordion-btn-active-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%237a3f1f' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M2 5L8 11L14 5'/%3e%3c/svg%3e");
}

.table-primary {
  --bs-table-bg: var(--wpc-orange-bg-subtle);
  --bs-table-border-color: #d3c1b4;
  --bs-table-striped-bg: #ecd8cb;
  --bs-table-active-bg: #e0cdc0;
}

.link-primary:hover,
.link-primary:focus {
  color: rgba(var(--wpc-orange-hover-rgb), var(--bs-link-opacity, 1)) !important;
  text-decoration-color: rgba(var(--wpc-orange-hover-rgb), var(--bs-link-underline-opacity, 1)) !important;
}

/* WebKit ignores `color` on the native search clear button, so it can only be
   recoloured by swapping its background image for an SVG. */
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  height: 1.3em;
  width: 1.3em;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='%23D47849' d='M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z'/></svg>");
  background-size: contain;
  background-repeat: no-repeat;
}

/*--------------------------------------------------------------
# 3. SweetAlert2
# Its confirm button takes its fill from confirmButtonColor, but the focus
# halo is a hardcoded blue-purple that no option exposes - which is the ring
# left around OK after tapping it on mobile.
--------------------------------------------------------------*/
.swal2-container button.swal2-styled.swal2-confirm:focus,
.swal2-container button.swal2-styled.swal2-default-outline:focus {
  box-shadow: 0 0 0 3px rgba(var(--wpc-orange-rgb), 0.5);
}

/*--------------------------------------------------------------
# 4. Quill editor (admin)
# Toolbar chrome only. Quill's .ql-color-blue / .ql-bg-blue are content
# colors an author picks for their text, so those stay blue.
--------------------------------------------------------------*/
.ql-snow.ql-toolbar button:hover,
.ql-snow .ql-toolbar button:hover,
.ql-snow.ql-toolbar button:focus,
.ql-snow .ql-toolbar button:focus,
.ql-snow.ql-toolbar button.ql-active,
.ql-snow .ql-toolbar button.ql-active,
.ql-snow.ql-toolbar .ql-picker-label:hover,
.ql-snow .ql-toolbar .ql-picker-label:hover,
.ql-snow.ql-toolbar .ql-picker-label.ql-active,
.ql-snow .ql-toolbar .ql-picker-label.ql-active,
.ql-snow.ql-toolbar .ql-picker-item:hover,
.ql-snow .ql-toolbar .ql-picker-item:hover,
.ql-snow.ql-toolbar .ql-picker-item.ql-selected,
.ql-snow .ql-toolbar .ql-picker-item.ql-selected {
  color: var(--wpc-orange);
}

.ql-snow.ql-toolbar button:hover .ql-fill,
.ql-snow .ql-toolbar button:hover .ql-fill,
.ql-snow.ql-toolbar button:focus .ql-fill,
.ql-snow .ql-toolbar button:focus .ql-fill,
.ql-snow.ql-toolbar button.ql-active .ql-fill,
.ql-snow .ql-toolbar button.ql-active .ql-fill,
.ql-snow.ql-toolbar .ql-picker-label:hover .ql-fill,
.ql-snow .ql-toolbar .ql-picker-label:hover .ql-fill,
.ql-snow.ql-toolbar .ql-picker-label.ql-active .ql-fill,
.ql-snow .ql-toolbar .ql-picker-label.ql-active .ql-fill,
.ql-snow.ql-toolbar .ql-picker-item:hover .ql-fill,
.ql-snow .ql-toolbar .ql-picker-item:hover .ql-fill,
.ql-snow.ql-toolbar .ql-picker-item.ql-selected .ql-fill,
.ql-snow .ql-toolbar .ql-picker-item.ql-selected .ql-fill,
.ql-snow.ql-toolbar button:hover .ql-stroke.ql-fill,
.ql-snow .ql-toolbar button:hover .ql-stroke.ql-fill,
.ql-snow.ql-toolbar button:focus .ql-stroke.ql-fill,
.ql-snow .ql-toolbar button:focus .ql-stroke.ql-fill,
.ql-snow.ql-toolbar button.ql-active .ql-stroke.ql-fill,
.ql-snow .ql-toolbar button.ql-active .ql-stroke.ql-fill {
  fill: var(--wpc-orange);
}

.ql-snow.ql-toolbar button:hover .ql-stroke,
.ql-snow .ql-toolbar button:hover .ql-stroke,
.ql-snow.ql-toolbar button:focus .ql-stroke,
.ql-snow .ql-toolbar button:focus .ql-stroke,
.ql-snow.ql-toolbar button.ql-active .ql-stroke,
.ql-snow .ql-toolbar button.ql-active .ql-stroke,
.ql-snow.ql-toolbar .ql-picker-label:hover .ql-stroke,
.ql-snow .ql-toolbar .ql-picker-label:hover .ql-stroke,
.ql-snow.ql-toolbar .ql-picker-label.ql-active .ql-stroke,
.ql-snow .ql-toolbar .ql-picker-label.ql-active .ql-stroke,
.ql-snow.ql-toolbar .ql-picker-item:hover .ql-stroke,
.ql-snow .ql-toolbar .ql-picker-item:hover .ql-stroke,
.ql-snow.ql-toolbar .ql-picker-item.ql-selected .ql-stroke,
.ql-snow .ql-toolbar .ql-picker-item.ql-selected .ql-stroke,
.ql-snow.ql-toolbar button:hover .ql-stroke-miter,
.ql-snow .ql-toolbar button:hover .ql-stroke-miter,
.ql-snow.ql-toolbar button:focus .ql-stroke-miter,
.ql-snow .ql-toolbar button:focus .ql-stroke-miter,
.ql-snow.ql-toolbar button.ql-active .ql-stroke-miter,
.ql-snow .ql-toolbar button.ql-active .ql-stroke-miter {
  stroke: var(--wpc-orange);
}

.ql-snow a {
  color: var(--wpc-orange);
}

/* Text selection and the browser's own UI accents (native selects, date
   pickers, spinners) default to blue too. */
::selection {
  background-color: rgba(var(--wpc-orange-rgb), 0.25);
}

:root {
  accent-color: var(--wpc-orange);
}
