/* ==========================================================================
   SHOP.CSS — Shop & Checkout page styles
   Depends on: base.css, layout.css, style.css
   ========================================================================== */

/* Utility
   ========================================================================== */

/* Screenreader-only — visually hidden but accessible */
.hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Shop Layout
   ========================================================================== */

.shop {
    display: flex;
    flex-direction: row;
    gap: var(--padding-xl);
}

/* Override body font to Garamond for shop pages */
.shop,
html .shop,
body .shop {
    font-family: Garamond, Baskerville, "Baskerville Old Face", "Hoefler Text",
    "Times New Roman", serif;
}

/* Stocklist (content area)
   ========================================================================== */

.shop #content {
    flex: 1 1 70%;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    margin-top: 100px;
    margin-bottom: 50px;
    /* shop has its own column scroll — override layout.css desktop max-height */
    max-height: none;
}

.shop #content::after {
    background: linear-gradient(to bottom, transparent, var(--ground));
    bottom: 0;
    content: "";
    display: block;
    height: 50px;
    left: 0;
    pointer-events: none;
    position: sticky;
    width: 100%;
}

.shop #content p:last-child {
    margin-bottom: 0;
}

.item-content_long {
    display: flex;
    flex-direction: column;
    gap: var(--padding-md);
}

.item-images {
    display: flex;
    gap: var(--padding-md);
    max-height: 200px;
}

.item-images img {
    object-fit: cover;
    width: 50%;
}

/* Space between stocklist items */
.stocklist {
    display: flex;
    flex-direction: column;
    gap: var(--padding-xl);
}

/* Stocklist description — no trailing margin */
.stocklist_item > .description {
    margin-bottom: 0;
}

/* Cart — Desktop Sidebar
   ========================================================================== */

.cart {
    margin-top: var(--padding-xl);
    flex: 0 1 30%;
    min-width: 0; /* fixes blueprint style rule overflow */
    position: sticky;
    top: var(--padding-xl);
    align-self: flex-start;
}

.cart_content {
    align-items: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    max-height: 100vh;
}

/* Dividers */
.cart_divider {
    overflow: hidden;
    text-align: center;
    margin: 0;
    width: 100%;
}

.cart_divider-double::before,
.cart_divider::after {
    content: "******************************************************************************************";
    display: inline-block;
    overflow: hidden;
    text-overflow: clip;
    white-space: nowrap;
}

.cart_divider::after {
    padding-top: 0.5rem;
}

.cart-section_thankyou {
    text-transform: uppercase;
}

/* Cart items list */
.cart-section_items {
    align-items: flex-start;
    display: flex;
    flex-direction: column;
    gap: var(--padding-lg);
    margin: 40px 0;
    width: 80%;
    overflow-y: auto;
    max-height: 40vh;
    padding-bottom: var(--padding-lg);
    mask-image: linear-gradient(to bottom, black calc(100% - 40px), transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 40px), transparent 100%);
}

.cart-section_items .message_empty-cart {
    text-align: center;
}

.cart_item {
    width: 100%;
}

/* Totals */
.cart-section_calculations {
    align-items: center;
    display: flex;
    flex-direction: column;
    font-style: italic;
}

.cart_subtotal::before {
    content: "Subtotal £";
}

.cart_postage::before {
    content: "Postage £";
}

.cart_total::before {
    content: "TOTAL £";
}

.item_details {
    display: flex;
    justify-content: space-between;
}

.item_quantity a:hover {
    text-decoration: none;
}

.item_count::before {
    content: "x ";
}

.item_price::before {
    content: "£";
}

.cart-section_total {
    align-items: center;
    display: flex;
    flex-direction: column;
}

/* Cart close text link — hidden on desktop, shown in mobile overlay only */
.cart .link-back {
    display: none;
}

/* Cart — Mobile
   ========================================================================== */

/* Sticky bar at top of viewport — shown when cart has items */
.cart-bar {
    display: none; /* hidden on desktop */
}

/* Cart close controls — only shown on mobile */
.cart-close,
.action-close {
    display: none;
}

@media (max-width: 768px) {
    /* Switch shop from row to column layout */
    .shop {
        flex-direction: column;
    }

    .shop #content {
        flex: none;
        overflow-y: visible;
        margin-top: calc(var(--menu-bar-height) + var(--padding-xl));
    }

    .shop #content::after {
        display: none;
    }

    /* Cart becomes a full-screen overlay, slides up from below viewport */
    .cart {
        position: fixed;
        inset: 0;
        z-index: 80;
        background: var(--ground);
        overflow-y: auto;
        margin-top: 0;
        padding: var(--padding-xxxl) var(--container-pad);
        flex: none;
        display: flex;
        flex-direction: column;
        align-items: center;
        align-self: auto;
        min-height: 100vh;
        transform: translateY(100%);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        will-change: transform;
    }

    .cart.open {
        transform: translateY(0);
    }

    .cart_content {
        width: 100%;
        max-height: none;
        max-width: 600px;
    }

    .cart-section_items {
        max-height: none;
        width: 100%;
    }

    /* Back link for closing mobile cart */
    .cart .link-back {
        display: block;
        margin-top: var(--padding-xl);
    }

    /* Cart close controls visible on mobile */
    .action-close {
        display: block;
    }

    .cart-close {
        display: block;
        position: absolute;
        top: 20px;
        right: var(--container-pad);
        background: none;
        border: none;
        color: var(--accent);
        font-size: 1rem;
        line-height: 1;
        cursor: pointer;
        font-family: inherit;
        padding: 0;
    }

    .cart-close:hover {
        color: var(--figure);
    }

    /* Sticky cart bar — shown when cart has items */
    .cart-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 50;
        background: var(--figure);
        border: none;
        padding: var(--padding-md) var(--container-pad);
        align-items: center;
        justify-content: flex-end;
        gap: var(--padding-sm);
        color: var(--ground);
        font-style: italic;
        font-weight: var(--fw-bold);
        cursor: pointer;
    }

    .cart-bar_count {
        color: var(--accent);
    }

    .cart-bar::after {
        content: "\00bb";
        font-size: var(--fs-large);
        line-height: 1;
    }

    /* Push content down when cart bar is visible */
    .shop.has-items #content {
        margin-top: calc(60px + 44px); /* original top + cart bar height */
    }
}

/* Checkout
   ========================================================================== */

.shop.checkout #content {
    overflow-y: auto;
}

.checkout-form fieldset select {
    padding-right: 2rem;
}

.checkout-form fieldset.submit p {
    font-style: italic;
    margin: 0;
    max-width: 600px;
}

.checkout-form fieldset .form-field.required label::before {
    content: "* ";
}

.checkout-form .explainer {
    font-size: var(--fs-small);
}

.checkout-form .form-field.error {
    background: inherit;
    border: inherit;
    margin: inherit;
    padding: 0;
}

.checkout-form .error input,
.checkout-form .error select {
    border-color: var(--accent);
    background-color: var(--accent-tint);
}

