/* ===========================================
   TCHIP — Borne d'arcade (overlay sur borne.png)
   =========================================== */

:root {
  --black:          #000000;
  --burgundy:       #8B1023;
  --burgundy-dark:  #250107;
  --burgundy-deep:  #1a0306;
  --cyan:           #1AD9F2;
  --cyan-glow:      #5DEEFF;
  --white:          #FFFFFF;
  --accent:         #FFE54D;
  --grey:           #888888;

  /* Borne image — ratio natif 1672 x 941 */
  --borne-ratio: 1672 / 941;

  /* Coordonnées des zones (% de l'image) — mesurées sur borne.png */
  --screen-left:   32.30%;
  --screen-top:    31.24%;
  --screen-width:  35.29%;
  --screen-height: 33.05%;

  --panel-left:    24.04%;
  --panel-top:     68.44%;
  --panel-width:   51.73%;
  --panel-height:  13.28%;

  /* Boutons LED (réservé pour customisations) */
  --btn-glow-blur: 18px;

}

/* ===========================================
   RESET & BASE
   =========================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh; /* dynamic viewport — gère bien la barre Safari mobile */
  overflow: hidden;
  background: #000; /* fallback uniforme — évite les bandes blanches sur iOS */
}

body {
  background: radial-gradient(ellipse at center, #1a0306 0%, #050000 70%, #000 100%);
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  /* Étend derrière les "safe areas" iOS (notch, home bar) */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button {
  font-family: inherit;
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
}

.hidden { display: none !important; }

/* ===========================================
   COMING SOON — MODE CONSTRUCTION
   =========================================== */

.construction-screen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background:
    radial-gradient(ellipse at center, rgba(139, 16, 35, 0.20) 0%, rgba(5, 0, 0, 0.72) 45%, #000 100%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.035) 0 1px, transparent 1px 4px);
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
}

.construction-screen::before {
  content: '';
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 229, 77, 0.10), transparent 22%),
    radial-gradient(circle at 50% 60%, rgba(139, 16, 35, 0.28), transparent 36%);
  filter: blur(12px);
  pointer-events: none;
}

.construction-inner {
  position: relative;
  width: min(92vw, 760px);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 34px;
}

.construction-logo {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(42px, 10vw, 104px);
  line-height: 1;
  letter-spacing: 0;
  color: #fff;
  text-shadow:
    0 0 8px rgba(255,255,255,0.86),
    0 0 28px rgba(139, 16, 35, 0.95),
    0 0 64px rgba(139, 16, 35, 0.72);
}

.construction-screen h1 {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(13px, 2.4vw, 24px);
  line-height: 1.65;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(255, 229, 77, 0.58);
}

.arcade-progress {
  width: min(86vw, 560px);
  padding: 10px;
  border: 3px solid var(--accent);
  box-shadow:
    0 0 0 3px rgba(0,0,0,0.9) inset,
    0 0 26px rgba(255, 229, 77, 0.38);
}

.arcade-progress-track {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  height: 30px;
}

.arcade-progress-track span {
  background: var(--burgundy);
  box-shadow: 0 0 16px rgba(139, 16, 35, 0.75);
  animation: progress-pulse 1.6s steps(2, start) infinite;
}

.arcade-progress-track span:nth-child(2) { animation-delay: 0.10s; }
.arcade-progress-track span:nth-child(3) { animation-delay: 0.20s; }
.arcade-progress-track span:nth-child(4) { animation-delay: 0.30s; }
.arcade-progress-track span:nth-child(5) { animation-delay: 0.40s; }
.arcade-progress-track span:nth-child(6) { animation-delay: 0.50s; }
.arcade-progress-track span:nth-child(7) { animation-delay: 0.60s; }
.arcade-progress-track span:nth-child(8) { animation-delay: 0.70s; }

@keyframes progress-pulse {
  0%, 100% {
    background: var(--burgundy);
    opacity: 0.38;
  }
  50% {
    background: var(--accent);
    opacity: 1;
  }
}

/* ===========================================
   BOOT SCREEN — INSERT COIN
   =========================================== */

