/* ============================================================
 * Dawn Munro Ceramics — main stylesheet.
 * Earth-tone palette built around the warmth of fired clay.
 * Tokens at the top; restyle to taste.
 * ============================================================ */

:root {
    /* These defaults match the "Earth & Clay" theme. The active theme is
       injected inline in includes/header.php and overrides these values. */
    --color-bg:           #fbf8f3;
    --color-bg-alt:       #f1ebe1;
    --color-text:         #2a2620;
    --color-text-light:   #6f6557;
    --color-accent:       #8b6f47;
    --color-accent-dark:  #6a5436;
    --color-border:       #e2d8c8;
    --color-sold:         #a04848;
    --color-for-sale:     #4a7a5a;
    --color-new:          #c08a3e;
    --footer-bg:          #1f1c17;
    --footer-text:        #b9b1a4;

    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body:    'Raleway', Arial, sans-serif;

    --space-xs:  0.4rem;
    --space-sm:  0.8rem;
    --space-md:  1.2rem;
    --space-lg:  2rem;
    --space-xl:  3rem;
    --space-2xl: 5rem;

    --radius:    4px;
    --shadow:    0 4px 20px rgba(0,0,0,0.06);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font-body);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    /* Sticky-footer pattern: body is a flex column at viewport height, main
       grows to fill, footer stays pinned to the bottom on short pages. */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
main { flex: 1 0 auto; }
.footer { flex-shrink: 0; }

img { max-width: 100%; display: block; }
a { color: var(--color-accent); text-decoration: none; }
a:hover { color: var(--color-accent-dark); }

h1, h2, h3, h4 {
    font-family: var(--font-display);
    color: var(--color-text);
    line-height: 1.2;
    font-weight: 500;
}
h1 { font-size: 2.4rem; margin-bottom: var(--space-md); }
h2 { font-size: 2rem;   margin-bottom: var(--space-sm); }
h3 { font-size: 1.4rem; margin-bottom: var(--space-sm); }

.container { max-width: 1280px; margin: 0 auto; padding: 0 var(--space-lg); }
.container--narrow { max-width: 760px; }
.text-center { text-align: center; }
.mt-xl { margin-top: var(--space-xl); }

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 0.75rem 1.6rem;
    border-radius: var(--radius);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.85rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.18s ease;
}
.btn--primary { background: var(--color-accent); color: #fff; }
.btn--primary:hover { background: var(--color-accent-dark); color: #fff; }
.btn--secondary { background: transparent; color: var(--color-accent); border-color: var(--color-accent); }
.btn--secondary:hover { background: var(--color-accent); color: #fff; }
.btn--full { width: 100%; }
.btn--large { padding: 1rem 2rem; font-size: 0.95rem; }

/* ─── Nav ─────────────────────────────────────────────────── */
.nav {
    position: sticky;
    top: 0;
    width: 100%;
    z-index: 100;
    transition: background 0.25s ease, box-shadow 0.25s ease;
}
.nav--solid { background: var(--color-bg); backdrop-filter: blur(8px); box-shadow: 0 1px 0 var(--color-border); }
.nav--transparent { background: transparent; }
.nav__container { max-width: 1280px; margin: 0 auto; padding: 1rem var(--space-lg); display: flex; align-items: center; justify-content: space-between; }
.nav__logo { font-family: var(--font-display); font-size: 1.4rem; color: var(--color-text); }
.nav--transparent .nav__logo { color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,0.4); }
.nav__menu { list-style: none; display: flex; gap: var(--space-lg); align-items: center; }
.nav__item { position: relative; }
.nav__link {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text);
    padding: 0.5rem 0;
}
.nav--transparent .nav__link { color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,0.4); }
.nav__link:hover { color: var(--color-accent); }
.nav__dropdown {
    position: absolute;
    top: 100%; left: 0;
    background: #fff;
    list-style: none;
    min-width: 200px;
    padding: 0.5rem 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    opacity: 0; visibility: hidden;
    transition: opacity 0.18s, visibility 0.18s;
}
.nav__item:hover .nav__dropdown { opacity: 1; visibility: visible; }
.nav__dropdown-link {
    display: block; padding: 0.55rem 1rem;
    color: var(--color-text); font-size: 0.85rem;
    text-transform: uppercase; letter-spacing: 0.06em;
}
.nav__dropdown-link:hover { background: var(--color-bg-alt); color: var(--color-accent); }

