/* ==========================================================================
   THE GRIMNAGERIE — SHOP
   Luxury dark academia. Shares the palette of the main site (style.css):
   ink #0a0a0a · parchment #e6dcc8 · antique gold #c9b48f · wax-seal #3a2e24
   Display face: Cormorant Garamond. Body: Georgia (as on the home page).
   ========================================================================== */

:root {
    --ink: #0a0a0a;
    --parchment: #e6dcc8;
    --parchment-dim: rgba(230, 220, 200, 0.72);
    --gold: #c9b48f;
    --gold-bright: #dfceb3;
    --wax: #3a2e24;
    --oxblood: #5a1f1f;
    --veil: rgba(10, 8, 6, 0.55);
    --panel: rgba(10, 8, 6, 0.62);
}

/* Reuse the same locked-down, atmospheric base as the home page */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden !important;
    position: relative;
    background-color: var(--ink);
}

body {
    /* Paths are relative to this stylesheet (in /shop/), hence the ../ */
    background-image: url('../images/apothecary-background.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: var(--parchment);
    font-family: 'Georgia', serif;
    min-height: 100vh;
}

@media (max-width: 768px) {
    body {
        background-image: url('../images/apothecary-background-mobile.webp');
        background-attachment: scroll;
    }
}

/* Fallback if the .webp is not present — the .png always is */
body { background-image: url('../images/apothecary-background.png'); }

.veil {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    background-color: var(--veil);
    display: flex;
    flex-direction: column;
}

a { color: inherit; text-decoration: none; }

/* --- TOP NAVIGATION BAR ------------------------------------------------- */
.shop-nav {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px clamp(18px, 5vw, 60px);
    background-color: rgba(10, 8, 6, 0.92);
    border-bottom: 1px solid var(--wax);
    backdrop-filter: blur(4px);
}

.shop-nav .brand {
    display: flex;
    align-items: center;
}

.shop-nav .brand-word {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 22px;
    letter-spacing: 5px;
    text-transform: uppercase;
    color: var(--gold);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: clamp(16px, 3vw, 34px);
    font-size: 14px;
    letter-spacing: 2.5px;
    text-transform: uppercase;
}

.nav-links a { color: var(--parchment-dim); transition: color .25s ease; }
.nav-links a:hover, .nav-links a.active { color: var(--gold-bright); }

.cart-toggle {
    position: relative;
    background: none;
    border: 1px solid var(--gold);
    color: var(--gold);
    font: inherit;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    font-size: 13px;
    padding: 10px 20px;
    border-radius: 40px;
    cursor: pointer;
    transition: background .25s ease, color .25s ease;
}
.cart-toggle:hover { background: var(--gold); color: var(--ink); }

.cart-count {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    margin-left: 6px;
    border-radius: 20px;
    background: var(--oxblood);
    color: var(--parchment);
    font-size: 12px;
    letter-spacing: 0;
    vertical-align: middle;
}

/* --- SHOP HEADER -------------------------------------------------------- */
.shop-hero {
    text-align: center;
    padding: clamp(50px, 9vw, 100px) 20px clamp(28px, 5vw, 56px);
}

.shop-hero .eyebrow {
    font-size: 13px;
    letter-spacing: 6px;
    text-transform: uppercase;
    color: var(--gold);
    display: block;
    margin-bottom: 22px;
}

.shop-hero h1 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 500;
    font-size: clamp(40px, 8vw, 82px);
    line-height: 1.02;
    color: var(--gold-bright);
    text-shadow: 0 6px 26px rgba(0,0,0,0.9);
}

.shop-hero p {
    max-width: 620px;
    margin: 26px auto 0;
    font-size: 18px;
    font-style: italic;
    line-height: 1.75;
    color: var(--parchment-dim);
}

/* --- CATEGORY FILTER ---------------------------------------------------- */
.category-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    padding: 0 20px 10px;
    margin-bottom: 20px;
}

.category-bar button {
    background: none;
    border: 1px solid rgba(201, 180, 143, 0.35);
    color: var(--parchment-dim);
    font-family: 'Georgia', serif;
    font-size: 13px;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 9px 20px;
    border-radius: 40px;
    cursor: pointer;
    transition: all .25s ease;
}
.category-bar button:hover { border-color: var(--gold); color: var(--gold-bright); }
.category-bar button.active {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--ink);
}

