/* SPDX-FileCopyrightText: 2025 Caspar Water Company */
/*                                                      */
/* SPDX-License-Identifier: Apache-2.0                  */

/* Watertown sitegen -- light ocean/meadow theme */

:root {
  --sidebar-width: 260px;
  --max-width: 960px;

  /* Spacing: shared inset keeps sidebar and content top-aligned */
  --page-inset: 2.5rem;

  /* Radii: shared between nav buttons, cards, and containers */
  --radius: 8px;
  --radius-sm: 4px;

  /* Palette: ocean blue + coastal green */
  --accent: #0c4a6e;
  --accent-light: #0284c7;
  --accent-wash: #e0f2fe;
  --green: #059669;
  --green-wash: #ecfdf5;

  /* Health palette for the pond status grid (selfmon).  Reuses the
     existing green so a healthy card matches the rest of the theme;
     yellow/red are added here as semantic aliases.  Sites can
     override these via the `theme:` map in site.yaml. */
  --status-green: var(--green);
  --status-green-wash: var(--green-wash);
  --status-yellow: #d97706;
  --status-yellow-wash: #fef3c7;
  --status-red: #dc2626;
  --status-red-wash: #fee2e2;
  --status-unknown: #94a3b8;
  --status-unknown-wash: #f1f5f9;

  /* Sidebar nav buttons */
  --nav-btn: rgba(50, 250, 200, 0.965);
  --nav-btn-hover: rgba(224, 224, 224, 0.965);
  --nav-btn-active: rgba(140, 130, 120, 0.9);
  --nav-sub-btn: rgba(50, 250, 200, 0.55);
  --nav-sub-btn-hover: rgba(200, 200, 200, 0.8);
  --nav-sub-btn-active: rgba(160, 150, 140, 0.85);
  /* Border for sub-nav buttons.  Default transparent so themes that don't
     opt in keep solid-fill sub-tabs; set a color to get outline-style tabs. */
  --nav-sub-btn-border: transparent;

  /* Surfaces */
  --bg: #f7f6f3;
  --bg-sidebar: #f0f7ff;
  --bg-card: #f8fafc;
  --bg-hover: #f1f5f9;

  /* Text */
  --fg: #1e293b;
  --fg-secondary: #475569;
  --fg-muted: #94a3b8;

  /* Borders */
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);

  /* Type */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Spline Sans Mono", ui-monospace, Menlo, Consolas, monospace;
}

/* ── Reset ──────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html {
  font: 16px/1.7 var(--font-sans);
  background: var(--bg);
  background-image: var(--bg-image, none);
  background-repeat: repeat;
  background-size: 1500px auto;
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0; padding: 0;
}

body {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
}

/* Two-column layout only when a sidebar nav is actually present.
   Without this, pages with no sidebar get their <main> placed in
   the narrow sidebar column instead of spanning the full width. */
body:has(> .sidebar) {
  grid-template-columns: var(--sidebar-width) 1fr;
}

a { color: var(--accent-light); }
a:hover { color: var(--accent); }

/* ── Sidebar ────────────────────────────────────────────────── */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: transparent;
  padding: var(--page-inset) 1.25rem;
  overflow-y: auto;
  z-index: 100;
}

.sidebar h2 {
  font-size: 1rem;
  font-weight: 700;
  padding: 0 0.5rem;
  margin: 0 0 1rem;
  color: var(--accent);
  letter-spacing: -0.01em;
}

.sidebar h2 a {
  color: inherit;
  text-decoration: none;
}

.sidebar h3 {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  padding: 0.75rem 0.5rem 0.35rem;
  margin: 0;
}

.sidebar ul {
  list-style: none;
  margin: 0; padding: 0;
}

.sidebar li {
  margin-bottom: 6px;
}

.sidebar a {
  display: block;
  padding: 0.75rem 1rem;
  background: var(--nav-btn);
  color: var(--fg);
  text-decoration: none;
  font-size: 1.3rem;
  font-weight: 400;
  border-radius: var(--radius);
  transition: background 0.2s;
}

.sidebar a:hover {
  background: var(--nav-btn-hover);
}

.sidebar li.active > a {
  background: var(--nav-btn-active);
  color: #ffffff;
  font-weight: 700;
}

/* Section heading (parent for grouped sub-navigation) */
.sidebar .nav-heading {
  display: block;
  padding: 0.75rem 1rem;
  background: var(--nav-btn);
  color: var(--fg);
  text-decoration: none;
  font-size: 1.3rem;
  font-weight: 400;
  border-radius: var(--radius);
  transition: background 0.2s;
}

