/* ============================================================
   STEIN SITE THEME
   ============================================================

   Brings the configurator's look in line with the main STEIN website
   (src/app/(frontend)/globals.css + src/components/ui/*): black / white /
   grey palette, square corners, site type sizes, black focus ring.

   This is an OVERRIDE layer owned by the website team. The freelancer's
   stylesheets (base / layout / components / configurator / landscape) are
   left untouched so a future handoff can be dropped in without losing
   these changes. Almost everything here re-points their design tokens;
   the few selector rules below exist only where a value is hardcoded or
   set inline by JS.

   MUST load after css/landscape.css (see index.html).

   Deliberately NOT changed:
   - Panel colour coding (--color-panel-hinge / -door / -fixed): functional,
     matched to the 3D materials.
   - Diff badges (--color-diff-success / -danger) and error red: semantic.
   - Bunnings checkout buttons (red / orange): retailer brand.
   ============================================================ */

:root {
    /* ── Colour: site palette ── */
    --color-primary: #000000;                 /* site --primary */
    --color-text: #000000;                    /* site --foreground */
    --color-text-secondary: #333f48;          /* site --muted-foreground */
    --color-background: #f5f5f5;              /* site --stein-gray */
    --color-border: #acacac;                  /* site --border */
    --color-card-border: #acacac;             /* site --border (ProductCard) */
    --color-border-strong: #000000;           /* hover = black, like site outline buttons */
    --color-surface-muted: #f9f9f9;           /* site --tertiary */
    --color-surface-hover: #ebeceb;           /* site --muted */
    --color-surface-pressed: #dfe0df;
    --color-primary-light-bg: #ebeceb;
    --color-primary-lighter-bg: #f5f5f5;

    /* Selection accent: the site has no green, selection is black.
       --color-success drives every tick badge + "Best Match" label;
       --color-success-light-bg drives the suggested/ready fills. */
    --color-success: #000000;
    --color-success-dark: #000000;
    --color-success-light-bg: #ebeceb;        /* site --muted (grey intro bands) */

    /* ── Focus: site ring (black, not Bootstrap blue) ── */
    --shadow-focus: 0 0 0 3px rgba(0, 0, 0, 0.2);

    /* ── Shape: the site is square-cornered ── */
    --border-radius: 0;
    --sheet-radius: 0;
    /* --border-radius-pill stays 50% (step number, tick badges, spinner). */

    /* ── Borders: site uses 1px hairlines ── */
    --border-width: 1px;

    /* ── Typography weights (design audit DA-02) ──
       Body copy 400, labels/buttons/headings 500. 600/700 are not used. */
    --weight-body: 400;
    --weight-button: 500;
    --weight-label-strong: 500;
    --weight-heading: 500;
    --weight-title: 500;
    --weight-sheet-title: 500;

    /* ── Typography sizes (design audit DA-03) ──
       6-step scale: 12 caption · 14 body-s · 16 body · 20 step title ·
       24 section · 32 page title. Explicit px replace base.css's
       calc(Npx + --font-offset) presets. */
    --font-offset: 0px;
    --font-size-caption:      12px;
    --font-size-label-strong: 12px;
    --font-size-body:         14px;
    --font-size-button:       14px;
    --font-size-subhead:      16px;
    --font-size-heading:      20px;
    --font-size-title:        24px;
    --font-size-sheet-title:  24px;
    --step1-panel-heading-size: 32px;
    --step1-panel-subtitle-size: 20px;
    /* Step 2/3 fixed chrome above the Best Match cards grows with the type
       (+2px heading, +2px subtitle, +2px input text) — keep the solo-card
       ceiling maths in step (see base.css). */
    --step-header-chrome-height: 112px;
}

/* Step 1 landscape panel heading: snaps down the scale on short viewports
   (replaces base.css's fluid clamp(20px, 4vh, 32px) with the same breakpoints
   that clamp crossed, so the photo isn't squeezed at e.g. 1280×500). */
@media (max-height: 720px) {
    :root {
        --step1-panel-heading-size: 24px;
        --step1-panel-subtitle-size: 14px;
    }
}
@media (max-height: 560px) {
    :root {
        --step1-panel-heading-size: 20px;
        --step1-panel-subtitle-size: 12px;
    }
}

/* ── Buttons ──
   --color-panel-black is set inline on <html> by formManager.js (#231F20,
   the 3D material colour), so it can't be re-pointed from :root. Match the
   site's default Button: black fill, 80% on hover. */
.btn-primary {
    background: #000000;
}

.btn-primary:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.8);
}

