/* ============================================================
   CRUNX — redesigned design system
   Tactile food-mag energy. Cream base, bold display, textures.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,500;12..96,600;12..96,700;12..96,800&family=Instrument+Serif:ital@0;1&family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ---- color tokens (palette: cream is default) ---- */
:root, [data-palette="cream"] {
  --bg:        #FBF1DE;
  --bg-2:      #F5E6CC;
  --bg-3:      #ECD7B1;
  --surface:   #FFFBF3;
  --ink:       #1A1208;
  --ink-soft:  #4A3A2A;
  --ink-mute:  #8B7A65;
  --line:      #1A12081A;
  --chili:     #E84A1F;
  --chili-deep:#B53609;
  --cheese:    #F7B500;
  --blue:      #2961FF;
  --lime:      #B8D63F;
  --berry:     #C73D6F;
}

[data-palette="midnight"] {
  --bg:        #14110A;
  --bg-2:      #1E1A10;
  --bg-3:      #2A2316;
  --surface:   #1E1A10;
  --ink:       #FBF1DE;
  --ink-soft:  #D9C9A4;
  --ink-mute:  #897C5E;
  --line:      #FBF1DE1F;
  --chili:     #FF6A3D;
  --chili-deep:#E84A1F;
  --cheese:    #FFCB2E;
  --blue:      #6B91FF;
  --lime:      #C8E454;
  --berry:     #E364A1;
}

[data-palette="sunset"] {
  --bg:        #FFE6DC;
  --bg-2:      #FFD2BF;
  --bg-3:      #FFBBA0;
  --surface:   #FFF1EA;
  --ink:       #2A0A04;
  --ink-soft:  #5C2418;
  --ink-mute:  #A87266;
  --line:      #2A0A041A;
  --chili:     #E03E66;
  --chili-deep:#8C1F3F;
  --cheese:    #FFB347;
  --blue:      #4A3FCC;
  --lime:      #FF9F5B;
  --berry:     #B8266F;
}

[data-palette="lime"] {
  --bg:        #F2F4E2;
  --bg-2:      #E5EBC8;
  --bg-3:      #D2DDA0;
  --surface:   #FAFCEC;
  --ink:       #0F1A0A;
  --ink-soft:  #2F3A1F;
  --ink-mute:  #6A7556;
  --line:      #0F1A0A1A;
  --chili:     #DD4A2B;
  --chili-deep:#8C2A14;
  --cheese:    #F4C234;
  --blue:      #1E5FA0;
  --lime:      #6A9C20;
  --berry:     #BC4F71;
}

/* ---- base reset ---- */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-font-smoothing: antialiased; }
html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow-x: clip;
}
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ---- custom scrollbar (consistent across the whole site) ---- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--ink-mute) transparent;
}
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background-color: var(--ink-mute);
  background-clip: padding-box;
  border: 3px solid transparent;
  border-radius: 999px;
  transition: background-color .2s ease;
}
::-webkit-scrollbar-thumb:hover {
  background-color: var(--ink-soft);
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:active {
  background-color: var(--chili);
  background-clip: padding-box;
}
::-webkit-scrollbar-corner {
  background: transparent;
}

/* ---- typography utilities ---- */
.font-display {
  font-family: 'Bricolage Grotesque', 'Bricolage', system-ui, sans-serif;
  font-variation-settings: 'wdth' 100, 'opsz' 96;
  letter-spacing: -0.02em;
}
.font-display-narrow {
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
  font-variation-settings: 'wdth' 75, 'opsz' 96;
  letter-spacing: -0.015em;
}
.font-italic-serif {
  font-family: 'Instrument Serif', Georgia, serif;
  font-style: italic;
  letter-spacing: -0.01em;
}
.font-mono {
  font-family: 'JetBrains Mono', monospace;
  font-feature-settings: 'ss01';
}
.label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}
h1, h2, h3, h4 { font-family: 'Bricolage Grotesque', system-ui, sans-serif; font-weight: 800; line-height: 0.95; letter-spacing: -0.025em; }

