/* Tanda Emergency — resident report screen.
 *
 * Design notes for whoever maintains this:
 *
 * - The screen is dark on purpose. Most reports come at night. A white screen
 *   at night destroys the reporter's night vision and lights up their face to
 *   everyone around them, which matters when the emergency is violence.
 * - No web fonts, no icon font, no CSS framework. Every byte crosses the mesh
 *   backhaul, and the page has to render when there is no upstream Internet at
 *   all. System fonts only.
 * - Nothing is smaller than 16px and no tap target is under 64px tall. The
 *   person using this is frightened, possibly running, possibly in the rain.
 * - The diagonal hazard rule is the one decorative element. It separates the
 *   questions, and it is the vocabulary of emergency signage rather than of a
 *   web form.
 */

:root {
  --ink:        #14161A;
  --ink-2:      #1B1F26;
  --slate:      #232830;
  --slate-hi:   #2E3542;
  --line:       #363E4A;
  --bone:       #EDEAE3;
  --dim:        #98A1AE;
  --signal:     #E02B1D;
  --signal-hot: #FF4C3D;
  --hazard:     #F2B705;
  --go:         #3FA37B;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "DejaVu Sans Mono", "Roboto Mono", Menlo, monospace;

  --gutter: 1rem;
  --tap: 4.25rem;
}

* { box-sizing: border-box; }

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

body.report {
  margin: 0;
  padding: 0 0 8.5rem;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: var(--gutter);
  top: var(--gutter);
  z-index: 50;
  background: var(--hazard);
  color: var(--ink);
  padding: .75rem 1rem;
  font-weight: 700;
}

/* ---------- masthead ---------- */

.masthead {
  padding: 1.5rem var(--gutter) 1.25rem;
  border-bottom: 1px solid var(--line);
}
.masthead .network {
  margin: 0 0 .5rem;
  font-family: var(--mono);
  font-size: .8125rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--dim);
}
.masthead h1 {
  margin: 0;
  font-size: clamp(1.75rem, 7vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.05;
}
.masthead .sw {
  margin: .25rem 0 0;
  font-size: 1.0625rem;
  color: var(--dim);
}

/* ---------- call the real emergency services first ---------- */

.call-first {
  background: var(--ink-2);
  border-bottom: 1px solid var(--line);
  padding: 1.25rem var(--gutter);
}
.call-first h2 {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.3;
}
.call-first .sw {
  margin: .2rem 0 .9rem;
  color: var(--dim);
  font-size: .9375rem;
}
.numbers {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: .5rem;
}
.numbers a {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 3.75rem;
  padding: .5rem .75rem;
  background: var(--slate);
  border: 1px solid var(--line);
  color: var(--bone);
  text-decoration: none;
}
.numbers a:active { background: var(--slate-hi); }
.numbers .num {
  font-family: var(--mono);
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--hazard);
}
.numbers .who {
  font-size: .75rem;
  color: var(--dim);
  line-height: 1.25;
}
.call-first .note {
  margin: .9rem 0 0;
  font-size: .8125rem;
  color: var(--dim);
}

/* ---------- errors ---------- */

.errors {
  background: var(--signal);
  color: #fff;
  padding: 1rem var(--gutter);
}
.errors p { margin: 0 0 .35rem; font-weight: 700; }
.errors ul { margin: 0; padding-left: 1.1rem; }

/* ---------- the signature rule ---------- */

hr.hazard {
  height: .625rem;
  border: 0;
  margin: 0;
  background: repeating-linear-gradient(
    135deg,
    var(--hazard) 0 .875rem,
    var(--ink) .875rem 1.75rem
  );
  opacity: .85;
}

/* ---------- form scaffolding ---------- */

.report-form { margin: 0; }

.step {
  margin: 0;
  padding: 1.5rem 0 1.75rem;
  border: 0;
}
.step.is-locked { display: none; }

