/*
 * Dmx4allAdventCalendar - Storefront-Styles
 *
 * Wird als fertige Datei ausgeliefert, kein SCSS und kein Theme-Build.
 * Die Farben kommen als CSS-Variablen vom Container und lassen sich in den
 * Plugin-Einstellungen ueberschreiben.
 */
.dmx4all-advent-calendar {
    --dmx4all-ac-accent: #b3121b;
    --dmx4all-ac-accent-dark: #7d0d13;
    --dmx4all-ac-text: #fff;
    /* Wird vom Container ueberschrieben, sobald in den Einstellungen etwas
       anderes steht. Die Werte hier sind der Auslieferungszustand. */
    --dmx4all-ac-duration: 550ms;
    --dmx4all-ac-origin: left center;
    --dmx4all-ac-open: rotateY(-105deg);
    --dmx4all-ac-hover: rotateY(-14deg);
    position: relative;
    padding: 24px;
    border-radius: 8px;
    background-size: cover;
    background-position: center;
}

.dmx4all-advent-calendar--green {
    --dmx4all-ac-accent: #1c6b3c;
    --dmx4all-ac-accent-dark: #11492a;
}

.dmx4all-advent-calendar--blue {
    --dmx4all-ac-accent: #1b4f8a;
    --dmx4all-ac-accent-dark: #123663;
}

.dmx4all-advent-calendar__headline {
    text-align: center;
    margin-bottom: 16px;
    color: var(--dmx4all-ac-headline, inherit);
}

/* Einleitung und Hinweise folgen der Ueberschriftfarbe, damit sie auf einem
   Hintergrundbild nicht in der Theme-Schriftfarbe untergehen. */
.dmx4all-advent-calendar__intro {
    margin: 0 auto 20px;
    max-width: 70ch;
    text-align: center;
    color: var(--dmx4all-ac-headline, inherit);
}

.dmx4all-advent-calendar__intro :last-child {
    margin-bottom: 0;
}

.dmx4all-advent-calendar__hint {
    text-align: center;
    font-size: 14px;
    opacity: .85;
    color: var(--dmx4all-ac-headline, inherit);
}

.dmx4all-advent-calendar__grid {
    display: grid;
    grid-template-columns: repeat(var(--dmx4all-ac-columns, 6), 1fr);
    gap: 12px;
}

@media (max-width: 767px) {
    .dmx4all-advent-calendar__grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .dmx4all-advent-calendar__grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Der Button ist nur noch der Rahmen und die Flaeche HINTER der Klappe.
   perspective sorgt dafuer, dass die aufschwingende Klappe raeumlich wirkt
   statt flach zu kippen. */
.dmx4all-advent-calendar__door {
    position: relative;
    aspect-ratio: 1 / 1;
    padding: 0;
    border: 2px solid var(--dmx4all-ac-accent-dark);
    border-radius: 6px;
    background-color: var(--dmx4all-ac-accent-dark);
    color: var(--dmx4all-ac-text);
    cursor: pointer;
    perspective: 700px;
    transition: filter .15s ease;
}

/* Die Klappe deckt den Rahmen mit ab, deshalb -2px. Sie dreht um die linke
   Kante; backface-visibility haelt die Rueckseite waehrend der Drehung
   unsichtbar. */
.dmx4all-advent-calendar__flap {
    position: absolute;
    inset: -2px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--dmx4all-ac-accent-dark);
    border-radius: 6px;
    background-color: var(--dmx4all-ac-accent);
    background-size: cover;
    background-position: center;
    /* Beim Zuschnitt aus dem Hintergrundbild wird die Groesse in Pixeln
       gesetzt - ohne dies wuerde das Bild dann kacheln. */
    background-repeat: no-repeat;
    transform-origin: var(--dmx4all-ac-origin);
    backface-visibility: hidden;
    transition: transform var(--dmx4all-ac-duration) cubic-bezier(.2, .8, .3, 1),
                box-shadow var(--dmx4all-ac-duration) ease;
    will-change: transform;
}

/* Beim Ueberfahren lupft die Klappe nur an - der Hinweis, dass sich hier
   etwas oeffnen laesst. Bereits geoeffnete Tuerchen sind ausgenommen: sonst
   zieht diese Regel die offene Klappe wieder zu, weil sie spezifischer ist
   als die Regel fuer den offenen Zustand. */
.dmx4all-advent-calendar__door.is-openable:not(.is-opened):not(.is-opening):hover .dmx4all-advent-calendar__flap {
    transform: var(--dmx4all-ac-hover);
    box-shadow: 6px 0 18px rgba(0, 0, 0, .25);
}