/* --- PRODUCT GRID ------------------------------------------------------- */
main.shop-main {
    flex: 1;
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 clamp(18px, 5vw, 40px) 90px;
    /* Crisp cross-fade + glide when switching category tabs */
    transition: opacity .3s ease, transform .3s ease;
    will-change: opacity, transform;
}

/* Applied by shop-page.js just before the grid content is swapped */
main.shop-main.is-switching {
    opacity: 0;
    transform: translateY(14px);
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    main.shop-main { transition: none; }
    main.shop-main.is-switching { transform: none; }
}

.category-group { margin-bottom: 64px; }

.category-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 30px;
    letter-spacing: 3px;
    color: var(--gold);
    text-transform: uppercase;
    padding-bottom: 12px;
    margin-bottom: 34px;
    border-bottom: 1px solid rgba(201, 180, 143, 0.28);
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
    gap: clamp(20px, 3vw, 38px);
}

.product-card {
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 1px solid var(--wax);
    overflow: hidden;
    transition: transform .3s ease, border-color .3s ease, box-shadow .3s ease;
}

.product-card:hover {
    transform: translateY(-6px);
    border-color: var(--gold);
    box-shadow: 0 22px 44px rgba(0,0,0,0.55);
}

.card-frame {
    position: relative;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    background: #14100c;
    border-bottom: 1px solid var(--wax);
}

.card-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .5s ease;
}
.product-card:hover .card-frame img { transform: scale(1.05); }

.card-body { padding: 20px 20px 24px; display: flex; flex-direction: column; flex: 1; }

.card-body h3 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 500;
    font-size: 23px;
    line-height: 1.2;
    color: var(--parchment);
    margin-bottom: 8px;
}

.card-blurb {
    font-size: 14.5px;
    line-height: 1.6;
    color: var(--parchment-dim);
    margin-bottom: 18px;
    flex: 1;
}

.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.price {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 24px;
    color: var(--gold-bright);
    letter-spacing: 1px;
}

/* --- BUTTONS ------------------------------------------------------------ */
.btn {
    font-family: 'Georgia', serif;
    font-size: 13px;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 11px 20px;
    border-radius: 40px;
    cursor: pointer;
    border: 1px solid var(--gold);
    background: none;
    color: var(--gold);
    transition: background .25s ease, color .25s ease, opacity .25s ease;
    white-space: nowrap;
}
.btn:hover { background: var(--gold); color: var(--ink); }
.btn.solid { background: var(--gold); color: var(--ink); }
.btn.solid:hover { background: var(--gold-bright); border-color: var(--gold-bright); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; text-align: center; }
.btn.large { padding: 16px 34px; font-size: 15px; }

/* Placeholder frame for products without photos yet */
.placeholder-frame {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    background:
        repeating-linear-gradient(45deg, rgba(201,180,143,0.05) 0 12px, transparent 12px 24px),
        radial-gradient(circle at 50% 40%, rgba(201,180,143,0.10), transparent 70%);
    color: var(--gold);
    text-align: center;
    padding: 20px;
}
.placeholder-frame span {
    font-size: 12px;
    letter-spacing: 3px;
    text-transform: uppercase;
    opacity: .8;
}
.placeholder-frame .sigil { font-size: 34px; margin-bottom: 12px; opacity: .5; }

/* ==========================================================================
   PRODUCT DETAIL PAGE
   ========================================================================== */
.detail-wrap {
    flex: 1;
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: clamp(24px, 5vw, 56px) clamp(18px, 5vw, 40px) 90px;
}

.breadcrumb {
    font-size: 13px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--parchment-dim);
    margin-bottom: 34px;
}
.breadcrumb a:hover { color: var(--gold-bright); }
.breadcrumb .sep { margin: 0 10px; opacity: .5; }

.detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    gap: clamp(30px, 5vw, 64px);
    align-items: start;
}

/* --- CAROUSEL GALLERY --------------------------------------------------- */
.gallery { position: relative; }

.gallery-stage {
    position: relative;
    aspect-ratio: 4 / 5;
    background: #14100c;
    border: 1px solid var(--wax);
    overflow: hidden;
}

