/* KoA Adventskalender. Alle Klassen tragen das Präfix koa-ak, damit nichts mit dem Theme kollidiert. */

.koa-ak {
  --koa-ak-rot: #e20613;
  --koa-ak-tinte: #1c1f2b;
  /* Ältere Türchen stehen angelehnt: die Klappe bleibt im Zwischenraum und verdeckt kein Nachbarbild.
     Das Türchen von heute schwingt ganz auf, seine Klappe mit Name und Text liegt über dem linken Nachbarn. */
  --koa-ak-winkel-alt: -100deg;
  --koa-ak-winkel-heute: -158deg;
  --koa-ak-tiefe: 900px;
  /* Der Abschnitt im Builder hat keinen eigenen Abstand, sonst bliebe ausserhalb der Adventszeit ein leeres Band stehen. */
  padding-block: clamp(36px, 6vw, 70px);
}
.koa-ak *,
.koa-ak *::before,
.koa-ak *::after { box-sizing: border-box; }
.koa-ak [hidden] { display: none !important; }

/* Titel und Einleitung: Schrift und Farbe kommen vom Theme (uk-h1, uk-text-lead), hier nur die Anordnung */
.koa-ak-intro {
  max-width: 720px;
  margin: 0 auto 32px;
  text-align: center;
}
.koa-ak .koa-ak-ueberschrift { margin: 0 0 12px; }
.koa-ak .koa-ak-einleitung { margin: 0; }

/* Bogen: volle Spaltenbreite, aber nie höher als das Sichtfeld */
.koa-ak-buehne {
  width: 100%;
  width: min(100%, max(320px, calc((100svh - 140px) * 1.4143)));
  margin-inline: auto;
}
.koa-ak-bogen {
  position: relative;
  isolation: isolate;
  container-type: inline-size;
  aspect-ratio: 297 / 210;
  background-color: #fff;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 26px 50px -18px rgba(0, 0, 0, .8);
}
/* Tiefenwirkung im Verhältnis zur Grösse des Bogens, damit die Klappen auf dem Handy gleich aussehen wie am Desktop */
@supports (width: 1cqw) {
  .koa-ak-bogen { --koa-ak-tiefe: 70cqw; }
}

/* Bilder erst laden, wenn der Kalender in die Nähe des Sichtfelds kommt (Klasse setzt das Skript) */
.koa-ak-geladen .koa-ak-bogen,
.koa-ak-geladen .koa-ak-vorn { background-image: var(--koa-ak-vorn); }
@media (max-width: 700px) {
  .koa-ak-geladen .koa-ak-bogen,
  .koa-ak-geladen .koa-ak-vorn { background-image: var(--koa-ak-vorn-klein); }
}
.koa-ak:not(.koa-ak-geladen) .koa-ak-loch,
.koa-ak:not(.koa-ak-geladen) .koa-ak-innen { background-image: none !important; }

/* Feld: ein Türchen samt Bild dahinter. Offene liegen über geschlossenen, das von heute über allen. */
.koa-ak-feld {
  position: absolute;
  z-index: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.koa-ak-feld.koa-ak-offen { z-index: 2; }
.koa-ak-feld.koa-ak-heute { z-index: 3; }
.koa-ak-feld:has(:focus-visible) { outline: 3px solid var(--koa-ak-rot); outline-offset: 2px; z-index: 4; }

.koa-ak-loch {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35), inset 3px 4px 10px rgba(0, 0, 0, .5);
}

