/* Observable modifications */
:root {
  --observablehq-max-width: auto;

  --vertical-padding: 10vh;
  --inner-padding: 1rem;

  --nato-max-height: 90vh;

}

h1,
h2,
h3,
h4,
h5,
h6,
body {
  font-family: var(--sans-serif);
}

#observablehq-main p a[href] {
  text-decoration: underline;
}

#observablehq-sidebar {
  --observablehq-sidebar-padding-left: 0px;
}

#observablehq-toc {
  right: 2rem !important;
  top: 2rem !important;
  width: 180px !important;
}

.role-title-text > text {
  font-size: 20px;
}

.role-title-subtitle > text {
  font-size: 14px;
}

/* Base resets to prevent standard ObservableHQ layout overrides */
h1, h2, h3, p {
  max-width: 100%;
}

/* Breakout graphics */
.breakout {
  display: block;

  max-width: 100%;
  max-height: var(--nato-max-height);
}

.breakout .vis {
  display: block;
  margin-left: 10%;
  margin-right: auto;
}

.vis canvas,
.vis svg {
  width: auto;
  max-width: 100%;
  max-height: var(--nato-max-height);
  display: block;
}

/* Scrollytelling Component */
.scrolly {
  position: relative;
  display: grid;
  grid-template-columns: 3fr 1fr;
  padding: var(--inner-padding);
  gap: calc(2 * var(--inner-padding));
  max-width: none;
}

/* Scoped elements within Scrollytelling */
.scrolly article {
  position: relative;
  order: 2;
  max-width: none;
}

.scrolly figure {
  position: sticky;
  top: var(--vertical-padding);
  padding-top: var(--inner-padding);
  width: 100%;
  height: 80vh;
  margin: 0;
  order: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fdfdfd;
  border-radius: 8px;
  border: 1px solid #eee;
  z-index: 1;
  max-width: none;
}

.scrolly .step {
  height: auto;
  margin-bottom: calc(0.5 * var(--vertical-padding));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: white;
  padding: calc(8 * var(--inner-padding)) calc(2 * var(--inner-padding));
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);

  /* Highlight focused step */
  opacity: 0.3;
  transition: opacity 0.3s ease;
}

/* Highlight focused step */
.scrolly .step.is-active {
  opacity: 1;
}

/* Shared utility for visualization containers */
.title {
  font-weight: bold;
}

.vis {
  margin: auto;
}

/* Hide interactive controls */
.no-control .vega-bindings {
  display: none;
}

text {
  /*font-size: inherit;*/
  font-family: inherit;
}

/* Specific page sections */
.exploration-plot {
  margin-top: 4rem;
  padding: calc(2 * var(--inner-padding));
  border-top: 2px solid #eee;
}

/* Mobile Responsive Overrides */
@media screen and (max-width: 768px) {
  .scrolly {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0;
    margin: 0;
  }

  .scrolly article {
    z-index: 1;
    padding: 2rem 1rem;
    box-sizing: border-box;
  }

  .scrolly figure {
    top: 0;
    height: 40vh;
    z-index: 10;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid #eee;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
  }

  .scrolly .step {
    height: auto;
    min-height: 50vh;
    margin-bottom: 60vh;
    padding: 1.5rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  }
}

/* Note: We no longer need 'position: relative' here since the popup is fixed to the screen */
.footnote-ref {
  cursor: help;
  text-decoration: underline dotted; /* Optional: makes it clearer that it's interactive */
}

/* The actual tooltip popup */
.footnote-ref::after {
  content: attr(data-tooltip);

  /* Fix to the bottom-right of the viewport */
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999; /* Ensure it's above all charts and scrolly elements */

  /* Sizing */
  width: max-content;
  max-width: 350px; /* Max width for desktop readability */
  white-space: normal;

  /* Styling */
  background-color: #222;
  color: #fff;
  text-align: left;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.4;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);

  /* Smooth animation (fade and slide up) */
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;

  /* Prevent the popup itself from blocking mouse events */
  pointer-events: none;
}

/* Hide the old directional arrow */
.footnote-ref::before {
  display: none;
}

/* Show tooltip on hover */
.footnote-ref:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

@media screen and (max-width: 768px) {
  .footnote-ref::after {
    /* On small screens, center it at the bottom instead of the right corner */
    bottom: 16px;
    left: 16px;
    right: 16px;
    width: auto;
    max-width: none;

    /* Slightly smaller text for mobile */
    font-size: 0.85rem;
  }
}

/* Code for the radio buttons in the equipment chart */
.button-group {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.button-group input[type="radio"] {
  display: none; /* hide actual radio */
}

.button-group label {
  padding: 8px 14px;
  border: 1px solid #ccc;
  border-radius: 6px;
  cursor: pointer;
  background: #f5f5f5;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* hover */
.button-group label:hover {
  background: #e0e0e0;
}

/* selected state */
.button-group input[type="radio"]:checked + label {
  background: #333;
  color: white;
  border-color: #333;
}

.column {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
}

/* Hide the 2025 figure by default */
#expenditure-2025 {
  display: none;
}

/* Toggle chart visibility */
#toggle-year:checked ~ #expenditure-2024 {
  display: none;
}

#toggle-year:checked ~ #expenditure-2025 {
  display: block;
}

/* Hide native checkbox */
#toggle-year {
  display: none;
}

/* Pretty toggle button */
.toggle-label {
  display: inline-block;
  font-family: sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #333;

  background: #f5f5f5;
  border: 1px solid #d0d0d0;
  border-radius: 999px;

  padding: 10px 18px;
  margin-bottom: 14px;

  cursor: pointer;
  user-select: none;

  transition:
    background 0.25s ease,
    color 0.25s ease;
}

/* Hover effect */
.toggle-label:hover {
  background: #ced4da;
  color: black;
}

/* Active click effect */
.toggle-label:active {
  transform: scale(0.98);
}

/* Checked state */
#toggle-year:checked + .toggle-label {
  background: #1b365d;
  color: white;
}

/* Grid for exploration */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* Two columns */
  grid-template-rows: repeat(2, auto);    /* Two rows */
  gap: 2rem;
  width: 100%;
  max-width: 1200px;
}

#explore-introduction {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
}


