/* styles.css - Antigravity Conquest Custom Styling */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Color Palette */
  --bg-primary: #0a0b0e;
  --bg-secondary: #12141a;
  --bg-glass: rgba(18, 20, 26, 0.65);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glass-active: rgba(255, 255, 255, 0.2);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  /* Player Colors */
  --p1-color: #00d2ff;
  --p1-glow: rgba(0, 210, 255, 0.4);
  --p2-color: #00ff87;
  --p2-glow: rgba(0, 255, 135, 0.4);
  --p3-color: #ff0055;
  --p3-glow: rgba(255, 0, 85, 0.4);
  --p4-color: #ffb300;
  --p4-glow: rgba(255, 179, 0, 0.4);

  /* Map Colors */
  --conn-color: rgba(255, 255, 255, 0.12);
  --conn-active: rgba(255, 255, 255, 0.4);

  /* Fonts */
  --font-heading: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* Reset and Globals */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: 
    radial-gradient(at 10% 10%, rgba(0, 210, 255, 0.03) 0px, transparent 50%),
    radial-gradient(at 90% 10%, rgba(208, 0, 255, 0.03) 0px, transparent 50%),
    radial-gradient(at 50% 90%, rgba(255, 0, 85, 0.02) 0px, transparent 50%);
  background-attachment: fixed;
}

/* Layout */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 2rem;
  background: rgba(10, 11, 14, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-glass);
  z-index: 10;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-container h1 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, #00d2ff 0%, #d000ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 30px rgba(0, 210, 255, 0.2);
}

.badge-version {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border-glass);
}

.status-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.turn-pill {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.4rem 1rem;
  border-radius: 9999px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.turn-pill .indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-muted);
}

.main-container {
  display: grid;
  grid-template-columns: 1fr 380px;
  flex: 1;
  height: calc(100vh - 72px);
  overflow: hidden;
}

/* Sidebar Dashboard */
.sidebar {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-left: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  height: 100%;
}

.sidebar-section {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-glass);
}

.sidebar-section h2 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Player Status List */
.player-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.player-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  transition: all 0.25s ease;
}

.player-card.active {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-glass-active);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.player-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.player-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
}

.player-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.player-personality {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.player-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  text-align: right;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-val {
  font-weight: 600;
  font-family: var(--font-mono);
}

.stat-lbl {
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* Action Controls Panel */
.action-controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.instruction-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 1rem;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

.btn-primary {
  font-family: var(--font-heading);
  background: linear-gradient(135deg, #00d2ff 0%, #0066ff 100%);
  color: #fff;
  border: none;
  padding: 0.9rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 15px rgba(0, 102, 255, 0.3);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 102, 255, 0.5);
  filter: brightness(1.1);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
  border: 1px solid var(--border-glass);
}

/* Console Logs */
.game-logs-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 200px;
  max-height: 350px;
}

.game-logs {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text-secondary);
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.log-entry {
  animation: logFadeIn 0.25s ease forwards;
  border-left: 2px solid transparent;
  padding-left: 0.5rem;
}

.log-entry.human { border-color: var(--p1-color); }
.log-entry.cautious { border-color: var(--p2-color); }
.log-entry.wreckless { border-color: var(--p3-color); }
.log-entry.strategic { border-color: var(--p4-color); }
.log-entry.system { border-color: var(--text-muted); color: var(--text-muted); }
.log-entry.combat { border-color: #ff3300; }

@keyframes logFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Map Screen area */
.map-area {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  background: radial-gradient(circle at center, rgba(18, 20, 26, 0.3) 0%, rgba(10, 11, 14, 0.8) 100%);
  overflow: hidden;
  padding: 2rem;
}

svg.game-map {
  width: 100%;
  height: 100%;
  max-width: 1000px;
  max-height: 650px;
  filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.5));
}

/* SVG Map Details */
.map-connector {
  stroke: var(--conn-color);
  stroke-width: 2.5;
  stroke-dasharray: 6, 6;
  fill: none;
  transition: all 0.3s ease;
}

.map-connector.intercontinent {
  stroke: rgba(255, 255, 255, 0.07);
  stroke-width: 2;
  stroke-dasharray: 4, 8;
}

.map-connector.active {
  stroke: var(--conn-active);
  stroke-width: 3.5;
  stroke-dasharray: none;
}

/* Continent Boundings or background styling */
.continent-group {
  opacity: 0.85;
  transition: opacity 0.3s ease;
}

