/* store.css – the public online stores (/retail, later /wholesale with the same file). Mobile first (360 px+).
   Two themes, like the admin: <html data-theme="dark|light">, set before the page draws by the inline
   script in index.html and switched in the header by /assets/js/theme.js (System / Light / Dark).
   In light, the header and the logo panel stay deep brown because the gold logo is weak on white.
   Contrast of both themes: tests/theme-contrast.test.js. Below the token blocks, colours only come from tokens. */

/* ---------- Dark theme (also the fallback) + everything that is not a colour ---------- */
:root, [data-theme="dark"] {
  color-scheme: dark;
  --font-head: "Cinzel", "Trajan Pro", Georgia, serif;
  --font-body: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --bg:        #0e0d0b;
  --bg-glow:   radial-gradient(900px 480px at 50% -120px, rgba(177, 140, 82, .16), transparent 70%);
  --panel:     #1c1b19;
  --panel-2:   #232220;
  --input:     #191816;
  --chip:      rgba(255, 255, 255, .06);
  --line:      #363432;
  --line-soft: #2a2826;
  --hover:     rgba(255, 255, 255, .04);
  --text:      #f2efe9;
  --muted:     #a8a39a;
  --gold:      var(--tph-gold-500);
  --gold-text: var(--tph-gold-300);
  --gold-hover:#bf9a5e;
  --gold-ink:  #141312;
  --gold-tint: rgba(177, 140, 82, .12);
  --ok:        #75b443;  --ok-tint:     rgba(117, 180, 67, .14);
  --warn:      #e3b25a;  --warn-tint:   rgba(227, 178, 90, .14);
  --danger:    #ec8070;  --danger-tint: rgba(224, 112, 95, .12);  /* a touch lighter than the admin: badges sit on the lighter cards */
  --backdrop:  rgba(10, 9, 8, .75);
  --focus-ring:rgba(177, 140, 82, .35);
  --bar-bg:    rgba(20, 19, 18, .97);
  --strip:     #e3b25a;  --strip-ink: #141312;
  --shadow-pop:0 14px 40px rgba(0, 0, 0, .55);
  --bar-shadow:0 -10px 30px rgba(0, 0, 0, .4);
  --logo-glow: drop-shadow(0 8px 30px rgba(177, 140, 82, .18));
  --band:      transparent;  /* behind the hero logo (light theme: deep brown) */

  --radius: 14px;  --radius-sm: 10px;  --pill: 999px;
  --tap: 44px;
  --ease: .18s ease;
}

