/* ==========================================================================
   BrainTrain - Styles Hashi (Ponts / Hashiwokakero)
   ========================================================================== */

.hashi-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  gap: clamp(0.5rem, 1.5vh, 0.875rem);
}

/* --------------------------------------------------------------------------
   Plateau de Jeu Hashi
   -------------------------------------------------------------------------- */
.hashi-board-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 0.5rem;
  overflow: hidden;
  touch-action: manipulation;
}

.hashi-board {
  position: relative;
  width: 100%;
  max-width: min(420px, 92vw, 48vh);
  aspect-ratio: 1 / 1;
  background-color: #FAF8F5;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  overflow: hidden;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.03);
}

/* Calque SVG pour le tracé des ponts et du quadrillage */
.hashi-svg-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: all;
}

/* Lignes du quadrillage d'alignement */
.hashi-grid-line {
  stroke: rgba(0, 0, 0, 0.08);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
}

.hashi-grid-dot {
  fill: rgba(0, 0, 0, 0.15);
}

/* Lignes de ponts SVG */
.hashi-bridge-line {
  stroke: #1C1917;
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke 150ms ease, stroke-width 150ms ease;
  cursor: pointer;
}

.hashi-bridge-hitbox {
  stroke: transparent;
  stroke-width: 28;
  cursor: pointer;
}

.hashi-bridge-group:hover .hashi-bridge-line {
  stroke: var(--accent-primary);
  stroke-width: 5;
}

/* Ligne de visée / pont potentiel */
.hashi-bridge-preview {
  stroke: var(--accent-primary);
  stroke-width: 3;
  stroke-dasharray: 6 4;
  opacity: 0.8;
}

/* Îles (Noeuds circulaires) */
.hashi-islands-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hashi-island {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: var(--radius-full);
  background-color: var(--bg-surface);
  border: 2.5px solid #1C1917;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #1C1917;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  pointer-events: all;
  transition: all var(--transition-fast);
  user-select: none;
  touch-action: manipulation;
  z-index: 5;
}

.hashi-island:hover {
  transform: translate(-50%, -50%) scale(1.08);
}

.hashi-island:active {
  transform: translate(-50%, -50%) scale(0.95);
}

.hashi-island.selected {
  background-color: #EEF2FF;
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.3), 0 4px 10px rgba(79, 70, 229, 0.25);
  transform: translate(-50%, -50%) scale(1.15);
  z-index: 10;
}

.hashi-island.target-candidate {
  border-color: var(--accent-primary);
  border-style: dashed;
  animation: pulseTarget 1.2s infinite alternate;
}

@keyframes pulseTarget {
  0% { box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.25); transform: translate(-50%, -50%) scale(1); }
  100% { box-shadow: 0 0 0 6px rgba(79, 70, 229, 0.45); transform: translate(-50%, -50%) scale(1.08); }
}

/* États de complétion de l'île */
.hashi-island.status-exact {
  background-color: #D1FAE5;
  border-color: #059669;
  color: #065F46;
}

.hashi-island.status-over {
  background-color: #FEE2E2;
  border-color: #DC2626;
  color: #991B1B;
  animation: shake 300ms ease;
}

.hashi-island.status-incomplete-highlight {
  box-shadow: 0 0 0 4px #FBBF24, 0 2px 8px rgba(245, 158, 11, 0.4);
  animation: pulseAmber 1s ease 2;
}

@keyframes pulseAmber {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.12); }
}

/* Badge de statut restant/total */
.hashi-island-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background-color: #1C1917;
  color: #FFFFFF;
  font-size: 0.5625rem;
  font-weight: 700;
  padding: 1px 3.5px;
  border-radius: var(--radius-full);
  pointer-events: none;
}
