/* ============================================================
   KINGDOM · Mapa Táctico de Asedios — Carta de Guerra de Aden
   Estética Diegética: Mesa de Estrategia Militar Dark Fantasy
   ============================================================ */

.section-map {
  background:
    linear-gradient(180deg, var(--bg-0) 0%, transparent 12%, transparent 88%, var(--bg-0) 100%),
    radial-gradient(80% 60% at 50% 30%, rgba(42, 29, 16, 0.4) 0%, transparent 75%),
    url('../assets/images/backgrounds/bg-texture-stone.webp') repeat;
  background-size: auto, auto, 512px;
  position: relative;
  overflow: hidden;
}

.map-layout {
  display: grid;
  grid-template-columns: 1.65fr 1fr;
  gap: 28px;
  align-items: start;
}

/* ============================================================
   MESA DE ESTRATEGIA (MARCO DE NOGAL OSCURO Y HIERRO FORJADO)
   ============================================================ */
.map-frame {
  position: relative;
  padding: 18px;
  border-radius: 4px;
  background: linear-gradient(155deg, #2e2214 0%, #1c150c 55%, #100b06 100%);
  border: 2px solid #5a421c;
  box-shadow:
    inset 0 0 0 2px #120d08,
    inset 0 0 35px rgba(0, 0, 0, 0.9),
    0 24px 60px -25px rgba(0, 0, 0, 0.95);
}

.map-frame::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid var(--gold-shadow);
  border-radius: 2px;
  pointer-events: none;
  z-index: 5;
}

/* Remaches decorativos forjados en esquinas */
.rivet {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  z-index: 6;
  background: radial-gradient(circle at 35% 30%, #f4dc94, #947128 55%, #3a2c12);
  box-shadow: 0 1px 4px #000, inset 0 0 2px rgba(0, 0, 0, 0.8);
}
.rivet.tl { top: 9px; left: 9px; }
.rivet.tr { top: 9px; right: 9px; }
.rivet.bl { bottom: 9px; left: 9px; }
.rivet.br { bottom: 9px; right: 9px; }

/* Contenedor del pergamino cartográfico */
.aden-map {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 2px;
  overflow: hidden;
  background: #cbb483;
  box-shadow: inset 0 0 70px rgba(74, 51, 16, 0.7), 0 4px 20px rgba(0, 0, 0, 0.6);
  border: 1px solid #7d5e27;
}

/* Efecto de luz de antorcha / vela sobre la mesa de guerra */
.aden-map::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 60% at 50% 45%, rgba(255, 235, 175, 0.15) 0%, transparent 75%);
  pointer-events: none;
  z-index: 2;
  mix-blend-mode: overlay;
}

.aden-map .map-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: contrast(1.04) sepia(0.15);
}

/* Leyenda táctica cartográfica */
.map-legend {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 6;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  padding: 8px 14px;
  font-family: var(--f-display);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #2b1f11;
  background: rgba(235, 220, 185, 0.94);
  border: 1px solid #9e814a;
  border-radius: 2px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 0 10px rgba(160, 130, 80, 0.2);
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.3);
}

.legend-dot.siege {
  background: var(--blood);
  box-shadow: 0 0 8px var(--blood);
}

.legend-dot.held {
  background: #c8952a;
  box-shadow: 0 0 5px rgba(200, 149, 42, 0.7);
}

.legend-dot.free {
  background: #4a7c9f;
  box-shadow: 0 0 5px rgba(74, 124, 159, 0.7);
}

/* ============================================================
   PINES HERÁLDICOS DE CASTILLO (BANDERA Y BALIZA)
   ============================================================ */
.castle-pin {
  position: absolute;
  z-index: 7;
  transform: translate(-50%, -100%);
  background: none;
  border: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--ink);
  cursor: pointer;
  outline: none;
}

.castle-pin .pennant {
  position: relative;
  width: 32px;
  height: 42px;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.75));
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), filter 0.25s ease;
}

.castle-pin .pennant svg {
  width: 100%;
  height: 100%;
}

.castle-pin:hover .pennant,
.castle-pin.is-active .pennant {
  transform: translateY(-5px) scale(1.15);
}

