/* StrandFinder — mobile-first, high-contrast UI for use outdoors on a phone. */

:root {
  --bg: #f4f7f9;
  --surface: #ffffff;
  --surface-2: #eef3f6;
  --border: #d3dde4;
  --text: #10242f;
  --text-muted: #566c7a;
  --accent: #0f6d8f;
  --accent-strong: #0b5570;
  --accent-soft: #e2f0f6;
  --urgent: #c2371c;
  --urgent-soft: #fdeae5;
  --warn: #a8690b;
  --warn-soft: #fcf1de;
  --ok: #1a7f52;
  --ok-soft: #e2f4eb;
  --danger: #b3261e;
  --focus: #1f8fb8;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 36, 47, .08), 0 4px 14px rgba(16, 36, 47, .06);
  --tap: 48px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c171e;
    --surface: #132430;
    --surface-2: #1b303e;
    --border: #2b4557;
    --text: #e8f1f6;
    --text-muted: #9db3c1;
    --accent: #47b3d8;
    --accent-strong: #6cc6e6;
    --accent-soft: #14323f;
    --urgent: #ff8163;
    --urgent-soft: #3a1d17;
    --warn: #e5a94a;
    --warn-soft: #362a13;
    --ok: #4cc48c;
    --ok-soft: #123124;
    --danger: #ff7a70;
    --focus: #6cc6e6;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-wrap: break-word;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px 64px; }
.wrap-wide { max-width: 1080px; }

/* --- header --------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 900;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
}
.topbar__brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; letter-spacing: -.01em; color: var(--text);
  text-decoration: none; font-size: 17px;
}
.topbar__brand svg { width: 26px; height: 26px; flex: none; }
.topbar__spacer { flex: 1; }
.topbar__links { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.topbar__links a, .topbar__links button {
  font-size: 14px; color: var(--text-muted); text-decoration: none;
  padding: 8px 10px; border-radius: var(--radius-sm); white-space: nowrap;
  background: none; border: 0; cursor: pointer; font-family: inherit;
}
.topbar__links a:hover, .topbar__links button:hover {
  background: var(--surface-2); color: var(--text);
}
.topbar__links a[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* --- typography ----------------------------------------------------- */

h1 { font-size: 1.6rem; line-height: 1.2; margin: 24px 0 8px; letter-spacing: -.02em; }
h2 { font-size: 1.18rem; margin: 28px 0 10px; letter-spacing: -.01em; }
h3 { font-size: 1rem; margin: 18px 0 6px; }
p { margin: 0 0 12px; }
.lede { color: var(--text-muted); font-size: 1.02rem; margin-bottom: 20px; }
.muted { color: var(--text-muted); }
.small { font-size: .86rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }

a { color: var(--accent); }

/* --- cards ---------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card--flat { box-shadow: none; }
.card__title { font-weight: 650; margin: 0 0 4px; font-size: 1rem; }
.stack > * + * { margin-top: 14px; }

/* --- buttons -------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 12px 20px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--accent); color: #fff;
  font: inherit; font-weight: 600; text-decoration: none;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--accent-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--block { width: 100%; }
.btn--lg { min-height: 62px; font-size: 1.12rem; padding: 16px 24px; }
.btn--urgent { background: var(--urgent); }
.btn--urgent:hover { background: #a32c15; }
.btn--ghost {
  background: var(--surface); color: var(--text); border-color: var(--border);
}
.btn--ghost:hover { background: var(--surface-2); }
.btn--warn { background: var(--warn); }
.btn--danger { background: var(--danger); }
.btn--sm { min-height: 38px; padding: 7px 13px; font-size: .88rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 9px; }
details > summary.btn { list-style: none; }
details > summary.btn::-webkit-details-marker { display: none; }
details > summary.btn::marker { content: ""; }
.btn-row .btn { flex: 1 1 auto; }

/* --- forms ---------------------------------------------------------- */

.field { margin-bottom: 18px; }
.field > label, .label {
  display: block; font-weight: 600; margin-bottom: 6px; font-size: .94rem;
}
.field__hint { color: var(--text-muted); font-size: .85rem; margin: -2px 0 7px; }
input[type="text"], input[type="tel"], input[type="email"], input[type="password"],
input[type="number"], input[type="search"], select, textarea {
  width: 100%; min-height: var(--tap);
  padding: 11px 13px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); appearance: none;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input:focus-visible, select:focus-visible, textarea:focus-visible,
.btn:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--focus); outline-offset: 2px;
}
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'><path d='M1 1l6 6 6-6' stroke='%23566c7a' stroke-width='2' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px;
}
.field--error input, .field--error select, .field--error textarea { border-color: var(--urgent); }
.error-text { color: var(--urgent); font-size: .87rem; font-weight: 500; margin-top: 5px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .grid-2 { grid-template-columns: 1fr; } }

