:root {
  --accent-color: #7ea253;
}

html, body {
  overflow-x: hidden;
}

/* Match Outages typography (Inter) so weight/line metrics are identical */
body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background-color: #f0f2f5;
  margin: 0;
  color: #333;
}

main {
  margin: 0 auto;
  width: 90%;
  max-width: 1600px;
}

/* =========================
   BASE TABLE STYLES (DESKTOP)
   ========================= */
table {
  width: 100%;
  border-collapse: collapse;
  background-color: #fff;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
  max-width: 100%;
}

th, td {
  padding: 12px 16px;
  border-bottom: 1px solid #ddd;
  text-align: left;
}

th {
  background-color: #f1f1f1;
  font-weight: 600;
}

.site-name {
  font-weight: 600;
  font-size: inherit;
}

/* =========================
   DESKTOP “FEEL” POLISH (minimal)
   - adds hover feedback without changing layout
   ========================= */
.usgs-table tbody tr:hover,
.nwps-table tbody tr:hover {
  background: rgba(0,0,0,0.02);
}

/* Keep your flood tint rows, but still let hover “win” slightly */
.nwps-table tbody tr.row-action:hover    { background: rgba(255, 244, 194, 0.55); }
.nwps-table tbody tr.row-minor:hover     { background: rgba(255, 226, 196, 0.55); }
.nwps-table tbody tr.row-moderate:hover  { background: rgba(255, 208, 208, 0.55); }
.nwps-table tbody tr.row-major:hover     { background: rgba(228, 220, 255, 0.55); }

/* Clickable row affordance (desktop) */
.nwps-clickable {
  cursor: pointer;
}

/* Keyboard focus visibility for accessibility + “polished” feel */
.nwps-clickable:focus,
.nwps-clickable:focus-within {
  outline: 2px solid rgba(126, 162, 83, 0.55);
  outline-offset: -2px;
}

/* =========================
   HEADER
   ========================= */
.site-header {
  background-color: #7ea253;
}

.site-header .header-inner {
  width: 100%;
  margin: 0 auto;
  padding: 10px 16px;
  min-height: 64px;
  position: relative;
  display: flex;
  align-items: center;
}

/* Brand left */
.site-header .brand {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  text-decoration: none;
}

/* Header logo (not footer) */
.site-header .logo {
  height: 40px;
  width: auto;
  display: block;
  object-fit: contain;
  max-height: none;
  max-width: none;
}

/* Title block centered */
.site-header .header-text {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  line-height: 1.15;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.site-header .site-title {
  color: #fff;
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  margin: 0 8px 2px;
}

.site-header .site-link a {
  color: #cce8c1;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  opacity: 0.95;
}

.site-header .site-link a:hover {
  text-decoration: underline;
  opacity: 1;
}

/* Right slot */
.site-header .header-right {
  margin-left: auto;
  min-width: 40px;
}

@media (max-width: 720px) {
  .site-header .header-inner {
    flex-direction: column;
    align-items: center;
    padding: 10px 12px;
    min-height: unset;
  }
  .site-header .brand { justify-content: center; margin-bottom: 6px; }
  .site-header .logo { height: 34px; }
  .site-header .header-text { position: static; transform: none; margin-top: 0; text-align: center; }
  .site-header .site-title { font-size: 1.15rem; }
  .site-header .site-link a { font-size: 0.9rem; }
  .site-header .header-right { display: none; }
}

/* =========================
   FOOTER
   ========================= */
.footer {
  margin-top: 40px;
  text-align: center;
  font-size: 0.9em;
  color: #777;
  padding-bottom: 30px;
}

.logos {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 40px;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* Footer logos sized explicitly (header logo is separate) */
.footer-logo {
  max-height: 60px;
  max-width: 200px;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* =========================
   Markdown/CSV buttons
   ========================= */
.corner-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 32px;
  margin-bottom: 10px;
}

.corner-btn {
  font-size: 12px;
  background: #fff;
  color: #333;
  border-radius: 7px;
  padding: 4px 12px;
  opacity: 0.85;
  text-decoration: none;
  border: 1px solid #7ea253;
  box-shadow: 0 2px 8px #0001;
  transition: opacity 0.2s, background 0.2s;
  margin: 0;
  cursor: pointer;
  display: inline-block;
  line-height: 1.6;
  font-family: inherit;
  text-align: center;
}

.corner-btn:hover {
  opacity: 1;
  background: #f0ffe5;
}

/* =========================
   MODAL
   ========================= */
#markdown-modal {
  display: none;
  position: fixed;
  right: 18px;
  bottom: 38px;
  background: #fff;
  border: 1.5px solid #a1c285;
  border-radius: 10px;
  box-shadow: 0 6px 24px #0003;
  z-index: 10001;
  max-width: 440px;
  max-height: 70vh;
  padding: 22px 18px 18px 18px;
  overflow: auto;
}

#markdown-modal h3 {
  margin: 0 0 12px 0;
  color: #7ea253;
  font-size: 1.18em;
}