.nav__cart { display: inline-flex; align-items: center; gap: 6px; }
.nav__cart-icon { font-size: 1.1rem; }
.nav__cart-count {
    display: inline-block;
    background: var(--color-accent);
    color: #fff;
    border-radius: 50%;
    min-width: 22px; height: 22px;
    padding: 0 6px;
    font-size: 0.7rem; line-height: 22px;
    text-align: center;
}

.nav__toggle { display: none; background: none; border: none; cursor: pointer; padding: 12px; position: relative; z-index: 110; }
.nav__toggle-bar { display: block; width: 26px; height: 2px; background: var(--color-text); margin: 5px 0; border-radius: 2px; transition: transform 0.25s ease, opacity 0.2s ease; }
.nav--transparent .nav__toggle-bar { background: #fff; }
/* Animate to an X when open */
.nav__toggle.is-open .nav__toggle-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav__toggle.is-open .nav__toggle-bar:nth-child(2) { opacity: 0; }
.nav__toggle.is-open .nav__toggle-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 880px) {
    .nav__container { padding: 0.6rem var(--space-md); position: relative; }
    .nav__toggle { display: block; }

    /* Full-width slide-down drawer */
    .nav__menu {
        display: flex;
        position: absolute;
        top: 100%; left: 0; right: 0;
        flex-direction: column;
        gap: 0;
        background: var(--color-bg);
        border-top: 1px solid var(--color-border);
        padding: 0;
        max-height: calc(100vh - 60px);
        overflow-y: auto;
        overflow-x: hidden;
        transform: translateY(-12px);
        opacity: 0;
        pointer-events: none;
        transition: transform 0.22s ease, opacity 0.22s ease;
        box-shadow: 0 8px 30px rgba(0,0,0,0.08);
    }
    .nav__menu.is-open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    /* Top-level items are full-width tap rows */
    .nav__item { width: 100%; border-bottom: 1px solid var(--color-border); }
    .nav__item:last-child { border-bottom: none; }
    .nav__link {
        display: flex; align-items: center;
        width: 100%;
        padding: 1rem var(--space-md);
        min-height: 48px;
        font-size: 1rem;
    }
    .nav__link:active { background: var(--color-bg-alt); }

    /* Sub-menu trigger (Collections, The Work) gets a chevron */
    .nav__item:has(.nav__dropdown) > .nav__link::after {
        content: '';
        margin-left: auto;
        width: 8px; height: 8px;
        border-right: 2px solid var(--color-text-light);
        border-bottom: 2px solid var(--color-text-light);
        transform: rotate(45deg) translate(-2px, -2px);
        transition: transform 0.2s ease;
    }
    .nav__item.is-expanded > .nav__link::after {
        transform: rotate(-135deg) translate(-2px, -2px);
    }
    .nav--transparent .nav__link { color: var(--color-text); text-shadow: none; }
    .nav--transparent .nav__logo { color: var(--color-text); text-shadow: none; }

    /* Sub-menus are accordion-style — collapsed by default, expand on tap */
    .nav__dropdown {
        position: static;
        opacity: 1; visibility: visible;
        box-shadow: none;
        border: none;
        border-radius: 0;
        min-width: 0;
        background: var(--color-bg-alt);
        padding: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }
    .nav__item.is-expanded > .nav__dropdown {
        max-height: 80vh;   /* generous; collapses in/out smoothly */
    }
    .nav__dropdown-link {
        padding: 0.85rem var(--space-md) 0.85rem calc(var(--space-md) * 2);
        min-height: 44px;
        font-size: 0.95rem;
        display: flex; align-items: center;
    }
    .nav__dropdown-link:active { background: rgba(0,0,0,0.04); }

    /* Cart icon sits inline as a row item on mobile */
    .nav__item--cart { width: 100%; }
    .nav__cart { padding: 1rem var(--space-md); width: 100%; }
}

