/* Terracottanoon - Compact Smooth Design */
/* Smaller, smoother, nicer - no arrows */

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Colors - Light Mode (Default) */
:root {
    --primary: #8B4513;
    --secondary: #FAF9F6;
    --text-dark: #2C1810;
    --text-light: #6B5B47;
    --background: #FEFCF8;
    --surface: #FFFFFF;
    --border: #E8DCC6;
    --hover-bg: rgba(139, 69, 19, 0.08);
    --shadow: rgba(0, 0, 0, 0.1);
    --card-bg: #FFFFFF;
    /* The saving badge. Green is the one colour that still earns its place
       on a price: it means money back, not danger. */
    --save-text: #1f7a3d;
    --save-bg: rgba(31, 122, 61, 0.10);
}

/* Colors - Dark Mode */
[data-theme="dark"] {
    --primary: #D4A574;
    --secondary: #2C2C2C;
    --text-dark: #E8E8E8;
    --text-light: #B8B8B8;
    --background: #1A1A1A;
    --surface: #2C2C2C;
    --border: #404040;
    --hover-bg: rgba(212, 165, 116, 0.15);
    --shadow: rgba(0, 0, 0, 0.5);
    --card-bg: #2C2C2C;
    --save-text: #7fd79f;
    --save-bg: rgba(127, 215, 159, 0.14);
}

/* Body */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--background);
    color: var(--text-dark);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Georgia', serif;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-dark);
}

h1 { font-size: 2.2rem; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.4rem; }

p {
    margin-bottom: 1rem;
    color: var(--text-light);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Compact Navigation */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    font-family: 'Georgia', serif;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
    text-decoration: none;
}

/* Compact Menu */
.nav-menu {
    display: flex;
    list-style: none;
    gap: 1.5rem;
    align-items: center;
}


/* ----------------------------------------------------------------------
   Prices on a product card.

   **One definition.** This block existed twice, byte for byte, in
   index.php and category.php - and a third time, differently, in
   product.php. Here it is loaded by every page already.

   **No red.** The paid figure was #b3261e, which is the colour of a
   clearance sticker and of an error message; on art between $40 and
   $1,000 it undersells the thing and in dark mode it is a saturated red
   on near-black. It is the brand terracotta now, which is what the
   product page's own large price has always used - so the two agree
   instead of disagreeing.

   Every colour is a token, so dark mode is handled by the theme rather
   than by a second set of rules. The old block was raw hex and simply did
   not respond to it.
   ---------------------------------------------------------------------- */
.product-price {
    display: flex;
    align-items: baseline;
    gap: 7px;
    flex-wrap: wrap;
    justify-content: center;
}

.price-from {
    font-size: 0.78rem;
    color: var(--text-light);
}

/* What the shopper actually pays - the one figure that should carry
   weight, so it gets the size and the brand colour. */
.price-now {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
}

.price-was {
    text-decoration: line-through;
    color: var(--text-light);
    font-size: 0.9rem;
}

.price-off {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--save-text);
    background: var(--save-bg);
    padding: 2px 7px;
    border-radius: 999px;
}

/* Muted, not red. A countdown is information, and rendering it in the
   error colour pressures the reader rather than informing them. */
.price-ends {
    font-size: 0.74rem;
    color: var(--text-light);
    margin-top: 3px;
    text-align: center;
}

.product-price-none,
.price-none {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Logo on the left, menu, then the always-visible controls on the right.
   **Ordered explicitly** because the DOM has .nav-right before .nav-menu -
   which is what the phone needs, so both buttons land on the first row -
   while a desktop wants the menu first or the theme toggle ends up
   stranded in the middle of the bar. */
.nav-right {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    order: 3;
}

.nav-menu {
    order: 2;
}

/* The hamburger. Hidden until the nav breakpoint, where the horizontal
   menu stops fitting - see the 900px block further down. */
.nav-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-dark);
    width: 42px;
    height: 42px;
    font-size: 1.1rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.nav-toggle:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.nav-menu li {
    position: relative;
}

.nav-menu a {
    color: var(--text-dark);
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: block;
    font-size: 0.9rem;
}

.nav-menu a:hover {
    color: var(--primary);
    background: var(--hover-bg);
}

/* Make top-level Categories appear non-clickable */
.categories-dropdown > a {
    cursor: default;
}

/* Smooth Dropdown */
.dropdown-content {
    display: none;
    position: absolute;
    background: var(--surface);
    min-width: 180px;
    box-shadow: 0 6px 25px rgba(0,0,0,0.12);
    border-radius: 10px;
    top: calc(100% + 6px);
    left: 0;
    border: 1px solid var(--border);
    padding: 0.5rem;
    z-index: 1000;
    opacity: 0;
    transform: translateY(-5px);
    transition: all 0.2s ease;
}

