/* Electrified Home – one stylesheet for every page.
   Colours come from UK wiring: brown is live, blue is neutral, green and
   yellow is earth. The home page's row of circuit breakers is the one
   decorative element; everything else stays plain. */

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("fonts/atkinson-hyperlegible-next-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("fonts/atkinson-hyperlegible-next-latin-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("fonts/atkinson-hyperlegible-next-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --plastic: #eef1f0;   /* page: the off-white of a consumer unit */
  --panel: #ffffff;
  --ink: #1d2733;
  --muted: #4f5b67;
  --rule: #cfd6d9;
  --live: #8a4b26;      /* brown */
  --neutral: #2458a6;   /* blue: links */
  --earth-green: #2f7d3a;
  --earth-yellow: #e2c21a;
  --measure: 38rem;
  --wide: 60rem;
}

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

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

body {
  margin: 0;
  background: var(--plastic);
  color: var(--ink);
  font-family: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
}

a { color: var(--neutral); text-underline-offset: 0.15em; }
a:hover { color: var(--ink); }

:focus-visible {
  outline: 3px solid var(--earth-yellow);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px var(--earth-green);
}

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

/* ---------- Header and footer ---------- */

.site-header {
  background: var(--panel);
  border-bottom: 1px solid var(--rule);
}
.site-header .inner {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1.5rem;
}
.site-name {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.site-name svg { width: 1.25rem; height: 1.25rem; flex: none; }
.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
}
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9375rem;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--ink); border-bottom-color: var(--rule); }
.site-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--live); }

.site-footer {
  margin-top: 4rem;
  border-top: 1px solid var(--rule);
  background: var(--panel);
  font-size: 0.9375rem;
  color: var(--muted);
}
.site-footer .inner {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
}
.site-footer p { margin: 0 0 0.5rem; max-width: var(--measure); }
.site-footer a { color: var(--muted); }

.skip {
  position: absolute;
  left: -999px;
}
.skip:focus { left: 1rem; top: 0.5rem; background: var(--panel); padding: 0.5rem; z-index: 10; }

/* ---------- Page body ---------- */

main {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 2.5rem 1rem 0;
}
main > * { max-width: var(--measure); }
main > .wide, main > .board { max-width: none; }

h1, h2, h3 { line-height: 1.2; font-weight: 700; }
h1 { font-size: clamp(2rem, 5vw, 2.75rem); margin: 0 0 1rem; letter-spacing: -0.01em; }
h2 { font-size: 1.5rem; margin: 2.75rem 0 0.75rem; }
h3 { font-size: 1.1875rem; margin: 2rem 0 0.5rem; }
p, ul, ol { margin: 0 0 1rem; }
li { margin-bottom: 0.375rem; }

.lede { font-size: 1.25rem; line-height: 1.5; color: var(--muted); }

.note {
  border-left: 4px solid var(--live);
  padding: 0.25rem 0 0.25rem 1rem;
  color: var(--muted);
}

.sources { font-size: 0.9375rem; color: var(--muted); }
.sources h2 { font-size: 1.0625rem; }

/* ---------- Embedded tools ---------- */

.tool {
  max-width: var(--wide);
  margin: 2rem 0 2.5rem;
}
.tool-frame {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-top: 4px solid var(--neutral);
  border-radius: 4px;
  padding: 0.5rem;
  min-height: 12rem;
}
.tool figcaption {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted);
  max-width: var(--measure);
}

/* ---------- Home page: the consumer unit ---------- */

.board {
  margin: 2rem 0 1rem;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1.25rem 1rem 1rem;
}
.board ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
  gap: 0.75rem;
}
.board li { margin: 0; }
.breaker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--ink);
  padding: 0.75rem 0.5rem 0.5rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--plastic);
}
.breaker .switch {
  position: relative;
  width: 2.25rem;
  height: 3.5rem;
  border-radius: 3px;
  background: var(--panel);
  border: 1px solid var(--rule);
}
/* The dolly sits down (off) and flips up (on) when you point at it. */
.breaker .switch::after {
  content: "";
  position: absolute;
  left: 0.3rem;
  right: 0.3rem;
  top: 1.75rem;
  height: 1.4rem;
  border-radius: 2px;
  background: var(--live);
  transition: top 120ms ease-out;
}
.breaker:hover .switch::after,
.breaker:focus-visible .switch::after { top: 0.3rem; }
.breaker .label {
  font-style: italic;
  font-size: 0.9375rem;
  line-height: 1.25;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--rule);
  padding: 0.125rem 0.375rem;
  width: 100%;
}
.board-caption {
  margin: 0.75rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .breaker .switch::after { transition: none; }
}

/* ---------- Lists of pages and tools ---------- */

.index-list { list-style: none; padding: 0; }
.index-list li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule);
  margin: 0;
}
.index-list a { font-weight: 700; }
.index-list p { margin: 0.25rem 0 0; color: var(--muted); }

@media (max-width: 30rem) {
  body { font-size: 1rem; }
  .lede { font-size: 1.125rem; }
  main { padding-top: 1.75rem; }
  /* On a phone the widget needs every pixel: run the frame almost to the
     screen edge instead of inside main's 1rem gutter. */
  .tool { margin-left: -0.75rem; margin-right: -0.75rem; }
  .tool-frame { padding: 0; }
  .tool figcaption { padding: 0 0.75rem; }
}
