/* ==========================================================================
   Hazmat Meter Guide — shared stylesheet
   Pure static CSS. No external fonts, no CDNs. Works fully offline.
   ========================================================================== */

:root {
  --bg: #f4f6f8;
  --bg-elev: #ffffff;
  --sidebar-bg: #1f2933;
  --sidebar-fg: #cbd5e1;
  --sidebar-fg-dim: #8a99ab;
  --sidebar-active-bg: #b91c1c;
  --sidebar-active-fg: #ffffff;
  --sidebar-hover-bg: #2b3742;
  --text: #1f2933;
  --text-dim: #52616b;
  --border: #d8dee5;
  --accent: #b91c1c;
  --link: #1d4ed8;
  --link-visited: #6d28d9;
  --code-bg: #eceff2;
  --table-stripe: #f0f3f5;
  --table-head: #e4e9ee;

  /* callouts */
  --warn-bg: #fdecea;   --warn-bd: #d64541; --warn-fg: #7a1712;
  --tip-bg:  #e8f1fd;   --tip-bd:  #2f74d0; --tip-fg:  #123a67;
  --rookie-bg:#fff5e0;  --rookie-bd:#d99411;--rookie-fg:#6b4906;
  --rem-bg:  #e6f4ea;   --rem-bd:  #2e844a; --rem-fg:  #14532d;

  --maxw: 900px;
  --sidebar-w: 270px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171d;
    --bg-elev: #1a2129;
    --sidebar-bg: #0d1116;
    --sidebar-fg: #b8c2cc;
    --sidebar-fg-dim: #6b7885;
    --sidebar-active-bg: #dc2626;
    --sidebar-active-fg: #ffffff;
    --sidebar-hover-bg: #1c2530;
    --text: #dbe2e8;
    --text-dim: #9aa7b3;
    --border: #2a333d;
    --accent: #f87171;
    --link: #6ea8ff;
    --link-visited: #c4a2f0;
    --code-bg: #232c35;
    --table-stripe: #1e262f;
    --table-head: #232e39;

    --warn-bg: #351917;  --warn-bd: #e05a54; --warn-fg: #ffcfcb;
    --tip-bg:  #12243b;  --tip-bd:  #4d8be0; --tip-fg:  #cfe0f7;
    --rookie-bg:#33280f; --rookie-bd:#e0a92f;--rookie-fg:#f6e2b6;
    --rem-bg:  #12301d;  --rem-bd:  #3fa564; --rem-fg:  #c3ecd0;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 17px;
}

/* ---------- Layout ---------- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 40;
  border-right: 1px solid rgba(0,0,0,0.3);
}
.sidebar-header {
  padding: 18px 18px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-header .brand {
  display: block;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  text-decoration: none;
  line-height: 1.25;
}
.sidebar-header .brand small {
  display: block;
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--sidebar-fg-dim);
  margin-top: 3px;
  letter-spacing: 0.02em;
}
#navSearch {
  width: 100%;
  margin-top: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #3a4650;
  background: #141a20;
  color: #e6ebf0;
  font-size: 0.9rem;
}
#navSearch::placeholder { color: #6b7885; }

.nav-list { list-style: none; margin: 0; padding: 8px 0 24px; }
.nav-section {
  padding: 14px 18px 4px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-fg-dim);
  font-weight: 700;
}
.nav-list a {
  display: block;
  padding: 8px 18px 8px 22px;
  color: var(--sidebar-fg);
  text-decoration: none;
  font-size: 0.92rem;
  border-left: 3px solid transparent;
}
.nav-list a:hover { background: var(--sidebar-hover-bg); color: #fff; }
.nav-list a.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-fg);
  border-left-color: #fff;
  font-weight: 600;
}
.nav-list li.hidden { display: none; }
.nav-noresult {
  padding: 10px 18px;
  color: var(--sidebar-fg-dim);
  font-size: 0.85rem;
  font-style: italic;
}

main.content {
  margin-left: var(--sidebar-w);
  padding: 42px 40px 80px;
  max-width: calc(var(--maxw) + 80px);
}
article { max-width: var(--maxw); }

/* ---------- Hamburger / mobile ---------- */
.hamburger {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 60;
  background: var(--sidebar-bg);
  color: #fff;
  border: 1px solid #3a4650;
  border-radius: 6px;
  font-size: 1.3rem;
  line-height: 1;
  padding: 8px 12px;
  cursor: pointer;
}
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 35;
}

/* ---------- Typography ---------- */
h1 {
  font-size: 2rem;
  line-height: 1.2;
  margin: 0 0 6px;
  color: var(--text);
}
.page-kicker {
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 4px;
}
.lede {
  font-size: 1.12rem;
  color: var(--text-dim);
  margin: 0 0 28px;
}
h2 {
  font-size: 1.45rem;
  margin: 40px 0 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border);
}
h3 { font-size: 1.15rem; margin: 26px 0 8px; }
h4 { font-size: 1.0rem; margin: 20px 0 6px; color: var(--text-dim); }
p { margin: 0 0 14px; }
ul, ol { margin: 0 0 16px; padding-left: 26px; }
li { margin: 4px 0; }
a { color: var(--link); }
a:visited { color: var(--link-visited); }
strong { color: var(--text); }

