/* Only paint the controls. Keep their layout, hit areas and native states. */
@layer dispatcher-glass {
@media (forced-colors: none) {
  html[data-dispatcher-background="galaxy"] {
    --glass-reflections: url("/glass/reflection.webp?v=3");
    /* Pixel-sized optics follow the actual rim at any button aspect ratio. */
    --glass-corners:
      radial-gradient(ellipse 25px 7px at 8% 1px, #fff9, transparent 100%),
      radial-gradient(ellipse 28px 6px at 90% calc(100% - 1px), #eaf9ff80, transparent 100%);
    --glass-edges:
      inset 0 1px 0 #fffffff2, inset 1px 0 1px #ffffff9e,
      inset 0 -1px 0 #e9f7ffab, inset -1px 0 0 #16233966,
      inset 0 0 0 2px #222e401c,
      inset 2px 3px 4px -2px #ffffffc4, inset -2px -3px 4px -2px #f1f9ff91,
      0 1px 1px #0713247a, 0 2px 4px -2px #030a16ad;
    --glass-deep-edges:
      inset 0 1px 0 #fffc, inset 1px 0 0 #ffffffbd,
      inset 0 -1px 0 #f8f8ffd9, inset -1px 0 1px #120c205e,
      inset 0 0 0 2px #220c241f,
      inset 2px 3px 3px -1.5px #ffffffa3, inset -2px -3px 3px -1px #fff8,
      inset 3px 4px 7px -3px #ffffff78, inset -3px -4px 9px -3px #10091d5c,
      0 1px 1px #050813bd, 0 3px 5px -2px #030816d1;
    --glass-red: url("/glass/ruby.webp?v=3");
    --glass-green: url("/glass/emerald.webp?v=3");
    --glass-amber: url("/glass/amber.webp?v=3");
    --glass-blue: url("/glass/sapphire.webp?v=3");
  }

  /* Also covers the controls mounted directly under body and inside the maps. */
  html[data-dispatcher-background="galaxy"] :where(
    button:not(.sliding-toggle > button.is-active),
    input:is([type="button"], [type="submit"], [type="reset"]),
    [role="button"], summary,
    a:is(.directions-button, .is-navigate, .patient-phone-button, .admin-sign-in, .side-menu-row, .media-file, .customer-qr-link),
    .access-gate > a, .job-utility-actions > a, .leaflet-bar > a,
    label:is(.media-picker, .message-media-picker, .recurrence-switch),
    .customer-when-options label,
    .category-option > span, .accepted-flip-face,
    .sliding-toggle, .sliding-toggle-indicator,
    .location-sharing-knob, .side-menu-theme-preference > i
  ):not(:where(
    [class$="-backdrop"], [class*="-backdrop "],
    .job-map-preview-trigger, .collaborator-map-expand, .conversation-pencil, .service-preference-item, .collaborator-color-legend summary, .visit-date.is-available, .accepted-flip-button, [role="button"].leaflet-interactive
  )),
  html[data-dispatcher-background="galaxy"] .side-menu-theme-preference > i::after {
    background-image: var(--glass-corners), var(--glass-pigment, var(--glass-reflections)) !important;
    background-size: 100% 100% !important;
    background-repeat: no-repeat !important;
  }

  html[data-dispatcher-background="galaxy"] :where(
    button:not(.sliding-toggle > button.is-active),
    input:is([type="button"], [type="submit"], [type="reset"]),
    [role="button"], summary,
    a:is(.directions-button, .is-navigate, .patient-phone-button, .admin-sign-in, .side-menu-row, .media-file, .customer-qr-link),
    .access-gate > a, .job-utility-actions > a, .leaflet-bar > a,
    label:is(.media-picker, .message-media-picker, .recurrence-switch),
    .customer-when-options label,
    .category-option > span, .accepted-flip-face,
    .sliding-toggle, .sliding-toggle-indicator,
    .location-sharing-knob, .side-menu-theme-preference > i
  ):not(:where(
    [class$="-backdrop"], [class*="-backdrop "], .job-map-preview-trigger, .collaborator-map-expand, .conversation-pencil, .service-preference-item, .collaborator-color-legend summary, .visit-date.is-available, .accepted-flip-button,
    [role="button"].leaflet-interactive, :focus-visible, .category-option > input:focus-visible + span
  )),
  html[data-dispatcher-background="galaxy"] .side-menu-theme-preference > i::after {
    box-shadow: var(--glass-bevel, var(--glass-edges)), var(--glass-accent, 0 0 0 transparent) !important;
  }

  html[data-dispatcher-background="galaxy"] :where(
    .create-job-button, .collaborator-invite-compact, .job-collaborators-button,
    .patient-phone-button, .delete-job-action, .delete-job-button,
    .job-swipe-actions > .is-delete, .message-swipe-actions > .is-delete,
    .customer-submit, .customer-success button
  ):not(:disabled) {
    --glass-pigment: var(--glass-red);
    --glass-accent: inset 0 0 6px rgb(255 139 177 / 50%);
  }

  html[data-dispatcher-background="galaxy"] :where(
    .directions-button, .job-swipe-actions > .is-navigate, .force-claim-action, .admin-force-claim-button
  ):not(:disabled) {
    --glass-pigment: var(--glass-green);
    --glass-accent: inset 0 0 6px rgb(109 255 195 / 46%);
  }

  html[data-dispatcher-background="galaxy"] :where(
    .edit-job-action, .job-swipe-actions > .is-edit
  ):not(:disabled) {
    --glass-pigment: var(--glass-amber);
    --glass-accent: inset 0 0 6px rgb(255 204 124 / 50%);
  }

  html[data-dispatcher-background="galaxy"] :where(
    .duplicate-job-button, .job-swipe-actions > .is-duplicate
  ):not(:disabled) {
    --glass-pigment: var(--glass-blue);
    --glass-accent: inset 0 0 6px rgb(142 202 255 / 55%);
  }

  html[data-dispatcher-background="galaxy"] :where(
    .view-mode-toggle, .list-content-tabs, .calendar-range-toggle,
    .calendar-all-filter
  ) {
    --glass-pigment: url("/glass/obsidian.webp?v=3");
  }

  html[data-dispatcher-background="galaxy"] .calendar-all-filter.is-active {
    --glass-pigment: var(--glass-reflections), linear-gradient(140deg, #503142, #24141e 65%, #593144);
  }

  html[data-dispatcher-background="galaxy"] .sliding-toggle > button:not(.is-active) {
    /* The shared dark track reads as one piece behind the moving selection. */
    --glass-corners: none;
    --glass-pigment: none;
    --glass-bevel: inset 0 0 0 transparent;
  }

  html[data-dispatcher-background="galaxy"] .sliding-toggle-indicator {
    --glass-corners: radial-gradient(ellipse 24px 6px at 10% 1px, #fffb, transparent);
    --glass-pigment: var(--glass-reflections);
  }

  html[data-dispatcher-background="galaxy"] .app-shell:not(.is-dark-mode) .sliding-toggle-indicator {
    --glass-pigment: url("/glass/pearl.webp?v=3");
  }

  html[data-dispatcher-background="galaxy"] .app-shell:not(.is-dark-mode) .mobile-bottom-nav-tabs :is(button, .accepted-flip-face) {
    --glass-pigment: url("/glass/pearl.webp?v=3");
  }

  html[data-dispatcher-background="galaxy"] .app-shell:not(.is-dark-mode) .mobile-bottom-nav-tabs :is(button, .accepted-flip-face).is-active {
    --glass-pigment: url("/glass/rose.webp?v=3");
  }

  html[data-dispatcher-background="galaxy"] .mobile-bottom-nav .accepted-flip-face {
    background-size: 100% 100%, calc(100% + 46% * (1 - cos(var(--surface-angle)))) 100% !important;
    background-position: center, calc(50% + 48% * var(--sweep)) center !important;
  }

  html[data-dispatcher-background="galaxy"] .app-shell.is-dark-mode .searchable-dropdown-menu .service-color-option {
    --glass-pigment: var(--glass-reflections), linear-gradient(90deg, rgba(var(--service-rgb), .23), #111926);
  }

  html[data-dispatcher-background="galaxy"] .conversation-action-menu button[aria-pressed="true"] {
    --glass-accent: inset 0 0 0 2px #9481d8;
  }

  /* Taller actions have room for a second inner edge. Their symbols have a
     separate rim so the surface reflection never crosses the glyph itself. */
  html[data-dispatcher-background="galaxy"] :where(
    .job-swipe-actions > :is(a, button), .message-swipe-actions > button,
    .job-utility-actions > :is(a, button), .directions-button,
    .create-job-button, .collaborator-invite-compact
  ) {
    --glass-bevel: var(--glass-deep-edges);
  }

  html[data-dispatcher-background="galaxy"] :where(
    .job-swipe-actions > :is(.is-edit, .is-navigate, .is-duplicate, .is-delete),
    .message-swipe-actions > :is(.is-edit, .is-delete)
  ) > span {
    background: linear-gradient(150deg, rgb(255 255 255 / 24%), rgb(255 255 255 / 4%) 55%, rgb(0 0 0 / 9%));
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / 56%), 0 1px 1px rgb(0 0 0 / 18%);
  }

  /* Compact ruby commands have a shallow reflection that clears the label. */
  html[data-dispatcher-background="galaxy"] :where(
    .create-job-button, .collaborator-invite-compact, .job-collaborators-button
  ):not(:disabled) {
    --glass-pigment: url("/glass/ruby-command.webp?v=3");
  }

  html[data-dispatcher-background="galaxy"] :where(
    .job-swipe-actions > :is(.is-edit, .is-navigate, .is-duplicate, .is-delete),
    .message-swipe-actions > :is(.is-edit, .is-delete)
  ) {
    --glass-corners:
      radial-gradient(ellipse 24px 10px at 3px 3px, #fff9, transparent),
      radial-gradient(ellipse 15px 28px at calc(100% - 2px) 98%, #fff5, transparent);
    text-shadow: 0 1px 2px rgb(31 11 26 / 65%);
  }

  /* The existing white rim still identifies the chosen map category. */
  html[data-dispatcher-background="galaxy"] .category-option > input:checked + span {
    --glass-accent: inset 0 0 0 3px #fff, 0 0 0 2px color-mix(in srgb, var(--category-color) 55%, #24354c);
  }

  html[data-dispatcher-background="galaxy"] :is(.plain-x-button, button[aria-label*="Κλείσιμο"], .modal-close) {
    background-image: none !important;
    box-shadow: none !important;
    border: 0 !important;
  }

}
}
