/*
 * preppers.world
 *
 * One stylesheet, no framework, no preprocessor. Everything below is either
 * layout or the small number of tokens the layout is built from.
 *
 * The palette is deliberately dark and low-chroma: this site is read on a
 * phone, outdoors, next to a map, and every saturated colour is reserved for
 * meaning — a blast ring, a flood edge, a severity tone. Nothing decorative
 * competes with the map.
 */

:root {
  --bg: #0d1013;
  --bg-panel: #14181d;
  --bg-raised: #1b2027;
  --bg-input: #0f1317;
  --line: #262c34;
  --line-strong: #38414c;

  --text: #e6e3dc;
  --text-dim: #9aa1aa;
  --text-faint: #6b727b;

  --accent: #d98a3a;
  --accent-dim: #8a5a26;

  --critical: #e0603f;
  --warning: #d9a441;
  --good: #6fb07a;

  --panel-width: 25rem;
  --topbar-height: 3.25rem;
  --radius: 4px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden; /* the panels scroll, the page does not */
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: #e9a75f; }

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.05em 0.35em;
}

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

.muted { color: var(--text-dim); }
.small { font-size: 0.82rem; line-height: 1.5; }
.block { display: block; }

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */

.topbar {
  flex: 0 0 var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* A compass rose reduced to two strokes — enough to read as "navigation"
   without shipping an icon font for a single glyph. */
.brand-mark {
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid var(--accent);
  border-radius: 50%;
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 2px 45% 45% 45%;
  background: var(--accent);
}
.brand-dot { color: var(--accent); }

.nav { display: flex; gap: 0.25rem; }

.nav button {
  appearance: none;
  border: 1px solid transparent;
  background: none;
  color: var(--text-dim);
  font: inherit;
  font-size: 0.9rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
}
.nav button:hover { color: var(--text); background: var(--bg-raised); }
.nav button.is-active {
  color: var(--text);
  background: var(--bg-raised);
  border-color: var(--line-strong);
}

/* --------------------------------------------------------------------------
   View layout
   -------------------------------------------------------------------------- */

.view {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--panel-width) 1fr;
}
.view[hidden] { display: none; }

.view-privacy { grid-template-columns: 1fr; overflow-y: auto; }

.panel {
  min-height: 0;
  overflow-y: auto;
  background: var(--bg-panel);
  border-right: 1px solid var(--line);
  overscroll-behavior: contain;
}

.panel-section {
  padding: 1.1rem 1.15rem;
  border-bottom: 1px solid var(--line);
}

.panel-section h2 {
  margin: 0 0 0.75rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.panel-footer { padding: 1.1rem 1.15rem 2rem; }

/* --------------------------------------------------------------------------
   Setup notice
   -------------------------------------------------------------------------- */

.notice {
  margin: 1rem 1.15rem;
  padding: 0.9rem 1rem;
  background: rgba(217, 138, 58, 0.09);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
}
.notice h2 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--accent);
}
.notice p { margin: 0 0 0.6rem; font-size: 0.87rem; }

.setup-form label { display: block; font-size: 0.82rem; color: var(--text-dim); margin-bottom: 0.3rem; }
.setup-row { display: flex; gap: 0.4rem; }
.setup-row input { flex: 1 1 auto; min-width: 0; }
.setup-row button {
  flex: 0 0 auto;
  background: var(--accent);
  color: #17130d;
  border: none;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  padding: 0 0.8rem;
  cursor: pointer;
}
.setup-form .muted { margin: 0.45rem 0 0; }

/* --------------------------------------------------------------------------
   Form controls
   -------------------------------------------------------------------------- */

input[type="text"],
input[type="search"],
select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.6rem;
}
input:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.search-form .muted { margin: 0.4rem 0 0; }

.search-results {
  margin-top: 0.4rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
}
.search-result {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--bg-input);
  border: none;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font: inherit;
  font-size: 0.87rem;
  padding: 0.5rem 0.6rem;
  cursor: pointer;
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--bg-raised); }
.search-error { margin: 0; padding: 0.5rem 0.6rem; font-size: 0.85rem; color: var(--critical); }

.location-readout {
  margin-top: 0.8rem;
  padding: 0.6rem 0.7rem;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.9rem;
}
.location-readout strong { font-family: var(--font-mono); font-size: 0.9rem; }
.location-readout .muted { font-size: 0.78rem; margin-top: 0.2rem; }

