/* ============================================================================
 * Purbeck Ice Cream — theme stylesheet
 *
 * Brand colours and heading typography are owned here via unlayered `--brand-*`
 * declarations (§11.8.1) — they beat B2BWare → Store setup → Appearance. The
 * palette is documented in the repo root README.md.
 *
 * IMPORTANT: the layout loads exactly ONE theme stylesheet, resolved from the
 * ACTIVE theme (`@themeAsset('css/storefront.css')`). This file therefore
 * REPLACES the default theme's stylesheet rather than adding to it, so every
 * platform-level component rule the storefront relies on must live here too.
 * The "Platform component rules" block below is that carried-over set — keep it
 * byte-identical to the default theme's, or native form controls, modals and
 * the light/dark logo swap break on every page.
 *
 * Load order (layouts/shop.blade.php):
 *   1. base.css                     — prebuilt Tailwind + design tokens
 *   2. <style> tenant brand CSS     — Appearance (optional; theme owns palette)
 *   3. tenant font <link>s
 *   4. THIS FILE                    — brand tokens + layout/behaviour
 *   5. <style> per-customer category branding
 * ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap");

/* Brand identity — always dark (same values under :root and :root.dark so OS
 * light-mode visitors still get the dark storefront). See root README.md. */
:root,
:root.dark {
    /* Typography */
    --font-primary: "Poppins", -apple-system, BlinkMacSystemFont, sans-serif;

    /* Palette bases — full gold ramp so hover/active utilities (e.g.
     * hover:bg-primary-600) stay on-brand instead of the platform blue default. */
    --brand-color-primary-200: #c9bc78;
    --brand-color-primary-300: #d4c470;
    --brand-color-primary-400: #e2d078;
    --brand-color-primary-500: #deca5b;
    --brand-color-primary-600: #b8a34e;
    --brand-color-primary-700: #958540;
    --brand-color-primary-800: #726430;
    --brand-color-primary-content: #3e3919;

    --brand-color-secondary-400: #5a5a5a;
    --brand-color-secondary-500: #474747;
    --brand-color-secondary-600: #3a3a3a;
    --brand-color-secondary-700: #2e2e2e;
    --brand-color-secondary-800: #1e1e1e;
    --brand-color-secondary-content: #f5f3ee;

    --brand-color-surface-500: #2a2a2a;

    /* Dark-anchored subtle primary stops (§11.10) */
    --brand-color-primary-50: #252318;
    --brand-color-primary-100: #3a3524;

    /* Semantic text */
    --brand-color-headings: #f5f3ee;
    --brand-color-body: #d7d4cc;
    --brand-color-placeholder: #8a8579;

    /* Page chrome */
    --brand-color-surface-page: #0f0f0f;
    --brand-color-surface-card: #1e1e1e;

    /* Borders */
    --brand-color-border-subtle: #2a2a2a;
    --brand-color-border: #3a3a3a;

    /* Form inputs */
    --brand-color-surface-input: #1a1a1a;
    --brand-color-surface-input-content: #f5f3ee;
    --brand-color-surface-input-placeholder: #8a8579;
    --brand-color-surface-input-stroke: #3a3a3a;

    /* Disabled */
    --brand-color-surface-disabled: #242424;
    --brand-color-surface-disabled-content: #6e6e6e;
    --brand-color-surface-disabled-stroke: #333333;

    /* Tooltip */
    --brand-color-tooltip: #f5f3ee;
    --brand-color-tooltip-content: #1e1e1e;

    /* Native controls + scrollbars */
    color-scheme: dark;
}

/* WebKit can retain a dark native date-picker glyph even when the control is
 * dark-themed. Draw a visible calendar while retaining its native, clickable
 * picker trigger for the API-key expiry field. */
.storefront input[type="date"] {
    padding-right: 2.75rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f5f3ee' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='17' rx='2'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.125rem;
}

.storefront input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0;
}

/* ============================================================================
 * Platform component rules — carried over because this file replaces the
 * default theme's stylesheet (see the note at the top).
 * ========================================================================== */

/* Light/dark asset swaps -----------------------------------------------------
 * The logo (header, footer, login) ships a light and a dark variant in the
 * markup; CSS shows the one matching the active `.dark` root class. A logo with
 * no dark variant ships no `--light` class, so it stays visible in both. */
.storefront-logo--dark { display: none; }
:root.dark .storefront-logo--light { display: none; }
:root.dark .storefront-logo--dark { display: block; }

