/**
 * mod_dialognotice
 * Standardwerte nutzen Systemfarben (Canvas/CanvasText) und passen sich
 * damit hell/dunkel an. Eigene Farben kommen als Custom Properties per JS.
 */

.dialognotice {
  --dn-bg: Canvas;
  --dn-text: CanvasText;
  --dn-accent: #0b57d0;
  --dn-accent-text: #ffffff;
  --dn-badge-bg: #ffd43b;
  --dn-badge-text: #1a1a1a;
  --dn-radius: 12px;
  --dn-width: 32rem;

  inline-size: min(var(--dn-width), calc(100vw - 2rem));
  max-block-size: calc(100dvh - 2rem);
  padding: 0;
  border: 0;
  border-radius: var(--dn-radius);
  background: var(--dn-bg);
  color: var(--dn-text);
  box-shadow: 0 1.5rem 3rem rgb(0 0 0 / 0.25);
  overflow: auto;
  overscroll-behavior: contain;
}

.dialognotice::backdrop {
  background: rgb(0 0 0 / var(--dn-backdrop, 0.5));
}

.dialognotice__inner {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 2rem 1.5rem 1.5rem;
}

/* Schließen – Zielgröße 44 × 44 px (WCAG 2.5.5 / 2.5.8) */
.dialognotice__closeform {
  position: absolute;
  inset-block-start: 0.5rem;
  inset-inline-end: 0.5rem;
  margin: 0;
}

.dialognotice__close {
  display: grid;
  place-items: center;
  inline-size: 2.75rem;
  block-size: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.dialognotice__close:hover {
  background: color-mix(in srgb, currentColor 12%, transparent);
}

/* Fokus in Textfarbe – hat damit automatisch Kontrast zum Hintergrund */
.dialognotice :focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 2px;
}

/* Dialog selbst erhält Fokus nur programmatisch beim Öffnen (nicht in der Tab-Reihenfolge) */
.dialognotice:focus {
  outline: none;
}

/* Eigene Farbe erzwingen – Templates färben h2/h3 oft global ein.
   Doppelte Klasse für höhere Spezifität gegenüber Template-Regeln wie ".content h2" */
.dialognotice .dialognotice__title {
  color: var(--dn-heading, var(--dn-text));
  margin: 0;
  padding-inline-end: 2.5rem;
  font-size: 1.5rem;
  line-height: 1.25;
}

/* Badge visuell über der Überschrift, im DOM danach (Überschrift wird zuerst vorgelesen) */
.dialognotice__badge {
  order: -1;
  align-self: flex-start;
  margin: 0;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: var(--dn-badge-bg);
  color: var(--dn-badge-text);
  font-weight: 700;
  line-height: 1.4;
}

.dialognotice__content > :first-child { margin-block-start: 0; }
.dialognotice__content > :last-child  { margin-block-end: 0; }

.dialognotice .dialognotice__content :is(h2, h3, h4, h5, h6) {
  color: var(--dn-heading, var(--dn-text));
}

.dialognotice__content a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.dialognotice__coupon-label {
  margin: 0 0 0.5rem;
  font-weight: 600;
}

.dialognotice__coupon-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.dialognotice__code {
  padding: 0.5rem 0.75rem;
  border: 2px dashed currentColor;
  border-radius: calc(var(--dn-radius) / 2);
  background: transparent;
  color: inherit;
  font: 700 1.125rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.05em;
  user-select: all;
}

.dialognotice__status {
  min-block-size: 1.5em;
  margin: 0.5rem 0 0;
  font-size: 0.9375rem;
}

.dialognotice__copy,
.dialognotice__cta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-block-size: 2.75rem;
  padding: 0.625rem 1.25rem;
  border: 2px solid var(--dn-accent);
  border-radius: calc(var(--dn-radius) / 1.5);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

/* Doppelte Klasse: schlägt globale Template-Regeln wie a:hover / button:hover */
.dialognotice .dialognotice__copy {
  border-color: currentColor;
  background: transparent;
  color: var(--dn-text);
}

.dialognotice .dialognotice__copy:hover {
  background: color-mix(in oklab, var(--dn-text) 12%, transparent);
  color: var(--dn-text);
  text-decoration: underline;
}

.dialognotice .dialognotice__cta,
.dialognotice .dialognotice__cta:visited {
  align-self: flex-start;
  background: var(--dn-accent);
  color: var(--dn-accent-text);
}

/*
 * Hover: Hintergrund in OKLab wegmischen von der Schriftfarbe.
 * --dn-hover-mix setzt das JS: black bei heller Schrift, white bei dunkler.
 * Dadurch steigt der Kontrast beim Hover immer – er kann nie unter den Ruhezustand fallen.
 */
.dialognotice .dialognotice__cta:hover,
.dialognotice .dialognotice__cta:focus-visible {
  --dn-accent-hover: color-mix(in oklab, var(--dn-accent), var(--dn-hover-mix, black) 20%);
  background: var(--dn-accent-hover);
  border-color: var(--dn-accent-hover);
  color: var(--dn-accent-text);
  text-decoration: underline;
}

.dn-sr-only {
  position: absolute !important;
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Animation nur, wenn Bewegung nicht reduziert werden soll */
@media (prefers-reduced-motion: no-preference) {
  .dialognotice[open] { animation: dn-in 0.25s ease-out; }
  .dialognotice[open]::backdrop { animation: dn-fade 0.25s ease-out; }
}

@keyframes dn-in {
  from { opacity: 0; transform: translateY(1rem) scale(0.98); }
}

@keyframes dn-fade {
  from { opacity: 0; }
}

/* Windows-Kontrastmodus */
@media (forced-colors: active) {
  .dialognotice { border: 2px solid CanvasText; }
  .dialognotice__badge { border: 1px solid CanvasText; }
  .dialognotice__copy,
  .dialognotice__cta { border-color: ButtonText; }
}