.sidebar .nav-heading:hover {
  background: var(--nav-btn-hover);
}

.sidebar li.active > .nav-heading {
  background: var(--nav-btn-active);
  color: #ffffff;
  font-weight: 700;
}

/* ── Sub-navigation (nested under sidebar entries) ─────────── */

.sidebar .subnav {
  display: none;
  /* Inset from the left so sub-tabs are slightly narrower than their parent
     and share its right edge (right-justified), reinforcing the hierarchy. */
  margin: 4px 0 0 0.9rem;
  padding: 0;
}

.sidebar .subnav.expanded {
  display: block;
}

.sidebar .subnav li {
  margin-bottom: 3px;
}

.sidebar .subnav a {
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem 0.4rem 1.25rem;
  background: var(--nav-sub-btn);
  border: 1px solid var(--nav-sub-btn-border);
  border-radius: var(--radius-sm);
}

.sidebar .subnav a:hover {
  background: var(--nav-sub-btn-hover);
}

.sidebar .subnav li.active > a {
  background: var(--nav-sub-btn-active);
  border-color: var(--nav-sub-btn-active);
  color: #ffffff;
  font-weight: 600;
}

/* ── Nav sections (collapsible) ─────────────────────────────── */

.nav-section > ul { display: none; }
.nav-section.expanded > ul { display: block; }

.nav-section-title {
  cursor: pointer;
  user-select: none;
}

.nav-list {
  list-style: none;
  margin: 0; padding: 0;
}

/* ── Main content ───────────────────────────────────────────── */

main {
  min-width: 0;
  padding: var(--page-inset) 3rem;
  max-width: calc(var(--max-width) + 6rem);
  background: transparent;
}

main h1 {
  margin: 0 0 0.25rem;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--accent);
}

main h2 {
  margin: 2rem 0 0.75rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.015em;
}

main h3 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--fg);
}

/* ── Content page typography ────────────────────────────────── */

.content-page article {
  max-width: var(--max-width);
}

.content-page p {
  margin: 0.75rem 0;
  line-height: 1.75;
  color: var(--fg-secondary);
}

.content-page ul, .content-page ol {
  margin: 0.75rem 0;
  padding-left: 1.5rem;
  color: var(--fg-secondary);
}

.content-page li {
  margin: 0.25rem 0;
  line-height: 1.7;
}

.content-page blockquote {
  margin: 1.5rem 0;
  padding: 0.75rem 1.25rem;
  border-left: 3px solid var(--accent-light);
  background: var(--accent-wash);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--fg-secondary);
}

.content-page blockquote p {
  margin: 0;
}

.content-page img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  margin: 1rem 0;
}

.content-page code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-card);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  color: var(--accent);
}

.content-page pre {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.6;
}

.content-page pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

.content-page .equation {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1rem 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.6;
  text-align: center;
}

.content-page .equation sub,
.content-page .equation sup {
  font-size: 0.7em;
}

.content-page hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* ── Tables ─────────────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
}

th {
  text-align: left;
  font-weight: 600;
  color: var(--fg);
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--border);
}

td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--fg-secondary);
}

tr:hover td {
  background: var(--bg-card);
}

/* ── Breadcrumb ─────────────────────────────────────────────── */

.breadcrumb ol {
  list-style: none;
  display: flex;
  gap: 0.25rem;
  padding: 0; margin: 0 0 1.5rem;
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.breadcrumb li + li::before {
  content: "/";
  margin-right: 0.25rem;
  color: var(--border);
}

.breadcrumb a {
  color: var(--accent-light);
  text-decoration: none;
}

.breadcrumb a:hover { text-decoration: underline; }

.breadcrumb .active {
  color: var(--fg);
  font-weight: 500;
}

/* ── Duration buttons ───────────────────────────────────────── */

.chart-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.duration-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.duration-buttons button {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.15s;
}

.duration-buttons button:hover {
  background: var(--bg-hover);
  border-color: var(--accent-light);
  color: var(--fg);
}

.duration-buttons button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.reset-zoom,
.reload-data {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--accent-light);
  background: transparent;
  color: var(--accent-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.15s;
}

.reset-zoom:hover:not(:disabled),
.reload-data:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.reset-zoom:disabled {
  opacity: 0.3;
  cursor: default;
  border-color: var(--border);
  color: var(--fg-muted);
}

.overlay-tracks {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--fg-secondary);
}

