/* ==========================================================================
   Apex Athletics — global styles
   Tailwind handles layout/utility work; this file holds the brand system:
   tokens, texture, buttons, product cards, motion and form controls.
   ========================================================================== */

/* ---------- 1. Design tokens ---------- */
:root {
  --carbon: #07090c;        /* page background */
  --panel: #0d1117;         /* cards, drawers */
  --panel-2: #141a24;       /* raised surfaces */
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --volt: #c6ff1a;          /* neon green accent */
  --surge: #2d7dff;         /* electric blue accent */
  --surge-2: #00c8ff;       /* cyan highlight */
  --text: #e9eef6;
  --muted: #8b95a7;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ---------- 2. Base ---------- */
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  background: var(--carbon);
  color: var(--text);
  font-family: "Barlow", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
::selection { background: var(--volt); color: var(--carbon); }
[x-cloak] { display: none !important; }

/* Film-grain overlay for depth (pure SVG noise, no image request) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Thin custom scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--carbon); }
::-webkit-scrollbar-thumb { background: #1f2733; border-radius: 10px; border: 2px solid var(--carbon); }
::-webkit-scrollbar-thumb:hover { background: var(--surge); }

/* ---------- 3. Header ---------- */
/* The whole header sticks, offset by the promo strip height so the strip
   scrolls away while the nav bar stays pinned. */
apex-header { display: block; position: sticky; top: -36px; z-index: 60; }
apex-footer { display: block; }

.nav-bar {
  background: rgba(7, 9, 12, 0.72);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.nav-link {
  position: relative;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.5rem 0;
  transition: color 0.2s;
}
.nav-link::after {
  content: "";
  position: absolute;
  left: 0; right: 100%; bottom: 0;
  height: 2px;
  background: var(--volt);
  transition: right 0.35s var(--ease-out);
}
.nav-link:hover, .nav-link.is-active { color: var(--text); }
.nav-link:hover::after, .nav-link.is-active::after { right: 0; }

/* ---------- 4. Typography helpers ---------- */
.eyebrow {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--volt);
}
.text-stroke {
  color: transparent;
  -webkit-text-stroke: 1.5px rgba(233, 238, 246, 0.55);
}
.text-gradient {
  background: linear-gradient(95deg, var(--surge) 0%, var(--surge-2) 45%, var(--volt) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.prose-apex p { color: #b7c0cf; line-height: 1.8; margin-bottom: 1.25rem; font-size: 1.075rem; }
.prose-apex h2 {
  font-family: "Big Shoulders Display", sans-serif;
  font-weight: 800; font-size: 2rem; text-transform: uppercase;
  margin: 2.5rem 0 1rem; color: var(--text);
}
.prose-apex blockquote {
  border-left: 3px solid var(--volt);
  padding: 0.25rem 0 0.25rem 1.25rem;
  margin: 2rem 0;
  font-family: "Big Shoulders Display", sans-serif;
  font-size: 1.75rem; font-weight: 700; line-height: 1.2; text-transform: uppercase;
}

/* ---------- 5. Buttons ---------- */
/* Angled "slash" buttons echo the logo's peak */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.6rem;
  font-family: "JetBrains Mono", monospace;
  font-weight: 700; font-size: 0.8rem;
  letter-spacing: 0.14em; text-transform: uppercase;
  padding: 1rem 1.75rem;
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
  transition: transform 0.25s var(--ease-out), background 0.25s, color 0.25s, box-shadow 0.25s;
  cursor: pointer;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-volt { background: var(--volt); color: var(--carbon); }
.btn-volt:hover { background: #d8ff5c; box-shadow: 0 0 40px rgba(198, 255, 26, 0.35); }
.btn-surge { background: var(--surge); color: #fff; }
.btn-surge:hover { background: #4a90ff; box-shadow: 0 0 40px rgba(45, 125, 255, 0.4); }
.btn-ghost { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 42px; height: 42px;
  border-radius: 999px;
  color: var(--text);
  transition: background 0.2s, color 0.2s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.08); color: var(--volt); }

/* ---------- 6. Chips & badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.65rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  padding: 0.35rem 0.6rem;
  background: var(--volt); color: var(--carbon);
}
.chip-blue { background: var(--surge); color: #fff; }
.chip-outline { background: transparent; color: var(--text); border: 1px solid var(--line-strong); }

/* ---------- 7. Product card ---------- */
.pcard {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  transition: border-color 0.35s, transform 0.45s var(--ease-out), box-shadow 0.45s;
  animation: card-in 0.6s var(--ease-out) both;
}
.pcard:hover {
  border-color: rgba(45, 125, 255, 0.55);
  transform: translateY(-6px);
  box-shadow: 0 24px 60px -24px rgba(45, 125, 255, 0.45);
}
.pcard-media { position: relative; aspect-ratio: 4 / 5; overflow: hidden; background: var(--panel-2); }
.pcard-media img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.9s var(--ease-out), opacity 0.6s;
}
.pcard:hover .pcard-media img { transform: scale(1.07); }
.pcard-media .pcard-alt { opacity: 0; }
.pcard:hover .pcard-media .pcard-alt { opacity: 1; }
/* diagonal light sweep on hover */
.pcard-media::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.14) 50%, transparent 65%);
  transform: translateX(-120%);
  transition: transform 0.9s var(--ease-out);
}
.pcard:hover .pcard-media::after { transform: translateX(120%); }
.pcard-add {
  position: absolute; right: 14px; top: 14px; z-index: 2;
  width: 44px; height: 44px; display: grid; place-items: center;
  background: var(--volt); color: var(--carbon);
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
  opacity: 0; transform: translateY(-8px);
  transition: opacity 0.3s, transform 0.3s var(--ease-out), background 0.2s;
}
.pcard:hover .pcard-add, .pcard-add:focus-visible { opacity: 1; transform: none; }
.pcard-add:hover { background: #fff; }
/* Touch devices have no hover, so keep the quick-add visible */
@media (hover: none) { .pcard-add { opacity: 1; transform: none; } }

@keyframes card-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* ---------- 8. Category tiles ---------- */
.cat-tile { position: relative; overflow: hidden; isolation: isolate; display: block; }
.cat-tile img { width: 100%; height: 100%; object-fit: cover; transition: transform 1.1s var(--ease-out), filter 0.6s; filter: grayscale(0.35) contrast(1.05); }
.cat-tile::before {
  content: ""; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(180deg, rgba(7, 9, 12, 0) 30%, rgba(7, 9, 12, 0.92) 100%);
}
.cat-tile:hover img { transform: scale(1.08); filter: grayscale(0) contrast(1.1); }
.cat-tile .cat-arrow { transition: transform 0.4s var(--ease-out), background 0.3s, color 0.3s; }
.cat-tile:hover .cat-arrow { transform: translateX(6px) rotate(-45deg); background: var(--volt); color: var(--carbon); }

/* ---------- 9. Motion ---------- */
/* Hero load: staggered rise; set --d inline for the delay */
.rise { animation: rise 1s var(--ease-out) both; animation-delay: var(--d, 0s); }
@keyframes rise { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }

/* Scroll reveal (toggled by IntersectionObserver in app.js) */
.reveal { opacity: 0; transform: translateY(28px); transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out); transition-delay: var(--d, 0s); }
.reveal.is-visible { opacity: 1; transform: none; }

/* Infinite ticker */
.marquee { display: flex; width: max-content; animation: marquee 32s linear infinite; }
.marquee:hover { animation-play-state: paused; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* Animated lane lines used behind the hero */
.lanes {
  background-image: repeating-linear-gradient(90deg, transparent 0 79px, rgba(255, 255, 255, 0.045) 79px 80px);
  mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
}
.speed-line {
  position: absolute; height: 1px; width: 40%;
  background: linear-gradient(90deg, transparent, var(--surge-2), transparent);
  animation: speed 3.2s linear infinite;
  opacity: 0.7;
}
@keyframes speed { from { transform: translateX(-120%); } to { transform: translateX(320%); } }

/* Glow blob background */
.glow { position: absolute; border-radius: 999px; filter: blur(90px); pointer-events: none; opacity: 0.55; }

/* Shake for invalid actions (e.g. add to cart without size) */
.shake { animation: shake 0.45s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* Diagonal section edge */
.cut-top { clip-path: polygon(0 40px, 100% 0, 100% 100%, 0 100%); }
.cut-hero { clip-path: polygon(14% 0, 100% 0, 100% 100%, 0 100%); }
@media (max-width: 1023px) { .cut-hero { clip-path: none; } }

/* ---------- 10. Forms ---------- */
.field {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0.9rem 1rem;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  border-radius: 0;
}
.field::placeholder { color: #5d6778; }
.field:focus { outline: none; border-color: var(--surge); box-shadow: 0 0 0 3px rgba(45, 125, 255, 0.2); }
.field.is-invalid { border-color: #ff4d6d; }
select.field {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23c6ff1a' stroke-width='2'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 1rem center; padding-right: 2.5rem;
}
select.field option { background: var(--panel); }

/* Custom checkbox/radio used in filters */
.check {
  appearance: none; width: 18px; height: 18px; flex-shrink: 0;
  border: 1.5px solid var(--line-strong); background: transparent;
  display: grid; place-items: center; cursor: pointer; transition: all 0.2s;
}
.check[type="radio"] { border-radius: 999px; }
.check:checked { background: var(--volt); border-color: var(--volt); }
.check:checked::after { content: ""; width: 8px; height: 8px; background: var(--carbon); }
.check[type="radio"]:checked::after { border-radius: 999px; }
.check:focus-visible { outline: 2px solid var(--surge); outline-offset: 2px; }

/* Size selector */
.size-btn {
  min-width: 56px; padding: 0.85rem 0.75rem;
  border: 1px solid var(--line-strong);
  font-family: "JetBrains Mono", monospace; font-size: 0.8rem; font-weight: 600;
  transition: all 0.2s;
}
.size-btn:hover { border-color: var(--text); }
.size-btn.is-selected { background: var(--volt); color: var(--carbon); border-color: var(--volt); }

/* Focus ring for keyboard users everywhere */
a:focus-visible, button:focus-visible { outline: 2px solid var(--volt); outline-offset: 3px; }

/* ---------- 11. Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
}