.theme-toggle__to-light { display: none; }
:root.dark .theme-toggle__to-dark { display: none; }
:root.dark .theme-toggle__to-light { display: inline-flex; }

/* Form controls — checkboxes ------------------------------------------------
 * base.css ships native checkboxes, which read small and inconsistent. Re-skin
 * every storefront checkbox to a 24px rounded box that fills with the brand
 * primary. `:not(.sr-only)` leaves visually-hidden checkboxes (switch peers)
 * untouched. */
.storefront input[type="checkbox"]:not(.sr-only) {
    appearance: none;
    -webkit-appearance: none;
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    margin: 0;
    padding: 0;
    border: 1px solid var(--color-border-subtle);
    border-radius: 0.375rem;
    background-color: var(--color-surface-card);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.storefront input[type="checkbox"]:not(.sr-only):checked {
    border-color: var(--color-primary);
    background-color: var(--color-primary);
}

/* The check is masked rather than baked into the data URI so its colour comes
 * from --color-primary-content: a hardcoded white glyph disappears on a light
 * brand colour (a gold primary scores 1.65:1 against white). */
.storefront input[type="checkbox"]:not(.sr-only):checked::after {
    content: "";
    display: block;
    width: 100%;
    height: 100%;
    background-color: var(--color-primary-content);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M3.5 8.5l3 3 6-6'/%3E%3C/svg%3E") center / 1rem no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M3.5 8.5l3 3 6-6'/%3E%3C/svg%3E") center / 1rem no-repeat;
}

.storefront input[type="checkbox"]:not(.sr-only):focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.storefront input[type="checkbox"]:not(.sr-only):disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* Form controls — radio buttons --------------------------------------------- */
.storefront input[type="radio"]:not(.sr-only) {
    appearance: none;
    -webkit-appearance: none;
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    margin: 0;
    padding: 0;
    border: 1px solid var(--color-border-subtle);
    border-radius: 9999px;
    background-color: var(--color-surface-card);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.storefront input[type="radio"]:not(.sr-only):checked {
    border-color: var(--color-primary);
    background-color: var(--color-primary);
}

/* Masked for the same contrast reason as the checkbox check above. */
.storefront input[type="radio"]:not(.sr-only):checked::after {
    content: "";
    display: block;
    width: 100%;
    height: 100%;
    background-color: var(--color-primary-content);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='4.5' fill='black'/%3E%3C/svg%3E") center / 1rem no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='4.5' fill='black'/%3E%3C/svg%3E") center / 1rem no-repeat;
}

.storefront input[type="radio"]:not(.sr-only):focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.storefront input[type="radio"]:not(.sr-only):disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* Form controls — select / dropdown -----------------------------------------
 * Replace the native arrow with a consistently sized, inset chevron.
 * `padding-right` reserves space so option text never overlaps it; the
 * selector's specificity outranks Tailwind's `px-*` utilities. The chevron
 * greys are the platform's own (carried over verbatim from the default theme),
 * not a Purbeck colour choice. */
.storefront select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234b5563' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.125rem;
    padding-right: 2.5rem;
    cursor: pointer;
}

:root.dark .storefront select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

/* Form controls — toggle switch (.sf-switch) --------------------------------
 * A pill switch built from an .sr-only native checkbox plus a track whose
 * ::after knob slides on :checked. Used by the catalog-export column picker. */
.sf-switch {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    cursor: pointer;
}

.sf-switch__track {
    position: relative;
    flex-shrink: 0;
    width: 2.25rem;
    height: 1.25rem;
    border-radius: 9999px;
    background-color: var(--color-border-subtle);
    transition: background-color 0.15s ease;
}

.sf-switch__track::after {
    content: "";
    position: absolute;
    top: 0.125rem;
    left: 0.125rem;
    width: 1rem;
    height: 1rem;
    border-radius: 9999px;
    background-color: var(--color-surface-card);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.15);
    transition: transform 0.15s ease;
}

.sf-switch input:checked + .sf-switch__track {
    background-color: var(--color-primary);
}

/* The knob rides ON the primary track once checked, so it takes the paired
 * foreground — a fixed white knob vanishes on a light brand colour. */
.sf-switch input:checked + .sf-switch__track::after {
    background-color: var(--color-primary-content);
    transform: translateX(1rem);
}