.overlay-tracks-label {
  font-weight: 600;
  color: var(--fg-muted);
}

.overlay-track {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  user-select: none;
}

.overlay-track input {
  cursor: pointer;
}

/* ── Window readout / editor + shareable link ───────────────── */

.window-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  font-size: 0.8rem;
}

.window-bar .window-label {
  font-weight: 600;
  color: var(--fg-secondary);
}

.window-bar .window-arrow {
  color: var(--fg-muted);
}

.window-input {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-family: inherit;
}

.window-input:focus {
  outline: none;
  border-color: var(--accent-light);
}

.copy-link {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--accent-light);
  background: transparent;
  color: var(--accent-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.15s;
}

.copy-link:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.copy-link.copied {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.download-csv,
.explore-data {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--accent-light);
  background: transparent;
  color: var(--accent-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.15s;
}

.download-csv:hover:not(:disabled),
.explore-data:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.download-csv:disabled,
.explore-data:disabled {
  opacity: 0.3;
  cursor: default;
  border-color: var(--border);
  color: var(--fg-muted);
}

/* ── Brush-to-zoom overlay ──────────────────────────────────── */

.brush-overlay {
  position: absolute;
  top: 0;
  height: 100%;
  cursor: crosshair;
  z-index: 10;
}

.brush-rect {
  display: none;
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(2, 132, 199, 0.12);
  border-left: 1px solid var(--accent-light);
  border-right: 1px solid var(--accent-light);
  pointer-events: none;
}

.crosshair-line {
  position: absolute;
  top: 0;
  height: 100%;
  width: 1px;
  background: var(--accent-light);
  pointer-events: none;
  z-index: 11;
}

.chart-tooltip {
  position: absolute;
  z-index: 12;
  pointer-events: none;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
  padding: 6px 8px;
  font-size: 0.78rem;
  line-height: 1.4;
  min-width: 110px;
  max-width: 260px;
}

.chart-tooltip .tt-time {
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--fg-muted);
  margin-bottom: 4px;
  white-space: nowrap;
}

.chart-tooltip .tt-row {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.chart-tooltip .tt-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.chart-tooltip .tt-label {
  color: var(--fg-muted);
  margin-right: auto;
}

.chart-tooltip .tt-val {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* Highlighted marker at the exact hovered intersection point on a line. */
.hover-dot {
  position: absolute;
  z-index: 11;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid;
  pointer-events: none;
  box-shadow: var(--shadow-sm);
}

/* ── Charts ─────────────────────────────────────────────────── */

.chart-container {
  margin-bottom: 2rem;
  background: #f3f4f6;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  min-height: 200px;
}

.chart-container svg {
  width: 100%;
  height: auto;
}

.empty-state {
  padding: 2rem;
  text-align: center;
  background: var(--accent-wash);
  border-radius: var(--radius);
  margin: 1rem 0;
  color: var(--fg-muted);
  font-size: 0.9rem;
}

/* ── Map (Leaflet) ──────────────────────────────────────────── */

#map {
  width: 100%;
  z-index: 0;
}

/* ── Blog grid ──────────────────────────────────────────────── */

.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0;
}

.blog-card {
  display: flex;
  flex-direction: column;
  background: var(--accent-wash);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
  box-shadow: var(--shadow-sm);
}

.blog-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent-light);
  transform: translateY(-2px);
  color: inherit;
}

.blog-card-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-card);
}

.blog-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.blog-card:hover .blog-card-image img {
  transform: scale(1.03);
}

.blog-card-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.blog-card-date {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent-light);
  letter-spacing: 0.02em;
}

.blog-card-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--fg);
  letter-spacing: -0.01em;
}

.blog-card-summary {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--fg-secondary);
}

/* ── Top bar (back link + icons, above card) ────────────────── */

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.top-bar-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent-light);
  text-decoration: none;
  transition: color 0.15s;
}

.top-bar-back:hover {
  color: var(--accent);
}

.blog-back-arrow {
  font-size: 1.1rem;
  line-height: 1;
}

.top-bar-icons {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.top-bar-icons a {
  color: var(--fg-muted);
  transition: color 0.15s;
  display: flex;
  align-items: center;
}

.top-bar-icons a:hover {
  color: var(--accent);
}

/* ── Full-screen chart toggle + overlay ─────────────────────── */

/* Link-styled button sitting just right of the back link; margin-right:auto
   keeps it next to "<- Home" while pushing the icon group to the far right. */
.fullscreen-toggle {
  margin-right: auto;
  margin-left: 1.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent-light);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: color 0.15s;
}

