/* Theme: Sage Morning. Dawn sky, sage hills, amber sun; forest green header and footer. */
:root {
  --bg: #f6f3ea;
  --bg-2: #eaf0e3;
  --card: #fffdf8;
  --fg: #26332b;
  --muted: #66705f;
  --heading: #2f4a3a;
  --accent: #c0632f;
  --rule: #dfe3d3;
  --header-bg: #2f4a3a;
  --header-fg: #f6f3ea;
  --sky-top: #fbe6c8;
  --sky-bottom: #e3ecd9;
  --sun: #f0a35a;
  --hill-3: #c3d6b6;
  --hill-2: #95b78d;
  --hill-1: #628c66;
  --glance-bg: #e6efdf;
  --shadow: 0 1px 2px rgba(38, 51, 43, .06), 0 6px 18px rgba(38, 51, 43, .08);
  --cat-home: #b65a33;
  --cat-tech: #23758a;
  --cat-money: #4c7a37;
  --cat-everyday: #85568a;
}
/* Dark colors: chosen with the header button, remembered per visitor. Light is the default. */
:root[data-theme="dark"] {
  --bg: #161d19;
  --bg-2: #1c2620;
  --card: #222c26;
  --fg: #ecefe6;
  --muted: #a3ad9e;
  --heading: #dcead6;
  --accent: #f0955c;
  --rule: #2f3a33;
  --header-bg: #101612;
  --header-fg: #ecefe6;
  --sky-top: #2a2f2a;
  --sky-bottom: #1c2620;
  --sun: #e0955a;
  --hill-3: #2f4434;
  --hill-2: #3d5c43;
  --hill-1: #4f7a56;
  --glance-bg: #26332b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
  --cat-home: #e8916b;
  --cat-tech: #6cc0d3;
  --cat-money: #95c47c;
  --cat-everyday: #c99ccc;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg-2); }
body {
  margin: 0;
  background: var(--bg) linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%) no-repeat;
  background-size: 100% 100%;
  color: var(--fg);
  font: 18px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.wrap { width: 100%; max-width: 46rem; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
main { flex: 1; padding-top: 2.5rem; padding-bottom: 3.5rem; }

a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3 { color: var(--heading); line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 2.2rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.35rem; margin: 2.5rem 0 1rem; }
time { color: var(--muted); font-size: 0.875rem; }
img { max-width: 100%; height: auto; border-radius: 10px; }

/* Header */
.site-header { background: var(--header-bg); color: var(--header-fg); }
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.5rem 1.5rem; padding-top: 0.95rem; padding-bottom: 0.95rem;
}
.brand { display: inline-flex; align-items: center; gap: 0.6rem; font-weight: 700; font-size: 1.15rem; color: var(--header-fg); text-decoration: none; }
.brand-mark { display: block; width: 30px; height: 30px; border-radius: 8px; box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--header-fg) 35%, transparent); }
.site-header nav { display: flex; align-items: center; gap: 1.25rem; }
.theme-toggle {
  display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 1px solid color-mix(in srgb, var(--header-fg) 35%, transparent); border-radius: 50%;
  background: transparent; color: var(--header-fg); cursor: pointer;
}
.theme-toggle:hover { border-color: var(--sun); color: var(--sun); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
.site-header nav a { color: var(--header-fg); opacity: .75; text-decoration: none; }
.site-header nav a:hover, .site-header nav a[aria-current="page"] { opacity: 1; text-decoration: underline; text-decoration-color: var(--sun); text-decoration-thickness: 2px; text-underline-offset: 6px; }

/* Home banner */
.hero {
  position: relative;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 100%);
  padding-top: 3.25rem;
  overflow: hidden;
}
.hero .wrap { position: relative; z-index: 1; }
.hero h1 { font-size: clamp(2.4rem, 7vw, 3.6rem); margin-bottom: 0.4rem; }
.hero .tagline { color: var(--fg); font-size: 1.25rem; margin: 0; max-width: 34rem; }
.hero-art { position: relative; z-index: 1; display: block; width: 100%; height: clamp(110px, 16vw, 200px); margin-top: 1.5rem; }
.hero-sun {
  position: absolute; z-index: 0; right: 14%; bottom: clamp(44px, 6.5vw, 84px);
  width: clamp(48px, 6vw, 84px); aspect-ratio: 1; border-radius: 50%;
  background: var(--sun); box-shadow: 0 0 0 14px color-mix(in srgb, var(--sun) 18%, transparent);
}
.hero-art .hill-3 { fill: var(--hill-3); }
.hero-art .hill-2 { fill: var(--hill-2); }
.hero-art .hill-1 { fill: var(--hill-1); }

.intro p { font-size: 1.1rem; }

/* Category labels */
.category {
  display: inline-block;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--cat, var(--accent));
  background: color-mix(in srgb, var(--cat, var(--accent)) 14%, transparent);
  padding: 0.2rem 0.6rem; border-radius: 999px;
}
.cat-home { --cat: var(--cat-home); }
.cat-tech { --cat: var(--cat-tech); }
.cat-money { --cat: var(--cat-money); }
.cat-everyday { --cat: var(--cat-everyday); }