#markdown-modal pre {
  background: #fafdf8;
  border-radius: 6px;
  padding: 10px;
  font-size: 0.97em;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid #e0e9d8;
}

#close-markdown {
  position: absolute;
  top: 7px;
  right: 13px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #888;
  opacity: 0.8;
  transition: opacity 0.2s;
}

#close-markdown:hover {
  color: #d04;
  opacity: 1;
}

/* =========================
   NWPS SECTION + LEGEND
   ========================= */
.section-title {
  margin: 26px 0 10px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #2f3a2b;
  text-align: left;
}

.flood-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px 0;
}

/* ---- Flood category badges ---- */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  border: 1px solid rgba(0,0,0,0.12);
}

.badge-unknown {
  background: #e5e7eb;
  color: #111827;
}

.badge-no_flooding,
.badge-normal {
  background: #e7f5e5;
  color: #1e4620;
  border-color: rgba(30,70,32,0.18);
}

.badge-action {
  background: #fff4c2;
  color: #6a4a00;
  border-color: rgba(106,74,0,0.18);
}

.badge-minor {
  background: #ffe2c4;
  color: #7a2e00;
  border-color: rgba(122,46,0,0.18);
}

.badge-moderate {
  background: #ffd0d0;
  color: #7a0f0f;
  border-color: rgba(122,15,15,0.18);
}

.badge-major {
  background: #e4dcff;
  color: #3e1b8a;
  border-color: rgba(62,27,138,0.18);
}

/* Subtle row tint to match badge */
.row-action    { background: rgba(255, 244, 194, 0.35); }
.row-minor     { background: rgba(255, 226, 196, 0.35); }
.row-moderate  { background: rgba(255, 208, 208, 0.35); }
.row-major     { background: rgba(228, 220, 255, 0.35); }

.flood-footnote {
  font-size: 12px;
  color: #666;
  margin-top: 8px;
}

.nwps-title {
  font-size: 15px;
  font-weight: 800;
  margin: 0;
}

.nwps-sub {
  font-size: 12px;
  color: #666;
  margin-top: 4px;
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* =========================
   OPTIONAL: “Current + Forecast” stacked badges
   (No visual change unless you add a 2nd badge in HTML)
   ========================= */
.badge-stack {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}
.badge-label {
  font-size: 11px;
  font-weight: 700;
  color: #666;
  margin-right: 6px;
}

/* =========================
   MOBILE (600px minor tweaks)
   ========================= */
@media (max-width: 600px) {
  main { width: 95%; }

  #markdown-modal {
    max-width: 97vw;
    left: 1vw;
    right: 1vw;
    bottom: 58px;
    font-size: 0.96em;
    padding: 16px 8px 16px 10px;
  }

  .corner-buttons {
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 18px;
    margin-top: 18px;
  }

  .corner-btn {
    font-size: 15px;
    padding: 11px 18px;
    opacity: 1;
    margin: 0 2px;
    box-shadow: 0 2px 8px #0002;
    text-align: center;
    width: 100%;
  }
}

/* =========================
   MOBILE TABLES (<=720px)
   IMPORTANT:
   - USGS table becomes cards
   - NWPS table becomes cards with Gauge as a header
   ========================= */
