/*
  lyngbrannkart.no
  ------------
  Visual language: a piece of field equipment, not a web app. Wet peat and
  granite for the ground, birch-bone for text, and ember orange used sparingly
  and only where fire is meant: the ignition targets. Everything numeric is set
  in a monospace so coordinates and elevations line up the way they do on a map
  sheet. Hairline borders and small radii keep it instrument-like rather than
  soft.
*/

:root {
  --ash-950:#0a0c0b; --ash-900:#0e1211; --ash-850:#131817; --ash-800:#171d1c;
  --ash-700:#1e2624; --ash-600:#2a3431; --ash-500:#3a4642; --ash-400:#54615c;
  --moss:#7c8b84; --bone:#e9e5da; --bone-dim:#b9b3a6;

  --ember:#ff6a1f; --ember-hi:#ff9350; --ember-lo:#c44a10;
  --ember-glow:rgba(255,106,31,.4);
  --signal:#ef4a4a; --amber:#f0a52c; --sage:#79b872; --ice:#63a6d8;

  --rail-w: 396px;
  --hair: 1px solid var(--ash-600);
  --r: 3px;
  --shadow-lift: 0 2px 4px rgba(0,0,0,.5), 0 12px 32px rgba(0,0,0,.45);
  --font-ui: 'Archivo', 'Helvetica Neue', Helvetica, sans-serif;
  --font-num: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--ash-950); color: var(--bone);
  font-family: var(--font-ui); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
h1,h2,h3 { margin:0; font-weight:800; letter-spacing:-.02em; }
button { font-family: inherit; color: inherit; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--rail-w) 1fr; height: 100vh; }

.rail {
  background: var(--ash-900); border-right: var(--hair);
  display: flex; flex-direction: column; min-height: 0;
  position: relative; z-index: 500;
}
/* A faint contour texture, so the panel reads as a map margin, not a sidebar. */
.rail::before {
  content:''; position:absolute; inset:0; pointer-events:none; opacity:.5;
  background-image: repeating-linear-gradient(115deg, transparent 0 22px, rgba(124,139,132,.055) 22px 23px);
}
.rail > * { position: relative; }

.brand { padding: 18px 20px 16px; border-bottom: var(--hair); flex: none; }
.brand h1 {
  font-size: 21px; text-transform: uppercase; letter-spacing: .04em; line-height: 1;
  display: flex; align-items: baseline; gap: 2px;
}
.brand h1 .dot { color: var(--ember); }
.brand p { margin: 7px 0 0; color: var(--moss); font-size: 11.5px; letter-spacing:.03em; text-transform: uppercase; }

.scroll { overflow-y: auto; overscroll-behavior: contain; flex: 1; min-height: 0; }
.scroll::-webkit-scrollbar { width: 9px; }
.scroll::-webkit-scrollbar-thumb { background: var(--ash-600); border-radius: 9px; border: 2px solid var(--ash-900); }

section.block { padding: 16px 20px; border-bottom: var(--hair); }
.label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .14em;
  color: var(--moss); margin: 0 0 11px;
}

/* ---------- buttons ---------- */
.btn {
  appearance:none; border: var(--hair); background: var(--ash-800); color: var(--bone);
  padding: 9px 13px; border-radius: var(--r); cursor: pointer; font-size: 12.5px;
  font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .15s, border-color .15s, color .15s, transform .06s;
}
.btn:hover:not(:disabled) { background: var(--ash-700); border-color: var(--ash-500); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(178deg, var(--ember) 0%, var(--ember-lo) 100%);
  border-color: var(--ember-lo); color: #190c04;
  box-shadow: 0 0 0 0 var(--ember-glow);
}
.btn.primary:hover:not(:disabled) { background: linear-gradient(178deg, var(--ember-hi), var(--ember)); box-shadow: 0 0 20px -4px var(--ember-glow); }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; justify-content: center; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.active { border-color: var(--ember); color: var(--ember-hi); background: rgba(255,106,31,.09); }

/* ---------- drawing state ---------- */
.hint {
  font-size: 12.5px; color: var(--bone-dim); margin: 11px 0 0; line-height: 1.55;
  padding-left: 11px; border-left: 2px solid var(--ash-600);
}
.hint.live { border-left-color: var(--ember); color: var(--bone); }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--ash-600); border: var(--hair); border-radius: var(--r); overflow: hidden; }
.stat { background: var(--ash-850); padding: 10px 12px; }
.stat dt { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--moss); margin: 0 0 3px; }
.stat dd { margin: 0; font-family: var(--font-num); font-size: 17px; font-weight: 500; letter-spacing: -.02em; }
.stat dd small { font-size: 11px; color: var(--moss); font-weight: 400; margin-left: 2px; }

