/* Bingo Overlay - Broadcast Dark Theme */

/* Font Face */
@font-face {
  font-family: 'Reitam';
  src: url('assets/Reitam.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* CSS Variables */
:root {
  --font-primary: 'Reitam', 'Inter', system-ui, -apple-system, sans-serif;
  --font-scale: 1.0;
  --symbol-scale: 1.0;
  
  --color-bg: #0d0d0d;
  --color-surface: #1a1a1a;
  --color-border: #333333;
  --color-accent: #c9a227;
  --color-accent-rgb: 201, 162, 39;
  --color-text: #f5f5f5;
  --color-text-muted: #888888;
  
  --board-width: 560px;
  --board-padding: 16px;
  --board-top-padding: 64px; /* Space for logo in background image */
  --grid-gap: 6px;
  --square-size: 100px;
  --square-opacity: 1.0;
  
  /* Typography */
  --label-font-weight: 400;
  --label-letter-spacing: 0em;
  --label-text-transform: normal;
  
  /* Animation timing (fixed values for smooth transitions) */
  --timing-reveal: 400ms;
  --timing-stamp: 300ms;
  --timing-stamp-hold: 2500ms;
  --timing-stamp-fade: 400ms;
  --timing-fade: 450ms;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: transparent;
}

body {
  font-family: var(--font-primary);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Board Wrapper - Handles visibility transitions */
.board-wrapper {
  position: fixed;
  bottom: 40px;
  right: 40px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.96);
  transition: 
    opacity var(--timing-reveal) cubic-bezier(0.22, 1, 0.36, 1),
    transform var(--timing-reveal) cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear var(--timing-reveal);
  pointer-events: none;
}

.board-wrapper.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition: 
    opacity var(--timing-reveal) cubic-bezier(0.22, 1, 0.36, 1),
    transform var(--timing-reveal) cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 0s;
}

.board-wrapper.fade-out {
  opacity: 0;
  transform: translateY(8px) scale(0.97);
  transition: 
    opacity var(--timing-fade) ease-in,
    transform var(--timing-fade) ease-in,
    visibility 0s linear var(--timing-fade);
}

/* Board Container */
.board {
  position: relative;
  width: var(--board-width);
  background: var(--color-bg);
  border: 2px solid var(--color-accent);
  border-radius: 8px;
  padding: var(--board-top-padding) var(--board-padding) var(--board-padding) var(--board-padding);
  box-shadow: 
    /* Outer glow */
    0 0 30px rgba(var(--color-accent-rgb), 0.25),
    0 4px 24px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(var(--color-accent-rgb), 0.2),
    /* Inner shadow/vignette */
    inset 0 0 60px rgba(0, 0, 0, 0.4);
}

/* Noise texture overlay (doesn't affect custom backgrounds) */
.board::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 100px 100px;
  opacity: 0.03;
  pointer-events: none;
  z-index: 1;
}

/* Custom background image */
.board.has-background {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* Hide noise when using custom background */
.board.has-background::before {
  display: none;
}

/* Grid */
.grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: var(--grid-gap);
}

/* Square */
.square {
  position: relative;
  aspect-ratio: 1;
  background: rgba(26, 26, 26, var(--square-opacity));
  border: 1px solid var(--color-border);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px;
  /* Note: no overflow:hidden - allows floating stamp to animate above square */
  transition: border-color 0.2s ease, background 0.2s ease;
}

/* Square Index Number */
.square-index {
  position: absolute;
  top: 3px;
  left: 5px;
  font-size: 0.65rem;
  color: var(--color-text-muted);
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 500;
  opacity: 0.7;
}

