/* ========================================================
   KEYPICKZ.COM - STYLESHEET
   Aesthetics: Cyber Tech / Dark Minimalist / Mechanical Keycap
   ======================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;600;700&display=swap');

:root {
  --primary-glow: rgba(99, 102, 241, 0.4);
  --accent-glow: rgba(244, 63, 94, 0.4);
  --keyboard-base: #0f172a;
}

html {
  overflow-x: clip;
  max-width: 100vw;
  width: 100%;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: #030712;
  color: #f8fafc;
  overflow-x: clip;
  max-width: 100vw;
  width: 100%;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #030712;
}
::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 9999px;
  border: 2px solid #030712;
}
::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* Background Gradients */
.bg-grid-pattern {
  background-size: 40px 40px;
  background-image: 
    linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
}

.glow-purple {
  filter: drop-shadow(0 0 25px rgba(99, 102, 241, 0.25));
}

/* Keycap 3D Simulation */
.sound-key {
  transform: translateY(0);
  transition: all 0.06s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 0 #020617, 0 8px 15px rgba(0, 0, 0, 0.4);
}

.sound-key:active,
.sound-key.key-active {
  transform: translateY(4px) !important;
  background-color: #4f46e5 !important;
  color: #ffffff !important;
  box-shadow: 0 0 0 #020617, 0 0 18px rgba(99, 102, 241, 0.7) !important;
}

/* Equalizer Bars Animation (Khôi phục chuẩn xác bản gốc 1:34 PM) */
#sound-wave {
  display: flex;
  align-items: flex-end;
}

@keyframes eqBounce {
  0%, 100% { height: 6px; }
  50% { height: 26px; }
}

.eq-bar-1 { animation: eqBounce 0.4s infinite ease-in-out; }
.eq-bar-2 { animation: eqBounce 0.6s infinite ease-in-out 0.1s; }
.eq-bar-3 { animation: eqBounce 0.5s infinite ease-in-out 0.2s; }
.eq-bar-4 { animation: eqBounce 0.7s infinite ease-in-out 0.15s; }
.eq-bar-5 { animation: eqBounce 0.45s infinite ease-in-out 0.05s; }

/* Glassmorphism Classes */
.glass-panel {
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Phone Mockup Frame for Bio View */
.phone-mockup {
  border: 12px solid #1e293b;
  border-radius: 40px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 35px rgba(99, 102, 241, 0.2);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* Custom sleek scrollbar for phone mockup (iOS floating style) */
.phone-mockup::-webkit-scrollbar {
  width: 4px;
}
.phone-mockup::-webkit-scrollbar-track {
  background: transparent;
  margin: 20px 0;
}
.phone-mockup::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 9999px;
}
.phone-mockup::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.45);
}

/* Logo Adaptations for Dark / Light Backgrounds */
.dark-logo {
  display: block;
}
.light-logo {
  display: none;
}

/* Khi sử dụng trên nền sáng */
.light-mode .dark-logo,
.light .dark-logo,
[data-theme="light"] .dark-logo {
  display: none !important;
}

.light-mode .light-logo,
.light .light-logo,
[data-theme="light"] .light-logo {
  display: block !important;
}

/* ========================================================
   3D SCROLL-DRIVEN EXPLODED KEYBOARD STYLES
   ======================================================== */
.perspective-stage {
  perspective: 1400px;
  transform-style: preserve-3d;
  touch-action: pan-y; /* Cho phép cuộn trang tự nhiên bằng ngón tay trên điện thoại */
}

.keyboard-3d-model {
  transform-style: preserve-3d;
  will-change: transform;
}

/* Khi đang đè chuột xoay 3D: con trỏ grabbing toàn trang, chống bôi đen văn bản */
body.is-orbiting-3d {
  user-select: none !important;
  -webkit-user-select: none !important;
  cursor: grabbing !important;
}

body.is-orbiting-3d * {
  cursor: grabbing !important;
}

body.is-orbiting-3d .layer-3d {
  pointer-events: none !important;
}

/* Thiết lập Z-index tự nhiên theo thứ tự trục Z để tầng phía trước luôn đón chuột chuẩn xác */
#layer-keycaps { z-index: 6; }
#layer-switches { z-index: 5; }
#layer-plate { z-index: 4; }
#layer-foam { z-index: 3; }
#layer-pcb { z-index: 2; }
#layer-case { z-index: 1; }

.layer-3d {
  transform-style: preserve-3d;
  will-change: transform, opacity, filter;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              filter 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  /* Mặc định khi chưa lướt đủ: Tắt pointer-events để cuộn và kéo xoay chuột mượt mà */
  pointer-events: none;
  cursor: default;
}

/* CHỈ KHI LƯỚT FULL (class layers-exploded-100 được kích hoạt): Mới cho phép tương tác hover */
.keyboard-3d-model.layers-exploded-100 .layer-3d {
  pointer-events: auto;
  cursor: pointer;
}

/* Trẻ hóa sự kiện: Các phần tử con không nuốt sự kiện chuột của tầng */
.keyboard-3d-model.layers-exploded-100 .layer-3d * {
  pointer-events: none;
}

/* Mở rộng hitbox bao quát cực kỳ nhạy và rộng quanh từng tầng (+22px trên dưới, +32px hai bên) */
.keyboard-3d-model.layers-exploded-100 .layer-3d::before {
  content: '';
  position: absolute;
  inset: -22px -32px;
  pointer-events: auto;
  z-index: 10;
  border-radius: 28px;
}

