/* amigobirds design system.
 *
 * Deliberate constraints, kept as constraints on purpose:
 *   - no rounded corners, anywhere;
 *   - no gradients and no shadows; depth comes from hairline rules alone;
 *   - no floating cards; sections are separated by lines, not by boxes;
 *   - one accent colour for the current action, so that colour still means
 *     something in the interface;
 *   - numbers are tabular so columns of figures line up and stay comparable.
 *
 * The score ramp is the one place colour is used freely, because there it is
 * data rather than decoration.
 */

:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --bg-sunk: #f4f4f2;
  --fg: #16160f;
  --fg-muted: #63635c;
  --rule: #d6d6d0;
  --rule-strong: #16160f;
  --accent: #b4340a;
  --accent-fg: #ffffff;
  --warn: #8a5a00;



  --sans: ui-sans-serif, system-ui, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --gap: 0.75rem;
  --panel-w: 26rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121210;
    --bg-sunk: #1c1c19;
    --fg: #ececE4;
    --fg-muted: #9a9a92;
    --rule: #33332e;
    --rule-strong: #ececE4;
    --accent: #ff7a45;
    --accent-fg: #121210;
    --warn: #d8a24a;
  }
}

/* An explicit theme attribute must beat the media query in both directions. */
:root[data-theme="dark"] {
  --bg: #121210;
  --bg-sunk: #1c1c19;
  --fg: #ececE4;
  --fg-muted: #9a9a92;
  --rule: #33332e;
  --rule-strong: #ececE4;
  --accent: #ff7a45;
  --accent-fg: #121210;
}
:root[data-theme="light"] {
  --bg: #ffffff;
  --bg-sunk: #f4f4f2;
  --fg: #16160f;
  --fg-muted: #63635c;
  --rule: #d6d6d0;
  --rule-strong: #16160f;
  --accent: #b4340a;
  --accent-fg: #ffffff;
}

/* Square by default, including anything Leaflet injects later. */
*,
*::before,
*::after {
  box-sizing: border-box;
  border-radius: 0;
}

html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 var(--sans);
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--accent); }

h1 { font-size: 1.35rem; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 var(--gap); }
h2 { font-size: 1rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
     margin: 1.5rem 0 var(--gap); }

.muted { color: var(--fg-muted); }
.hint { color: var(--fg-muted); font-size: 0.8125rem; margin: 0.35rem 0 0; }
.error { color: var(--accent); border-left: 2px solid var(--accent); padding-left: 0.6rem; margin: var(--gap) 0; }
.warn { color: var(--warn); }

/* Header ------------------------------------------------------------------ */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--rule);
  flex: 0 0 auto;
}
.wordmark {
  font-weight: 600;
  letter-spacing: -0.02em;
  text-decoration: none;
}
.bar-right { display: flex; align-items: center; gap: 1rem; font-size: 0.8125rem; }
.bar-right form { margin: 0; }

main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  /* The map page fills the shell exactly and scrolls inside its own panel, so
     this only engages for document-flow pages like the account list. */
  overflow-y: auto;
}

.credits {
  flex: 0 0 auto;
  border-top: 1px solid var(--rule);
  padding: 0.5rem 1rem;
  font-size: 0.6875rem;
  color: var(--fg-muted);
}

/* Explore layout: fixed panel, map takes the rest ------------------------- */

.split { display: flex; flex: 1 1 auto; min-height: 0; }

.panel {
  width: var(--panel-w);
  flex: 0 0 var(--panel-w);
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.map { flex: 1 1 auto; min-height: 24rem; background: var(--bg-sunk); }

@media (max-width: 46rem) {
  .split { flex-direction: column; }
  .panel { width: auto; flex: 0 0 auto; border-right: 0; border-bottom: 1px solid var(--rule); }
  .map { min-height: 60vh; }
}

/* Forms ------------------------------------------------------------------- */

.search, .stack { padding: 1rem; display: flex; flex-direction: column; gap: var(--gap); }
.narrow { max-width: 26rem; padding: 1.5rem 1rem; }

/* The home page: small and minimal on purpose, so it is centred rather than
   pinned to the left edge like a form. */
.home { margin: 4rem auto 0; text-align: center; }
.home .hint { margin-bottom: 1.5rem; }
.home-actions { display: flex; justify-content: center; gap: 0.75rem; }

/* Document-flow sections must not be stretched by the flex shell. */
.narrow, .wide { flex: 0 0 auto; }

/* The account page's birded list.
   The section rule runs the full width so it reads as a page division, while the
   content inside stays in a readable column rather than stretching across a wide
   monitor. */
.wide {
  padding: 0 0 2rem;
  border-top: 1px solid var(--rule);
}
.wide > * { max-width: 48rem; }
.wide > h2 { margin: 1.5rem 0 0; padding: 0 1rem; }
.wide > .hint { padding: 0 1rem; }
.wide > .error { margin-left: 1rem; }

.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field > label, .legend-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}
.row { display: flex; gap: 0.4rem; }
.row > input { flex: 1 1 auto; min-width: 0; }