/* ---------- targets ---------- */
.target {
  display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center;
  padding: 11px 12px; border: var(--hair); border-radius: var(--r);
  background: var(--ash-850); margin-bottom: 7px; cursor: pointer;
  transition: border-color .15s, background .15s, transform .12s;
  animation: rise .42s cubic-bezier(.16,.84,.44,1) backwards;
}
@keyframes rise { from { opacity:0; transform: translateY(9px); } }
.target:hover { border-color: var(--ember-lo); background: var(--ash-800); transform: translateX(2px); }
.target.sel { border-color: var(--ember); background: rgba(255,106,31,.08); }

.step {
  width: 34px; height: 34px; display: grid; place-items: center;
  font-family: var(--font-num); font-weight: 600; font-size: 14px; color: #1a0d05;
  background: radial-gradient(circle at 34% 28%, var(--ember-hi), var(--ember) 55%, var(--ember-lo));
  clip-path: polygon(50% 0,93% 25%,93% 75%,50% 100%,7% 75%,7% 25%);
}
.target.avoid .step { background: radial-gradient(circle at 34% 28%, #9aa39e, #616b66 60%, #454d49); color:#0d100f; }

.t-main { min-width: 0; }
.t-elev { font-family: var(--font-num); font-size: 15.5px; font-weight: 500; }
.t-elev small { color: var(--moss); font-size: 11px; font-weight: 400; }
.t-meta { font-size: 11px; color: var(--moss); margin-top: 2px; display: flex; gap: 9px; flex-wrap: wrap; }
.t-meta b { color: var(--bone-dim); font-weight: 500; }
.tag {
  font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700;
  padding: 2px 5px; border-radius: 2px; border: 1px solid;
}
.tag.avoid { color: var(--amber); border-color: rgba(240,165,44,.4); background: rgba(240,165,44,.1); }
.tag.hazard { color: var(--signal); border-color: rgba(239,74,74,.4); background: rgba(239,74,74,.1); }
.tag.edge { color: var(--ice); border-color: rgba(99,166,216,.4); background: rgba(99,166,216,.1); }

/* ---------- notices ---------- */
.notice {
  border: var(--hair); border-left: 3px solid var(--ash-500); border-radius: var(--r);
  background: var(--ash-850); padding: 11px 13px; margin-bottom: 8px;
}
.notice.blocker { border-left-color: var(--signal); background: linear-gradient(90deg, rgba(239,74,74,.09), var(--ash-850) 62%); }
.notice.warning { border-left-color: var(--amber); }
.notice.info    { border-left-color: var(--sage); }
.notice h4 { margin: 0 0 5px; font-size: 12.5px; font-weight: 700; letter-spacing: 0; }
.notice p { margin: 0; font-size: 12px; color: var(--bone-dim); line-height: 1.55; }
.notice .act { margin-top: 7px; font-size: 11.5px; color: var(--moss); }
.notice .act::before { content: '→ '; color: var(--ember); }

/* ---------- wind dial ---------- */
.wind { display: flex; gap: 15px; align-items: center; }
.dial { flex: none; }
.dial .card { fill: none; stroke: var(--ash-500); stroke-width: 1; }
.dial .tick { stroke: var(--ash-500); stroke-width: 1; }
.dial .arrow { fill: var(--ice); }
.dial text { fill: var(--moss); font-family: var(--font-num); font-size: 8px; }
.wind-read { min-width: 0; }
.wind-read .big { font-family: var(--font-num); font-size: 22px; font-weight: 500; letter-spacing: -.02em; }
.wind-read .big small { font-size: 12px; color: var(--moss); }
.wind-read .sub { font-size: 11.5px; color: var(--moss); margin-top: 1px; }
.pill { display:inline-block; font-size:10px; font-weight:700; letter-spacing:.1em; text-transform:uppercase; padding:2px 7px; border-radius:20px; border:1px solid; margin-top:6px; }
.pill.good { color: var(--sage); border-color: rgba(121,184,114,.45); background: rgba(121,184,114,.1); }
.pill.caution { color: var(--amber); border-color: rgba(240,165,44,.45); background: rgba(240,165,44,.1); }
.pill.danger { color: var(--signal); border-color: rgba(239,74,74,.45); background: rgba(239,74,74,.1); }
.pill.unknown { color: var(--moss); border-color: var(--ash-500); }

/* ---------- terrain bar ---------- */
.tbar { display: flex; height: 9px; border-radius: 2px; overflow: hidden; border: var(--hair); }
.tbar span { display: block; }
.tlegend { margin-top: 9px; display: grid; gap: 4px; }
.tlegend div { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--bone-dim); }
.tlegend i { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.tlegend em { margin-left: auto; font-family: var(--font-num); font-style: normal; color: var(--moss); }

/* ---------- map ---------- */
.map-wrap { position: relative; }
#map { position: absolute; inset: 0; background: var(--ash-950); }
.leaflet-container { font-family: var(--font-ui); background: var(--ash-950); }
.leaflet-control-attribution { display: none; }

.map-tools {
  position: absolute; top: 14px; right: 14px; z-index: 600;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.card {
  background: rgba(14,18,17,.93); backdrop-filter: blur(9px);
  border: var(--hair); border-radius: var(--r); box-shadow: var(--shadow-lift);
}
.layer-switch { display: flex; padding: 3px; gap: 3px; }
.layer-switch button {
  border: 0; background: transparent; padding: 6px 10px; border-radius: 2px;
  font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--moss); cursor: pointer;
}
.layer-switch button:hover { color: var(--bone); }
.layer-switch button.on { background: var(--ash-700); color: var(--ember-hi); }

.readout {
  position: absolute; left: 14px; bottom: 14px; z-index: 600;
  padding: 8px 12px; font-family: var(--font-num); font-size: 11.5px; color: var(--bone-dim);
}
.readout b { color: var(--bone); font-weight: 500; }
.readout .attr { color: var(--ash-400); font-size: 10px; margin-top: 4px; font-family: var(--font-ui); letter-spacing:.02em; }
.readout a { color: var(--moss); }

/* ---------- markers ---------- */
.pin { position: relative; }
.pin .core {
  width: 30px; height: 30px; display: grid; place-items: center;
  font-family: var(--font-num); font-weight: 600; font-size: 13px; color: #1a0d05;
  background: radial-gradient(circle at 34% 28%, var(--ember-hi), var(--ember) 55%, var(--ember-lo));
  clip-path: polygon(50% 0,93% 25%,93% 75%,50% 100%,7% 75%,7% 25%);
  box-shadow: 0 0 14px -1px var(--ember-glow);
}
.pin.avoid .core { background: radial-gradient(circle at 34% 28%, #9aa39e, #616b66 60%, #454d49); box-shadow:none; }
.pin .halo {
  position: absolute; inset: -9px; border-radius: 50%; border: 1px solid var(--ember);
  opacity: 0; animation: ping 2.6s ease-out infinite;
}
.pin.sel .halo { animation-duration: 1.3s; }
@keyframes ping { 0% { transform: scale(.55); opacity: .8; } 70%,100% { transform: scale(1.35); opacity: 0; } }
.pin .flag {
  position: absolute; left: 36px; top: 4px; white-space: nowrap;
  font-family: var(--font-num); font-size: 11px; color: var(--bone);
  background: rgba(14,18,17,.9); border: var(--hair); border-radius: 2px; padding: 1px 6px;
}

/* ---------- progress ---------- */
.progress { height: 2px; background: var(--ash-700); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--ember-lo), var(--ember-hi)); transition: width .2s; }

.empty { color: var(--moss); font-size: 12.5px; line-height: 1.6; }
.err { color: var(--signal); font-size: 12.5px; }

/* ---------- responsive ---------- */
@media (max-width: 940px) {
  body { overflow: auto; }
  .app { grid-template-columns: 1fr; grid-template-rows: 46vh 1fr; height: 100vh; }
  .rail { grid-row: 2; border-right: 0; border-top: var(--hair); }
  .map-wrap { grid-row: 1; }
  :root { --rail-w: 100%; }
}

/* ---------- burn routes (phase two) ---------- */
.unit {
  border: var(--hair); border-top: 0; border-radius: 0 0 var(--r) var(--r);
  background: var(--ash-900); padding: 11px 12px 9px; margin: -8px 0 9px;
}
.unit-head { font-size: 11.5px; color: var(--moss); margin-bottom: 9px; }
.unit-head b { color: var(--bone-dim); font-family: var(--font-num); font-weight: 500; }

.phases { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.phases li { display: grid; grid-template-columns: 3px 1fr; gap: 10px; }
.phases i { display: block; border-radius: 2px; }
.p-title {
  font-size: 12px; font-weight: 600; color: var(--bone);
  display: flex; gap: 8px; align-items: baseline;
}
.p-title em {
  margin-left: auto; font-style: normal; font-family: var(--font-num);
  font-size: 11px; color: var(--moss); font-weight: 400; white-space: nowrap;
}
.phases p { margin: 2px 0 0; font-size: 11.5px; color: var(--bone-dim); line-height: 1.5; }
.unit-note {
  margin: 9px 0 0; font-size: 11px; color: var(--moss);
  padding-left: 9px; border-left: 2px solid var(--ash-600);
}
