/* ============================================================
   MENU ANIMATIONS — exact values from design spec
   ============================================================ */
@keyframes ctgDraw {
  from { stroke-dashoffset: 640; }
  to   { stroke-dashoffset: 0; }
}

@keyframes ctgRide {
  from { offset-distance: 0%; }
  to   { offset-distance: 100%; }
}

@keyframes ctgMenuItem {
  from { opacity: 0; transform: translateX(46px); }
  to   { opacity: 1; transform: none; }
}

/* Lock scroll while any overlay is open */
body.ctg-menu-open,
body.ctg-cart-open {
  overflow: hidden;
}

/* ============================================================
   COMPONENT A: FULLSCREEN MENU OVERLAY
   Exact spec: transform:translateY(-100%) hidden → translateY(0) open
   transition: .55s cubic-bezier(.62,.04,.2,1)
   Nav z-index is 55 so this at 80 correctly floats above it.
   ============================================================ */
#ctg-menu {
  position: fixed;
  left: 0; right: 0; top: 0;
  height: 75vh;
  z-index: 80;
  background: #0E0A04;
  border-bottom: 5px solid #0A0703;
  box-shadow: 0 26px 60px rgba(0, 0, 0, .6);
  overflow: hidden;

  /* hidden state */
  transform: translateY(-100%);
  visibility: hidden;
  transition: transform .55s cubic-bezier(.62, .04, .2, 1),
              visibility 0s linear .55s;
}

#ctg-menu.is-open {
  transform: translateY(0);
  visibility: visible;
  transition: transform .55s cubic-bezier(.62, .04, .2, 1),
              visibility 0s;
}

/* ---- Background decorative layers ---- */
.ctg-menu__grid {
  position: absolute; inset: 0;
  opacity: .08;
  pointer-events: none;
  background-image: repeating-linear-gradient(45deg,  #FFB81C 0 2px, transparent 2px 22px),
                    repeating-linear-gradient(-45deg, #FFB81C 0 2px, transparent 2px 22px);
  background-size: 32px 32px;
}

.ctg-menu__glow {
  position: absolute; inset: 0;
  pointer-events: none;
  background: radial-gradient(720px 420px at 82% 8%, rgba(255, 184, 28, .16), transparent 60%);
}

/* ---- Close button ---- */
.ctg-menu__close {
  position: absolute; top: 20px; right: 24px; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  background: #FF3B2F;
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  padding: 9px 12px;
  border: 2px solid #0A0703;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 3px 3px 0 #0A0703;
  transition: background .15s ease;
}

.ctg-menu__close:hover { background: #cc2e25; }

/* ---- Inner layout: flex row, snake-col + links ---- */
.ctg-menu__inner {
  position: relative;
  height: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 48px;
}

/* ---- Snake column ---- */
.ctg-menu__snake-col {
  position: relative;
  width: 120px; height: 480px;
  flex: none;
}

.ctg-menu__snake-svg {
  position: absolute; left: 0; top: 0;
  overflow: visible;
}

.ctg-menu__snake-path {
  filter: drop-shadow(2px 2px 0 #0A0703);
}

/* Draw animation fires when menu opens */
#ctg-menu.is-open .ctg-menu__snake-path {
  animation: ctgDraw 1.2s ease forwards;
}

/* Snake head rides the path */
.ctg-menu__snake-head {
  position: absolute; left: 0; top: 0;
  width: 56px; height: 56px;
  offset-path: path("M60,0 C20,60 100,120 60,180 C20,240 100,300 60,360 C30,410 84,448 60,480");
  offset-rotate: 0deg;
  offset-distance: 0%;
}

#ctg-menu.is-open .ctg-menu__snake-head {
  animation: ctgRide 1.2s ease forwards;
}

.ctg-menu__snake-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 3px solid #0A0703;
  overflow: hidden;
  background: #FFB81C;
  box-shadow: 0 0 0 4px #FFB81C, 4px 4px 0 #0A0703;
}

.ctg-menu__snake-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

/* ---- Nav links column ---- */
.ctg-menu__links {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  max-height: 100%;
}

.ctg-menu__item {
  display: flex;
  align-items: baseline;
  gap: 20px;
  text-decoration: none;
  font-family: 'Bungee', sans-serif;
  font-size: clamp(28px, 4.6vw, 50px);
  color: #FFF3D2;
  padding: 8px 0;
  border-bottom: 2px solid rgba(255, 184, 28, .12);
  transition: color .18s ease, transform .18s ease;
  opacity: 0; /* reset between opens */
}

.ctg-menu__item:hover {
  color: #FFB81C;
  transform: translateX(8px);
}

.ctg-menu__num {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  color: #FFB81C;
  flex: none;
}

.ctg-menu__label { flex: 1; }

.ctg-menu__arrow {
  color: #A6FF1A;
  flex: none;
}

/* Stagger: items + socials row animate in on open (0.06s apart) */
#ctg-menu.is-open [data-mi] {
  animation: ctgMenuItem .5s ease both;
}

