/**
 * minCore EasytextSwitcher CSS
 * Frontend-Umschalter fuer 3 Text-Versionen
 *
 * Features:
 * - Dezente Toggle-Buttons
 * - Dark Mode Support
 * - prefers-reduced-motion
 * - Mobile-optimiert
 * - High Contrast Mode Support
 * - Print Styles
 *
 * @version 2.0.0
 * @since TYPO3 13 LTS
 * @author made in nature Projektagentur
 */

/* ==========================================================================
   CSS Custom Properties (Design Tokens)
   ========================================================================== */

:root {
    /* Button Colors - Light Mode */
    --mincore-easytext-switcher-bg: transparent;
    --mincore-easytext-btn-bg: #f5f5f5;
    --mincore-easytext-btn-bg-hover: #e8e8e8;
    --mincore-easytext-btn-bg-active: #1a73e8;
    --mincore-easytext-btn-color: #333333;
    --mincore-easytext-btn-color-hover: #1a1a1a;
    --mincore-easytext-btn-color-active: #ffffff;
    --mincore-easytext-btn-border: #cccccc;
    --mincore-easytext-btn-border-hover: #999999;
    --mincore-easytext-btn-border-active: #1a73e8;

    /* Focus Ring */
    --mincore-easytext-focus-color: #1a73e8;
    --mincore-easytext-focus-shadow: 0 0 0 3px rgba(26, 115, 232, 0.3);

    /* Content Styling */
    --mincore-easytext-content-easy1-bg: #f8f9fa;
    --mincore-easytext-content-easy2-bg: #e8f4fd;
    --mincore-easytext-content-easy2-border: #1a73e8;

    /* Typography for Easy Language */
    --mincore-easytext-easy-font-size: 1.125rem;
    --mincore-easytext-easy-line-height: 1.8;
    --mincore-easytext-easy-letter-spacing: 0.02em;

    /* Spacing */
    --mincore-easytext-switcher-gap: 0.5rem;
    --mincore-easytext-btn-padding-x: 1rem;
    --mincore-easytext-btn-padding-y: 0.5rem;
    --mincore-easytext-btn-radius: 4px;
    --mincore-easytext-btn-gap: 0.375rem;

    /* Animation */
    --mincore-easytext-transition-duration: 200ms;
    --mincore-easytext-transition-timing: ease-in-out;
}

/* ==========================================================================
   Dark Mode
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    :root {
        --mincore-easytext-btn-bg: #2d2d2d;
        --mincore-easytext-btn-bg-hover: #3d3d3d;
        --mincore-easytext-btn-bg-active: #4da3ff;
        --mincore-easytext-btn-color: #e0e0e0;
        --mincore-easytext-btn-color-hover: #ffffff;
        --mincore-easytext-btn-color-active: #000000;
        --mincore-easytext-btn-border: #555555;
        --mincore-easytext-btn-border-hover: #777777;
        --mincore-easytext-btn-border-active: #4da3ff;
        --mincore-easytext-focus-color: #4da3ff;
        --mincore-easytext-focus-shadow: 0 0 0 3px rgba(77, 163, 255, 0.4);
        --mincore-easytext-content-easy1-bg: #1e1e1e;
        --mincore-easytext-content-easy2-bg: #1a2e40;
        --mincore-easytext-content-easy2-border: #4da3ff;
    }
}

/* ==========================================================================
   Easytext Switcher Container
   ========================================================================== */

.mincore-easytext-switcher {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--mincore-easytext-switcher-gap);
    margin-block: 1rem;
    padding: 0.25rem;
    background: var(--mincore-easytext-switcher-bg);
    border-radius: calc(var(--mincore-easytext-btn-radius) + 2px);
}

/* Wrapper for the entire easytext content area */
.mincore-easytext-wrapper {
    position: relative;
}

/* ==========================================================================
   Button Styles
   ========================================================================== */