/* Waehrend und nach dem Oeffnen steht die Klappe fast senkrecht. z-index
   hebt das Tuerchen ueber seine Nachbarn, sonst schneidet die Klappe an. */
.dmx4all-advent-calendar__door.is-opening,
.dmx4all-advent-calendar__door.is-opened {
    z-index: 2;
}

/* Die Klappe eines geoeffneten Tuerchens bleibt stehen, wo sie ist. Der
   Rueckfallwert greift, falls die Variable am Container fehlt - offen ist
   hier wichtiger als die eingestellte Drehrichtung. */
.dmx4all-advent-calendar__door.is-opening .dmx4all-advent-calendar__flap,
.dmx4all-advent-calendar__door.is-opened .dmx4all-advent-calendar__flap {
    transform: var(--dmx4all-ac-open, rotateY(-105deg));
    box-shadow: 10px 0 24px rgba(0, 0, 0, .3);
}

.dmx4all-advent-calendar__door:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 2px;
}

.dmx4all-advent-calendar__door:not(.is-openable) {
    cursor: not-allowed;
    filter: grayscale(.6) brightness(.8);
}

/* Ein Tuerchen, das fertig geoeffnet ist, bekommt is-settled. Danach gibt es
   fuer seine Klappe keine Uebergaenge mehr - egal was sonst an Klassen
   wechselt, sie bleibt stehen, wo sie steht. */
.dmx4all-advent-calendar__door.is-settled .dmx4all-advent-calendar__flap {
    transition: none;
}

/* Ruettelt kurz, wenn ein Tuerchen noch nicht dran ist. */
@keyframes dmx4all-ac-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(2px); }
}

.dmx4all-advent-calendar__door.is-locked {
    animation: dmx4all-ac-shake .4s ease;
}

.dmx4all-advent-calendar__door.is-opened {
    filter: none;
    border-style: dashed;
}

.dmx4all-advent-calendar__door.is-opened::after {
    content: '\2713';
    position: absolute;
    right: 6px;
    top: 4px;
    font-size: 14px;
    z-index: 1;
}

.dmx4all-advent-calendar__day {
    font-size: clamp(18px, 3vw, 32px);
    font-weight: 700;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}

/* Liegt unter der Klappe und kommt beim Oeffnen zum Vorschein. */
.dmx4all-advent-calendar__reveal {
    position: absolute;
    inset: 0;
    border-radius: 4px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Auf einem Bild braucht die Ziffer mehr Halt als auf der einfarbigen
   Flaeche, sonst verschwindet sie in hellen Motiven. */
.dmx4all-advent-calendar__door:has(.dmx4all-advent-calendar__reveal) .dmx4all-advent-calendar__day--behind {
    opacity: 1;
    text-shadow: 0 1px 4px rgba(0, 0, 0, .85);
}

.dmx4all-advent-calendar__day--behind {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: .5;
}

@keyframes dmx4all-ac-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes dmx4all-ac-pop {
    from { opacity: 0; transform: translateY(12px) scale(.96); }
    to { opacity: 1; transform: none; }
}

.dmx4all-advent-calendar__overlay {
    animation: dmx4all-ac-fade .2s ease;
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .6);
    padding: 16px;
}

.dmx4all-advent-calendar__overlay[hidden] {
    display: none;
}

.dmx4all-advent-calendar__dialog {
    animation: dmx4all-ac-pop .28s cubic-bezier(.2, .8, .3, 1);
    position: relative;
    background: #fff;
    color: #333;
    border-radius: 8px;
    padding: 32px 24px 24px;
    max-width: 520px;
    width: 100%;
    max-height: 85vh;
    overflow: auto;
}

.dmx4all-advent-calendar__close {
    position: absolute;
    right: 8px;
    top: 4px;
    border: 0;
    background: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

.dmx4all-advent-calendar__title {
    margin-bottom: 12px;
}

.dmx4all-advent-calendar__image {
    max-width: 100%;
    height: auto;
    margin-bottom: 12px;
}

.dmx4all-advent-calendar__image[hidden] {
    display: none;
}

.dmx4all-advent-calendar__link[hidden] {
    display: none;
}

/* Wer im Betriebssystem weniger Bewegung eingestellt hat, bekommt denselben
   Ablauf ohne Animation - das Tuerchen ist danach genauso offen. */
@media (prefers-reduced-motion: reduce) {
    .dmx4all-advent-calendar__flap {
        transition: none;
    }

    .dmx4all-advent-calendar__door.is-locked,
    .dmx4all-advent-calendar__overlay,
    .dmx4all-advent-calendar__dialog {
        animation: none;
    }
}