/* **Only where a hover actually exists.**
 *
 * On a touch screen there is no hover, and iOS emulates one: the first tap
 * counts as a hover over whatever was touched, so this rule opened the
 * category list a tap late and attached to the wrong element - tap
 * Categories, nothing; tap something else, the list appears; tap a
 * category, nothing. Serving it only to pointing devices removes the class
 * of problem instead of fighting it with overrides. */
html:not(.tcn-navmobile) .nav-menu li:hover .dropdown-content {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.dropdown-content a {
    color: var(--text-dark);
    padding: 0.5rem 0.75rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    border-radius: 6px;
    margin: 0.15rem 0;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

.dropdown-content a:hover {
    background: var(--hover-bg);
    color: var(--primary);
    transform: translateX(3px);
}

.dropdown-content a i {
    margin-right: 0.5rem;
    width: 14px;
    text-align: center;
    opacity: 0.7;
    font-size: 0.8rem;
}

.user-account-dropdown .dropdown-content {
    right: 0;
    left: auto;
    top: calc(100% + 2px);
}

/* Compact Cart Counter */
.cart-counter {
    background: var(--primary);
    color: var(--surface);
    padding: 0.2rem 0.4rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: bold;
    margin-left: 0.4rem;
    min-width: 18px;
    text-align: center;
}

/* Compact Buttons */
.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    background: var(--primary);
    color: var(--surface);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn:hover {
    background: #A0522D;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--surface);
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-secondary:hover {
    background: var(--primary);
    color: var(--surface);
}

/* Compact Cards */
.card {
    background: var(--surface);
    border-radius: 10px;
    box-shadow: 0 3px 15px rgba(0,0,0,0.08);
    padding: 1.2rem;
    transition: all 0.2s ease;
    border: 1px solid var(--border);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0,0,0,0.12);
}

/* Grid */
.grid {
    display: grid;
    gap: 1.2rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Compact Hero Section */
.hero {
    background: linear-gradient(135deg, var(--background) 0%, var(--secondary) 100%);
    padding: 3rem 0;
    text-align: center;
}

.hero-content {
    max-width: 700px;
    margin: 0 auto;
    padding: 0 1rem;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.hero p {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

.hero-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Compact Product Cards */
.product-image {
    width: 100%;
    height: 220px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 0.8rem;
}

.product-info {
    text-align: center;
}

.product-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    line-height: 1.3;
}

.product-price {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 0.2rem;
}

.product-category {
    font-size: 0.8rem;
    color: var(--text-light);
    font-style: italic;
}

/* Smooth Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.4s ease-out;
}

/* Utility Classes */
.text-center { text-align: center; }
.mb-sm { margin-bottom: 0.4rem; }
.mb-md { margin-bottom: 0.8rem; }
.mb-lg { margin-bottom: 1.2rem; }
.mb-xl { margin-bottom: 1.6rem; }

/* Compact Loading */
.loading {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-light);
    font-style: italic;
    font-size: 0.9rem;
}

/* Compact Error */
.error {
    text-align: center;
    padding: 0.8rem;
    color: #dc3545;
    background: rgba(220, 53, 69, 0.1);
    border-radius: 6px;
    border: 1px solid rgba(220, 53, 69, 0.2);
    font-size: 0.9rem;
}

/* Dark Mode Toggle Button */
.dark-mode-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dark);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 36px;
}

.dark-mode-toggle:hover {
    background: var(--hover-bg);
    color: var(--primary);
    border-color: var(--primary);
}

.dark-mode-toggle i {
    transition: transform 0.3s ease;
}

[data-theme="dark"] .dark-mode-toggle {
    border-color: var(--border);
}

[data-theme="dark"] .dark-mode-toggle:hover {
    background: var(--hover-bg);
    color: var(--primary);
}

/* Responsive */
/* ----------------------------------------------------------------------
   Tablet. An iPad in portrait is 768-1024 CSS px: wide enough that one
   column wastes most of the screen, not wide enough for four.
   ---------------------------------------------------------------------- */
@media (max-width: 1024px) and (min-width: 901px) {
    .grid-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ----------------------------------------------------------------------
   The navigation breakpoint.

   **900px, not 768.** An iPad in portrait is 768 or 834 CSS px, and the
   horizontal menu - eight items plus two dropdowns - does not fit there
   either. 900 keeps iPad landscape and desktop on the full menu.

   The same figure is in the matchMedia() call in header.php. **They must
   agree**: if the script thinks it is on desktop while these rules apply,
   the Categories row stops responding to taps and there is no way to open
   it at all.
   ---------------------------------------------------------------------- */
/* **Width OR the absence of hover.** A phone with "Request Desktop
   Website" switched on lays out at about 980px, and iPadOS does that by
   default - so a width test alone strands a touch device on a hover menu
   it physically cannot operate. (hover: none) catches every such case.

   The same condition is mirrored in header.php's matchMedia call and the
   two must agree: if the script believes it is on desktop while these
   rules apply, Categories stops responding to taps altogether. */
/* ----------------------------------------------------------------------
   The mobile navigation.

   **Keyed on a class, not a media query, and that is deliberate.** Two
   earlier attempts keyed it on (max-width: 900px) and then on
   (hover: none); both failed on a real iPhone. Safari with "Request
   Desktop Website" switched on - a per-site setting that sticks, and the
   iPadOS default - lays out at about 980px AND presents itself as a
   desktop, so neither question gets an honest answer. The browser is
   pretending, and these media features are part of the pretence.

   navigator.maxTouchPoints is hardware. An iPhone says 5 in any layout
   mode; a mouse-driven desktop says 0. The decision is made once, in the
   small script at the top of header.php, and published as .tcn-navmobile
   on <html>. The script that opens the menu reads the same class, so there
   is no second copy of a condition to drift out of step - which is the
   hazard both earlier versions carried.

   Grid columns stay on a width media query below: how many products fit on
   a row really is a question about width.
   ---------------------------------------------------------------------- */
html.tcn-navmobile .navbar-content {
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.7rem 1rem;
}

html.tcn-navmobile .nav-toggle {
    display: inline-flex;
}

/* Collapsed by default, opened by the button. The rules this replaced set
   .dropdown-content to display:block here, so all eighteen categories
   rendered inline, always - which is what tore the header apart. */
html.tcn-navmobile .nav-menu {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 0;
    padding: 0.3rem 0 0.2rem;
    border-top: 1px solid var(--border);
}

html.tcn-navmobile .navbar.is-open .nav-menu {
    display: flex;
}

html.tcn-navmobile .nav-menu li {
    width: 100%;
}

/* 0.8rem of padding puts every row past the 44px minimum touch target. */
html.tcn-navmobile .nav-menu > li > a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.8rem 0.3rem;
    font-size: 1rem;
    border-radius: 8px;
}

html.tcn-navmobile .nav-menu > li + li > a {
    border-top: 1px solid var(--border);
    border-radius: 0;
}

html.tcn-navmobile .categories-dropdown > a,
html.tcn-navmobile .user-account-dropdown > a {
    cursor: pointer;
}

/* The menu goes last so it wraps onto its own row beneath the logo and
   the two buttons, rather than between them. */
html.tcn-navmobile .nav-right { order: 2; }
html.tcn-navmobile .nav-menu  { order: 3; }

/* Match the hamburger exactly - side by side, two buttons of different
   heights look like a mistake rather than a pair. */
html.tcn-navmobile .nav-right .dark-mode-toggle {
    width: 42px;
    height: 42px;
    min-width: 0;
    padding: 0;
    border-radius: 8px;
    font-size: 1.1rem;
}

/* **The rule that produced the reported symptom.** With hover still live on
   a touch screen, iOS treats the first tap as a hover over whatever was
   touched before - so the category list appeared one tap late and attached
   to the wrong element: tap Categories, nothing; tap something else, the
   list appears; tap a category, nothing. Cancelled here, and the .is-open
   rule below takes over. Order matters: equal specificity, so .is-open has
   to come second. */
html.tcn-navmobile .nav-menu li:hover .dropdown-content {
    display: none;
}

html.tcn-navmobile .dropdown-content {
    position: static;
    display: none;
    box-shadow: none;
    border: none;
    background: transparent;
    opacity: 1;
    transform: none;
    min-width: 0;
    margin: 0 0 0.4rem;
    padding-left: 0.9rem;
    /* Eighteen categories would otherwise push the rest of the menu off the
       bottom of the screen with no way back to it. */
    max-height: 55vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

html.tcn-navmobile .categories-dropdown.is-open > .dropdown-content,
html.tcn-navmobile .user-account-dropdown.is-open > .dropdown-content {
    display: block;
}

html.tcn-navmobile .dropdown-content a {
    display: block;
    padding: 0.65rem 0.3rem;
    margin: 0;
    border-radius: 0;
    font-size: 0.95rem;
}

html.tcn-navmobile .dropdown-content a:hover {
    transform: none;
}

/* Two columns, not one. A single full-width card shows one product per
   screen and makes a 1,469-design catalogue feel empty. */
@media (max-width: 900px) {
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.9rem;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: 2rem 0;
    }
    
    .hero h1 {
        font-size: 1.6rem;
    }
    
    .product-image {
        height: 180px;
    }
    
    .card {
        padding: 1rem;
    }
}
