/* World Map Layout */

.map-info {
  max-width: 800px;
  margin: 1rem auto;
  display: flex;
  justify-content: center;
  gap: 2rem;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  border: 1px solid #333;
}

.info-item {
  text-align: center;
}

.info-label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #888;
  margin-bottom: 0.25rem;
}

.info-value {
  font-size: 1rem;
  font-weight: 600;
  color: #c9a84c;
}

/* Map Grid */
.map-grid {
  max-width: 800px;
  margin: 1.5rem auto;
  display: grid;
  gap: 8px;
  justify-content: center;
}

.map-cell {
  width: 120px;
  height: 80px;
  border-radius: 8px;
  cursor: pointer;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.3s;
  border: 2px solid #333;
  background: #16213e;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.map-cell:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(201, 168, 76, 0.3);
}

/* Face-down card uses .card-back.map component */
.map-cell.face-down {
  background: transparent;
  border-color: rgba(180, 160, 90, 0.4);
  padding: 0;
}

.map-cell.face-down > .card-back {
  position: absolute;
  inset: 0;
  border-radius: 6px;
}

.map-cell.face-down::after {
  content: '\2605';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: rgba(180, 160, 90, 0.5);
  border: 2px solid rgba(180, 160, 90, 0.35);
  border-radius: 50%;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
  z-index: 3;
  pointer-events: none;
}

/* Face-up cards by terrain type */
.map-cell.face-up {
  border-color: #555;
}

