/* =============================================================================
   opening.css - Booster opening view (choice of the extension, quota, scene).

   Reference: `.docs/steps/4.md` point 2. Colors come exclusively from
   `css/themes.css`; buttons rely on the shared `.btn` classes of `css/base.css`.
   ============================================================================= */

.opening {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.opening__panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* --- Form field ---------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.field__label {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}

.field__select {
  min-height: var(--touch-target);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: var(--color-surface-alt);
  color: var(--color-text);
  font-size: var(--font-size-md);
  touch-action: manipulation;
}

.field__select:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* --- 3D preview of the chosen booster ------------------------------------ */

/* The booster sits under the extension picker, with one arrow on each side: the arrows change the
   extension (and the combo follows), the combo changes the texture. */
.opening__preview {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-2);
}

.opening__preview-arrow {
  display: grid;
  place-items: center;
  width: var(--touch-target);
  height: var(--touch-target);
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background-color: var(--color-surface-alt);
  color: var(--color-text);
  font-size: var(--font-size-lg);
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform var(--duration-fast) var(--easing-standard),
    border-color var(--duration-fast) var(--easing-standard),
    color var(--duration-fast) var(--easing-standard);
}

.opening__preview-arrow:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  transform: scale(1.06);
}

.opening__preview-arrow:active {
  transform: scale(0.94);
}

.opening__preview-arrow:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* The preview stage is shorter than the opening scene: the picker, the quota and the button must
   all stay above the fold on a phone. Its height follows the one of the scene (10 % more than the
   original 34vh), and the doubled class beats the base `.booster-3d` rule whatever the order the
   two stylesheets are loaded in. */
.booster-3d.booster-3d--preview {
  min-height: 38vh;
}

.booster-3d--preview .booster-3d__viewport {
  height: 38vh;
}

.booster-3d--preview .booster-3d__fallback {
  max-height: 27vh;
  cursor: default;
}

/* --- Quota and countdown ------------------------------------------------- */

.opening__quota {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.opening__countdown {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-warning);
}

.opening__countdown-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Announced extension: the release day, shown instead of the quota and the countdown. Accent
   colour, because it is the answer to "why can I not open this booster?". */
.opening__release {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-accent);
}

/* --- Scene stage --------------------------------------------------------- */

.opening__scene {
  position: relative;
}

/* --- Spotlight (one big card at a time) -------------------------------------- */

.opening__reveal-hint,
.opening__summary {
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.opening__spotlight {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: center;
}

.opening__counter {
  font-size: var(--font-size-sm);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.opening__stage {
  width: min(100%, 20rem);
  perspective: 1200px;
  touch-action: pan-y;
  cursor: pointer;
}

.opening__stage .card-reveal__card {
  width: 100%;
  animation: spotlight-rise var(--duration-base) var(--easing-standard);
}

.opening__stage .card-reveal__card.is-entering-next {
  animation:
    spotlight-rise var(--duration-base) var(--easing-standard),
    spotlight-in-right var(--duration-base) var(--easing-standard);
}

.opening__stage .card-reveal__card.is-entering-prev {
  animation:
    spotlight-rise var(--duration-base) var(--easing-standard),
    spotlight-in-left var(--duration-base) var(--easing-standard);
}

.opening__spotnav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
}

.opening__spotnav .btn {
  flex: 1 1 0;
  min-width: 0;
}

/* --- Summary grid (5 cards, tap for the detail modal) ----------------------- */

.card-reveal--summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card-reveal__summary-item {
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background-color: transparent;
  cursor: pointer;
  touch-action: manipulation;
  /* Longhands rather than the `animation` shorthand: the animation mode (`css/animations/`)
     only swaps the name and the duration, and the shorthand would reset the staggered delays
     below to 0. */
  animation-name: summary-pop;
  animation-duration: var(--duration-base);
  animation-timing-function: var(--easing-standard);
  animation-fill-mode: backwards;
}

.card-reveal__summary-item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

/* One delay per card, driven by the animation mode (`--anim-stagger-ms`: 60ms in "normal",
   150ms in "epic", 90ms in "explosive"). */
.card-reveal__summary-item:nth-child(2) {
  animation-delay: calc(var(--anim-stagger-ms, 60ms) * 1);
}

.card-reveal__summary-item:nth-child(3) {
  animation-delay: calc(var(--anim-stagger-ms, 60ms) * 2);
}

.card-reveal__summary-item:nth-child(4) {
  animation-delay: calc(var(--anim-stagger-ms, 60ms) * 3);
}

.card-reveal__summary-item:nth-child(5) {
  animation-delay: calc(var(--anim-stagger-ms, 60ms) * 4);
}

.card-reveal__summary-item .card-reveal__card {
  width: 100%;
  pointer-events: none;
}

/* The ribbon of a thumbnail: the same corner mark as the spotlight, one notch smaller. At the
   size of the spotlight it would eat a sixth of a card that is a third as wide. */
.card-reveal__summary-item .card-reveal__badge {
  padding: 1px 2px 0 3px;
  font-size: 0.5rem;
  letter-spacing: 0.02em;
}

.card-reveal__summary-item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: var(--radius-md);
}

/* --- Card detail modal ------------------------------------------------------ */

/* The window of the effects: it takes the exact shape of the illustration, so the foil and the halo
   of `css/components/card-shine.css` line up with the card and stop there (`--card-reveal-art-ratio`
   is published by `OpeningView` once the image is loaded). It is also the tilt surface, which keeps
   the gesture on the card itself instead of on a letterboxed box. */
.card-modal__art {
  position: relative;
  height: min(46vh, 32rem);
  max-width: 100%;
  aspect-ratio: var(--card-reveal-art-ratio, var(--card-ratio));
  width: auto;
  margin-inline: auto;
}

.card-modal__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: var(--radius-md);
  background-color: var(--color-surface-alt);
}

.card-modal__details {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
}

/* What the card is about. Only the details opened from a surface without a page of its own (a shop
   offer, a daily reward) show it: the collection and the opening summary list the facts of the
   printing, not the text of the card. */
.card-modal__desc {
  margin: 0;
  line-height: 1.5;
}

.card-modal__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

.card-modal__row dt {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}

.card-modal__row dd {
  margin: 0;
  font-weight: 700;
  color: var(--color-text);
  text-align: right;
}

/* The movement of this screen - the arrival of the spotlight card, the pop of the summary
   tiles - lives in `css/animations/opening.css`. This file keeps the structure and the
   `animation:` declarations that name its keyframes. */
@media (min-width: 768px) {
  .booster-3d.booster-3d--preview,
  .booster-3d--preview .booster-3d__viewport {
    min-height: 42vh;
    height: 42vh;
  }

  .opening__stage {
    width: min(100%, 24rem);
  }

  .card-reveal--summary {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .opening__spotnav {
    max-width: 32rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .opening__stage .card-reveal__card,
  .card-reveal__summary-item {
    animation: none;
  }
}

.opening__summary {
  color: var(--color-success);
}

.opening__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

@media (min-width: 768px) {
  .opening__panel {
    width: 100%;
    max-width: 32rem;
    margin: 0 auto;
  }

  .opening__actions {
    flex-direction: row;
    justify-content: center;
  }

  .opening__actions .btn {
    min-width: 12rem;
  }
}