#boot-screen {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.8s ease-out;
}
#boot-screen.fade-out { opacity: 0; pointer-events: none; }

.boot-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 40px;
  align-items: center;
}

.boot-logo {
  font-family: 'Press Start 2P', monospace;
  font-size: 64px;
  color: var(--burgundy);
  text-shadow: 0 0 24px rgba(139, 16, 35, 0.7), 0 0 4px var(--accent);
  letter-spacing: 8px;
  animation: logo-pulse 3s ease-in-out infinite;
}

@keyframes logo-pulse {
  0%, 100% { transform: scale(1); text-shadow: 0 0 24px rgba(139, 16, 35, 0.7), 0 0 4px var(--accent); }
  50%      { transform: scale(1.03); text-shadow: 0 0 36px rgba(139, 16, 35, 1), 0 0 8px var(--accent); }
}

.insert-coin {
  font-family: 'Press Start 2P', monospace;
  font-size: 18px;
  color: var(--accent);
  background: transparent;
  border: 3px solid var(--accent);
  padding: 18px 36px;
  letter-spacing: 4px;
  animation: blink 1s steps(2, start) infinite;
  transition: all 0.2s;
}
.insert-coin:hover {
  background: var(--accent);
  color: var(--black);
  animation: none;
  box-shadow: 0 0 24px var(--accent);
}
@keyframes blink { to { visibility: hidden; } }

.boot-hint {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  letter-spacing: 2px;
}

/* ===========================================
   STAGE 3D & BORNE
   =========================================== */

#stage {
  position: relative;
  /* La borne occupe le max possible tout en restant entièrement visible */
  width: min(98vw, calc(96vh * 1672 / 941));
  aspect-ratio: var(--borne-ratio);
  animation: stage-enter 1s cubic-bezier(.2,.8,.2,1) both;
}

@keyframes stage-enter {
  from { opacity: 0; transform: translateY(40px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

#arcade {
  position: relative;
  width: 100%;
  height: 100%;
  background-image: url('../assets/img/borne.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  /* Borne statique — pas de parallax (cassait les clicks Safari) */
  transform: none;
  filter: drop-shadow(0 30px 60px rgba(0,0,0,0.7));
}

#arcade.shake {
  animation: arcade-shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}
@keyframes arcade-shake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}

/* Ombre au sol */
.floor-shadow {
  position: absolute;
  bottom: -5%;
  left: 15%;
  right: 15%;
  height: 6%;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.8), transparent 70%);
  filter: blur(15px);
  z-index: -1;
}

/* ===========================================
   ÉCRAN — OVERLAY sur la zone cyan
   =========================================== */

.screen-area {
  position: absolute;
  left: var(--screen-left);
  top: var(--screen-top);
  width: var(--screen-width);
  height: var(--screen-height);
  background: #050005;
  overflow: hidden;
  border-radius: 2.5% / 4.5%;
}

.screen-content {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.screen-bg-img {
  position: absolute;
  inset: -20%;
  width: 140%;
  height: 140%;
  object-fit: cover;
  object-position: center;
  filter: blur(35px) brightness(0.58) saturate(1.45);
  z-index: 0;
  pointer-events: none;
  transform: scale(1.08);
}

.screen-main-img {
  position: relative;
  z-index: 1;
}

.screen-content img,
.screen-content iframe {
  width: 100%;
  height: 100%;
  /* contain = affiche TOUTE l'image sans crop. Le fond flouté comble les bords. */
  object-fit: contain;
  object-position: center;
  border: none;
  display: block;
}

.screen-content .screen-bg-img {
  position: absolute;
  inset: -20%;
  width: 140%;
  height: 140%;
  object-fit: cover;
  z-index: 0;
}

.screen-content .screen-main-img {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 1;
}

/* Pour les vidéos iframe : on garde cover (les vidéos remplissent toujours l'écran) */
.screen-content iframe {
  object-fit: cover;
}

.screen-placeholder {
  text-align: center;
  color: var(--burgundy-dark);
}
.screen-placeholder-text {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(18px, 2.5vw, 40px);
  letter-spacing: 4px;
}

.screen-message {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(10px, 1.2vw, 18px);
  color: var(--accent);
  background: rgba(10, 2, 6, 0.88);
  backdrop-filter: blur(8px);
  text-align: center;
  padding: 5%;
  line-height: 1.6;
  letter-spacing: 1px;
  animation: message-flash 0.4s ease-out;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
@keyframes message-flash {
  0%   { transform: scale(0.9); opacity: 0; }
  50%  { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

/* CRT effects (scanlines + glow + vignette) */
.crt-scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.18) 0px,
    rgba(0,0,0,0.18) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  z-index: 3;
  mix-blend-mode: multiply;
}
.crt-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,80,100,0.25) 100%);
  pointer-events: none;
  z-index: 4;
}
.crt-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.45) 100%);
  pointer-events: none;
  z-index: 5;
}

