/* ==========================================================================
   KEKO storefront — design system
   Single stylesheet. Tokens -> reset -> layout -> components -> utilities.
   Page-specific rules live in assets/css/page-<name>.css
   ========================================================================== */

/* --------------------------------------------------------------- tokens -- */
:root {
  /* surfaces */
  --bg:            #0a0a0f;
  --bg-elev:       #12121a;
  --surface:       #171722;
  --surface-2:     #1e1e2c;
  --surface-3:     #262636;
  --border:        #2c2c3d;
  --border-soft:   #22222f;

  /* text */
  --text:          #f4f4f8;
  --text-dim:      #a6a6bd;
  --text-faint:    #6e6e87;

  /* brand */
  --brand:         #7c5cff;
  --brand-bright:  #9b82ff;
  --brand-dim:     #4b357d;
  --accent:        #00e5a0;
  --accent-dim:    #00996b;
  --danger:        #ff5c72;
  --warn:          #ffb347;

  /* per-card flavour accent — overridden inline via style="--flavor: …" */
  --flavor:        var(--brand);

  /* type */
  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;

  --fs-xs:   0.75rem;
  --fs-sm:   0.8125rem;
  --fs-base: 0.9375rem;
  --fs-md:   1.0625rem;
  --fs-lg:   1.375rem;
  --fs-xl:   1.875rem;
  --fs-2xl:  2.5rem;
  --fs-3xl:  3.5rem;

  /* space */
  --s-1: 0.25rem;  --s-2: 0.5rem;   --s-3: 0.75rem;  --s-4: 1rem;
  --s-5: 1.5rem;   --s-6: 2rem;     --s-7: 3rem;     --s-8: 4rem;
  --s-9: 6rem;

  /* shape */
  --r-sm: 6px;  --r-md: 10px;  --r-lg: 16px;  --r-xl: 24px;  --r-pill: 999px;

  /* effects */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 8px 24px -8px rgba(0,0,0,.6);
  --shadow-lg: 0 24px 64px -16px rgba(0,0,0,.7);
  --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--brand);

  --header-h: 64px;
  --maxw: 1240px;
  --ease: cubic-bezier(.2,.7,.3,1);
}

/* ---------------------------------------------------------------- reset -- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
h1,h2,h3,h4 { margin: 0; line-height: 1.15; letter-spacing: -.02em; font-weight: 700; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

/* --------------------------------------------------------------- layout -- */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--s-5); }
@media (max-width: 640px) { .wrap { padding-inline: var(--s-4); } }

.section { padding-block: var(--s-8); }
.section--tight { padding-block: var(--s-7); }
@media (max-width: 768px) { .section { padding-block: var(--s-7); } }

.stack > * + * { margin-top: var(--s-4); }
.row { display: flex; align-items: center; gap: var(--s-3); }
.row--between { justify-content: space-between; }
.grid { display: grid; gap: var(--s-5); }

.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--s-4); margin-bottom: var(--s-6); flex-wrap: wrap;
}
.section-head h2 { font-size: var(--fs-xl); }
.section-head p { color: var(--text-dim); font-size: var(--fs-sm); margin-top: var(--s-2); }

.eyebrow {
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--brand-bright);
}

/* --------------------------------------------------------------- header -- */
/* mountChrome() injects the announce bar + header into #header-slot. Without
   this, that wrapper div becomes the sticky header's containing block and the
   header scrolls away after ~99px. display:contents dissolves the wrapper so
   the sticky element resolves against the viewport instead. */
#header-slot { display: contents; }

.site-header {
  position: sticky; top: 0; z-index: 60;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.site-header__inner { display: flex; align-items: center; gap: var(--s-5); height: 100%; }

.logo { display: inline-flex; align-items: center; gap: 9px; color: var(--text); }
.logo svg { width: 28px; height: 28px; flex: none; filter: drop-shadow(0 0 10px rgba(112,84,255,.18)); }
.logo__word {
  display: inline-block;
  font-size: 1.08rem;
  font-weight: 900;
  font-style: italic;
  letter-spacing: -.075em;
  line-height: 1;
  transform: skew(-5deg);
}

.nav { display: flex; gap: var(--s-2); margin-left: var(--s-4); }
.nav a {
  padding: var(--s-2) var(--s-3); border-radius: var(--r-sm);
  font-size: var(--fs-sm); font-weight: 500; color: var(--text-dim);
  transition: color .18s var(--ease), background .18s var(--ease);
}
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }

.header-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); }

.icon-btn {
  display: inline-grid; place-items: center; position: relative;
  width: 38px; height: 38px; border-radius: var(--r-md);
  background: transparent; border: 1px solid transparent; cursor: pointer;
  color: var(--text-dim); transition: all .18s var(--ease);
}
.icon-btn:hover { color: var(--text); background: var(--surface); border-color: var(--border); }
.icon-btn svg { width: 19px; height: 19px; }

.cart-count {
  position: absolute; top: 2px; right: 2px; min-width: 17px; height: 17px;
  padding: 0 4px; border-radius: var(--r-pill);
  background: var(--brand); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 17px; text-align: center;
  transform: scale(0); transition: transform .22s var(--ease);
}
.cart-count[data-visible="true"] { transform: scale(1); }

.burger { display: none; }
@media (max-width: 900px) {
  .nav { display: none; }
  .burger { display: inline-grid; }
}

/* mobile drawer */
.mobile-nav {
  position: fixed; inset: var(--header-h) 0 0 0; z-index: 55;
  background: var(--bg); padding: var(--s-5);
  transform: translateX(100%); transition: transform .3s var(--ease);
  overflow-y: auto;
}
.mobile-nav[data-open="true"] { transform: none; }
.mobile-nav a {
  display: block; padding: var(--s-4) var(--s-2);
  border-bottom: 1px solid var(--border-soft);
  font-size: var(--fs-md); font-weight: 600;
}

/* announcement strip */
.announce {
  background: linear-gradient(90deg, var(--brand-dim), var(--brand));
  color: #fff; text-align: center;
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: .04em;
  padding: var(--s-2) var(--s-4);
}

/* -------------------------------------------------------------- buttons -- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: var(--s-3) var(--s-5); border-radius: var(--r-md);
  border: 1px solid transparent; cursor: pointer;
  font-size: var(--fs-sm); font-weight: 600; letter-spacing: -.01em;
  white-space: nowrap; transition: all .18s var(--ease);
}
.btn svg { width: 17px; height: 17px; }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-bright); transform: translateY(-1px); box-shadow: 0 6px 20px -6px var(--brand); }
.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--surface-3); }
.btn--outline { background: transparent; border-color: var(--border); color: var(--text-dim); }
.btn--outline:hover { color: var(--text); border-color: var(--text-faint); }
.btn--block { width: 100%; }
.btn--lg { padding: var(--s-4) var(--s-6); font-size: var(--fs-base); border-radius: var(--r-md); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* --------------------------------------------------------------- chips --- */
.chip {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3); border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--border);
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-dim);
  cursor: pointer; transition: all .16s var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--text-faint); }
.chip[aria-pressed="true"], .chip[data-active="true"] {
  background: color-mix(in srgb, var(--brand) 18%, transparent);
  border-color: var(--brand); color: var(--brand-bright);
}
.chip--static { cursor: default; }
.chip--static:hover { color: var(--text-dim); border-color: var(--border); }

.badge {
  display: inline-block; padding: 3px var(--s-2); border-radius: var(--r-sm);
  font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
}
.badge--new    { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.badge--hot    { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }
.badge--out    { background: var(--surface-3); color: var(--text-faint); }
.badge--strong { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }

/* ---------------------------------------------------------- product tin -- */
/* Catalogue photography is preferred; generated SVG remains the fallback. */
.tin { width: 100%; height: auto; aspect-ratio: 1; display: block; }
.tin--photo { object-fit: contain; }
.tin-wrap {
  position: relative; display: grid; place-items: center;
  background:
    radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--flavor) 26%, transparent), transparent 62%),
    var(--surface);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  overflow: hidden;
}
.tin-wrap:has(.tin--photo) { padding: 0; background: transparent; }
.tin-wrap::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 120%, rgba(255,255,255,.05), transparent 60%);
  pointer-events: none;
}
.tin-wrap:has(.tin--photo)::after { display: none; }