.mincore-easytext-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--mincore-easytext-btn-gap);
    padding: var(--mincore-easytext-btn-padding-y) var(--mincore-easytext-btn-padding-x);
    background: var(--mincore-easytext-btn-bg);
    border: 2px solid var(--mincore-easytext-btn-border);
    border-radius: var(--mincore-easytext-btn-radius);
    color: var(--mincore-easytext-btn-color);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.4;
    text-decoration: none;
    cursor: pointer;
    transition-property: background-color, border-color, color, box-shadow, transform;
    transition-duration: var(--mincore-easytext-transition-duration);
    transition-timing-function: var(--mincore-easytext-transition-timing);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    user-select: none;
    touch-action: manipulation;
}

/* Hover State */
.mincore-easytext-btn:hover {
    background: var(--mincore-easytext-btn-bg-hover);
    border-color: var(--mincore-easytext-btn-border-hover);
    color: var(--mincore-easytext-btn-color-hover);
}

/* Focus State */
.mincore-easytext-btn:focus {
    outline: none;
}

.mincore-easytext-btn:focus-visible {
    outline: 2px solid var(--mincore-easytext-focus-color);
    outline-offset: 2px;
    box-shadow: var(--mincore-easytext-focus-shadow);
}

/* Active/Pressed State */
.mincore-easytext-btn[aria-pressed="true"],
.mincore-easytext-btn.is-active {
    background: var(--mincore-easytext-btn-bg-active);
    border-color: var(--mincore-easytext-btn-border-active);
    color: var(--mincore-easytext-btn-color-active);
}

/* Click/Active Feedback */
.mincore-easytext-btn:active {
    transform: scale(0.98);
}

/* ==========================================================================
   Button Icon
   ========================================================================== */

.mincore-easytext-btn__icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.mincore-easytext-btn__icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* ==========================================================================
   Button Label
   ========================================================================== */

.mincore-easytext-btn__label {
    white-space: nowrap;
}

/* Screen reader only text */
.mincore-easytext-btn .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Content Containers
   ========================================================================== */

.mincore-easytext-content {
    transition-property: opacity;
    transition-duration: var(--mincore-easytext-transition-duration);
    transition-timing-function: var(--mincore-easytext-transition-timing);
}

.mincore-easytext-content[hidden] {
    display: none !important;
}

/* Easy1 Content (Leicht verstaendlich) */
.mincore-easytext-content[data-easytext-content="easy1"] {
    background: var(--mincore-easytext-content-easy1-bg);
    padding: 1rem;
    border-radius: var(--mincore-easytext-btn-radius);
}

/* Easy2 Content (Einfache Sprache) */
.mincore-easytext-content[data-easytext-content="easy2"] {
    background: var(--mincore-easytext-content-easy2-bg);
    border-left: 4px solid var(--mincore-easytext-content-easy2-border);
    padding: 1rem 1.5rem;
    margin-block: 1rem;
    font-size: var(--mincore-easytext-easy-font-size);
    line-height: var(--mincore-easytext-easy-line-height);
    letter-spacing: var(--mincore-easytext-easy-letter-spacing);
}

.mincore-easytext-content[data-easytext-content="easy2"] p {
    margin-bottom: 1.25em;
}

.mincore-easytext-content[data-easytext-content="easy2"] ul,
.mincore-easytext-content[data-easytext-content="easy2"] ol {
    padding-left: 1.5rem;
    margin-bottom: 1.25em;
}

.mincore-easytext-content[data-easytext-content="easy2"] li {
    margin-bottom: 0.75em;
}

/* ==========================================================================
   Not Initialized State (NoScript Fallback)
   ========================================================================== */

/* Before JS initialization, show all content with labels */
.mincore-easytext-switcher:not(.is-initialized) {
    opacity: 0.6;
    pointer-events: none;
}

/* NoScript: Show all content versions */
.mincore-easytext-wrapper:not([data-easytext-initialized]) .mincore-easytext-content {
    display: block !important;
    opacity: 1 !important;
}

.mincore-easytext-wrapper:not([data-easytext-initialized]) .mincore-easytext-content::before {
    display: block;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--mincore-easytext-btn-bg);
    border-radius: var(--mincore-easytext-btn-radius);
    font-weight: 600;
    font-size: 0.875rem;
}

.mincore-easytext-wrapper:not([data-easytext-initialized]) .mincore-easytext-content[data-easytext-content="normal"]::before {
    content: "Standard:";
}

