/* ===== HACK GATES ===== *
 * Built entirely from the site's existing design tokens (see style.css :root)
 * so the lavender/glass theme is unchanged — this just adds Vee's hacker layer.
 */

.hack-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  background: rgba(8, 5, 14, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.hack-overlay.is-open {
  opacity: 1;
}

body.hack-open {
  overflow: hidden;
}

.hack-card {
  position: relative;
  width: min(440px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--space-lg) var(--space-md) var(--space-md);
  text-align: center;
  box-shadow: var(--border-glow), 0 24px 60px rgba(0, 0, 0, 0.55);
  transform: translateY(12px) scale(0.98);
  transition: transform 0.22s ease;
}

.hack-overlay.is-open .hack-card {
  transform: translateY(0) scale(1);
}

.hack-card.is-fail {
  animation: hack-shake 0.4s ease;
}

.hack-card.is-win {
  border-color: rgba(179, 157, 219, 0.55);
  box-shadow: 0 0 36px rgba(179, 157, 219, 0.55), 0 24px 60px rgba(0, 0, 0, 0.55);
}

@keyframes hack-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.hack-close {
  position: absolute;
  top: 0.6rem;
  right: 0.85rem;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease;
}

.hack-close:hover {
  color: var(--text-primary);
}

.hack-eyebrow {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--accent-lavender);
  margin-bottom: 0.35rem;
}

.hack-title {
  font-family: 'Rajdhani', sans-serif;
  color: var(--text-primary);
  letter-spacing: 0.04em;
}

.hack-subtitle {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin: 0.25rem auto var(--space-md);
  max-width: 30ch;
}

.hack-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
}

.hack-status {
  min-height: 1.4em;
  margin-top: var(--space-sm);
  font-family: 'Rajdhani', sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.82rem;
  color: var(--text-soft);
}

.hack-status.is-fail { color: #e88aa8; }
.hack-status.is-win { color: var(--accent-lavender); }

.hack-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  margin-top: var(--space-sm);
}

.hack-btn {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.85rem;
  color: var(--text-primary);
  background: rgba(179, 157, 219, 0.14);
  border: 1px solid rgba(179, 157, 219, 0.4);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1.6rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.hack-btn:hover {
  background: rgba(179, 157, 219, 0.26);
  border-color: var(--accent-lavender);
}

.hack-skip {
  font-size: 0.78rem;
  color: var(--text-secondary);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.hack-skip.is-visible {
  opacity: 0.7;
  pointer-events: auto;
}

.hack-skip:hover { opacity: 1; }

/* ---- shared timer bar (Thermite) ---- */
.hack-timer {
  width: 100%;
  max-width: 280px;
  height: 6px;
  border-radius: 999px;
  background: rgba(179, 157, 219, 0.14);
  overflow: hidden;
}

.hack-timer-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-champagne), var(--accent-lavender));
}

.hack-timer-fill.hack-timer-show {
  background: linear-gradient(90deg, var(--accent-lavender), var(--accent-blush));
}

.hack-timer-fill.hack-timer-pin {
  background: linear-gradient(90deg, var(--accent-blush), var(--accent-lavender));
}

.hack-timer.hack-timer-full {
  max-width: none;
  height: 8px;
}

/* ---- Thermite grid ---- */
.hack-grid {
  display: grid;
  grid-template-columns: repeat(var(--hack-grid-size, 5), 1fr);
  gap: 0.5rem;
  width: min(280px, 80vw);
}

.hack-cell {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(179, 157, 219, 0.2);
  background: rgba(28, 18, 42, 0.6);
  cursor: pointer;
  transition: background 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, transform 0.1s ease;
}

.hack-cell:hover {
  border-color: rgba(179, 157, 219, 0.5);
}

.hack-cell:active {
  transform: scale(0.94);
}

.hack-cell.lit {
  background: var(--accent-lavender);
  border-color: var(--accent-lavender);
  box-shadow: var(--border-glow);
}

.hack-cell.correct {
  background: rgba(179, 157, 219, 0.85);
  border-color: var(--accent-lavender);
  box-shadow: var(--border-glow);
}

.hack-cell.wrong {
  background: rgba(214, 92, 128, 0.55);
  border-color: #e88aa8;
}

/* ---- PinCracker — one row of 4 slots, each with a feedback bar under it ---- */
.hack-pin-board {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: clamp(1.2rem, 8vw, 3rem);
  width: 100%;
  padding: 1.5rem 0;
}

.hack-pin-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  border-radius: var(--radius-sm);
  transition: background 0.18s ease;
}