/* ---- paper grain texture (used as overlay) ---- */
.grain {
  position: relative;
}
.grain::before {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.1, 0 0 0 0 0.07, 0 0 0 0 0.03, 0 0 0 0.5 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.5'/></svg>");
  mix-blend-mode: multiply;
  opacity: 0.18;
  z-index: 1;
}
.grain > * { position: relative; z-index: 2; }

/* dot pattern */
.dots {
  background-image: radial-gradient(var(--ink) 1.1px, transparent 1.1px);
  background-size: 22px 22px;
  background-position: 0 0;
  opacity: 0.08;
}

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 14px 22px;
  font-weight: 700; font-size: 15px;
  border-radius: 999px;
  transition: transform .25s, box-shadow .25s, background .2s;
  cursor: pointer; white-space: nowrap;
  border: 2px solid transparent;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { background: var(--chili); }
.btn-chili   { background: var(--chili); color: #fff; }
.btn-chili:hover { background: var(--chili-deep); }
.btn-cheese  { background: var(--cheese); color: var(--ink); }
.btn-ghost   { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn-ghost:hover { background: var(--ink); color: var(--bg); }
.btn-sm { padding: 10px 18px; font-size: 13px; }
.btn-lg { padding: 18px 28px; font-size: 16px; }

/* ---- pill / chip ---- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.chip-solid { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip-chili { background: var(--chili); color: #fff; border-color: var(--chili); }
.chip-cheese { background: var(--cheese); color: var(--ink); border-color: var(--cheese); }

/* ---- card ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
}

/* ---- container ---- */
.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.container-wide { max-width: 1440px; margin: 0 auto; padding: 0 24px; }
.container-narrow { max-width: 980px; margin: 0 auto; padding: 0 24px; }

/* ---- sticker effect ---- */
.sticker {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  text-align: center;
  line-height: 0.95;
  letter-spacing: -0.02em;
  filter: drop-shadow(2px 4px 0 rgba(26, 18, 8, 0.18));
}

/* hand-drawn underline */
.hand-underline {
  position: relative; display: inline-block;
}
.hand-underline::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -0.15em;
  height: 0.42em;
  background: var(--cheese);
  z-index: -1;
  border-radius: 999px;
  transform: rotate(-1deg);
}

/* squiggly underline svg-based */
.squiggle::after {
  content: "";
  position: absolute;
  left: -2%; right: -2%; bottom: -0.2em;
  height: 0.35em;
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='12' viewBox='0 0 100 12' preserveAspectRatio='none'><path d='M0 6 C 12 0, 25 12, 50 6 S 88 0, 100 6' stroke='%23E84A1F' stroke-width='3' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

/* ---- marquee animation ---- */
@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
.marquee-track { display: inline-flex; animation: marquee 60s linear infinite; }

/* fade-in-up reveal */
.reveal {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity .8s cubic-bezier(0.22, 1, 0.36, 1), transform .8s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal.in-view { opacity: 1; transform: none; }

/* utility */
.flex { display: flex; }
.grid { display: grid; }
.relative { position: relative; }
.text-center { text-align: center; }
.cursor-grab { cursor: grab; }
.cursor-grab:active { cursor: grabbing; }

/* sticky header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: color-mix(in oklab, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

/* scroll-snap shelf */
.shelf-wrap { overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scrollbar-width: none; }
.shelf-wrap::-webkit-scrollbar { display: none; }
.shelf-track { display: flex; gap: 24px; padding: 0 24px 24px; }
.shelf-track > * { scroll-snap-align: start; flex: 0 0 auto; }

/* ---- Tweaks panel (custom, simple) ---- */
.tweaks-fab {
  position: fixed; right: 18px; bottom: 18px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--ink); color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; cursor: pointer;
  box-shadow: 0 12px 30px -8px rgba(0,0,0,0.4);
  z-index: 100;
  border: 2px solid var(--bg);
}
.tweaks-panel {
  position: fixed; right: 18px; bottom: 88px;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  z-index: 100;
  box-shadow: 0 24px 50px -16px rgba(0,0,0,0.3);
  font-size: 14px;
}
.tweaks-panel h4 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--ink-mute);
  margin-bottom: 10px;
}
.tweaks-section { margin-bottom: 18px; }
.tweaks-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tweak-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 2px solid transparent;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.tweak-pill.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* swatch */
.swatch {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 3px solid var(--surface);
  outline: 2px solid var(--line);
  cursor: pointer;
}
.swatch.active { outline-color: var(--ink); outline-width: 3px; }