/* Project cards */
.project-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
h1 + .project-list { margin-top: 1.5rem; }
.card {
  display: flex; flex-direction: column; gap: 0.35rem;
  background: var(--card); color: var(--fg); text-decoration: none;
  border-radius: 14px; padding: 1.2rem 1.35rem;
  box-shadow: var(--shadow);
  border-left: 5px solid var(--hill-2);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-2px); }
.card .category { align-self: flex-start; }
.card-title { font-weight: 650; font-size: 1.2rem; color: var(--heading); line-height: 1.3; }
.card-desc { color: var(--muted); }

/* Project page */
.project header { margin-bottom: 1.75rem; }
.project header .category { margin-bottom: 0.6rem; }
.glance {
  background: var(--glance-bg); border-radius: 14px;
  border-left: 5px solid var(--hill-2);
  padding: 1.1rem 1.35rem; margin: 0 0 2rem;
}
.glance h2 { font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 0.6rem; }
.glance dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; margin: 0; }
.glance dt { font-weight: 650; color: var(--heading); }
.glance dd { margin: 0; }
@media (max-width: 480px) {
  .glance dl { grid-template-columns: 1fr; gap: 0; }
  .glance dd { margin-bottom: 0.5rem; }
}
.project h2 { padding-top: 0.25rem; }
.project li { margin-bottom: 0.4rem; }
.project li::marker { color: var(--hill-1); }
.what-i-use {
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
  border-left: 5px solid var(--sun);
  padding: 1.1rem 1.35rem; margin: 1.75rem 0;
}
.what-i-use h3 { font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 0.6rem; }
.what-i-use ul { margin: 0 0 0.75rem; padding-left: 1.2rem; }
.what-i-use p { margin: 0 0 0.6rem; }
.what-i-use .disclosure { font-size: 0.875rem; color: var(--muted); font-style: italic; margin: 0; }
.no-sponsors {
  margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--rule);
  font-size: 0.875rem; color: var(--muted); font-style: italic;
}
.back { margin-top: 1.5rem; }

/* Wiring diagrams */
.diagram { margin: 1.75rem 0; padding: 1.1rem; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); }
.diagram svg { display: block; width: 100%; height: auto; font-family: inherit; }
.diagram-narrow svg { max-width: 520px; margin: 0 auto; }
.diagram figcaption { margin-top: 0.75rem; font-size: 0.9rem; color: var(--muted); }
.diagram .box { fill: var(--bg); stroke: var(--hill-2); stroke-width: 2; }
.diagram .box-strong { fill: var(--glance-bg); stroke: var(--hill-1); }
.diagram .box-accent { fill: color-mix(in srgb, var(--sun) 16%, var(--bg)); stroke: var(--sun); stroke-width: 2.5; }
.diagram .group { fill: none; stroke: var(--rule); stroke-width: 2; stroke-dasharray: 2 6; stroke-linecap: round; }
.diagram .label { fill: var(--fg); font-size: 17px; font-weight: 600; }
.diagram .label-small { fill: var(--muted); font-size: 14px; }
.diagram .label-alert { fill: var(--accent); font-weight: 600; }
.diagram .wire { fill: none; stroke: var(--heading); stroke-width: 2.5; }
.diagram .data { fill: none; stroke: var(--cat-tech); stroke-width: 2.5; stroke-dasharray: 7 6; }
.diagram .alert { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.diagram .arrowhead { fill: var(--muted); }

/* Copyable prompts */
.project pre { background: var(--card); border: 1px solid var(--rule); border-left: 5px solid var(--hill-2); border-radius: 12px; padding: 0.9rem 1.1rem; overflow-x: auto; margin: 0.5rem 0 1.5rem; box-shadow: var(--shadow); font-size: 0.85rem; line-height: 1.55; }
.project pre code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: inherit; line-height: inherit; color: var(--fg); white-space: pre-wrap; }

/* Tables in projects */
.project table { width: 100%; border-collapse: collapse; margin: 1rem 0 1.5rem; font-size: 0.95rem; background: var(--card); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.project th, .project td { text-align: left; vertical-align: top; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--rule); }
.project th { background: var(--glance-bg); color: var(--heading); }
.project tr:last-child td { border-bottom: 0; }

/* Related projects */
.related { margin-top: 2.5rem; }
.related h2 { font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 0.75rem; }

/* Footer */
.site-footer { background: var(--header-bg); color: var(--header-fg); font-size: 0.9rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.25rem 1rem; padding-top: 1.4rem; padding-bottom: 1.4rem; }
.footer-links { display: flex; gap: 1rem; }
.footer-links a { color: var(--header-fg); opacity: .75; text-decoration: none; }
.footer-links a:hover { opacity: 1; text-decoration: underline; }
.byline { margin: 0; color: var(--muted); font-size: 0.9rem; }
.byline a { color: var(--muted); }
