/*
 * Adventskalender (OH-2).
 * Wendeanimation wie bei den Methodenkarten (_osmethodenkarten.scss: perspective
 * 1000px, transform 0.8s). Das Seitenverhältnis der Karten kommt ausschließlich
 * aus --advent-card-aspect, das adventskalender.js aus data-aspect-ratio setzt –
 * ein Motivtausch in anderem Format braucht also keine CSS-Änderung.
 */

.advent {
  --advent-columns: 3;
  --advent-gap: 8px;
  --advent-radius: 6px;
  --advent-flip-duration: .8s;
  --advent-flip-easing: ease;
  --advent-shadow: 0 2px 6px rgba(0, 0, 0, .2);
  --advent-shadow-hover: 0 6px 14px rgba(0, 0, 0, .3);
  --advent-accent: #ae0f0a;
  --advent-card-aspect: 3 / 4;
}

@media (min-width: 640px) {
  .advent {
    --advent-columns: 4;
    --advent-gap: 12px;
  }
}

@media (min-width: 1024px) {
  .advent {
    --advent-columns: 6;
    --advent-gap: 16px;
  }
}

.advent .advent__grid {
  display: grid;
  grid-template-columns: repeat(var(--advent-columns), minmax(0, 1fr));
  gap: var(--advent-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

.advent .advent__item {
  position: relative;
  margin: 0;
  padding: 0;
  perspective: 1000px;
}

.advent .advent__card {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: var(--advent-card-aspect);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--advent-radius);
  background: none;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform var(--advent-flip-duration) var(--advent-flip-easing);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.advent .advent__card[data-state="open"] {
  transform: rotateY(180deg);
}

.advent .advent__card[data-state="locked"] {
  cursor: not-allowed;
}

/* Nur :focus-visible, sonst bleibt auf iOS nach dem Antippen ein Rahmen stehen. */
.advent .advent__card:focus-visible {
  outline: 3px solid var(--advent-accent);
  outline-offset: 3px;
}

.advent .advent__face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: var(--advent-radius);
  background-color: #fff;
  box-shadow: var(--advent-shadow);
  transition: box-shadow .2s ease;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.advent .advent__face--back {
  transform: rotateY(180deg);
}

.advent .advent__face img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Fehlendes Bild: Tageszahl statt leerem Feld, damit ein Tippfehler auffällt. */
.advent .advent__face.is-missing {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #eee;
  border: 2px dashed var(--advent-accent);
}

.advent .advent__face.is-missing img {
  display: none;
}

.advent .advent__face.is-missing::after {
  content: attr(data-day);
  color: var(--advent-accent);
  font-size: 2em;
  font-weight: bold;
}

/* Schloss-Symbol auf gesperrten Türchen. */
.advent .advent__lock {
  display: none;
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--advent-accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M17 10V7a5 5 0 0 0-10 0v3H6a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V11a1 1 0 0 0-1-1h-1zm-8-3a3 3 0 0 1 6 0v3H9V7zm3 7a1.5 1.5 0 0 1 .75 2.8V19h-1.5v-2.2A1.5 1.5 0 0 1 12 14z'/%3E%3C/svg%3E") no-repeat center / 16px;
}

.advent .advent__card[data-state="locked"] .advent__lock {
  display: block;
}

.advent .advent__card[data-state="locked"] .advent__face--front img {
  filter: grayscale(.6);
  opacity: .75;
}

/* Hinweis legt sich über die Karte, damit das Raster beim Einblenden nicht springt. */
.advent .advent__hint {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 40px;
  z-index: 2;
  margin: 0;
  padding: 6px 8px;
  border-radius: var(--advent-radius);
  background: rgba(0, 0, 0, .8);
  color: #fff;
  font-size: .8rem;
  line-height: 1.3;
  text-align: center;
  pointer-events: none;
}

.advent .advent__hint[hidden] {
  display: none;
}

/* Lupe unten rechts auf der offenen Rückseite, öffnet die Aufgabe groß im Dialog. */
.advent .advent__zoom {
  position: absolute;
  right: 6px;
  bottom: 6px;
  z-index: 2;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--advent-accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6'/%3E%3Cpath d='M15 15l5.5 5.5M10.5 8v5M8 10.5h5'/%3E%3C/svg%3E") no-repeat center / 22px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
  cursor: zoom-in;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.advent .advent__zoom[hidden] {
  display: none;
}

.advent .advent__zoom:focus-visible {
  outline: 3px solid var(--advent-accent);
  outline-offset: 2px;
}

.advent .advent__dialog {
  max-width: 95vw;
  max-height: 95vh;
  padding: 0;
  border: 0;
  border-radius: var(--advent-radius);
  background: #fff;
  overflow: visible;
}

.advent .advent__dialog::backdrop {
  background: rgba(0, 0, 0, .75);
}

.advent .advent__dialog-image {
  display: block;
  max-width: 95vw;
  max-height: 95vh;
  width: auto;
  height: auto;
  border-radius: var(--advent-radius);
}

.advent .advent__dialog-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--advent-accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E") no-repeat center / 20px;
  cursor: pointer;
}

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

/* Auf schmalen Viewports passt der überstehende Schließen-Button nicht neben das Bild. */
@media (max-width: 575px) {
  .advent .advent__dialog-close {
    top: 6px;
    right: 6px;
  }
}

.advent .advent__preview {
  margin: 0 0 1em;
  padding: 8px 12px;
  border: 1px solid #e6d68a;
  background: #fffbe6;
}

.advent .advent__status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Tap-Feedback auf Touch-Geräten. */
.advent .advent__card:active .advent__face {
  box-shadow: none;
}

/* Hover nur bei echter Maus – kein "klebender" Hover und kein Doppel-Tap auf Touch. */
@media (hover: hover) and (pointer: fine) {
  .advent .advent__card:not([data-state="locked"]):hover .advent__face {
    box-shadow: var(--advent-shadow-hover);
  }
}

@media (prefers-reduced-motion: reduce) {
  .advent .advent__card,
  .advent .advent__card[data-state="open"] {
    transform: none;
    transition: none;
  }

  .advent .advent__face {
    transition: opacity .15s linear;
  }

  .advent .advent__face--back {
    transform: none;
    opacity: 0;
  }

  .advent .advent__card[data-state="open"] .advent__face--front {
    opacity: 0;
  }

  .advent .advent__card[data-state="open"] .advent__face--back {
    opacity: 1;
  }
}