.mincore-easytext-wrapper:not([data-easytext-initialized]) .mincore-easytext-content[data-easytext-content="easy1"]::before {
    content: "Leicht verstaendlich:";
}

.mincore-easytext-wrapper:not([data-easytext-initialized]) .mincore-easytext-content[data-easytext-content="easy2"]::before {
    content: "Einfache Sprache:";
}

/* Noscript message */
.mincore-easytext-noscript {
    background: #fff3cd;
    border: 1px solid #ffc107;
    padding: 0.75rem 1rem;
    border-radius: var(--mincore-easytext-btn-radius);
    color: #856404;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

@media (prefers-color-scheme: dark) {
    .mincore-easytext-noscript {
        background: #433a21;
        border-color: #665c2e;
        color: #ffc107;
    }
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

/* Tablet and below */
@media (max-width: 768px) {
    .mincore-easytext-switcher {
        flex-wrap: wrap;
    }

    .mincore-easytext-btn {
        flex: 1 1 auto;
        min-width: 0;
        padding: var(--mincore-easytext-btn-padding-y) 0.75rem;
    }

    .mincore-easytext-btn__label {
        font-size: 0.8125rem;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .mincore-easytext-switcher {
        flex-direction: column;
        align-items: stretch;
    }

    .mincore-easytext-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .mincore-easytext-btn {
        transition: none;
    }

    .mincore-easytext-btn:active {
        transform: none;
    }

    .mincore-easytext-content {
        transition: none;
    }
}

/* ==========================================================================
   High Contrast Mode (Windows)
   ========================================================================== */

@media (forced-colors: active) {
    .mincore-easytext-btn {
        border: 2px solid ButtonText;
        background: ButtonFace;
        color: ButtonText;
    }

    .mincore-easytext-btn:hover {
        background: Highlight;
        color: HighlightText;
        border-color: Highlight;
    }

    .mincore-easytext-btn[aria-pressed="true"],
    .mincore-easytext-btn.is-active {
        background: Highlight;
        color: HighlightText;
        border-color: Highlight;
    }

    .mincore-easytext-btn:focus-visible {
        outline: 3px solid Highlight;
        outline-offset: 2px;
    }

    .mincore-easytext-content[data-easytext-content="easy2"] {
        border-color: Highlight;
        background: Canvas;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    /* Hide switcher on print */
    .mincore-easytext-switcher {
        display: none !important;
    }

    /* Show all content versions with labels */
    .mincore-easytext-content {
        display: block !important;
        opacity: 1 !important;
        page-break-inside: avoid;
        border: 1px solid #ccc;
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .mincore-easytext-content[hidden] {
        display: block !important;
    }

    .mincore-easytext-content::before {
        display: block;
        font-weight: bold;
        margin-bottom: 0.5rem;
        padding-bottom: 0.5rem;
        border-bottom: 1px solid #ccc;
    }

    .mincore-easytext-content[data-easytext-content="normal"]::before {
        content: "Standard-Text:";
    }

    .mincore-easytext-content[data-easytext-content="easy1"]::before {
        content: "Leicht verstaendlich:";
    }

    .mincore-easytext-content[data-easytext-content="easy2"]::before {
        content: "Einfache Sprache:";
    }
}

/* ==========================================================================
   Integration with Accessibility Toolbar
   ========================================================================== */

.mincore-a11y-toolbar .mincore-easytext-switcher {
    margin: 0;
    padding: 0;
}

.mincore-a11y-toolbar .mincore-easytext-btn {
    padding: 0.375rem 0.625rem;
    font-size: 0.8125rem;
}

/* ==========================================================================
   Compact Variant
   ========================================================================== */

.mincore-easytext-switcher--compact .mincore-easytext-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.mincore-easytext-switcher--compact .mincore-easytext-btn__icon {
    width: 14px;
    height: 14px;
}

/* ==========================================================================
   Pill/Rounded Variant
   ========================================================================== */

.mincore-easytext-switcher--pill .mincore-easytext-btn {
    border-radius: 9999px;
}

.mincore-easytext-switcher--pill {
    border-radius: 9999px;
    background: var(--mincore-easytext-btn-bg);
    padding: 0.25rem;
}