.continent-group:hover {
  opacity: 1;
}

/* Node Styling */
.territory-node {
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.territory-circle {
  fill: var(--bg-secondary);
  stroke-width: 3;
  transition: all 0.3s ease;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

.territory-node:hover .territory-circle {
  transform: scale(1.08);
  filter: drop-shadow(0 0 12px currentColor);
}

/* Selection and valid targets states */
.territory-node.selected .territory-circle {
  stroke-width: 5;
  stroke: #ffffff !important;
  filter: drop-shadow(0 0 20px currentColor) !important;
  transform: scale(1.1);
}

.territory-node.attack-target .territory-circle {
  animation: pulseTarget 1.5s infinite;
}

@keyframes pulseTarget {
  0% { stroke-width: 3; stroke-dasharray: none; }
  50% { stroke-width: 6; stroke: #ff0055; stroke-dasharray: 4, 2; filter: drop-shadow(0 0 15px #ff0055); transform: scale(1.06); }
  100% { stroke-width: 3; stroke-dasharray: none; }
}

.territory-node.deploy-target .territory-circle {
  animation: pulseDeploy 1.5s infinite;
}

@keyframes pulseDeploy {
  0% { stroke-width: 3; transform: scale(1); }
  50% { stroke-width: 5; stroke: #ffffff; filter: drop-shadow(0 0 15px currentColor); transform: scale(1.05); }
  100% { stroke-width: 3; transform: scale(1); }
}

.node-label {
  font-family: var(--font-heading);
  font-size: 0.65rem;
  font-weight: 600;
  fill: #fff;
  text-anchor: middle;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 4px rgba(0, 0, 0, 0.5);
  user-select: none;
}

.node-continent-label {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  font-weight: 500;
  fill: var(--text-muted);
  text-anchor: middle;
  pointer-events: none;
  text-transform: uppercase;
  user-select: none;
}

/* Army Badge counter inside nodes */
.army-badge-bg {
  fill: #12141a;
  stroke: rgba(255, 255, 255, 0.15);
  stroke-width: 1.5;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.army-badge-text {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  fill: #0a0b0e;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  user-select: none;
}

/* Modals and Dialogs (Top Layer) */
dialog {
  margin: auto;
  border: 1px solid var(--border-glass-active);
  background: rgba(14, 16, 22, 0.92);
  backdrop-filter: blur(20px);
  border-radius: 16px;
  color: var(--text-primary);
  width: 90%;
  max-width: 520px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 40px rgba(0, 210, 255, 0.15);
  outline: none;
}

/* 1. Define the visible (open) state */
dialog[open] {
  opacity: 1;
  transform: scale(1);

  /* 2. Define the starting state for entry */
  @starting-style {
    opacity: 0;
    transform: scale(0.9);
  }
}

/* 3. Define the base (closed/exit) state and transitions */
dialog {
  opacity: 0;
  transform: scale(0.9);
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.3s;
  transition-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1);
  transition-behavior: allow-discrete;
}

/* 4. Animate the backdrop */
dialog::backdrop {
  background-color: rgba(0, 0, 0, 0);
  transition:
    display 0.3s allow-discrete,
    overlay 0.3s allow-discrete,
    background-color 0.3s ease-out;
}

dialog[open]::backdrop {
  background-color: rgba(6, 7, 10, 0.8);

  @starting-style {
    background-color: rgba(0, 0, 0, 0);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  dialog {
    transform: none;
    transition-duration: 0.1s;
  }
  @starting-style {
    dialog[open] {
      transform: none;
    }
  }
}

/* Modal Content details */
.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border-glass);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.btn-secondary {
  font-family: var(--font-heading);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid var(--border-glass);
  padding: 0.8rem 1.25rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-glass-active);
}

/* Setup Screen overlay overlay */
.setup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 14, 0.95);
  backdrop-filter: blur(16px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  text-align: center;
}

.setup-card {
  max-width: 500px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass-active);
  padding: 2.5rem;
  border-radius: 16px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6), 0 0 50px rgba(0, 210, 255, 0.1);
  animation: cardPulse 4s infinite alternate;
}

@keyframes cardPulse {
  from { box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6), 0 0 40px rgba(0, 210, 255, 0.05); }
  to { box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6), 0 0 60px rgba(208, 0, 255, 0.15); }
}

.setup-card h2 {
  font-family: var(--font-heading);
  font-size: 2rem;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #00d2ff 0%, #d000ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.setup-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 2rem;
}

