/* US Drought Monitor Clone — shared styles */

@import url('https://fonts.googleapis.com/css2?family=Lora:wght@500;600;700&family=Source+Sans+3:wght@400;500;600;700&display=swap');

:root {
  --usdm-red: #da3910;
  --usdm-red-dark: #b32d0a;
  --usdm-red-darker: #8a230a;
  --usdm-charcoal: #4d4847;
  --usdm-charcoal-light: #6b6664;
  --usdm-bg: #ffffff;
  --usdm-bg-tint: #faf9f8;
  --usdm-border: #e2dfdc;
  --usdm-text: #1f1d1c;
  --usdm-muted: #7a716c;
  --usdm-info-bg: #d4ecf2;
  --usdm-info-border: #b8dde6;
  --usdm-link: #b32d0a;

  /* USDM official intensity colors */
  --usdm-d0: #FFFF00;
  --usdm-d1: #FCD37F;
  --usdm-d2: #FFAA00;
  --usdm-d3: #E60000;
  --usdm-d4: #730000;
  --usdm-none: #ffffff;
  --usdm-nodata: #cccccc;

  --font-display: 'Lora', Georgia, 'Times New Roman', serif;
  --font-body: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --max-width: 1280px;
  --header-h: 64px;
  --nav-h: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  color: var(--usdm-text);
  background: var(--usdm-bg);
  line-height: 1.55;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--usdm-link);
  text-decoration: none;
  transition: color .15s ease;
}
a:hover { color: var(--usdm-red); text-decoration: underline; }

/* ============ HEADER ============ */
.usdm-header {
  background: var(--usdm-charcoal);
  color: #fff;
  height: var(--header-h);
  display: flex;
  align-items: center;
}
.usdm-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  width: 100%;
}
.usdm-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 24px;
  letter-spacing: -0.01em;
  color: #fff;
  margin: 0;
}
.usdm-title a { color: #fff; text-decoration: none; }
.usdm-title a:hover { color: #fff; text-decoration: none; opacity: 0.9; }

/* ============ NAV ============ */
.usdm-nav {
  background: var(--usdm-red);
  height: var(--nav-h);
}
.usdm-nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  scrollbar-width: none;
}
.usdm-nav-inner::-webkit-scrollbar { display: none; }
.usdm-nav a {
  color: #fff;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 16px;
  letter-spacing: 0.01em;
  padding: 0 18px;
  display: flex;
  align-items: center;
  text-decoration: none;
  transition: background .15s ease;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.usdm-nav a:hover {
  background: var(--usdm-red-dark);
  text-decoration: none;
  color: #fff;
}
.usdm-nav a.active {
  background: var(--usdm-red-dark);
  border-bottom-color: #fff;
  font-weight: 600;
}

/* ============ MAIN CONTAINER ============ */
.usdm-main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 24px 64px;
  min-height: calc(100vh - 64px - 56px - 240px);
}

/* ============ BREADCRUMBS ============ */
.usdm-breadcrumbs {
  font-size: 14px;
  color: var(--usdm-muted);
  margin-bottom: 8px;
}
.usdm-breadcrumbs a { color: var(--usdm-link); }
.usdm-breadcrumbs .sep { padding: 0 6px; color: var(--usdm-muted); }

/* ============ PAGE TITLE ============ */
.page-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 44px;
  margin: 0 0 28px;
  letter-spacing: -0.02em;
  color: var(--usdm-text);
}

.page-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  letter-spacing: -0.01em;
  margin: 32px 0 16px;
  color: var(--usdm-text);
}
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.005em;
  margin: 24px 0 10px;
  color: var(--usdm-red-darker);
}
h4 {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 18px;
  margin: 16px 0 8px;
}
p { margin: 0 0 14px; }

/* ============ DATE/RELEASE INFO ============ */
.release-block { margin-bottom: 12px; }
.release-block h2 {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.015em;
}
.release-block .data-valid {
  color: #9B9392;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  margin-top: 4px;
}

/* ============ MAP DISPLAY ============ */
.map-wrap {
  background: #fff;
  border: 1px solid var(--usdm-border);
  border-radius: 4px;
  padding: 16px;
  margin: 16px auto 24px;
  position: relative;
  max-width: 880px;
}
.map-img {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  height: auto;
  display: block;
  transition: filter .25s ease;
}
.map-img.grayscale { filter: grayscale(1); }

