/* ============================================================
   NUTIMPEX — HOME DYNAMIC LAYER
   Scroll-driven almond, parallax, reveals, counters,
   floating nuts, magnetic CTA, tweaks panel.
   Loaded ONLY on index.html (after styles.css).
   ============================================================ */

/* ------------------------------------------------------------
   0. MOTION CONFIG VARS (driven by Tweaks)
   ------------------------------------------------------------ */
:root {
  --fx-intensity: 0.8;       /* 0..1   global motion multiplier   */
  --fx-almond-size: 46;      /* vmin   base footprint of kernel    */
  --fx-glow: rgba(196,168,130,0.55);
}

/* ------------------------------------------------------------
   1. HERO REWORK — gradient stage + spinning kernel
   ------------------------------------------------------------ */
.hero {
  isolation: isolate;                 /* clean stacking context  */
  background: radial-gradient(125% 95% at 70% 16%, #1d3866 0%, #122a52 42%, #0b1730 100%);
}

/* dim the original photo so the kernel reads as the focal point */
.hero-bg {
  opacity: 0.16;
  filter: saturate(0.85) contrast(1.05);
  z-index: 0;
  will-change: transform;
}

/* warm vignette so the white headline keeps contrast over the kernel */
.hero-overlay {
  background:
    radial-gradient(72% 82% at 26% 50%, rgba(9,18,38,0.74) 0%, rgba(9,18,38,0.36) 40%, rgba(9,18,38,0) 70%),
    linear-gradient(180deg, rgba(11,23,48,0.40) 0%, rgba(11,23,48,0.0) 24%, rgba(11,23,48,0.30) 100%);
  z-index: 1;
}

.hero-content { z-index: 3; }
.scroll-indicator { z-index: 4; }

/* ---- the kernel layer (fixed overlay, no layout impact) ---- */
.almond-fx {
  position: fixed;
  inset: 0;
  z-index: 2;                          /* above scrim, below headline text */
  display: grid;
  place-items: center;
  pointer-events: none;
  perspective: 1400px;
  will-change: opacity;
}

.almond-stage {
  width: calc(var(--fx-almond-size) * 1vmin);
  height: calc(var(--fx-almond-size) * 1vmin);
  position: relative;
  display: grid;
  place-items: center;
  transform-style: preserve-3d;
  transform-origin: 50% 50%;   /* spin & travel pivot at the kernel centre */
  will-change: transform;
}

/* soft radiant halo behind the kernel — opacity driven by Tweaks (0 = off) */
.almond-stage::before {
  content: "";
  position: absolute;
  inset: -22%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, var(--fx-glow) 0%, rgba(196,168,130,0.12) 38%, rgba(196,168,130,0) 68%);
  filter: blur(6px);
  opacity: var(--fx-glow-op, 0.5);
  z-index: -1;
}

.almond {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  transform-origin: 50% 50%;
  filter: drop-shadow(0 6px 22px rgba(0,0,0,0.32));
}

.almond-drop-hint {
  position: absolute;
  bottom: 14%;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.85);
  background: rgba(15,31,61,0.78);
  border: 1px dashed rgba(196,168,130,0.7);
  padding: 10px 18px;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.almond-drop-hint.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ------------------------------------------------------------
   2. FLOATING NUTS FIELD
   ------------------------------------------------------------ */
.nut-field {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.nut {
  position: absolute;
  height: auto;
  display: block;
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 5px 12px rgba(0,0,0,0.35));
  will-change: transform, opacity;
}

/* ------------------------------------------------------------
   3. SCROLL REVEALS
   ------------------------------------------------------------ */
.reveal {
  opacity: 0;
  transform: translateY(34px);
  transition: opacity 0.8s cubic-bezier(.22,.61,.36,1),
              transform 0.8s cubic-bezier(.22,.61,.36,1);
  transition-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}
.reveal.in {
  opacity: 1;
  transform: none;
}

/* ------------------------------------------------------------
   4. STAT COUNTERS — subtle pop when they land
   ------------------------------------------------------------ */