/* ---------------------------------------------------------------- card --- */
.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--bg-elev); border: 1px solid var(--border-soft);
  border-radius: var(--r-lg); overflow: hidden;
  transition: border-color .2s var(--ease), transform .2s var(--ease), box-shadow .2s var(--ease);
}
.card:hover { border-color: color-mix(in srgb, var(--flavor) 55%, var(--border)); transform: translateY(-3px); box-shadow: var(--shadow-md); }
.card__media { position: relative; }
.card__flags { position: absolute; top: var(--s-3); left: var(--s-3); display: flex; gap: var(--s-2); z-index: 2; }
.card__body { padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-2); flex: 1; }
.card__title { font-size: var(--fs-base); font-weight: 700; letter-spacing: -.015em; }
.card__meta { font-size: var(--fs-xs); color: var(--text-faint); }
.card__foot { margin-top: auto; padding-top: var(--s-3); display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.price { font-size: var(--fs-md); font-weight: 700; letter-spacing: -.03em; }
.price small { font-size: var(--fs-xs); font-weight: 500; color: var(--text-faint); margin-left: 4px; }
.price del { color: var(--text-faint); font-weight: 500; font-size: var(--fs-sm); margin-right: var(--s-2); }

.card__strengths { display: flex; gap: 4px; flex-wrap: wrap; }
.strength-dot {
  font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--text-faint);
}

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--s-5); }
@media (max-width: 520px) { .product-grid { grid-template-columns: repeat(2, 1fr); gap: var(--s-3); } }

/* --------------------------------------------------------------- forms --- */
.field { display: flex; flex-direction: column; gap: var(--s-2); }
.field label { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-faint); }
.input, .select, .textarea {
  width: 100%; padding: var(--s-3) var(--s-4);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--text);
  transition: border-color .16s var(--ease);
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); }
.input::placeholder { color: var(--text-faint); }
.select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a6a6bd' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
  padding-right: 38px;
}

.qty { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.qty button { width: 36px; height: 38px; background: none; border: 0; cursor: pointer; color: var(--text-dim); font-size: var(--fs-md); }
.qty button:hover { color: var(--text); }
.qty input { width: 40px; height: 38px; text-align: center; background: none; border: 0; font-weight: 700; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty input[type=number] { -moz-appearance: textfield; }

/* --------------------------------------------------------------- notice -- */
.notice {
  display: flex; gap: var(--s-3); padding: var(--s-4);
  border-radius: var(--r-md); border: 1px solid var(--border);
  background: var(--surface); font-size: var(--fs-sm); color: var(--text-dim);
}
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--warn); }
.notice--warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); }

/* ---------------------------------------------------------- cart drawer -- */
.drawer-scrim {
  position: fixed; inset: 0; z-index: 90; background: rgba(5,5,9,.6);
  opacity: 0; pointer-events: none; transition: opacity .25s var(--ease);
}
.drawer-scrim[data-open="true"] { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 100;
  width: min(400px, 100%); display: flex; flex-direction: column;
  background: var(--bg-elev); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform .3s var(--ease);
}
.drawer[data-open="true"] { transform: none; }
.drawer__head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border-soft); }
.drawer__head h3 { font-size: var(--fs-md); }
.drawer__body { flex: 1; overflow-y: auto; padding: var(--s-4) var(--s-5); }
.drawer__foot { padding: var(--s-5); border-top: 1px solid var(--border-soft); display: flex; flex-direction: column; gap: var(--s-4); }

.line-item { display: grid; grid-template-columns: 60px 1fr auto; gap: var(--s-3); padding: var(--s-3) 0; border-bottom: 1px solid var(--border-soft); }
.line-item__thumb { border-radius: var(--r-sm); background: var(--surface); padding: 6px; }
.line-item__name { font-size: var(--fs-sm); font-weight: 600; }
.line-item__opt { font-size: var(--fs-xs); color: var(--text-faint); }
.line-item__remove { background: none; border: 0; cursor: pointer; color: var(--text-faint); font-size: var(--fs-xs); padding: 0; text-align: left; }
.line-item__remove:hover { color: var(--danger); }