.sf-switch input:focus-visible + .sf-switch__track {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.sf-switch input:disabled + .sf-switch__track {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Catalog-export preview table ---------------------------------------------- */
.sf-preview-table {
    border-collapse: collapse;
}

.sf-preview-table th,
.sf-preview-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--color-border-subtle);
    text-align: left;
    vertical-align: top;
}

.sf-preview-table thead th {
    font-weight: 600;
    color: var(--color-headings);
    white-space: nowrap;
}

.sf-preview-table tbody td {
    color: var(--color-body);
}

.sf-preview-table tbody tr:last-child td {
    border-bottom: 0;
}

/* Native <dialog> centering -------------------------------------------------
 * Tailwind's Preflight `* { margin: 0 }` beats the user-agent
 * `dialog { margin: auto }`, so every showModal() dialog would pin to the
 * top-left corner. base.css does NOT ship this rule — every theme must
 * re-declare it. */
dialog {
    margin: auto;
}

/* Checkout "deliver to my billing address" toggle ---------------------------- */
.checkout__panel:has(.checkout__same-cb:checked) .checkout__delivery-body {
    display: none;
}

/* Hidden scrollbars — rows that ship their own arrow controls ---------------- */
.storefront-nav__links {
    scrollbar-width: none;
}

.storefront-nav__links::-webkit-scrollbar {
    display: none;
}

.product-gallery__thumbs {
    scrollbar-width: none;
}

.product-gallery__thumbs::-webkit-scrollbar {
    display: none;
}

/* ============================================================================
 * Purbeck header, drawer and search sheet
 *
 * Layout and behaviour only. The header sits on `bg-secondary-800`, so its
 * foreground uses `--color-secondary-content` (the platform's auto-derived
 * readable pair for the secondary colour) rather than a hardcoded white.
 * ========================================================================== */

.purbeck-header {
    box-shadow: 0 1px 0 color-mix(in srgb, var(--color-secondary-content) 6%, transparent);
}

.purbeck-brand {
    display: inline-flex;
    align-items: center;
}

/* Hard cap the logo box here rather than with a utility: the tenant uploads
 * arbitrarily large logo files, and base.css is prebuilt so only the utility
 * sizes the default theme already uses exist. */
.purbeck-brand img {
    max-height: 2.75rem;
    max-width: 13rem;
    width: auto;
    object-fit: contain;
}

.purbeck-desktop-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-left: 1rem;
}

.purbeck-nav-link {
    position: relative;
    padding: 0.5rem 0.125rem;
    color: var(--color-secondary-content);
    font-size: 0.9375rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}

.purbeck-nav-link:hover {
    color: var(--color-secondary-content);
    opacity: 0.85;
    text-decoration: none;
}

.purbeck-nav-link.is-active::after {
    position: absolute;
    right: 0;
    bottom: -0.25rem;
    left: 0;
    height: 0.1875rem;
    border-radius: 9999px;
    background: var(--color-primary);
    content: "";
}

.purbeck-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.purbeck-search {
    display: flex;
    align-items: center;
    width: clamp(11rem, 24vw, 20rem);
    padding: 0 0.5rem 0 1rem;
    border: 1px solid color-mix(in srgb, var(--color-secondary-content) 18%, transparent);
    border-radius: 9999px;
    background: color-mix(in srgb, var(--color-secondary-content) 6%, transparent);
}

.purbeck-search:focus-within {
    border-color: var(--color-primary);
    background: color-mix(in srgb, var(--color-secondary-content) 10%, transparent);
}

.purbeck-search input {
    min-width: 0;
    flex: 1;
    height: 2.25rem;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--color-secondary-content);
    font-size: 0.875rem;
}

.purbeck-search input::placeholder {
    color: color-mix(in srgb, var(--color-secondary-content) 55%, transparent);
}

.purbeck-search-submit,
.purbeck-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.375rem;
    height: 2.375rem;
    border: 0;
    border-radius: 9999px;
    background: transparent;
    color: var(--color-secondary-content);
    cursor: pointer;
}

.purbeck-search-submit {
    width: 1.875rem;
    height: 1.875rem;
}

.purbeck-search-submit:hover,
.purbeck-icon-button:hover {
    color: var(--color-primary);
    background: color-mix(in srgb, var(--color-secondary-content) 8%, transparent);
}

.purbeck-cart-count {
    position: absolute;
    top: -0.125rem;
    right: -0.125rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.125rem;
    height: 1.125rem;
    padding: 0 0.25rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 700;
    line-height: 1;
}