/* Khi rê chuột vào 1 tầng: Các tầng khác mờ đi rõ rệt */
.keyboard-3d-model.layers-exploded-100.has-layer-hover .layer-3d:not(.layer-hovered) {
  opacity: 0.16 !important;
  filter: blur(2px) grayscale(65%) !important;
}

/* Tầng đang được hover: Phát sáng rực rỡ, viền sáng LED */
.keyboard-3d-model.layers-exploded-100 .layer-3d.layer-hovered {
  opacity: 1 !important;
  filter: brightness(1.35) drop-shadow(0 0 30px rgba(99, 102, 241, 0.9)) !important;
  border-color: rgba(165, 180, 252, 1) !important;
  box-shadow: 0 0 40px rgba(99, 102, 241, 0.75), 
              0 0 20px rgba(168, 85, 247, 0.55), 
              inset 0 0 25px rgba(129, 140, 248, 0.45) !important;
  z-index: 50 !important;
}

/* Badge của tầng được hover cũng phóng to và phát sáng */
.keyboard-3d-model.layers-exploded-100 .layer-3d.layer-hovered > div.absolute {
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.95), 0 0 10px rgba(255, 255, 255, 0.8) !important;
  transform: scale(1.1) !important;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

/* Keycap miniature grid in 3D layer */
.keycap-mini {
  background: linear-gradient(145deg, #334155, #1e293b);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 3px 0 #0f172a, inset 0 1px 0 rgba(255, 255, 255, 0.2);
  border-radius: 5px;
}

.switch-mini {
  background: #1e293b;
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 4px;
  position: relative;
}
.switch-mini::after {
  content: '✚';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a5b4fc;
  font-size: 8px;
}

/* Hide scrollbar for slider */
.scrollbar-none::-webkit-scrollbar {
  display: none;
}
.scrollbar-none {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.cursor-grab {
  cursor: grab;
}
.cursor-grabbing {
  cursor: grabbing !important;
  user-select: none;
}

/* ROG Azoth Style Centered Hero Carousel (1 Main Product + Peeking Edges) */
.rog-main-slide {
  width: 78vw;
  max-width: 920px;
  margin-right: 32px;
  opacity: 0.38;
  transform: scale(0.96);
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.rog-main-slide.active-slide {
  opacity: 1;
  transform: scale(1);
}

/* Centralized Typography Reveal Effect ("Chữ dần dần hiện lên trông rất nghệ") */
@keyframes rogTextReveal {
  0% {
    opacity: 0;
    transform: translateY(22px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.rog-title-anim {
  animation: rogTextReveal 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.rog-desc-anim {
  animation: rogTextReveal 0.85s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

.rog-text-anim {
  animation: rogTextReveal 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.rog-header-container {
  width: 78vw;
  max-width: 920px;
  margin-left: auto;
  margin-right: auto;
}

/* Tối ưu điểm dừng cuộn mượt cho section sản phẩm không bị che bởi sticky header */
#products {
  scroll-margin-top: 5rem;
}

/* Đảm bảo khung 3D Scrollytelling luôn dính bên dưới thanh điều hướng (header h-16 = 4rem), không bao giờ bị che */
#scroll-showcase {
  scroll-margin-top: 4rem;
}

#scroll-showcase > div.sticky {
  top: 4rem !important;
  height: calc(100vh - 4rem) !important;
  height: calc(100dvh - 4rem) !important;
}

/* ========================================================
   RESPONSIVE DESIGN & MOBILE OPTIMIZATIONS (360px - 768px)
   ======================================================== */
@media (max-width: 768px) {
  .rog-main-slide {
    width: 88vw;
    max-width: 88vw;
    margin-right: 14px;
  }

  .rog-header-container {
    width: 88vw;
    max-width: 88vw;
  }

  .perspective-stage {
    perspective: 1100px;
  }
}

@media (max-width: 640px) {
  .rog-main-slide {
    width: 92vw;
    max-width: 92vw;
    margin-right: 10px;
  }

  .rog-header-container {
    width: 92vw;
    max-width: 92vw;
  }

  /* Khung bàn phím 3D vừa vặn màn hình điện thoại */
  .keyboard-3d-model {
    width: 280px !important;
    height: 130px !important;
  }

  /* Tinh chỉnh cỡ chữ nhãn các tầng không bị tràn */
  .layer-3d span, 
  .layer-3d div {
    font-size: 9.5px !important;
    line-height: 1.25;
  }

  /* Hitbox thu gọn vừa vặn */
  .keyboard-3d-model.layers-exploded-100 .layer-3d::before {
    inset: -12px -16px;
  }

  /* Phone Mockup Modal trên màn hình nhỏ */
  .phone-mockup {
    border-width: 6px !important;
    border-radius: 28px !important;
    max-height: 82vh !important;
    padding: 1rem !important;
  }
}

/* ================= KEYBOARD FINDER WIZARD PILLS ================= */
.wizard-pill {
  background-color: rgba(15, 23, 42, 0.7);
  border-color: rgba(30, 41, 59, 0.9);
  color: #94a3b8;
  cursor: pointer;
  user-select: none;
}

.wizard-pill:hover {
  background-color: rgba(30, 41, 59, 0.85);
  border-color: rgba(99, 102, 241, 0.4);
  color: #f1f5f9;
}

.wizard-pill.active {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.25), rgba(147, 51, 234, 0.2)) !important;
  border-color: #6366f1 !important;
  color: #ffffff !important;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
}

.wizard-pill.active span {
  color: #cbd5e1;
}