.totals { display: flex; flex-direction: column; gap: var(--s-2); font-size: var(--fs-sm); }
.totals__row { display: flex; justify-content: space-between; color: var(--text-dim); }
.totals__row--grand { color: var(--text); font-weight: 700; font-size: var(--fs-md); padding-top: var(--s-3); border-top: 1px solid var(--border-soft); }

.empty-state { text-align: center; padding: var(--s-8) var(--s-4); color: var(--text-faint); }
.empty-state svg { width: 44px; height: 44px; margin: 0 auto var(--s-4); opacity: .35; }

/* ---------------------------------------------------------------- toast -- */
.toast-host { position: fixed; bottom: var(--s-5); left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: var(--s-2); pointer-events: none; }
.toast {
  padding: var(--s-3) var(--s-5); border-radius: var(--r-pill);
  background: var(--surface-3); border: 1px solid var(--border);
  font-size: var(--fs-sm); font-weight: 600; box-shadow: var(--shadow-md);
  animation: toast-in .28s var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

/* ----------------------------------------------------- analytics consent -- */
.meta-consent {
  position: fixed; z-index: 250; right: var(--s-5); bottom: var(--s-5);
  width: min(620px, calc(100vw - 2 * var(--s-5)));
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-5);
  padding: var(--s-5); border: 1px solid var(--border);
  border-radius: var(--r-lg); background: color-mix(in srgb, var(--bg-elev) 96%, transparent);
  box-shadow: var(--shadow-lg); backdrop-filter: blur(18px);
}
.meta-consent__copy { max-width: 56ch; }
.meta-consent__copy strong { display: block; margin-bottom: var(--s-2); font-size: var(--fs-base); }
.meta-consent__copy p { color: var(--text-dim); font-size: var(--fs-sm); line-height: 1.55; }
.meta-consent__copy a { display: inline-block; margin-top: var(--s-2); color: var(--brand-bright); font-size: var(--fs-xs); }
.meta-consent__actions { display: flex; flex: none; gap: var(--s-2); }
@media (max-width: 680px) {
  .meta-consent { right: var(--s-3); bottom: var(--s-3); width: calc(100vw - 2 * var(--s-3)); align-items: stretch; flex-direction: column; }
  .meta-consent__actions { display: grid; grid-template-columns: 1fr 1fr; }
}

/* --------------------------------------------------------------- footer -- */
.site-footer { border-top: 1px solid var(--border-soft); background: var(--bg-elev); margin-top: var(--s-8); }
.footer-grid { display: grid; grid-template-columns: 1.6fr repeat(3, 1fr); gap: var(--s-6); padding-block: var(--s-7); }
@media (max-width: 860px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-col h4 { font-size: var(--fs-xs); letter-spacing: .12em; text-transform: uppercase; color: var(--text-faint); margin-bottom: var(--s-4); }
.footer-col li + li { margin-top: var(--s-3); }
.footer-col a { font-size: var(--fs-sm); color: var(--text-dim); }
.footer-col a:hover { color: var(--text); }
.footer-bottom {
  border-top: 1px solid var(--border-soft); padding-block: var(--s-5);
  display: flex; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap;
  font-size: var(--fs-xs); color: var(--text-faint);
}
.footer-bottom__actions { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.footer-link-button {
  border: 0; padding: 0; background: none; color: var(--text-faint);
  font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.footer-link-button:hover { color: var(--text); }
.health-warning {
  border: 1px solid var(--warn); border-radius: var(--r-md);
  padding: var(--s-4); margin-block: var(--s-5);
  font-size: var(--fs-sm); font-weight: 700; color: var(--warn); text-align: center;
}

/* ----------------------------------------------------------- utilities --- */
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.center { text-align: center; }
.mono { font-family: var(--font-mono); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 50%; top: -100px; transform: translateX(-50%);
  z-index: 500; padding: var(--s-3) var(--s-5); background: var(--brand); color: #fff;
  border-radius: 0 0 var(--r-md) var(--r-md); font-weight: 600;
}
.skip-link:focus { top: 0; }
[hidden] { display: none !important; }
