/* M2C Lookbook – Frontend-Viewer */

.m2c-lookbook {
    --m2c-bg: #1a1a1a;
    --m2c-fg: #f5f5f5;
    --m2c-accent: #c9a86a;
    --m2c-max-width: 1100px;

    background: var(--m2c-bg);
    color: var(--m2c-fg);
    border-radius: 6px;
    padding: 2rem 1rem 1rem;
    margin: 1.5rem 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
    position: relative; /* Verankerung für absolut positionierten Grid-Modal-Overlay */
}

.m2c-lookbook *,
.m2c-lookbook *::before,
.m2c-lookbook *::after {
    box-sizing: border-box;
}

.m2c-lookbook__viewport {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    min-height: 200px;
    isolation: isolate; /* sauberer Stacking-Context, damit Pill über Buch liegt */
    overflow: hidden;   /* Curl-/Pan-Overflow bleibt im Viewport, keine Page-Scrollbars */
}

.m2c-lookbook__book-frame {
    /* Outer-Wrapper für Cover-Mittig-Shift (Issuu-Style). Muss die volle Container-
       Breite belegen, damit StPageFlip beim Init/Update seinen Landscape-Modus
       korrekt erkennt (sonst fällt es auf Single-Page zurück). */
    width: 100%;
    max-width: var(--m2c-max-width);
    display: flex;
    justify-content: center;
    align-items: center;
    --m2c-cover-shift: 0px;
    transition: transform 0.6s ease-out;
    /* Default: kein Transform. Shift greift nur via .is-cover-front/back unten. */
}
/* Zwei-Klassen-Selektor (Spezifität 0,2,0), damit unser transform die
   inline `<style>`-Regel von StPageFlip schlägt (`.stf__parent { transform: translateZ(0) }`,
   Spezifität 0,1,0, käme sonst durch Cascade-Order zuletzt durch). Ohne diesen Trick
   bleibt das Zoom-Transform wirkungslos – der Indicator zeigt 200 %, aber das Buch
   skaliert nicht. */
.m2c-lookbook .m2c-lookbook__book {
    margin: 0 auto;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.55);
    max-width: var(--m2c-max-width);

    /* Zoom + Pan via CSS-Variablen */
    --m2c-zoom: 1;
    --m2c-pan-x: 0px;
    --m2c-pan-y: 0px;
    transform: translate(var(--m2c-pan-x), var(--m2c-pan-y)) scale(var(--m2c-zoom));
    transform-origin: center center;
    transition: transform 0.18s ease-out;
    will-change: transform;
    touch-action: pan-y; /* erlaubt vertikales Page-Scroll; Pinch wird von uns abgefangen */
}

/* Cover-Mittig nur, wenn StPageFlip im Landscape-Modus rendert (book breiter als 1.5x page).
   Im Portrait/Single-Page ist das Buch eh zentriert → kein Shift. Der Shift-Wert wird in JS
   in px gesetzt (= 25 % der gemessenen Buchbreite), damit der Verschub unabhängig
   von der Frame-Container-Breite stimmt. */
.m2c-lookbook.is-landscape.is-cover-front .m2c-lookbook__book-frame {
    transform: translateX(calc(var(--m2c-cover-shift) * -1));
}
.m2c-lookbook.is-landscape.is-cover-back .m2c-lookbook__book-frame {
    transform: translateX(var(--m2c-cover-shift));
}
.m2c-lookbook__book.is-pinching {
    transition: none; /* Live-Updates ohne Lag während aktiver Geste */
}
.m2c-lookbook.is-zoomed .m2c-lookbook__book {
    cursor: grab;
    touch-action: none; /* alles unter unserer Kontrolle */
}
.m2c-lookbook.is-zoomed .m2c-lookbook__book.is-panning {
    cursor: grabbing;
}
/* Side-Buttons während Zoom: ausgegraut, nicht klickbar */
.m2c-lookbook.is-zoomed .m2c-lookbook__side-btn {
    opacity: 0.2;
    pointer-events: none;
}

