/*!
 * SayWOW Login — Drawer Stylesheet
 *
 * Brand Design System v3.0 compliant. The drawer feel intentionally
 * matches the saywow-cart drawer (timing, easing, backdrop opacity)
 * so guests don't context-switch between "this is how a SayWOW drawer
 * behaves" when moving between cart and login surfaces.
 *
 * Sections:
 *   1. Root wrapper + visibility state
 *   2. Backdrop
 *   3. Panel — desktop right-side slide-out
 *   4. Panel — mobile bottom-sheet (≤768px), no drag handle (DS v3.0 §11.3)
 *   5. Panel header — title + grey-square close (DS v3.0 §11.2)
 *   6. Panel body — overrides partial spacing when nested
 *   7. Body scroll lock — iOS-friendly position:fixed pattern
 *   8. Reduced motion
 *
 * @package SayWOW_Login
 * @version 1.3.6
 */

/* ============================================================================
   1. ROOT
   ----------------------------------------------------------------------------
   Tokens are inherited via login.css's :scope on .custom-login-wrapper —
   but the drawer is NOT inside .custom-login-wrapper. We re-declare the
   small set of tokens we use here, scoped to .sw-login-root, to keep the
   drawer standalone-styled when login.css's wrapper-scoped tokens aren't
   in scope.
   ============================================================================ */

.sw-login-root {
    --sw-font: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
    --sw-blue: #0052CC;
    --sw-blue-dark: #003D99;
    --sw-grey-900: #212529;
    --sw-grey-500: #6B7280;
    --sw-grey-300: #9CA3AF;
    --sw-grey-200: #E5E7EB;
    --sw-grey-100: #F8F9FA;
    --sw-white: #FFFFFF;
    --sw-sheet-pad: 20px;
    --sw-sheet-radius: 16px;
    --sw-sheet-close-size: 40px;
    /* Brand DS §11.2 — proposed spec update from grey-100 (#F8F9FA, too
       light against white panel headers — close button had no visible
       edge) to grey-200 (#E5E7EB, the system border colour). To be
       reflected in 00-SPEC-BRAND-DESIGN-SYSTEM.md §11.2 and inherited
       by the cart drawer + future modals on their V3 conformance pass. */
    --sw-sheet-close-bg: var(--sw-grey-200);
    --sw-sheet-close-bg-hover: var(--sw-grey-300);
    --sw-sheet-close-radius: 8px;
    --sw-sheet-close-icon: var(--sw-grey-900);
}

.sw-login-root,
.sw-login-root *,
.sw-login-root *::before,
.sw-login-root *::after {
    box-sizing: border-box;
}

.sw-login-root {
    font-family: var(--sw-font);
    color: var(--sw-grey-900);
    font-size: 16px;
    line-height: 1.5;
}

/* Closed state — backdrop + panel hidden, no pointer events, panel
   translated off-screen ready for the open transition. */
.sw-login-root--closed .sw-login-backdrop,
.sw-login-root--closed .sw-login-panel {
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
}

.sw-login-root--closed .sw-login-panel {
    transform: translateX(100%);
}

@media (max-width: 768px) {
    .sw-login-root--closed .sw-login-panel {
        transform: translateY(100%);
    }
}

.sw-login-root--open .sw-login-backdrop,
.sw-login-root--open .sw-login-panel {
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
}

.sw-login-root--open .sw-login-panel {
    transform: translateX(0) translateY(0);
}

/* ============================================================================
   2. BACKDROP
   ----------------------------------------------------------------------------
   rgba(0,0,0,0.45), z-index 9998 — matches the saywow-cart drawer for
   visual consistency. Fade 200ms.
   ============================================================================ */

.sw-login-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9998;
    transition: opacity 200ms cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0s linear 200ms;
}

.sw-login-root--open .sw-login-backdrop {
    transition: opacity 200ms cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0s linear 0s;
}

/* ============================================================================
   3. PANEL — DESKTOP (≥769px)
   ----------------------------------------------------------------------------
   Same width/height/shadow/timing as the cart drawer (420px / 100vh /
   280ms / cubic-bezier(0.4, 0, 0.2, 1)) for feel consistency. Z-index
   10000 matches cart (only one drawer is open at a time in normal flow).
   ============================================================================ */

.sw-login-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    height: 100vh;
    height: 100dvh;
    background: var(--sw-white);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    box-shadow: -20px 0 60px rgba(0, 0, 0, 0.18);
    transform: translateX(100%);
    transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1),
                opacity 200ms cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0s linear 280ms;
    overflow: hidden;
}

.sw-login-root--open .sw-login-panel {
    transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1),
                opacity 200ms cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0s linear 0s;
}

/* ============================================================================
   4. PANEL — MOBILE BOTTOM-SHEET (≤768px)
   ----------------------------------------------------------------------------
   100vw, max-height 90vh, top corners 16px radius, slides up. NO drag
   handle per Brand DS v3.0 §11.3 — the grey-square close is the single
   explicit dismissal control. Login is a simpler surface than the cart;
   no swipe-to-dismiss is implemented or promised.
   ============================================================================ */

@media (max-width: 768px) {
    .sw-login-panel {
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: auto;
        max-height: 90vh;
        max-height: 90dvh;
        border-radius: var(--sw-sheet-radius) var(--sw-sheet-radius) 0 0;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.16);
        transform: translateY(100%);
        transition: transform 320ms cubic-bezier(0.4, 0, 0.2, 1),
                    opacity 200ms cubic-bezier(0.4, 0, 0.2, 1),
                    visibility 0s linear 320ms;
    }

    .sw-login-root--open .sw-login-panel {
        transition: transform 320ms cubic-bezier(0.4, 0, 0.2, 1),
                    opacity 200ms cubic-bezier(0.4, 0, 0.2, 1),
                    visibility 0s linear 0s;
    }
}