/* Klappe: dreht um ihre linke Kante */
.koa-ak-tuer {
  position: absolute;
  inset: 0;
  transform-origin: 0 50%;
  transform-style: preserve-3d;
  transform: perspective(var(--koa-ak-tiefe)) rotateY(0deg);
  transition: transform .95s cubic-bezier(.25, .8, .25, 1);
}
.koa-ak-vorn,
.koa-ak-innen {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
/* Vorderseite: der eigentliche Knopf */
.koa-ak-vorn {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  background-size: 825% 583.333%;
  background-repeat: no-repeat;
  box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .22);
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
/* Innenseite: bei geschlossenem Türchen ganz ausgeblendet, damit sie auch dort nie gespiegelt
   durchscheint, wo backface-visibility nicht greift. */
.koa-ak-innen {
  transform: rotateY(180deg);
  background-size: cover;
  background-color: #fff;
  box-shadow: 0 0 0 .5px rgba(0, 0, 0, .18), 0 8px 18px rgba(0, 0, 0, .28);
  visibility: hidden;
}
.koa-ak-offen .koa-ak-innen { visibility: visible; }
/* Noch verschlossene Türchen haben kein Bild im Quelltext. Damit der Spalt beim Darüberfahren nicht weiss
   bleibt, liegt dahinter ein dunkles Fach. */
.koa-ak-feld:not(.koa-ak-frei)::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #0d0e13, #2b2e3b);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35), inset 3px 4px 10px rgba(0, 0, 0, .6);
  opacity: 0;
  transition: opacity .15s;
}
/* Darüberfahren: jedes geschlossene Türchen öffnet sich einen Spalt. Nur mit Maus, nicht auf Touch-Geräten. */
@media (hover: hover) {
  .koa-ak-feld:not(.koa-ak-offen) .koa-ak-tuer { transition-duration: .4s; }
  .koa-ak-feld:not(.koa-ak-offen):hover .koa-ak-tuer { transform: perspective(var(--koa-ak-tiefe)) rotateY(-34deg); }
  .koa-ak-feld:not(.koa-ak-offen):hover .koa-ak-vorn { box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .22), 6px 4px 12px rgba(0, 0, 0, .35); }
  .koa-ak-feld:not(.koa-ak-frei):hover::before { opacity: 1; }
}
.koa-ak-offen .koa-ak-tuer { transform: perspective(var(--koa-ak-tiefe)) rotateY(var(--koa-ak-winkel-alt)); }
.koa-ak-heute.koa-ak-offen .koa-ak-tuer { transform: perspective(var(--koa-ak-tiefe)) rotateY(var(--koa-ak-winkel-heute)); }

/* Karte: Portrait und Text gross, oder der Hinweis bei einem noch geschlossenen Türchen */
.koa-ak-dialog {
  width: min(680px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 0;
  background: transparent;
  overflow: auto;
  text-align: left;
}
.koa-ak-dialog.koa-ak-ohne-bild { width: min(440px, calc(100vw - 32px)); }
.koa-ak-dialog::backdrop { background: rgba(8, 8, 10, .74); }
/* Rückfall für Browser ohne showModal() */
.koa-ak-dialog.koa-ak-rueckfall {
  position: fixed;
  inset: 0;
  z-index: 100000;
  margin: auto;
  height: fit-content;
  box-shadow: 0 0 0 100vmax rgba(8, 8, 10, .74);
}
.koa-ak-karte {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .7);
}
.koa-ak-ohne-bild .koa-ak-karte { grid-template-columns: minmax(0, 1fr); }
.koa-ak-text {
  align-self: center;
  padding: 32px 28px;
}
.koa-ak-ohne-bild .koa-ak-text { padding-right: 56px; }
.koa-ak-portrait {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}
/* Farben mit !important: der Kalender steht in einem dunklen Abschnitt, dessen Regeln sonst helle Schrift erzwingen */
.koa-ak-dialog p {
  margin: 0;
  color: var(--koa-ak-tinte) !important;
  font-size: 18px;
  line-height: 1.45;
}
.koa-ak-dialog .koa-ak-kopf {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-right: 28px;
}
.koa-ak-nr {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--koa-ak-rot);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}
.koa-ak-titel {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
}
.koa-ak-dialog .koa-ak-info {
  margin-top: 18px;
  color: var(--koa-ak-rot) !important;
  font-size: 16px;
  font-weight: 500;
}
.koa-ak-dialog .koa-ak-satz { margin-top: 8px; }
.koa-ak-dialog .koa-ak-aktion { margin-top: 22px; }
.koa-ak-dialog a.koa-ak-knopf {
  display: inline-block;
  padding: 10px 22px;
  border-radius: 999px;
  background: var(--koa-ak-rot);
  color: #fff !important;
  font-size: 16px;
  font-weight: 500;
  text-decoration: none;
}
.koa-ak-dialog a.koa-ak-knopf:hover { background: #b9050f; }
.koa-ak-zu {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .92);
  color: var(--koa-ak-tinte);
  font: inherit;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
.koa-ak-zu:hover { background: #ececec; }
.koa-ak-zu:focus-visible,
.koa-ak-knopf:focus-visible { outline: 3px solid var(--koa-ak-tinte); outline-offset: 2px; }

@media (max-width: 560px) {
  .koa-ak-dialog { width: min(360px, calc(100vw - 32px)); }
  .koa-ak-karte { grid-template-columns: minmax(0, 1fr); }
  .koa-ak-portrait { order: -1; height: auto; }
  .koa-ak-text { padding: 22px 20px 24px; }
  .koa-ak-titel { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .koa-ak-tuer { transition-duration: .01s; }
}
