/* ============================================================================
   CORE IDENTITY (Scene 9 / .ps-scene-identity / #psScene8) — layout fix v3
   ----------------------------------------------------------------------------
   WHY v3 (what was wrong with v2):
     v2 forced .ps-left into a CSS Grid with a fixed row template and pinned the
     scene to `max-height: 100dvh`. Three things then broke it in the live
     cascade:
       1. This file loads in <head> (≈709), but private-seller.css
          (`.ps-scene{display:flex}`), private-seller-mobile-fixes.css
          (`.ps-scene > .ps-left > .ps-nav{position:relative;flex:0 0 auto}`)
          load LATER in the @section Styles block — so equal-specificity rules
          there beat v2. And ikhayalami-frontend-fixes.css uses
          `#psScene8 .ps-id-form{overflow:visible}` (id specificity) which beat
          v2's class-only `.ps-id-form{overflow-y:auto}`. Net: the form stopped
          scrolling and the grid rows were half-overridden.
       2. `max-height: 100dvh` let the scene grow to the FULL viewport — taller
          than the sell-journey card it lives in — so the Back/Continue nav was
          pushed below the card, off the bottom of the page.
       3. The injected breadcrumb added a row the grid template didn't expect.

   v3 STRATEGY — stop fighting, match what already works:
     • Use the SAME flex-column layout the working scenes (0–7) use and that
       core-identity-mobile-fix.js is explicitly built to measure & pin:
         HEAD (breadcrumb · progress · question · subtitle)  flex: 0 0 auto
         BODY (.ps-id-form — the ONE scroller)               flex: 1 1 auto, overflow-y:auto
         FOOT (.ps-nav — Back / Continue)                    flex: 0 0 auto (pinned bottom)
     • Bound the scene with `height: 100%` ONLY (no 100dvh). The carousel chain
       (.sj-track-viewport flex:1 → .sj-scroll-track → .sj-panel →
       .sj-branch-step[position:absolute;inset:0] → module → .ps-viewport/.ps-track/
       .ps-scene height:100%) is already definite — it's what sizes scenes 0–7
       — so 100% resolves to the card box and the nav sits at the card bottom.
     • Scope every rule to #psScene8 so it wins regardless of load order:
         #psScene8.ps-scene-identity            (1,2,0) beats .ps-scene            (0,1,0)
         #psScene8 > .ps-left                    (1,1,0) beats .ps-scene > .ps-left (0,2,0)
         #psScene8 > .ps-left > .ps-id-form      (1,3,0) beats #psScene8 .ps-id-form(1,1,0)
         #psScene8 > .ps-left > .ps-nav          (1,3,0) beats .ps-scene>.ps-left>.ps-nav(0,3,0)
     • The dial-code control is a NATIVE <select>; its dropdown paints in the OS
       layer and is NOT clipped by an overflow:auto ancestor, so making the form
       scroll does not reintroduce the clipped-dropdown problem
       ikhayalami-frontend-fixes.css was guarding against.

   Load order in _Layout.cshtml:
     <link rel="stylesheet" href="~/css/private-seller-scenes-extra.css" />
     <link rel="stylesheet" href="~/css/ikhayalami-frontend-fixes.css" />
     <link rel="stylesheet" href="~/css/core-identity-fix.css" />
   ============================================================================ */


/* ── (1) SCENE — two-column layout, bounded to the carousel scene box ──────── */
#psScene8.ps-scene-identity {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) clamp(280px, 38%, 360px) !important;
    align-items: stretch !important;
    min-width: 100% !important;
    width: 100% !important;
    height: 100% !important; /* bound to the card box — NOT 100dvh */
    overflow: hidden !important;
    position: relative !important;
}


