/* Phase 1 redesign foundation: intentionally scoped to the storefront shell. */
:root {
    --rd-canvas: #faf7f2;
    --rd-canvas-subtle: #f8f3ed;
    --rd-surface: #ffffff;
    --rd-surface-subtle: #fffdf9;
    --rd-surface-warm: #fffaf5;
    --rd-surface-muted: #f5f3f1;
    --rd-surface-section: #f8f1ea;
    --rd-text: #241a15;
    --rd-text-warm: #382a23;
    --rd-text-soft: #4d4038;
    --rd-text-secondary: #746a63;
    --rd-text-muted: #7b6e65;
    --rd-border: #e8e0d8;
    --rd-border-subtle: #eee8e2;
    --rd-border-strong: #d9ccbf;
    --rd-border-section: #dfd4c9;
    --rd-sand: #efe5d8;
    --rd-brand: #5a3828;
    --rd-brand-soft: #684431;
    --rd-brand-hover: #472b20;
    --rd-brand-active: #43291e;
    --rd-on-brand: #ffffff;
    --rd-accent: #c86636;
    --rd-focus-ring: rgba(200, 102, 54, .12);
    --rd-surface-inverse: #24150e;
    --rd-text-inverse: #faf7f2;
    --rd-text-inverse-soft: rgba(250, 247, 242, .76);
    --rd-text-inverse-muted: rgba(250, 247, 242, .7);
    --rd-text-inverse-subtle: rgba(250, 247, 242, .52);
    --rd-border-inverse: rgba(250, 247, 242, .14);
    --rd-action-disabled: #a89589;
    --rd-success: var(--color-success, #19713f);
    --rd-success-strong: #12623a;
    --rd-success-text: #2f6b3b;
    --rd-success-surface: #edf6ef;
    --rd-success-surface-subtle: #edf4ee;
    --rd-success-surface-highlight: #edf8f2;
    --rd-success-border: #d4e4d8;
    --rd-warning: var(--color-warning, #7a4600);
    --rd-warning-text-soft: #7a5314;
    --rd-warning-text: #74502f;
    --rd-warning-surface: #f3e7d5;
    --rd-warning-surface-highlight: #fffaeb;
    --rd-warning-border: #e4d2b8;
    --rd-danger: var(--color-danger, #b42318);
    --rd-danger-text: #8c453c;
    --rd-danger-strong: #a43a32;
    --rd-danger-surface: #f9ecea;
    --rd-danger-status-text: #963f39;
    --rd-danger-border: #edd2cf;
    --rd-info: var(--color-info, #175b8f);
    --rd-space-1: 4px;
    --rd-space-2: 8px;
    --rd-space-3: 12px;
    --rd-space-4: 16px;
    --rd-space-6: 24px;
    --rd-space-8: 32px;
    --rd-radius-sm: 8px;
    --rd-radius-md: 12px;
    --rd-radius-lg: 18px;
    --rd-shadow-header: 0 8px 24px rgba(36, 26, 21, .055);
    --rd-transition: 160ms ease;
}

body {
    background-color: var(--rd-canvas);
    color: var(--rd-text);
}

.topbar {
    background: var(--rd-brand);
    color: var(--rd-text-inverse);
    font-size: .78rem;
    padding: 6px 0;
}
.topbar-inner { align-items: center; display: flex; justify-content: flex-start; }
.topbar-inner span { align-items: center; display: inline-flex; gap: var(--rd-space-2); }

.site-header {
    background: color-mix(in srgb, var(--rd-canvas) 96%, transparent);
    border-bottom: 1px solid var(--rd-border);
    box-shadow: var(--rd-shadow-header);
    color: var(--rd-text);
    position: sticky;
    top: 0;
    z-index: 1030;
}
.header-main { background: color-mix(in srgb, var(--rd-canvas) 96%, transparent); backdrop-filter: blur(12px); }
.header-main-inner {
    align-items: center;
    display: grid;
    gap: 28px;
    grid-template-columns: auto minmax(280px, 1fr) auto;
    min-height: 82px;
}
.navbar-brand { align-items: center; color: var(--rd-text); display: inline-flex; gap: 14px; margin: 0; min-width: max-content; }
.navbar-brand:hover { color: var(--rd-text); }
.brand-icon { border-radius: var(--rd-radius-md); height: 52px; object-fit: cover; width: 52px; }
.brand-copy { display: grid; line-height: 1.25; }
.brand-title { color: var(--rd-text); font-size: 1.3rem; font-weight: 850; letter-spacing: -.04em; }
.brand-sub { color: var(--rd-text-secondary); font-size: .76rem; margin-top: 4px; }

.header-search {
    align-items: center;
    background: var(--rd-surface);
    border: 1px solid var(--rd-border);
    border-radius: var(--rd-radius-md);
    display: flex;
    gap: var(--rd-space-3);
    height: 48px;
    max-width: 680px;
    padding-inline: var(--rd-space-3) var(--rd-space-4);
    position: relative;
    transition: border-color var(--rd-transition), box-shadow var(--rd-transition);
    width: 100%;
}
.header-search:focus-within { border-color: var(--rd-accent); box-shadow: 0 0 0 3px var(--rd-focus-ring); }
.header-search-submit {
    align-items: center;
    align-self: auto;
    background: transparent;
    border: 0;
    border-radius: var(--rd-radius-sm);
    color: var(--rd-text-secondary);
    display: inline-flex;
    flex: 0 0 32px;
    height: 32px;
    justify-content: center;
    margin: 0;
    min-width: 32px;
    padding: 0;
    transition: background-color var(--rd-transition), color var(--rd-transition);
}
.header-search-submit:hover { background: var(--rd-sand); color: var(--rd-brand); }
.header-search-submit i { font-size: 1.08rem; }
.header-search input,
.header-search input:focus {
    background: transparent;
    border: 0;
    box-shadow: none;
    color: var(--rd-text);
    flex: 1;
    min-height: 0;
    min-width: 0;
    outline: 0;
    padding: 0;
}
.header-search input::placeholder { color: var(--rd-text-secondary); }
.header-search-panel {
    background: var(--rd-surface);
    border: 1px solid var(--rd-border);
    border-radius: var(--rd-radius-md);
    box-shadow: 0 14px 34px rgba(36, 26, 21, .09);
    left: 0;
    max-height: min(420px, calc(100vh - 180px));
    overflow-y: auto;
    padding: var(--rd-space-2);
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 1060;
}
.header-search-panel[hidden] { display: none; }
.search-suggestion {
    align-items: center;
    border-radius: var(--rd-radius-sm);
    color: var(--rd-text);
    display: grid;
    gap: var(--rd-space-3);
    grid-template-columns: 52px minmax(0, 1fr) auto;
    min-height: 64px;
    padding: var(--rd-space-2);
    transition: background-color var(--rd-transition);
}
.search-suggestion:hover,
.search-suggestion:focus-visible { background: var(--rd-canvas); color: var(--rd-text); }
.search-suggestion + .search-suggestion { border-top: 1px solid var(--rd-border); }
.search-suggestion img { background: var(--rd-canvas); border-radius: var(--rd-radius-sm); height: 52px; object-fit: contain; width: 52px; }
.search-suggestion-copy { display: grid; gap: 3px; min-width: 0; }
.search-suggestion-name { font-size: .88rem; font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-suggestion-variant { color: var(--rd-text-secondary); font-size: .72rem; }
.search-suggestion-price { display: grid; font-size: .78rem; font-weight: 750; justify-items: end; white-space: nowrap; }
.search-suggestion-price del { color: var(--rd-text-secondary); font-size: .68rem; font-weight: 500; }
.search-suggestion-state { align-items: center; color: var(--rd-text-secondary); display: flex; font-size: .82rem; gap: var(--rd-space-2); justify-content: center; min-height: 64px; padding: var(--rd-space-3); text-align: center; }
.search-suggestion-state i { color: var(--rd-accent); }
.active-header-search.is-loading .header-search-submit i { animation: searchPulse .8s ease-in-out infinite alternate; }
@keyframes searchPulse { to { opacity: .35; transform: scale(.9); } }

/* Product card redesign: scoped here to avoid refactoring legacy card rules. */
.product-card {
    background: var(--rd-surface);
    border: 1px solid var(--rd-border);
    border-radius: var(--rd-radius-lg);
    box-shadow: none;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    transition: border-color var(--rd-transition), box-shadow var(--rd-transition), transform var(--rd-transition);
}
.product-card:hover {
    border-color: var(--rd-sand);
    box-shadow: var(--rd-shadow-header);
    transform: translateY(-2px);
}
.product-card .product-img {
    aspect-ratio: 1;
    background: var(--rd-canvas);
    display: block;
    overflow: hidden;
    position: relative;
}
.product-card .product-img img {
    height: 100%;
    object-fit: contain;
    padding: var(--rd-space-3);
    transition: transform var(--rd-transition);
    width: 100%;
}
.product-card:hover .product-img img { transform: scale(1.015); }
.product-card .badge-soft {
    background: var(--rd-sand);
    border: 1px solid var(--rd-border);
    border-radius: 999px;
    color: var(--rd-accent);
    font-size: .68rem;
    font-weight: 700;
    padding: 4px 8px;
    position: absolute;
    right: var(--rd-space-3);
    top: var(--rd-space-3);
    z-index: 1;
}
.product-card .product-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--rd-space-3);
    padding: var(--rd-space-4);
}
.product-card .product-title {
    color: var(--rd-text);
    display: -webkit-box;
    font-size: 1rem;
    font-weight: 650;
    letter-spacing: -.015em;
    line-height: 1.7;
    margin: 0;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}
.product-card .product-title a { color: inherit; }
.product-card .product-title a:hover { color: var(--rd-brand); }
.product-card .product-features {
    color: var(--rd-text-secondary);
    display: flex;
    flex-wrap: wrap;
    font-size: .75rem;
    gap: var(--rd-space-2);
    list-style: none;
    margin: 0;
    padding: 0;
}
.product-card .product-features li { display: inline; }
.product-card .product-features li + li::before { color: var(--rd-border); content: "•"; margin-inline-end: var(--rd-space-2); }
.product-card .product-purchase { display: grid; gap: var(--rd-space-3); margin-top: auto; min-width: 0; }
.product-card .product-price-block { align-content: end; display: grid; }
.product-card .price { color: var(--rd-text); font-size: 1.12rem; font-weight: 850; letter-spacing: -.02em; line-height: 1.45; }
.product-card .price small { color: var(--rd-text-secondary); font-size: .7rem; font-weight: 550; }
.product-card .old { color: var(--rd-text-secondary); font-size: .72rem; line-height: 1.35; text-decoration: line-through; }
.product-card .product-price-note,
.product-card .product-price-context { color: var(--rd-text-secondary); font-size: .72rem; line-height: 1.55; }
.product-card .product-price-context { margin-top: 2px; }
.product-card .product-action { min-width: 0; }
.product-card .add-btn {
    align-items: center;
    background: var(--rd-brand);
    border: 1px solid var(--rd-brand);
    border-radius: var(--rd-radius-md);
    box-shadow: none;
    color: var(--rd-on-brand);
    display: inline-flex;
    font-size: .82rem;
    font-weight: 700;
    gap: var(--rd-space-2);
    height: 42px;
    justify-content: center;
    min-height: 42px;
    padding: 0 var(--rd-space-3);
    transition: background-color var(--rd-transition), border-color var(--rd-transition), color var(--rd-transition);
    width: 100%;
}
.product-card .add-btn span { display: inline; }
.product-card .add-btn:hover { background: var(--rd-accent); border-color: var(--rd-accent); color: var(--rd-on-brand); transform: none; }
.product-card .variant-btn { background: var(--rd-surface); color: var(--rd-brand); }
.product-card .variant-btn:hover { background: var(--rd-sand); border-color: var(--rd-brand); color: var(--rd-brand); }
.product-card .product-stock-state {
    align-items: center;
    background: var(--rd-canvas);
    border: 1px solid var(--rd-border);
    border-radius: var(--rd-radius-md);
    color: var(--rd-text-secondary);
    display: flex;
    font-size: .78rem;
    font-weight: 650;
    gap: var(--rd-space-2);
    height: 42px;
    justify-content: center;
    width: 100%;
}
.product-card.is-unavailable .product-img img { opacity: .72; }

/* Mobile category controls and Bootstrap-backed filter bottom sheet. */
.mobile-listing-controls { display: none; }
@media (max-width: 991.98px) {
    .product-listing-page { padding-bottom: 72px; }
    .category-filter-panel.offcanvas-bottom {
        --bs-offcanvas-height: 88vh;
        background: var(--rd-surface);
        border: 1px solid var(--rd-border);
        border-bottom: 0;
        border-radius: var(--rd-radius-lg) var(--rd-radius-lg) 0 0;
        max-height: 88vh;
        overflow: hidden;
    }
    .category-filter-panel .filter-sheet-handle {
        background: var(--rd-border);
        border-radius: 999px;
        height: 4px;
        margin: var(--rd-space-2) auto 0;
        width: 42px;
    }
    .category-filter-panel .offcanvas-header { padding: var(--rd-space-2) var(--rd-space-4) var(--rd-space-3); }
    .category-filter-panel .offcanvas-body { display: flex; min-height: 0; overflow: hidden; padding: 0 var(--rd-space-4); }
    .category-filter-panel .category-tools {
        display: flex;
        flex: 1;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
        padding: 0;
    }
    .category-filter-panel .filter-select-label,
    .category-filter-panel #category-sort { flex: 0 0 auto; }
    .category-filter-panel .category-filter-scroll {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding-bottom: calc(88px + env(safe-area-inset-bottom));
        scrollbar-gutter: stable;
    }
    .category-filter-panel .category-filter-actions {
        background: var(--rd-surface);
        border-top: 1px solid var(--rd-border);
        bottom: 0;
        box-shadow: 0 -8px 22px rgba(36, 26, 21, .06);
        inset-inline: 0;
        margin: 0;
        padding: var(--rd-space-3) var(--rd-space-4) calc(var(--rd-space-3) + env(safe-area-inset-bottom));
        position: fixed;
        z-index: 1050;
    }
    .category-sort-sheet.offcanvas-bottom {
        --bs-offcanvas-height: auto;
        background: var(--rd-surface);
        border: 1px solid var(--rd-border);
        border-bottom: 0;
        border-radius: var(--rd-radius-lg) var(--rd-radius-lg) 0 0;
        max-height: min(70vh, 430px);
    }
    .category-sort-sheet .filter-sheet-handle {
        background: var(--rd-border);
        border-radius: 999px;
        height: 4px;
        margin: var(--rd-space-2) auto 0;
        width: 42px;
    }
    .category-sort-sheet .offcanvas-header { padding: var(--rd-space-2) var(--rd-space-4) var(--rd-space-3); }
    .category-sort-sheet .offcanvas-body {
        display: grid;
        gap: var(--rd-space-2);
        padding: 0 var(--rd-space-4) calc(var(--rd-space-4) + env(safe-area-inset-bottom));
    }
    .category-sort-option {
        align-items: center;
        background: transparent;
        border: 1px solid var(--rd-border);
        border-radius: var(--rd-radius-md);
        color: var(--rd-text);
        display: flex;
        font-weight: 650;
        justify-content: space-between;
        min-height: 46px;
        padding: var(--rd-space-2) var(--rd-space-3);
        text-align: start;
    }
    .category-sort-option[aria-pressed="true"] { background: var(--rd-sand); border-color: var(--rd-brand); color: var(--rd-brand); }
    .category-sort-option[aria-pressed="true"]::after { content: "✓"; font-weight: 800; }
    .mobile-listing-controls {
        background: color-mix(in srgb, var(--rd-surface) 97%, transparent);
        border: 1px solid var(--rd-border);
        border-radius: var(--rd-radius-md);
        bottom: max(12px, env(safe-area-inset-bottom));
        box-shadow: var(--rd-shadow-header);
        display: grid;
        gap: var(--rd-space-2);
        grid-template-columns: repeat(2, minmax(0, 1fr));
        left: max(var(--rd-space-3), env(safe-area-inset-left));
        padding: var(--rd-space-2);
        position: fixed;
        right: max(var(--rd-space-3), env(safe-area-inset-right));
        z-index: 1025;
    }
    .mobile-listing-controls button {
        align-items: center;
        background: transparent;
        border: 0;
        border-radius: var(--rd-radius-sm);
        color: var(--rd-text);
        display: flex;
        font-size: .82rem;
        font-weight: 700;
        gap: var(--rd-space-2);
        justify-content: center;
        min-height: 42px;
        padding-inline: var(--rd-space-3);
    }
    .mobile-listing-controls button + button { border-inline-start: 1px solid var(--rd-border); border-radius: 0; }
    .mobile-listing-controls i { color: var(--rd-brand); font-size: 1rem; }
    .mobile-listing-controls .filter-active-count { background: var(--rd-sand); color: var(--rd-brand); }
}
@media (max-width: 767.98px) {
    .category-filter-panel .category-filter-scroll {
        padding-bottom: calc(164px + env(safe-area-inset-bottom));
    }
    .category-filter-panel .category-filter-actions {
        bottom: calc(76px + env(safe-area-inset-bottom));
        padding-bottom: var(--rd-space-3);
    }
    .mobile-listing-controls { bottom: calc(76px + env(safe-area-inset-bottom)); }
}

.header-actions { align-items: center; display: flex; flex-shrink: 0; gap: var(--rd-space-3); }
.header-account,
.header-cart,
.header-menu-toggle {
    align-items: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--rd-radius-md);
    color: var(--rd-text);
    display: inline-flex;
    gap: 10px;
    height: 46px;
    justify-content: center;
    padding: 0 14px;
    transition: background-color var(--rd-transition), border-color var(--rd-transition), color var(--rd-transition);
}
.header-account:hover,
.header-cart:hover,
.header-menu-toggle:hover { background: var(--rd-sand); border-color: var(--rd-border); color: var(--rd-brand); }
.header-account { font-size: .92rem; font-weight: 650; }
.header-account .account-chevron { font-size: .65rem; }
.header-cart { position: relative; }
.header-cart > span { font-size: .92rem; font-weight: 650; }
.header-cart > i,
.header-menu-toggle > i { font-size: 1.32rem; }
.header-cart b {
    align-items: center;
    background: var(--rd-accent);
    border: 2px solid var(--rd-canvas);
    border-radius: 999px;
    color: var(--rd-on-brand);
    display: flex;
    font-size: .62rem;
    height: 19px;
    justify-content: center;
    min-width: 19px;
    padding: 0 4px;
    position: absolute;
    right: 0;
    top: -2px;
}
.account-menu { border: 1px solid var(--rd-border); border-radius: var(--rd-radius-md); box-shadow: 0 14px 36px rgba(36, 26, 21, .1); min-width: 210px; padding: var(--rd-space-2); }
.account-menu .dropdown-item { border-radius: var(--rd-radius-sm); color: var(--rd-text); padding: 9px 10px; }
.account-menu .dropdown-item:hover { background: var(--rd-sand); }
.panel-menu-entry { align-items: center; display: flex; gap: var(--rd-space-2); }

.header-navigation { background: var(--rd-surface); border-top: 1px solid var(--rd-border); }
.coffee-main-nav { display: flex; gap: 38px; list-style: none; margin: 0; padding: 0; }
.coffee-main-nav a { color: var(--rd-text-secondary); display: block; font-size: .95rem; font-weight: 650; padding: 12px 0; position: relative; }
.coffee-main-nav a::after { background: var(--rd-accent); bottom: -1px; content: ""; height: 2px; inset-inline: 50%; position: absolute; transition: inset-inline var(--rd-transition); }
.coffee-main-nav a:hover,
.coffee-main-nav a.active { color: var(--rd-text); }
.coffee-main-nav a:hover::after,
.coffee-main-nav a.active::after { inset-inline: 0; }

.header-mobile-search { padding-bottom: var(--rd-space-3); }
.header-mobile-menu { background: var(--rd-surface); border-top: 1px solid var(--rd-border); }
.header-mobile-menu .container-xxl { display: grid; padding-block: var(--rd-space-2); }
.header-mobile-menu a { align-items: center; border-radius: var(--rd-radius-sm); color: var(--rd-text); display: flex; gap: var(--rd-space-3); min-height: 44px; padding: 8px 10px; }
.header-mobile-menu a:hover { background: var(--rd-sand); }
.header-mobile-menu .mobile-panel-entry { border-top: 1px solid var(--rd-border); border-radius: 0; color: var(--rd-brand); margin-top: var(--rd-space-2); }

@media (max-width: 991.98px) {
    .topbar,
    .header-navigation { display: none; }
    .header-main-inner { gap: var(--rd-space-3); grid-template-columns: 44px minmax(0, 1fr) 44px; min-height: 66px; }
    .header-main-inner .navbar-brand { justify-self: center; }
    .header-main-inner .header-actions { justify-self: end; }
    .header-menu-toggle,
    .header-cart { height: 44px; padding: 0; width: 44px; }
    .header-cart b { right: -3px; }
    .brand-icon { height: 40px; width: 40px; }
    .brand-title { font-size: 1.05rem; }
    .brand-sub { display: none; }
    .header-mobile-search .header-search { height: 44px; max-width: none; }
    .header-mobile-search .header-search-submit { flex-basis: 32px; min-width: 32px; padding: 0; }
    .header-mobile-search .header-search-panel { max-height: min(360px, calc(100vh - 190px)); }
}

@media (max-width: 767.98px) {
    body { padding-bottom: 76px; }
    .mobile-nav {
        align-items: center;
        background: color-mix(in srgb, var(--rd-surface) 98%, transparent);
        border-top: 1px solid var(--rd-border);
        box-shadow: 0 -8px 24px rgba(36, 26, 21, .08);
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        min-height: 68px;
        padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    }
    .mobile-nav a { color: var(--rd-text-secondary); font-size: .68rem; gap: 2px; justify-content: center; min-width: 0; position: relative; }
    .mobile-nav a:hover,
    .mobile-nav a.active { color: var(--rd-brand); }
    .mobile-nav a.active::before {
        background: var(--rd-accent);
        border-radius: 999px;
        content: "";
        height: 2px;
        left: 34%;
        position: absolute;
        right: 34%;
        top: -6px;
    }
    .mobile-nav i { font-size: 1.15rem; }
    .cart-count-badge { background: var(--rd-accent); border-color: var(--rd-surface); }
    .product-card .product-body { gap: var(--rd-space-2); padding: var(--rd-space-3); }
    .product-card .product-title { font-size: .88rem; line-height: 1.65; }
    .product-card .product-features { font-size: .7rem; }
    .product-card .product-features li:nth-child(n+2) { display: none; }
    .product-card .price { font-size: .94rem; }
    .product-card .price small { font-size: .62rem; }
    .product-card .add-btn,
    .product-card .product-stock-state { border-radius: var(--rd-radius-sm); font-size: .72rem; height: 40px; min-height: 40px; padding-inline: var(--rd-space-2); }
    .product-card .add-btn span { display: inline; }
}

@media (max-width: 389.98px) {
    .header-main-inner { gap: var(--rd-space-2); }
    .brand-icon { height: 36px; width: 36px; }
    .brand-title { font-size: .98rem; }
    .mobile-nav a { font-size: .64rem; }
    .search-suggestion { grid-template-columns: 46px minmax(0, 1fr); }
    .search-suggestion img { height: 46px; width: 46px; }
    .search-suggestion-price { grid-column: 2; justify-items: start; }
}

@media (prefers-reduced-motion: reduce) {
    .site-header *, .mobile-nav * { transition-duration: .01ms !important; }
}
