/* Firefox Energy Scanner — static site styles.
   No framework, no build step. Colours are defined for both schemes. */

:root {
  color-scheme: light dark;
  --fg: #1a1a1a;
  --bg: #ffffff;
  --muted: #565656;
  --line: #d0d0d0;
  --accent: #0b4fd0;
  --accent-fg: #ffffff;
  --warn-fg: #7a4a00;
  --warn-bg: #fff6e5;
  --ok-fg: #1d5b26;
  --surface: #f6f7f9;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e9e9e9;
    --bg: #131313;
    --muted: #b0b0b0;
    --line: #3c3c3c;
    --accent: #7fa9ff;
    --accent-fg: #10141c;
    --warn-fg: #ffd08a;
    --warn-bg: #3a2b10;
    --ok-fg: #8fd79b;
    --surface: #1c1c1c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--fg);
  background: var(--bg);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-fg);
  padding: .75rem 1rem;
  z-index: 10;
}
.skip-link:focus { left: 0; }

/* A visible focus indicator on every interactive element. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.table-scroll:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.site-header,
main,
footer {
  max-width: 62rem;
  margin: 0 auto;
  padding: 1rem;
}

.site-header { padding-top: 2rem; }
.site-header h1 { margin: 0 0 .25rem; font-size: 1.9rem; }
.tagline { margin: 0 0 1rem; color: var(--muted); font-size: 1.05rem; }

nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0;
  padding: 0;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1rem;
}

a { color: var(--accent); }

h2 { margin-top: 2.5rem; font-size: 1.4rem; }
h3 { margin-top: 1.75rem; font-size: 1.1rem; }

.note, .hint { color: var(--muted); font-size: .93rem; }
.muted { color: var(--muted); font-weight: normal; }

.boundary {
  background: var(--surface);
  border-left: 4px solid var(--accent);
  padding: 1rem 1.25rem;
  margin-top: 1.5rem;
}
.boundary dt { font-weight: 600; margin-top: .75rem; }
.boundary dd { margin: 0 0 .25rem; }

/* Visually hidden but available to assistive technology. */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Stats bar */
.stats-bar { margin-top: 1.5rem; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 1px;
  margin: 0;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.stat-item { background: var(--surface); padding: .85rem 1rem; }
.stat-item dt { font-size: .8rem; color: var(--muted); margin: 0 0 .2rem; }
.stat-item dd { margin: 0; font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* How it works */
.how-steps { list-style: none; padding: 0; display: grid; gap: 1rem; }
.how-steps li { padding-left: 2.5rem; position: relative; }
.step-num {
  position: absolute;
  left: 0; top: 0;
  width: 1.75rem; height: 1.75rem;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 700;
  font-size: .85rem;
}

/* Form */
.field { margin-bottom: 1.5rem; }
.field[hidden] { display: none; }
.hint.indent { margin-left: 1.6rem; margin-top: 0; }
label.spaced { margin-top: 1rem; }

.estimate { color: var(--muted); font-size: .93rem; }
.estimate.over { color: var(--warn-fg); font-weight: 600; }
fieldset.field { border: 1px solid var(--line); padding: 1rem; }
legend { font-weight: 600; padding: 0 .4rem; }

label { display: block; font-weight: 600; margin-bottom: .25rem; }
.radio-row { display: flex; align-items: baseline; gap: .5rem; margin: .4rem 0; }
.radio-row label { font-weight: normal; margin: 0; }
.radio-row input { margin: 0; }

textarea, input[type="text"], input[type="number"], input[type="search"], select {
  width: 100%;
  max-width: 40rem;
  padding: .55rem;
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
}
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; }

button {
  font: inherit;
  font-weight: 600;
  padding: .6rem 1.1rem;
  color: var(--accent-fg);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
}
button:hover { opacity: .9; }

#form-status:not(:empty) {
  margin-top: .75rem;
  padding: .6rem .8rem;
  background: var(--warn-bg);
  color: var(--warn-fg);
  border-left: 4px solid currentColor;
}

