/**
 * Öffnungszeiten-Modul
 * (C) 2026 BACHMAIER IT Solutions GmbH & Co. KG – GNU GPL v2 or later
 *
 * Alle Farben sind CSS-Variablen und lassen sich im Template überschreiben, z. B.
 *   .oez { --oez-open: #0a7d32; --oez-accent: #c00; }
 *
 * Farbschemata (Moduloption):
 *   inherit – übernimmt Schrift-/Hintergrundfarben des Templates (inkl. dessen Dark Mode)
 *   light   – helle Karte          dark – dunkle Karte          auto – folgt der Systemeinstellung
 */

/* ------------------------------------------------------------------ Variablen */
.oez {
  --oez-open: #1a7f37;
  --oez-soon: #b35900;
  --oez-closed: #c62828;
  --oez-accent: currentColor;
  --oez-fg: inherit;
  --oez-bg: transparent;
  --oez-surface: var(--bs-body-bg, #fff);
  --oez-surface-fg: var(--bs-body-color, #1f2328);
  --oez-muted: color-mix(in srgb, currentColor 62%, transparent);
  --oez-line: color-mix(in srgb, currentColor 14%, transparent);
  --oez-today-bg: color-mix(in srgb, currentColor 7%, transparent);
  --oez-shadow: 0 10px 40px rgb(0 0 0 / .18), 0 2px 6px rgb(0 0 0 / .08);
  --oez-radius: .5rem;
  line-height: 1.5;
  color: var(--oez-fg);
}

.oez--scheme-light,
.oez--scheme-auto {
  --oez-fg: #1f2328;
  --oez-bg: #fff;
  --oez-surface: #fff;
  --oez-surface-fg: #1f2328;
  --oez-line: #e3e6ea;
  --oez-muted: #5c6670;
  --oez-today-bg: #f1f4f8;
}

.oez--scheme-dark {
  --oez-open: #4cc764;
  --oez-soon: #f0b23e;
  --oez-closed: #ff7369;
  --oez-fg: #e6edf3;
  --oez-bg: #1c2128;
  --oez-surface: #1c2128;
  --oez-surface-fg: #e6edf3;
  --oez-line: #30363d;
  --oez-muted: #9aa5b1;
  --oez-today-bg: #262d36;
  --oez-shadow: 0 10px 40px rgb(0 0 0 / .55);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  .oez--scheme-auto {
    --oez-open: #4cc764;
    --oez-soon: #f0b23e;
    --oez-closed: #ff7369;
    --oez-fg: #e6edf3;
    --oez-bg: #1c2128;
    --oez-surface: #1c2128;
    --oez-surface-fg: #e6edf3;
    --oez-line: #30363d;
    --oez-muted: #9aa5b1;
    --oez-today-bg: #262d36;
    --oez-shadow: 0 10px 40px rgb(0 0 0 / .55);
    color-scheme: dark;
  }
}

/* Template im Dark Mode (Cassiopeia/Bootstrap: data-bs-theme="dark"), Schema „inherit“ */
[data-bs-theme="dark"] .oez--scheme-inherit {
  --oez-open: #4cc764;
  --oez-soon: #f0b23e;
  --oez-closed: #ff7369;
}

/* Eigene Karte bei festem Farbschema (nicht bei Statuszeile und schwebendem Button) */
.oez--mode-inline:not(.oez--scheme-inherit) .oez__card {
  padding: 1rem 1.25rem;
  background: var(--oez-bg);
  border: 1px solid var(--oez-line);
  border-radius: var(--oez-radius);
}

.oez--mode-line:not(.oez--scheme-inherit) .oez__line,
.oez--mode-popup:not(.oez--scheme-inherit) .oez__line {
  padding: .45rem .9rem;
  background: var(--oez-bg);
  border: 1px solid var(--oez-line);
  border-radius: var(--oez-radius);
}

/* ------------------------------------------------------------------ Status */
.oez__status-row { margin: 0 0 .75rem; }

.oez__status {
  display: inline-flex;
  align-items: center;
  gap: .5em;
  font-weight: 600;
  color: var(--oez-closed);
}

.oez__status--open { color: var(--oez-open); }
.oez__status--soon { color: var(--oez-soon); }

.oez__dot {
  flex: none;
  width: .6em;
  height: .6em;
  border-radius: 50%;
  background: currentColor;
}

.oez__status--open .oez__dot {
  box-shadow: 0 0 0 .22em color-mix(in srgb, var(--oez-open) 25%, transparent);
  animation: oez-pulse 2.4s ease-in-out infinite;
}

@keyframes oez-pulse {
  50% { box-shadow: 0 0 0 .4em color-mix(in srgb, var(--oez-open) 0%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  .oez__status--open .oez__dot { animation: none; }
}

/* ------------------------------------------------------------------ Eine Zeile */
.oez__line {
  /* normaler Textfluss: bricht in schmalen Spalten sauber um */
  display: inline-block;
  max-width: 100%;
  margin: 0;
}

.oez__line > * { margin-inline-end: .35rem; }
.oez__line > :last-child { margin-inline-end: 0; }

.oez__prefix { font-weight: 600; }
.oez__sep { color: var(--oez-muted); }
.oez__today { color: var(--oez-muted); font-variant-numeric: tabular-nums; }

.oez__link {
  padding: 0;
  font: inherit;
  color: var(--oez-accent);
  text-decoration: underline;
  text-underline-offset: .2em;
  cursor: pointer;
  background: none;
  border: 0;
}

.oez__link:hover,
.oez__link:focus-visible { text-decoration-thickness: 2px; }

/* ------------------------------------------------------------------ Tabelle */
.oez__address {
  margin: 0 0 .75rem;
  font-style: normal;
}

.oez__table {
  width: 100%;
  margin: 0;
  color: inherit;
  border-collapse: collapse;
}

.oez__table th,
.oez__table td {
  padding: .35rem .5rem;
  color: inherit;
  text-align: start;
  vertical-align: top;
  background: none;
  border-bottom: 1px solid var(--oez-line);
}

.oez__table tr:last-child th,
.oez__table tr:last-child td { border-bottom: 0; }

.oez__day {
  width: 1%;
  padding-inline-start: 0;
  font-weight: 500;
  white-space: nowrap;
}

.oez__hours {
  padding-inline-end: 0;
  font-variant-numeric: tabular-nums;
  text-align: end !important;
}

.oez__closed { color: var(--oez-muted); }
.oez__slot { white-space: nowrap; }

.oez--highlight .is-today > * {
  font-weight: 700;
  background: var(--oez-today-bg) !important;
}

.oez--highlight .is-today > th { padding-inline-start: .5rem; border-start-start-radius: .375rem; border-end-start-radius: .375rem; }
.oez--highlight .is-today > td { padding-inline-end: .5rem; border-start-end-radius: .375rem; border-end-end-radius: .375rem; }

.oez__special-label {
  display: block;
  font-size: .8em;
  font-weight: 400;
  color: var(--oez-soon);
}

/* ------------------------------------------------------------------ Sonderzeiten */
.oez__specials { margin-top: 1rem; }

.oez__subtitle {
  margin: 0 0 .35rem;
  font-weight: 600;
}

.oez__special-list {
  padding: 0;
  margin: 0;
  list-style: none;
}

.oez__special-list li {
  display: flex;
  gap: .25rem 1rem;
  align-items: baseline;
  justify-content: space-between;
  padding: .35rem 0;
  border-bottom: 1px solid var(--oez-line);
}

.oez__special-list li:last-child { border-bottom: 0; }
.oez__special-info { display: flex; flex-direction: column; }
.oez__special-date { font-weight: 500; font-variant-numeric: tabular-nums; }
.oez__special-title { font-size: .9em; color: var(--oez-muted); }
.oez__special-hours { font-variant-numeric: tabular-nums; text-align: end; white-space: nowrap; }

.oez__note {
  margin: .75rem 0 0;
  font-size: .9em;
  color: var(--oez-muted);
}

.oez--today .oez__table th,
.oez--today .oez__table td { border-bottom: 0; }

/* ------------------------------------------------------------------ Schwebender Button */
.oez__fab {
  position: fixed;
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 1030;
  display: inline-flex;
  align-items: center;
  max-width: calc(100vw - 2rem);
  padding: .6rem 1rem;
  font: inherit;
  font-size: .95rem;
  cursor: pointer;
  background: var(--oez-surface);
  border: 1px solid var(--oez-line);
  border-radius: 999px;
  box-shadow: var(--oez-shadow);
  transition: transform .15s ease;
}

.oez__fab:hover { transform: translateY(-2px); }
.oez__fab--right { right: max(1rem, env(safe-area-inset-right)); }
.oez__fab--left { left: max(1rem, env(safe-area-inset-left)); }

/* ------------------------------------------------------------------ Pop-up */
.oez__dialog {
  width: min(32rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: 1.25rem 1.5rem 1.5rem;
  overflow: auto;
  color: var(--oez-surface-fg);
  background: var(--oez-surface);
  border: 1px solid var(--oez-line);
  border-radius: calc(var(--oez-radius) * 1.5);
  box-shadow: var(--oez-shadow);
}

.oez__dialog::backdrop {
  background: rgb(10 14 20 / .5);
  backdrop-filter: blur(2px);
}

.oez__dialog[open] { animation: oez-in .18s ease-out; }

@keyframes oez-in {
  from { opacity: 0; transform: translateY(.5rem) scale(.98); }
}

@media (prefers-reduced-motion: reduce) {
  .oez__dialog[open] { animation: none; }
}

.oez__dialog-head {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .5rem;
}

.oez__dialog-title {
  margin: 0;
  font-size: 1.35rem;
  color: inherit;
}

.oez__close {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  font-size: 1.5rem;
  line-height: 1;
  color: inherit;
  cursor: pointer;
  background: var(--oez-today-bg);
  border: 0;
  border-radius: 50%;
}

.oez__close:hover,
.oez__close:focus-visible { background: var(--oez-line); }

/* ------------------------------------------------------------------ Urlaub & Notfall (1.2) */
.oez [hidden] { display: none !important; }

.oez__status--vacation { color: var(--oez-vacation, var(--oez-soon)); }

.oez__vacation,
.oez__emergency {
  display: flex;
  gap: .65rem;
  align-items: flex-start;
  padding: .65rem .85rem;
  margin: 0 0 .85rem;
  font-size: .95em;
  border-radius: var(--oez-radius);
}

.oez__vacation {
  background: color-mix(in srgb, var(--oez-soon) 12%, transparent);
  border-inline-start: 3px solid var(--oez-soon);
}

.oez__vacation.is-active {
  background: color-mix(in srgb, var(--oez-closed) 10%, transparent);
  border-inline-start-color: var(--oez-closed);
}

.oez__emergency {
  margin: .85rem 0 0;
  background: color-mix(in srgb, var(--oez-closed) 9%, transparent);
  border-inline-start: 3px solid var(--oez-closed);
}

.oez__vacation-icon,
.oez__emergency-icon {
  flex: none;
  font-size: 1.1em;
  line-height: 1.35;
}

.oez__emergency-icon { color: var(--oez-closed); }
.oez__vacation-title { font-weight: 600; }
.oez__vacation-note,
.oez__emergency-note { margin-top: .15rem; color: var(--oez-muted); }

.oez__emergency-contact a,
.oez__emergency--inline a {
  font-weight: 600;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: .2em;
}

.oez__emergency-phone { white-space: nowrap; }
.oez__emergency--inline .oez__emergency-label { font-weight: 600; }
.oez__vacation-short { font-weight: 600; color: var(--oez-soon); }

/* Notfallkontakt innerhalb der Statuszeile: kein Kasten, normaler Textfluss */
.oez__emergency.oez__emergency--inline {
  display: inline;
  padding: 0;
  margin: 0;
  font-size: inherit;
  background: none;
  border: 0;
  border-radius: 0;
}

.oez__emergency a { overflow-wrap: anywhere; }

/* ================================================================== Hervorhebung (1.3)
 * Effekte (kombinierbar): glow · gradient · float · shine · border
 * Ziel: .oez__fx-target (Karte, Statuszeile oder schwebender Button)
 * Aktiv nur mit .is-fx-active (immer / nur geöffnet / nur geschlossen – schaltet live per JS)
 */
.oez {
  --oez-fx-k: 1;                 /* Stärke */
  --oez-fx-dur: 2.6s;            /* Grundtempo */
  --oez-fx-status: var(--oez-closed);
  --oez-fx-a: var(--oez-fx-1, var(--oez-fx-status));
  --oez-fx-b: var(--oez-fx-2, #2f6fde);
  --oez-fx-c: var(--oez-fx-3, #8a3ffc);
}

.oez[data-oez-state="open"] { --oez-fx-status: var(--oez-open); }
.oez[data-oez-state="soon"] { --oez-fx-status: var(--oez-soon); }

.oez--fx-subtle { --oez-fx-k: .55; }
.oez--fx-strong { --oez-fx-k: 1.6; }
.oez--fx-speed-slow { --oez-fx-dur: 4.2s; }
.oez--fx-speed-fast { --oez-fx-dur: 1.5s; }

/* Effektziele brauchen Innenabstand und Rundung, auch beim Schema „vom Template“ */
.oez--fx .oez__fx-target {
  isolation: isolate;
  border-radius: var(--oez-radius);
}

/* Bezugsrahmen für Glanzlicht/Leuchtrahmen – der schwebende Button bleibt „fixed“ */
.oez--fx .oez__fx-target:not(.oez__fab) { position: relative; }

.oez--fx.oez--mode-inline .oez__card { padding: 1rem 1.25rem; }
.oez--fx .oez__line { padding: .45rem .9rem; }
.oez--fx .oez__fab { border-radius: 999px; }

/* 1) Glühen – pulsierender Lichtschein in der Statusfarbe (grün = offen, rot = zu) */
.oez--fx-glow.is-fx-active .oez__fx-target {
  animation: oez-glow var(--oez-fx-dur) ease-in-out infinite;
}

@keyframes oez-glow {
  0%, 100% { box-shadow: 0 0 calc(4px * var(--oez-fx-k)) calc(1px * var(--oez-fx-k)) color-mix(in srgb, var(--oez-fx-a) 35%, transparent); }
  50%      { box-shadow: 0 0 calc(22px * var(--oez-fx-k)) calc(6px * var(--oez-fx-k)) color-mix(in srgb, var(--oez-fx-a) 70%, transparent); }
}

/* 2) Animierter Farbverlauf – Hintergrund wandert langsam durch die Effektfarben */
.oez--fx-gradient.is-fx-active .oez__fx-target {
  color: #fff;
  background: linear-gradient(120deg, var(--oez-fx-a), var(--oez-fx-b), var(--oez-fx-c), var(--oez-fx-a));
  background-size: 300% 300%;
  border-color: transparent;
  animation: oez-gradient calc(var(--oez-fx-dur) * 3) ease infinite;
}

.oez--fx-gradient.is-fx-active .oez__fx-target :is(.oez__status, .oez__today, .oez__sep, .oez__closed, .oez__muted,
  .oez__special-title, .oez__note, .oez__vacation-short, .oez__link, .oez__special-label, .oez__emergency-icon) {
  color: inherit;
}

.oez--fx-gradient.is-fx-active .oez__fx-target :is(.oez__table th, .oez__table td) { border-color: rgb(255 255 255 / .25); }
.oez--fx-gradient.is-fx-active .oez__fx-target .oez__dot { background: #fff; }
.oez--fx-gradient.is-fx-active .oez__fx-target { text-shadow: 0 1px 2px rgb(0 0 0 / .25); }
.oez--fx-gradient.is-fx-active .oez__fx-target :is(.oez__vacation, .oez__emergency) { background: rgb(0 0 0 / .18); border-color: #fff; }
.oez--fx-gradient.is-fx-active.oez--highlight .oez__fx-target .is-today > * { background: rgb(255 255 255 / .16) !important; }

@keyframes oez-gradient {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

/* 3) Bewegung – sanftes Schweben (der schwebende Button „hüpft“ zusätzlich leicht) */
.oez--fx-float.is-fx-active .oez__fx-target {
  animation: oez-float calc(var(--oez-fx-dur) * 1.2) ease-in-out infinite;
}

.oez--fx-float.is-fx-active .oez__fab { animation-name: oez-hop; }

/* Kombination Glühen + Bewegung */
.oez--fx-glow.oez--fx-float.is-fx-active .oez__fx-target {
  animation: oez-glow var(--oez-fx-dur) ease-in-out infinite, oez-float calc(var(--oez-fx-dur) * 1.2) ease-in-out infinite;
}

.oez--fx-gradient.oez--fx-float.is-fx-active .oez__fx-target {
  animation: oez-gradient calc(var(--oez-fx-dur) * 3) ease infinite, oez-float calc(var(--oez-fx-dur) * 1.2) ease-in-out infinite;
}

.oez--fx-glow.oez--fx-gradient.is-fx-active .oez__fx-target {
  animation: oez-glow var(--oez-fx-dur) ease-in-out infinite, oez-gradient calc(var(--oez-fx-dur) * 3) ease infinite;
}

.oez--fx-glow.oez--fx-gradient.oez--fx-float.is-fx-active .oez__fx-target {
  animation: oez-glow var(--oez-fx-dur) ease-in-out infinite, oez-gradient calc(var(--oez-fx-dur) * 3) ease infinite,
    oez-float calc(var(--oez-fx-dur) * 1.2) ease-in-out infinite;
}

@keyframes oez-float {
  0%, 100% { translate: 0 0; }
  50%      { translate: 0 calc(-5px * var(--oez-fx-k)); }
}

@keyframes oez-hop {
  0%, 70%, 100% { translate: 0 0; }
  78%           { translate: 0 calc(-10px * var(--oez-fx-k)); }
  86%           { translate: 0 0; }
  92%           { translate: 0 calc(-4px * var(--oez-fx-k)); }
}

/* 4) Vorschlag: Glanzlicht – ein Lichtreflex wandert regelmäßig über das Element */
.oez--fx-shine .oez__fx-target { overflow: hidden; }

.oez--fx-shine.is-fx-active .oez__fx-target::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  content: "";
  background: linear-gradient(105deg, transparent 35%, rgb(255 255 255 / calc(.32 * var(--oez-fx-k))) 50%, transparent 65%);
  background-size: 250% 100%;
  animation: oez-shine calc(var(--oez-fx-dur) * 2) ease-in-out infinite;
}

@keyframes oez-shine {
  0%       { background-position: 150% 0; }
  45%, 100% { background-position: -100% 0; }
}

/* 5) Vorschlag: Leuchtrahmen – ein Farbverlauf läuft als Rahmen um das Element */
@property --oez-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

.oez--fx-border.is-fx-active .oez__fx-target::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  padding: calc(2px * var(--oez-fx-k) + 1px);
  pointer-events: none;
  content: "";
  background: conic-gradient(from var(--oez-angle), var(--oez-fx-a), var(--oez-fx-b), var(--oez-fx-c), var(--oez-fx-a));
  border-radius: inherit;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: oez-spin calc(var(--oez-fx-dur) * 1.6) linear infinite;
}

@keyframes oez-spin {
  to { --oez-angle: 360deg; }
}

/* Barrierefreiheit: Bei „Bewegung reduzieren“ bleiben die Effekte sichtbar, aber unbewegt */
@media (prefers-reduced-motion: reduce) {
  .oez--fx .oez__fx-target,
  .oez--fx .oez__fx-target::before,
  .oez--fx .oez__fx-target::after {
    animation: none !important;
    translate: none !important;
  }

  .oez--fx-glow.is-fx-active .oez__fx-target {
    box-shadow: 0 0 calc(14px * var(--oez-fx-k)) calc(3px * var(--oez-fx-k)) color-mix(in srgb, var(--oez-fx-a) 55%, transparent);
  }

  .oez--fx-shine.is-fx-active .oez__fx-target::after { display: none; }
}

/* Farbschema „Eigene Farben“: abgeleitete Töne */
.oez--scheme-custom {
  --oez-muted: color-mix(in srgb, var(--oez-fg, currentColor) 62%, transparent);
  --oez-today-bg: color-mix(in srgb, var(--oez-fg, currentColor) 8%, transparent);
}