/* ─── Hero / homepage ────────────────────────────────────── */
.hero {
    min-height: 80vh;
    display: flex; align-items: center; justify-content: center;
    background: var(--color-bg-alt) center/cover no-repeat;
    color: #fff;
    text-align: center;
    margin-top: -78px; /* overlap transparent nav */
    padding-top: 78px;
}
.hero__content { max-width: 800px; padding: var(--space-xl) var(--space-lg); }
.hero__title { color: #fff; font-weight: 300; text-shadow: 0 4px 24px rgba(0,0,0,0.5); }
.hero__subtitle { color: #fff; font-style: italic; opacity: 0.9; margin-top: var(--space-md); }

.intro { padding: var(--space-2xl) 0; background: var(--color-bg); }

/* ─── Gallery ────────────────────────────────────────────── */
.gallery { padding: var(--space-2xl) 0; }
.gallery__header { text-align: center; margin-bottom: var(--space-xl); }
.gallery__title { font-size: 2.4rem; }
.gallery__description { color: var(--color-text-light); margin-top: var(--space-xs); }
.gallery__grid {
    display: grid;
    gap: var(--space-md);
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.gallery__item {
    position: relative;
    overflow: hidden;
    background: var(--color-bg-alt);
    border-radius: var(--radius);
    cursor: pointer;
    aspect-ratio: 1 / 1;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.gallery__item:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.gallery__image { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.gallery__item:hover .gallery__image { transform: scale(1.04); }
.gallery__overlay {
    position: absolute; inset: 0;
    background: linear-gradient(to bottom, transparent 50%, rgba(0,0,0,0.65));
    opacity: 0; transition: opacity 0.25s;
}
.gallery__item:hover .gallery__overlay { opacity: 1; }
.gallery__info {
    position: absolute; bottom: 0; left: 0; right: 0;
    color: #fff; padding: var(--space-md);
    transform: translateY(100%); transition: transform 0.3s ease;
}
.gallery__item:hover .gallery__info { transform: translateY(0); }
.gallery__painting-title { color: #fff; font-size: 1.2rem; margin-bottom: 2px; }
.gallery__painting-meta { font-size: 0.85rem; opacity: 0.85; }

.gallery__badge {
    position: absolute; top: 10px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #fff;
    z-index: 2;
}
.gallery__badge--new      { left: 10px; background: var(--color-new); }
.gallery__badge--sold     { right: 10px; background: var(--color-sold); }
.gallery__badge--for-sale { right: 10px; background: var(--color-for-sale); }

/* ─── Filters ────────────────────────────────────────────── */
.filters {
    background: var(--color-bg-alt);
    padding: var(--space-md);
    border-radius: var(--radius);
    margin-bottom: var(--space-xl);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    align-items: center;
}
.filters__group { display: flex; flex-direction: column; gap: 4px; }
.filters__group label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-light); }
.filters__group select, .filters__group input {
    padding: 7px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: #fff;
    font-size: 0.9rem;
    min-width: 160px;
}

/* ─── Piece detail ───────────────────────────────────────── */
.piece-single { padding: var(--space-xl) 0 var(--space-2xl); }
.piece-single__breadcrumb { margin-bottom: var(--space-lg); font-size: 0.85rem; color: var(--color-text-light); }
.piece-single__breadcrumb a { color: var(--color-text-light); }
.piece-single__layout {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    gap: var(--space-xl);
}
@media (max-width: 880px) { .piece-single__layout { grid-template-columns: 1fr; } }

/* The carousel arranges its thumbnails to the LEFT of the main image on
   wider screens, and falls back to a horizontal strip below the main image
   on narrow screens. The HTML order is [main, thumbs] — we use `order: -1`
   to flip the thumbnails ahead of the main image visually. */
.piece-carousel {
    position: relative;
    display: flex;
    gap: var(--space-sm);
    align-items: flex-start;
}
.piece-carousel__main {
    position: relative;
    flex: 1 1 auto;
    min-width: 0; /* allow the image to shrink inside the flex row */
    background: var(--color-bg-alt);
    border-radius: var(--radius);
    overflow: hidden;
    /* Let the image's natural aspect dictate the container's height — no
       letterbox bars when the user has cropped to a square or other ratio. */
}
.piece-carousel__main img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 80vh;
    object-fit: contain;
    background: var(--color-bg-alt);
}
.piece-carousel__nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(255,255,255,0.85);
    border: none;
    width: 38px; height: 38px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--color-text);
    display: flex; align-items: center; justify-content: center;
}
.piece-carousel__nav:hover { background: #fff; }
.piece-carousel__nav--prev { left: 12px; }
.piece-carousel__nav--next { right: 12px; }
.piece-carousel__thumbs {
    /* Sit to the LEFT of the main image even though the HTML lists thumbs
       after main. On narrow screens this is reset to drop the rail below. */
    order: -1;
    flex: 0 0 84px;
    width: 84px;
    margin-top: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 80vh;
    padding-bottom: 0;
    padding-right: 2px;
}
.piece-carousel__thumb {
    flex: 0 0 70px; width: 70px; height: 70px;
    background: var(--color-bg-alt);
    border: 2px solid transparent;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    padding: 0;
}
.piece-carousel__thumb img { width: 100%; height: 100%; object-fit: cover; }
.piece-carousel__thumb.is-active { border-color: var(--color-accent); }

/* Narrow screens — drop the rail back under the main image as a horizontal
   scroller. Smaller than the layout breakpoint (880px) at 700px because the
   two-column piece-single layout has already collapsed, and a left rail
   inside the now-full-width carousel feels cramped. */
@media (max-width: 700px) {
    .piece-carousel { flex-direction: column; }
    .piece-carousel__thumbs {
        order: 0;
        flex: 0 0 auto;
        width: auto;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: visible;
        max-height: none;
        margin-top: var(--space-sm);
        padding-bottom: 4px;
        padding-right: 0;
    }
}

.piece-single__title { font-size: 2.4rem; margin-bottom: var(--space-md); }
.piece-single__meta p { margin-bottom: 6px; color: var(--color-text-light); }
.piece-single__meta strong { color: var(--color-text); }
.piece-single__price {
    font-size: 1.5rem;
    color: var(--color-accent);
    margin: var(--space-md) 0;
}
.piece-single__actions { margin-top: var(--space-lg); display: flex; gap: var(--space-sm); flex-wrap: wrap; }
.piece-single__description { margin-top: var(--space-lg); }
.piece-single__related { margin-top: var(--space-2xl); }
.piece-single__related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-md); margin-top: var(--space-md); }
.piece-single__related-item img { aspect-ratio: 1/1; object-fit: cover; border-radius: var(--radius); }
.piece-single__related-item span { display: block; margin-top: 6px; font-size: 0.85rem; color: var(--color-text); }

