/* =========================================================
   STOREFRONT STYLESHEET
   ---------------------------------------------------------
   Design tokens:
   Color   - bg #FAF9F6, surface #FFFFFF, primary #1F4B43,
             primary-dark #14332D, accent #C08A3E,
             text #1B1B1B, muted #6B6B65, border #E4E1D8
   Type    - "Fraunces" (serif) for headings/prices,
             "Inter" (sans) for UI and body text
   Layout  - sticky header, horizontal category rail,
             responsive product grid, slide-in cart drawer
   ========================================================= */

:root {
    --color-bg: #faf9f6;
    --color-surface: #ffffff;
    --color-primary: #1f4b43;
    --color-primary-dark: #14332d;
    --color-accent: #c08a3e;
    --color-text: #1b1b1b;
    --color-muted: #6b6b65;
    --color-border: #e4e1d8;
    --color-danger: #b3452d;
    --font-display: "Fraunces", Georgia, serif;
    --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --radius: 10px;
    --shadow-card: 0 1px 2px rgba(20, 20, 20, 0.06);
    --shadow-elevated: 0 12px 32px rgba(20, 20, 20, 0.14);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
}

img {
    max-width: 100%;
    display: block;
}

button {
    font-family: inherit;
    cursor: pointer;
}

:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------------------------------------------------------
   HEADER
   --------------------------------------------------------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.site-header__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.site-header__logo {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--color-primary-dark);
    white-space: nowrap;
    text-decoration: none;
}

.site-header__search {
    flex: 1;
    position: relative;
}

.site-header__search input {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: 0.95rem;
    background: var(--color-bg);
    color: var(--color-text);
}

.site-header__search input:focus {
    background: var(--color-surface);
    border-color: var(--color-primary);
}

.cart-button {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 500;
    flex-shrink: 0;
}

.cart-button:hover {
    background: var(--color-primary-dark);
}

.cart-button__count {
    background: var(--color-accent);
    color: #201400;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

/* ---------------------------------------------------------
   CATEGORY RAIL
   --------------------------------------------------------- */
.category-rail {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 20px 4px;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scrollbar-width: none;
}

.category-rail::-webkit-scrollbar {
    display: none;
}

.category-chip {
    flex-shrink: 0;
    padding: 8px 18px;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    font-size: 0.88rem;
    color: var(--color-text);
    white-space: nowrap;
}

.category-chip.is-active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

/* ---------------------------------------------------------
   STORE SHELL — desktop sidebar layout / mobile stacked layout
   --------------------------------------------------------- */
.store-shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    gap: 28px;
    align-items: flex-start;
}

.store-main {
    flex: 1;
    min-width: 0;
}

.category-sidebar {
    display: none; /* shown on desktop only, see media query below */
    width: 210px;
    flex-shrink: 0;
    position: sticky;
    top: 84px;
    padding: 18px 0;
}

.category-sidebar h3 {
    font-family: var(--font-display);
    font-size: 1rem;
    margin: 0 0 12px;
    padding: 0 4px;
}

.sidebar-link {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--color-text);
}

.sidebar-link:hover {
    background: var(--color-bg);
}

.sidebar-link.is-active {
    background: var(--color-primary);
    color: #fff;
    font-weight: 500;
}

/* ---------------------------------------------------------
   HERO SLIDESHOW
   --------------------------------------------------------- */
.hero {
    margin: 18px 0 0;
}

.slideshow {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
}

.slideshow__track {
    display: flex;
    transition: transform 0.45s ease;
}

.slide {
    flex: 0 0 100%;
    min-height: 220px;
    background-color: var(--color-primary-dark);
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: flex-end;
}

.slide--plain {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
}

.slide__overlay {
    padding: 26px 28px;
    background: linear-gradient(0deg, rgba(10, 20, 18, 0.55) 0%, rgba(10, 20, 18, 0) 70%);
    width: 100%;
    color: #fff;
}

.slide__overlay h1 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin: 0 0 6px;
    font-weight: 600;
}

.slide__overlay p {
    margin: 0;
    opacity: 0.9;
    font-size: 0.92rem;
}

.slideshow__dots {
    position: absolute;
    bottom: 12px;
    right: 16px;
    display: flex;
    gap: 6px;
}

.slideshow__dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    border: none;
    background: rgba(255, 255, 255, 0.5);
    padding: 0;
}

.slideshow__dot.is-active {
    background: #fff;
    width: 20px;
}

/* ---------------------------------------------------------
   MOBILE BOTTOM NAVIGATION BAR
   --------------------------------------------------------- */
.bottom-nav {
    display: none; /* shown on mobile only, see media query below */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 62px;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    z-index: 45;
    align-items: stretch;
}

.bottom-nav__item {
    flex: 1;
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 0.68rem;
    color: var(--color-muted);
}

.bottom-nav__item.is-active {
    color: var(--color-primary);
}

.bottom-nav__icon {
    font-size: 1.15rem;
    line-height: 1;
}

/* ---------------------------------------------------------
   MOBILE BOTTOM SHEET (category list on mobile)
   --------------------------------------------------------- */
.bottom-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-surface);
    border-radius: 18px 18px 0 0;
    z-index: 60;
    padding: 10px 20px 24px;
    max-height: 60vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.25s ease;
}

.bottom-sheet.is-open {
    transform: translateY(0);
}

.bottom-sheet__handle {
    width: 40px;
    height: 4px;
    background: var(--color-border);
    border-radius: 999px;
    margin: 6px auto 14px;
}

.bottom-sheet h3 {
    font-family: var(--font-display);
    font-size: 1rem;
    margin: 0 0 10px;
}

/* ---------------------------------------------------------
   RESPONSIVE SWITCH: sidebar (desktop) vs rail + bottom nav (mobile)
   --------------------------------------------------------- */