/* ===========================================
   PANNEAU — OVERLAY boutons sur burgundy
   =========================================== */

.panel-area {
  position: absolute;
  left: var(--panel-left);
  top: var(--panel-top);
  width: var(--panel-width);
  height: var(--panel-height);
  padding: 0.5% 2%;
}

.button-grid {
  width: 100%;
  height: 100%;
  display: grid;
  /* minmax(0, 1fr) = AUTORISE les cellules à shrink en dessous de la taille intrinsèque
     du contenu (sinon les images PNG forcent les rangs à leur taille native) */
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1% 2%;
  place-items: center;
}

/* ===========================================
   BOUTONS — PNG photoréalistes (normal + pressed swap)
   Les images vivent dans assets/img/buttons/
   =========================================== */

.arcade-btn {
  position: relative;
  height: 100%;
  width: 100%;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  max-height: 100%;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: visible;
  /* FIX MOBILE : élimine le délai de 300ms iOS + autorise le tap rapide */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.arcade-btn.locked {
  cursor: not-allowed;
}

.arcade-btn img {
  /* Force le scaling à 100% du conteneur, contained dans l'aspect ratio */
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  display: block;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.55));
  transition: filter 150ms, transform 100ms;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* HOVER — uniquement sur les vrais devices souris (évite les bugs sticky tap mobile)
   Le transform a été retiré car il causait des clicks fantômes sur Safari
   (le bouton bouge → mouseup tombe sur un élément différent → click jamais fired) */
@media (hover: hover) and (pointer: fine) {
  .arcade-btn:not(.locked):hover img {
    filter: drop-shadow(0 10px 16px rgba(0,0,0,0.65)) brightness(1.06);
  }
}

/* PRESSED — image stays */
.arcade-btn.is-pressed img {
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.6));
}

/* ===========================================
   MUTE BUTTON
   =========================================== */

.mute-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  font-size: 18px;
  z-index: 100;
  transition: background 0.2s;
}
.mute-btn:hover { background: rgba(0,0,0,0.8); }
.mute-btn .mute-icon-off { display: none; }
.mute-btn.muted .mute-icon-on  { display: none; }
.mute-btn.muted .mute-icon-off { display: inline; }

/* ===========================================
   RESPONSIVE
   =========================================== */

@media (max-width: 700px) {
  #stage {
    width: 100vw;
  }
  .boot-logo  { font-size: 40px; }
  .insert-coin { font-size: 14px; padding: 14px 24px; }
}

/* MOBILE PORTRAIT — rotate la borne 90° pour qu'elle remplisse l'écran
   (sinon en 16:9 sur un téléphone portrait, la borne est minuscule = inutilisable) */
@media (max-width: 700px) and (orientation: portrait) {
  /* On affiche le boot normalement (centré, pas tourné) */
  #boot-screen { transform: none; }

  /* Le stage est rotaté à 90° et redimensionné aux dimensions inversées */
  #stage {
    width: 100dvh;
    height: 100dvw;
    transform: rotate(90deg);
    transform-origin: center center;
    position: fixed;
    top: 50%;
    left: 50%;
    margin-top: calc(-50dvw);
    margin-left: calc(-50dvh);
  }

}

/* MOBILE LANDSCAPE — la borne prend la pleine largeur */
@media (max-width: 900px) and (orientation: landscape) {
  #stage {
    width: 100vw;
    height: 100dvh;
  }
}