/* ============================================================================
   5. PANEL HEADER — title + grey-square close
   ----------------------------------------------------------------------------
   Brand DS v3.0 §11.1 anatomy: title left (H3 weight 700), close right,
   flex-row centred. §11.2 close control specifications.
   ============================================================================ */

.sw-login-panel__header {
    flex: 0 0 auto;
    height: 64px;
    padding: 0 var(--sw-sheet-pad);
    background: var(--sw-white);
    border-bottom: 1px solid var(--sw-grey-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: relative;
    z-index: 1;
}

@media (max-width: 768px) {
    .sw-login-panel__header {
        height: 56px;
    }
}

.sw-login-panel__title {
    margin: 0;
    font-family: var(--sw-font);
    /* Brand DS §11.1 sheet anatomy: title is H3 weight 700.
       §2.2 type scale: H3 = 18px / 1.125rem / 700 / 0 letter-spacing
       / 1.4 line-height. */
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--sw-grey-900);
    letter-spacing: 0;
}

/* Grey-square close — Brand DS v3.0 §11.2 (proposed spec update v1.3.6).
   40×40, 8px radius, grey-200 bg (was grey-100 — too light against
   white panel header), grey-900 icon at 20px. Hover lifts to grey-300
   for clearer feedback than the previous grey-100 → grey-200 shift. */
.sw-login-close {
    width: var(--sw-sheet-close-size);
    height: var(--sw-sheet-close-size);
    flex: 0 0 var(--sw-sheet-close-size);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: var(--sw-sheet-close-radius);
    background: var(--sw-sheet-close-bg);
    color: var(--sw-sheet-close-icon);
    cursor: pointer;
    transition: background 150ms ease;
}

.sw-login-close:hover {
    background: var(--sw-sheet-close-bg-hover);
}

.sw-login-close:focus-visible {
    outline: none;
    background: var(--sw-sheet-close-bg-hover);
    box-shadow: 0 0 0 3px rgba(0, 82, 204, 0.20);
}

.sw-login-close svg {
    width: 20px;
    height: 20px;
    display: block;
}

/* ============================================================================
   6. PANEL BODY — overrides the partial's page-level spacing
   ----------------------------------------------------------------------------
   The shared form partial outputs .login-brand + form. As of v1.2.1 there
   is no longer a .login-heading / .login-subhead in the markup — the
   brand image is the surface's identity anchor.

   In the drawer context, the brand image still shows (it reinforces
   identity, which matters more on white-label partner sites than on
   saywow.co.uk) but at a more compact size than the page version.
   The panel header's "Log in" text remains as the dialog's
   aria-labelledby anchor — the slight redundancy is acceptable since
   the panel-header title serves an accessibility role the brand image
   alone cannot.

   Brand DS v3.0 §10.4 also forbids bordered cards inside sheets — the
   defensive rule below neutralises .login-container chrome if a future
   surface ever wraps the partial in one inside the drawer body.
   ============================================================================ */

.sw-login-panel__body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    /* v1.3.5 — top padding bumped from 20px to 32px so the first form
       label has breathing room beneath the header border (the prior
       uniform 20px felt cramped against the chrome band). */
    padding: 32px var(--sw-sheet-pad) 24px;
}

/* The shared form partial outputs .login-brand (wrapped in an <a> to
   home). That brand is the identity anchor for the /login/ page. In
   the drawer context, the brand is already visible elsewhere on the
   page (GP header logo, PWA header logo), so repeating it inside the
   drawer body is noise — and the link would yank guests mid-flow if
   they clicked it. Hide entirely. The drawer panel header's "Login"
   title is sufficient identity for this surface. */
.sw-login-panel__body .login-brand {
    display: none;
}

/* Defensive — neutralise card chrome if a .login-container ever sneaks
   in here (DS v3.0 §10.4 forbids cards-inside-sheets). */
.sw-login-panel__body .login-container {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    padding: 0;
    max-width: none;
    width: 100%;
}

/* The form's first interactive group can sit a touch tighter against
   the brand block (no double padding) but keep enough breathing space
   that the form doesn't slam into the panel header. */
.sw-login-panel__body .saywow-login-form .form-group:first-of-type {
    margin-top: 4px;
}

/* Login button + links sit at the bottom of the panel body with
   consistent rhythm — same vertical spacing as on the page. */
.sw-login-panel__body .login-links {
    margin-top: 20px;
}

/* ============================================================================
   7. BODY SCROLL LOCK
   ----------------------------------------------------------------------------
   Same pattern as saywow-cart: JS adds .sw-login-locked to <body>,
   sets inline `top: -<scrollY>px` to preserve visual scroll position.
   On close, JS removes the class and restores window.scrollTo. iOS-safe
   (position: fixed prevents rubber-band scroll behind the drawer).
   ============================================================================ */

body.sw-login-locked {
    position: fixed;
    width: 100%;
    overflow: hidden;
}

/* ============================================================================
   8. REDUCED MOTION
   ----------------------------------------------------------------------------
   Reduce slide-in transforms to opacity-only for users who prefer
   reduced motion. The dismissal mechanics (ESC, close button) still work.
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    .sw-login-panel,
    .sw-login-backdrop,
    .sw-login-close {
        transition-duration: 0ms !important;
    }

    .sw-login-root--closed .sw-login-panel {
        transform: none;
    }
}

/* ============================================================================
   PRINT — never render the drawer when printing.
   ============================================================================ */

@media print {
    .sw-login-root {
        display: none !important;
    }
}
