/* OffBeat — Windows 98 look: MS Sans Serif 8pt, #c0c0c0 face, two-line bevels. */
/* W95FA by Alina Sava: a pixel re-creation of MS Sans Serif, SIL OFL 1.1 (fonts/W95FA-OFL.txt) */
@font-face {
  font-family: "W95FA";
  src: url("../fonts/w95fa.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: block;
}

:root {
  --desk: #3a6ea5;
  --face: #c0c0c0;
  --hi: #ffffff;   /* outer light */
  --lt: #dfdfdf;   /* inner light */
  --lo: #808080;   /* inner shadow */
  --dk: #000000;   /* outer shadow */
  --ink: #000000;
  --paper: #ffffff;
  --title-a: #000080;
  --title-b: #1084d0;
  --sel: #000080;
  --link: #0000ee;
  --ui: "W95FA", "MS Sans Serif", "Microsoft Sans Serif", Tahoma, Arial, "Liberation Sans", sans-serif;

  /* the four bevels every control is built from */
  --raised:  inset -1px -1px 0 var(--dk), inset 1px 1px 0 var(--hi), inset -2px -2px 0 var(--lo), inset 2px 2px 0 var(--lt);
  --pressed: inset -1px -1px 0 var(--hi), inset 1px 1px 0 var(--dk), inset -2px -2px 0 var(--lt), inset 2px 2px 0 var(--lo);
  --sunken:  inset -1px -1px 0 var(--hi), inset 1px 1px 0 var(--lo), inset -2px -2px 0 var(--lt), inset 2px 2px 0 var(--dk);
  --window:  inset -1px -1px 0 var(--dk), inset 1px 1px 0 var(--lt), inset -2px -2px 0 var(--lo), inset 2px 2px 0 var(--hi);

  --st-drop: #c00000;   /* HV drop: clearing, fire */
  --st-flood: #0050c8;  /* HH jump: flooded vegetation */
  --st-drift: #d86b00;  /* slow phase drift: subsidence */
  --st-step: #007a1f;   /* displacement step: earthquake */
}

* { box-sizing: border-box; }
html { background: var(--desk); }
body {
  margin: 0;
  padding: 12px 0 40px;
  background: var(--desk);
  color: var(--ink);
  font: 12.5px/16px var(--ui); /* W95FA sits on its pixel grid at 12.5px: 80 units = 1px */
  -webkit-font-smoothing: none;
  font-smooth: never;
}
button, input, select, textarea { font: inherit; }
a:link { color: var(--link); }
a:visited { color: #551a8b; }
h1, h2 { margin: 0; font: bold 12.5px/16px var(--ui); }
p { margin: 0 0 8px; }

.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 8px; top: 8px; z-index: 1000; background: #ffffe1; color: #000; padding: 6px 10px; border: 1px solid #000; }

#desk { width: 1000px; max-width: calc(100% - 16px); margin: 0 auto; }
#cols { display: grid; grid-template-columns: 220px 1fr; gap: 10px; align-items: start; }

/* --- window: 2px bevel, then 2px of face around the title bar --- */
.win {
  background: var(--face);
  box-shadow: var(--window);
  padding: 4px;
  margin-bottom: 10px;
}
.win-t {
  display: flex; align-items: center; gap: 4px;
  background: linear-gradient(90deg, var(--title-a), var(--title-b));
  color: #fff;
  padding: 2px 4px;
  min-height: 18px;
}
.win-t h1, .win-t h2 { flex: 1; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-t__icon { width: 16px; height: 16px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Crect width='16' height='16' fill='%23000'/%3E%3Cpath d='M1 10h3l1-5 2 9 2-7 1 3h5' fill='none' stroke='%23ffcc00' stroke-width='1.6'/%3E%3C/svg%3E"); }
.win-b { padding: 8px 6px 6px; }
.win-b--flush { padding: 4px 2px 2px; }

/* --- menu bar: flat, raises 1px on hover, sinks on press --- */
.menu { display: flex; flex-wrap: wrap; padding: 2px 0 0; }
.menu a { color: #000; text-decoration: none; padding: 3px 7px; }
.menu a:hover { box-shadow: inset -1px -1px 0 var(--lo), inset 1px 1px 0 var(--hi); }
.menu a:active { box-shadow: inset -1px -1px 0 var(--hi), inset 1px 1px 0 var(--lo); }

/* --- sunken surfaces: fields, lists, maps, plots --- */
.sunk, .paper, .grid, .props, .sites {
  border: 0; padding: 2px;
  box-shadow: var(--sunken);
  background: var(--paper);
}
.paper { padding: 8px 10px; line-height: 1.5; }
/* maps and plots paint over an inset shadow, so their bevel is a border plus an outer shadow */
.map, .plots canvas {
  border: 1px solid; border-color: var(--dk) var(--lt) var(--lt) var(--dk);
  box-shadow: -1px -1px 0 var(--lo), 1px 1px 0 var(--hi);
  margin: 1px;
}
.paper p:last-child { margin: 0; }

/* --- side controls --- */
.sites { list-style: none; margin: 0; }
.sites button {
  display: block; width: 100%; text-align: left; cursor: default;
  background: none; border: 0; padding: 4px 5px; color: #000;
}
.sites button small { display: block; color: #000; }
.sites button[aria-pressed="true"], .sites button[aria-pressed="true"] small { background: var(--sel); color: #fff; }
.place-search { display: grid; gap: 5px; }
.place-search input { min-width: 0; width: 100%; padding: 4px; border: 0; background: #fff; box-shadow: var(--sunken); font: inherit; }
.place-search .btn { justify-self: start; }
.place-hint { margin: 6px 0; }
#place-status:empty { display: none; }
.place-results { list-style: none; padding: 0; margin: 4px 0; }
.place-results button { width: 100%; text-align: left; font: inherit; padding: 5px; border: 0; background: #fff; cursor: pointer; }
.place-results button:hover, .place-results button:focus-visible { background: var(--sel); color: #fff; }

/* group box: etched line, grey then white */
.group {
  margin: 0 0 8px; padding: 6px 8px 8px;
  border: 1px solid var(--lo);
  box-shadow: inset 1px 1px 0 var(--hi), 1px 1px 0 var(--hi);
}
.group:last-child { margin-bottom: 0; }
.group legend { padding: 0 2px; }
.group label { display: flex; align-items: center; gap: 6px; padding: 2px 0; }

/* checkbox: white sunken square, black tick */
input[type="checkbox"] {
  -webkit-appearance: none; appearance: none; margin: 0;
  width: 13px; height: 13px; flex: none;
  background: var(--paper); box-shadow: var(--sunken);
}
input[type="checkbox"]:checked {
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='7' height='7' shape-rendering='crispEdges'%3E%3Cpath d='M6 0v3L3 6H2L0 4V1l2 2h1l3-3z'/%3E%3C/svg%3E") 3px 3px no-repeat;
}
input[type="checkbox"]:focus-visible { outline: 1px dotted #000; outline-offset: 2px; }

/* Win98 trackbar: sunken groove, pointed thumb, ticks under it */
.slider { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: start; margin-top: 4px; }
.slider > span { line-height: 21px; }
.slider__rail { min-width: 0; }
.slider__ticks {
  height: 4px; margin: 1px 5px 0;
  background: linear-gradient(90deg, #000 1px, transparent 1px) 0 0 / calc((100% - 1px) / 9) 100% repeat-x;
}
input[type="range"] { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 21px; margin: 0; background: transparent; cursor: default; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: var(--face); box-shadow: var(--sunken); }
input[type="range"]::-moz-range-track { height: 4px; background: var(--face); box-shadow: var(--sunken); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 11px; height: 21px; margin-top: -8px; border: 0; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='21' viewBox='0 0 11 21'%3E%3Cpath d='M0 0h11v16l-5.5 5L0 16z' fill='%23c0c0c0'/%3E%3Cpath d='M.5 16V.5h9.5' fill='none' stroke='%23fff' shape-rendering='crispEdges'/%3E%3Cpath d='M1.5 15.5v-14h7.5' fill='none' stroke='%23dfdfdf' shape-rendering='crispEdges'/%3E%3Cpath d='M10.5 0v16' fill='none' stroke='%23000' shape-rendering='crispEdges'/%3E%3Cpath d='M9.5 1v15' fill='none' stroke='%23808080' shape-rendering='crispEdges'/%3E%3Cpath d='M.5 16l5 4.5' fill='none' stroke='%23fff'/%3E%3Cpath d='M10.5 16l-5 4.5' fill='none' stroke='%23000'/%3E%3Cpath d='M9.5 15.5l-4 3.6' fill='none' stroke='%23808080'/%3E%3C/svg%3E"); }
input[type="range"]::-moz-range-thumb { width: 11px; height: 21px; border: 0; border-radius: 0; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='21' viewBox='0 0 11 21'%3E%3Cpath d='M0 0h11v16l-5.5 5L0 16z' fill='%23c0c0c0'/%3E%3Cpath d='M.5 16V.5h9.5' fill='none' stroke='%23fff' shape-rendering='crispEdges'/%3E%3Cpath d='M1.5 15.5v-14h7.5' fill='none' stroke='%23dfdfdf' shape-rendering='crispEdges'/%3E%3Cpath d='M10.5 0v16' fill='none' stroke='%23000' shape-rendering='crispEdges'/%3E%3Cpath d='M9.5 1v15' fill='none' stroke='%23808080' shape-rendering='crispEdges'/%3E%3Cpath d='M.5 16l5 4.5' fill='none' stroke='%23fff'/%3E%3Cpath d='M10.5 16l-5 4.5' fill='none' stroke='%23000'/%3E%3Cpath d='M9.5 15.5l-4 3.6' fill='none' stroke='%23808080'/%3E%3C/svg%3E"); }
input[type="range"]:focus { outline: none; }
input[type="range"]:focus-visible { outline: 1px dotted #000; outline-offset: 1px; }

.legend { margin-top: 6px; }
.legend__ramp { height: 10px; margin-top: 3px; box-shadow: var(--sunken); }
.legend__ends { display: flex; justify-content: space-between; }

.styles { list-style: none; margin: 0; padding: 0; }
.styles li { display: grid; grid-template-columns: 13px 1fr; gap: 6px; padding: 3px 0; align-items: start; }
.styles .dot { width: 11px; height: 11px; margin-top: 1px; border: 1px solid #000; }
.styles b { display: block; }

/* --- maps --- */
.maps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.maps__pane { display: flex; flex-direction: column; min-width: 0; }
.maps__pane > .pane-label { flex: 1; }
.maps__pane > .map { flex-shrink: 0; }
.pane-label { padding: 2px 2px 3px; }
.map { height: 360px; }
.leaflet-container { font: 12.5px/16px var(--ui); background: #808080; }
#map .context-imagery { filter: grayscale(1) brightness(.72) contrast(1.05); }
.area-label { width: max-content !important; white-space: nowrap; pointer-events: none; transform-origin: center; }
.area-label span { display: block; transform: translate(-50%, -100%); padding: 1px 4px; background: #ffffe1; color: #000; border: 1px solid #000; font: 12.5px/16px var(--ui); }
.leaflet-container .leaflet-control-attribution {
  max-width: calc(100% - 8px); margin: 0; padding: 1px 4px; font: 12.5px/14px var(--ui); color: #000;
  background: var(--face); box-shadow: inset 1px 1px 0 var(--hi), inset -1px -1px 0 var(--lo);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;   /* one line; the full credits open on hover */
}
.leaflet-container .leaflet-control-attribution:hover { white-space: normal; }
.leaflet-container .leaflet-bottom.leaflet-right { left: 0; }                    /* the credits line may use the map's width, no more */
.leaflet-container .leaflet-bottom.leaflet-right .leaflet-control-attribution { float: right; max-width: 100%; }
.leaflet-container .leaflet-control-attribution a { color: #0000ee; }
.raster { image-rendering: pixelated; image-rendering: crisp-edges; }
#map { cursor: crosshair; }
.leaflet-bar { border: 0 !important; border-radius: 0 !important; box-shadow: none !important; }
.leaflet-bar a, .leaflet-bar a:hover {
  border: 0 !important; border-radius: 0 !important; margin-bottom: 1px;
  background: var(--face); color: #000; box-shadow: var(--raised); font: bold 12.5px/26px var(--ui);
}
.leaflet-bar a:active { box-shadow: var(--pressed); }
.leaflet-tooltip { background: #ffffe1; border: 1px solid #000; border-radius: 0; box-shadow: none; padding: 1px 4px; color: #000; }

/* --- pixel card --- */
.card { display: grid; grid-template-columns: 220px 1fr; gap: 8px; }
.props { width: 100%; border-collapse: separate; border-spacing: 0; align-self: start; }
.props th, .props td { text-align: left; padding: 3px 5px; vertical-align: top; }
.props th { width: 42%; font-weight: normal; color: #000; }
.props td { font-weight: bold; }
.plots { display: grid; gap: 6px; min-width: 0; }
.plots canvas { display: block; width: calc(100% - 2px); background: var(--paper); }
.sw { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin: 0 4px 0 1px; }
.sw--hh { background: var(--title-a); }
.sw--hv { background: var(--st-drop); }
.sw--peer { background: #b8b8b8; height: 8px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }

/* --- defaults: any control a teammate adds looks native to the page --- */
:where(button:not(.sites button):not(.sbar__sound)) {
  color: #000; background: var(--face); border: 0; border-radius: 0; cursor: default;
  padding: 4px 12px; min-height: 23px; box-shadow: var(--raised);
}
:where(button:not(.sites button):not(.sbar__sound)):active:not(:disabled) { box-shadow: var(--pressed); padding: 5px 11px 3px 13px; }
:where(button:not(.sites button):not(.sbar__sound)):disabled { color: var(--lo); text-shadow: 1px 1px 0 var(--hi); }
:where(button:not(.sites button):not(.sbar__sound)):focus { outline: none; }
:where(button:not(.sites button):not(.sbar__sound)):focus-visible { outline: 1px dotted #000; outline-offset: -4px; }
/* a toggle that is on: sunk in, on the light checkerboard Win98 used for latched buttons */
:where(button[aria-pressed="true"]:not(.sites button):not(.sbar__sound)) {
  box-shadow: var(--pressed);
  background: repeating-conic-gradient(var(--face) 0 25%, var(--hi) 0 50%) 0 0 / 2px 2px;
}
:where(input[type="text"], input[type="search"], input[type="number"], input:not([type]), select, textarea) {
  font: inherit; color: #000; background: var(--paper); border: 0; border-radius: 0;
  padding: 3px 4px; box-shadow: var(--sunken);
}
:where(input[type="search"])::-webkit-search-cancel-button { -webkit-appearance: none; }
:where(select) {
  -webkit-appearance: none; appearance: none; padding-right: 22px;
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='17' shape-rendering='crispEdges'%3E%3Crect width='16' height='17' fill='%23c0c0c0'/%3E%3Cpath d='M0 0h15M0 0v16' stroke='%23dfdfdf'/%3E%3Cpath d='M1 1h13M1 1v14' stroke='%23fff'/%3E%3Cpath d='M15 0v17M0 16h16' stroke='%23000'/%3E%3Cpath d='M14 1v15M1 15h14' stroke='%23808080'/%3E%3Cpath d='M4 7h7v1H4zM5 8h5v1H5zM6 9h3v1H6zM7 10h1v1H7z'/%3E%3C/svg%3E") right 2px center no-repeat;
}

/* --- push buttons: raised, sink on press, dotted focus inside --- */
.btn {
  color: #000; cursor: default;
  background: var(--face); padding: 4px 12px; min-width: 75px; min-height: 23px;
  border: 0; box-shadow: var(--raised);
}
.btn:active:not(:disabled) { box-shadow: var(--pressed); padding: 5px 11px 3px 13px; }
#l-labels[aria-pressed="true"] { box-shadow: var(--pressed); }
.btn:disabled { color: var(--lo); text-shadow: 1px 1px 0 var(--hi); }
.btn:focus { outline: none; }
.btn:focus-visible, .sites button:focus-visible, .menu a:focus-visible { outline: 1px dotted #000; outline-offset: -4px; }

/* --- list view table --- */
.grid { width: 100%; border-collapse: separate; border-spacing: 0; }
.grid th { background: var(--face); text-align: left; padding: 2px 6px; font-weight: normal; box-shadow: var(--raised); }
.grid td { padding: 2px 6px; }
.grid tbody tr { cursor: default; }
.grid tbody tr[aria-selected="true"] { background: var(--sel); color: #fff; }
.grid tbody tr:focus-visible { outline: 1px dotted #000; outline-offset: -1px; }
.tag { display: inline-block; width: 9px; height: 9px; border: 1px solid #000; margin-right: 5px; vertical-align: -1px; }

.foot { color: #fff; margin: 4px 2px 0; }
.foot a { color: #ffff66; }

/* --- data notice: a grey message panel, never bare text on the desktop --- */
.notice {
  display: grid; grid-template-columns: 16px 1fr; gap: 2px 8px; align-items: start;
  margin: 0 0 10px; padding: 6px 8px;
  background: #ffffe1; color: #000; box-shadow: var(--window);
}
.notice__icon { grid-row: span 2; margin-top: 1px; }
.notice p { margin: 0; }
.notice a:link, .notice a:visited { color: #0000ee; }

/* --- tour: a Win98 wizard docked above the map --- */
.tour__body { display: grid; grid-template-columns: 170px 1fr; gap: 12px; }
.tour__steps {
  margin: 0; padding: 8px 8px 8px 26px; align-self: start;
  background: var(--sel); color: #fff; box-shadow: var(--sunken);
}
.tour__steps li { padding: 2px 0; color: #c8d4f0; }
.tour__steps li.done { color: #fff; }
.tour__steps li[aria-current] { color: #fff; font-weight: bold; }
.tour__page { min-height: 150px; }
.tour__page h3 { margin: 0 0 8px; font: bold 12.5px/16px var(--ui); }
.tour__page p { max-width: 62ch; }
.tour__note { margin: 8px 0 0; padding: 3px 6px; box-shadow: inset -1px -1px 0 var(--hi), inset 1px 1px 0 var(--lo); }
.tour__note--warn { background: #ffffe1; }
.tour__note--ok { background: var(--face); }
.tour__bar { display: flex; gap: 6px; align-items: center; padding: 8px 6px 4px; border-top: 1px solid var(--lo); box-shadow: inset 0 1px 0 var(--hi); }
.tour__gap { flex: 1; }
.btn--default { box-shadow: 0 0 0 1px #000, var(--raised); }

/* --- status bar: shallow sunken panels --- */
.sbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
  display: flex; gap: 2px; padding: 2px;
  background: var(--face); box-shadow: inset 0 1px 0 var(--hi);
}
.sbar span { padding: 2px 6px; box-shadow: inset -1px -1px 0 var(--hi), inset 1px 1px 0 var(--lo); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sbar__sound span { box-shadow: none; padding: 0; }
.sbar #sb-state { flex: 1; }
.sbar__sound {
  display: flex; align-items: center; gap: 4px; padding: 1px 6px; border: 0; background: var(--face); color: #000; cursor: default;
  box-shadow: inset -1px -1px 0 var(--hi), inset 1px 1px 0 var(--lo);
}
.sbar__sound:active { box-shadow: inset 1px 1px 0 var(--dk), inset -1px -1px 0 var(--hi); }
.sbar__sound:focus-visible { outline: 1px dotted #000; outline-offset: -3px; }
.sbar__sound .mute { display: none; }
.sbar__sound[aria-pressed="false"] .mute { display: inline; }
.sbar__sound[aria-pressed="false"] .wave { display: none; }

/* --- narrow screens: stack it all --- */
@media (max-width: 860px) {
  #cols, .card, .tour__body { grid-template-columns: 1fr; }
  .tour__steps { display: none; }
  .tour__bar { flex-wrap: wrap; }
  #main { order: -1; } /* map first on a phone, controls under it */
  .maps { grid-template-columns: 1fr; }
  .map { height: 300px; }
  .sbar #sb-src { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