.fullscreen-toggle:hover {
  color: var(--accent);
}

.fullscreen-toggle .fs-icon {
  font-size: 1.1rem;
  line-height: 1;
}

/* While a chart or the explorer is full screen, lift its <main> out of the
   grid and let it cover the viewport (over the sidebar).  The view re-renders
   to fit. */
body.chart-fullscreen,
body.explore-fullscreen {
  overflow: hidden;
}

body.chart-fullscreen .content-page,
body.explore-fullscreen .content-page {
  position: fixed;
  inset: 0;
  z-index: 1000;
  width: 100vw;
  max-width: none;
  height: 100vh;
  margin: 0;
  padding: 1rem 2rem 2rem;
  overflow: auto;
  background: var(--bg);
}

body.chart-fullscreen .blog-post {
  min-height: calc(100vh - 7rem);
}

/* The post body and content normally cap at --max-width; let them span the
   full overlay so the chart can use the entire width (and, via its computed
   height, the entire height). */
body.chart-fullscreen .blog-post,
body.chart-fullscreen .blog-post-content,
body.explore-fullscreen .blog-post,
body.explore-fullscreen .blog-post-content {
  max-width: none;
}

/* In full screen, let the explorer's result grid use the available height
   instead of its compact inline cap. */
body.explore-fullscreen .explore-results {
  max-height: calc(100vh - 18rem);
  overflow-y: auto;
}

/* ── Per-chart analysis toolbar + full screen ───────────────── */

.analysis-toolbar {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 0.5rem;
}

.analysis-toolbar .fullscreen-toggle {
  margin: 0;
}

/* One analysis chart expanded to fill the viewport (over the sidebar). The
   Vega view refits width via its ResizeObserver; overlay.js bumps its height. */
body.analysis-fullscreen {
  overflow: hidden;
}

.analysis-block.block-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  margin: 0;
  padding: 1rem 2rem 2rem;
  width: 100vw;
  max-width: none;
  height: 100vh;
  overflow: auto;
  background: var(--bg);
}

.analysis-block.block-fullscreen .chart-host {
  width: 100%;
}

.blog-post {
  background: var(--accent-wash);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 2.5rem;
  box-shadow: var(--shadow-sm);
  max-width: var(--max-width);
}

.blog-post-header {
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-light);
}

.blog-post-date {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent-light);
  letter-spacing: 0.02em;
  margin-bottom: 0.5rem;
}

.blog-post-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.blog-post-content {
  max-width: var(--max-width);
}

.blog-post-content p {
  margin: 0.75rem 0;
  line-height: 1.75;
  color: var(--fg-secondary);
}

.blog-post-content a {
  color: var(--accent-light);
}

.blog-post-content a:hover {
  color: var(--accent);
}

.blog-post-content code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-card);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  color: var(--accent);
}

.blog-post-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  margin: 1rem 0;
}

/* ── Anchor links ───────────────────────────────────────────── */

.anchor {
  color: var(--border);
  text-decoration: none;
  margin-left: 0.25em;
  opacity: 0;
  transition: opacity 0.15s;
}

h1:hover .anchor,
h2:hover .anchor,
h3:hover .anchor {
  opacity: 1;
}

.anchor:hover {
  color: var(--accent-light);
}

/* ── Responsive ─────────────────────────────────────────────── */

@media (max-width: 768px) {
  body {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform 0.3s;
  }
  .sidebar.open { transform: translateX(0); }
  main {
    padding: 1.5rem;
  }
}

/* -- Overlay chart styles ------------------------------------------------- */

.overlay-header {
  margin-bottom: 0.5rem;
}

.overlay-header h3 {
  margin: 0 0 0.25rem 0;
  font-size: 1.1rem;
  color: var(--fg);
}

.overlay-header .chart-subtitle {
  margin: 0;
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.overlay-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.25rem;
  font-size: 0.8rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--fg-muted);
}

.legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.overlay-chart {
  margin-bottom: 2rem;
}

/* ---- Log viewer ---- */

#log-viewer {
  font-family: var(--font-sans);
}

.log-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.log-unit-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.log-unit-pill {
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--fg-secondary);
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.15s, color 0.15s;
}

.log-unit-pill:hover {
  background: var(--accent-light);
  color: #fff;
}

.log-unit-pill.active {
  background: var(--accent);
  color: #fff;
}

.log-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.log-nav-btn {
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg-secondary);
  cursor: pointer;
  font-size: 0.8rem;
}