/* Square Label */
.square-label {
  font-size: calc(0.75rem * var(--font-scale));
  font-weight: var(--label-font-weight);
  letter-spacing: var(--label-letter-spacing);
  text-transform: var(--label-text-transform);
  font-variant: var(--label-font-variant, normal);
  line-height: 1.2;
  text-align: center;
  color: var(--color-text);
  white-space: pre-line; /* Preserve manual line breaks */
  overflow: hidden;
  overflow-wrap: break-word;
  word-break: normal; /* Avoid mid-word breaks */
  hyphens: auto;
  padding-top: 8px;
  max-height: 3.6em; /* ~3 lines at 1.2 line-height */
}

/* Center Square (Set Symbol) */
.square.center {
  background: linear-gradient(135deg, #1f1f1f 0%, #151515 100%);
  border-color: var(--color-accent);
  border-width: 2px;
}

.square.center .center-symbol {
  width: 70%;
  height: 70%;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  transform: scale(var(--symbol-scale));
  transform-origin: center center;
}

/* Stamped Square */
.square.stamped {
  border-color: var(--color-accent);
  background: linear-gradient(135deg, #1f1a0f 0%, #1a1a1a 100%);
}

.square.stamped::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(var(--color-accent-rgb), 0.12) 0%, transparent 70%);
  pointer-events: none;
}

/* Square Impact Animation - micro "thud" shake */
.square.impact {
  animation: square-impact 150ms ease-out;
}

@keyframes square-impact {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-3px, 1px); }
  40% { transform: translate(2px, -1px); }
  60% { transform: translate(-2px, 0); }
  80% { transform: translate(1px, 1px); }
}

/* Gold Flash Effect on impact */
.square.ink-pulse::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 6px;
  background: radial-gradient(circle at center, rgba(var(--color-accent-rgb), 0.6) 0%, rgba(var(--color-accent-rgb), 0.2) 40%, transparent 70%);
  opacity: 0;
  animation: gold-flash 200ms ease-out forwards;
  pointer-events: none;
}

@keyframes gold-flash {
  0% { 
    transform: scale(0.8);
    opacity: 0.8;
  }
  50% {
    opacity: 0.5;
  }
  100% { 
    transform: scale(1.2);
    opacity: 0;
  }
}

/* Floating Stamp (child of target square, uses square-local coordinates) */
.floating-stamp {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 80px;
  height: 80px;
  pointer-events: none;
  z-index: 100;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
  /* Start state: scaled up and offset, will animate down */
  transform: translate(-50%, -50%) scale(2.2) translateY(-30px);
  opacity: 0;
}

.floating-stamp.animate-drop {
  animation: stamp-drop-local 250ms ease-out forwards;
}

.floating-stamp.animate-fade {
  animation: stamp-fade-local 400ms ease-in forwards;
}

@keyframes stamp-drop-local {
  0% {
    transform: translate(-50%, -50%) scale(2.2) translateY(-30px);
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  65% {
    /* Squash on impact */
    transform: translate(-50%, -50%) scale(1.1, 0.85) translateY(3px);
    opacity: 1;
  }
  80% {
    /* Stretch bounce */
    transform: translate(-50%, -50%) scale(0.95, 1.08) translateY(-2px);
    opacity: 1;
  }
  90% {
    transform: translate(-50%, -50%) scale(1.02, 0.98) translateY(1px);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1) translateY(0);
    opacity: 1;
  }
}

@keyframes stamp-fade-local {
  0% {
    transform: translate(-50%, -50%) scale(1) translateY(0);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(0.9) translateY(5px);
    opacity: 0;
  }
}

/* Committed stamp (lives inside square, perfectly aligned, never moves) */
.committed-stamp {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 65px;
  height: 65px;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
}

.committed-stamp.visible {
  opacity: 0.75; /* Slightly dimmer than floating stamp for "settled" look */
}

/* Legacy stamp-container and stamp-img removed - no longer used */

/* Loading State */
.board-wrapper.loading {
  opacity: 0 !important;
}

/* Debug Mode (add ?debug=true to URL) */
.board-wrapper.debug {
  opacity: 1 !important;
  transform: none !important;
}

.board-wrapper.debug .board {
  outline: 2px dashed red;
}