/* Active column during the staggered crack reveal. */
.hack-pin-slot.flash {
  background: radial-gradient(
    circle at center,
    rgba(179, 157, 219, 0.45),
    rgba(179, 157, 219, 0) 70%
  );
}

.hack-pin-digit {
  height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1.8rem;
  color: var(--text-primary);
}

/* The feedback bar: dim until submitted, then classic green/yellow/red so the
   meaning reads instantly under the time limit (the rest of the UI stays on
   the lavender theme). Correct = green, present = yellow, absent = red. */
.hack-pin-bar {
  width: 3rem;
  height: 6px;
  border-radius: 999px;
  background: rgba(179, 157, 219, 0.22);
  transition: background 0.18s ease, box-shadow 0.18s ease;
}

.hack-pin-bar.correct {
  background: #4ade80;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
}

.hack-pin-bar.present {
  background: #facc15;
}

.hack-pin-bar.absent {
  background: #f87171;
}

/* Full-width "Crack" submit button — inherits the lavender .hack-btn look. */
.hack-crack {
  width: 100%;
  padding: 0.9rem 0;
  font-size: 1.1rem;
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--accent-lavender);
}

/* ---- Cuff Break — sweep a cube along a rail, stop it on the lit slot; 3x ---- */
/* Round progress pips: one per required stop, filled green as you clear them. */
.hack-cb-pips {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.hack-cb-pip {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: rgba(179, 157, 219, 0.22);
  transition: background 0.18s ease, box-shadow 0.18s ease;
}

.hack-cb-pip.done {
  background: #4ade80;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
}

/* The control bar: square "E" key on the left, the rail filling the rest. */
.hack-cb-bar {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  width: 100%;
  height: 3.5rem;
  margin: 1rem 0 0.6rem;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, rgba(18, 12, 28, 0.92), rgba(30, 40, 52, 0.7));
  border: 1px solid rgba(179, 157, 219, 0.18);
}

