/*!
 * This file is part of the TYPO3 extension "TKLMN Slider".
 *
 * Copyright © Tom Kilimann <info@tklmn.de>
 * All rights reserved.
 *
 * Proprietary and confidential. Unauthorized copying, distribution or
 * modification of this file, via any medium, is strictly prohibited.
 * See the LICENSE file for the full license terms.
 */

/**
 * TKLMN Slider — Frontend Styles
 * ================================
 */

.tklmn-slider-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.tklmn-slider {
    width: 100%;
    position: relative;
}

.tklmn-slider .swiper-slide {
    position: relative;
    overflow: hidden;
    /* Default height when no height is set on the slider (height=0):
       layers + background image are position:absolute, otherwise the slide collapses to 0px. */
    min-height: 400px;
}

/* Slide image */
.tklmn-slider-slide-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Ken Burns: slow zoom/pan on the active slide's background image. Alternating
   direction per slide adds variety. Only the active slide animates (Swiper sets
   the class), so it restarts each time a slide becomes active. */
.tklmn-slider--kenburns .tklmn-slider-slide-image {
    transform: scale(1);
    transition: none;
}
.tklmn-slider--kenburns .swiper-slide-active .tklmn-slider-slide-image {
    animation: tklmnKenBurns 12s ease-out forwards;
    transform-origin: center center;
}
.tklmn-slider--kenburns .swiper-slide-active:nth-child(even) .tklmn-slider-slide-image {
    animation-name: tklmnKenBurnsAlt;
}

@keyframes tklmnKenBurns {
    from { transform: scale(1) translate(0, 0); }
    to { transform: scale(1.15) translate(-2%, -2%); }
}
@keyframes tklmnKenBurnsAlt {
    from { transform: scale(1.15) translate(2%, 2%); }
    to { transform: scale(1) translate(0, 0); }
}

/* Video layer: responsive 16:9 embed wrapper for iframes/direct media. */
.tklmn-slider-video-embed {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #000;
}
.tklmn-slider-video-embed iframe,
.tklmn-slider-video-embed video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Layer content — default text color is black; per-layer color overrides inline. */
.tklmn-slider-layer {
    color: #000000;
}

/* Dark mode: lighten only the DEFAULT text colour for accessible contrast on a
   dark page. Per-layer colours are set inline and outrank these rules (no
   !important), so an explicitly chosen colour is never touched. Covers the OS
   preference and the common manual-toggle conventions (class + data-attribute,
   incl. Bootstrap 5.3 data-bs-theme). */
@media (prefers-color-scheme: dark) {
    .tklmn-slider-layer {
        color: #f0f0f0;
    }
}

html.dark .tklmn-slider-layer,
body.dark .tklmn-slider-layer,
.dark .tklmn-slider-layer,
[data-theme="dark"] .tklmn-slider-layer,
[data-bs-theme="dark"] .tklmn-slider-layer {
    color: #f0f0f0;
}

/* A button layer never shrinks below its button. */
.tklmn-slider-layer--button {
    min-width: fit-content;
}

/* An image layer without an explicit width never grows beyond the slide. */
.tklmn-slider-layer--image {
    max-width: 100%;
}

/* Text layer with a background colour gets default padding. Background and
   padding live on the layer CONTENT (the animated element), so they reveal
   together with the text. Overridable with plain CSS (no !important), e.g.:
   .tklmn-slider-layer--has-bg .tklmn-slider-layer-content { padding: 12px 30px; } */
.tklmn-slider-layer--text.tklmn-slider-layer--has-bg .tklmn-slider-layer-content {
    padding: 7px 15px;
}

.tklmn-slider-text {
    font-size: 1.1rem;
    line-height: 1.6;
}

.tklmn-slider-text h1,
.tklmn-slider-text h2,
.tklmn-slider-text h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
}

/* h2/h3 sit flush — no trailing gap below the caption heading. */
.tklmn-slider-text h2,
.tklmn-slider-text h3 {
    margin-bottom: 0;
}

.tklmn-slider-text p {
    margin-bottom: 0;
}

/* Status badge */
.tklmn-slider-status-badge {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 10px;
}

/* ==========================================================================
   Bootstrap 5 button classes — scoped to the slider so button layers are styled
   even when the site itself does not load Bootstrap. (Subset: base + variants.)
   ========================================================================== */
.tklmn-slider .btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
.tklmn-slider .btn:hover { text-decoration: none; }
.tklmn-slider .btn-lg { padding: 0.5rem 1rem; font-size: 1.25rem; border-radius: 0.5rem; }
.tklmn-slider .btn-sm { padding: 0.25rem 0.5rem; font-size: 0.875rem; border-radius: 0.25rem; }