.log-nav-btn:hover:not(:disabled) {
  background: var(--accent-light);
  color: #fff;
}

.log-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.log-status {
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.log-table-wrap {
  overflow-x: auto;
  max-height: 80vh;
  overflow-y: auto;
}

.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  font-family: var(--font-mono);
}

.log-table th {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  border-bottom: 2px solid var(--border);
  text-align: left;
  padding: 0.3rem 0.5rem;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
}

.log-table td {
  padding: 0.2rem 0.5rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--fg);
  white-space: pre-wrap;
  word-break: break-all;
  max-width: 60vw;
}

.log-table tbody tr:hover {
  background: var(--bg-hover);
}

/* Priority coloring */
.log-emerg td,
.log-alert td,
.log-crit td  { color: #c0392b; font-weight: 600; }
.log-err td   { color: #e74c3c; }
.log-warn td  { color: #b8860b; }
.log-notice td { color: var(--green); }
.log-info td  { color: var(--fg); }
.log-debug td { color: var(--fg-muted); }

/* Build footer */
.build-footer {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem 1rem 1rem;
  color: var(--fg-muted);
}

/* Site banner (logo header) */
.site-banner {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  padding: 1.5rem 1rem 1rem;
}

.site-banner img {
  width: 100%;
  height: auto;
}

/* Per-chart caption rendered beneath each chart in the selfmon /
 * dashboard layout.  Set via SiteConfig.metric_captions and emitted
 * by the {{ chart }} shortcode (chart.js renders one <p> per chart). */
.chart .chart-caption {
  color: var(--fg-muted);
  font-size: 0.85rem;
  margin: 0.25rem 0 1.25rem;
  line-height: 1.4;
}

/* Pond status grid -- per-pond "systemctl status"-style cards
 * rendered server-side by the pond_status_grid shortcode from
 * journal data.  See SiteConfig.status_grid. */
.pond-status-grid-wrap {
  margin: 1rem 0 2rem;
}

.pond-status-generated-at {
  color: var(--fg-muted);
  font-size: 0.85rem;
  margin: 0 0 1rem;
}

.pond-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr));
  gap: 1rem;
}

.pond-status-card {
  border: 1px solid var(--border, #ccc);
  border-left: 4px solid var(--status-unknown);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  background: var(--card-bg, #fafafa);
}

.pond-status-card.health-green {
  border-left-color: var(--status-green);
  background: var(--status-green-wash);
}

.pond-status-card.health-yellow {
  border-left-color: var(--status-yellow);
  background: var(--status-yellow-wash);
}

.pond-status-card.health-red {
  border-left-color: var(--status-red);
  background: var(--status-red-wash);
}

.pond-status-card.health-unknown {
  border-left-color: var(--status-unknown);
  background: var(--status-unknown-wash);
}

.pond-status-meta time {
  font-variant-numeric: tabular-nums;
}

.pond-status-meta .rel-time {
  color: var(--fg-muted);
  font-size: 0.78rem;
  margin-left: 0.4rem;
}

.pond-status-unit {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
}

.pond-status-meta {
  margin: 0 0 0.5rem;
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 0.75rem;
  row-gap: 0.25rem;
  font-size: 0.85rem;
}

.pond-status-meta dt {
  color: var(--fg-muted);
  font-weight: 600;
}

.pond-status-meta dd {
  margin: 0;
  word-break: break-word;
}

.pond-status-msg {
  color: var(--fg-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
}

.pond-status-tail {
  background: var(--code-bg, #f0f0f0);
  border-radius: 4px;
  padding: 0.5rem;
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.3;
  max-height: 16rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.pond-status-tail-empty,
.pond-status-empty {
  color: var(--fg-muted);
  font-style: italic;
  font-size: 0.85rem;
}

/* ── Data explorer (explore.js) ─────────────────────────────────────────── */

#explore {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.explore-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.75rem;
}

.explore-window {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.explore-window-label {
  font-weight: 500;
  color: var(--fg-secondary);
}

.explore-window-input {
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--fg-secondary);
  font-size: 0.78rem;
}

.explore-window-full {
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--accent);
  font-size: 0.78rem;
  cursor: pointer;
}

.explore-window-full:hover {
  background: var(--accent-wash);
}

.explore-window-hint {
  color: var(--fg-muted);
  font-style: italic;
}

.explore-dataset {
  margin-left: 0.25rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--fg-secondary);
}

.explore-schema {
  color: var(--fg-muted);
  font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.explore-sql {
  width: 100%;
  box-sizing: border-box;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  line-height: 1.4;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--fg-secondary);
  resize: vertical;
}

.explore-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.explore-run,
.explore-download,
.explore-download-json,
.explore-download-parquet {
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--accent-wash);
  color: var(--accent);
  cursor: pointer;
}

.explore-run:disabled,
.explore-download:disabled,
.explore-download-json:disabled,
.explore-download-parquet:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Clickable column browser: chips that insert a column name into the editor. */
.explore-columns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0.4rem 0;
}