.choice-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.choice {
  display: flex; align-items: center; gap: 9px; min-height: var(--tap);
  padding: 11px 13px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); cursor: pointer;
  font-size: .93rem;
}
.choice input { accent-color: var(--accent); width: 20px; height: 20px; flex: none; margin: 0; }
.choice:has(input:checked) {
  border-color: var(--accent); background: var(--accent-soft); font-weight: 600;
}
.checkbox { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.checkbox input { width: 22px; height: 22px; accent-color: var(--accent); margin: 1px 0 0; flex: none; }

/* --- alerts --------------------------------------------------------- */

.alert {
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 16px;
  border: 1px solid var(--border); background: var(--surface-2); font-size: .93rem;
}
.alert--error { background: var(--urgent-soft); border-color: var(--urgent); color: var(--urgent); }
.alert--ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.alert--warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.alert--info { background: var(--accent-soft); border-color: var(--accent); }
.alert strong { display: block; margin-bottom: 2px; }

/* --- badges --------------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 650; letter-spacing: .01em;
  border: 1px solid transparent; white-space: nowrap;
}
.badge--urgent { background: var(--urgent-soft); color: var(--urgent); border-color: var(--urgent); }
.badge--active { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent); }
.badge--done { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.badge--muted { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
.badge--dist { background: var(--surface-2); color: var(--text); border-color: var(--border); }

/* --- map ------------------------------------------------------------ */

.map {
  height: 300px; width: 100%;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface-2); z-index: 1;
}
.map--sm { height: 200px; }
.map--detail { height: 260px; }
.leaflet-container { font: inherit; border-radius: var(--radius-sm); }
.map-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.coords {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .82rem; color: var(--text-muted); margin-top: 8px;
}
.coords:empty { display: none; }
.crosshair-hint {
  display: flex; align-items: center; gap: 8px;
  font-size: .85rem; color: var(--text-muted); margin-top: 8px;
}

/* --- photos --------------------------------------------------------- */

.photo-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 9px; margin-top: 12px;
}
.photo-tile {
  position: relative; aspect-ratio: 1; border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface-2); border: 1px solid var(--border);
}
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile__remove {
  position: absolute; top: 4px; right: 4px;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(10, 20, 26, .78); color: #fff;
  border: 0; cursor: pointer; font-size: 17px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.photo-tile--uploading { display: flex; align-items: center; justify-content: center; }
.photo-tile--uploading::after {
  content: ""; width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.photo-lightbox { display: block; }

.upload-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 64px; width: 100%;
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--accent);
  font: inherit; font-weight: 600; cursor: pointer;
}
.upload-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.upload-btn svg { width: 22px; height: 22px; }

/* --- queue ---------------------------------------------------------- */

