/*
  Site register
  Built for use during an incident: one question asked in plain words,
  answered in a ranked list, with anything unknown stated just as plainly.

  Palette
    paper   cool grey-blue page
    surface white panels
    ink     navy text
    muted   secondary text
    rule    hairlines
    p1      raspberry, the one strong colour, for "act now"
*/

:root {
  --paper: #edf1f5;
  --surface: #ffffff;
  --ink: #17202e;
  --muted: #586477;
  --rule: #cbd3dd;
  --rule-strong: #9aa6b5;
  --field: #f7f9fb;
  --p1: #b8245a;
  --p1-wash: #fbe8ef;
  --p2: #96540a;
  --p2-wash: #f8eedf;
  --p3: #2c5e9e;
  --p3-wash: #e6eef8;
  --ok: #2d6a4f;
  --warn: #96540a;
  --bad: #b8245a;
  --focus: #2c5e9e;

  --font: 'Atkinson Hyperlegible Next', 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Atkinson Hyperlegible Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.563rem;
  --step-3: clamp(1.75rem, 1.2rem + 2.2vw, 2.6rem);

  --gap: 1.5rem;
  --radius: 4px;
  --measure: 72rem;

  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1622;
    --surface: #172131;
    --ink: #e6ecf3;
    --muted: #9aa7b8;
    --rule: #2a3647;
    --rule-strong: #46546a;
    --field: #111a28;
    --p1: #ef5b8c;
    --p1-wash: #3a1626;
    --p2: #e0a04a;
    --p2-wash: #33250f;
    --p3: #82a9e6;
    --p3-wash: #16263d;
    --ok: #6fcf97;
    --warn: #e0a04a;
    --bad: #ef5b8c;
    --focus: #82a9e6;
    color-scheme: dark;
  }
}

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

html { scroll-padding-top: calc(env(safe-area-inset-top, 0px) + 4.5rem); }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--step-0);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

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

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

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

/* Top bar */

.bar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  background: var(--surface);
  z-index: 21;
}
.bar-inner {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0.75rem var(--gap);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.75rem;
}
.mark { display: inline-flex; align-items: center; gap: 0.75rem; font-weight: 700; text-decoration: none; font-size: var(--step-1); letter-spacing: -0.01em; }
.mark img { display: block; height: 2.25rem; width: auto; }
.bar nav { display: flex; gap: 1.25rem; }
.bar nav a { text-decoration: none; color: var(--muted); padding: 0.25rem 0; border-bottom: 2px solid transparent; }
.bar nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
.freshness-line { margin: 0; color: var(--muted); font-size: var(--step--1); flex: 1 1 16rem; }
.freshness-line strong { color: var(--ink); font-weight: 500; }
.who { display: flex; gap: 0.75rem; align-items: center; font-size: var(--step--1); color: var(--muted); }

/* Page */

main { outline: none; }
.page { max-width: var(--measure); margin: 0 auto; padding: 2rem var(--gap) 4rem; }
.loading { max-width: var(--measure); margin: 0 auto; padding: 3rem var(--gap); color: var(--muted); }

h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: var(--step-2); }
h2 { font-size: var(--step-1); }
h3 { font-size: var(--step-0); }
p { margin: 0; max-width: 68ch; }
.muted { color: var(--muted); }
.small { font-size: var(--step--1); }
.stack > * + * { margin-top: 1rem; }
.section { margin-top: 2.5rem; }
.section > h2 + * { margin-top: 0.75rem; }

/* Buttons and fields */

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

.button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.button.secondary { background: transparent; color: var(--ink); border-color: var(--rule-strong); }
.button:disabled { opacity: 0.55; cursor: progress; }
.link-button { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; text-underline-offset: 0.18em; cursor: pointer; }

.field { display: grid; gap: 0.35rem; }
.field label, .field .label { font-weight: 500; }
.field .hint { color: var(--muted); font-size: var(--step--1); }
.field input[type="text"], .field input[type="url"], .field select, .field textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--field);
}
.field textarea { min-height: 5.5rem; resize: vertical; }
.field textarea.code { font-family: var(--mono); font-size: var(--step--1); }
.check { display: flex; gap: 0.6rem; align-items: flex-start; }
.check input { width: 1.15rem; height: 1.15rem; margin-top: 0.2rem; accent-color: var(--ink); }

.form-grid { display: grid; gap: 1.25rem 2rem; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-top: 1.5rem; }

.notice { padding: 0.8rem 1rem; border-radius: var(--radius); border-left: 4px solid var(--rule-strong); background: var(--surface); }
.notice.error { border-left-color: var(--bad); }
.notice.ok { border-left-color: var(--ok); }

/* Ask: the question is the page */

.ask {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: clamp(1.25rem, 3vw, 2.5rem);
}
.question {
  font-size: var(--step-3);
  line-height: 1.35;
  font-weight: 500;
  letter-spacing: -0.015em;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2em 0.35em;
  margin: 0;
}
.blank {
  font: inherit;
  font-family: var(--mono);
  font-size: 0.82em;
  border: 0;
  border-bottom: 3px solid var(--ink);
  background: transparent;
  padding: 0 0.1em 0.05em;
  min-width: 0;
  border-radius: 0;
}
.blank::placeholder { color: var(--rule-strong); }
.blank:focus { outline: none; border-bottom-color: var(--focus); background: var(--field); }
.blank.package { width: 13ch; flex: 1 1 13ch; max-width: 22ch; }
.blank.version { width: 7ch; flex: 0 1 7ch; }
.qmark { margin-left: -0.3em; }
.ask-actions { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; align-items: center; margin-top: 1.5rem; }
.ask-actions .muted { font-size: var(--step--1); }