.map-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}
.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  cursor: pointer;
}
.checkbox-row input { accent-color: var(--usdm-red); cursor: pointer; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-block;
  background: var(--usdm-red);
  color: #fff;
  padding: 9px 18px;
  border-radius: 3px;
  font-size: 15px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, transform .05s ease;
  font-family: var(--font-body);
  margin: 0 8px 8px 0;
}
.btn:hover {
  background: var(--usdm-red-dark);
  color: #fff;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn.dropdown::after {
  content: "▾";
  margin-left: 6px;
  font-size: 12px;
}
.btn-group { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: #fff;
  border: 1px solid var(--usdm-border);
  border-radius: 3px;
  min-width: 200px;
  box-shadow: 0 6px 24px rgba(0,0,0,.12);
  display: none;
  z-index: 100;
  padding: 6px 0;
  margin-top: 4px;
}
.btn-group.open .dropdown-menu { display: block; }
.dropdown-menu a {
  display: block;
  padding: 8px 16px;
  color: var(--usdm-text);
  font-size: 15px;
}
.dropdown-menu a:hover { background: #f5f3f1; text-decoration: none; }

/* ============ INFO ALERT ============ */
.alert-info {
  background: var(--usdm-info-bg);
  border: 1px solid var(--usdm-info-border);
  border-radius: 4px;
  padding: 16px 18px;
  font-size: 15px;
  line-height: 1.55;
}
.alert-info b, .alert-info strong { font-weight: 700; }

/* ============ LEGEND ============ */
.legend-section { margin: 32px 0; }
.legend-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px 24px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
}
.legend-swatch {
  display: inline-block;
  width: 44px;
  height: 22px;
  border: 1px solid #aaa;
  flex-shrink: 0;
}
.legend-swatch.dnone { background: #fff; }
.legend-swatch.d0 { background: var(--usdm-d0); }
.legend-swatch.d1 { background: var(--usdm-d1); }
.legend-swatch.d2 { background: var(--usdm-d2); }
.legend-swatch.d3 { background: var(--usdm-d3); }
.legend-swatch.d4 { background: var(--usdm-d4); }
.legend-swatch.nodata { background: var(--usdm-nodata); }
.legend-item strong { font-weight: 700; }

.impact-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px 24px;
  margin-top: 18px;
  font-size: 15px;
}
.impact-item .imp-key {
  font-weight: 700;
  font-size: 17px;
  color: var(--usdm-text);
}
.impact-line {
  display: inline-block;
  width: 38px;
  height: 2px;
  background: #000;
  vertical-align: middle;
  margin-right: 4px;
}

/* ============ GRID LAYOUTS ============ */
.row { display: grid; gap: 32px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
  .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
  .legend-grid, .impact-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .legend-grid, .impact-grid { grid-template-columns: 1fr; }
  .page-title { font-size: 32px; }
  .release-block h2 { font-size: 24px; }
  .release-block .data-valid { font-size: 18px; }
}

/* ============ CARD GRID (Maps/Data landing) ============ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
  margin: 24px 0;
}
@media (max-width: 900px) {
  .card-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 580px) {
  .card-grid { grid-template-columns: 1fr; }
}
.card {
  background: #fff;
  border: 1px solid var(--usdm-border);
  border-radius: 6px;
  padding: 24px 22px;
  transition: box-shadow .2s ease, transform .15s ease, border-color .2s ease;
  display: flex;
  flex-direction: column;
}
.card:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,.07);
  border-color: #d0c8c2;
  transform: translateY(-2px);
}
.card .icon {
  font-size: 38px;
  color: var(--usdm-red);
  margin-bottom: 12px;
  line-height: 1;
}
.card h3 {
  font-family: var(--font-display);
  color: var(--usdm-red-darker);
  margin: 0 0 8px;
  font-size: 22px;
}
.card h3 a { color: var(--usdm-red-darker); }
.card h3 a:hover { color: var(--usdm-red); text-decoration: none; }
.card p {
  font-size: 15px;
  line-height: 1.55;
  color: #3a3431;
  margin: 0 0 16px;
  flex-grow: 1;
}
.card .card-link {
  margin-top: auto;
  font-size: 14px;
  font-weight: 600;
  color: var(--usdm-red);
}

/* ============ FORM CONTROLS ============ */
.form-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 16px 0 24px;
}
@media (max-width: 900px) { .form-row { grid-template-columns: 1fr; } }