/* Battle Overlay Modal content */
.battle-arena {
  display: flex;
  justify-content: space-around;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.battle-faction {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  padding: 1rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border-glass);
  text-align: center;
  transition: all 0.3s ease;
}

.battle-faction.attacker {
  border-color: rgba(0, 210, 255, 0.2);
}

.battle-faction.defender {
  border-color: rgba(255, 0, 85, 0.2);
}

.faction-role {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.faction-name {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.faction-armies {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.battle-vs {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-muted);
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

/* 3D Dice styling */
.die-container {
  width: 70px;
  height: 70px;
  position: relative;
  perspective: 200px;
}

.die {
  width: 100%;
  height: 100%;
  position: absolute;
  border-radius: 12px;
  background: rgba(22, 25, 35, 0.85);
  border: 2px solid currentColor;
  box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.1), 0 5px 15px rgba(0, 0, 0, 0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  transition: all 0.15s ease;
  user-select: none;
}

.die.rolling {
  animation: spinDie 0.4s infinite linear;
}

.die.loser {
  filter: grayscale(0.8) opacity(0.4);
  border-style: dashed;
  text-decoration: line-through;
}

@keyframes spinDie {
  0% { transform: rotateX(0deg) rotateY(0deg) scale(0.95); }
  50% { transform: rotateX(180deg) rotateY(90deg) scale(1.05); }
  100% { transform: rotateX(360deg) rotateY(360deg) scale(0.95); }
}

.battle-result-text {
  text-align: center;
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: #ff3300;
  min-height: 24px;
}

/* Custom Alert styles */
.game-instructions-overlay {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-top: 1rem;
  text-align: left;
}

.rule-card {
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border-glass);
  border-radius: 6px;
  font-size: 0.75rem;
}

.rule-card strong {
  color: var(--text-primary);
  display: block;
  margin-bottom: 0.25rem;
}

/* Screen shake for defeat */
.shake-screen {
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  10%, 30%, 50%, 70%, 90% { transform: translate(-3px, 2px); }
  20%, 40%, 60%, 80% { transform: translate(3px, -2px); }
}

/* Responsive Scaling */
@media (max-width: 1024px) {
  .main-container {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 300px;
    height: auto;
    overflow: auto;
  }
  .sidebar {
    border-left: none;
    border-top: 1px solid var(--border-glass);
    height: 450px;
  }
  .map-area {
    padding: 1rem;
    height: 500px;
  }
}

/* Movement Target Glowing Green Circle */
.territory-node.movement-target .territory-circle {
  animation: pulseMovement 1.5s infinite;
}

@keyframes pulseMovement {
  0% { stroke-width: 3; stroke-dasharray: none; }
  50% { stroke-width: 6; stroke: #00ff87; stroke-dasharray: 4, 2; filter: drop-shadow(0 0 15px #00ff87); transform: scale(1.06); }
  100% { stroke-width: 3; stroke-dasharray: none; }
}

/* Movement Modal Layout */
.movement-setup {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.movement-faction {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem;
  background: rgba(10, 11, 14, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

.movement-faction .faction-role {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 0.5rem;
}

.movement-faction .faction-name {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
  margin-bottom: 0.2rem;
  text-align: center;
}

.movement-faction .faction-owner {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.movement-faction .faction-armies {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
  margin-top: 0.3rem;
}

.movement-arrow {
  font-size: 2.5rem;
  color: var(--p1-color);
  text-shadow: 0 0 15px currentColor;
  animation: floatArrow 1.5s ease-in-out infinite;
}

@keyframes floatArrow {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(5px); }
}

.movement-slider-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  margin-bottom: 1rem;
}

.slider-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  justify-content: center;
}

.slider-controls input[type="range"] {
  flex: 1;
  max-width: 250px;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.1);
  height: 6px;
  border-radius: 3px;
  outline: none;
  transition: background 0.3s;
}

.slider-controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--p1-color);
  cursor: pointer;
  box-shadow: 0 0 8px var(--p1-color);
  transition: transform 0.1s, box-shadow 0.1s;
}

.slider-controls input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 15px var(--p1-color);
}

.btn-small {
  padding: 0.3rem 0.8rem !important;
  font-size: 0.9rem !important;
  min-width: unset !important;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.move-amount-value {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--p1-color);
  min-width: 30px;
  text-align: center;
  text-shadow: 0 0 10px currentColor;
}