/* Side-Buttons links/rechts (wie Issuu) */
.m2c-lookbook__side-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 3rem;
    height: 4.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 20, 20, 0.55);
    color: #fff;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    z-index: 5;
    transition: background 0.15s, opacity 0.15s;
    opacity: 0.85;
}
.m2c-lookbook__side-btn:hover:not(:disabled),
.m2c-lookbook__side-btn:focus-visible {
    background: rgba(20, 20, 20, 0.9);
    opacity: 1;
    outline: none;
}
.m2c-lookbook__side-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}
.m2c-lookbook__side-btn--prev { left: 0.5rem; }
.m2c-lookbook__side-btn--next { right: 0.5rem; }

@media (max-width: 600px) {
    .m2c-lookbook__side-btn {
        width: 2.4rem;
        height: 3.5rem;
    }
}

.m2c-lookbook__page {
    background: #fff;
    overflow: hidden;
}

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

.m2c-lookbook__controls {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    width: 100%;
    max-width: var(--m2c-max-width);
}
.m2c-lookbook__btn--grid {
    grid-column: 1;
    justify-self: start;
    min-width: 0;
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.m2c-lookbook__counter {
    grid-column: 2;
}
.m2c-lookbook__controls-right {
    grid-column: 3;
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.m2c-lookbook__btn--zoom-in,
.m2c-lookbook__btn--zoom-out {
    min-width: 0;
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.m2c-lookbook__btn--fullscreen {
    margin-left: 0;
}

.m2c-lookbook__btn {
    background: transparent;
    color: var(--m2c-fg);
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-family: inherit;
    line-height: 1;
    min-width: 3rem;
    transition: border-color 0.15s, color 0.15s;
}

.m2c-lookbook__btn:hover:not(:disabled),
.m2c-lookbook__btn:focus-visible {
    border-color: var(--m2c-accent);
    color: var(--m2c-accent);
    outline: none;
}

.m2c-lookbook__btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.m2c-lookbook__counter {
    font-variant-numeric: tabular-nums;
    font-size: 0.9rem;
    min-width: 3rem;
    text-align: center;
}

.m2c-lookbook__btn--fullscreen {
    min-width: 0;
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.5rem;
}

.m2c-lookbook__icon {
    display: block;
}

/* Standard: enter-Icon zeigen, exit ausblenden */
.m2c-lookbook .m2c-lookbook__icon--exit { display: none; }
.m2c-lookbook .m2c-lookbook__icon--enter { display: block; }

/* Im Fullscreen: umkehren */
.m2c-lookbook.is-fullscreen .m2c-lookbook__icon--enter { display: none; }
.m2c-lookbook.is-fullscreen .m2c-lookbook__icon--exit { display: block; }

/* Fullscreen-Layout: Buch füllt die Viewport-Höhe maximal */
.m2c-lookbook:fullscreen,
.m2c-lookbook.is-fullscreen,
.m2c-lookbook--fullsize {
    --m2c-max-width: 100vw;
    margin: 0;
    border-radius: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0;
    background: #0a0a0a; /* pitch dunkler in Fullscreen */
}
.m2c-lookbook:fullscreen .m2c-lookbook__viewport,
.m2c-lookbook.is-fullscreen .m2c-lookbook__viewport,
.m2c-lookbook--fullsize .m2c-lookbook__viewport {
    background: #0a0a0a;
}
/* Kein Box-Shadow am Buch in Fullscreen – sonst entsteht optischer Grau-Halo */
.m2c-lookbook:fullscreen .m2c-lookbook__book,
.m2c-lookbook.is-fullscreen .m2c-lookbook__book,
.m2c-lookbook--fullsize .m2c-lookbook__book {
    box-shadow: none;
}

.m2c-lookbook:fullscreen .m2c-lookbook__viewport,
.m2c-lookbook.is-fullscreen .m2c-lookbook__viewport,
.m2c-lookbook--fullsize .m2c-lookbook__viewport {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    align-items: center;
    padding: 1rem 4.5rem; /* Platz für Side-Buttons */
}

.m2c-lookbook:fullscreen .m2c-lookbook__book,
.m2c-lookbook.is-fullscreen .m2c-lookbook__book,
.m2c-lookbook--fullsize .m2c-lookbook__book {
    max-width: 100%;
    max-height: 100%;
}

/* Frame braucht in Fullscreen/Fullsize eine definite Höhe, sonst greift max-height:100%
   auf dem inneren .m2c-lookbook__book nicht (es bezieht sich auf den Frame, der ohne
   definite Höhe einfach auf Inhalt = Buch wächst → keine Begrenzung). */
.m2c-lookbook:fullscreen .m2c-lookbook__book-frame,
.m2c-lookbook.is-fullscreen .m2c-lookbook__book-frame,
.m2c-lookbook--fullsize .m2c-lookbook__book-frame {
    height: 100%;
    max-height: 100%;
    max-width: 100%;
    overflow: hidden;
}

/* Größere Side-Buttons in Fullscreen / Fullsize */
.m2c-lookbook:fullscreen .m2c-lookbook__side-btn,
.m2c-lookbook.is-fullscreen .m2c-lookbook__side-btn,
.m2c-lookbook--fullsize .m2c-lookbook__side-btn {
    width: 3.5rem;
    height: 6rem;
    background: #1a1a1a;
}
.m2c-lookbook:fullscreen .m2c-lookbook__side-btn:hover:not(:disabled),
.m2c-lookbook.is-fullscreen .m2c-lookbook__side-btn:hover:not(:disabled),
.m2c-lookbook--fullsize .m2c-lookbook__side-btn:hover:not(:disabled),
.m2c-lookbook:fullscreen .m2c-lookbook__side-btn:focus-visible,
.m2c-lookbook.is-fullscreen .m2c-lookbook__side-btn:focus-visible,
.m2c-lookbook--fullsize .m2c-lookbook__side-btn:focus-visible {
    background: #2a2a2a;
}
.m2c-lookbook:fullscreen .m2c-lookbook__side-btn--prev,
.m2c-lookbook.is-fullscreen .m2c-lookbook__side-btn--prev,
.m2c-lookbook--fullsize .m2c-lookbook__side-btn--prev { left: 1rem; }
.m2c-lookbook:fullscreen .m2c-lookbook__side-btn--next,
.m2c-lookbook.is-fullscreen .m2c-lookbook__side-btn--next,
.m2c-lookbook--fullsize .m2c-lookbook__side-btn--next { right: 1rem; }

.m2c-lookbook:fullscreen .m2c-lookbook__controls,
.m2c-lookbook.is-fullscreen .m2c-lookbook__controls,
.m2c-lookbook--fullsize .m2c-lookbook__controls {
    flex: 0 0 auto;
    padding: 0.75rem 1rem;
    background: #000;
    width: 100%;
    max-width: 100%;
    justify-content: center;
    position: relative;
    z-index: 10;
    pointer-events: auto;
}
.m2c-lookbook:fullscreen .m2c-lookbook__controls .m2c-lookbook__btn,
.m2c-lookbook.is-fullscreen .m2c-lookbook__controls .m2c-lookbook__btn,
.m2c-lookbook--fullsize .m2c-lookbook__controls .m2c-lookbook__btn {
    position: relative;
    z-index: 11;
}

.m2c-lookbook:fullscreen .m2c-lookbook__viewport,
.m2c-lookbook.is-fullscreen .m2c-lookbook__viewport,
.m2c-lookbook--fullsize .m2c-lookbook__viewport {
    overflow: hidden;
}

/* Fullsize-spezifisch: 100% des Eltern-Containers nutzen, NICHT 100vh
   (sonst kollidiert es mit Share-Page-Header/Footer) */
.m2c-lookbook--fullsize {
    width: 100%;
    height: 100%;
}

.m2c-lookbook__notice {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.06);
    border-left: 3px solid var(--m2c-accent);
    color: var(--m2c-fg);
}

.m2c-lookbook__pdf-fallback {
    color: var(--m2c-accent);
    text-decoration: underline;
}

/* Initialer Layout-Stand vor JS-Init: Galerie-Liste.
   Wird auch genutzt von Lookbooks, die per IntersectionObserver-Defer-Mount
   noch nicht initialisiert sind (under-the-fold). Sobald sichtbar/initialisiert,
   wird .is-ready gesetzt und der Page-Flip-Viewer übernimmt. */
.m2c-lookbook:not(.is-ready) .m2c-lookbook__viewport {
    overflow: visible;
}
.m2c-lookbook:not(.is-ready) .m2c-lookbook__book-frame {
    display: block;
    width: 100%;
}
.m2c-lookbook:not(.is-ready) .m2c-lookbook__book {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    max-height: 70vh;
    overflow: auto;
    box-shadow: none;
    transform: none;
}
.m2c-lookbook:not(.is-ready) .m2c-lookbook__page {
    max-width: 100%;
}
.m2c-lookbook:not(.is-ready) .m2c-lookbook__controls,
.m2c-lookbook:not(.is-ready) .m2c-lookbook__side-btn,
.m2c-lookbook:not(.is-ready) .m2c-lookbook__zoom-indicator {
    display: none;
}

/* ── Zoom-Level-Indicator (Pill oben rechts) ────────────────── */

.m2c-lookbook__zoom-indicator {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: rgba(40, 40, 40, 0.9);
    color: #fff;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    font-size: 0.78rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease-out;
    z-index: 200; /* hoch, damit auch über transformiertem Buch + StPageFlip-Inner-Layern liegt */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.m2c-lookbook__zoom-indicator.is-visible {
    opacity: 1;
}

/* ── Grid-Modal (Seitenübersicht) ───────────────────────────── */

.m2c-lookbook__grid-modal {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 10, 0.97);
    z-index: 100;
    display: flex;
    flex-direction: column;
    animation: m2c-grid-fade-in 0.18s ease-out;
    border-radius: inherit; /* übernimmt 6px vom Lookbook-Container, kein scharfer Knick an der Kante */
    overflow: hidden;
}
.m2c-lookbook__grid-modal[hidden] {
    display: none;
}
@keyframes m2c-grid-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.m2c-lookbook__grid-header {
    flex: 0 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: #000;
}
.m2c-lookbook__grid-title {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--m2c-fg);
}
.m2c-lookbook__grid-close {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: var(--m2c-fg);
    width: 2.2rem;
    height: 2.2rem;
    padding: 0;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s, color 0.15s;
}
.m2c-lookbook__grid-close:hover,
.m2c-lookbook__grid-close:focus-visible {
    border-color: var(--m2c-accent);
    color: var(--m2c-accent);
    outline: none;
}

.m2c-lookbook__grid-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
    align-content: start;
}
@media (min-width: 600px) {
    .m2c-lookbook__grid-body {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 1rem;
    }
}
@media (min-width: 1024px) {
    .m2c-lookbook__grid-body {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}

.m2c-lookbook__grid-item {
    background: transparent;
    border: 2px solid transparent;
    padding: 0.25rem;
    cursor: pointer;
    border-radius: 4px;
    transition: border-color 0.15s, transform 0.15s;
    font: inherit;
    color: inherit;
}
.m2c-lookbook__grid-item:hover,
.m2c-lookbook__grid-item:focus-visible {
    border-color: var(--m2c-accent);
    transform: translateY(-2px);
    outline: none;
}
.m2c-lookbook__grid-item img {
    width: 100%;
    height: auto;
    display: block;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}
.m2c-lookbook__grid-label {
    display: block;
    text-align: center;
    font-size: 0.75rem;
    margin-top: 0.35rem;
    color: rgba(255, 255, 255, 0.7);
    font-variant-numeric: tabular-nums;
}

/* ── Reduced Motion (prefers-reduced-motion: reduce) ─────────────────
   Respektiert die OS-Einstellung "Bewegung reduzieren". Transitions und
   Keyframe-Animationen werden auf ~0 gesetzt – die Funktion bleibt voll
   erhalten (Zoom, Cover-Zentrierung, Grid-Modal, Pill), nur ohne Bewegung.
   Scope bewusst auf .m2c-lookbook begrenzt, damit das übrige Theme
   unberührt bleibt. Die 3D-Page-Flip-Animation wird zusätzlich in
   frontend.js auf 1 ms + ohne Flip-Schatten reduziert. */
@media (prefers-reduced-motion: reduce) {
    .m2c-lookbook *,
    .m2c-lookbook *::before,
    .m2c-lookbook *::after {
        transition-duration: 0.01ms !important;
        transition-delay: 0ms !important;
        animation-duration: 0.01ms !important;
        animation-delay: 0ms !important;
        animation-iteration-count: 1 !important;
    }
    /* Hover-Lift der Grid-Thumbnails komplett aus (kein Versatz statt nur
       schnellerer Übergang). */
    .m2c-lookbook__grid-item:hover,
    .m2c-lookbook__grid-item:focus-visible {
        transform: none !important;
    }
}