.link-button {
  margin-top: 0.5rem;
  background: none;
  border: none;
  color: var(--text-dim);
  font: inherit;
  font-size: 0.82rem;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
  cursor: pointer;
}
.link-button:hover { color: var(--text); }

/* --------------------------------------------------------------------------
   Scenario picker
   -------------------------------------------------------------------------- */

.scenario-list { display: flex; flex-direction: column; gap: 0.4rem; }

.scenario-option {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-align: left;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  padding: 0.6rem 0.7rem;
  cursor: pointer;
}
.scenario-option:hover { background: var(--bg-raised); }
.scenario-option.is-active {
  border-left-color: var(--accent);
  background: var(--bg-raised);
}
.scenario-title { font-weight: 600; font-size: 0.92rem; }
.scenario-description { font-size: 0.8rem; color: var(--text-dim); line-height: 1.45; }

/* --------------------------------------------------------------------------
   Parameters
   -------------------------------------------------------------------------- */

.params { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.9rem; }
.param-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
}
.param-value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
}
.param-help { margin: 0.35rem 0 0; font-size: 0.78rem; color: var(--text-faint); line-height: 1.45; }

input[type="range"] {
  width: 100%;
  height: 1.5rem;
  background: none;
  appearance: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px; background: var(--line-strong); border-radius: 2px;
}
input[type="range"]::-moz-range-track {
  height: 3px; background: var(--line-strong); border-radius: 2px;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 1rem; height: 1rem;
  margin-top: -0.4rem;
  background: var(--accent);
  border-radius: 50%;
  border: none;
}
input[type="range"]::-moz-range-thumb {
  width: 1rem; height: 1rem;
  background: var(--accent);
  border-radius: 50%;
  border: none;
}