/* Filled buttons had no focus rule (browser default ring showed through).
   A white gap + black ring stays visible against the black fill. */
.btn-primary:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #000000;
}

/* Secondary buttons → site outline Button (black border, fills on hover). */
.step6-download-btn:hover,
.step6-breakdown-btn:hover {
    background: #000000;
    border-color: #000000;
    color: #ffffff;
}

/* ── Loading spinner (hardcoded Bootstrap blue in layout.css) ── */
.spinner {
    border-top-color: #000000;
}

/* ── Inputs: site Input (black border, black ring) ── */
.form-group select,
.form-group input {
    border-color: #000000;
}

.form-group select:focus,
.form-group input:focus {
    border-color: #000000;
}

/* ── Selected cards: black outline like the rest of the selection language ── */
.best-match-card.selected {
    border-color: #000000;
}

/* ── Landscape Step 1: right-hand gutter ──
   The /configurator page makes the iframe 24px wider than the site
   container on each side, because the app insets its content by
   --padding-page-horizontal. The Steps 2+ preview column already pads both
   sides by that amount, but the Step 1 "Your Shower, Taking Shape" panel runs
   flush to the right edge — give it the matching 24px so it lines up with the
   header's right edge too. */
html.is-landscape .container:has(.step[data-step="1"].active) {
    padding-right: var(--padding-page-horizontal);
    box-sizing: border-box;
}

html.is-landscape {
    --step1-panel-width: calc(100vw - var(--shell-width) - 2 * var(--padding-page-horizontal));
}

/* ── Sheets → centred modal on desktop ──
   On phones the sheets stay bottom sheets (layout.css). On desktop-sized
   landscape frames the handoff pins them to the bottom-left of the form
   column (landscape.css §4), which reads as a detached drawer inside the
   site layout — show them as a centred modal dialog instead, like the
   site's own Dialog.

   Same two-state contract as landscape.css §4 (closed / .open, transform
   folded with centring). Specificity equals landscape.css's rules and this
   file loads later, so no !important. The sheet gets .open in the same
   frame it is inserted (widthSheets.js _openSheet), so a transition would
   never run on open — the enter animation is a keyframe instead; the close
   still uses the transition (widthSheets.js removes the node on
   transitionend, with a 320ms fallback). */
@media (min-width: 768px) {
    html.is-landscape .bottom-sheet {
        top: 50%;
        bottom: auto;
        left: 50%;
        width: min(560px, calc(100vw - 2 * var(--padding-page-horizontal)));
        max-height: min(85vh, 720px);
        padding-bottom: var(--sheet-pad-bottom-base);
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.96);
        transition: opacity 0.2s ease, transform 0.2s ease;
    }

    html.is-landscape .bottom-sheet.open {
        opacity: 1;
        transform: translate(-50%, -50%);
        animation: stein-modal-in 0.2s ease;
    }

    /* Drag handle only makes sense on a bottom sheet. */
    html.is-landscape .bottom-sheet .sheet-handle {
        display: none;
    }
}

@keyframes stein-modal-in {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.96);
    }
}

/* ── Sheet close: fade out instead of snapping ──
   layout.css transitions the scrim's opacity but not its visibility, so on
   close `visibility: hidden` applies instantly and the scrim vanishes with no
   fade-out. Inside the site that shows as a flash: the page-level overlay
   around the iframe (ConfiguratorFrame.tsx) fades over 0.25s while the frame's
   own scrim is already gone. Delay the visibility flip until the fade ends
   (and flip it immediately on open). */
.sheet-scrim {
    transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}

.sheet-scrim.open {
    transition: opacity 0.25s ease, visibility 0s linear 0s;
}

/* widthSheets.js removes a closing sheet on its first `transitionend` — and
   that event bubbles, so a child transition finishing first (e.g. the ✕ or
   ‹ Back hover background as the pointer leaves) removes the sheet mid-fade,
   making it pop out. A closing sheet's children don't need transitions. */
.bottom-sheet:not(.open) * {
    transition: none !important;
}

/* ── Nav buttons: stacked, full width ──
   Next on top (primary action first), Back underneath. column-reverse keeps
   the DOM order (Back, Next) so tab order is unchanged. formManager.js
   toggles each button's inline display/visibility per step, so a hidden
   Next (Step 2/3 before a valid size) keeps its row and Back doesn't jump.
   Back becomes the site's outline button so the pair reads primary /
   secondary instead of two identical black bars. */
.button-section {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 8px;
}

.button-section > button {
    flex: none;
    width: 100%;
}

