/* Diseño panorámico de la página Mapa v0.6.11.
   En escritorio se elimina la columna reservada al TOC y se aprovecha casi
   todo el ancho de la ventana. En móvil se conserva el flujo normal. */
@media (min-width: 992px) {
  body:has(section#mapa) #quarto-content > main.content {
    grid-column: screen-start-inset / screen-end-inset;
  }
}

body:has(section#mapa) #title-block-header {
  margin-top: 0.45rem;
  margin-bottom: 0.2rem;
}

body:has(section#mapa) #title-block-header h1.title {
  margin-bottom: 0.1rem;
  font-size: clamp(1.55rem, 2vw, 2rem);
}

body:has(section#mapa) #title-block-header .subtitle {
  margin-top: 0;
  margin-bottom: 0.15rem;
  font-size: clamp(0.9rem, 1.15vw, 1.05rem);
}

body:has(section#mapa) section#mapa > h2 {
  margin-top: 0.15rem;
  margin-bottom: 0.35rem;
  font-size: 1.2rem;
}

body:has(section#mapa) section#mapa .cell {
  margin-bottom: 0.5rem;
}

body:has(section#mapa) .leaflet.html-widget {
  width: 100% !important;
  border: 1px solid rgba(55, 65, 75, 0.18);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

body:has(section#mapa) .callout-note {
  margin-top: 0.65rem;
}

.quarto-title-block .quarto-title-banner {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.fire-panel {
  background: rgba(255, 255, 255, 0.92);
  padding: 10px 12px;
  border-radius: 6px;
  box-shadow: 0 1px 5px rgba(0,0,0,0.35);
  font-size: 13px;
  line-height: 1.25;
}

.fire-panel label {
  display: block;
  margin-top: 6px;
  font-weight: 600;
}

.fire-panel select {
  width: 220px;
  max-width: 220px;
  margin-top: 2px;
}

.fire-legend {
  background: rgba(255, 255, 255, 0.92);
  padding: 10px 12px;
  border-radius: 6px;
  box-shadow: 0 1px 5px rgba(0,0,0,0.35);
  font-size: 13px;
}

.fire-legend .swatch {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 6px;
  vertical-align: middle;
  border: 1px solid #555;
}

.fire-legend-context {
  margin: 5px 0 3px 0;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(85, 85, 85, 0.35);
  color: #333;
  line-height: 1.3;
}

.fire-panel small {
  display: block;
  margin-top: 6px;
  color: #555;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  border: 1px solid #555;
}

.dot-red { background: #d7191c; }
.dot-orange { background: #fdae61; }
.dot-yellow { background: #ffffbf; }
.dot-grey { background: #999999; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0 1.25rem 0;
}

.summary-card {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.summary-card span {
  display: block;
  font-size: 0.82rem;
  color: #555;
  margin-bottom: 0.2rem;
}

.summary-card strong {
  display: block;
  font-size: 1.45rem;
  line-height: 1.2;
}


.alert-high {
  color: #8b0000;
  font-weight: 700;
}

.alert-medium {
  color: #a65f00;
  font-weight: 700;
}

.report-box {
  border-left: 4px solid #d7191c;
  padding: 0.75rem 1rem;
  background: #fff7f7;
  margin: 1rem 0;
}

.dot-purple { background: #7b3294; }
.dot-darkred { background: #8b0000; }

.summary-card small {
  display: block;
  margin-top: 0.15rem;
  color: #666;
  font-size: 0.78rem;
}

/* El widget usa height="88vh" desde index.qmd; estas reglas evitan que el
   mapa quede demasiado bajo en monitores grandes o portátiles panorámicos. */
.leaflet.html-widget {
  min-height: 760px;
}

@media (max-height: 850px) {
  .leaflet.html-widget {
    min-height: 600px;
  }
}

@media (max-width: 760px) {
  .leaflet.html-widget {
    min-height: 620px;
  }
}

.aemet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1rem;
  align-items: start;
}

.aemet-card {
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  padding: 0.85rem;
}

.aemet-card h3 {
  font-size: 1rem;
  margin: 0 0 0.6rem 0;
}

.aemet-img {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid #eee;
  background: #f8f8f8;
}

.aemet-caption {
  margin: 0.6rem 0 0 0;
  font-size: 0.82rem;
  color: #666;
}

.aemet-empty {
  border: 1px dashed #bbb;
  padding: 1rem;
  border-radius: 8px;
  background: #fafafa;
}

.fire-panel select {
  width: 370px;
  max-width: 72vw;
}

.fire-panel input[type="range"] {
  width: 100%;
}


.fire-timeline {
  display: grid;
  grid-template-columns: 38px 38px 38px 1fr;
  gap: 5px;
  align-items: center;
  margin-top: 7px;
}

.fire-timeline button {
  min-width: 38px;
  height: 32px;
  padding: 0;
  border: 1px solid #9aa0a6;
  border-radius: 5px;
  background: #fff;
  color: #222;
  cursor: pointer;
  font-size: 14px;
  line-height: 30px;
}

.fire-timeline button:hover:not(:disabled),
.fire-timeline button:focus-visible {
  background: #eef4fb;
  border-color: #4b7bec;
}

.fire-timeline button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.fire-timeline button.is-playing {
  background: #e8f2ff;
  border-color: #2563a8;
  color: #174f83;
}

.fire-layer-position {
  text-align: right;
  color: #555;
  font-size: 0.82rem;
  white-space: nowrap;
}

.data-freshness {
  margin-top: 9px;
  padding-top: 7px;
  border-top: 1px solid rgba(85, 85, 85, 0.25);
}

.freshness-title {
  margin-bottom: 3px;
  font-weight: 600;
}

.freshness-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 0.82rem;
  color: #333;
}

.freshness-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #8a8a8a;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.freshness-fresh .freshness-dot { background: #2e8b57; }
.freshness-warning .freshness-dot { background: #d99500; }
.freshness-stale .freshness-dot { background: #c43d3d; }
.freshness-unavailable .freshness-dot { background: #8a8a8a; }

@media (max-width: 600px) {
  .fire-panel select {
    width: min(370px, 76vw);
  }

  .fire-timeline {
    grid-template-columns: 36px 36px 36px 1fr;
  }
}

/* Panel territorial interactivo v0.6.9 */
.territory-panel {
  width: 330px;
  max-width: min(330px, 78vw);
  max-height: calc(88vh - 80px);
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.34);
  font-size: 12.5px;
  line-height: 1.3;
  color: #222;
}

.territory-panel.is-empty {
  width: 280px;
}

.territory-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #d8dde2;
  background: #f3f7fa;
  border-radius: 8px 8px 0 0;
}

.territory-panel-header strong {
  display: block;
  font-size: 1rem;
  line-height: 1.2;
}

.territory-level {
  display: block;
  margin-bottom: 2px;
  color: #5d6873;
  font-size: 0.75rem;
}

.territory-close {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #45515c;
  font-size: 22px;
  line-height: 26px;
  cursor: pointer;
}

.territory-close:hover,
.territory-close:focus-visible {
  background: #dde8ef;
  color: #123c55;
}

.territory-panel-empty {
  padding: 10px 12px;
  color: #4e5963;
}

.territory-section {
  padding: 9px 12px;
  border-bottom: 1px solid #e1e5e8;
}

.territory-section-title {
  margin-bottom: 6px;
  color: #34434f;
  font-weight: 700;
}

.territory-section small {
  display: block;
  margin-top: 5px;
  color: #66727c;
  font-size: 0.72rem;
}

.territory-risk {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 31px;
  padding: 6px 8px;
  border: 1px solid #d7dde1;
  border-radius: 5px;
  background: #f7f8f9;
  font-weight: 700;
}

.territory-risk-swatch {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  border: 1px solid rgba(0, 0, 0, 0.35);
  border-radius: 3px;
  background: #9aa0a6;
}

.risk-critical { border-color: #9b1c1c; background: #fff0f0; }
.risk-high { border-color: #d46b1f; background: #fff5ec; }
.risk-medium { border-color: #c49a00; background: #fffbea; }
.risk-low { border-color: #4e91b5; background: #eef8fd; }
.risk-loading,
.risk-unavailable { color: #626d75; }

.territory-window-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.territory-window-grid > div {
  padding: 5px 3px;
  border: 1px solid #dfe4e7;
  border-radius: 5px;
  background: #f8fafb;
  text-align: center;
}

.territory-window-grid strong,
.territory-window-grid span {
  display: block;
}

.territory-window-grid strong {
  font-size: 1.05rem;
}

.territory-window-grid span {
  color: #65717a;
  font-size: 0.7rem;
}

.territory-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-top: 7px;
}

.territory-metrics span {
  padding: 5px 6px;
  border-radius: 4px;
  background: #f3f5f6;
}

.territory-metrics strong {
  display: block;
}

.territory-latest {
  margin-top: 7px;
  color: #4b5760;
}

.territory-alert {
  margin-top: 6px;
  padding: 4px 7px;
  border-left: 4px solid #8a8a8a;
  background: #f5f5f5;
  text-transform: capitalize;
}

.territory-alert-alta {
  border-left-color: #7b3294;
  background: #f7eef9;
}

.territory-alert-media {
  border-left-color: #d7191c;
  background: #fff0f0;
}

.territory-alert-seguimiento {
  border-left-color: #f0a029;
  background: #fff7e9;
}

.territory-effis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.territory-effis-grid > div {
  padding: 6px 7px;
  border: 1px solid #e0d7e8;
  border-radius: 5px;
  background: #faf7fc;
}

.territory-effis-grid strong,
.territory-effis-grid span {
  display: block;
}

.territory-effis-grid span {
  margin-top: 2px;
  color: #686071;
  font-size: 0.7rem;
}

.territory-actions {
  padding: 8px 12px 10px;
}

.territory-actions button {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #4d7892;
  border-radius: 5px;
  background: #edf6fb;
  color: #214e68;
  cursor: pointer;
  font-weight: 600;
}

.territory-actions button:hover,
.territory-actions button:focus-visible {
  background: #dceff8;
}

@media (max-width: 760px) {
  .territory-panel {
    width: min(320px, 80vw);
    max-height: 56vh;
  }

  .territory-panel.is-empty {
    width: min(270px, 76vw);
  }
}

/* Estado de carga dinámica de assets (v0.6.24). */
.runtime-source-status {
  margin-top: 5px;
  margin-bottom: 2px;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 0.78rem;
  line-height: 1.25;
  background: rgba(100, 116, 139, 0.10);
  color: #475569;
}

.runtime-source-status.is-loading {
  background: rgba(37, 99, 235, 0.08);
  color: #1d4ed8;
}

.runtime-source-status.is-fresh {
  background: rgba(46, 139, 87, 0.10);
  color: #246b45;
}

.runtime-source-status.is-warning {
  background: rgba(217, 149, 0, 0.12);
  color: #8a5a00;
}