.castle-pin .pin-name {
  margin-top: 3px;
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #1e150b;
  background: rgba(240, 227, 196, 0.95);
  padding: 2px 7px;
  border-radius: 2px;
  border: 1px solid #9e814a;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  transition: all 0.2s ease;
}

.castle-pin:hover .pin-name,
.castle-pin.is-active .pin-name {
  background: #fff3d1;
  border-color: #5a421c;
  color: #000;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.7);
}

/* Baliza de asedio inminente */
.castle-pin .pulse {
  position: absolute;
  top: 8px;
  left: 50%;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  border-radius: 50%;
  border: 2px solid var(--blood);
  opacity: 0;
  pointer-events: none;
}

.castle-pin.is-next .pulse {
  animation: pinPulse 2s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}

.castle-pin.is-next .pennant {
  filter: drop-shadow(0 0 10px var(--blood)) drop-shadow(0 4px 6px rgba(0, 0, 0, 0.8));
}

@keyframes pinPulse {
  0% {
    opacity: 0.95;
    transform: scale(0.6);
  }
  100% {
    opacity: 0;
    transform: scale(2.8);
  }
}

.castle-pin:focus-visible {
  outline: 2px solid var(--blood);
  outline-offset: 4px;
  border-radius: 3px;
}

/* ============================================================
   CÉDULA DE GUERRA FLOTANTE (ROYAL WAR DISPATCH / TOOLTIP)
   ============================================================ */
.siege-tooltip {
  position: absolute;
  z-index: 20;
  width: 275px;
  max-width: 82vw;
  padding: 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.96);
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s ease;
  pointer-events: none;
}

.siege-tooltip.is-open {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.siege-tooltip .scroll-body {
  position: relative;
  padding: 20px 22px 18px;
  color: #1e150a;
  background: radial-gradient(120% 90% at 50% 0%, #f6edd4, #ebd7aa 55%, #dfc590 100%);
  border: 2px solid #8c6a28;
  border-radius: 3px;
  box-shadow:
    inset 0 0 35px rgba(140, 106, 40, 0.35),
    0 22px 45px -15px rgba(0, 0, 0, 0.85);
}

.siege-tooltip .scroll-body::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--noise);
  opacity: 0.16;
  mix-blend-mode: multiply;
  pointer-events: none;
  border-radius: inherit;
}

/* Rodillos de madera noble del pergamino */
.siege-tooltip .roll {
  height: 12px;
  background: linear-gradient(180deg, #7a5c24, #3a2a10);
  border-radius: 6px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.6);
  position: relative;
  z-index: 1;
  border: 1px solid #947128;
}
.siege-tooltip .roll.bottom { margin-top: -3px; }
.siege-tooltip .roll.top { margin-bottom: -3px; }

.tt-castle {
  font-family: var(--f-display);
  font-weight: 900;
  font-size: 1.25rem;
  color: #1c1308;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.4);
}

.tt-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 2px;
  margin-bottom: 12px;
}

.tt-status.siege {
  background: rgba(163, 39, 31, 0.18);
  color: #8c1d15;
  border: 1px solid rgba(163, 39, 31, 0.5);
}

.tt-status.held {
  background: rgba(140, 106, 36, 0.18);
  color: #6b4d12;
  border: 1px solid rgba(140, 106, 36, 0.5);
}

.tt-status.free {
  background: rgba(74, 124, 159, 0.18);
  color: #2b5675;
  border: 1px solid rgba(74, 124, 159, 0.5);
}

.tt-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.88rem;
  padding: 6px 0;
  border-top: 1px solid rgba(140, 106, 40, 0.35);
}

.tt-row .k {
  color: #5c4728;
  font-style: italic;
}

.tt-row .v {
  font-family: var(--f-display);
  font-weight: 700;
  color: #181005;
  text-align: right;
}

/* Contador dentro del tooltip */
.tt-count {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.tt-count .cd-box {
  min-width: 0;
  flex: 1;
  padding: 8px 4px 6px;
  background: #1e160c;
  border: 1px solid #5a421a;
  border-radius: 2px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.8);
}

.tt-count .cd-num {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--gold-bright);
}