@media (max-width: 720px) {
  /* ---------- USGS cards (ONLY .usgs-table) ---------- */
  table.usgs-table {
    border-collapse: separate;
    border-spacing: 0 12px;
    background: transparent;
    box-shadow: none;
  }

  table.usgs-table thead {
    display: none;
  }

  table.usgs-table tbody tr {
    display: block;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    overflow: hidden;
    margin-bottom: 12px;
    max-width: 100%;
  }

  table.usgs-table tbody td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid #eee;
    text-align: right;
    font-size: 14px;
    width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  table.usgs-table tbody td:last-child {
    border-bottom: none;
  }

  table.usgs-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #555;
    text-align: left;
    flex: 1 1 auto;
    min-width: 0;
    padding-right: 10px;
  }

  table.usgs-table tbody td > * {
    flex: 0 0 auto;
    text-align: right;
    max-width: 70%;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  table.usgs-table td.site-name,
  table.usgs-table .site-name {
    font-size: 15px;
    font-weight: 700;
  }

  /* ---------- NWPS cards (ONLY .nwps-table) ---------- */
  table.nwps-table {
    border-collapse: separate;
    border-spacing: 0 12px;
    background: transparent;
    box-shadow: none;
  }

  table.nwps-table thead {
    display: none;
  }

  table.nwps-table tbody tr {
    display: block;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    overflow: hidden;
    margin-bottom: 12px;
    max-width: 100%;
  }

  /* Gauge cell becomes the card header */
  table.nwps-table tbody td.nwps-gauge {
    display: block;
    padding: 12px 14px;
    border-bottom: 1px solid #eee;
    text-align: left;
    width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  table.nwps-table tbody td.nwps-gauge::before {
    display: none;
    content: none;
  }

  table.nwps-table tbody td.nwps-gauge .nwps-title {
    font-size: 15px;
    font-weight: 800;
    line-height: 1.2;
  }

  table.nwps-table tbody td.nwps-gauge .nwps-sub {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
  }

  /* All other NWPS fields become label/value rows */
  table.nwps-table tbody td:not(.nwps-gauge) {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  table.nwps-table tbody td:not(.nwps-gauge)::before {
    content: attr(data-label);
    font-weight: 600;
    color: #555;
    text-align: left;
    flex: 1 1 auto;
    min-width: 0;
    padding-right: 10px;
  }

  table.nwps-table tbody td:not(.nwps-gauge) > * {
    flex: 0 0 auto;
    text-align: right;
    max-width: 70%;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  table.nwps-table tbody td:last-child {
    border-bottom: none;
  }

  table.nwps-table .badge {
    font-size: 13px;
    padding: 6px 12px;
    max-width: 70%;
    white-space: normal;
    text-align: right;
  }

  /* Make padding count inside width everywhere */
  table.usgs-table, table.nwps-table,
  table.usgs-table * , table.nwps-table * {
    box-sizing: border-box;
  }
}

/* -----------------------------
   SEO INTRO + FAQ
   ONLY affects .seo-intro and .seo-faq
   ----------------------------- */

.seo-intro,
.seo-faq {
  box-sizing: border-box;   /* KEY FIX */
  width: 100%;
  max-width: 100%;
  margin: 18px 0;
  padding: 16px 18px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 12px;
  box-shadow: 0 0 10px rgba(0,0,0,0.10);
  color: #333;
}

/* Make sure children can’t force overflow */
.seo-intro *,
.seo-faq * {
  box-sizing: border-box;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.seo-intro h1 {
  margin: 0 0 10px 0;
  font-size: 1.28rem;
  line-height: 1.2;
  font-weight: 800;
  color: #2f3a2b;
}

.seo-intro p {
  margin: 0 0 10px 0;
  line-height: 1.6;
  color: #444;
}

.seo-intro p:last-child {
  margin-bottom: 0;
}

.seo-faq h2 {
  margin: 0 0 12px 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: #2f3a2b;
}

.seo-faq h3 {
  margin: 14px 0 6px 0;
  font-size: 0.98rem;
  font-weight: 800;
  color: #2f3a2b;
}

.seo-faq p {
  margin: 0 0 10px 0;
  line-height: 1.6;
  color: #444;
}

.seo-faq h3:not(:first-of-type) {
  padding-top: 12px;
  border-top: 1px solid #eee;
}

@media (max-width: 720px) {
  .seo-intro,
  .seo-faq {
    margin: 14px 0;
    padding: 14px 14px;     /* slightly tighter helps too */
    border-radius: 12px;
  }

  .seo-intro h1 { font-size: 1.15rem; }

  .seo-intro p,
  .seo-faq p { font-size: 0.95rem; }
}

#nwps-debug-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 9999;
}
#nwps-debug-modal .box {
  width: min(980px, 96vw);
  max-height: 88vh;
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(0,0,0,0.25);
  padding: 14px 16px;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}
#nwps-debug-modal .top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
#nwps-debug-modal .title {
  font-weight: 700;
  font-size: 16px;
}
#nwps-debug-modal .close {
  border: 0;
  background: transparent;
  font-size: 26px;
  cursor: pointer;
  line-height: 1;
}
#nwps-debug-modal pre {
  background: #f6f7f9;
  border: 1px solid #e4e7ee;
  border-radius: 10px;
  padding: 10px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}