.map-cell.terrain-plains { background: linear-gradient(135deg, #2d5016, #1a3309); border-color: #4a7a2a; }
.map-cell.terrain-forest { background: linear-gradient(135deg, #1a3d12, #0d2008); border-color: #2d6120; }
.map-cell.terrain-mountain { background: linear-gradient(135deg, #4a3d2e, #2d2520); border-color: #6b5c4a; }
.map-cell.terrain-desert { background: linear-gradient(135deg, #5a4a20, #3d3015); border-color: #8a7a3a; }
.map-cell.terrain-cave { background: linear-gradient(135deg, #2a2035, #1a1525); border-color: #4a3a5a; }
.map-cell.terrain-coast { background: linear-gradient(135deg, #1a3d5a, #0d2535); border-color: #2a5a7a; }
.map-cell.terrain-swamp { background: linear-gradient(135deg, #2a3d1a, #1a2510); border-color: #4a5a2a; }
.map-cell.terrain-ruins { background: linear-gradient(135deg, #3d2d2d, #251a1a); border-color: #5a3a3a; }

/* Campaign event cards */
.map-cell.type-campaign {
  border-color: #c9a84c;
  box-shadow: 0 0 8px rgba(201, 168, 76, 0.2);
}

.map-cell.type-campaign::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid rgba(201, 168, 76, 0.3);
  border-radius: 6px;
}

/* Campaign event won in combat: dimmed with a victory check */
.map-cell.type-campaign.cleared {
  border-color: #51cf66;
  box-shadow: 0 0 8px rgba(81, 207, 102, 0.25);
}
.map-cell.type-campaign.cleared .cell-art {
  filter: grayscale(0.6) brightness(0.7);
}
.map-cell.type-campaign.cleared::after {
  content: '\2713';
  position: absolute;
  top: 4px;
  right: 6px;
  color: #51cf66;
  font-size: 1rem;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  z-index: 2;
}

/* Nexus card */
.map-cell.type-nexus {
  border-color: #74c0fc;
  box-shadow: 0 0 12px rgba(116, 192, 252, 0.3);
  background: linear-gradient(135deg, #1a2d5a, #0d1a35);
}

/* Squad marker */
.map-cell.has-squad {
  border-color: #51cf66;
  box-shadow: 0 0 16px rgba(81, 207, 102, 0.4);
}

.map-cell.has-squad::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #51cf66;
  box-shadow: 0 0 8px rgba(81, 207, 102, 0.6);
  z-index: 2;
}

/* Adjacent (clickable) cells */
.map-cell.adjacent {
  border-color: rgba(201, 168, 76, 0.5);
  animation: pulse-adjacent 2s ease-in-out infinite;
}

@keyframes pulse-adjacent {
  0%, 100% { box-shadow: 0 0 4px rgba(201, 168, 76, 0.2); }
  50% { box-shadow: 0 0 12px rgba(201, 168, 76, 0.4); }
}

/* World map card art on revealed tiles */
.cell-art {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.4;
  border-radius: 6px;
  z-index: 0;
}

.map-cell.face-up:hover .cell-art {
  opacity: 0.6;
}

.cell-name {
  font-size: 0.65rem;
  font-weight: 600;
  color: #f0e8d0;
  text-align: center;
  padding: 4px 6px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 1), 0 0 8px rgba(0, 0, 0, 0.8);
  position: relative;
  z-index: 2;
  line-height: 1.3;
}

/* Dark overlay for text readability on revealed tiles */
.map-cell.face-up::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
  z-index: 1;
  pointer-events: none;
}

/* Map actions */
.map-actions {
  max-width: 800px;
  margin: 1rem auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

/* Map log */
.map-log {
  max-width: 800px;
  margin: 1rem auto;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 12px;
  border: 1px solid #333;
}

.map-log h3 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #888;
}

.map-log .log-entries {
  max-height: 150px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  line-height: 1.6;
  color: #aaa;
}

/* Encounter modal */
.encounter-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.encounter-modal.active {
  opacity: 1;
  pointer-events: all;
}

.encounter-content {
  background: linear-gradient(135deg, #2a2218, #1e1a14);
  border: 1px solid rgba(201, 168, 76, 0.4);
  border-radius: 12px;
  padding: 2rem;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), inset 0 0 40px rgba(201, 168, 76, 0.03);
}

.encounter-content h2 {
  color: #c9a84c;
  margin: 0 0 1rem;
  font-size: 1.3rem;
  text-shadow: 0 1px 4px rgba(201, 168, 76, 0.3);
}

.encounter-content p {
  color: #bba580;
  margin: 0 0 1.5rem;
  line-height: 1.7;
  font-style: italic;
}

.encounter-content .btn-action {
  margin: 0 0.5rem;
}

/* Mission briefing parchment style */
.briefing-modal .encounter-content {
  max-width: 500px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(201, 168, 76, 0.06), transparent 60%),
    linear-gradient(135deg, #2a2218, #1e1a14);
  border-color: rgba(201, 168, 76, 0.5);
}

.briefing-title {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: #888;
  margin-bottom: 0.5rem;
}

.briefing-name {
  font-size: 1.4rem;
  color: #c9a84c;
  font-weight: 700;
  margin-bottom: 1rem;
  text-shadow: 0 1px 4px rgba(201, 168, 76, 0.3);
}

.briefing-text {
  color: #bba580;
  font-size: 0.9rem;
  line-height: 1.8;
  margin-bottom: 1.5rem;
  font-style: italic;
  padding: 1rem;
  border-top: 1px solid rgba(201, 168, 76, 0.15);
  border-bottom: 1px solid rgba(201, 168, 76, 0.15);
}

.briefing-objectives {
  text-align: left;
  margin-bottom: 1.5rem;
}

.briefing-objectives h4 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #888;
  margin-bottom: 0.5rem;
}

.briefing-objectives li {
  color: #bba580;
  font-size: 0.85rem;
  line-height: 1.6;
  margin-bottom: 0.25rem;
  list-style: none;
  padding-left: 1rem;
  position: relative;
}

.briefing-objectives li::before {
  content: '\2022';
  color: #c9a84c;
  position: absolute;
  left: 0;
}

/* Mobile responsive map */
@media (max-width: 768px) {
  .map-info {
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.5rem;
  }

  .map-grid {
    gap: 5px;
    padding: 0 0.5rem;
    max-width: 100%;
    /* Override JS inline grid-template-columns: 3 flexible columns */
    grid-template-columns: repeat(3, 1fr) !important;
  }

  .map-cell {
    width: auto;
    height: 70px;
    border-radius: 6px;
  }

  .cell-terrain-icon {
    font-size: 0.9rem;
  }

  .cell-name {
    font-size: 0.5rem;
  }


  .map-cell.has-squad::before {
    width: 8px;
    height: 8px;
    top: 2px;
    left: 2px;
  }

  .encounter-content {
    max-width: 90%;
    padding: 1.5rem;
  }

  .map-log {
    margin: 0.5rem;
  }
}