.step > legend {
  display: block;
  width: 100%;
  padding: 0 var(--gutter) 1rem;
  font-size: 1.375rem;
  font-weight: 800;
  letter-spacing: -.015em;
}
.step > legend .n {
  display: inline-block;
  min-width: 1.75rem;
  margin-right: .5rem;
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--hazard);
}
.step > legend em {
  display: block;
  margin-left: 2.25rem;
  font-style: normal;
  font-size: .9375rem;
  font-weight: 400;
  color: var(--dim);
}
.step > legend .opt {
  margin-left: .5rem;
  font-family: var(--mono);
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--dim);
  vertical-align: middle;
}

/* radios are removed from view but stay in the tab order */
.type input, .area input, .urg input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

/* ---------- 1. what is happening ---------- */

.types {
  display: block;
  border-top: 1px solid var(--line);
}
.type {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: var(--tap);
  padding: .75rem var(--gutter);
  background: var(--ink);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.type .glyph {
  font-size: 1.75rem;
  line-height: 1;
  width: 2rem;
  text-align: center;
  flex: none;
}
.type .words { display: flex; flex-direction: column; }
.type .sw-label {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -.01em;
  line-height: 1.1;
}
.type .en-label {
  font-size: .875rem;
  color: var(--dim);
}
.type.is-chosen,
.type:has(input:checked) {
  background: var(--slate-hi);
  box-shadow: inset .375rem 0 0 var(--hazard);
}
.type.is-chosen .en-label,
.type:has(input:checked) .en-label { color: var(--bone); }

/* ---------- 2. where ---------- */

.areas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: 1px;
  background: var(--line);
  border-block: 1px solid var(--line);
  margin-bottom: 1.25rem;
}
.area {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 3.5rem;
  padding: .5rem;
  background: var(--ink);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.area.is-chosen,
.area:has(input:checked) {
  background: var(--hazard);
  color: var(--ink);
  font-weight: 800;
}

/* ---------- 3. urgency ---------- */

.urgency { border-top: 1px solid var(--line); }
.urg {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  padding: .75rem var(--gutter);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.urg .words { display: flex; flex-direction: column; }
.urg .en-label { font-size: 1.125rem; font-weight: 700; line-height: 1.2; }
.urg .sw-label { font-size: .875rem; color: var(--dim); }
.urg.is-chosen,
.urg:has(input:checked) { background: var(--slate-hi); }
.urg-critical.is-chosen,
.urg-critical:has(input:checked) { box-shadow: inset .375rem 0 0 var(--signal); }
.urg-high.is-chosen,
.urg-high:has(input:checked) { box-shadow: inset .375rem 0 0 var(--hazard); }
.urg-medium.is-chosen,
.urg-medium:has(input:checked) { box-shadow: inset .375rem 0 0 var(--dim); }

/* ---------- fields ---------- */

.field {
  display: block;
  padding: 0 var(--gutter) 1.25rem;
}
.field .label,
.who-you-are .label {
  display: block;
  margin-bottom: .4rem;
  font-size: 1rem;
  font-weight: 700;
}
.field .label em,
.who-you-are .label em {
  font-style: normal;
  font-weight: 400;
  color: var(--dim);
  margin-left: .4rem;
}
.field input[type=text],
.field input[type=tel],
.field textarea {
  display: block;
  width: 100%;
  min-height: 3.25rem;
  padding: .75rem;
  background: var(--slate);
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--bone);
  font-family: var(--sans);
  font-size: 1.0625rem;
}
.field textarea { min-height: 5.5rem; resize: vertical; }
.field input::placeholder,
.field textarea::placeholder { color: #6C7787; }
.field input[type=file] {
  width: 100%;
  padding: .75rem 0;
  font-size: .9375rem;
  color: var(--dim);
}
.field .hint {
  display: block;
  margin-top: .4rem;
  font-size: .8125rem;
  color: var(--dim);
}

.who-you-are {
  margin: .5rem var(--gutter) 0;
  padding: 1rem 0 .25rem;
  border-top: 1px solid var(--line);
}
.who-you-are .hint {
  margin: 0 0 1rem;
  font-size: .875rem;
  color: var(--dim);
}
.who-you-are .field { padding-inline: 0; }

/* ---------- gps ---------- */

.gps {
  margin: 0;
  padding: 0 var(--gutter) .5rem;
}
.gps .gps-msg {
  display: block;
  margin-top: .4rem;
  font-size: .8125rem;
  color: var(--dim);
}
.gps.is-found .gps-msg { color: var(--go); }
.gps.is-failed .gps-msg { color: var(--hazard); }

button.ghost {
  min-height: 3rem;
  padding: .6rem 1rem;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--bone);
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
button.ghost:active { background: var(--slate); }

/* ---------- send ---------- */

.send-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: .75rem var(--gutter) calc(.75rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--ink) 70%, transparent);
}
.send {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .1rem;
  width: 100%;
  min-height: 5rem;
  padding: 1rem;
  background: var(--signal);
  border: 0;
  color: #fff;
  font-family: var(--sans);
  cursor: pointer;
}
.send:active { background: var(--signal-hot); }
.send[aria-busy=true] { opacity: .7; }
.send-en {
  font-size: 1.375rem;
  font-weight: 800;
  letter-spacing: -.01em;
}
.send-sw {
  font-size: .9375rem;
  opacity: .85;
}

