/* PathLog - field UI. Optimized for gloves, sunlight and one-handed use on a tower. */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --line: #d3dae5;
  --text: #101724;
  --text-dim: #5b6779;
  --accent: #0b64d6;
  --accent-text: #ffffff;
  --ok: #0f7a3d;
  --warn: #9a6100;
  --bad: #b3261e;
  --ok-bg: #dff3e6;
  --warn-bg: #fbeed3;
  --bad-bg: #fbdedc;
  --radius: 12px;
  --tap: 48px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1220;
    --surface: #151d2e;
    --surface-2: #1e2739;
    --line: #2c374c;
    --text: #e9eef7;
    --text-dim: #94a1b8;
    --accent: #4d9bff;
    --accent-text: #06121f;
    --ok: #4ade80;
    --warn: #fbbf24;
    --bad: #ff6b61;
    --ok-bg: #12301f;
    --warn-bg: #34280b;
    --bad-bg: #3a1512;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220;
  --surface: #151d2e;
  --surface-2: #1e2739;
  --line: #2c374c;
  --text: #e9eef7;
  --text-dim: #94a1b8;
  --accent: #4d9bff;
  --accent-text: #06121f;
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #ff6b61;
  --ok-bg: #12301f;
  --warn-bg: #34280b;
  --bad-bg: #3a1512;
}

:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Author rules beat the UA stylesheet, so any class setting `display` (.modal,
   .topbar, .nav) would otherwise defeat the `hidden` attribute - leaving the
   full-screen modal scrim painted over the app and eating every tap. */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: contain;
}

.boot { padding: 3rem 1rem; text-align: center; color: var(--text-dim); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: .25rem;
  padding: calc(var(--safe-t) + .4rem) .5rem .4rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  min-height: 52px;
}
.topbar h1 {
  font-size: 1.1rem; margin: 0; flex: 1; font-weight: 650;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions { display: flex; gap: .25rem; }
.icon-btn {
  min-width: 44px; height: 44px; border: 0; background: transparent;
  color: var(--text); font-size: 1.6rem; line-height: 1; border-radius: 10px;
  cursor: pointer; display: grid; place-items: center; padding: 0 .5rem;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn.small { font-size: .95rem; font-weight: 600; }

/* ---------- layout ---------- */
.app {
  padding: .75rem .75rem calc(var(--tap) + var(--safe-b) + 2.6rem);
  max-width: 760px; margin: 0 auto;
}
.row { display: flex; gap: .5rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--text-dim); }
.small { font-size: .82rem; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.center { text-align: center; }

h2.section {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-dim); margin: 1.2rem .25rem .4rem; font-weight: 700;
}
h2.section:first-child { margin-top: .2rem; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .8rem;
}
a.card, button.card {
  display: block; width: 100%; text-align: left; color: inherit;
  text-decoration: none; font: inherit; cursor: pointer;
}
a.card:active, button.card:active { background: var(--surface-2); }
.card-title { font-weight: 650; display: flex; align-items: center; gap: .4rem; }
.card-sub { color: var(--text-dim); font-size: .85rem; margin-top: .15rem; }

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

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: .1rem .45rem; border-radius: 999px;
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; background: var(--surface-2); color: var(--text-dim);
  border: 1px solid var(--line); white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.badge.accent { background: var(--accent); color: var(--accent-text); border-color: transparent; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: var(--tap); padding: 0 1rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.block { width: 100%; }
.btn.sm { min-height: 38px; padding: 0 .7rem; font-size: .85rem; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.fab {
  position: fixed; right: 1rem; z-index: 25;
  bottom: calc(var(--tap) + var(--safe-b) + 1.2rem);
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text);
  border: 0; font-size: 1.8rem; line-height: 1; cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,.3);
  display: grid; place-items: center;
}

/* ---------- forms ---------- */
label.field { display: block; margin-bottom: .7rem; }
label.field > span.lbl {
  display: block; font-size: .78rem; font-weight: 650; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: .25rem;
}
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: .55rem .7rem;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 16px; /* 16px stops iOS zoom-on-focus */
}
textarea { min-height: 90px; resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .6rem; }
@media (max-width: 380px) { .grid2 { grid-template-columns: 1fr; } }
.hint { font-size: .76rem; color: var(--text-dim); margin-top: .2rem; }

/* ---------- checklist ---------- */
.chk {
  display: flex; gap: .65rem; align-items: flex-start;
  padding: .7rem; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent;
}
.chk:active { background: var(--surface-2); }
.chk input[type=checkbox] {
  width: 26px; height: 26px; min-height: 26px; margin: 0; flex: none;
  accent-color: var(--accent);
}
.chk.done .chk-text { color: var(--text-dim); text-decoration: line-through; }
.chk-text { flex: 1; }
.chk-note { font-size: .78rem; color: var(--text-dim); margin-top: .1rem; text-decoration: none; }

.progress {
  height: 8px; border-radius: 999px; background: var(--surface-2);
  overflow: hidden; border: 1px solid var(--line);
}
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .2s; }

/* ---------- key/value readout ---------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: .3rem .8rem; font-size: .92rem; margin: 0; }
.kv dt { color: var(--text-dim); }
.kv dd { margin: 0; text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .4rem; text-align: center; }
.stat b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .7rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: .75rem; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: none; min-height: 42px; padding: 0 .8rem; border: 0; background: transparent;
  color: var(--text-dim); font: inherit; font-weight: 600; cursor: pointer;
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- photos ---------- */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .4rem; }
.photo { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .tag {
  position: absolute; left: 0; right: 0; bottom: 0; font-size: .62rem; padding: .15rem .25rem;
  background: rgba(0,0,0,.65); color: #fff; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- bottom nav ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.nav a {
  min-height: var(--tap); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: .1rem;
  color: var(--text-dim); text-decoration: none; font-size: .66rem;
  font-weight: 600; padding: .3rem 0;
}
.nav a[aria-current="page"] { color: var(--accent); }
.nav-ico { font-size: 1.1rem; line-height: 1; }

/* ---------- toast + modal ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px);
  bottom: calc(var(--tap) + var(--safe-b) + 1rem); z-index: 60;
  background: var(--text); color: var(--bg); padding: .6rem 1rem;
  border-radius: 999px; font-size: .9rem; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal {
  position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-sheet {
  background: var(--surface); width: 100%; max-width: 560px;
  border-radius: 16px 16px 0 0; padding: 1rem 1rem calc(1rem + var(--safe-b));
  max-height: 92vh; overflow-y: auto;
}
.modal-sheet h3 { margin: 0 0 .75rem; font-size: 1.05rem; }

.empty { text-align: center; color: var(--text-dim); padding: 2.5rem 1rem; }
.empty p { margin: .4rem 0 1rem; }

hr.sep { border: 0; border-top: 1px solid var(--line); margin: .8rem 0; }

.banner {
  border-radius: var(--radius); padding: .6rem .75rem; font-size: .85rem;
  border: 1px solid transparent;
}
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner.ok { background: var(--ok-bg); color: var(--ok); }

@media print { .nav, .topbar, .fab { display: none !important; } .app { padding: 0; } }