.btn-back.btn-primary {
    background: #ffffff;
    color: #000000;
    border: 1px solid #000000;
}

.btn-back.btn-primary:hover:not(:disabled) {
    background: #000000;
    color: #ffffff;
}

/* ── Step 1: breathing room under the subtitle ── */
:root {
    --gap-s1-03: 16px;    /* subtitle → first layout card (was 5px) */
}

/* ── Step 7 shopping list: spacing + alignment ──
   The handoff's gaps here were uneven (0 / 4 / 16px) so the list ran
   straight into the order section and the two checkout blocks crowded their
   copy. Re-tuned on a consistent 8/16/24 rhythm: 24px between sections,
   12–16px within one. All of these are the handoff's own gap-bar tokens
   (see configurator.css "Step 7 gap bars"). */
:root {
    --gap-s7-01a: 8px;    /* title ↔ list (symmetric; was 1px) */
    /* list → "Order these products": --gap-s7-05 is a margin-bottom, which
       the Step 7 zero-out strips (margin !important), so it never rendered.
       Painted as a border on the subheading instead — see rule below. */
    /* s7-06…09 sat between the order copy and the two checkout buttons.
       Those now live inside .shopping-order-card, which spaces its own
       children with `gap` (see "Bunnings order card" below). */
    --gap-s7-06: 0px;
    --gap-s7-07: 0px;
    --gap-s7-08: 0px;
    --gap-s7-09: 0px;
    --gap-s7-11: 16px;    /* order card → "Important information" link */
    --gap-s7-10: 24px;    /* link → Back (was 16px) */
    /* Only the list scrolls; everything below it (order copy, both checkout
       buttons, the link) stays on screen. The disclaimers moved into a sheet
       (formManager.renderShoppingDisclaimers) so this fixed footer is short
       enough to leave the list room. Floor ≈ 2 rows (rows are ~60px): only
       below that does the handoff's fallback (html.step7-list-expanded)
       scroll the whole step instead. */
    --shopping-list-min-height: 120px;
}

/* list → order card (24px) → print row (16px) → stock notice (16px).
   Borders, not margins: the Step 7 zero-out strips margin with !important.
   The card and notice are filled, so their backgrounds are clipped to the
   padding box to keep the gap clear. */
.container:has(.step[data-step="7"].active) .shopping-order-card {
    border-top: 24px solid transparent;
    padding-top: 24px !important;
    padding-bottom: 24px !important;
}

.container:has(.step[data-step="7"].active) .shopping-print-row {
    border-top: 16px solid transparent;
}

.container:has(.step[data-step="7"].active) .shopping-stock-notice {
    border-top: 16px solid transparent;
    padding-top: 16px !important;
    padding-bottom: 16px !important;
}

/* Desktop: the shopping list is the last step and has no inputs, so it
   takes 60% of the width and the finished-shower preview the other 40%
   (every other step keeps the 500px form column). The preview's own
   ResizeObserver (src/main.js) re-fits the 3D canvas. */
html.is-landscape .container:has(.step[data-step="7"].active) {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
}

/* "Important information ›" — same look as Step 2's "View Other Options ›". */
.shopping-disclaimers-link {
    flex: none;
    width: auto;
    height: auto;
    padding: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    font-family: var(--font-family);
    font-size: var(--font-size-body);
    font-weight: var(--weight-body);
    color: var(--color-text);
    cursor: pointer;
}

.shopping-disclaimers-link:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.shopping-disclaimers-link:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

