/* ============================================================
   Shared stylesheet — SGMA Depletion One-Pagers
   Professional, print-friendly, accessible
   ============================================================ */

:root {
  /* Water palette */
  --water-deep: #0f3a5f;
  --water-mid: #2c6e9a;
  --water-light: #a8c8dc;
  --water-pale: #e7f0f6;

  /* Earth / aquifer */
  --aquifer-sat: #d4b896;
  --aquifer-vad: #ebd9b4;
  --bedrock: #5b5b5b;
  --bedrock-light: #8a8a8a;

  /* Accents */
  --well: #b54a1b;
  --well-light: #e08a5d;
  --veg: #4a7c3a;
  --warn: #c9a227;
  --danger: #a02020;

  /* Neutrals */
  --bg: #fafaf7;
  --surface: #ffffff;
  --ink: #1a1a1a;
  --ink-muted: #555;
  --ink-dim: #8a8a8a;
  --rule: #d8d4cc;
  --rule-soft: #ece8df;

  /* Layout */
  --content-max: 1100px;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 12px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--water-mid); text-decoration: none; border-bottom: 1px solid transparent; }
a:hover { border-bottom-color: var(--water-mid); }

code, .mono {
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.92em;
}

/* ---------- Page frame ---------- */
.page {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 28px 36px 60px;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 2px solid var(--water-deep);
  padding-bottom: 14px;
  margin-bottom: 22px;
  gap: 24px;
}

.title-block { flex: 1; min-width: 0; }

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--water-mid);
  font-weight: 600;
  margin-bottom: 4px;
}

.page-header h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--water-deep);
}

.page-header .subtitle {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--ink-muted);
  font-weight: 400;
  max-width: 70ch;
}

.page-header .meta {
  font-size: 11px;
  color: var(--ink-dim);
  text-align: right;
  white-space: nowrap;
}

.crumb {
  font-size: 11px;
  color: var(--ink-dim);
  margin-bottom: 8px;
}
.crumb a { color: var(--ink-muted); }

/* ---------- Grid sections ---------- */
.grid {
  display: grid;
  gap: 18px;
}

.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }
.grid-1-2 { grid-template-columns: 1fr 2fr; }

@media (max-width: 760px) {
  .grid-2, .grid-3, .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
  .page { padding: 18px 16px 40px; }
}

/* ---------- Cards & panels ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.card.tinted {
  background: var(--water-pale);
  border-color: var(--water-light);
}

.card.callout {
  background: #fff8e6;
  border-color: #e8d28a;
  border-left: 4px solid var(--warn);
}

.card h2, .card h3 {
  margin: 0 0 8px 0;
  color: var(--water-deep);
}
.card h2 { font-size: 16px; font-weight: 700; }
.card h3 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }

.card p { margin: 0 0 8px 0; }
.card p:last-child { margin-bottom: 0; }

.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--water-deep);
  margin: 22px 0 10px 0;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--rule);
}

/* ---------- Figures & viz ---------- */
.figure {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
}

.figure-caption {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 8px;
  line-height: 1.45;
}

.figure-caption .fignum {
  font-weight: 700;
  color: var(--water-deep);
}

svg.diagram { display: block; width: 100%; height: auto; }

/* ---------- Controls (sliders, selects) ---------- */
.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 16px;
  padding: 12px 14px;
  background: var(--rule-soft);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  margin: 10px 0;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}

.control label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 600;
  color: var(--ink-muted);
}

.control label .val {
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
  font-weight: 500;
  color: var(--water-deep);
  background: white;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--rule);
  font-size: 11px;
}

.control input[type=range] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  height: 20px;
}
.control input[type=range]::-webkit-slider-runnable-track {
  height: 4px; background: var(--water-light); border-radius: 2px;
}
.control input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--water-mid);
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  margin-top: -5px;
  cursor: pointer;
}
.control input[type=range]::-moz-range-track {
  height: 4px; background: var(--water-light); border-radius: 2px;
}
.control input[type=range]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--water-mid);
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  cursor: pointer;
}

