/* ═══════════════════════════════════════════════════════════════════════════
 *                                SNAKE GAME
 ═══════════════════════════════════════════════════════════════════════════ */
/* ═══════════════════════════════════════════════════════════════════════════
 *                                 TRIGGER
 ═══════════════════════════════════════════════════════════════════════════ */
/* #region TRIGGER */

/* ═══════════════════════════════════════════════════════════════════════════

 *   Dark pill with raised 3D shadow â stands out against the gold page

 ═══════════════════════════════════════════════════════════════════════════ */
.snake-trigger {
  appearance: none;
  position: relative;
  background: linear-gradient(
    color-mix(in srgb, var(--NV-Black) 72%, transparent),
    color-mix(in srgb, var(--NV-Black) 85%, transparent)
  ) padding-box;
  border: 1px solid transparent;
  border-radius: 2rem;
  padding: 0.5rem 1.2rem;
  cursor: pointer;
  color: var(--NV-Ivory);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  overflow: hidden;
  isolation: isolate;
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--NV-Ivory) 10%, transparent),
    0 2px 5px color-mix(in srgb, var(--NV-Black) 35%, transparent),
    0 0 0 1px color-mix(in srgb, var(--NV-Black) 12%, transparent);
  transition: transform 140ms ease, box-shadow 140ms ease;
  animation: snake-trigger-pulse 3s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════════════════════════

 *           Inner highlight layer (mirrors .button-link::after)

 ═══════════════════════════════════════════════════════════════════════════ */
.snake-trigger::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  pointer-events: none;
  background: color-mix(in srgb, var(--NV-Ivory) 5%, transparent);
  z-index: -1;
}

/* ═══════════════════════════════════════════════════════════════════════════

 *                      Pressed state on hover / focus

 ═══════════════════════════════════════════════════════════════════════════ */
.snake-trigger:hover,
.snake-trigger:focus-visible {
  transform: translateY(1px);
  animation: none;
  box-shadow:
    inset 0 3px 5px color-mix(in srgb, var(--NV-Black) 50%, transparent),
    inset 0 0 0 1px color-mix(in srgb, var(--NV-Ivory) 8%, transparent);
}

/* ═══════════════════════════════════════════════════════════════════════════

 *            Gentle drop-shadow pulse to draw attention on load

 ═══════════════════════════════════════════════════════════════════════════ */
@keyframes snake-trigger-pulse {
  0%, 100% {
    box-shadow:
      inset 0 0 0 1px color-mix(in srgb, var(--NV-Ivory) 10%, transparent),
      0 2px 5px color-mix(in srgb, var(--NV-Black) 35%, transparent),
      0 0 0 1px color-mix(in srgb, var(--NV-Black) 12%, transparent);
  }
  50% {
    box-shadow:
      inset 0 0 0 1px color-mix(in srgb, var(--NV-Ivory) 10%, transparent),
      0 2px 5px color-mix(in srgb, var(--NV-Black) 35%, transparent),
      0 0 0 1px color-mix(in srgb, var(--NV-Black) 12%, transparent),
      0 0 1rem color-mix(in srgb, var(--NV-Black) 22%, transparent);
  }
}

/* #endregion TRIGGER */


/* ═══════════════════════════════════════════════════════════════════════════


 *                                  MODAL


 ═══════════════════════════════════════════════════════════════════════════ */
/* #region MODAL */

/* ═══════════════════════════════════════════════════════════════════════════

 *        Full-viewport backdrop â hidden until .is-open is added

 ═══════════════════════════════════════════════════════════════════════════ */
.snake-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(23, 20, 13, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: 100;
}

.snake-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* ═══════════════════════════════════════════════════════════════════════════

 *                    Centered panel containing the game

 ═══════════════════════════════════════════════════════════════════════════ */
.snake-modal__panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.6rem;
  padding: 1rem;
  background: var(--NV-Black);
  border: 1px solid color-mix(in srgb, var(--NV-Primary) 35%, transparent);
  border-radius: 1rem;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--NV-Black) 60%, transparent),
    0 1.5rem 3rem rgba(0, 0, 0, 0.5);
}