code {
  background: var(--code-bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
}

/* ---------- Callouts ---------- */
.callout {
  border-left: 5px solid;
  border-radius: 6px;
  padding: 12px 16px;
  margin: 18px 0;
  font-size: 0.98rem;
}
.callout p:last-child { margin-bottom: 0; }
.callout .callout-title {
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
  letter-spacing: 0.01em;
}
.callout.warn   { background: var(--warn-bg);   border-color: var(--warn-bd);   color: var(--warn-fg); }
.callout.warn .callout-title { color: var(--warn-bd); }
.callout.tip    { background: var(--tip-bg);    border-color: var(--tip-bd);    color: var(--tip-fg); }
.callout.tip .callout-title { color: var(--tip-bd); }
.callout.rookie { background: var(--rookie-bg); border-color: var(--rookie-bd); color: var(--rookie-fg); }
.callout.rookie .callout-title { color: var(--rookie-bd); }
.callout.remember { background: var(--rem-bg); border-color: var(--rem-bd);    color: var(--rem-fg); }
.callout.remember .callout-title { color: var(--rem-bd); }
.callout a { color: inherit; text-decoration: underline; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 18px 0; }
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
  background: var(--bg-elev);
}
th, td {
  border: 1px solid var(--border);
  padding: 8px 11px;
  text-align: left;
  vertical-align: top;
}
thead th { background: var(--table-head); font-weight: 700; }
tbody tr:nth-child(even) { background: var(--table-stripe); }
caption {
  caption-side: bottom;
  font-size: 0.8rem;
  color: var(--text-dim);
  padding-top: 6px;
  text-align: left;
}

/* ---------- Scrollable-table affordance (touch: iPhone / iPad) ----------
   JS wraps each .table-wrap in .table-scroll. Edge fades + a swipe hint
   appear ONLY when a table is wider than the screen, and fade out at the
   ends. On desktop, where tables fit, nothing shows. */
.table-scroll { position: relative; }
.table-scroll::before,
.table-scroll::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 34px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
  z-index: 2;
}
.table-scroll::before {
  left: 0;
  background: linear-gradient(to right, var(--bg), rgba(0, 0, 0, 0));
}
.table-scroll::after {
  right: 0;
  background: linear-gradient(to left, var(--bg), rgba(0, 0, 0, 0));
}
.table-scroll.can-left::before { opacity: 1; }
.table-scroll.can-right::after { opacity: 1; }

.table-scroll .swipe-hint {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.table-scroll.is-scrollable:not(.scrolled) .swipe-hint { opacity: 0.95; }

/* ---------- Cards / section index ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin: 22px 0;
}
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  text-decoration: none;
  color: var(--text);
  display: block;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,0.12); }
.card h3 { margin: 0 0 4px; font-size: 1.02rem; color: var(--accent); }
.card p { margin: 0; font-size: 0.88rem; color: var(--text-dim); }

/* on-page section nav */
.onpage-toc {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 18px;
  margin: 8px 0 28px;
  font-size: 0.9rem;
}
.onpage-toc strong { display:block; margin-bottom: 6px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); }
.onpage-toc ul { columns: 2; margin: 0; padding-left: 20px; }
@media (max-width: 620px){ .onpage-toc ul { columns: 1; } }

/* inline SVG diagrams */
.diagram {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin: 18px 0;
  text-align: center;
}
.diagram svg { max-width: 100%; height: auto; }
.diagram figcaption { font-size: 0.82rem; color: var(--text-dim); margin-top: 8px; }

.pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--code-bg);
  color: var(--text-dim);
  margin-right: 6px;
}
/* NFPA level tags */
.levels { margin: 0 0 22px; }
.pill.ops  { background: var(--tip-bg);  color: var(--tip-fg);  border: 1px solid var(--tip-bd); }
.pill.tech { background: var(--rem-bg);  color: var(--rem-fg);  border: 1px solid var(--rem-bd); }
.pill.ref  { background: var(--rookie-bg); color: var(--rookie-fg); border: 1px solid var(--rookie-bd); }

hr { border: none; border-top: 1px solid var(--border); margin: 34px 0; }

/* ---------- Footer ---------- */
.site-footer {
  margin-left: var(--sidebar-w);
  padding: 22px 40px 40px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.82rem;
  max-width: calc(var(--maxw) + 80px);
}
.site-footer strong { color: var(--text); }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .hamburger { display: block; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    width: 82%;
    max-width: 320px;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .overlay { display: block; }
  main.content { margin-left: 0; padding: 62px 20px 60px; }
  .site-footer { margin-left: 0; padding: 22px 20px 40px; }
  h1 { font-size: 1.6rem; }
}

/* ---------- Print (cheat-sheet friendly) ---------- */
@media print {
  .sidebar, .hamburger, .overlay, #navSearch, .onpage-toc, .no-print, .swipe-hint { display: none !important; }
  .table-scroll::before, .table-scroll::after { display: none !important; }
  main.content, .site-footer { margin-left: 0; max-width: 100%; padding: 0; }
  body { font-size: 11pt; background: #fff; color: #000; }
  h2 { page-break-after: avoid; }
  table, .callout, .diagram { page-break-inside: avoid; }
  .callout { border: 1px solid #999; background: #fff !important; color: #000 !important; }
  a { color: #000; text-decoration: none; }
  thead th { background: #ddd !important; }
  .print-only { display: block !important; }
}
.print-only { display: none; }