.tklmn-slider .btn-primary { color: #fff; background-color: #0d6efd; border-color: #0d6efd; }
.tklmn-slider .btn-primary:hover { color: #fff; background-color: #0b5ed7; border-color: #0a58ca; }
.tklmn-slider .btn-secondary { color: #fff; background-color: #6c757d; border-color: #6c757d; }
.tklmn-slider .btn-secondary:hover { color: #fff; background-color: #5c636a; border-color: #565e64; }
.tklmn-slider .btn-success { color: #fff; background-color: #198754; border-color: #198754; }
.tklmn-slider .btn-success:hover { color: #fff; background-color: #157347; border-color: #146c43; }
.tklmn-slider .btn-danger { color: #fff; background-color: #dc3545; border-color: #dc3545; }
.tklmn-slider .btn-danger:hover { color: #fff; background-color: #bb2d3b; border-color: #b02a37; }
.tklmn-slider .btn-warning { color: #000; background-color: #ffc107; border-color: #ffc107; }
.tklmn-slider .btn-warning:hover { color: #000; background-color: #ffca2c; border-color: #ffc720; }
.tklmn-slider .btn-info { color: #000; background-color: #0dcaf0; border-color: #0dcaf0; }
.tklmn-slider .btn-info:hover { color: #000; background-color: #31d2f2; border-color: #25cff2; }
.tklmn-slider .btn-light { color: #000; background-color: #f8f9fa; border-color: #f8f9fa; }
.tklmn-slider .btn-light:hover { color: #000; background-color: #d3d4d5; border-color: #c6c7c8; }
.tklmn-slider .btn-dark { color: #fff; background-color: #212529; border-color: #212529; }
.tklmn-slider .btn-dark:hover { color: #fff; background-color: #1c1f23; border-color: #1a1e21; }
.tklmn-slider .btn-link { color: #0d6efd; background-color: transparent; border-color: transparent; text-decoration: underline; }
.tklmn-slider .btn-link:hover { color: #0a58ca; }

.tklmn-slider .btn-outline-primary { color: #0d6efd; border-color: #0d6efd; background-color: transparent; }
.tklmn-slider .btn-outline-primary:hover { color: #fff; background-color: #0d6efd; }
.tklmn-slider .btn-outline-secondary { color: #6c757d; border-color: #6c757d; background-color: transparent; }
.tklmn-slider .btn-outline-secondary:hover { color: #fff; background-color: #6c757d; }
.tklmn-slider .btn-outline-light { color: #f8f9fa; border-color: #f8f9fa; background-color: transparent; }
.tklmn-slider .btn-outline-light:hover { color: #000; background-color: #f8f9fa; }
.tklmn-slider .btn-outline-dark { color: #212529; border-color: #212529; background-color: transparent; }
.tklmn-slider .btn-outline-dark:hover { color: #fff; background-color: #212529; }

/* CTA Button */
.tklmn-slider-cta {
    display: inline-block;
    padding: 10px 24px;
    background: #ffffff;
    color: #333333;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.tklmn-slider-cta:hover {
    background: #f0f0f0;
    color: #000000;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    text-decoration: none;
}

/* Swiper navigation overrides */
.tklmn-slider .swiper-button-prev,
.tklmn-slider .swiper-button-next {
    color: #ffffff;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    backdrop-filter: blur(5px);
    transition: background 0.3s ease;
}

.tklmn-slider .swiper-button-prev:hover,
.tklmn-slider .swiper-button-next:hover {
    background: rgba(0, 0, 0, 0.6);
}

.tklmn-slider .swiper-button-prev::after,
.tklmn-slider .swiper-button-next::after {
    font-size: 18px;
    font-weight: bold;
}

/* Swiper pagination */
.tklmn-slider .swiper-pagination-bullet {
    width: 10px;
    height: 10px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 1;
}

.tklmn-slider .swiper-pagination-bullet-active {
    background: #ffffff;
}

/* Swiper scrollbar */
.tklmn-slider .swiper-scrollbar {
    background: rgba(255, 255, 255, 0.2);
}

.tklmn-slider .swiper-scrollbar-drag {
    background: rgba(255, 255, 255, 0.6);
}

/* Accessibility: respect reduced-motion — show layers immediately, no animation. */
@media (prefers-reduced-motion: reduce) {
    .tklmn-slider-layer-content[data-animation],
    .tklmn-slider-cta[data-animation] {
        opacity: 1 !important;
        animation: none !important;
    }
    .tklmn-slider--kenburns .swiper-slide-active .tklmn-slider-slide-image {
        animation: none !important;
        transform: none !important;
    }
}

/* Layers flagged "hide on mobile" disappear below the phone breakpoint. */
@media (max-width: 767px) {
    .tklmn-slider-layer--hide-mobile {
        display: none !important;
    }
}

/* Animations */
.tklmn-slider-layer-content[data-animation] {
    opacity: 0;
}

.tklmn-slider-layer-content.animated {
    opacity: 1;
}

.tklmn-slider-layer-content[data-animation="fadeIn"].animated {
    animation: tklmnFadeIn 0.6s ease forwards;
}

.tklmn-slider-layer-content[data-animation="fadeInUp"].animated {
    animation: tklmnFadeInUp 0.6s ease forwards;
}

.tklmn-slider-layer-content[data-animation="fadeInDown"].animated {
    animation: tklmnFadeInDown 0.6s ease forwards;
}

.tklmn-slider-layer-content[data-animation="fadeInLeft"].animated {
    animation: tklmnFadeInLeft 0.6s ease forwards;
}

.tklmn-slider-layer-content[data-animation="fadeInRight"].animated {
    animation: tklmnFadeInRight 0.6s ease forwards;
}

.tklmn-slider-layer-content[data-animation="zoomIn"].animated {
    animation: tklmnZoomIn 0.6s ease forwards;
}

.tklmn-slider-layer-content[data-animation="slideInUp"].animated {
    animation: tklmnSlideInUp 0.6s ease forwards;
}

.tklmn-slider-layer-content[data-animation="slideInDown"].animated {
    animation: tklmnSlideInDown 0.6s ease forwards;
}

.tklmn-slider-layer-content[data-animation="slideInLeft"].animated {
    animation: tklmnSlideInLeft 0.6s ease forwards;
}

.tklmn-slider-layer-content[data-animation="slideInRight"].animated {
    animation: tklmnSlideInRight 0.6s ease forwards;
}

.tklmn-slider-layer-content[data-animation="bounceIn"].animated {
    animation: tklmnBounceIn 0.8s ease forwards;
}

.tklmn-slider-cta[data-animation] {
    opacity: 0;
}

.tklmn-slider-cta.animated[data-animation="fadeIn"] {
    animation: tklmnFadeIn 0.6s ease forwards;
}

.tklmn-slider-cta.animated[data-animation="fadeInUp"] {
    animation: tklmnFadeInUp 0.6s ease forwards;
}

.tklmn-slider-cta.animated[data-animation="fadeInDown"] {
    animation: tklmnFadeInDown 0.6s ease forwards;
}

.tklmn-slider-cta.animated[data-animation="fadeInLeft"] {
    animation: tklmnFadeInLeft 0.6s ease forwards;
}

.tklmn-slider-cta.animated[data-animation="fadeInRight"] {
    animation: tklmnFadeInRight 0.6s ease forwards;
}

.tklmn-slider-cta.animated[data-animation="zoomIn"] {
    animation: tklmnZoomIn 0.6s ease forwards;
}

.tklmn-slider-cta.animated[data-animation="bounceIn"] {
    animation: tklmnBounceIn 0.8s ease forwards;
}

/* Keyframes */
@keyframes tklmnFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes tklmnFadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes tklmnFadeInDown {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes tklmnFadeInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes tklmnFadeInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes tklmnZoomIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes tklmnSlideInUp {
    from { opacity: 0; transform: translateY(50px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes tklmnSlideInDown {
    from { opacity: 0; transform: translateY(-50px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes tklmnSlideInLeft {
    from { opacity: 0; transform: translateX(-50px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes tklmnSlideInRight {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes tklmnBounceIn {
    0% { opacity: 0; transform: scale(0.3); }
    50% { opacity: 1; transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { opacity: 1; transform: scale(1); }
}

/* Responsive */
@media (max-width: 768px) {
    .tklmn-slider-text {
        font-size: 0.95rem;
    }

    .tklmn-slider-cta {
        padding: 8px 18px;
        font-size: 0.8rem;
    }

    .tklmn-slider .swiper-button-prev,
    .tklmn-slider .swiper-button-next {
        width: 34px;
        height: 34px;
    }

    .tklmn-slider .swiper-button-prev::after,
    .tklmn-slider .swiper-button-next::after {
        font-size: 14px;
    }
}

/* ================================
   Thumbnail navigation
   ================================ */
.tklmn-slider-thumbs {
    margin-top: 10px;
    width: 100%;
    box-sizing: border-box;
}

.tklmn-slider-thumbs .swiper-slide.tklmn-slider-thumb {
    width: 120px;
    height: 68px;
    cursor: pointer;
    opacity: 0.5;
    border-radius: 4px;
    overflow: hidden;
    transition: opacity 0.2s ease;
    background: #1d1d1d;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tklmn-slider-thumbs .swiper-slide-thumb-active {
    opacity: 1;
    outline: 2px solid #2f6fed;
    outline-offset: -2px;
}

.tklmn-slider-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tklmn-slider-thumb-label {
    color: #fff;
    font-size: 0.75rem;
    text-align: center;
    padding: 4px;
    line-height: 1.2;
}

/* ================================
   Autoplay play/pause control (a11y)
   ================================ */
.tklmn-slider-autoplay-toggle {
    position: absolute;
    bottom: 12px;
    right: 12px;
    z-index: 10;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.tklmn-slider-autoplay-toggle:hover,
.tklmn-slider-autoplay-toggle:focus-visible {
    background: rgba(0, 0, 0, 0.8);
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Play icon (triangle) — shown when paused. */
.tklmn-slider-autoplay-icon {
    display: block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 7px 0 7px 12px;
    border-color: transparent transparent transparent #fff;
    margin-left: 2px;
}

/* Pause icon (two bars) — shown while playing. */
.tklmn-slider-autoplay-toggle.is-playing .tklmn-slider-autoplay-icon {
    width: 12px;
    height: 14px;
    border: none;
    margin-left: 0;
    background: linear-gradient(to right, #fff 0 4px, transparent 4px 8px, #fff 8px 12px);
}

@media (prefers-reduced-motion: reduce) {
    .tklmn-slider-autoplay-toggle {
        transition: none;
    }
}
