/* ============================================================
   WaterHeaterTrace — Design System
   Direction: "Trust Utility" — inspector-grade, source-linked.
   Cool slate surfaces, confident blue accent, crisp cards.
   ============================================================ */

:root {
  /* --- Color: surfaces & ink --- */
  --bg: #f1f5f9;            /* slate-100 page field */
  --surface: #ffffff;       /* cards */
  --surface-sunken: #f8fafc;/* slate-50 insets */
  --ink: #0f172a;           /* slate-900 headings */
  --body: #334155;          /* slate-700 body text */
  --muted: #64748b;         /* slate-500 secondary */
  --faint: #94a3b8;         /* slate-400 */

  /* --- Color: brand accent --- */
  --accent: #075985;        /* sky-800 — primary */
  --accent-strong: #0c4a6e; /* sky-900 — hover */
  --accent-ink: #ffffff;
  --accent-soft: #e0f2fe;   /* sky-100 — tints */
  --accent-softer: #f0f9ff; /* sky-50 */

  /* --- Color: semantic --- */
  --confirm: #047857;       /* emerald-700 — confirmed result */
  --confirm-soft: #ecfdf5;
  --estimate: #b45309;      /* amber-700 — estimate / caveat */
  --estimate-soft: #fffbeb;
  --estimate-border: #fde68a;
  --danger: #b91c1c;

  /* --- Borders & lines --- */
  --border: #e2e8f0;        /* slate-200 */
  --border-strong: #cbd5e1; /* slate-300 */

  /* --- Radii --- */
  --r-sm: 6px;
  --r: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;

  /* --- Shadows --- */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

  /* --- Layout --- */
  --container: 1040px;
  --container-narrow: 760px;
  --gutter: clamp(1rem, 4vw, 2rem);

  /* --- Type --- */
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --ring: 0 0 0 3px rgba(7, 89, 133, 0.28);

  color-scheme: light;
  font-family: var(--font-sans);
  line-height: 1.6;
  color: var(--body);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

img,
svg {
  display: block;
  max-width: 100%;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--r-sm);
}

/* --------------------------- typography -------------------------- */
h1,
h2,
h3,
h4 {
  color: var(--ink);
  line-height: 1.18;
  letter-spacing: -0.018em;
  font-weight: 700;
}

h1 {
  font-size: clamp(1.9rem, 1.2rem + 3vw, 3rem);
}

h2 {
  font-size: clamp(1.4rem, 1.1rem + 1.2vw, 1.9rem);
}

h3 {
  font-size: 1.2rem;
}

p {
  text-wrap: pretty;
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
}

a:hover {
  color: var(--accent-strong);
  text-decoration-color: currentColor;
}