/* The "E" stop key — green/teal, flips red on a miss (matches the reference). */
.hack-cb-key {
  flex: 0 0 auto;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 5px;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1.4rem;
  color: #06281c;
  background: radial-gradient(circle at 50% 40%, #5eead4, #0f9b76);
  box-shadow: 0 0 8px rgba(45, 212, 191, 0.4);
  cursor: pointer;
  transition: transform 0.1s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.hack-cb-key:hover { transform: scale(1.04); }
.hack-cb-key:active { transform: scale(0.95); }

.hack-cb-key.lose {
  color: #2a0b0b;
  background: radial-gradient(circle at 50% 40%, #fca5a5, #b91c1c);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.55);
}

.hack-cb-track {
  position: relative;
  flex: 1 1 auto;
  height: 100%;
  border-radius: 5px;
  background: rgba(10, 7, 16, 0.6);
  outline: 1px solid rgba(179, 157, 219, 0.18);
  overflow: hidden;
}

/* The target slot — a faint green column with bright top/bottom tick bars.
   Green so "land here = success" reads instantly, like the PinCracker markers. */
.hack-cb-slot {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1.8rem;
  transform: translateX(-50%);
  background: rgba(74, 222, 128, 0.12);
  border-left: 1px solid rgba(74, 222, 128, 0.4);
  border-right: 1px solid rgba(74, 222, 128, 0.4);
}

.hack-cb-slot::before,
.hack-cb-slot::after {
  content: '';
  position: absolute;
  left: 50%;
  width: 100%;
  height: 4px;
  transform: translateX(-50%);
  border-radius: 2px;
  background: rgba(74, 222, 128, 0.95);
}

.hack-cb-slot::before { top: 0; }
.hack-cb-slot::after { bottom: 0; }

/* The sweeping block. Lavender while moving; flips green/red on stop. */
.hack-cb-cube {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 1.8rem;
  height: 1.8rem;
  transform: translate(-50%, -50%);
  border-radius: 5px;
  background: radial-gradient(circle at 50% 40%, #d9ccff, var(--accent-lavender));
  box-shadow: 0 0 8px rgba(179, 157, 219, 0.7);
  z-index: 2;
}

.hack-cb-cube.win {
  background: radial-gradient(circle at 50% 40%, #86efac, #22c55e);
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.85);
}

.hack-cb-cube.lose {
  background: radial-gradient(circle at 50% 40%, #fca5a5, #ef4444);
  box-shadow: 0 0 12px rgba(248, 113, 113, 0.85);
}

/* ---- Generator grid (NoPixel Thermite: 6x6 icons, full/half/empty + combo) ---- */
.hack-gen-stats {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  width: 100%;
  margin-bottom: 0.2rem;
}

.hack-gen-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}

.hack-gen-label {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.hack-gen-val {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
}

/* Score shown on its own (no Charges/Combo/Time row). */
.hack-gen-score {
  font-size: 1.5rem;
  letter-spacing: 0.04em;
}

/* ---- Chopping ("Alphabet"): type Q/W/E/R/A/S/D in order ---- */
.hack-chop-grid {
  display: grid;
  grid-template-columns: repeat(var(--chop-cols, 6), 1fr);
  gap: 6px;
  width: min(320px, 84vw);
}

.hack-chop-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: clamp(1rem, 4vw, 1.4rem);
  border-radius: var(--radius-sm);
  background: rgba(28, 18, 42, 0.6);
  border: 1px solid rgba(179, 157, 219, 0.25);
  color: var(--text-soft);
  transition: background 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.hack-chop-cell.active {
  border-color: var(--accent-blush);
  color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--accent-blush), 0 0 14px rgba(255, 217, 236, 0.5);
}

.hack-chop-cell.done {
  background: var(--accent-lavender);
  border-color: var(--accent-lavender);
  color: #1a0f2a;
  box-shadow: var(--border-glow);
}

.hack-chop-cell.fail {
  background: rgba(214, 92, 128, 0.6);
  border-color: #e88aa8;
  color: #fff;
}

.hack-gen-combo {
  color: var(--accent-champagne);
}

.hack-gen-grid {
  display: grid;
  grid-template-columns: repeat(var(--gen-cols, 6), 1fr);
  gap: 5px;
  width: min(320px, 84vw);
}

.hack-gen-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14%;
  border-radius: var(--radius-sm);
  cursor: default;
  transition: background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, transform 0.08s ease, opacity 0.15s ease;
}

.hack-gen-cell svg {
  width: 100%;
  height: 100%;
}

/* PNG icons (e.g. the Noun Project banana peel) rendered as a mask so they
   tint with the tile's currentColor exactly like the inline-SVG icons. */
.hack-gen-img {
  width: 100%;
  height: 100%;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.hack-gen-img.banana {
  -webkit-mask-image: url("../assets/icons/banana-peel.png");
  mask-image: url("../assets/icons/banana-peel.png");
}

/* Full — intact charge, lavender icon */
.hack-gen-cell.full {
  background: rgba(28, 18, 42, 0.6);
  border: 1px solid rgba(179, 157, 219, 0.35);
  color: var(--accent-lavender);
}

/* Half — cracked once, warmed to champagne */
.hack-gen-cell.half {
  background: rgba(60, 40, 24, 0.5);
  border: 1px solid rgba(245, 214, 168, 0.6);
  color: var(--accent-champagne);
}

/* Empty — burnt out, dead node */
.hack-gen-cell.empty {
  background: rgba(8, 5, 14, 0.55);
  border: 1px solid rgba(179, 157, 219, 0.07);
  pointer-events: none;
}

/* Not currently targetable — dimmed and inert */
.hack-gen-cell:not(.live):not(.empty) {
  opacity: 0.34;
  pointer-events: none;
}

/* Live — a legal target this turn */
.hack-gen-cell.live {
  cursor: pointer;
  box-shadow: inset 0 0 0 1.5px rgba(179, 157, 219, 0.85), var(--border-glow);
}

.hack-gen-cell.live.half {
  box-shadow: inset 0 0 0 1.5px var(--accent-champagne), 0 0 14px rgba(245, 214, 168, 0.4);
}

.hack-gen-cell.live:hover {
  transform: scale(1.07);
  background: rgba(179, 157, 219, 0.22);
}

/* Legend */
.hack-gen-legend {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  margin-top: 0.1rem;
}

.hack-gen-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.hack-gen-legend-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  color: var(--accent-lavender);
}

.hack-gen-legend-icon svg { width: 100%; height: 100%; }

@media (max-width: 480px) {
  .hack-card { padding: var(--space-md) var(--space-sm) var(--space-sm); }
  .hack-pin-digit { width: 2.2rem; height: 2.2rem; font-size: 1.2rem; }
  .hack-gen-stats { gap: var(--space-sm); }
  .hack-gen-legend { gap: var(--space-sm); }
}

@media (prefers-reduced-motion: reduce) {
  .hack-overlay,
  .hack-card,
  .hack-cell { transition: none; }
  .hack-card.is-fail { animation: none; }
}