/* Results */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: end;
  margin: 1rem 0 1.5rem;
}
.controls label { margin: 0 0 .2rem; }
.controls input, .controls select { max-width: 18rem; }

.run {
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.run-head {
  background: var(--surface);
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--line);
}
.run-head h3 { margin: 0 0 .25rem; font-size: 1.05rem; }
.run-meta { font-size: .87rem; color: var(--muted); }

.badge {
  display: inline-block;
  font-size: .78rem;
  font-weight: 600;
  padding: .12rem .5rem;
  border-radius: 999px;
  border: 1px solid currentColor;
  margin-left: .4rem;
  vertical-align: middle;
}
.badge-energy { color: var(--ok-fg); }
.badge-noenergy { color: var(--warn-fg); }

.table-scroll { overflow-x: auto; }

table { border-collapse: collapse; width: 100%; font-size: .93rem; }
caption { text-align: left; padding: .6rem 1rem; color: var(--muted); font-size: .87rem; }
th, td { padding: .45rem .7rem; border-bottom: 1px solid var(--line); text-align: right; }
th:first-child, td:first-child { text-align: left; }
thead th { background: var(--surface); font-size: .85rem; }
tbody tr:last-child td { border-bottom: none; }

td.unresolved { color: var(--muted); font-style: italic; }

.run-warning {
  margin: 0;
  padding: .6rem 1rem;
  background: var(--warn-bg);
  color: var(--warn-fg);
  font-size: .88rem;
  border-top: 1px solid var(--line);
}

footer {
  margin-top: 3rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .9rem;
}

@media (max-width: 40rem) {
  .controls { flex-direction: column; align-items: stretch; }
  .controls input, .controls select { max-width: none; }
}

/* Structural detail: available on every host, energy or not. */
.tier-note {
  margin: .4rem 0 0;
  padding: .5rem .75rem;
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  font-size: .9rem;
}
.scenario-detail { margin-top: 1rem; padding-top: .75rem; border-top: 1px solid var(--line); }
.scenario-detail-label { margin: 0 0 .35rem; font-weight: 600; font-size: .9rem; word-break: break-all; }
.anatomy { margin: .25rem 0; font-size: .88rem; }
.findings { margin-top: .5rem; }
.findings summary { cursor: pointer; font-size: .9rem; }
.findings ul { margin: .5rem 0 0; padding-left: 1.2rem; }
.findings li { margin-bottom: .6rem; font-size: .9rem; }

/* Lighthouse: one disclosure per URL, metrics as a definition list. */
.lighthouse { margin-top: .5rem; }
.lighthouse summary { cursor: pointer; font-size: .9rem; }
.lighthouse ol { margin: .35rem 0 0; padding-left: 1.4rem; }
.lighthouse li { margin-bottom: .4rem; font-size: .9rem; }
.lh-metrics { display: grid; grid-template-columns: max-content 1fr; gap: .15rem 1rem;
  margin: .5rem 0; font-size: .88rem; }
.lh-metrics dt { color: var(--muted); }
.lh-metrics dd { margin: 0; }
.lh-subhead { margin: .6rem 0 0; font-size: .9rem; font-weight: 600; }
@media (max-width: 30rem) {
  .lh-metrics { grid-template-columns: 1fr; }
  .lh-metrics dd { margin-bottom: .3rem; }
}
td.failed-note { text-align: left; min-width: 16rem; }
.lh-note { font-size: .85rem; }
.lh-sitewide { margin: .35rem 0 0; padding-left: 1.2rem; }
.lh-sitewide li { margin-bottom: .4rem; font-size: .9rem; }

/* "More options" disclosure on the request form. */
.more-options { border: 1px solid var(--line); padding: .75rem 1rem; }
.more-options > summary { cursor: pointer; font-weight: 600; }
.more-options[open] > summary { margin-bottom: 1rem; }
.more-options .field:last-child { margin-bottom: 0; }
