/**
 * Slide-out drawer (panel boczny) — IKEA-style.
 * Korzysta z istniejacych CSS variables z main.css (--ink-*, --brand-*,
 * --shadow-*, --border-radius-*, --spacing-*).
 *
 * Struktura: overlay + aside z transform: translateX. Treść per-trigger
 * wstrzykiwana przez window.LMDrawer (drawer.js).
 */

:root {
    --lm-drawer-width: 480px;
    --lm-drawer-duration: 320ms;
    --lm-drawer-easing: cubic-bezier(0.22, 1, 0.36, 1);
    --lm-drawer-overlay-bg: rgba(17, 17, 17, 0.45);
    --lm-drawer-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
}

/* =========================================================
   Body lock (wspolne z preview modal — patrz products-shared.js)
   ========================================================= */
body.is-locked {
    overflow: hidden;
}

/* =========================================================
   Overlay (backdrop)
   ========================================================= */
.lm-drawer-overlay {
    position: fixed;
    inset: 0;
    background: var(--lm-drawer-overlay-bg);
    opacity: 0;
    transition: opacity var(--lm-drawer-duration) var(--lm-drawer-easing);
    z-index: 999;
    pointer-events: none;
}

.lm-drawer-overlay[hidden] {
    display: none;
}

.lm-drawer-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* =========================================================
   Drawer panel
   ========================================================= */
.lm-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    height: 100dvh;
    width: var(--lm-drawer-width);
    max-width: 100vw;
    background: var(--white, #FFFFFF);
    box-shadow: var(--lm-drawer-shadow);
    transform: translateX(100%);
    transition: transform var(--lm-drawer-duration) var(--lm-drawer-easing);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    will-change: transform;
}

.lm-drawer[hidden] {
    display: none;
}

.lm-drawer.is-open {
    transform: translateX(0);
}

/* =========================================================
   Drawer header
   ========================================================= */
.lm-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md, 1rem);
    padding: var(--spacing-lg, 1.5rem);
    border-bottom: 1px solid var(--ink-200, #E0E8F0);
    flex-shrink: 0;
}

.lm-drawer-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ink-900, #333333);
    line-height: 1.3;
}