/* ─── Forms ──────────────────────────────────────────────── */
.form__row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
.form__group { margin-bottom: var(--space-md); }
.form__label { display: block; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-light); margin-bottom: 6px; }
.form__input, .form__select, .form__textarea {
    width: 100%; padding: 0.7rem 0.9rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: #fff;
    font-family: inherit;
    font-size: 1rem;
}
.form__input:focus, .form__select:focus, .form__textarea:focus { outline: none; border-color: var(--color-accent); }
.form__textarea { resize: vertical; min-height: 100px; }
.form__radio-group { display: flex; gap: var(--space-md); flex-wrap: wrap; }
.form__radio-label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 0.9rem; }

/* ─── Contact panel ──────────────────────────────────────── */
.contact-modal { position: fixed; bottom: 30px; right: 30px; z-index: 200; }
.contact-trigger {
    background: var(--color-accent);
    color: #fff;
    border: none;
    padding: 0.85rem 1.4rem;
    border-radius: 999px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.85rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
}
.contact-trigger:hover { background: var(--color-accent-dark); }
.contact-panel {
    position: absolute;
    bottom: 70px; right: 0;
    width: 380px; max-width: calc(100vw - 30px);
    max-height: 80vh; overflow: auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    display: none;
}
.contact-panel.is-open { display: block; }
.contact-panel__header { padding: var(--space-md); border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; }
.contact-panel__close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--color-text-light); }
.contact-panel__body { padding: var(--space-md); }

