/* Historical-fire LocalWP preview: one map panel plus one small map timeline.
   Style stays scoped to this feature and reuses OCI design tokens. */

.ofi-habitat-fires-page #ofi-orangutan-map .ofi-fire-layer-panel {
  width: 235px;
  max-width: calc(100vw - 86px);
}
.ofi-historical-panel__view[hidden],
.ofi-historical-timeline[hidden],
.ofi-historical-timeline__details[hidden],
.ofi-historical-panel__history[hidden],
.ofi-habitat-fires-page .ofi-range-control[hidden] { display: none !important; }

.ofi-historical-panel__tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  padding: 4px;
  margin-top: 10px;
  border-radius: 5px;
  background: var(--ofi-color-border-soft, #eef1ee);
}
.ofi-historical-panel__tabs button {
  padding: 8px 5px;
  min-height: 36px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ofi-color-text-secondary, #465449);
  font: inherit;
  font-weight: 700;
  font-size: .73rem;
  cursor: pointer;
}
.ofi-historical-panel__tabs button[aria-selected="true"] {
  color: var(--ofi-color-text-primary);
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.10);
}
.ofi-historical-panel__mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  margin-top: 13px;
  padding: 4px;
  border-radius: 5px;
  background: var(--ofi-color-border-soft, #eef1ee);
}
.ofi-historical-panel__mode button {
  min-height: 36px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ofi-color-text-secondary);
  font: inherit;
  font-size: .72rem;
  font-weight: 700;
  cursor: pointer;
}
.ofi-historical-panel__mode button.is-active {
  background: #fff;
  color: var(--ofi-color-text-primary);
  box-shadow: 0 1px 4px rgba(0,0,0,.10);
}
.ofi-historical-panel__time .ofi-range-control {
  width: 100%;
  margin: 12px 0 0;
  text-align: left;
  gap: 6px;
}
.ofi-historical-panel__time .ofi-range-control__head {
  align-items: center;
  justify-content: space-between;
  gap: 5px;
}
.ofi-historical-panel__time .ofi-range-control__head .ofi-kicker {font-size: .62rem;}
.ofi-historical-panel__time .ofi-range-control__value {font-size: .67rem;}
.ofi-historical-panel__time .ofi-range-control__ticks small {font-size:.58rem;}
.ofi-historical-panel__time .ofi-range-control__status {
  font-size: .68rem;
  line-height: 1.5;
  margin-top: 1px;
  text-align: left;
  overflow-wrap: anywhere;
}
.ofi-historical-panel__history {
  margin-top: 13px;
  border-top: 1px solid var(--ofi-color-border-soft, #e6ebe7);
  padding-top: 11px;
  display: grid;
  gap: 5px;
}
.ofi-historical-panel__eyebrow {
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ofi-color-text-muted, #607065);
}
.ofi-historical-panel__history strong {
  font-size: 1rem;
  line-height: 1.3;
}
.ofi-historical-panel__history p {
  color: var(--ofi-color-text-primary, #2c3b32);
  font-size: .69rem;
  line-height: 1.5;
  margin: 2px 0;
}
.ofi-historical-panel__history small {
  color: var(--ofi-color-text-muted, #607065);
  font-size: .62rem;
  line-height: 1.5;
}
.ofi-historical-panel__view {padding-bottom: 2px;}

/* Timeline: attached to the map, collapsed by default. Never display
   fabricated monthly bar heights until the full 2026 archive is imported. */
.ofi-habitat-fires-page #range .ofi-historical-timeline {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  width: min(740px, calc(100% - 32px));
  box-sizing: border-box;
  z-index: 7;
  padding: 11px 16px 12px;
  background: rgba(255,255,255,.97);
  color: var(--ofi-color-text-primary, #2b3c32);
  border: 1px solid var(--ofi-color-border-default, #d4dbd5);
  border-radius: 9px;
  font-family: inherit;
  backdrop-filter: blur(6px);
}
.ofi-historical-timeline__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.ofi-historical-timeline__title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 10px;
}
.ofi-historical-timeline__title strong {font-size:.76rem;}
.ofi-historical-timeline__top-actions {
  display:flex;
  align-items:center;
  gap: 9px;
  flex: 0 0 auto;
}
.ofi-historical-timeline__quick {
  font-size:.67rem;
  color:var(--ofi-color-text-secondary,#4e6554);
  font-weight:700;
  font-variant-numeric:tabular-nums;
  white-space:nowrap;
}
.ofi-historical-timeline__title span {
  font-size: .66rem;
  color: var(--ofi-color-text-muted, #647267);
}
.ofi-historical-timeline__expand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: #fff;
  border: 1px solid var(--ofi-color-brand-orange);
  border-radius: 4px;
  color: var(--ofi-color-text-primary);
  white-space: nowrap;
  font: inherit;
  font-size: .7rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 34px;
  padding: 5px 9px;
}
.ofi-historical-timeline__expand-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  flex: none;
  line-height: 0;
}
.ofi-historical-timeline__expand-chevron svg {
  display: block;
  width: 12px;
  height: 12px;
}
.ofi-historical-timeline__expand[aria-expanded="true"] .ofi-historical-timeline__expand-chevron {transform:rotate(180deg);}
.ofi-historical-timeline__graph-icon {
  display:flex;
  align-items:flex-end;
  gap:2px;
  height:13px;
  width:14px;
  flex: none;
}
.ofi-historical-timeline__graph-icon i {
  display:block;
  width:3px;
  height:6px;
  border-radius:1px 1px 0 0;
  background:currentColor;
}
.ofi-historical-timeline__graph-icon i:nth-child(2) {height:12px;}
.ofi-historical-timeline__graph-icon i:nth-child(3) {height:9px;}
.ofi-historical-timeline__months {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 2px;
  margin-top: 5px;
}
.ofi-historical-timeline__months button {
  min-height: 29px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--ofi-color-text-secondary, #475c4e);
  font: inherit;
  font-weight: 650;
  font-size: .69rem;
  cursor: pointer;
  padding: 2px 0;
}
.ofi-historical-timeline__months button.is-active {
  color: #fff;
  background: var(--ofi-color-brand-orange);
  border-bottom-color: var(--ofi-color-brand-orange);
  border-radius:4px;
  font-weight:800;
}
.ofi-historical-timeline__details {
  margin-top: 9px;
  border-top: 1px solid var(--ofi-color-border-soft, #e8ece9);
  padding-top: 8px;
}
.ofi-historical-timeline__window {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: .75rem;
  font-weight: 750;
}
.ofi-historical-timeline__window button {
  width: 32px;
  height: 32px;
  font: inherit;
  font-size: 1.2rem;
  background: #fff;
  border: 1px solid var(--ofi-color-border-default, #cbd3cd);
  border-radius: 5px;
  cursor: pointer;
}
.ofi-historical-timeline__window button:disabled {opacity:.4;cursor:not-allowed;}
.ofi-historical-timeline__chart {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  height: 112px;
  padding: 3px 0 0;
}
.ofi-historical-timeline__day {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0 1px;
}
.ofi-historical-timeline__day:disabled {cursor: default;}
.ofi-historical-timeline__count {font-size:.68rem;font-weight:700;}
.ofi-historical-timeline__bar {
  width: min(64px, 80%);
  min-height: 3px;
  background: var(--ofi-color-brand-orange,#b96c3c);
  border-radius: 3px 3px 0 0;
  opacity:.82;
}
.ofi-historical-timeline__day.is-selected .ofi-historical-timeline__bar {
  outline:2px solid var(--ofi-color-brand-orange);outline-offset:2px;
}
.ofi-historical-timeline__day small {
  font-size: .66rem;
  color: var(--ofi-color-text-muted,#607065);
}
.ofi-historical-timeline__status {
  font-size: .71rem;
  line-height: 1.35;
  text-align: center;
  margin: 8px 0 0;
}
.ofi-historical-timeline__note {
  color: var(--ofi-color-text-muted,#607065);
  font-size: .65rem;
  line-height: 1.5;
  text-align: center;
  margin: 5px 0 0;
}
.ofi-historical-timeline__about {
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0 0 0 3px;
  font: inherit;
  font-weight: 700;
  color: var(--ofi-color-text-primary, #2b3c32);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.ofi-historical-timeline__about:hover {
  color: var(--ofi-color-brand-orange);
  background: transparent;
}
/* Avoid repeating About the Data below the chart and in the page footer.
   In map fullscreen the footer is out of view, so keep the chart link there. */
.ofi-habitat-fires-page #range .ofi-historical-timeline__about {
  display: none;
}
.ofi-habitat-fires-page #range #ofi-orangutan-map:fullscreen .ofi-historical-timeline__about,
.ofi-habitat-fires-page #range #ofi-orangutan-map:-webkit-full-screen .ofi-historical-timeline__about,
.ofi-habitat-fires-page #range #ofi-orangutan-map.maplibregl-pseudo-fullscreen .ofi-historical-timeline__about {
  display: inline;
}
.ofi-historical-timeline button:focus-visible,
.ofi-historical-panel__tabs button:focus-visible,
.ofi-historical-panel__mode button:focus-visible {
  outline: 2px solid var(--ofi-color-brand-orange,#b96c3c);
  outline-offset: 2px;
}
@media (max-width: 700px) {
  .ofi-habitat-fires-page #ofi-orangutan-map .ofi-fire-layer-panel[open] {
    max-height: min(300px, calc(100dvh - 100px));
  }
  /* The mobile collapsed control is a single icon button. The preview
     panel's ID-specific desktop width must not override this state. */
  .ofi-habitat-fires-page #ofi-orangutan-map .ofi-fire-layer-panel:not([open]) {
    box-sizing: border-box;
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    height: 40px;
    overflow: hidden;
  }
  .ofi-habitat-fires-page #range .ofi-historical-timeline {
    width: calc(100% - 16px);
    padding: 9px 8px 10px;
    bottom: 8px;
  }
  /* On phones, expanded daily bars flow after the fixed-height map.
     A fullscreen map keeps the chart inside the map as an overlay. */
  .ofi-habitat-fires-page #range .ofi-historical-timeline.is-below-map {
    position: relative;
    inset: auto;
    top: auto;
    right: auto;
    left: auto;
    bottom: auto;
    transform: none;
    width: calc(100% - 16px);
    margin: 10px auto 0;
    z-index: 1;
  }
  /* In phone fullscreen, both elements live inside the map. Reserve the
     bottom strip for the map key and float the timeline above it. */
  .ofi-habitat-fires-page #range #ofi-orangutan-map:fullscreen .ofi-historical-timeline:not(.is-below-map),
  .ofi-habitat-fires-page #range #ofi-orangutan-map.maplibregl-pseudo-fullscreen .ofi-historical-timeline:not(.is-below-map) {
    bottom: 105px;
  }
  .ofi-historical-timeline__title strong {font-size:.7rem;}
  .ofi-historical-timeline__top-actions {gap: 5px;}
  .ofi-historical-timeline__quick {font-size:.6rem;}
  .ofi-historical-timeline__expand {font-size:.65rem;}
  .ofi-historical-timeline__title span {display:none;}
  .ofi-historical-timeline__months button {font-size:.62rem;min-height:35px;}
  .ofi-historical-timeline__note {font-size:.62rem;}
}


/* Timeline and action buttons retain the established orange hover and selected
   states; segmented navigation uses neutral grey/white styling instead. */
.ofi-habitat-fires-page #range .ofi-historical-timeline__months button:not(:disabled):hover,
.ofi-habitat-fires-page #range .ofi-historical-timeline__expand:not(:disabled):hover,
.ofi-habitat-fires-page #range .ofi-historical-timeline__window button:not(:disabled):hover,
.ofi-habitat-fires-page #range .ofi-historical-timeline__day:not(:disabled):hover {
  background:var(--ofi-color-brand-orange);
  border-color:var(--ofi-color-brand-orange);
  color:#fff;
}
.ofi-habitat-fires-page #range .ofi-historical-timeline__months button[aria-pressed="true"],
.ofi-habitat-fires-page #range .ofi-historical-timeline__day[aria-pressed="true"] {
  background:var(--ofi-color-brand-orange);
  border-color:var(--ofi-color-brand-orange);
  color:#fff;
}
.ofi-habitat-fires-page #range .ofi-historical-timeline__day[aria-pressed="true"] small,
.ofi-habitat-fires-page #range .ofi-historical-timeline__day:not(:disabled):hover small {color:#fff;}
.ofi-habitat-fires-page #range .ofi-historical-timeline__day[aria-pressed="true"] .ofi-historical-timeline__bar,
.ofi-habitat-fires-page #range .ofi-historical-timeline__day:not(:disabled):hover .ofi-historical-timeline__bar {
  background:#fff;
  opacity:1;
}
.ofi-historical-panel__export-note {
  margin:8px 0 0;
  color:var(--ofi-color-text-muted);
  font-size:.66rem;
  line-height:1.45;
}
.ofi-historical-panel__export-note[hidden] {display:none !important;}
.ofi-habitat-fires-page #ofi-orangutan-map .ofi-fire-layer-panel__action:disabled {
  opacity:.5;
  cursor:not-allowed;
}
@media (max-width:700px) {
  .ofi-historical-timeline__top {flex-wrap:wrap;}
  .ofi-historical-timeline__top-actions {margin-left:auto;flex-wrap:wrap;justify-content:flex-end;}
}