.form-group {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--usdm-border);
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
}
.form-label {
  background: var(--usdm-red);
  color: #fff;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  display: flex;
  align-items: center;
}
.form-group select,
.form-group input[type="text"],
.form-group input[type="date"] {
  flex: 1;
  border: none;
  padding: 10px 14px;
  font-size: 15px;
  font-family: var(--font-body);
  background: #fff;
  color: var(--usdm-text);
  outline: none;
  min-width: 0;
}
.form-group select:focus,
.form-group input:focus { background: #faf9f8; }
.help-btn {
  background: var(--usdm-red);
  color: #fff;
  border: none;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
  font-size: 16px;
  border-left: 1px solid rgba(255,255,255,.3);
}
.help-btn:hover { background: var(--usdm-red-dark); }

/* ============ COMPARE GRID ============ */
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin: 16px 0 32px;
}
@media (max-width: 900px) { .compare-grid { grid-template-columns: 1fr; } }
.compare-grid .map-wrap { margin: 0; }
.compare-caption {
  text-align: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--usdm-text);
}

/* ============ TABLE ============ */
.usdm-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 32px;
  font-size: 15px;
}
.usdm-table th, .usdm-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--usdm-border);
}
.usdm-table th {
  background: #f5f3f1;
  font-weight: 700;
  color: var(--usdm-text);
}
.usdm-table tr:hover td { background: #faf9f8; }
.usdm-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* color stripes */
.swatch-cell {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  vertical-align: middle;
  border: 1px solid #aaa;
}

/* ============ AUTHORS BLOCK ============ */
.authors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin: 16px 0 24px;
  font-style: italic;
  font-size: 15.5px;
  line-height: 1.6;
}
@media (max-width: 900px) { .authors { grid-template-columns: 1fr; } }
.authors strong { font-weight: 700; font-style: normal; }
.authors a { font-weight: 600; }

/* ============ SUMMARY (regional narrative) ============ */
.summary-section h3 {
  font-family: var(--font-display);
  color: var(--usdm-red);
  font-size: 24px;
  margin-top: 36px;
  font-weight: 700;
}
.summary-section p {
  font-size: 16.5px;
  line-height: 1.7;
  color: #2a2624;
  max-width: 78ch;
}
.summary-section .lead {
  font-size: 17px;
  line-height: 1.7;
}

/* ============ TIME SERIES STATS BAR ============ */
.dsci-bar-wrap {
  background: #fff;
  border: 1px solid var(--usdm-border);
  border-radius: 6px;
  padding: 24px;
  margin: 16px 0;
}
.dsci-bar-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  margin-bottom: 16px;
  text-align: center;
}