/* ---------- foot ---------- */

.foot {
  padding: 1.5rem var(--gutter) 0;
  border-top: 1px solid var(--line);
}
.foot a { color: var(--hazard); font-weight: 600; }
.foot .tiny {
  font-size: .8125rem;
  color: var(--dim);
}

/* ---------- confirmation ---------- */

.confirm-wrap { padding: 0 var(--gutter); }
.confirm-mark {
  margin: 2rem 0 1rem;
  font-size: clamp(1.75rem, 7vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.05;
}
.confirm-mark .sw {
  display: block;
  font-size: 1.0625rem;
  font-weight: 400;
  color: var(--dim);
}
.code-block {
  margin: 1.5rem 0;
  padding: 1.25rem;
  background: var(--slate);
  border: 1px solid var(--line);
  border-left: .375rem solid var(--hazard);
  text-align: center;
}
.code-block .code-label {
  display: block;
  font-family: var(--mono);
  font-size: .75rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--dim);
}
.code-block .code {
  display: block;
  margin-top: .5rem;
  font-family: var(--mono);
  font-size: clamp(2rem, 11vw, 3rem);
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--hazard);
}
.what-next {
  margin: 1.5rem 0;
  padding: 0;
  list-style: none;
  counter-reset: nx;
}
.what-next li {
  position: relative;
  counter-increment: nx;
  padding: .875rem 0 .875rem 2.5rem;
  border-bottom: 1px solid var(--line);
}
.what-next li::before {
  content: counter(nx);
  position: absolute;
  left: 0;
  top: .875rem;
  font-family: var(--mono);
  font-weight: 700;
  color: var(--hazard);
}
.status-line {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1rem;
  margin: 1rem 0;
  font-family: var(--mono);
  font-size: .9375rem;
}
.status-line dt { color: var(--dim); }
.status-line dd { margin: 0 1.5rem 0 0; font-weight: 700; }

.again {
  display: block;
  width: 100%;
  min-height: 3.5rem;
  margin: 1.5rem 0;
  padding: 1rem;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--bone);
  font-size: 1.0625rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  line-height: 1.5rem;
}

/* ---------- track ---------- */

.track-form { padding: 1.5rem var(--gutter); }
.track-form input[type=text] {
  width: 100%;
  min-height: 3.75rem;
  padding: .75rem;
  background: var(--slate);
  border: 1px solid var(--line);
  color: var(--bone);
  font-family: var(--mono);
  font-size: 1.5rem;
  letter-spacing: .1em;
  text-align: center;
  text-transform: uppercase;
}
.track-form button {
  width: 100%;
  min-height: 3.75rem;
  margin-top: .75rem;
  background: var(--hazard);
  border: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.125rem;
  font-weight: 800;
  cursor: pointer;
}

/* ---------- accessibility floor ---------- */

:where(a, button, input, textarea, select, label):focus-visible {
  outline: 3px solid var(--hazard);
  outline-offset: 2px;
}

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

@media (min-width: 46rem) {
  :root { --gutter: 2rem; }
  body.report {
    max-width: 46rem;
    margin: 0 auto;
    border-inline: 1px solid var(--line);
  }
  .send-bar { max-width: 46rem; margin: 0 auto; }
}