/* Neutral segmented navigation: selected = white, inactive = grey.
   Only inactive options react to hover. Explicit selected hover styling
   overrides any global button:hover rule without changing the selected state. */
.ofi-habitat-fires-page #ofi-orangutan-map .ofi-historical-panel__tabs button:not(:disabled):not([aria-selected="true"]):hover,
.ofi-habitat-fires-page #ofi-orangutan-map .ofi-historical-panel__mode button:not(:disabled):not([aria-pressed="true"]):hover {
  background: rgba(255,255,255,.6);
  color: var(--ofi-color-text-primary);
}
.ofi-habitat-fires-page #ofi-orangutan-map .ofi-historical-panel__tabs button[aria-selected="true"]:hover,
.ofi-habitat-fires-page #ofi-orangutan-map .ofi-historical-panel__mode button[aria-pressed="true"]:hover {
  background: #fff;
  color: var(--ofi-color-text-primary);
  border-color: transparent;
  box-shadow: 0 1px 4px rgba(0,0,0,.10);
}


/* The map legend is a direct child of the map, not part of the timeline.
   Keep it independent of chart open/close, including in MapLibre fullscreen.
   On narrower layouts move it below the native zoom/fullscreen controls so
   the wide chart cannot cover it. Never hide a map key when layers are shown. */