/* ---------- Light theme (warm daylight) ---------- */
[data-theme="light"] {
  color-scheme: light;
  --bg:        #f7f3ea;
  --bg-glow:   radial-gradient(900px 480px at 50% -120px, rgba(215, 180, 114, .30), transparent 70%);
  --panel:     #ffffff;
  --panel-2:   #fbf8f2;
  --input:     #ffffff;
  --chip:      #f1ece2;
  --line:      #ddd4c4;
  --line-soft: #ece6db;
  --hover:     rgba(141, 106, 54, .07);
  --text:      #211d17;
  --muted:     #6b6457;
  --gold:      var(--tph-gold-700);  /* #8D6A36 deeper gold: buttons, with white text */
  --gold-text: #8a6326;
  --gold-hover:#7a5a2b;
  --gold-ink:  #ffffff;
  --gold-tint: rgba(177, 140, 82, .15);
  --ok:        #23702d;  --ok-tint:     rgba(66, 160, 70, .14);
  --warn:      #8a5700;  --warn-tint:   rgba(232, 168, 40, .18);
  --danger:    #b0321f;  --danger-tint: rgba(214, 72, 52, .10);
  --backdrop:  rgba(40, 32, 20, .45);
  --bar-bg:    rgba(255, 255, 255, .97);  /* cart bar */
  --bar-shadow:0 -6px 20px rgba(60, 45, 20, .10);
  --strip:     #f0c869;  --strip-ink: #1d1810;
  --shadow-pop:0 14px 36px rgba(60, 45, 20, .18);
  --logo-glow: none;
  --band:      #1f1b16;
}
/* Light theme: dark tokens inside the deep-brown header and logo panel (and the theme menu in the header) */
[data-theme="light"] .site-head, [data-theme="light"] .hero {
  color-scheme: dark;
  --text: #f4efe6; --muted: #bfb6a6; --line: #4a433a; --line-soft: #362f27;
  --panel: #2a241e; --panel-2: #312a23; --input: #2a241e; --hover: rgba(255, 255, 255, .06);
  --gold: var(--tph-gold-500); --gold-text: var(--tph-gold-300); --gold-hover: #bf9a5e; --gold-ink: #141312;
  --gold-tint: rgba(177, 140, 82, .16);
  --bar-bg: #1f1b16;
}
[data-theme="light"] .hero { background: var(--band); border-radius: var(--radius); margin-top: 16px; padding: 20px 16px 18px; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg) var(--bg-glow) no-repeat;
  color: var(--text); font: 15px/1.55 var(--font-body);
}
body.has-cart { padding-bottom: 96px; } /* room for the cart bar */
img { max-width: 100%; }
a { color: var(--gold-text); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h2 { font: 600 20px/1.3 var(--font-head); letter-spacing: .03em; }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.gold { color: var(--gold-text); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- Strips + header ---------- */
.demo-strip { background: var(--strip); color: var(--strip-ink); text-align: center; font-size: 12.5px; font-weight: 600; padding: 5px 12px; }
.min-strip {
  background: var(--gold-tint); border-bottom: 1px solid var(--line-soft); color: var(--text);
  font-size: 13px; padding: 8px 16px; text-align: center;
}
.site-head {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--bar-bg); border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); min-width: 0; margin-right: auto; }
.brand img { flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font: 700 17px/1.1 var(--font-head); letter-spacing: .08em; color: var(--gold-text); text-transform: uppercase; white-space: nowrap; }
.brand-sub { font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.head-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--pill); color: var(--text); text-decoration: none;
  font-weight: 600; font-size: 13px; flex: none;
}
.head-btn:hover { border-color: var(--gold); color: var(--gold-text); }
.head-btn span { display: none; }
@media (min-width: 480px) { .head-btn span { display: inline; } }

/* ---------- Page ---------- */
.page { max-width: 1100px; margin: 0 auto; padding: 0 16px 32px; }
.hero { text-align: center; padding: 20px 0 8px; }
.hero-logo { width: 170px; height: auto; filter: var(--logo-glow); }
.hero-line { color: var(--muted); font-size: 13px; letter-spacing: .12em; text-transform: uppercase; margin: 6px 0 0; }
@media (min-width: 700px) { .hero-logo { width: 220px; } }

.how { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); margin: 16px 0; padding: 0 16px; }
.how summary {
  display: flex; align-items: center; gap: 10px; min-height: 52px; cursor: pointer; list-style: none;
  font-weight: 600; color: var(--gold-text);
}
.how summary::-webkit-details-marker { display: none; }
.how ul { margin: 0 0 12px; padding-left: 20px; }
.how li { margin: 6px 0; }
.how .btn { margin-bottom: 8px; }
.how > p { margin: 0 0 14px; }

