/* ==========================================================================
   Flavour Flip
   ========================================================================== */

.timer-fill {
  height: 100%;
  width: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--frimax-amber), var(--win));
  transition: width 0.3s linear;
}

/* Under fifteen seconds the bar turns and starts pulsing */
.timer-fill.low {
  background: linear-gradient(90deg, var(--frimax-amber), var(--lose));
  animation: timer-pulse 0.9s ease-in-out infinite;
}

@keyframes timer-pulse {
  50% {
    opacity: 0.55;
  }
}

/* --------------------------------------------------------------- board --- */

/* The board has no fixed size of its own. flip.js measures the play area and
   sets --card to the largest card that fits, so the grid below is always
   exactly as big as the screen allows, on a phone or a desktop. */
.board-shell {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

.board {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), var(--card, 72px));
  gap: var(--gap, 8px);
  justify-content: center;
  touch-action: manipulation;
}

/* ---------------------------------------------------------------- card --- */

.card {
  position: relative;
  width: var(--card, 72px);
  aspect-ratio: 3 / 4;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  perspective: 700px;
  -webkit-tap-highlight-color: transparent;
}

.card:disabled {
  cursor: default;
}

.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.36s cubic-bezier(0.4, 0, 0.2, 1);
}

.card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card:active:not(:disabled):not(.flipped) .card-inner {
  transform: scale(0.94);
}

.card-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}

/* Face down: the F from the Frimax logo on foil-striped green */
.card-back {
  background:
    url("../assets/brand/mark.svg") center / 58% no-repeat,
    repeating-linear-gradient(-45deg, rgba(255, 253, 247, 0.09) 0 6px, transparent 6px 14px),
    linear-gradient(150deg, var(--frimax-green) 0%, var(--frimax-green-deep) 100%);
  border: 2px solid var(--frimax-green-dark);
  box-shadow:
    inset 0 1px 0 rgba(255, 253, 247, 0.4),
    0 4px 10px rgba(0, 0, 0, 0.45);
}

/* Face up: a pale card, so every pack reads against the same ground whatever
   its own colour. */
.card-front {
  transform: rotateY(180deg);
  background: radial-gradient(ellipse at 50% 35%, #ffffff, #e8e2d2);
  border: 2px solid rgba(255, 253, 247, 0.9);
  padding: 7%;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
}

.card-front img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.card:not(:disabled):hover .card-back {
  border-color: var(--frimax-amber);
}

/* Matched pairs settle back and stop competing for attention */
.card.matched .card-front {
  border-color: var(--win);
  box-shadow:
    0 0 0 2px rgba(29, 194, 103, 0.55),
    0 0 18px rgba(29, 194, 103, 0.5);
}

.card.matched {
  animation: card-match 0.45s ease;
}

@keyframes card-match {
  40% {
    transform: scale(1.09);
  }
}

.card.wrong .card-front {
  border-color: var(--lose);
  animation: card-shake 0.4s ease;
}

@keyframes card-shake {
  25% {
    transform: rotateY(180deg) translateX(-5px);
  }
  75% {
    transform: rotateY(180deg) translateX(5px);
  }
}