@media (min-width: 960px) {
    .category-sidebar {
        display: block;
    }
    .category-rail {
        display: none;
    }
    .bottom-nav,
    .bottom-sheet,
    #categorySheetBackdrop {
        display: none !important;
    }
}

@media (max-width: 959px) {
    .store-shell {
        padding-bottom: 78px; /* room for the fixed bottom nav */
    }
    .bottom-nav {
        display: flex;
    }
}

/* ---------------------------------------------------------
   PRODUCT GRID
   --------------------------------------------------------- */
.product-section {
    padding: 24px 0 60px;
}

.product-section h2 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0 0 16px;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.product-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
}

.product-card__image {
    aspect-ratio: 1 / 1;
    background: #f1efe9;
    overflow: hidden;
}

.product-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    loading: lazy;
}

.product-card__body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.product-card__name {
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-decoration: none;
    color: var(--color-text);
}

.product-card__price {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--color-primary-dark);
    margin-top: auto;
}

.product-card__add {
    margin-top: 6px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 0;
    font-size: 0.85rem;
    font-weight: 500;
}

.product-card__add:hover {
    background: var(--color-primary-dark);
}

.product-card__add:disabled {
    background: var(--color-border);
    color: var(--color-muted);
    cursor: not-allowed;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-muted);
}

/* ---------------------------------------------------------
   OVERLAY (shared by product detail + cart drawer)
   --------------------------------------------------------- */
.overlay-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 18, 0.45);
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.overlay-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* ---------------------------------------------------------
   PRODUCT DETAIL PANEL
   --------------------------------------------------------- */
.product-panel {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translate(-50%, 16px);
    width: min(720px, 92vw);
    max-height: 88vh;
    overflow-y: auto;
    margin-top: 6vh;
    background: var(--color-surface);
    border-radius: 16px;
    box-shadow: var(--shadow-elevated);
    z-index: 60;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.product-panel.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0);
}

.panel-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    width: 34px;
    height: 34px;
    font-size: 1rem;
    line-height: 1;
    z-index: 2;
}

.product-panel__content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.product-panel__image {
    background: #f1efe9;
    aspect-ratio: 1 / 1;
}

.product-panel__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-panel__info {
    padding: 28px 26px;
}

.product-panel__info h2 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    margin: 0 0 8px;
}

.product-panel__price {
    font-family: var(--font-display);
    font-size: 1.3rem;
    color: var(--color-primary-dark);
    font-weight: 600;
    margin-bottom: 12px;
}

.product-panel__desc {
    color: var(--color-muted);
    font-size: 0.92rem;
    margin-bottom: 20px;
}

.qty-stepper {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 16px;
}

.qty-stepper button {
    background: var(--color-bg);
    border: none;
    width: 36px;
    height: 36px;
    font-size: 1rem;
}

.qty-stepper input {
    width: 44px;
    text-align: center;
    border: none;
    border-left: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
    height: 36px;
    font-size: 0.95rem;
}

.btn-primary-block {
    display: block;
    width: 100%;
    background: var(--color-primary);
    color: #fff;
    border: none;
    padding: 13px 0;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
}

.btn-primary-block:hover {
    background: var(--color-primary-dark);
}

@media (max-width: 640px) {
    .product-panel__content {
        grid-template-columns: 1fr;
    }
    .product-panel {
        margin-top: 0;
        top: 5vh;
    }
}

/* ---------------------------------------------------------
   CART DRAWER
   --------------------------------------------------------- */
.cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: min(400px, 92vw);
    background: var(--color-surface);
    z-index: 60;
    box-shadow: var(--shadow-elevated);
    transform: translateX(100%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
}

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

.cart-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--color-border);
}

.cart-drawer__header h2 {
    font-family: var(--font-display);
    font-size: 1.15rem;
    margin: 0;
}

.cart-drawer__body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.cart-line {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
}

.cart-line__image {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    background: #f1efe9;
    flex-shrink: 0;
}

.cart-line__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cart-line__info {
    flex: 1;
    min-width: 0;
}

.cart-line__name {
    font-size: 0.88rem;
    font-weight: 500;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cart-line__price {
    font-size: 0.85rem;
    color: var(--color-muted);
}

.cart-line__remove {
    background: none;
    border: none;
    color: var(--color-danger);
    font-size: 0.8rem;
    padding: 0;
    margin-top: 6px;
}

.cart-drawer__footer {
    border-top: 1px solid var(--color-border);
    padding: 16px 20px 20px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: var(--color-muted);
}

.summary-row.total {
    color: var(--color-text);
    font-weight: 600;
    font-size: 1.05rem;
    margin-top: 10px;
}

/* ---------------------------------------------------------
   CHECKOUT FORM (inside the cart drawer)
   --------------------------------------------------------- */
.checkout-form label {
    display: block;
    font-size: 0.85rem;
    color: var(--color-muted);
    margin-bottom: 6px;
}

.checkout-form input,
.checkout-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.92rem;
    margin-bottom: 14px;
    font-family: inherit;
}

.checkout-form .required-mark {
    color: var(--color-danger);
}

.form-error {
    background: #fbeae5;
    color: var(--color-danger);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 14px;
    display: none;
}

.form-error.is-visible {
    display: block;
}

.order-success {
    text-align: center;
    padding: 30px 10px;
}

.order-success h3 {
    font-family: var(--font-display);
    color: var(--color-primary-dark);
    margin-bottom: 8px;
}

.order-success .order-number {
    display: inline-block;
    background: var(--color-bg);
    border: 1px dashed var(--color-border);
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    margin: 10px 0 18px;
}

.link-button {
    background: none;
    border: none;
    color: var(--color-primary-dark);
    font-size: 0.85rem;
    text-decoration: underline;
    padding: 0;
}