/* ---------- Buttons + forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 20px; border-radius: var(--pill);
  border: 1px solid var(--line); background: transparent; color: var(--text);
  font: 600 14px var(--font-body); cursor: pointer; text-decoration: none; transition: background var(--ease), border-color var(--ease);
}
.btn:hover { border-color: var(--gold); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn-gold:hover:not(:disabled) { background: var(--gold-hover); border-color: var(--gold-hover); }
.btn-block { width: 100%; }
.btn-small { min-height: 38px; padding: 0 14px; font-size: 13px; }
.btn svg { flex: none; }
.link-btn {
  background: none; border: 0; padding: 4px 0; min-height: 32px; color: var(--gold-text); font: 600 13px var(--font-body);
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.link-danger { color: var(--danger); }
.icon-btn {
  display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); flex: none;
  border: 1px solid var(--line); border-radius: 50%; background: none; color: var(--text); cursor: pointer;
}
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--input); color: var(--text); font: 15px var(--font-body);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--focus-ring); }
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.field-hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }
.field-hint.is-ok { color: var(--ok); }
.field-hint.is-bad { color: var(--danger); font-weight: 600; }
.form-error { color: var(--danger); min-height: 1.2em; margin: 8px 0; font-weight: 600; }

/* ---------- Menu ---------- */
.menu-tools {
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 12px;
  display: grid; gap: 10px; margin-bottom: 14px;
}
.search-wrap { position: relative; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); display: flex; }
.search-input { padding-left: 40px; }
.menu-links { display: flex; justify-content: flex-end; gap: 16px; }
@media (min-width: 700px) {
  .menu-tools { grid-template-columns: 1fr 220px auto; align-items: center; }
}
.menu-list { display: grid; gap: 10px; }
.cat { background: var(--panel); border: 1px solid var(--line-soft); border-left: 3px solid var(--gold); border-radius: var(--radius); }
.cat > summary {
  display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 0 16px; cursor: pointer; list-style: none;
}
.cat > summary::-webkit-details-marker { display: none; }
.cat-chevron { display: flex; color: var(--gold-text); transition: transform var(--ease); }
.cat[open] > summary .cat-chevron { transform: rotate(90deg); }
.cat-name { font: 700 16px var(--font-head); letter-spacing: .1em; text-transform: uppercase; color: var(--gold-text); flex: 1; }
.cat-count { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }
.cat-body { padding: 0 12px 12px; }
.sub + .sub { margin-top: 14px; }
.sub-title {
  display: flex; align-items: center; gap: 8px; padding: 6px 4px 10px; font-size: 12px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--text);
}
.grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 980px) { .grid { grid-template-columns: 1fr 1fr 1fr; } }

.product {
  display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: start;
  background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 10px;
}
.product.is-soldout { opacity: .6; }
.product-photo {
  width: 96px; height: 96px; border-radius: var(--radius-sm); overflow: hidden; background: var(--chip);
  display: grid; place-items: center; color: var(--muted);
}
.product-photo img { width: 100%; height: 100%; object-fit: cover; }
.photo-none svg { width: 32px; height: 32px; color: var(--gold); opacity: .6; }
.product-body { min-width: 0; }
.product-name { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.product-cat { color: var(--gold-text); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; margin: 2px 0; }
.product-price { margin: 4px 0 2px; }
.product-price strong { font-size: 16px; }
.product-stock { color: var(--muted); font-size: 12.5px; margin: 0 0 8px; }
.line-total { color: var(--gold-text); font-size: 13px; font-weight: 600; margin: 6px 0 0; min-height: 0; }
.line-total:empty { display: none; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: var(--pill); font-size: 11px; font-weight: 700; letter-spacing: .05em;
}
.badge-warn { background: var(--warn-tint); color: var(--warn); }
.badge-danger { background: var(--danger-tint); color: var(--danger); }

/* −/+ quantity */
.qty { display: flex; align-items: center; gap: 6px; }
.qty-btn {
  display: grid; place-items: center; width: var(--tap); height: var(--tap); flex: none;
  border-radius: 50%; border: 1px solid var(--line); background: var(--input); color: var(--text); cursor: pointer;
}
.qty-btn:hover:not(:disabled) { border-color: var(--gold); color: var(--gold-text); }
.qty-btn:disabled { opacity: .35; cursor: not-allowed; }
.qty-input { width: 64px; min-width: 0; text-align: center; padding: 8px 4px; -moz-appearance: textfield; }
.qty-input::-webkit-outer-spin-button, .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-unit { color: var(--muted); font-size: 12px; width: 32px; }
.qty.has-qty .qty-input { border-color: var(--gold); }

.loading, .empty { text-align: center; color: var(--muted); padding: 32px 0; }
.spinner {
  display: inline-block; width: 18px; height: 18px; margin-right: 10px; vertical-align: -3px;
  border: 2px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-box { background: var(--danger-tint); border: 1px solid var(--danger); border-radius: var(--radius); padding: 16px; text-align: center; }

/* ---------- Cart bar ---------- */
.cart-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--bar-bg); border-top: 1px solid var(--line); box-shadow: var(--bar-shadow);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.cart-bar-inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cart-bar-sum { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.cart-bar-sum strong { font-size: 17px; }
.cart-bar-sum span { font-size: 12px; color: var(--muted); }
.cart-min.is-short { color: var(--warn); }
.cart-min.is-ok { color: var(--ok); }
.cart-bar .btn { flex: none; }

/* ---------- Dialogs ---------- */
.dlg {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 24px); margin: auto; padding: 18px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text);
  box-shadow: var(--shadow-pop);
}
.dlg::backdrop { background: var(--backdrop); }
.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.dlg-head p { margin: 4px 0 0; }
.dlg-actions { display: grid; gap: 10px; margin-top: 14px; }
@media (max-width: 559px) {
  /* Phones: checkout fills the screen */
  .dlg-checkout { width: 100vw; max-width: 100vw; height: 100%; max-height: 100%; border-radius: 0; border: 0; }
}
.review-lines { display: grid; gap: 0; }
.review-line {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 12px 0; border-bottom: 1px solid var(--line-soft);
}
.review-info { display: flex; flex-direction: column; min-width: 0; flex: 1 1 160px; }
.review-info .link-btn { align-self: flex-start; }
.qty-small .qty-btn { width: 40px; height: 40px; }
.min-box { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; margin: 12px 0; }
.min-box.is-ok { background: var(--ok-tint); color: var(--ok); }
.min-box.is-short { background: var(--warn-tint); color: var(--warn); }
.min-box p { margin: 0 0 8px; }
.voucher-row { display: flex; gap: 8px; }
.voucher-row input { flex: 1; min-width: 0; }
.voucher-row .btn { flex: none; }
/* Progress to the minimum order (cart bar + review) */
.min-bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 4px; width: 100%; min-width: 120px; }
.min-bar span { display: block; height: 100%; background: var(--warn); border-radius: 3px; transition: width .2s; }
.min-bar.is-ok span { background: var(--ok); }
.total-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
.total-big { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px; font-size: 17px; }
.totals { margin: 6px 0 4px; }