input[type="text"], input[type="email"], input[type="password"] {
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: 0.4rem 0.5rem;
}
input[type="text"]:focus-visible,
input[type="email"]:focus-visible,
input[type="password"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
input:disabled { color: var(--fg-muted); background: var(--bg-sunk); }

#lat, #lng { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 0.8125rem; }

.field.check { flex-direction: row; align-items: center; gap: 0.5rem; }
.field.check label { text-transform: none; letter-spacing: 0; font-size: 0.875rem; color: var(--fg); }
input[type="checkbox"] {
  appearance: none;
  width: 1rem; height: 1rem;
  border: 1px solid var(--rule-strong);
  background: var(--bg);
  display: grid; place-content: center;
  flex: 0 0 auto;
}
input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"]:checked::after {
  content: "";
  width: 0.5rem; height: 0.25rem;
  border-left: 2px solid var(--accent-fg);
  border-bottom: 2px solid var(--accent-fg);
  transform: translateY(-1px) rotate(-45deg);
}
input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Square slider, no shadows or rounded thumbs. */
input[type="range"] {
  appearance: none;
  width: 100%;
  height: 1rem;
  background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px; background: var(--rule);
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 0.5rem; height: 1rem;
  background: var(--fg);
  margin-top: -7px;
}
input[type="range"]::-moz-range-track { height: 2px; background: var(--rule); }
input[type="range"]::-moz-range-thumb {
  width: 0.5rem; height: 1rem; border: 0; background: var(--fg);
}
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

output {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  text-transform: none;
  letter-spacing: 0;
}

button {
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--rule-strong);
  padding: 0.4rem 0.7rem;
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--bg-sunk); }
button:disabled { color: var(--fg-muted); border-color: var(--rule); cursor: not-allowed; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
button.primary:hover { filter: brightness(1.08); background: var(--accent); }

button.link {
  border: 0; padding: 0; background: none;
  text-decoration: underline; text-underline-offset: 2px;
  color: inherit;
}
button.link:hover { color: var(--accent); background: none; }

/* .btn is the button look on an <a>: the home page's actions are navigation,
   not form submission, and an <a> styled as a button still reads as a link to
   assistive tech and to Ctrl/Cmd-click — a <button> with a click handler would
   not. It intentionally mirrors `button` and `button.primary` above rather
   than merging with them, so nothing about the form buttons can regress by
   editing this. */
.btn {
  display: inline-block;
  font: inherit;
  text-decoration: none;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--rule-strong);
  padding: 0.5rem 1.1rem;
  cursor: pointer;
}
.btn:hover { background: var(--bg-sunk); color: var(--fg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); color: var(--accent-fg); }

/* Place-search suggestions ------------------------------------------------ */

.suggestions {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
  border: 1px solid var(--rule);
  max-height: 12rem;
  overflow-y: auto;
}
.suggestions li + li { border-top: 1px solid var(--rule); }
.suggestions button {
  border: 0; width: 100%; text-align: left; background: none;
  padding: 0.35rem 0.5rem; font-size: 0.8125rem;
}

/* The score ramp ---------------------------------------------------------- */
/* Six stops — grey, blue, green, yellow, orange, red — sampled into ten
 * classes. The stops are written out per bucket rather than interpolated at
 * runtime for two reasons: a six-stop ramp is not expressible as a single
 * color-mix(), and these classes are the one definition of the ramp, which
 * app.js reads back so the map markers cannot drift from the list dots.
 *
 * Classes rather than inline styles is not a stylistic choice: the CSP forbids
 * the style attribute, so `style="--s:0.42"` is dropped silently and the colour
 * simply never appears. */