#ctg-menu.is-open .ctg-menu__links > [data-mi]:nth-child(1) { animation-delay: .18s; }
#ctg-menu.is-open .ctg-menu__links > [data-mi]:nth-child(2) { animation-delay: .24s; }
#ctg-menu.is-open .ctg-menu__links > [data-mi]:nth-child(3) { animation-delay: .30s; }
#ctg-menu.is-open .ctg-menu__links > [data-mi]:nth-child(4) { animation-delay: .36s; }
#ctg-menu.is-open .ctg-menu__links > [data-mi]:nth-child(5) { animation-delay: .42s; }

/* Reset to hidden when closed so re-open re-triggers stagger */
#ctg-menu:not(.is-open) [data-mi] {
  animation: none;
  opacity: 0;
}

/* ---- Social buttons ---- */
.ctg-menu__socials {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 24px;
  opacity: 0; /* controlled by data-mi animation */
}

.ctg-menu__social {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  text-decoration: none;
  color: #fff;
  padding: 11px 13px;
  border: 2px solid #0A0703;
  border-radius: 5px;
  box-shadow: 3px 3px 0 #0A0703;
  transition: opacity .15s ease;
}

.ctg-menu__social:hover { opacity: .85; }

.ctg-menu__social--twitch  { background: #9146FF; }
.ctg-menu__social--youtube { background: #FF0000; }
.ctg-menu__social--discord { background: #5865F2; }

/* ============================================================
   HAMBURGER → X  (JS targets sp[0] sp[1] sp[2] via setBurger)
   ============================================================ */
.ctg-nav__bar {
  display: block;
  transition: transform .3s ease, opacity .3s ease;
}

/* ---- Mobile ---- */
@media (max-width: 700px) {
  .ctg-menu__snake-col { display: none; }
  .ctg-menu__inner     { padding: 0 20px; }
  .ctg-menu__item      { font-size: clamp(24px, 8vw, 38px); }
}

/* ============================================================
   COMPONENT B: CART DRAWER (slide from right)
   ============================================================ */

/* Backdrop */
#ctg-cart-backdrop {
  position: fixed; inset: 0;
  z-index: 98;
  background: rgba(0, 0, 0, .65);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}

#ctg-cart-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* Drawer panel */
.ctg-cart {
  position: fixed;
  top: 0; right: 0;
  height: 100vh;
  width: 380px;
  max-width: 100vw;
  z-index: 100;
  background: #15100A;
  border-left: 4px solid #0A0703;
  display: flex;
  flex-direction: column;

  /* Hidden state */
  transform: translateX(100%);
  transition: transform .35s cubic-bezier(.4, 0, .2, 1);
}

.ctg-cart.is-open {
  transform: translateX(0);
}

/* Cart header */
.ctg-cart__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 2px solid rgba(255, 184, 28, .18);
  flex-shrink: 0;
}

.ctg-cart__title {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: #FFB81C;
}

.ctg-cart__close {
  background: none;
  border: none;
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  color: #FFB81C;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.ctg-cart__close:hover { color: #A6FF1A; }

/* Cart body (fragment target) */
#ctg-cart-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Empty state */
.ctg-cart__empty {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: #9C8A60;
  text-align: center;
  padding: 48px 24px;
  line-height: 1.8;
  margin: 0;
}

/* Items list */
.ctg-cart__items {
  list-style: none;
  margin: 0;
  padding: 12px 0;
  flex: 1;
}

.ctg-cart__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(255, 184, 28, .08);
  transition: opacity .2s ease;
}

.ctg-cart__item.ctg-removing {
  opacity: .35;
  pointer-events: none;
}

.ctg-cart__thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border: 1px solid rgba(255, 184, 28, .2);
  flex-shrink: 0;
}

.ctg-cart__item-details {
  flex: 1;
  min-width: 0;
}

.ctg-cart__item-name {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #FFF3D2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ctg-cart__item-meta {
  display: block;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #9C8A60;
  margin-top: 4px;
}

.ctg-cart__remove {
  background: none;
  border: none;
  font-size: 16px;
  color: #9C8A60;
  cursor: pointer;
  padding: 4px 6px;
  text-decoration: none;
  flex-shrink: 0;
  transition: color .15s ease;
}

.ctg-cart__remove:hover { color: #FF3B2F; }

/* Footer */
.ctg-cart__footer {
  padding: 16px 20px 24px;
  border-top: 2px solid rgba(255, 184, 28, .18);
  flex-shrink: 0;
}

.ctg-cart__subtotal {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: #FFF3D2;
  margin-bottom: 16px;
}

.ctg-cart__subtotal span:last-child {
  color: #FFB81C;
}

.ctg-cart__checkout {
  display: block;
  width: 100%;
  text-align: center;
  background: #FFB81C;
  color: #0A0703;
  font-family: 'Bungee', sans-serif;
  font-size: 16px;
  padding: 14px 20px;
  text-decoration: none;
  border-radius: 2px;
  transition: background .2s ease;
  margin-bottom: 10px;
}

.ctg-cart__checkout:hover { background: #A6FF1A; color: #0A0703; }

.ctg-cart__view-cart {
  display: block;
  text-align: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: #9C8A60;
  text-decoration: none;
  padding: 8px;
  transition: color .15s ease;
}

.ctg-cart__view-cart:hover { color: #FFB81C; }

/* Mobile: narrower drawer */
@media (max-width: 420px) {
  .ctg-cart { width: 100vw; }
}