.choices { border: 0; padding: 0; margin: 0 0 14px; display: grid; gap: 8px; }
.choices legend { font-weight: 600; font-size: 14px; margin-bottom: 8px; padding: 0; }
.choice { position: relative; display: block; margin: 0; cursor: pointer; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice-text {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 52px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--input);
}
.choice-text small { color: var(--muted); font-size: 12.5px; text-align: right; }
.choice input:checked + .choice-text { border-color: var(--gold); background: var(--gold-tint); }
.choice input:focus-visible + .choice-text { box-shadow: 0 0 0 3px var(--focus-ring); }
.info-box { background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 14px; }
.info-box p { margin: 4px 0 0; }
.info-warn { border-color: var(--warn); background: var(--warn-tint); }
.loc-row { margin-top: 8px; }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.placed { text-align: center; }
.placed-tick { font-size: 40px; margin: 0; }
.placed h2 { margin: 6px 0 4px; }
.placed .info-box { text-align: left; }
.placed-total { font-size: 16px; }

/* ---------- Theme switch (header) ---------- */
.theme-head { position: relative; flex: none; }
.theme-btn {
  width: var(--tap); height: var(--tap); border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line); background: transparent; color: var(--gold-text); cursor: pointer; transition: border-color var(--ease);
}
.theme-btn svg { width: 19px; height: 19px; }
.theme-btn:hover, .theme-btn[aria-expanded="true"] { border-color: var(--gold); }
.theme-menu {
  position: absolute; right: 0; top: calc(var(--tap) + 8px); z-index: 40; width: 220px; padding: 8px;
  border-radius: var(--radius); background: var(--panel-2); border: 1px solid var(--line); box-shadow: var(--shadow-pop);
}
.theme-menu p { margin: 4px 8px 6px; }
.theme-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: var(--tap); padding: 0 10px;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); font: 14px var(--font-body); cursor: pointer; text-align: left;
}
.theme-menu button svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.theme-menu button:hover { background: var(--hover); }
.theme-menu button[aria-checked="true"] { background: var(--gold-tint); font-weight: 600; }
.theme-menu button[aria-checked="true"] svg { color: var(--gold-text); }

/* ---------- Footer + toast ---------- */
.site-foot { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 16px 32px; }
.toast {
  position: fixed; left: 50%; bottom: 110px; transform: translate(-50%, 20px); z-index: 60;
  max-width: calc(100vw - 32px); padding: 10px 18px; border-radius: var(--pill);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text); font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity var(--ease), transform var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: var(--danger); color: var(--danger); }