.s0 { --score-color: #8f8f88; } /* grey: nothing recorded here */
.s1 { --score-color: #5a7da3; }
.s2 { --score-color: #2f73ac; } /* blue */
.s3 { --score-color: #2f8472; }
.s4 { --score-color: #559a45; } /* green */
.s5 { --score-color: #b3b52a; }
.s6 { --score-color: #dba81d; } /* yellow */
.s7 { --score-color: #df8019; } /* orange */
.s8 { --score-color: #d55412; }
.s9 { --score-color: #c8280a; } /* red: the best spots */

/* Brighter and more saturated on a dark background, where the light-mode
   mid-tones would otherwise turn to mud. */
@media (prefers-color-scheme: dark) {
  .s0 { --score-color: #77776f; }
  .s1 { --score-color: #5f87ae; }
  .s2 { --score-color: #4a97d2; }
  .s3 { --score-color: #46ac8f; }
  .s4 { --score-color: #69bf5e; }
  .s5 { --score-color: #cad148; }
  .s6 { --score-color: #f5c13b; }
  .s7 { --score-color: #fd9c32; }
  .s8 { --score-color: #ff7329; }
  .s9 { --score-color: #ff4a20; }
}
:root[data-theme="dark"] .s0 { --score-color: #77776f; }
:root[data-theme="dark"] .s1 { --score-color: #5f87ae; }
:root[data-theme="dark"] .s2 { --score-color: #4a97d2; }
:root[data-theme="dark"] .s3 { --score-color: #46ac8f; }
:root[data-theme="dark"] .s4 { --score-color: #69bf5e; }
:root[data-theme="dark"] .s5 { --score-color: #cad148; }
:root[data-theme="dark"] .s6 { --score-color: #f5c13b; }
:root[data-theme="dark"] .s7 { --score-color: #fd9c32; }
:root[data-theme="dark"] .s8 { --score-color: #ff7329; }
:root[data-theme="dark"] .s9 { --score-color: #ff4a20; }
:root[data-theme="light"] .s0 { --score-color: #8f8f88; }
:root[data-theme="light"] .s1 { --score-color: #5a7da3; }
:root[data-theme="light"] .s2 { --score-color: #2f73ac; }
:root[data-theme="light"] .s3 { --score-color: #2f8472; }
:root[data-theme="light"] .s4 { --score-color: #559a45; }
:root[data-theme="light"] .s5 { --score-color: #b3b52a; }
:root[data-theme="light"] .s6 { --score-color: #dba81d; }
:root[data-theme="light"] .s7 { --score-color: #df8019; }
:root[data-theme="light"] .s8 { --score-color: #d55412; }
:root[data-theme="light"] .s9 { --score-color: #c8280a; }

/* Score ramp legend ------------------------------------------------------- */

.legend {
  padding: 0 1rem 1rem;
  border-bottom: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
/* Discrete swatches rather than a CSS gradient: the ramp is a key, and a key
   reads better as steps you can point at. One swatch per bucket, so the legend
   shows exactly the colours the map can use. */
.ramp { display: flex; height: 0.5rem; }
.ramp > i { flex: 1 1 0; background: var(--score-color); }
.legend-ends {
  display: flex;
  justify-content: space-between;
  font-size: 0.6875rem;
  color: var(--fg-muted);
}

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

.results { padding: 0 0 1rem; }
.count {
  margin: 0;
  padding: 0.6rem 1rem;
  font-size: 0.8125rem;
  border-bottom: 1px solid var(--rule);
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.count strong { font-variant-numeric: tabular-nums; }

.list { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--rule);
}
.item.active { background: var(--bg-sunk); }
.item-main { flex: 1 1 auto; min-width: 0; }
.item-name { display: block; font-weight: 500; }

/* On the map page the row is a control: clicking it locates the hotspot. The
   cursor is the only affordance saying so, so it applies to the whole row. */
#list .item { cursor: pointer; }
/* The secondary link out to eBird, added by app.js beside the other metadata. */
.item-link { color: var(--fg-muted); }
.item-link:hover { color: var(--accent); }
.item-meta {
  margin: 0.15rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}
.item .mark { margin: 0; flex: 0 0 auto; }
.item .mark button { font-size: 0.75rem; padding: 0.2rem 0.4rem; }
.item.visited .mark button { border-color: var(--accent); color: var(--accent); }

/* The list dot uses the same ramp as the map markers, so the two views agree. */
.dot {
  width: 0.75rem; height: 0.75rem;
  flex: 0 0 auto;
  margin-top: 0.22rem;
  background: var(--score-color);
}
/* Birded spots are faded, matching the map markers, with only a hairline edge to
   keep the shape readable. The 25% here is the same figure as
   VISITED_FILL_OPACITY in app.js — keep the two in step. */
.item.visited .dot {
  box-sizing: border-box;
  background: color-mix(in srgb, var(--score-color) 25%, transparent);
  border: 1px solid var(--score-color);
}

/* Account ---------------------------------------------------------------- */

.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 1rem; margin: 0 0 1rem; }
.facts dt { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-muted); }
.facts dd { margin: 0; }
code { font-family: var(--mono); background: var(--bg-sunk); padding: 0.1rem 0.25rem; }
.code-out { border-left: 2px solid var(--accent); padding-left: 0.6rem; }

/* Admin ------------------------------------------------------------------ */

/* .notice is the counterpart to .error: same left-rule construction so the two
   read as one family, in the muted foreground rather than the accent, because a
   confirmation should not shout as loudly as a failure. */
.notice {
  color: var(--fg);
  border-left: 2px solid var(--rule-strong);
  padding-left: 0.6rem;
  margin: var(--gap) 0;
}

/* The tables carry rules, not fills: a zebra stripe would fight the score
   colours the rest of the app uses to mean something. */
.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  margin: var(--gap) 0 0;
}
.grid th,
.grid td {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
.grid th {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  border-bottom: 1px solid var(--rule-strong);
  white-space: nowrap;
}
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid .actions { text-align: right; white-space: nowrap; }
.grid .actions form { margin: 0; display: inline-block; }
.grid .actions button { font-size: 0.75rem; padding: 0.2rem 0.4rem; }

/* A suspended account stays fully readable — it is still a row of data to act
   on — and is marked by its tag rather than by being greyed out. */
.grid tr.banned strong { color: var(--fg-muted); text-decoration: line-through; }

/* .block turns an inline span into its own line, for the secondary text stacked
   under a table cell's main value. */
.block { display: block; }

.tag {
  display: inline-block;
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.05rem 0.3rem;
  border: 1px solid currentColor;
  margin-top: 0.15rem;
}

/* The wide section constrains its children to 48rem, which is too narrow for
   these tables; they get the full column and pad themselves instead. */
.wide > .grid { max-width: none; }
.wide > .grid th:first-child,
.wide > .grid td:first-child { padding-left: 1rem; }
.wide > .grid th:last-child,
.wide > .grid td:last-child { padding-right: 1rem; }
.wide > .count { max-width: none; }

/* Leaflet overrides ------------------------------------------------------ */
/* Leaflet ships rounded, shadowed, gradient-free-but-still-glossy chrome.
   These rules bring it back in line with the rest of the interface. */

.leaflet-container { font: inherit; background: var(--bg-sunk); }
.leaflet-bar,
.leaflet-popup-content-wrapper,
.leaflet-popup-tip,
.leaflet-control-attribution {
  border-radius: 0 !important;
  box-shadow: none !important;
}
.leaflet-bar a {
  border: 1px solid var(--rule-strong);
  background: var(--bg);
  color: var(--fg);
}
.leaflet-bar a:hover { background: var(--bg-sunk); color: var(--fg); }
.leaflet-popup-content-wrapper {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--rule-strong);
}
.leaflet-popup-tip { background: var(--bg); border: 1px solid var(--rule-strong); }
.leaflet-popup-content { margin: 0.6rem 0.7rem; font-size: 0.8125rem; }
.leaflet-container a.leaflet-popup-close-button { color: var(--fg-muted); }
.leaflet-control-attribution {
  background: var(--bg) !important;
  color: var(--fg-muted);
  font-size: 0.625rem;
}
.leaflet-control-attribution a { color: var(--fg-muted); }

/* The start point: a square outline, visually distinct from the round hotspot
   markers so the two are never confused. */
.start-pin { background: none; border: 0; }
.start-pin-mark {
  display: block;
  width: 14px; height: 14px;
  border: 2px solid var(--rule-strong);
  background: var(--bg);
  cursor: grab;
}

/* Popup contents. */
.pop-name { font-weight: 600; display: block; margin-bottom: 0.25rem; }
.pop-meta {
  margin: 0 0 0.4rem;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
}
.pop-meta span { display: block; }
.pop-actions { display: flex; gap: 0.35rem; align-items: center; }
.pop-actions button { font-size: 0.75rem; padding: 0.2rem 0.4rem; }

/* Dark mode: keep the tiles legible without inverting label colours away. */
@media (prefers-color-scheme: dark) {
  .leaflet-tile-pane { filter: brightness(0.72) contrast(1.05); }
}
:root[data-theme="dark"] .leaflet-tile-pane { filter: brightness(0.72) contrast(1.05); }
:root[data-theme="light"] .leaflet-tile-pane { filter: none; }
