/* Keep the sticky bar outside page shells with overflow: hidden. */
body:has(> #cookie-consent) {
  overflow-x: clip;
}

#cookie-consent[hidden] {
  display: none;
}

#cookie-consent {
  position: sticky;
  inset: auto;
  bottom: 0;
  z-index: 1000;
  display: block;
  width: min(100%, 430px);
  container: cookie-bar / inline-size;
  margin: 0 auto;
  opacity: 0;
  transform: none;
  pointer-events: none;
  transition: opacity 180ms ease;
}

#cookie-consent.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

#cookie-consent .cookie-consent-panel {
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 12px;
  width: 100%;
  min-height: 76px;
  padding: 7px 12px max(8px, env(safe-area-inset-bottom));
  border: 0;
  border-top: 1px solid rgba(200, 164, 95, 0.5);
  border-radius: 0;
  background: #fffaf5;
  box-shadow: 0 -6px 24px rgba(15, 10, 16, 0.12);
  color: #2b2430;
  text-align: left;
  font-family: var(--font-ui, "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
}

#cookie-consent .cookie-consent-summary {
  grid-column: 1 / -1;
  margin: 0;
  color: inherit;
  font: 400 12px/1.35 var(--font-ui, "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
}

#cookie-consent .cookie-consent-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin: 0;
}

#cookie-consent .cookie-consent-actions button {
  box-sizing: border-box;
  min-width: 64px;
  min-height: 36px;
  margin: 0;
  padding: 0 13px;
  border-radius: 999px;
  box-shadow: none;
  cursor: pointer;
  font: 500 12px/1.2 var(--font-ui, "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
  white-space: nowrap;
}

#cookie-consent .cookie-consent-primary {
  border: 1px solid #914164;
  background: #914164;
  color: #fffaf5;
}

#cookie-consent .cookie-consent-secondary {
  border: 1px solid #9f824f;
  background: transparent;
  color: inherit;
}

#cookie-consent .cookie-consent-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  margin: 0;
}

#cookie-consent .cookie-consent-links button {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  min-height: 32px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #7a5520;
  cursor: pointer;
  font: 400 11px/1.3 var(--font-ui, "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

body.dark-plum-mobile #cookie-consent .cookie-consent-panel {
  background: #20121f;
  color: var(--ivory-primary, #f6efe8);
}

body.dark-plum-mobile #cookie-consent .cookie-consent-links button {
  color: var(--antique-gold, #c8a45f);
}

/* Preferences open in a separate modal sheet only after a settings click. */
html.has-cookie-preferences {
  overflow: hidden;
}

.cookie-preferences-sheet {
  box-sizing: border-box;
  position: fixed;
  inset: auto 0 0;
  width: min(100%, 480px);
  max-width: 100%;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  margin: auto auto 0;
  padding: 20px 20px max(20px, env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid #c8a45f;
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  background: #fffaf5;
  color: #2b2430;
  box-shadow: 0 -16px 48px rgba(4, 1, 5, 0.3);
  text-align: left;
  font-family: var(--font-ui, "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
}

.cookie-preferences-sheet:not([open]) {
  display: none;
}

.cookie-preferences-sheet::backdrop {
  background: rgba(8, 3, 9, 0.6);
}

.cookie-preferences-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.cookie-preferences-header h2 {
  margin: 0;
  color: inherit;
  font: 500 24px/1.2 var(--font-display, Georgia, serif);
  letter-spacing: 0;
}

.cookie-preferences-close {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(159, 130, 79, 0.5);
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: 400 26px/1 sans-serif;
}

.cookie-preferences-sheet > p {
  margin: 8px 0 0;
  color: inherit;
  font-size: 13px;
  line-height: 1.5;
}

.cookie-preferences-sheet .cookie-preferences {
  display: grid;
  gap: 16px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(159, 130, 79, 0.35);
}

.cookie-preferences-sheet .cookie-preferences label {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  min-height: 44px;
  color: inherit;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.4;
}

.cookie-preferences-sheet .cookie-preferences input {
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  accent-color: #914164;
}

.cookie-preferences-sheet .cookie-preferences strong {
  font-size: 13px;
  font-weight: 600;
}

.cookie-preferences-sheet .cookie-preferences small {
  display: block;
  margin-top: 3px;
  color: #756b7e;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
}

.cookie-preferences-necessary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 12px;
}

.cookie-preferences-necessary > span {
  color: #7a5520;
  font-size: 12px;
}

.cookie-preferences-necessary > small {
  grid-column: 1 / -1;
}

.cookie-preferences-sheet .cookie-consent-policy {
  justify-self: start;
  min-height: 24px;
  color: #7a5520;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.cookie-preferences-sheet [data-consent-save] {
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 10px 16px;
  border: 1px solid #914164;
  border-radius: 999px;
  background: #914164;
  color: #fffaf5;
  cursor: pointer;
  font: 600 13px/1.3 var(--font-ui, "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
}

body.dark-plum-mobile .cookie-preferences-sheet {
  background: #20121f;
  color: var(--ivory-primary, #f6efe8);
}

body.dark-plum-mobile .cookie-preferences-sheet .cookie-preferences small {
  color: var(--ivory-secondary, #d6c6ce);
}

body.dark-plum-mobile .cookie-preferences-sheet :is(.cookie-consent-policy, .cookie-preferences-necessary > span) {
  color: var(--antique-gold, #c8a45f);
}

#cookie-consent .cookie-consent-primary:hover,
.cookie-preferences-sheet [data-consent-save]:hover {
  background: #9b486d;
}

#cookie-consent button:focus-visible,
.cookie-preferences-sheet :is(button, a, input):focus-visible {
  outline: 2px solid #c8a45f;
  outline-offset: 3px;
}

@media (min-width: 768px) {
  #cookie-consent {
    width: min(calc(100% - 32px), 940px);
  }
}

@container cookie-bar (min-width: 640px) {
  #cookie-consent .cookie-consent-panel {
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 16px;
    min-height: 72px;
    padding: 14px 20px max(14px, env(safe-area-inset-bottom));
    border: 1px solid rgba(200, 164, 95, 0.5);
    border-bottom: 0;
    border-radius: 14px 14px 0 0;
  }

  #cookie-consent .cookie-consent-summary {
    grid-column: auto;
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #cookie-consent {
    transition: none;
  }
}