.run-button {
  margin-top: 1rem;
  width: 100%;
  background: var(--accent);
  color: #17130d;
  border: none;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.6rem;
  cursor: pointer;
}
.run-button:hover:not(:disabled) { background: #e9a75f; }
.run-button:disabled { background: var(--bg-raised); color: var(--text-faint); cursor: not-allowed; }

.run-status {
  margin: 0.6rem 0 0;
  font-size: 0.83rem;
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   Results
   -------------------------------------------------------------------------- */

.result-headline {
  margin: 0 0 0.9rem;
  font-size: 1rem;
  line-height: 1.45;
  font-weight: 600;
}

.facts { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 0.3rem 0.75rem; }
.facts dt {
  font-size: 0.83rem;
  color: var(--text-dim);
  align-self: baseline;
}
.facts dd {
  margin: 0;
  text-align: right;
  font-size: 0.86rem;
  font-weight: 600;
  align-self: baseline;
}
.tone-critical { color: var(--critical); }
.tone-warning { color: var(--warning); }
.tone-good { color: var(--good); }
.tone-neutral { color: var(--text); }

.result-section { margin-top: 1.1rem; }
.result-section h4 {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.result-section ul { margin: 0; padding-left: 1.05rem; }
.result-section li { font-size: 0.85rem; line-height: 1.5; margin-bottom: 0.45rem; }

.result-section summary {
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-dim);
  padding: 0.2rem 0;
}
.result-section summary:hover { color: var(--text); }
details.result-section ul { margin-top: 0.5rem; }
details.result-section li { color: var(--text-dim); font-size: 0.81rem; }

.result-meta {
  margin: 1.1rem 0 0;
  font-size: 0.75rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.result-error {
  border-left: 3px solid var(--critical);
  padding-left: 0.75rem;
}
.result-error h3 { margin: 0 0 0.35rem; font-size: 0.95rem; color: var(--critical); }
.result-error p { margin: 0; font-size: 0.87rem; color: var(--text-dim); }

.confirmation {
  color: var(--good);
  font-size: 0.9rem;
}

/* --------------------------------------------------------------------------
   Map
   -------------------------------------------------------------------------- */

.map-wrap { position: relative; min-height: 0; }
.map { position: absolute; inset: 0; background: #161a1f; }

.map-controls {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-start;
  background: rgba(13, 16, 19, 0.9);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0.5rem;
  backdrop-filter: blur(6px);
}

.control-group { display: flex; }
.control-group button {
  background: var(--bg-input);
  border: 1px solid var(--line-strong);
  color: var(--text-dim);
  font: inherit;
  font-size: 0.8rem;
  padding: 0.28rem 0.6rem;
  cursor: pointer;
}
.control-group button:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.control-group button:last-child { border-radius: 0 var(--radius) var(--radius) 0; border-left: none; }
.control-group button.is-active { background: var(--accent); color: #17130d; border-color: var(--accent); }

.control-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  cursor: pointer;
}
.control-toggle input { accent-color: var(--accent); }

/* Live layer readout: sits under the map controls, quiet until it has
   something to say. The resolution it reports is the honest counterweight to a
   layer that redraws itself at every zoom. */
.live-status {
  margin: 0.15rem 0 0;
  max-width: 15rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 0.74rem;
  line-height: 1.35;
}
.live-status.is-error { color: var(--warning); }

/* The picked-location pin. Drawn in CSS rather than loaded as an image: it is
   two shapes, and a request for a 400-byte PNG is not worth making. */
.pin {
  width: 1.1rem;
  height: 1.1rem;
  background: var(--accent);
  border: 2px solid #17130d;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 0 0 1px rgba(217, 138, 58, 0.4), 0 2px 6px rgba(0, 0, 0, 0.6);
}

.maplibregl-ctrl-attrib { font-size: 10px; }

/* --------------------------------------------------------------------------
   Guides
   -------------------------------------------------------------------------- */

.guide-list { display: flex; flex-direction: column; gap: 0.4rem; }
.guide-option {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-align: left;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  padding: 0.6rem 0.7rem;
  cursor: pointer;
}
.guide-option:hover { background: var(--bg-raised); }
.guide-option.is-active { border-left-color: var(--accent); background: var(--bg-raised); }
.guide-title { font-weight: 600; font-size: 0.9rem; }
.guide-summary { font-size: 0.79rem; color: var(--text-dim); line-height: 1.45; }

.guide-body {
  min-height: 0;
  overflow-y: auto;
  padding: 2rem 2.5rem 4rem;
}

/* --------------------------------------------------------------------------
   Long-form typography, shared by guides and the privacy page
   -------------------------------------------------------------------------- */

.guide-body, .prose {
  max-width: 46rem;
  margin: 0 auto;
}
.prose { padding: 2.5rem 1.5rem 5rem; }

.guide-body h1, .prose h1 {
  font-size: 1.7rem;
  line-height: 1.25;
  margin: 0 0 0.75rem;
}
.guide-body h2, .prose h2 {
  font-size: 1.1rem;
  margin: 2rem 0 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
}
.guide-body h3, .prose h3 { font-size: 0.98rem; margin: 1.4rem 0 0.4rem; }
.guide-body p, .prose p { margin: 0 0 0.9rem; }
.guide-body ul, .guide-body ol, .prose ul, .prose ol { margin: 0 0 1rem; padding-left: 1.3rem; }
.guide-body li, .prose li { margin-bottom: 0.4rem; }

.lede { font-size: 1.05rem; color: var(--text-dim); }

.guide-body blockquote {
  margin: 1.2rem 0;
  padding: 0.1rem 0 0.1rem 1rem;
  border-left: 3px solid var(--accent-dim);
  color: var(--text-dim);
}

.guide-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2rem 0;
  font-size: 0.87rem;
}
.guide-body th, .guide-body td {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--line);
}
.guide-body th { color: var(--text-faint); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }

.guide-meta { font-size: 0.8rem; color: var(--text-faint); margin-bottom: 1.5rem; }

/* --------------------------------------------------------------------------
   Narrow screens
   --------------------------------------------------------------------------
   The map and the controls swap from side-by-side to stacked. The map keeps a
   fixed share of the viewport rather than shrinking to nothing, because a map
   you cannot see is worse than a shorter panel.
   -------------------------------------------------------------------------- */

@media (max-width: 62rem) {
  body { overflow: auto; }

  .view {
    grid-template-columns: 1fr;
    grid-template-rows: 55vh auto;
  }

  .view-explorer { display: flex; flex-direction: column-reverse; }
  .map-wrap { flex: 0 0 55vh; position: relative; }
  .panel {
    border-right: none;
    border-top: 1px solid var(--line);
    overflow: visible;
  }

  .view-guides { display: flex; flex-direction: column; }
  .guide-body { padding: 1.5rem 1.25rem 3rem; overflow: visible; }
  .prose { padding: 1.5rem 1.25rem 3rem; }
}

/* Phone widths: the brand plus three nav buttons overflowed 390 px at full
   size. Tightening the nav rather than hiding it keeps every section reachable. */
@media (max-width: 26rem) {
  .topbar { padding: 0 0.6rem; gap: 0.5rem; }
  .brand { font-size: 0.92rem; }
  .nav button { padding: 0.35rem 0.45rem; font-size: 0.82rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