.stat-number.counting { color: var(--color-tan); }
.stat-item.in .stat-number {
  animation: statPop 0.6s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes statPop {
  0%   { transform: translateY(10px) scale(0.96); opacity: 0; }
  100% { transform: none; opacity: 1; }
}

/* ------------------------------------------------------------
   5. MAGNETIC / SHINE CTA
   ------------------------------------------------------------ */
.btn-magnetic {
  position: relative;
  overflow: hidden;
  will-change: transform;
  transition: transform 0.18s cubic-bezier(.22,.61,.36,1), background 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.btn-magnetic::after {
  content: "";
  position: absolute;
  top: 0; left: -120%;
  width: 60%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,0.55), transparent);
  transform: skewX(-18deg);
  pointer-events: none;
}
.btn-magnetic:hover {
  box-shadow: 0 14px 34px rgba(196,168,130,0.4);
}
.btn-magnetic:hover::after {
  animation: btnShine 0.9s ease;
}
@keyframes btnShine {
  to { left: 160%; }
}

/* ------------------------------------------------------------
   6. TWEAKS PANEL (vanilla)
   ------------------------------------------------------------ */
.tw-panel {
  position: fixed;
  top: 84px;
  right: 20px;
  z-index: 4000;
  width: 290px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  background: #0f1f3d;
  color: #fff;
  border: 1px solid rgba(196,168,130,0.35);
  border-radius: 10px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.5);
  font-family: 'DM Sans', sans-serif;
  display: none;
  user-select: none;
}
.tw-panel.open { display: block; }

.tw-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  cursor: grab;
}
.tw-head.dragging { cursor: grabbing; }
.tw-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 17px;
}
.tw-close {
  width: 26px; height: 26px;
  border-radius: 6px;
  color: rgba(255,255,255,0.7);
  font-size: 18px; line-height: 1;
  display: grid; place-items: center;
  transition: background 0.15s, color 0.15s;
}
.tw-close:hover { background: rgba(255,255,255,0.1); color: #fff; }

.tw-body { padding: 8px 16px 18px; }

.tw-section {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-tan);
  margin: 18px 0 10px;
}
.tw-section:first-child { margin-top: 6px; }

.tw-row { margin-bottom: 14px; }
.tw-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  margin-bottom: 7px;
}
.tw-val { color: var(--color-tan); font-variant-numeric: tabular-nums; font-size: 12px; }

.tw-row input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 3px;
  background: rgba(255,255,255,0.18);
  outline: none;
}
.tw-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--color-tan);
  cursor: pointer;
  border: 2px solid #0f1f3d;
  box-shadow: 0 0 0 1px var(--color-tan);
}
.tw-row input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border: 2px solid #0f1f3d;
  border-radius: 50%; background: var(--color-tan); cursor: pointer;
}

/* segmented radio */
.tw-seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 7px;
  padding: 4px;
}
.tw-seg button {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: rgba(255,255,255,0.7);
  padding: 7px 4px;
  border-radius: 5px;
  transition: background 0.15s, color 0.15s;
}
.tw-seg button.active {
  background: var(--color-tan);
  color: #0f1f3d;
}

/* toggle */
.tw-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  padding: 6px 0;
  cursor: pointer;
}
.tw-switch {
  width: 40px; height: 23px;
  border-radius: 99px;
  background: rgba(255,255,255,0.18);
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}
.tw-switch::after {
  content: "";
  position: absolute;
  top: 2.5px; left: 2.5px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.tw-toggle.on .tw-switch { background: var(--color-tan); }
.tw-toggle.on .tw-switch::after { transform: translateX(17px); }

.tw-hint {
  font-size: 11px;
  line-height: 1.5;
  color: rgba(255,255,255,0.45);
  margin-top: 4px;
}

/* ------------------------------------------------------------
   7. REDUCED MOTION
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .nut { display: none; }
  .scroll-arrow { animation: none; }
}