/* ============ FOOTER ============ */
.usdm-footer {
  background: var(--usdm-charcoal);
  color: #c8c2bf;
  padding: 48px 0 36px;
}
.usdm-footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}
.partner-logos {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.partner-logos img {
  height: 56px;
  width: auto;
  background: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  object-fit: contain;
}
.partner-blurb {
  text-align: center;
  font-size: 15px;
  line-height: 1.6;
  max-width: 920px;
  margin: 0 auto 36px;
  color: #d4cfcc;
}
.contact-block {
  border-top: 1px solid #5e5856;
  padding-top: 32px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 32px;
}
@media (max-width: 900px) { .contact-block { grid-template-columns: 1fr; } }
.contact-block h3 {
  font-family: var(--font-display);
  font-weight: 600;
  color: #fff;
  font-size: 22px;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #5e5856;
}
.contact-block p, .contact-block li {
  margin: 0 0 6px;
  font-size: 14.5px;
  color: #d4cfcc;
}
.contact-block ul { list-style: none; padding: 0; margin: 0; }
.contact-block ul li { margin-bottom: 4px; }
.contact-block a { color: #ffd2c4; }
.contact-block a:hover { color: #fff; }
.contact-icon {
  display: inline-block;
  width: 18px;
  text-align: center;
  margin-right: 6px;
  opacity: .85;
}

.footer-copy {
  text-align: center;
  font-size: 13px;
  color: #a09995;
  margin-top: 32px;
  padding-top: 18px;
  border-top: 1px solid #5e5856;
}

/* ============ ANIMATION CONTROLS ============ */
.anim-stage {
  background: #fff;
  border: 1px solid var(--usdm-border);
  border-radius: 6px;
  padding: 24px;
  margin: 16px 0 24px;
  text-align: center;
}
.anim-stage img { max-width: 100%; height: auto; }
.anim-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.anim-controls button {
  background: var(--usdm-red);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 3px;
  font-size: 15px;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 500;
}
.anim-controls button:hover { background: var(--usdm-red-dark); }
.anim-controls input[type=range] {
  flex: 1;
  max-width: 360px;
  accent-color: var(--usdm-red);
}
.anim-date {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  min-width: 130px;
}

/* ============ COMPARISON SLIDER ============ */
.slider-stage {
  position: relative;
  width: 100%;
  max-width: 760px;
  margin: 16px auto 24px;
  user-select: none;
  background: #fff;
  border: 1px solid var(--usdm-border);
  border-radius: 6px;
  padding: 16px;
}
.slider-inner {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #fff;
}
.slider-inner > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}
.slider-inner .clip {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
  width: 50%;
}
/* image inside .clip must be sized to the FULL slider-inner, not the clip,
   so the visible portion matches the underneath full image pixel-for-pixel */
.slider-inner .clip > img {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  /* width of the slider-inner = width of the .clip / (clip width as % of inner) */
  /* simpler: use width:100vw fallback, but the cleanest way is JS-free with CSS calc */
  width: var(--slider-w, 728px);
  object-fit: contain;
  object-position: center;
  max-width: none;
}
.slider-handle {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 3px;
  background: var(--usdm-red);
  cursor: ew-resize;
  z-index: 5;
}
.slider-handle::after {
  content: "⇆";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--usdm-red);
  color: #fff;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.slider-label {
  position: absolute;
  top: 8px;
  background: rgba(255,255,255,.92);
  border: 1px solid var(--usdm-border);
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 3px;
  pointer-events: none;
}
.slider-label.left { left: 12px; }
.slider-label.right { right: 12px; }

/* ============ STATISTICS BAR CHART (inline SVG) ============ */
.stat-bar-row {
  display: grid;
  grid-template-columns: 100px 1fr 60px;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  font-size: 14.5px;
}
.stat-bar-track {
  background: #f5f3f1;
  height: 18px;
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}
.stat-bar-fill {
  height: 100%;
}
.stat-bar-row .stat-val {
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-weight: 600;
  color: var(--usdm-text);
}

/* ============ HOME PAGE INTRO BANNER ============ */
.intro-strip {
  background: linear-gradient(to right, #faf9f8 0%, #fff 100%);
  border-left: 4px solid var(--usdm-red);
  padding: 18px 22px;
  margin-bottom: 24px;
  font-size: 16px;
  line-height: 1.6;
  color: #2a2624;
}
.intro-strip strong { color: var(--usdm-red-darker); }

/* ============ MISC ============ */
.muted { color: var(--usdm-muted); }
.center { text-align: center; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
hr.soft {
  border: none;
  border-top: 1px solid var(--usdm-border);
  margin: 28px 0;
}
.tag {
  display: inline-block;
  padding: 3px 10px;
  background: #f5f3f1;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--usdm-charcoal);
  letter-spacing: .02em;
  text-transform: uppercase;
}

/* =============================================================================
 * MOBILE FRIENDLINESS (consolidated)
 * ========================================================================== */

/* Never let anything cause a horizontal scrollbar on the page. */
html, body { max-width: 100%; overflow-x: hidden; }
img, svg, canvas, iframe, table { max-width: 100%; }

/* Tablet / small laptop */
@media (max-width: 900px) {
  :root { --nav-h: 50px; }
  .usdm-main { padding-left: 16px; padding-right: 16px; }
  .usdm-nav a { font-size: 15px; padding: 0 14px; }
  .usdm-title { font-size: 22px; }
  /* let map toolbars wrap instead of overflowing */
  .idm-toolbar, .hydro-toolbar, .idm-summary-controls { flex-wrap: wrap; }
  /* the side rail drops below the map on narrow screens */
  .idm-viewer-grid { grid-template-columns: 1fr; }
}

/* Phones */
@media (max-width: 600px) {
  .usdm-header-inner { padding: 0 16px; }
  .usdm-title { font-size: 20px; }
  .usdm-nav-inner { padding: 0 12px; }
  .usdm-nav a { font-size: 14px; padding: 0 12px; }
  .page-title { font-size: 28px; }

  /* generic content tables scroll horizontally inside their own box */
  .table-wrap, .idm-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { font-size: 13px; }

  /* map control panels: full-width, comfortable tap targets */
  .idm-tool-group, .idm-summary-controls .idm-tool-group { width: 100%; }
  .idm-tool-group select, .idm-summary-controls select, .hydro-toolbar select { width: 100%; min-width: 0; }
  .idm-btn { padding: 9px 12px; }

  /* footer columns stack */
  .contact-block { grid-template-columns: 1fr !important; gap: 18px; }
  .partner-logos { gap: 18px; flex-wrap: wrap; justify-content: center; }

  /* chatbot becomes a near-full-screen sheet */
  .idm-chat-panel {
    right: 0; bottom: 0; width: 100vw; max-width: 100vw;
    height: 88vh; max-height: 88vh; border-radius: 14px 14px 0 0;
  }
  .idm-chat-launch { right: 14px; bottom: 14px; }
}

/* Honour users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