/* =========================
   STATUS LINES (DROP-IN REPLACEMENT)
   - desktop aligned
   - mobile-safe (no clipping)
   ========================= */

/* Desktop / default */
.status-line{
  display: grid;
  grid-template-columns: 56px minmax(96px, 120px) minmax(0, 1fr); /* label | pill | remainder */
  align-items: center;
  column-gap: 8px;
  margin: 2px 0;
}

/* Label column */
.status-k{
  font-weight: 700;
  font-size: 12px;
  color: #666;
  text-align: left;
}

/* Pill column:
   - don't force a hard width on small screens
   - keep centered text */
.status-line .badge{
  width: 100%;
  max-width: 120px;       /* desktop cap */
  justify-self: start;
  text-align: center;
  white-space: nowrap;
}

/* Optional value column */
.status-v{
  font-weight: 700;
  font-size: 12px;
  color: #333;
  text-align: right;
  justify-self: end;
  white-space: nowrap;
}

/* Time line stays right-aligned */
.status-time{
  font-size: 11px;
  color: #777;
  margin-top: 4px;
  text-align: right;
  overflow-wrap: anywhere;
}

/* -------------------------
   MOBILE CARD FIXES
   - prevents right-side clipping in NWPS "cards"
   ------------------------- */
@media (max-width: 720px) {
  /* In your mobile cards you have:
     table.nwps-table tbody td:not(.nwps-gauge) > * { max-width: 70%; }
     That breaks status rows. Override ONLY for the Status cell. */
  table.nwps-table tbody td[data-label="Status"] > *{
    max-width: 100% !important;
    width: 100%;
  }

  /* Also remove clipping just for the Status cell */
  table.nwps-table tbody td[data-label="Status"]{
    overflow: visible;
  }

  /* Make the status grid shrink-friendly */
  .status-line{
    grid-template-columns: 44px minmax(0, 1fr);  /* label | pill */
    column-gap: 10px;
  }

  /* Badge can shrink now without pushing off-screen */
  .status-line .badge{
    max-width: none;
    width: auto;
    justify-self: end;
  }

  /* If a value exists, put it on its own line (won't clip) */
  .status-v{
    grid-column: 2 / -1;
    justify-self: end;
    margin-top: 2px;
  }
}

/* =========================
   MOBILE FIX: Status cell layout
   - stack Now + Forecast cleanly
   - no overlap, no missing pills
   ========================= */
@media (max-width: 720px) {

  /* The generic mobile card rule makes every td a flex row.
     Override ONLY the Status td so it can contain multiple lines. */
  table.nwps-table tbody td[data-label="Status"]{
    display: block !important;          /* stop the "label/value" flex row */
    padding: 12px 14px;
  }

  /* Kill the injected "Status" label on the left for this cell */
  table.nwps-table tbody td[data-label="Status"]::before{
    display: none !important;
    content: none !important;
  }

  /* If your Status cell contains multiple .status-line rows, stack them */
  table.nwps-table tbody td[data-label="Status"] .status-line{
    display: grid;
    grid-template-columns: 56px 1fr;    /* Now/Forecast label | pill */
    align-items: center;
    gap: 10px;
    justify-content: start;
    margin: 6px 0;
  }

  table.nwps-table tbody td[data-label="Status"] .status-k{
    min-width: 0 !important;
    text-align: left;
  }

  table.nwps-table tbody td[data-label="Status"] .badge{
    justify-self: end;
    width: auto;
    max-width: 100%;
    white-space: nowrap;
  }

  /* If you still have .status-v present in HTML, keep it from clipping */
  table.nwps-table tbody td[data-label="Status"] .status-v{
    grid-column: 2 / -1;
    justify-self: end;
    margin-top: 2px;
    min-width: 0 !important;
    white-space: nowrap;
  }

  table.nwps-table tbody td[data-label="Status"] .status-time{
    margin-top: 6px;
    text-align: right;
  }
}