/* ═══════════════════════════════════════════════════════════════════════════

 *            Header row: score on the left, close on the right

 ═══════════════════════════════════════════════════════════════════════════ */
.snake-modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.snake-modal__score {
  color: color-mix(in srgb, var(--NV-Ivory) 55%, transparent);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.snake-modal__score span {
  color: var(--NV-Primary);
  font-weight: bold;
}

/* ═══════════════════════════════════════════════════════════════════════════

 *                            Close button (â)

 ═══════════════════════════════════════════════════════════════════════════ */
.snake-modal__close {
  appearance: none;
  background: none;
  border: none;
  padding: 0.2rem 0.4rem;
  cursor: pointer;
  color: color-mix(in srgb, var(--NV-Ivory) 40%, transparent);
  font-size: 1rem;
  line-height: 1;
  transition: color 140ms ease;
}

.snake-modal__close:hover,
.snake-modal__close:focus-visible {
  color: var(--NV-Ivory);
}

/* #endregion MODAL */


/* ═══════════════════════════════════════════════════════════════════════════


 *                            GAME OVER OVERLAY


 ═══════════════════════════════════════════════════════════════════════════ */
/* #region GAME OVER OVERLAY */

/* ═══════════════════════════════════════════════════════════════════════════

 *     Positioned over the canvas â hidden until .is-visible is added

 ═══════════════════════════════════════════════════════════════════════════ */
.snake-modal__panel {
  position: relative;
}

.snake-gameover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  background: rgba(23, 20, 13, 0.82);
  border-radius: 0.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.snake-gameover.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.snake-gameover__title {
  color: var(--NV-Primary);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 1.5rem;
  font-weight: bold;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.snake-gameover__score {
  color: var(--NV-Ivory);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
}

.snake-gameover__score span {
  color: var(--NV-Primary);
  font-weight: bold;
}

/* ═══════════════════════════════════════════════════════════════════════════

 *         Play-again button â styled like the snake trigger pill

 ═══════════════════════════════════════════════════════════════════════════ */
.snake-gameover__btn {
  appearance: none;
  position: relative;
  background: linear-gradient(
    color-mix(in srgb, var(--NV-Black) 72%, transparent),
    color-mix(in srgb, var(--NV-Black) 85%, transparent)
  ) padding-box;
  border: 1px solid transparent;
  border-radius: 2rem;
  padding: 0.55rem 1.4rem;
  cursor: pointer;
  color: var(--NV-Ivory);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  overflow: hidden;
  isolation: isolate;
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--NV-Ivory) 10%, transparent),
    0 2px 5px color-mix(in srgb, var(--NV-Black) 35%, transparent),
    0 0 0 1px color-mix(in srgb, var(--NV-Black) 12%, transparent);
  transition: transform 140ms ease, box-shadow 140ms ease;
  margin-top: 0.4rem;
}

.snake-gameover__btn:hover,
.snake-gameover__btn:focus-visible {
  transform: translateY(1px);
  box-shadow:
    inset 0 3px 5px color-mix(in srgb, var(--NV-Black) 50%, transparent),
    inset 0 0 0 1px color-mix(in srgb, var(--NV-Ivory) 8%, transparent);
}

/* #endregion GAME OVER OVERLAY */


/* ═══════════════════════════════════════════════════════════════════════════


 *                                  CANVAS


 ═══════════════════════════════════════════════════════════════════════════ */
/* #region CANVAS */

/* ═══════════════════════════════════════════════════════════════════════════

 *         Canvas scales down on small screens, keeps square ratio

 ═══════════════════════════════════════════════════════════════════════════ */
.snake-canvas {
  display: block;
  width: 400px;
  height: 400px;
  max-width: min(80vw, 80vh);
  aspect-ratio: 1;
  border-radius: 0.5rem;
}

/* #endregion CANVAS */