/* Answer */

.answer { margin-top: 2rem; }
.answer-line { font-size: var(--step-1); font-weight: 500; max-width: none; }
.answer-line .count { font-weight: 700; }
.answer-meta { margin-top: 0.35rem; }

.ranked { list-style: none; margin: 1.25rem 0 0; padding: 0; border-top: 1px solid var(--rule); }
.ranked > li {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr) auto;
  gap: 0.25rem 1.25rem;
  align-items: start;
  padding: 1rem 0.75rem 1rem 0;
  border-bottom: 1px solid var(--rule);
}
.tier {
  font-weight: 700;
  font-size: var(--step-1);
  padding-left: 0.75rem;
  border-left: 5px solid currentColor;
  line-height: 1.15;
}
.tier small { display: block; font-size: var(--step--1); font-weight: 400; color: var(--muted); }
.tier-P1 { color: var(--p1); }
.tier-P2 { color: var(--p2); }
.tier-P3 { color: var(--p3); }
.ranked > li.tier-row-P1 { background: linear-gradient(90deg, var(--p1-wash), transparent 60%); }

.who-what h3 { font-size: var(--step-0); }
.who-what h3 a { text-decoration: none; }
.who-what h3 a:hover { text-decoration: underline; }
.who-what .reason { color: var(--muted); font-size: var(--step--1); margin-top: 0.15rem; }
.facts { display: flex; flex-wrap: wrap; gap: 0.35rem 0.5rem; margin-top: 0.5rem; padding: 0; list-style: none; }
.facts li {
  font-size: var(--step--1);
  padding: 0.05rem 0.5rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--muted);
}
.facts li.strong { color: var(--ink); border-color: var(--rule-strong); }
.facts li.alert { color: var(--bad); border-color: currentColor; }
.version-cell { text-align: right; }
.version-cell .v { font-family: var(--mono); font-size: var(--step-1); white-space: nowrap; }
.version-cell .small { display: block; }

.gaps { margin-top: 2rem; border-left: 4px solid var(--warn); padding: 0.25rem 0 0.25rem 1.25rem; }
.gaps h2 { font-size: var(--step-1); }
.gaps ul { margin: 0.75rem 0 0; padding-left: 1.1rem; }
.gaps li + li { margin-top: 0.35rem; }

.empty { margin-top: 1.5rem; color: var(--muted); }

/* Tables */

.table-wrap { overflow-x: auto; margin-top: 1rem; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: var(--step--1); }
th, td { text-align: left; padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-weight: 500; color: var(--muted); background: var(--field); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.code, td .code { font-family: var(--mono); }
tbody tr:hover { background: var(--field); }

.state { white-space: nowrap; font-weight: 500; }
.state::before { content: ""; display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; margin-right: 0.45rem; background: currentColor; vertical-align: 0.05em; }
.state-fresh { color: var(--ok); }
.state-stale, .state-never { color: var(--warn); }
.state-error { color: var(--bad); }
.state-unmapped, .state-inactive { color: var(--muted); }

.toolbar { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: end; margin-top: 1.25rem; }
.toolbar .field { min-width: 14rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.filters button {
  border: 1px solid var(--rule-strong);
  background: transparent;
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
  font-size: var(--step--1);
  cursor: pointer;
}
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 1rem; }
.page-head p { margin-top: 0.35rem; }

/* Site detail */

.detail-grid { display: grid; gap: 2rem; grid-template-columns: minmax(0, 1fr); margin-top: 1.5rem; }
@media (min-width: 60rem) { .detail-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); } }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.25rem 1.5rem; }
dl.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.4rem 1.25rem; margin: 0.75rem 0 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.issues { margin: 0.5rem 0 0; padding-left: 1.1rem; }

/* Sign in */

.signin { max-width: 34rem; margin: 12vh auto 0; padding: 0 var(--gap); }
.signin-logo { display: block; width: 10rem; height: auto; margin-bottom: 2rem; }
.signin h1 { font-size: var(--step-3); }
.signin p { margin-top: 1rem; }
.signin .button { margin-top: 2rem; }

@media (max-width: 40rem) {
  .ranked > li { grid-template-columns: 4.5rem minmax(0, 1fr); }
  .version-cell { grid-column: 2; text-align: left; }
  .who { width: 100%; justify-content: space-between; }
}

@media (prefers-reduced-motion: no-preference) {
  .answer { animation: settle 180ms ease-out; }
  @keyframes settle { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
}

/* Spacing helpers (inline styles are blocked by the content security policy) */
.mt-0 { margin-top: 0; }
.mt-xs { margin-top: 0.25rem; }
.mt-s { margin-top: 0.35rem; }
.mt { margin-top: 0.5rem; }
.mt-l { margin-top: 1.25rem; }
fieldset.bare { border: 0; padding: 0; margin: 0; min-width: 0; }
.panel .mt-l > .form-grid, .form-grid.mt { margin-top: 0.5rem; }