.eyebrow {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.lede {
  font-size: clamp(1.02rem, 0.98rem + 0.4vw, 1.18rem);
  color: var(--body);
}

.muted {
  color: var(--muted);
}

code,
.mono {
  font-family: var(--font-mono);
}

/* ----------------------------- layout ---------------------------- */
.container {
  width: min(var(--container), calc(100% - var(--gutter) * 2));
  margin-inline: auto;
}

.container-narrow {
  width: min(var(--container-narrow), calc(100% - var(--gutter) * 2));
  margin-inline: auto;
}

main {
  flex: 1 0 auto;
  padding-block: clamp(1.5rem, 1rem + 2vw, 2.75rem) clamp(3rem, 2rem + 4vw, 5rem);
}

.stack > * + * {
  margin-top: 1.1rem;
}

.section {
  margin-top: clamp(2.5rem, 2rem + 2vw, 3.75rem);
}

.section > h2 {
  margin-bottom: 1rem;
}

/* --------------------------- site header ------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.7rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 1.06rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand:hover {
  color: var(--ink);
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(155deg, var(--accent), var(--accent-strong));
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.brand__mark svg {
  width: 17px;
  height: 17px;
}

.brand b {
  font-weight: 800;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.site-nav a {
  padding: 0.4rem 0.7rem;
  border-radius: var(--r-sm);
  font-size: 0.94rem;
  font-weight: 500;
  color: var(--body);
  text-decoration: none;
}

.site-nav a:hover {
  background: var(--surface-sunken);
  color: var(--ink);
}

.site-nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
}

@media (max-width: 560px) {
  .site-nav a {
    padding: 0.4rem 0.5rem;
    font-size: 0.88rem;
  }
  .brand span.brand__full {
    display: none;
  }
}

/* --------------------------- breadcrumbs ------------------------- */
.breadcrumbs {
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  list-style: none;
  padding: 0;
}

.breadcrumbs a {
  color: var(--muted);
  text-decoration: none;
}

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

.breadcrumbs li:not(:last-child)::after {
  content: "/";
  margin-left: 0.4rem;
  color: var(--faint);
}

.breadcrumbs li:last-child span {
  color: var(--ink);
  font-weight: 500;
}

/* ----------------------------- cards ----------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: clamp(1.1rem, 0.9rem + 1vw, 1.6rem);
  box-shadow: var(--shadow-sm);
}

.card--flush {
  padding: 0;
  overflow: hidden;
}

/* ----------------------------- chips ----------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--r-pill);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
  border: 1px solid transparent;
}

.chip--neutral {
  background: var(--surface-sunken);
  color: var(--muted);
  border-color: var(--border);
}

.chip--accent {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.chip--confirm {
  background: var(--confirm-soft);
  color: var(--confirm);
}

.chip--estimate {
  background: var(--estimate-soft);
  color: var(--estimate);
  border-color: var(--estimate-border);
}

.chip__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* ---------------------------- buttons ---------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.1rem;
  border-radius: var(--r);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.96rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn--primary:hover {
  background: var(--accent-strong);
  color: var(--accent-ink);
}

.btn--ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--ink);
}

.btn--ghost:hover {
  background: var(--surface-sunken);
  color: var(--ink);
}

.btn--sm {
  padding: 0.45rem 0.8rem;
  font-size: 0.88rem;
}

/* ---------------------------- callouts --------------------------- */
.callout {
  display: flex;
  gap: 0.75rem;
  padding: 0.9rem 1.1rem;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--surface-sunken);
  font-size: 0.94rem;
}

.callout__icon {
  flex: none;
  margin-top: 0.1rem;
}

.callout--estimate {
  background: var(--estimate-soft);
  border-color: var(--estimate-border);
  color: #7c3a06;
}

.callout--accent {
  background: var(--accent-softer);
  border-color: var(--accent-soft);
}

/* ---------------------------- tables ----------------------------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.data th,
table.data td {
  padding: 0.55rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table.data thead th {
  background: var(--surface-sunken);
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

table.data tbody tr:last-child td {
  border-bottom: 0;
}

table.data .mono {
  font-weight: 600;
  color: var(--ink);
}

/* reference grid: compact letter→value chart */
.code-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 0.4rem;
}

.code-cell {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.45rem 0.6rem;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.85rem;
}

.code-cell b {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--accent);
}


/* ----------------------- source citation ------------------------- */
.source-cite {
  font-size: 0.85rem;
  color: var(--muted);
  border-left: 3px solid var(--border-strong);
  padding: 0.2rem 0 0.2rem 0.85rem;
}

.source-cite a {
  font-weight: 500;
}

.source-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.9rem;
  margin-top: 0.3rem;
  font-size: 0.78rem;
  color: var(--faint);
}

/* ----------------------------- lists ----------------------------- */
.tick-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.tick-list li {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}

.tick-list li::before {
  content: "";
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 0.15rem;
  border-radius: 50%;
  background: var(--accent-soft)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23075985' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E")
    center / 12px no-repeat;
}

.link-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.link-list a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
}

/* --------------------------- site footer ------------------------- */
.site-footer {
  flex: none;
  margin-top: clamp(3rem, 2rem + 4vw, 5rem);
  background: var(--ink);
  color: #cbd5e1;
  padding-block: clamp(2.25rem, 1.5rem + 3vw, 3.25rem);
  font-size: 0.9rem;
}

.site-footer a {
  color: #e2e8f0;
  text-decoration: none;
}

.site-footer a:hover {
  color: #fff;
  text-decoration: underline;
}

.footer-grid {
  display: grid;
  gap: 2rem;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
}

@media (max-width: 860px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .footer-grid > :first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: #fff;
  font-size: 1.02rem;
}

.footer-col h4 {
  color: #fff;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.8rem;
}

.footer-col ul {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.footer-note {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  font-size: 0.82rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
}

/* --------------------------- utilities --------------------------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
