/* ============================================================================
 * H.O.W. Bazaar — Master Design System & Styling (SHOP, GROW, RESCUE)
 * Exact Brand Palette: Logo Emerald #0A6142 · Sunrise Orange #F37321 · Mint #EBF5F0
 * Typography: Fraunces (Headings) · Source Sans 3 (UI Body) · IBM Plex Mono (Data)
 * WCAG 2.2 AA · Mobile-First Touch Targets (>= 44px) · Light High-Contrast Headers
 * ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400..800;1,9..144,400..800&family=IBM+Plex+Mono:ital,wght@0,400;0,500;0,600;1,400&family=Source+Sans+3:ital,wght@0,300..800;1,300..800&display=swap');

:root {
    /* Exact Colors Sourced directly from Logo */
    --logo-green:       #0A6142;        /* Rich logo emerald green */
    --logo-green-dark:  #06422D;        /* Deep dark emerald */
    --logo-orange:      #F37321;        /* Logo sunrise orange accent */
    --logo-orange-dark: #D45A0E;        /* Darker orange for hover/active */
    --logo-lime:        #85D643;        /* Logo bright lime accent */
    --logo-mint-light:  #EBF5F0;        /* Light mint header background */
    --logo-mint-border: #C6E4D5;        /* Mint border accent */
    
    /* Default System Theme */
    --primary:          #0A6142;        /* Logo Emerald Green */
    --primary-dk:       #06422D;
    --accent:           #F37321;        /* Sunrise Orange Action Accent */
    --accent-dk:        #D45A0E;
    --accent-light:     #FDF0E6;
    --bg:               #F7FAF8;        /* Soft crisp mint/cream background */
    --surface:          #FFFFFF;
    --surface-alt:      #EBF5F0;
    --ink:              #14241D;
    --ink-soft:         #4B6358;
    --line:             #D5E5DD;
    
    /* Status & Semantics */
    --warn:             #8A5A00;
    --warn-bg:          #FFF1C7;
    --warn-border:      #EBD9A6;
    --danger:           #B3261E;
    --danger-bg:        #FCE8E6;
    --danger-border:    #F2C4C0;
    --ok:               #0A6142;
    --ok-bg:            #EBF5F0;
    --ok-border:        #C6E4D5;
    
    /* Typography Tokens */
    --font-heading:     'Fraunces', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
    --font-body:        'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono:        'IBM Plex Mono', 'Cascadia Mono', Consolas, monospace;
    
    /* Radius & Spacing */
    --radius-sm:        8px;
    --radius:           14px;
    --radius-lg:        20px;
    --radius-pill:      999px;
    --shadow-low:       0 2px 8px rgba(10,97,66,0.05);
    --shadow:           0 6px 20px rgba(10,97,66,0.08);
    --shadow-high:      0 12px 32px rgba(10,97,66,0.14);
    --tap:              48px;
    --safe-b:           env(safe-area-inset-bottom, 0px);
    --ease-out:         cubic-bezier(0.2, 0, 0, 1);
}

/* Theme Overrides (SHOP, GROW, RESCUE) */
body.theme-shop, .theme-shop {
    --accent:           #F37321;        /* Sunrise Orange */
    --accent-dk:        #D45A0E;
    --accent-light:     #FDF0E6;
}

body.theme-grow, .theme-grow {
    --accent:           #0A6142;        /* Emerald Green */
    --accent-dk:        #06422D;
    --accent-light:     #EBF5F0;
}

body.theme-rescue, .theme-rescue {
    --accent:           #1F6F8B;        /* Harbour Teal */
    --accent-dk:        #154F63;
    --accent-light:     #E3F3F7;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
html, body { overflow-x: hidden; max-width: 100%; }

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg);
    padding-bottom: calc(76px + var(--safe-b));
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, .headline {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 .5rem;
    line-height: 1.22;
    letter-spacing: -0.01em;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 0.98rem; }
p  { margin: 0 0 .75rem; }
img, svg { max-width: 100%; height: auto; }
small, .small { font-size: .875rem; }
.muted { color: var(--ink-soft); }

/* ---------- Appbar (Header) Crisp White Background ---------- */
.appbar {
    position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; gap: .75rem;
    padding: .65rem 1.25rem;
    padding-top: calc(.65rem + env(safe-area-inset-top, 0px));
    background: #ffffff;
    color: var(--logo-green);
    border-bottom: 1.5px solid var(--line);
    box-shadow: 0 2px 12px rgba(10,97,66,0.05);
}
.appbar img {
    height: 42px;
    width: auto;
    max-width: 220px;
    flex: 0 0 auto;
    object-fit: contain;
}
.appbar-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.18rem;
    color: var(--logo-green);
    line-height: 1.1;
    display: flex;
    align-items: center;
    gap: .4rem;
}
.appbar-sub { font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--logo-orange); font-weight: 700; }
.appbar-spacer { flex: 1; }