.tt-count .cd-label {
  font-size: 0.52rem;
  color: var(--parch-dim);
  margin-top: 3px;
  text-transform: uppercase;
}

/* ============================================================
   CUADERNO DE GUERRA (LEDGER LATERAL)
   ============================================================ */
.war-ledger {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* Placa del próximo asedio */
.ledger-next {
  position: relative;
  padding: 28px 28px 24px;
  border-radius: 3px;
  background: linear-gradient(170deg, #241a10 0%, #161008 100%);
  border: 1px solid var(--gold-shadow);
  box-shadow: inset 0 1px 0 rgba(244, 220, 148, 0.15), 0 16px 36px -12px rgba(0, 0, 0, 0.8);
}

.ledger-next::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--blood), transparent);
}

.ledger-next .next-label {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: #e0452c;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ledger-next .next-label .icon {
  width: 17px;
  height: 17px;
  color: #e0452c;
  filter: drop-shadow(0 0 6px rgba(224, 69, 44, 0.6));
}

.ledger-next h3 {
  font-family: var(--f-display);
  font-size: 1.85rem;
  font-weight: 900;
  margin: 10px 0 4px;
  color: var(--gold-bright);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.ledger-next .next-time {
  color: var(--parch-dim);
  font-size: 0.92rem;
  font-style: italic;
  margin-bottom: 20px;
}

.ledger-next .next-countdown {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.ledger-next .next-countdown .cd-box {
  flex: 1;
  padding: 10px 4px 8px;
  background: #100b06;
  border: 1px solid #4a3616;
  border-radius: 2px;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.9);
}

.ledger-next .next-countdown .cd-num {
  font-size: 1.45rem;
  font-weight: 900;
  color: var(--gold-bright);
}

.ledger-next .next-countdown .cd-label {
  font-size: 0.58rem;
  color: var(--parch-dim);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.ledger-next .next-reward {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  color: var(--parch-2);
  padding-top: 16px;
  border-top: 1px solid var(--gold-shadow);
}

.ledger-next .next-reward .icon {
  width: 18px;
  height: 18px;
  color: var(--gold);
}

/* Bitácora de eventos semanales */
.ledger-week {
  padding: 24px 26px;
  border-radius: 3px;
  background: linear-gradient(170deg, #1e150d 0%, #120d07 100%);
  border: 1px solid var(--gold-shadow);
  box-shadow: inset 0 1px 0 rgba(244, 220, 148, 0.1), 0 16px 36px -12px rgba(0, 0, 0, 0.8);
}

.ledger-week h4 {
  font-family: var(--f-display);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ledger-week h4 .icon {
  width: 17px;
  height: 17px;
  color: var(--gold);
}

.event-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid rgba(58, 44, 26, 0.5);
  transition: background 0.2s ease;
}

.event-row:first-of-type {
  border-top: 0;
}

.event-day {
  text-align: center;
}

.event-day .d-name {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
}

.event-day .d-time {
  font-size: 0.76rem;
  color: var(--parch-dim);
}

.event-info h5 {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 0.94rem;
  color: var(--parch);
  margin: 0 0 3px;
}

.event-info p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--parch-dim);
  line-height: 1.45;
}

.event-tag {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 2px;
  white-space: nowrap;
}

/* ============================================================
   RESPONSIVIDAD Y ADAPTACIÓN MÓVIL
   ============================================================ */
@media (max-width: 980px) {
  .map-layout {
    grid-template-columns: 1fr;
  }
  .aden-map {
    aspect-ratio: 1 / 1;
  }
}

@media (max-width: 560px) {
  .map-frame {
    padding: 10px;
  }
  .castle-pin .pin-name {
    font-size: 0.56rem;
    padding: 1px 4px;
  }
  .castle-pin .pennant {
    width: 25px;
    height: 33px;
  }
  .siege-tooltip {
    width: 230px;
  }
  .event-row {
    grid-template-columns: 48px 1fr;
    gap: 10px;
  }
  .event-tag {
    display: none;
  }
  .map-legend {
    font-size: 0.55rem;
    padding: 6px 10px;
    gap: 8px;
  }
}