/* ── (2) LEFT PANE — proven flex column (header / scroller / footer) ───────── */
#psScene8 > .ps-left {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
    padding: 18px 28px 0 !important;
    position: relative !important;
}

    /* Header chrome — never scrolls, never shrinks. (The injected breadcrumb is
       the first child and is covered by .ps-breadcrumb's own v2 styling.) */
    #psScene8 > .ps-left > .ps-breadcrumb,
    #psScene8 > .ps-left > .ps-progress,
    #psScene8 > .ps-left > .ps-question,
    #psScene8 > .ps-left > .ps-subtitle,
    #psScene8 > .ps-left > .ps-id-error {
        flex: 0 0 auto !important;
    }

    #psScene8 > .ps-left > .ps-progress,
    #psScene8 > .ps-left > .ps-question,
    #psScene8 > .ps-left > .ps-subtitle {
        min-width: 0 !important;
    }

    /* Scene name now lives in the breadcrumb — hide the redundant label. */
    #psScene8 > .ps-left > .ps-scene-label {
        display: none !important;
    }

    /* (3) BODY — the ONE scroller. Beats ikhayalami-frontend-fixes' overflow:visible. */
    #psScene8 > .ps-left > .ps-id-form {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        min-width: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
        margin: 4px -6px 0 0 !important;
        padding: 6px 6px 16px 0 !important;
        scrollbar-width: thin;
        scrollbar-color: rgba(15, 23, 42, 0.32) transparent;
    }

        #psScene8 > .ps-left > .ps-id-form::-webkit-scrollbar {
            width: 6px;
        }

        #psScene8 > .ps-left > .ps-id-form::-webkit-scrollbar-track {
            background: rgba(15, 23, 42, 0.04);
            border-radius: 3px;
        }

        #psScene8 > .ps-left > .ps-id-form::-webkit-scrollbar-thumb {
            background: rgba(15, 23, 42, 0.28);
            border-radius: 3px;
        }

            #psScene8 > .ps-left > .ps-id-form::-webkit-scrollbar-thumb:hover {
                background: rgba(15, 23, 42, 0.45);
            }

    #psScene8 > .ps-left > .ps-id-error[hidden] {
        display: none !important;
    }

    #psScene8 > .ps-left > .ps-id-error {
        margin: 0 0 8px !important;
    }

    /* (4) FOOTER — Back / Continue, pinned at the bottom of the flex column.
       position:relative (a flex footer, not sticky); flex:0 0 auto keeps it out
       of the scroll region. ALWAYS visible. */
    #psScene8 > .ps-left > .ps-nav {
        flex: 0 0 auto !important;
        position: relative !important;
        z-index: 3 !important;
        margin: 0 -28px !important;
        padding: 14px 28px !important;
        padding-bottom: max(14px, env(safe-area-inset-bottom)) !important;
        background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.95) 32%, #ffffff 70%) !important;
        border-top: 1px solid rgba(15, 23, 42, 0.06) !important;
        display: flex !important;
        align-items: center !important;
        gap: 12px !important;
    }


/* ── (5) RIGHT PANE — unchanged on desktop, hidden on mobile ───────────────── */
#psScene8 > .ps-right {
    overflow-y: auto !important;
    min-height: 0 !important;
}


/* ============================================================================
   MOBILE (≤900px) — single column, right pane hidden, form keeps scrolling
   ============================================================================ */
@media (max-width: 900px) {

    #psScene8.ps-scene-identity {
        grid-template-columns: minmax(0, 1fr) !important;
        height: 100% !important;
    }

    #psScene8 > .ps-left {
        padding: 14px 18px 0 !important;
    }

        #psScene8 > .ps-left > .ps-question {
            font-size: 1.4rem !important;
            line-height: 1.2 !important;
            margin-bottom: 4px !important;
        }

        #psScene8 > .ps-left > .ps-subtitle {
            font-size: 12.5px !important;
            margin-bottom: 10px !important;
        }

        #psScene8 > .ps-left > .ps-id-form {
            padding: 6px 4px 14px 0 !important;
            margin: 4px -4px 0 0 !important;
        }

        #psScene8 > .ps-left > .ps-nav {
            margin: 0 -18px !important;
            padding: 10px 18px !important;
            padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
        }

    #psScene8 > .ps-right {
        display: none !important;
    }
}


/* ============================================================================
   SMALL PHONES (≤600px) — compact field sizing
   ============================================================================ */
@media (max-width: 600px) {

    #psScene8 > .ps-left {
        padding: 12px 14px 0 !important;
    }

        #psScene8 > .ps-left > .ps-nav {
            margin: 0 -14px !important;
            padding: 10px 14px !important;
            padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
            gap: 8px !important;
        }

            #psScene8 > .ps-left > .ps-nav .ps-btn-back {
                flex: 0 0 auto !important;
                padding: 10px 14px !important;
            }

    #psScene8.ps-scene-identity .ps-id-row {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }

    #psScene8.ps-scene-identity .ps-id-photo-zone {
        width: 150px !important;
        height: 150px !important;
        margin: 0 auto;
    }

    #psScene8.ps-scene-identity .ps-id-photo-cam {
        width: 38px !important;
        height: 38px !important;
        font-size: 15px !important;
        margin-bottom: 4px !important;
    }

    #psScene8.ps-scene-identity .ps-id-photo-title {
        font-size: 12.5px !important;
    }

    #psScene8.ps-scene-identity .ps-id-photo-sub {
        font-size: 10.5px !important;
    }

    #psScene8.ps-scene-identity .ps-id-row-2 {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    #psScene8.ps-scene-identity .ps-id-fields-col {
        gap: 8px !important;
    }

    #psScene8.ps-scene-identity .ps-id-input {
        padding: 9px 12px 9px 32px !important;
        font-size: 13px !important;
    }

    #psScene8.ps-scene-identity .ps-id-question-row {
        grid-template-columns: 1fr !important;
    }
}