.shopping-disclaimers-link .chevron-circle {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Disclaimer sheet body copy — readable size now it has its own surface. */
.sheet-disclaimer {
    font-size: var(--font-size-body);
    font-weight: var(--weight-caption);
    line-height: 1.5;
    color: var(--color-text-secondary);
}

/* The disclaimer sheet has no subtitle; drop the empty heading's gap. */
.sheet-subtitle:empty {
    display: none;
}

/* List rows: quantity centred against the name + I/N, site hairline
   dividers instead of near-black, slightly tighter rows to offset the
   extra section spacing above. Same selectors (and !important) as the
   handoff's restore rules in configurator.css; this file loads later. */
.container:has(.step[data-step="7"].active) .shopping-list-item {
    align-items: center;
    padding-top: 14px !important;
    padding-bottom: 14px !important;
    border-bottom-color: var(--color-card-border);
}

.shopping-list-divider {
    border-top-color: var(--color-card-border);
}

/* Right-align quantities so 1- and 2-digit counts share a right edge.
   (Its 8px padding-right is kept: it clears the list's scrollbar.)
   Quantity is secondary to the price: regular weight, muted, "×N". */
.shopping-list-item-qty {
    text-align: right;
    font-weight: var(--weight-body);
    color: var(--color-text-secondary);
    font-variant-numeric: tabular-nums;
}

.shopping-list-item-qty::before {
    content: '×';
    margin-right: 1px;
}

/* Per-row unit price (from products.js) — the most prominent text in the row.
   Italic/secondary only when missing. */
.shopping-list-item-price {
    flex-shrink: 0;
    margin-left: 24px;
    font-size: var(--font-size-heading);
    font-weight: var(--weight-heading);
    color: var(--color-text);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.shopping-list-item-price.is-unavailable {
    font-size: var(--font-size-caption);
    font-weight: var(--weight-body);
    font-style: italic;
    color: var(--color-text-secondary);
}

/* Narrow list (portrait / phones): a price column squeezes long product
   names onto three lines, so the price drops under the I/N code instead,
   with the quantity still centred on the right. */
.shopping-list {
    container-type: inline-size;
}

@container (max-width: 480px) {
    .shopping-list-item:has(.shopping-list-item-price) {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
    }

    .shopping-list-item-price {
        grid-column: 1;
        grid-row: 2;
        margin-left: 0;
        padding-top: 2px;
    }

    .shopping-list-item-qty {
        grid-column: 2;
        grid-row: 1 / span 2;
    }
}

/* ── Step 7 Bunnings order card, print row + stock notice ──
   From the "3rd Party Cart Transfer" supplier assets (Figma): a grey card
   holding the order copy and the two logo checkout buttons, a "Print Your
   Shopping List" row, then a pink stock-availability notice. Each
   paragraph is paired with the button it describes: stacked in a narrow
   card (Figma's mobile card), side by side once the card is wide enough
   (Figma's desktop card) — a container query, so it follows the card's
   own width in either orientation. Type is Bunnings' (Figma: Futura Std
   Heavy heading, Helvetica Neue body/buttons) rather than Stolzl — the
   card and notice redefine --font-family so every descendant rule that
   reads it picks up Helvetica Neue. Colours, sizes and radii follow the
   Figma. Vertical padding is set with the spacing rules above, which
   match the Step 7 zero-out's specificity. */
.shopping-order-card,
.shopping-stock-notice {
    --font-family: 'Helvetica Neue LT Std', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-family: var(--font-family);
}

.shopping-stock-notice {
    flex: none;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding-left: 16px;
    padding-right: 16px;
    border-radius: 4px;
    background: #fdd9d7;
    background-clip: padding-box;
    color: #333333;
    font-size: var(--font-size-body);
    font-weight: 400;   /* Helvetica Neue 55 Roman */
    line-height: 1.5;
}

.shopping-stock-notice-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: #da291c;
}

.shopping-order-card {
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-left: 24px;
    padding-right: 24px;
    border-radius: 4px;
    background: #f5f5f5;
    background-clip: padding-box;
    container-type: inline-size;
}

.shopping-order-card .shopping-subheading {
    font-size: 20px;
    font-family: 'Futura Std', Futura, var(--font-family);   /* Figma: Futura Std Heavy */
    font-weight: 700;   /* Bunnings brief: Bold / Heavy (overrides DA-02's 500) */
    line-height: 28px;
    letter-spacing: 0.25px;
    color: #0d5257;
}

/* Each paragraph sits directly above the button it describes, as in the
   Figma's narrow (mobile) card. */
.shopping-order-option {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

@container (min-width: 600px) {
    .shopping-order-option {
        flex-direction: row;
        align-items: center;
    }

    .shopping-order-option > p {
        flex: 1 1 0;
        min-width: 0;
    }

    .shopping-order-card .shopping-order-option .btn-checkout {
        flex: 0 0 270px;
        width: 270px;
    }
}

.shopping-order-card .shopping-body-text,
.shopping-order-card .shopping-small-print {
    font-size: 14px;
    font-weight: 400;   /* Helvetica Neue 55 Roman */
    line-height: 21px;
    letter-spacing: 0.175px;
    color: #333333;
}

.shopping-order-card .btn-checkout {
    height: 48px;
    gap: 8px;
    padding: 0 24px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 700;   /* Bunnings brief: bold label */
    letter-spacing: 0.175px;
}

.shopping-order-card .btn-checkout-red {
    background: #da291c;
    color: #ffffff;
}

.shopping-order-card .btn-checkout-orange {
    background: #ffab00;
    color: #333333;
}

.btn-checkout-logo {
    display: block;
    flex-shrink: 0;
}

/* "Print Your Shopping List" — downloads the PDF plan (same handler as
   Step 6's download button). Label + boxed printer icon, then the total,
   as in the Figma. */
.shopping-print-row {
    flex: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 12px 32px;
}

/* "Total (N items): $X" — sits after Print, as in the Figma. The amount is
   the headline; the item-count label is quieter. */
.shopping-list-total {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: var(--font-size-body);
    font-weight: var(--weight-body);
    color: var(--color-text-secondary);
}

.shopping-list-total-amount {
    font-size: var(--font-size-sheet-title);
    font-weight: var(--weight-sheet-title);
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.shopping-list-total-amount.is-unavailable {
    font-size: var(--font-size-body);
    font-weight: var(--weight-body);
    font-style: italic;
    color: var(--color-text-secondary);
}

.shopping-print-btn {
    flex: none;
    width: auto;
    height: auto;
    gap: 12px;
    padding: 0;
    background: transparent;
    border: none;
    font-family: var(--font-family);
    font-size: var(--font-size-body);
    font-weight: var(--weight-body);
    color: var(--color-text);
    cursor: pointer;
}

.shopping-print-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 2px solid currentColor;
}

.shopping-print-icon svg {
    width: 20px;
    height: 20px;
}

.shopping-print-btn:hover > span:first-child {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.shopping-print-btn:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

/* ══════════════════════════════════════════════════════════════
   Client corrections — Step 2 / Step 3 ("STEIN Last Corrections")
   Spacing is scoped to landscape (desktop), where the mock-ups were
   reviewed; portrait keeps its tighter vertical budget for the preview.
   ══════════════════════════════════════════════════════════════ */

/* More air in the header and around the pinned configuration. */
html.is-landscape {
    --gap-s2-01: calc(var(--space-6) + var(--space-1));   /* "STEP 2 OF 6" → heading */
    --gap-s3-01: calc(var(--space-6) + var(--space-1));
    --gap-s2-02: var(--space-2);   /* heading → subtitle */
    --gap-s3-02: var(--space-2);
    --gap-s2-03: var(--space-3);   /* subtitle → input */
    --gap-s3-03: var(--space-3);
    --gap-s2-08: var(--space-1);   /* config card → "View Other Options" (Step 2 + 3) */
    --gap-s2-09: var(--space-4);   /* "View Other Options" → Next — 16px, same as
                                      portrait, so Recommended Configurations sits on
                                      the Next / Back stack (was 48px). */

    /* The header above grows ~45px (gaps + 32px badge + 16px subtitle).
       Grow its cap and chrome by the same amount so the Best Match cards
       keep their height. */
    --step-header-max-height: calc(clamp(230px, 46vh, 410px) + 45px);
    --step-header-chrome-height: calc(112px + 45px);
}

/* Heading, subtitle and "View Other Options" start where the text inside
   the box below them starts (input inset 7px, config card inset 10px),
   rather than on the box's outer edge. */
.container:has(.step[data-step="2"].active) .step-header-above-preview .step-heading,
.container:has(.step[data-step="2"].active) .step-header-above-preview .step-subtitle,
.container:has(.step[data-step="3"].active) .step-header-above-preview .step-heading,
.container:has(.step[data-step="3"].active) .step-header-above-preview .step-subtitle {
    padding-left: calc(7px + var(--border-width));
}
.container:has(.step[data-step="2"].active) .view-other-options,
.container:has(.step[data-step="3"].active) .view-other-options {
    padding-left: calc(10px + var(--border-width));
}

/* Larger step badge + subtitle on desktop. */
html.is-landscape .step-header-above-preview .step-number-circle {
    width: var(--space-8);
    height: var(--space-8);
}
html.is-landscape .container:has(.step[data-step="2"].active) .step-header-above-preview .step-subtitle,
html.is-landscape .container:has(.step[data-step="3"].active) .step-header-above-preview .step-subtitle {
    font-size: var(--font-size-subhead);
}

/* Hinge-side toggle (Step 2 preview): larger copy and buttons. */
html.is-landscape .orientation-overlay__copy {
    font-size: var(--font-size-subhead);
}
html.is-landscape .orientation-option {
    height: var(--control-height);
    padding: 0 var(--space-3);
    gap: var(--space-2);
    font-size: var(--font-size-subhead);
}
html.is-landscape .orientation-option-check {
    width: var(--space-5);
    height: var(--space-5);
}
html.is-landscape .orientation-option-check svg {
    width: 14px;
    height: 14px;
}