/* ---------- Layout & Container ---------- */
.screen { display: none; padding: 1.25rem 1rem; max-width: 1080px; margin: 0 auto; }
.screen.active { display: block; animation: fadeSlideUp .22s var(--ease-out); }

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.card {
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-low);
    transition: box-shadow .2s var(--ease-out), border-color .2s var(--ease-out);
}
.card:hover {
    box-shadow: var(--shadow);
}
.card.tight { padding: .85rem 1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; }

/* ---------- Hero Banner ---------- */
.hero {
    background: linear-gradient(135deg, #0A6142 0%, #06422D 100%);
    color: #ffffff;
    border-radius: var(--radius-lg);
    padding: 1.35rem 1.25rem;
    margin-bottom: 1.1rem;
    box-shadow: var(--shadow);
}
.hero h2 { color: #ffffff; font-size: 1.45rem; margin-bottom: .35rem; }
.hero p { color: #E4F4EC; margin: 0; font-size: .95rem; line-height: 1.5; }
.hero b { color: #FAD4B5; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    min-height: var(--tap); padding: .75rem 1.25rem;
    font-family: var(--font-body); font-weight: 600; font-size: .95rem;
    color: var(--primary); background: var(--surface);
    border: 1.5px solid var(--line); border-radius: var(--radius-pill);
    cursor: pointer; transition: transform .1s var(--ease-out), background .18s var(--ease-out), border-color .18s var(--ease-out), box-shadow .18s var(--ease-out);
    user-select: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
.btn:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(10,97,66,0.1);
}
.btn:active { transform: scale(.97); }
.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(243,115,33,0.25);
}
.btn-primary:hover {
    background: var(--accent-dk);
    border-color: var(--accent-dk);
    color: #ffffff;
}
.btn-primary:active { background: var(--accent-dk); }
.btn-dark { background: var(--primary); border-color: var(--primary); color: #ffffff; }
.btn-block { display: flex; width: 100%; }
.btn-sm { min-height: 40px; padding: .4rem .9rem; font-size: .85rem; border-radius: 999px; }
.btn:disabled { opacity: .5; pointer-events: none; }

/* ---------- Form Controls ---------- */
label { display: block; font-size: .88rem; font-weight: 600; color: var(--primary); margin-bottom: .35rem; }
input[type=text], input[type=number], input[type=search], select, textarea {
    width: 100%; min-height: var(--tap); padding: .75rem 1rem;
    font-family: var(--font-body); font-size: 16px;
    color: var(--ink); background: var(--surface);
    border: 1.5px solid var(--line); border-radius: 12px;
    transition: border-color .18s var(--ease-out), box-shadow .18s var(--ease-out);
}
textarea { min-height: 100px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--logo-green);
    box-shadow: 0 0 0 3px rgba(243,115,33,0.3);
}
.field { margin-bottom: 1rem; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; }
.row > * { flex: 1 1 200px; }

/* Chips (Diet & Allergy Toggles) */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
    display: inline-flex; align-items: center; gap: .35rem;
    min-height: 42px; padding: .5rem .95rem;
    font-size: .875rem; font-weight: 600; color: var(--ink);
    background: var(--surface); border: 1.5px solid var(--line);
    border-radius: var(--radius-pill); cursor: pointer; user-select: none;
    transition: all .16s var(--ease-out);
}
.chip:hover { border-color: var(--primary); background: var(--surface-alt); }
.chip[aria-pressed="true"] {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(243,115,33,0.25);
}
.chip.hard[aria-pressed="true"] {
    background: var(--danger);
    border-color: var(--danger);
    color: #ffffff;
}

/* ---------- Product Cards & Grid ---------- */
.products { display: grid; grid-template-columns: 1fr; gap: .85rem; }
.product {
    display: flex; gap: .85rem; align-items: flex-start;
    background: var(--surface); border: 1.5px solid var(--line);
    border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow-low);
    transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out), border-color .18s var(--ease-out);
}
.product:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--logo-mint-border);
}
.product-icon {
    flex: 0 0 auto; width: 56px; height: 56px; border-radius: 14px;
    display: grid; place-items: center; font-size: 1.7rem;
    background: var(--logo-mint-light); border: 1px solid var(--logo-mint-border);
}
.product-main { flex: 1 1 auto; min-width: 0; }
.product-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.02rem;
    color: var(--primary);
    line-height: 1.25;
    margin-bottom: .15rem;
}
.product-meta { font-size: .82rem; color: var(--ink-soft); }
.product-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .55rem; }
.price { font-family: var(--font-heading); font-weight: 700; font-size: 1.15rem; color: var(--logo-green); }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: .3rem;
    font-size: .72rem; font-weight: 700; letter-spacing: .02em;
    padding: .25rem .6rem; border-radius: var(--radius-pill); white-space: nowrap;
}
.badge-verified { background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok-border); }
.badge-pending  { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-border); }
.badge-blocked  { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.badge-nz       { background: var(--surface-alt); color: var(--primary); border: 1px solid var(--line); }

/* ---------- Agent Feed & Refusals ---------- */
.agent-line {
    display: flex; gap: .65rem; padding: .65rem .85rem; margin-bottom: .5rem;
    background: var(--surface-alt); border-left: 4px solid var(--accent);
    border-radius: 0 12px 12px 0; font-size: .9rem; line-height: 1.45;
}
.agent-line.refuse { background: var(--danger-bg); border-left-color: var(--danger); color: #7A1C16; }
.agent-line.warn   { background: var(--warn-bg);   border-left-color: var(--warn);   color: #5C3D00; }
.agent-line b { font-family: var(--font-heading); font-weight: 700; }
.agent-avatar { flex: 0 0 auto; font-size: 1.15rem; }

/* ---------- Receipt / Proof (Monospace Hashes) ---------- */
.receipt { border: 1.5px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: .85rem; background: var(--surface); }
.receipt-head { display: flex; gap: .75rem; align-items: center; padding: .85rem 1rem; background: var(--logo-mint-light); }
.receipt-body { padding: 1rem; border-top: 1px dashed var(--line); display: none; }
.receipt.open .receipt-body { display: block; }
.hash {
    font-family: var(--font-mono);
    font-size: .75rem; word-break: break-all; color: #8DE4AC;
    background: #0D1C16; padding: .5rem .75rem; border-radius: 8px;
    letter-spacing: 0.03em; border: 1px solid #1C382C;
}
.chain-step { display: flex; gap: .6rem; align-items: flex-start; font-size: .85rem; margin-bottom: .5rem; }
.chain-dot { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--logo-orange); color: #ffffff; font-size: .65rem; font-weight: 700; }

/* ---------- Bottom Navigation ---------- */
.bottomnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    display: grid; grid-template-columns: repeat(4, 1fr);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1.5px solid var(--line);
    padding-bottom: var(--safe-b);
    box-shadow: 0 -4px 20px rgba(10,97,66,0.06);
}
.navbtn {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 64px; padding: .4rem; border: 0; background: none; cursor: pointer;
    font-family: var(--font-body); font-size: .72rem; font-weight: 600; color: var(--ink-soft);
    position: relative; transition: color .16s var(--ease-out);
}
.navbtn .ico { font-size: 1.35rem; line-height: 1; transition: transform .16s var(--ease-out); }
.navbtn:hover .ico { transform: translateY(-2px); }
.navbtn[aria-current="true"] { color: var(--logo-orange); font-weight: 700; }
.navbtn .pill {
    position: absolute; top: 8px; right: calc(50% - 18px);
    min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
    background: var(--danger); color: #ffffff; font-size: .65rem; font-weight: 700;
    display: grid; place-items: center;
}

/* ---------- Install Banner & Notices ---------- */
.install-banner {
    position: sticky; top: 0; z-index: 45;
    background: var(--logo-green); color: #ffffff; padding: .85rem 1.25rem;
    display: none; gap: .75rem; align-items: flex-start;
    box-shadow: var(--shadow);
}
.install-banner.show { display: flex; }
.install-banner .btn { flex: 0 0 auto; }
.ios-steps { font-size: .85rem; color: #E3EFE3; }
.ios-steps b { color: #ffffff; }

.notice { padding: .85rem 1rem; border-radius: 12px; font-size: .88rem; margin-bottom: .85rem; line-height: 1.45; }
.notice-sim  { background: var(--warn-bg);  border: 1px solid var(--warn-border); color: #5C3D00; }
.notice-info { background: var(--logo-mint-light); border: 1px solid var(--logo-mint-border); color: var(--logo-green); }
.notice-bad  { background: var(--danger-bg);border: 1px solid var(--danger-border); color: var(--danger); }
.empty { text-align: center; color: var(--ink-soft); padding: 2.5rem 1rem; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.divider { height: 1px; background: var(--line); margin: 1rem 0; }

/* ---------- Responsive Desktop & Tablet Grid ---------- */
@media (min-width: 680px) {
    .products { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
    .screen { padding: 2rem 1.5rem; }
    h1 { font-size: 2.1rem; }
    h2 { font-size: 1.5rem; }
}
@media (min-width: 1024px) {
    .products { grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
    .screen { max-width: 1080px; }
}
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
