/**
 * board.css
 * SVG board styling, terrain gradients, tokens, and animations.
 */

.board-viewport {
  position: relative;
  grid-area: board;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(1000px 650px at 50% 45%, #242b38 0%, #171b24 55%, #0f1218 100%),
    radial-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: auto, 24px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.catan-board-svg {
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

.catan-board-svg:active {
  cursor: grabbing;
}

/* Hex Tiles */
.hex-tile {
  transition: transform var(--transition-fast);
}

.hex-tile > polygon.hex-base,
.hex-tile > polygon.hex-wood-frame {
  transition: filter var(--transition-fast), stroke var(--transition-fast);
}

.hex-tile:hover > polygon.hex-wood-frame {
  filter: brightness(1.08);
  stroke: var(--gold-primary);
}

.hex-tile:hover > polygon.hex-base {
  filter: brightness(1.06);
}

.hex-relief,
.hex-relief * {
  pointer-events: none !important;
}

.hex-terrain-icon {
  opacity: 0.92;
  pointer-events: none;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.55));
}

.hex-icon-wool,
.hex-icon-wheat {
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.45)) drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.35));
}

.harbor-badge-icon {
  pointer-events: none;
}

/* Number Tokens */
.token-group {
  cursor: default;
}

.token-group text {
  font-family: var(--font-body);
  user-select: none;
}

.token-hot text {
  font-weight: 800;
}

/* Interactive Build Highlights (Calm, Tabletop-Authentic, Zero Coordinate Jumping) */
.valid-settlement-target {
  cursor: pointer;
}

.valid-settlement-target .target-halo {
  transition: r 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), stroke-width 0.2s ease, opacity 0.2s ease, fill 0.2s ease;
  animation: haloBreathe 2.8s ease-in-out infinite alternate;
}

@keyframes haloBreathe {
  0% { opacity: 0.45; stroke-opacity: 0.55; }
  100% { opacity: 0.9; stroke-opacity: 0.95; }
}

.valid-settlement-target .target-core {
  transition: r 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), fill 0.2s ease, stroke 0.2s ease;
}

.valid-settlement-target:hover .target-halo {
  r: 13px;
  opacity: 1;
  stroke: #fbbf24;
  stroke-width: 2.2;
  fill: rgba(245, 158, 11, 0.32);
}

.valid-settlement-target:hover .target-core {
  r: 6.5px;
  fill: #ffffff;
  stroke: #d97706;
}

/* Road paths */
.valid-road-group {
  cursor: pointer;
}

.valid-road-path {
  transition: stroke 0.2s ease, stroke-width 0.2s ease, opacity 0.2s ease;
  animation: dashRoad 3s linear infinite;
}

@keyframes dashRoad {
  to { stroke-dashoffset: -20; }
}

.valid-road-group:hover .valid-road-path {
  stroke: #fbbf24 !important;
  stroke-width: 8 !important;
  stroke-dasharray: none !important;
  filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.5));
}

/* City Upgrade targets */
.valid-city-target {
  transition: stroke 0.2s ease, stroke-width 0.2s ease;
  animation: dashCity 4s linear infinite;
}

@keyframes dashCity {
  to { stroke-dashoffset: 28; }
}

.valid-city-target:hover {
  stroke: #fbbf24 !important;
  stroke-width: 4 !important;
  filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.6));
}

/* Robber target hexes */
.hex-robber-target {
  cursor: pointer;
}

.hex-robber-target .hex-wood-frame {
  transition: stroke 0.2s ease, filter 0.2s ease;
}

/* On hover: light up with an elegant golden contour and warm glow without obscuring the tile */
.hex-robber-target:hover .hex-wood-frame {
  stroke: #fbbf24 !important;
  stroke-width: 3.5 !important;
  filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.7)) !important;
}

.hex-robber-target:hover .hex-base {
  stroke: #fbbf24 !important;
  stroke-width: 1.5 !important;
}

/* Robber Figure */
.robber-figure {
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.55));
}

/* Board Floating Hint Banner */
.board-hint {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
  white-space: normal;
  text-align: center;
  backdrop-filter: blur(8px);
  transition: all var(--transition-normal);
}