.gallery-track {
    display: flex;
    height: 100%;
    transition: transform .5s cubic-bezier(.4,.0,.2,1);
}

.gallery-slide {
    flex: 0 0 100%;
    height: 100%;
    position: relative;
}

.gallery-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: zoom-in;
    display: block;
}

.gallery-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 4;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    background: rgba(10, 8, 6, 0.75);
    border: 1px solid var(--gold);
    color: var(--gold);
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    transition: background .25s ease, color .25s ease;
}
.gallery-arrow:hover { background: var(--gold); color: var(--ink); }
.gallery-arrow.prev { left: 14px; }
.gallery-arrow.next { right: 14px; }
.gallery-arrow[hidden] { display: none; }

.zoom-hint {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4;
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--parchment);
    background: rgba(10,8,6,0.7);
    padding: 6px 14px;
    border-radius: 30px;
    pointer-events: none;
}

.thumbs {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}
.thumb {
    width: 66px;
    height: 66px;
    border: 1px solid var(--wax);
    background: #14100c;
    overflow: hidden;
    cursor: pointer;
    padding: 0;
    opacity: .6;
    transition: opacity .25s ease, border-color .25s ease;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.active, .thumb:hover { opacity: 1; border-color: var(--gold); }

/* --- DETAIL INFO -------------------------------------------------------- */
.detail-info .eyebrow {
    font-size: 12px;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--gold);
    display: block;
    margin-bottom: 16px;
}

.detail-info h1 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 500;
    font-size: clamp(34px, 5vw, 52px);
    line-height: 1.05;
    color: var(--gold-bright);
    margin-bottom: 18px;
}

.detail-price {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 34px;
    color: var(--parchment);
    margin-bottom: 26px;
}

.detail-desc {
    font-size: 18px;
    line-height: 1.85;
    color: var(--parchment);
    margin-bottom: 30px;
    border-top: 1px solid rgba(201,180,143,0.25);
    border-bottom: 1px solid rgba(201,180,143,0.25);
    padding: 26px 0;
}

.detail-meta { font-size: 14px; color: var(--parchment-dim); letter-spacing: 1px; margin-bottom: 30px; }

.qty-row { display: flex; align-items: center; gap: 18px; margin-bottom: 24px; }
.qty-label { font-size: 13px; letter-spacing: 2px; text-transform: uppercase; color: var(--parchment-dim); }
.qty-control { display: flex; align-items: center; border: 1px solid var(--wax); }
.qty-control button {
    background: none; border: none; color: var(--gold); font-size: 20px;
    width: 42px; height: 42px; cursor: pointer;
}
.qty-control button:hover { color: var(--gold-bright); }
.qty-control span { min-width: 40px; text-align: center; font-size: 18px; }

.detail-actions { display: flex; flex-direction: column; gap: 14px; }

/* --- EDITOR NOTE (visible only for the shop owner while photos are absent) */
.editor-note {
    margin-top: 34px;
    padding: 18px 20px;
    border: 1px dashed rgba(201,180,143,0.4);
    background: rgba(201,180,143,0.05);
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--parchment-dim);
    border-radius: 4px;
}
.editor-note strong { color: var(--gold); letter-spacing: 1px; }
.editor-note code {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 12.5px;
    color: var(--gold-bright);
    background: rgba(0,0,0,0.35);
    padding: 1px 6px;
    border-radius: 3px;
}