.lm-drawer-close {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 50%;
    color: var(--ink-700, #4A4A4A);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.lm-drawer-close:hover {
    background: var(--ink-100, #F5F7FA);
    color: var(--ink-900, #333333);
}

.lm-drawer-close:focus-visible {
    outline: none;
    border-color: var(--brand-primary, #27A3DC);
    box-shadow: 0 0 0 3px rgba(39, 163, 220, 0.25);
}

.lm-drawer-close svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* =========================================================
   Drawer body
   ========================================================= */
.lm-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.75rem var(--spacing-lg, 1.5rem) 2rem;
    color: var(--ink-800, #2A2A2A);
    font-size: 1rem;
    line-height: 1.7;
    -webkit-overflow-scrolling: touch;
}

.lm-drawer-body > *:first-child {
    margin-top: 0;
}

.lm-drawer-body p {
    margin: 0 0 1rem 0;
    color: var(--ink-800, #2A2A2A);
}

.lm-drawer-body p:last-child {
    margin-bottom: 0;
}

.lm-drawer-body ul {
    margin: 0 0 1.25rem 0;
    padding-left: 0;
    list-style: none;
}

.lm-drawer-body li {
    position: relative;
    padding: 0.35rem 0 0.35rem 1.5rem;
    line-height: 1.55;
    color: var(--ink-800, #2A2A2A);
    border-bottom: 1px dashed var(--ink-200, #E0E8F0);
}

.lm-drawer-body li:last-child {
    border-bottom: none;
}

.lm-drawer-body li::before {
    content: '';
    position: absolute;
    left: 0.25rem;
    top: 0.95rem;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--brand-primary, #27A3DC);
}

.lm-drawer-body a {
    color: var(--brand-primary, #27A3DC);
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-word;
}

.lm-drawer-body a:hover {
    color: var(--brand-primary-dark, #1A86B8);
}

/* FAQ details/summary — natywny accordion */
.lm-drawer-body .lm-faq {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.lm-drawer-body .lm-faq details {
    border: 1px solid var(--ink-200, #E0E8F0);
    border-radius: var(--border-radius-card, 8px);
    background: var(--ink-100, #F5F7FA);
    transition: box-shadow 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.lm-drawer-body .lm-faq details:hover {
    border-color: var(--brand-primary, #27A3DC);
}

.lm-drawer-body .lm-faq details[open] {
    background: var(--white, #FFFFFF);
    border-color: var(--brand-primary, #27A3DC);
    box-shadow: 0 2px 12px rgba(39, 163, 220, 0.12);
}

.lm-drawer-body .lm-faq summary {
    cursor: pointer;
    padding: 0.95rem 1rem;
    font-weight: 600;
    color: var(--ink-900, #333333);
    list-style: none;
    position: relative;
    padding-right: 2.75rem;
    line-height: 1.45;
}

.lm-drawer-body .lm-faq summary::-webkit-details-marker {
    display: none;
}

.lm-drawer-body .lm-faq summary::after {
    content: '';
    position: absolute;
    right: 1rem;
    top: 50%;
    width: 12px;
    height: 12px;
    border-right: 2px solid var(--ink-600, #888888);
    border-bottom: 2px solid var(--ink-600, #888888);
    transform: translateY(-70%) rotate(45deg);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.lm-drawer-body .lm-faq details[open] summary::after {
    transform: translateY(-30%) rotate(-135deg);
    border-color: var(--brand-primary, #27A3DC);
}

.lm-drawer-body .lm-faq summary:focus-visible {
    outline: 2px solid var(--brand-primary, #27A3DC);
    outline-offset: -2px;
    border-radius: var(--border-radius-card, 8px);
}

.lm-drawer-body .lm-faq .lm-faq-answer {
    padding: 0.25rem 1rem 1rem 1rem;
    color: var(--ink-700, #4A4A4A);
    line-height: 1.65;
    border-top: 1px solid var(--ink-200, #E0E8F0);
    margin-top: 0.4rem;
}

.lm-drawer-body .lm-faq .lm-faq-answer p {
    margin: 0.6rem 0 0.5rem 0;
}

.lm-drawer-body .lm-faq .lm-faq-answer p:last-child {
    margin-bottom: 0;
}

.lm-drawer-body .lm-faq .lm-faq-answer ul {
    margin-top: 0.6rem;
}

/* =========================================================
   Trigger buttons (na stronie produktu)
   ========================================================= */
.product-detail-drawer-section {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: var(--spacing-xl, 2rem);
    border-top: 1px solid var(--ink-200, #E0E8F0);
}

.drawer-trigger {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--ink-200, #E0E8F0);
    padding: 1.15rem 0.85rem 1.15rem 0.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    text-align: left;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink-900, #333333);
    cursor: pointer;
    transition: color 0.18s ease, background-color 0.18s ease, padding-left 0.18s ease;
}

.drawer-trigger:hover {
    color: var(--brand-primary, #27A3DC);
    background-color: rgba(39, 163, 220, 0.04);
    padding-left: 0.85rem;
}

.drawer-trigger:focus-visible {
    outline: 2px solid var(--brand-primary, #27A3DC);
    outline-offset: -2px;
    border-radius: 4px;
}

.drawer-trigger .drawer-trigger-label {
    flex: 1;
    letter-spacing: -0.01em;
}

.drawer-trigger .drawer-trigger-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.55;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.drawer-trigger:hover .drawer-trigger-icon {
    transform: translateX(4px);
    opacity: 1;
}

/* =========================================================
   Mobile (≤ 768px) — drawer full screen
   ========================================================= */
@media (max-width: 768px) {
    .lm-drawer {
        width: 100vw;
    }

    .lm-drawer-header {
        padding: var(--spacing-md, 1rem);
    }

    .lm-drawer-body {
        padding: var(--spacing-md, 1rem);
    }

    .lm-drawer-title {
        font-size: 1.1rem;
    }
}

/* =========================================================
   prefers-reduced-motion — wylacz tranzycje
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
    .lm-drawer,
    .lm-drawer-overlay,
    .drawer-trigger,
    .drawer-trigger .drawer-trigger-icon,
    .lm-drawer-close,
    .lm-drawer-body .lm-faq summary::after {
        transition: none !important;
    }
}