.board-hint.hint-active {
  border-color: var(--gold-primary);
  color: #fbbf24;
}

.board-hint .hint-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold-primary);
  flex-shrink: 0;
  animation: dotPulse 1.6s ease-in-out infinite alternate;
}

@keyframes dotPulse {
  0% { opacity: 0.4; transform: scale(0.85); }
  100% { opacity: 1; transform: scale(1.2); }
}

.board-controls {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}

.board-control-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.board-control-btn .ico {
  font-size: 16px;
}

.board-control-btn:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--gold-primary);
}

.knight-inactive {
  opacity: 0.5;
}

.knight-piece:not(.knight-inactive) {
  filter: drop-shadow(0 0 3px rgba(255, 215, 0, 0.45));
  animation: knight-glow 2s ease-in-out infinite;
}

@keyframes knight-glow {
  0%, 100% { filter: drop-shadow(0 0 3px rgba(255, 215, 0, 0.3)); }
  50% { filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.7)); }
}

.knight-action-menu {
  position: absolute;
  z-index: 40;
  min-width: 220px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.knight-action-menu[hidden] {
  display: none !important;
}

.knight-action-btn {
  width: 100%;
  text-align: left;
  justify-content: space-between;
}

.knight-action-btn:disabled {
  opacity: 0.42;
}

.knight-supply {
  font-size: 11px;
  font-weight: 650;
  color: var(--text-secondary);
  background: oklch(1 0 0 / 0.035);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  letter-spacing: 0.02em;
}

/* Road Network Hover & Tooltip */
.edge-group.built-road {
  cursor: pointer;
}

.edge-group.built-road .road-hit-area {
  stroke: transparent;
  stroke-width: 20;
  stroke-linecap: round;
  cursor: pointer;
}

.edge-group.built-road.road-hover-highlight .road-body,
.road-casing.road-hover-highlight {
  transition: stroke-width 0.15s ease, filter 0.15s ease, stroke 0.15s ease;
}

.edge-group.built-road.road-hover-highlight .road-body {
  stroke-width: 11 !important;
  filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.85)) drop-shadow(0 0 12px currentColor) !important;
}

.edge-group.built-road.road-hover-active .road-body {
  stroke-width: 13 !important;
  filter: drop-shadow(0 0 8px #ffffff) drop-shadow(0 0 16px currentColor) !important;
}

.road-casing.road-hover-highlight {
  stroke: rgba(255, 255, 255, 0.6) !important;
  stroke-width: 15 !important;
}

.road-casing.road-hover-active {
  stroke: rgba(255, 255, 255, 0.9) !important;
  stroke-width: 17 !important;
}

/* Floating Road Length Tooltip */
.road-length-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 8px 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.65), 0 0 14px rgba(217, 119, 6, 0.25);
  backdrop-filter: blur(10px);
  color: #f8fafc;
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 12px;
  line-height: 1.4;
  transform: translate(-50%, -100%) translateY(-14px);
  transition: opacity 0.15s cubic-bezier(0.16, 1, 0.3, 1), transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.road-length-tooltip.hidden {
  opacity: 0;
  transform: translate(-50%, -100%) translateY(-6px);
  pointer-events: none;
}

.road-length-tooltip.tooltip-flip-below {
  transform: translate(-50%, 0) translateY(14px);
}

.road-length-tooltip.tooltip-flip-below.hidden {
  transform: translate(-50%, 0) translateY(6px);
}

.road-tooltip-header {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 4px;
}

.road-tooltip-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.6);
  flex-shrink: 0;
}

.road-tooltip-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: #cbd5e1;
}

.road-tooltip-stat {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.road-tooltip-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.road-tooltip-badge.badge-holder {
  background: rgba(234, 179, 8, 0.2);
  color: #fde047;
  border: 1px solid rgba(234, 179, 8, 0.4);
}

.road-tooltip-badge.badge-tied {
  background: rgba(56, 189, 248, 0.2);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.road-tooltip-badge.badge-contender {
  background: rgba(148, 163, 184, 0.16);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