.ofi-habitat-fires-page #range #ofi-orangutan-map.ofi-history-active .ofi-map-note {
  top: auto;
  left: 14px;
  bottom: 14px;
  display: block;
}
@media (min-width: 701px) and (max-width: 1050px) {
  /* Only the desktop overlay needs to avoid the chart at the bottom.
     On phones the timeline is below the map, leaving room for its key. */
  .ofi-habitat-fires-page #range #ofi-orangutan-map.ofi-history-active .ofi-map-note {
    top: 142px;
    bottom: auto;
    left: 12px;
  }
}

/* One stable viewport for Live and Historical: the chart overlays the map
   without changing its height. Override the two-ID #range selector in
   main.css but leave MapLibre's native fullscreen sizing untouched. */
.ofi-habitat-fires-page #range #ofi-orangutan-map:not(:fullscreen):not(.maplibregl-pseudo-fullscreen) {
  height: 700px;
}
@media (max-width: 700px) {
  .ofi-habitat-fires-page #range #ofi-orangutan-map:not(:fullscreen):not(.maplibregl-pseudo-fullscreen) {
    height: 600px;
  }
}

.ofi-historical-archive .ofi-historical-timeline__months {
  align-items: end;
  gap: 4px;
}
.ofi-historical-archive .ofi-historical-timeline__months .ofi-history-month {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 65px;
  padding: 4px 0 5px;
}
.ofi-history-month__bar {
  display: block;
  width: clamp(6px, 42%, 30px);
  min-height: 2px;
  background: var(--ofi-color-brand-orange);
  border-radius: 2px 2px 0 0;
  opacity: .65;
}
.ofi-historical-archive .ofi-history-month.is-active .ofi-history-month__bar,
.ofi-historical-archive .ofi-history-month:not(:disabled):hover .ofi-history-month__bar {
  background: #fff;
  opacity: 1;
}
.ofi-historical-archive .ofi-historical-timeline__chart {
  display: flex;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  justify-content: flex-start;
  align-items: stretch;
  gap: 4px;
  height: 136px;
  padding: 4px 3px 8px;
  scrollbar-width: thin;
}
.ofi-historical-archive .ofi-historical-timeline__day {
  flex: 1 0 23px;
  min-width: 23px;
  max-width: 42px;
  padding: 2px 0;
}
.ofi-historical-archive .ofi-historical-timeline__count {font-size: .56rem;}
.ofi-historical-archive .ofi-historical-timeline__day small {font-size: .62rem;}
.ofi-historical-archive .ofi-historical-timeline__bar {width:70%;}
@media (max-width:700px) {
  .ofi-historical-archive .ofi-historical-timeline__months .ofi-history-month {
    height: 60px;
  }
  .ofi-historical-archive .ofi-historical-timeline__day {flex-basis: 25px;}
}

/* Optional desktop chart repositioning, especially useful in fullscreen.
   Drag only the header, never the month/day bars or chart controls. */
.ofi-historical-timeline__grip {display:none;}
@media (min-width: 701px) and (pointer: fine) {
  .ofi-habitat-fires-page #range .ofi-historical-timeline__top {
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
  }
  .ofi-habitat-fires-page #ofi-orangutan-map .ofi-historical-timeline.is-dragging .ofi-historical-timeline__top {
    cursor: grabbing;
  }
  .ofi-historical-timeline__grip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 12px;
    color: var(--ofi-color-text-muted, #647267);
  }
  .ofi-historical-timeline__grip svg { display: block; }
  .ofi-historical-timeline__title {align-items:center;}
  .ofi-habitat-fires-page #range .ofi-historical-timeline__top button {
    cursor:pointer;
    touch-action:manipulation;
  }
}