/* ─── Footer ─────────────────────────────────────────────── */
.footer { background: var(--footer-bg); color: var(--footer-text); padding: var(--space-xl) 0; margin-top: var(--space-2xl); }
.footer__inner { display: flex; flex-wrap: wrap; gap: var(--space-md); justify-content: space-between; align-items: center; }
.footer__sep { margin: 0 6px; opacity: 0.5; }
.footer__admin-link { color: var(--footer-text); }
.footer__admin-link:hover { color: #fff; }
.footer__social a { color: var(--footer-text); margin-left: var(--space-md); }
.footer__social a:hover { color: #fff; }

/* ─── Flash messages ─────────────────────────────────────── */
.flash { padding: var(--space-md); border-radius: var(--radius); margin: var(--space-md) 0; }
.flash--success { background: #e8f5e9; color: #1b5e20; border: 1px solid #a5d6a7; }
.flash--error   { background: #fdecec; color: #8a0000; border: 1px solid #f5b5b5; }

/* ─── Lightbox ───────────────────────────────────────────── */
.lightbox {
    position: fixed; inset: 0;
    background: rgba(20,18,15,0.96);
    z-index: 1000;
    display: none; align-items: center; justify-content: center;
    padding: var(--space-md);
}
.lightbox.is-open { display: flex; }
.lightbox img { max-width: 95vw; max-height: 90vh; }
.lightbox__close { position: absolute; top: 20px; right: 30px; background: none; border: none; color: #fff; font-size: 2rem; cursor: pointer; }
.lightbox__caption { position: absolute; bottom: 20px; left: 0; right: 0; text-align: center; color: #fff; }

/* ─── Shop ───────────────────────────────────────────────── */
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-md); }
.shop-card { background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; transition: transform 0.18s ease, box-shadow 0.18s ease; }
.shop-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.shop-card__img { aspect-ratio: 1/1; object-fit: cover; width: 100%; background: var(--color-bg-alt); }
.shop-card__body { padding: var(--space-md); }
.shop-card__title { font-size: 1.1rem; margin-bottom: 4px; }
.shop-card__price { color: var(--color-accent); font-weight: 600; }

.cart-table { width: 100%; border-collapse: collapse; }
.cart-table th, .cart-table td { padding: var(--space-sm) var(--space-md); text-align: left; border-bottom: 1px solid var(--color-border); }
.cart-table th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-light); }
.cart-table img { width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius); }
.cart-summary { background: var(--color-bg-alt); border-radius: var(--radius); padding: var(--space-lg); }
.cart-summary__row { display: flex; justify-content: space-between; padding: 6px 0; }
.cart-summary__row--total { font-weight: 600; font-size: 1.1rem; padding-top: var(--space-sm); border-top: 1px solid var(--color-border); margin-top: var(--space-sm); }