.explore-col-chip {
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--fg);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  cursor: pointer;
}

.explore-col-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Canned example queries for the current dataset. */
.explore-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.explore-example {
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  font-size: 0.8rem;
  cursor: pointer;
}

.explore-example:hover {
  background: var(--accent-wash);
}

/* Result pager. */
.explore-pager {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.explore-prev,
.explore-next {
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--accent-wash);
  color: var(--accent);
  cursor: pointer;
}

.explore-prev:disabled,
.explore-next:disabled {
  opacity: 0.5;
  cursor: default;
}

.explore-page-info {
  color: var(--fg-muted);
  font-size: 0.82rem;
}

.explore-status {
  color: var(--fg-muted);
  font-size: 0.85rem;
}

.explore-error {
  color: #b91c1c;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
}

.explore-results {
  overflow-x: auto;
}

/* View switcher (Table / Chart) for the result area. */
.explore-views {
  display: flex;
  gap: 0;
  margin: 0.5rem 0;
}

.explore-view-table,
.explore-view-chart {
  padding: 0.25rem 0.8rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--accent);
  font-size: 0.8rem;
  cursor: pointer;
}

.explore-view-table {
  border-radius: 6px 0 0 6px;
}

.explore-view-chart {
  border-radius: 0 6px 6px 0;
  border-left: none;
}

.explore-view-table.active,
.explore-view-chart.active {
  background: var(--accent-wash);
}

/* Vega-Lite chart render target. */
.explore-chart {
  width: 100%;
  min-height: 360px;
}

/* Editable Vega-Lite spec panel, shown beneath the chart in chart view. */
.explore-spec {
  margin-top: 0.75rem;
}

.explore-spec-label {
  font-size: 0.8rem;
  color: var(--accent);
  margin-bottom: 0.3rem;
}

.explore-spec-editor {
  width: 100%;
  box-sizing: border-box;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  line-height: 1.4;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--fg-secondary);
  resize: vertical;
}

.explore-spec-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.explore-spec-apply,
.explore-spec-reset {
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--accent-wash);
  color: var(--accent);
  font-size: 0.8rem;
  cursor: pointer;
}

table.explore-grid {
  border-collapse: collapse;
  font-size: 0.82rem;
  width: 100%;
}

table.explore-grid th,
table.explore-grid td {
  border: 1px solid var(--border-light);
  padding: 0.25rem 0.5rem;
  text-align: left;
  white-space: nowrap;
}

table.explore-grid th {
  background: var(--bg-card);
  color: var(--accent);
  position: sticky;
  top: 0;
}
/* Opt-in documentation layout. Navigation remains usable without JavaScript. */
.documentation { font-family: system-ui, sans-serif; }
.documentation .sidebar .subnav { display: block; }
.documentation .manual-article { max-width: 76ch; line-height: 1.65; }
.documentation pre { overflow-x: auto; padding: 1rem; background: var(--bg-secondary, #f3f4f6); border: 1px solid #8886; border-radius: .3rem; }
.documentation code { font-family: ui-monospace, monospace; overflow-wrap: anywhere; }
.documentation pre code { overflow-wrap: normal; }
.documentation table { border-collapse: collapse; display: block; overflow-x: auto; }
.documentation th, .documentation td { padding: .5rem; border: 1px solid #8886; text-align: left; }
.documentation th { white-space: nowrap; }
.documentation td:first-child code { white-space: nowrap; overflow-wrap: normal; }
.documentation .page-toc { display: var(--page-toc-display, block); padding: 1rem; border: 1px solid #8886; }
.documentation .page-toc ul { margin-block: .35rem 0; padding-left: 1.5rem; }
.documentation a:focus-visible { outline: 3px solid currentColor; outline-offset: 3px; }
.documentation .skip-link { position: absolute; left: -10000px; }
.documentation .skip-link:focus { left: 1rem; top: 1rem; z-index: 100; background: white; color: black; padding: 1rem; }