.control select, .control input[type=number], .control input[type=text] {
  font: inherit;
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: white;
}

.toggles {
  display: flex; gap: 14px; flex-wrap: wrap;
  font-size: 12px;
}
.toggles label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }

/* ---------- Equations ---------- */
.eq {
  background: var(--rule-soft);
  border-left: 3px solid var(--water-mid);
  padding: 8px 12px;
  margin: 8px 0;
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
  font-size: 13px;
  overflow-x: auto;
}

.eq .where { color: var(--ink-muted); font-size: 11px; margin-top: 4px; display: block; }

/* ---------- Lists ---------- */
ul.tight, ol.tight { padding-left: 20px; margin: 6px 0; }
ul.tight li, ol.tight li { margin-bottom: 3px; }
ul.tick { list-style: none; padding-left: 0; }
ul.tick li {
  padding-left: 22px;
  position: relative;
  margin-bottom: 5px;
}
ul.tick li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--veg);
  font-weight: 700;
}

/* ---------- Tables ---------- */
table.compact {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
table.compact th, table.compact td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}
table.compact thead th {
  background: var(--water-deep);
  color: white;
  font-weight: 600;
  letter-spacing: 0.02em;
}
table.compact tbody tr:nth-child(even) { background: var(--rule-soft); }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--water-pale);
  color: var(--water-deep);
  border: 1px solid var(--water-light);
}
.badge.warn   { background: #fff3cd; border-color: #e8d28a; color: #8a6500; }
.badge.danger { background: #fbe5e5; border-color: #e8a8a8; color: #8a1010; }
.badge.ok     { background: #e7f3e0; border-color: #a8c89a; color: #2f5a1f; }

/* ---------- Footer / refs ---------- */
.refs {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-size: 11.5px;
  color: var(--ink-muted);
  line-height: 1.4;
}
.refs h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--water-deep);
  margin: 0 0 6px 0;
}
.refs ol { margin: 0; padding-left: 22px; }
.refs ol li { margin-bottom: 3px; }
.refs .author { font-weight: 600; color: var(--ink); }

.page-footer {
  margin-top: 18px;
  padding-top: 10px;
  border-top: 1px solid var(--rule-soft);
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--ink-dim);
}

/* ---------- Print ---------- */
@media print {
  body { background: white; font-size: 10.5pt; }
  .page { max-width: 100%; padding: 0.5in; }
  .controls { display: none; }
  .card, .figure { box-shadow: none; break-inside: avoid; }
  .figure { break-inside: avoid; page-break-inside: avoid; }
  a { color: inherit; border-bottom: none; }
  .no-print { display: none !important; }
}

/* ---------- Index page specifics ---------- */
.index-hero {
  background: linear-gradient(135deg, var(--water-deep) 0%, var(--water-mid) 100%);
  color: white;
  padding: 36px 36px 28px;
  border-radius: var(--radius);
  margin-bottom: 24px;
}
.index-hero h1 {
  margin: 0 0 8px 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.index-hero p {
  margin: 0;
  font-size: 15px;
  color: rgba(255,255,255,0.92);
  max-width: 72ch;
}
.index-hero .eyebrow { color: rgba(255,255,255,0.7); }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.tile {
  display: block;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 16px 18px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.15s, transform 0.15s;
  position: relative;
}
.tile:hover {
  border-color: var(--water-mid);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.tile .tile-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--water-mid);
  font-weight: 600;
}
.tile h3 {
  margin: 4px 0 6px 0;
  font-size: 15px;
  color: var(--water-deep);
}
.tile p {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-muted);
  line-height: 1.4;
}

/* ---------- Tooltip ---------- */
.tooltip {
  position: absolute;
  background: rgba(15, 58, 95, 0.95);
  color: white;
  padding: 6px 9px;
  border-radius: 4px;
  font-size: 11px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 100;
  white-space: nowrap;
}
.tooltip.show { opacity: 1; }
