/* =========================================================
   Panel (SHARED: cookie-consent + a11y)
   ========================================================= */
/* Shared panel motion tokens (CSS custom properties) */
:root {
  --dt-panel-dur-in: 250ms;
  --dt-panel-dur-out: 250ms;
  --dt-panel-ease-in: ease-out;
  --dt-panel-ease-out: ease-in;
}

/* =========================================================
   Modal wrapper gating (SAFE: targets ONLY the fullscreen modals)
   - Does NOT touch the cookie banner (#dtcc-banner)
   - Ensures modals are inert when hidden (no click/scroll bleed)
   ========================================================= */
#dtcc-modal,
#a11yModal {
  position: fixed;
  inset: 0;
  z-index: 99999;
}

/* Hidden state: cookie modal uses [hidden] + aria-hidden; a11y will now too */
#dtcc-modal[hidden],
#a11yModal[hidden],
#dtcc-modal[aria-hidden=true],
#a11yModal[aria-hidden=true],
#dtcc-modal.cookie-consent--hidden,
#a11yModal.a11y--hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

/* Visible state */
#dtcc-modal[aria-hidden=false],
#a11yModal[aria-hidden=false] {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

/* Prevent a left-panel flash if wrapper becomes visible before state classes apply */
#dtcc-modal[aria-hidden=true] .panel-shell,
#a11yModal[aria-hidden=true] .panel-shell,
#dtcc-modal.cookie-consent--hidden .panel-shell,
#a11yModal.a11y--hidden .panel-shell {
  transform: translateX(-110%);
}

/* =========================================================
   Panel shell (unchanged)
   ========================================================= */
.panel-shell {
  border-radius: 12px;
  position: absolute;
  inset: 16px auto 16px 16px;
  width: min(92vw, 420px);
  max-width: 420px;
  height: calc(100dvh - 32px);
  height: calc(100svh - 32px);
  max-height: calc(100% - 32px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  overscroll-behavior: contain;
  touch-action: pan-y;
  will-change: transform;
  border-right: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05), 6px 0 24px rgba(0, 0, 0, 0.15);
}
.panel-shell p {
  font-size: 14px;
}
.panel-shell .panel-wrapper {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--g-spacing);
  padding: calc(var(--g-spacing) * 1.4);
  overflow: hidden;
}
.panel-shell .panel-header {
  flex: 0 0 auto;
}
.panel-shell .panel-header h2 {
  font-size: 19px;
  margin-bottom: 0;
}
.panel-shell .panel-intro {
  font-size: 14px;
  line-height: 1.5;
}
.panel-shell .panel-body {
  overflow-x: hidden;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  padding-right: 4px;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.panel-shell .panel-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-direction: column;
  flex: 0 0 auto;
  padding: 0;
}
.panel-shell .panel-footer button {
  font-size: 13px;
  background: transparent;
  color: var(--cc-muted-fg);
  border: 1px solid var(--cc-muted-border);
  border-radius: 500px;
  padding: 6px;
  transition: color 120ms ease, border-color 120ms ease, background-color 120ms ease;
}
.panel-shell .panel-footer button:hover,
.panel-shell .panel-footer button:focus-visible {
  color: currentColor;
  border-color: currentColor;
  background-color: color-mix(in srgb, currentColor 10%, transparent);
}
.panel-shell .panel-close {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0 !important;
  line-height: 1;
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 3;
  pointer-events: auto;
  -webkit-appearance: none;
  appearance: none;
  color: currentColor;
  transition: color 120ms ease, background-color 120ms ease;
}
.panel-shell .panel-close::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  box-shadow: inset 0 0 0 2px currentColor;
}
.panel-shell .panel-close:hover {
  background-color: color-mix(in srgb, currentColor 10%, transparent);
}
.panel-shell .panel-close:focus-visible {
  outline: none;
  background-color: color-mix(in srgb, currentColor 10%, transparent);
}
.panel-shell .panel-close:focus-visible::after {
  opacity: 1;
}

/* Optional: shared open/close micro-animations (match timing in JS) */
@keyframes panelFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes panelFadeOut {
  from {
    opacity: 1;
    transform: none;
  }
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}
/* Shared slide-in/out from left for panels (for cookie + a11y) */
@keyframes dt-slide-in-left {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}
@keyframes dt-slide-out-left {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-100%);
  }
}
/* Hook to existing state classes from each feature */
.cookie-consent--opening .panel-shell,
.a11y--opening .panel-shell {
  animation: panelFadeIn var(--dt-panel-dur-in) var(--dt-panel-ease-in) both;
}

.cookie-consent--closing .panel-shell,
.a11y--closing .panel-shell {
  animation: panelFadeOut var(--dt-panel-dur-out) var(--dt-panel-ease-out) both;
}



/* Panel controls: stable baseline that still works with a11y preference overrides. */
.panel-shell .panel-footer .panel-btn,
.panel-shell .panel-footer button {
  min-height: 44px;
}

.panel-shell .panel-close {
  min-width: 44px;
  min-height: 44px;
}

.panel-shell .panel-footer .panel-btn:focus-visible,
.panel-shell .panel-footer button:focus-visible {
  outline: var(--outline-size, 3px) var(--outline-style, solid) var(--outline-color, currentColor);
  outline-offset: var(--outline-offset, 4px);
  box-shadow: none;
}

.panel-shell .panel-close:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 var(--outline-size, 3px) var(--outline-color, currentColor);
}

.panel-shell .panel-close:focus-visible::after {
  opacity: 0;
}

.panel-option {
  border: 1px solid var(--clr-border);
  padding: 11px;
  border-radius: 11px;
  margin: 0;
}
.panel-option .desc {
  font-size: 13px;
  line-height: 1.4;
}

.panel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.option-control {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* === Global panel switches (compatible with cookie-consent) ============ */
.panel-switch {
  display: inline-flex;
  align-items: flex-start;
  gap: 11px;
  cursor: pointer;
}
.panel-switch input[type=checkbox] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.panel-switch span {
  display: block;
}
.panel-switch .panel-switch__slider {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #cfd6dd;
  position: relative;
  display: inline-block;
  transition: background 0.18s ease;
}
.panel-switch .panel-switch__slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}
.panel-switch input[type=checkbox]:checked + .panel-switch__slider {
  background: #88c0ff;
}
.panel-switch input[type=checkbox]:checked + .panel-switch__slider::after {
  transform: translateX(20px);
}
.panel-switch input[type=checkbox]:disabled + .panel-switch__slider {
  background: #a9b1b9;
  opacity: 0.7;
}
.panel-switch input[type=checkbox]:focus-visible + .panel-switch__slider {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}
.panel-switch .panel-switch__label {
  font-weight: 600;
}

@media (max-width: 480px) {
  .panel-shell {
    inset: 0;
    width: 100vw;
    max-width: none;
    height: 100dvh;
    height: 100svh;
    max-height: none;
    border-radius: 0;
  }
}