.purbeck-admin-link {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--color-primary);
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-primary);
    text-decoration: none;
    white-space: nowrap;
}

.purbeck-admin-link:hover {
    background: var(--color-primary);
    color: var(--color-primary-content);
    text-decoration: none;
}

.purbeck-admin-link__label {
    display: none;
}

.purbeck-account-menu {
    position: relative;
}

.purbeck-account-trigger {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem;
    color: var(--color-secondary-content);
    cursor: pointer;
    list-style: none;
}

.purbeck-account-trigger::-webkit-details-marker {
    display: none;
}

.purbeck-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    font-size: 0.8125rem;
    font-weight: 700;
}

.purbeck-account-panel {
    position: absolute;
    top: calc(100% + 0.625rem);
    right: 0;
    z-index: 70;
    width: 15rem;
    overflow: hidden;
    border-radius: 0.5rem;
    box-shadow: 0 1rem 2rem color-mix(in srgb, var(--color-backdrop) 28%, transparent);
}

.purbeck-menu-item {
    display: block;
    padding: 0.625rem 0.75rem;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 0.875rem;
    text-decoration: none;
    cursor: pointer;
}

.purbeck-menu-item:hover {
    background: var(--color-surface-hover);
    color: var(--color-primary);
    text-decoration: none;
}

.purbeck-mobile-only,
.purbeck-mobile-search-button {
    display: none;
}

.purbeck-drawer,
.purbeck-search-sheet {
    position: fixed;
    inset: 0;
    z-index: 80;
    visibility: hidden;
    pointer-events: none;
}

.purbeck-drawer.is-open,
.purbeck-search-sheet.is-open {
    visibility: visible;
    pointer-events: auto;
}

.purbeck-drawer-backdrop,
.purbeck-search-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: color-mix(in srgb, var(--color-backdrop) 55%, transparent);
    opacity: 0;
    transition: opacity 180ms ease;
}

.purbeck-drawer.is-open .purbeck-drawer-backdrop,
.purbeck-search-sheet.is-open .purbeck-search-backdrop {
    opacity: 1;
}

.purbeck-drawer-panel {
    position: absolute;
    inset: 0 auto 0 0;
    display: flex;
    width: min(20rem, 86vw);
    flex-direction: column;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 220ms ease;
}

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

.purbeck-drawer-link {
    display: block;
    padding: 0.6875rem 0.75rem;
    border-radius: 0.5rem;
    color: var(--color-secondary-content);
    font-size: 0.9375rem;
    font-weight: 500;
    text-decoration: none;
}

.purbeck-drawer-link:hover {
    background: color-mix(in srgb, var(--color-secondary-content) 8%, transparent);
    color: var(--color-primary);
    text-decoration: none;
}

.purbeck-search-sheet {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1rem;
}

.purbeck-search-sheet-panel {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: min(40rem, 100%);
    padding: 0.5rem;
    border-radius: 0.75rem;
    opacity: 0;
    transform: translateY(-0.75rem);
    transition: opacity 180ms ease, transform 180ms ease;
}

.purbeck-search-sheet.is-open .purbeck-search-sheet-panel {
    opacity: 1;
    transform: translateY(0);
}

.purbeck-search-sheet .purbeck-search {
    width: auto;
    flex: 1;
}

:root.purbeck-overlay-open {
    overflow: hidden;
}

.purbeck-home-table {
    min-width: 56rem;
}

@media (max-width: 64rem) {
    .purbeck-desktop-nav {
        display: none;
    }

    .purbeck-mobile-only {
        display: inline-flex;
    }
}

@media (min-width: 48rem) {
    .purbeck-admin-link {
        display: inline-flex;
    }
}

@media (min-width: 64rem) {
    .purbeck-admin-link__label {
        display: inline;
    }
}

@media (max-width: 40rem) {
    .purbeck-header > div {
        gap: 0.375rem;
        padding: 0.5rem 0.75rem;
    }

    .purbeck-desktop-search,
    .purbeck-desktop-locale {
        display: none;
    }

    .purbeck-mobile-search-button {
        display: inline-flex;
    }

    .purbeck-brand img {
        max-height: 2.25rem;
        max-width: 8rem;
    }

    .purbeck-header-actions {
        gap: 0.125rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .purbeck-drawer-backdrop,
    .purbeck-search-backdrop,
    .purbeck-drawer-panel,
    .purbeck-search-sheet-panel {
        transition: none;
    }
}