.queue-item {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 5px solid var(--border);
  border-radius: var(--radius); padding: 13px 15px; margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.queue-item:hover { border-color: var(--accent); }
.queue-item--urgent { border-left-color: var(--urgent); }
.queue-item--active { border-left-color: var(--accent); }
.queue-item--mine { border-left-color: var(--ok); background: var(--ok-soft); }
.queue-item--done { border-left-color: var(--border); opacity: .78; }
.queue-item__top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.queue-item__title { font-weight: 650; margin: 0 0 3px; }
.queue-item__meta { color: var(--text-muted); font-size: .86rem; }
.queue-item__thumbs { display: flex; gap: 5px; margin-top: 9px; }
.queue-item__thumbs img {
  width: 54px; height: 54px; object-fit: cover;
  border-radius: 7px; border: 1px solid var(--border);
}
.out-of-range { opacity: .62; }

/* --- timeline ------------------------------------------------------- */

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative; padding: 0 0 20px 34px; border-left: 2px solid var(--border);
  margin-left: 11px;
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -10px; top: 1px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border);
}
.timeline li.done::before {
  background: var(--ok); border-color: var(--ok);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path d='M2.5 6.2l2.3 2.3L9.5 3.8' stroke='white' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-size: 12px; background-position: center; background-repeat: no-repeat;
}
.timeline li.current::before {
  border-color: var(--accent); background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.timeline__label { font-weight: 640; }
.timeline__time { color: var(--text-muted); font-size: .84rem; }
.timeline__detail { color: var(--text-muted); font-size: .88rem; margin-top: 2px; }
.timeline li:not(.done) .timeline__label { color: var(--text-muted); font-weight: 500; }

/* --- events / log --------------------------------------------------- */

.event-log { list-style: none; margin: 0; padding: 0; }
.event-log li {
  padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .91rem;
}
.event-log li:last-child { border-bottom: 0; }
.event-log__who { font-weight: 620; }
.event-log__when { color: var(--text-muted); font-size: .82rem; }

/* --- detail rows ---------------------------------------------------- */

.detail-list { display: grid; gap: 1px; background: var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.detail-list > div {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 11px 14px; background: var(--surface); font-size: .94rem;
}
.detail-list dt, .detail-list .k { color: var(--text-muted); flex: none; }
.detail-list dd, .detail-list .v { margin: 0; text-align: right; font-weight: 550; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 13px;
}
.stat__value { font-size: 1.7rem; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.stat__label { color: var(--text-muted); font-size: .8rem; margin-top: 2px; line-height: 1.3; }

/* --- tables --------------------------------------------------------- */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td {
  padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data th { color: var(--text-muted); font-weight: 600; font-size: .82rem; }
table.data tr:last-child td { border-bottom: 0; }

/* --- misc ----------------------------------------------------------- */

.empty {
  text-align: center; padding: 36px 18px; color: var(--text-muted);
  border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface);
}
.divider { height: 1px; background: var(--border); margin: 22px 0; border: 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: #fff; padding: 12px 18px; z-index: 1000;
}
.skip-link:focus { left: 0; }
.spin { animation: spin .8s linear infinite; }
.htmx-request .htmx-indicator { display: inline-flex; }
.htmx-indicator { display: none; }
footer.site {
  border-top: 1px solid var(--border); margin-top: 40px; padding: 20px 0;
  color: var(--text-muted); font-size: .85rem; text-align: center;
}
.hotline {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px; border-radius: var(--radius-sm);
  background: var(--urgent-soft); color: var(--urgent);
  font-weight: 650; text-decoration: none; border: 1px solid var(--urgent);
}

/* Keep the header on one line on a phone. */
@media (max-width: 480px) {
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar__brand { font-size: 15px; gap: 7px; }
  .topbar__brand svg { width: 22px; height: 22px; }
  .topbar__links { gap: 1px; flex-wrap: nowrap; }
  .topbar__links a, .topbar__links button { padding: 7px 6px; font-size: 13px; }
}
@media (max-width: 480px) {
  /* The logo alone still links home, and the links must not overflow. */
  .topbar__brand span { display: none; }
}