/* ==========================================================================
   ZOOM LIGHTBOX
   ========================================================================== */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(6, 5, 4, 0.94);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    padding: 40px;
}
.lightbox.open { display: flex; animation: fade .3s ease; }
.lightbox img {
    max-width: 92vw;
    max-height: 88vh;
    object-fit: contain;
    border: 1px solid var(--wax);
    box-shadow: 0 30px 80px rgba(0,0,0,0.7);
}
.lightbox .lb-close {
    position: absolute;
    top: 24px;
    right: 30px;
    font-size: 34px;
    color: var(--gold);
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
}
.lightbox .lb-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(10,8,6,0.6);
    border: 1px solid var(--gold);
    color: var(--gold);
    width: 54px; height: 54px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
}
.lightbox .lb-arrow.prev { left: 24px; }
.lightbox .lb-arrow.next { right: 24px; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ==========================================================================
   CART DRAWER
   ========================================================================== */
.cart-scrim {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(6,5,4,0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease;
}
.cart-scrim.open { opacity: 1; pointer-events: auto; }

.cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 95;
    width: min(420px, 92vw);
    height: 100%;
    background: rgba(14, 11, 8, 0.98);
    border-left: 1px solid var(--wax);
    transform: translateX(100%);
    transition: transform .35s cubic-bezier(.4,0,.2,1);
    display: flex;
    flex-direction: column;
}
.cart-drawer.open { transform: translateX(0); }

.cart-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 26px;
    border-bottom: 1px solid var(--wax);
}
.cart-head h2 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 500;
    font-size: 26px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--gold);
}
.cart-close { background: none; border: none; color: var(--parchment-dim); font-size: 28px; cursor: pointer; line-height: 1; }
.cart-close:hover { color: var(--gold-bright); }

.cart-items { flex: 1; overflow-y: auto; padding: 10px 26px; }

.cart-line { display: flex; gap: 14px; padding: 18px 0; border-bottom: 1px solid rgba(201,180,143,0.15); }
.cart-line .thumb-sm {
    width: 60px; height: 60px; flex: 0 0 60px;
    background: #14100c; border: 1px solid var(--wax); overflow: hidden;
}
.cart-line .thumb-sm img { width: 100%; height: 100%; object-fit: cover; }
.cart-line .thumb-sm .ph { width: 100%; height: 100%; display: grid; place-items: center; color: var(--gold); opacity: .4; font-size: 18px; }
.cart-line .line-info { flex: 1; }
.cart-line .line-info h4 { font-size: 15px; font-weight: normal; color: var(--parchment); margin-bottom: 4px; line-height: 1.3; }
.cart-line .line-info .line-price { font-size: 14px; color: var(--gold-bright); }
.cart-line .line-qty { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.cart-line .line-qty button { background: none; border: 1px solid var(--wax); color: var(--gold); width: 26px; height: 26px; cursor: pointer; }
.cart-line .line-qty button:hover { border-color: var(--gold); }
.cart-line .remove { background: none; border: none; color: var(--parchment-dim); font-size: 12px; letter-spacing: 1px; text-transform: uppercase; cursor: pointer; }
.cart-line .remove:hover { color: var(--oxblood); }

.cart-empty { text-align: center; color: var(--parchment-dim); font-style: italic; padding: 60px 20px; line-height: 1.7; }

.cart-foot { padding: 22px 26px 30px; border-top: 1px solid var(--wax); }
.cart-total { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 18px; }
.cart-total .label { font-size: 13px; letter-spacing: 2px; text-transform: uppercase; color: var(--parchment-dim); }
.cart-total .amount { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 30px; color: var(--gold-bright); }
.cart-foot .fineprint { font-size: 12px; color: var(--parchment-dim); text-align: center; margin-top: 12px; font-style: italic; }
.checkout-error { color: #e0a3a3; font-size: 13px; text-align: center; margin-top: 12px; min-height: 16px; }

/* --- CHECKOUT BANNERS (success / cancel) -------------------------------- */
.banner {
    max-width: 900px;
    margin: 0 auto 10px;
    padding: 16px 22px;
    border: 1px solid var(--gold);
    background: rgba(201,180,143,0.08);
    text-align: center;
    font-size: 15px;
    letter-spacing: 1px;
    color: var(--gold-bright);
}
.banner.cancel { border-color: var(--oxblood); color: #e0b3b3; }

/* --- FOOTER ------------------------------------------------------------- */
.shop-footer {
    padding: 44px 20px;
    text-align: center;
    background: rgba(10,8,6,0.9);
    border-top: 1px solid var(--wax);
}
.shop-footer a { color: var(--gold); letter-spacing: 2px; text-transform: uppercase; font-size: 13px; }
.shop-footer .copyright { color: var(--parchment-dim); margin-top: 16px; font-size: 13px; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 860px) {
    .detail-layout { grid-template-columns: 1fr; }
    .nav-links { gap: 16px; font-size: 12px; }
}

@media (max-width: 560px) {
    .nav-links a:not(.active) { display: none; }
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
    .card-body h3 { font-size: 19px; }
    .card-blurb { display: none; }
}