/* ---- product grid card ---- */
.product-card {
  background: var(--surface);
  border-radius: 24px;
  padding: 16px;
  border: 1px solid var(--line);
  transition: transform .3s cubic-bezier(0.22, 1, 0.36, 1), box-shadow .3s;
  position: relative;
  overflow: hidden;
}
.product-card:hover {
  transform: translateY(-6px) rotate(-0.6deg);
  box-shadow: 0 24px 40px -16px rgba(26, 18, 8, 0.18);
}
.product-card .photo-frame {
  position: relative;
  aspect-ratio: 1;
  border-radius: 18px;
  overflow: hidden;
  background: var(--bg-2);
  margin-bottom: 14px;
}
.product-card .photo-frame img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .6s cubic-bezier(0.22, 1, 0.36, 1);
}
.product-card:hover .photo-frame img { transform: scale(1.06); }

/* corner sticker */
.corner-sticker {
  position: absolute;
  top: -10px; right: -10px;
  z-index: 4;
  transform: rotate(8deg);
}

/* small spinner during drag */
@keyframes wobble {
  0%, 100% { transform: rotate(-2deg); }
  50% { transform: rotate(2deg); }
}
.wobble { animation: wobble 1.6s ease-in-out infinite; }

/* parallax / scroll-pinned */
.float-y {
  animation: float-y 6s ease-in-out infinite;
}
@keyframes float-y {
  0%, 100% { transform: translateY(0) rotate(var(--rot, 0deg)); }
  50% { transform: translateY(-10px) rotate(var(--rot, 0deg)); }
}

/* mobile */
@media (max-width: 900px) {
  .container { padding: 0 18px; }
}

/* ---- Cart Drawer ---- */
.cart-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 18, 8, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.cart-drawer-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}
.cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  box-shadow: -10px 0 40px rgba(0,0,0,0.15);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  border-left: 2px solid var(--ink);
}
.cart-drawer.is-open {
  transform: translateX(0);
}
.cart-drawer-header {
  padding: 20px 24px;
  border-bottom: 2px dashed var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.cart-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}
.cart-drawer-footer {
  padding: 24px;
  background: var(--bg-2);
  border-top: 2px solid var(--ink);
}
.cart-item {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px dashed var(--line);
  align-items: center;
}
.cart-item-img {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--bg-2);
  border: 1px solid var(--line);
}
.cart-item-info {
  flex: 1;
}
.cart-item-title {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
  margin-bottom: 4px;
}
.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.qty-btn {
  width: 24px;
  height: 24px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}
.qty-btn:hover {
  background: var(--ink);
  color: var(--bg);
}

/* ---- Product Detail Page Specific Styles ---- */
.product-detail-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 48px;
  align-items: start;
  margin-top: 40px;
}
@media (max-width: 768px) {
  .product-detail-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}

.product-image-container {
  border-radius: 32px;
  overflow: hidden;
  border: 2px solid var(--ink);
  box-shadow: 8px 8px 0 var(--ink);
}

.accordion-item {
  border-bottom: 1px solid var(--line);
}
.accordion-header {
  padding: 16px 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 16px;
}
.accordion-content {
  padding-bottom: 16px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.6;
}

