/* ─────────────────────────────────────────────────────────────
   Hike Checklist — Direction B · Tabbed Field Guide
   Styles ported from the wireframe and adapted for a real PWA.
   The wireframe rendered at fixed 360×720; this version fills
   the device viewport while keeping the same visual tokens.
   ───────────────────────────────────────────────────────────── */

:root {
  --paper: #f5efe1;
  --paper-2: #ede4cf;
  --ink: #2a2520;
  --ink-2: #4a4239;
  --rule: #b9ad8e;
  --accent: #6b8a4a;          /* forest */
  --accent-2: #b85c3a;        /* rust */
  --shadow: 2px 3px 0 rgba(0,0,0,.08);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Kalam', sans-serif;
  font-size: 16px;
  line-height: 1.3;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
html, body { height: 100%; overflow: hidden; }
body { min-height: 100dvh; }

button { font: inherit; color: inherit; }

/* ───── App shell — phone-sized centered card on big screens ───── */
.app {
  max-width: 480px;
  margin: 0 auto;
  height: 100dvh;
  background: var(--paper);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (min-width: 600px) {
  body { background: #e8e1cf; padding: 24px 0; height: 100dvh; }
  .app {
    border-radius: 28px;
    box-shadow: 0 1px 0 #fff inset, 0 0 0 2px var(--ink), 0 0 0 8px #d8cfb8, 0 14px 30px rgba(0,0,0,.18);
    overflow: hidden;
    height: calc(100dvh - 48px);
    max-height: 820px;
  }
}

.page {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
/* `hidden` attr's default display:none loses to .page's display:flex,
   which made both screens render at once. Force it. */
.page[hidden] { display: none; }

/* ───── Topbar ───── */
.topbar {
  padding: calc(var(--safe-top) + 16px) 18px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1.5px solid var(--ink);
  background: linear-gradient(180deg, transparent 90%, rgba(0,0,0,.04));
  flex: 0 0 auto;
}
.topbar-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.topbar .title {
  font-family: 'Patrick Hand', sans-serif;
  font-size: 24px;
  line-height: 1.05;
  margin: 0;
  font-weight: 400;
}
.topbar .sub {
  font-size: 11px;
  color: var(--ink-2);
  line-height: 1.2;
  margin: 0;
}
.running-count {
  font-family: 'Patrick Hand', sans-serif;
  font-size: 18px;
}
.topbar-back {
  background: transparent;
  border: none;
  font-family: 'Patrick Hand', sans-serif;
  font-size: 22px;
  color: var(--ink);
  cursor: pointer;
  padding: 4px 8px 4px 0;
  line-height: 1;
}

/* ───── Buttons ───── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 12px 14px;
  text-align: center;
  font-family: 'Patrick Hand', sans-serif;
  font-size: 18px;
  background: #fffdf6;
  color: var(--ink);
  position: relative;
  cursor: pointer;
  text-decoration: none;
  -webkit-user-select: none;
  user-select: none;
}
.btn::after {
  content: "";
  position: absolute;
  inset: 3px -3px -3px 3px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  opacity: .3;
  pointer-events: none;
}
.btn:active { transform: translate(1px, 1px); }
.btn.primary { background: var(--accent); color: #fffdf6; }
.btn.ghost { background: transparent; }

/* ───── Home: progress ring + blurb ───── */
.summary { padding: 12px 18px 4px; flex: 0 0 auto; }
.ringwrap {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 4px;
}
.ring {
  width: 96px; height: 96px;
  border-radius: 50%;
  flex: 0 0 96px;
  position: relative;
  background: conic-gradient(var(--accent) 0 var(--pct, 0%), #d9cfb1 var(--pct, 0%) 100%);
  border: 2px solid var(--ink);
  transition: background .4s ease;
}
.ring::before {
  content: "";
  position: absolute;
  inset: 10px;
  background: var(--paper);
  border-radius: 50%;
  border: 1.5px solid var(--ink);
}
.ring .pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-family: 'Patrick Hand', sans-serif;
}
.ring .pct b { font-size: 26px; line-height: 1; font-weight: 400; }
.ring .pct span { font-size: 11px; color: var(--ink-2); }
.blurb { min-width: 0; flex: 1; }
.blurb h2 {
  margin: 0;
  font-family: 'Patrick Hand', sans-serif;
  font-size: 20px;
  line-height: 1.15;
  font-weight: 400;
}
.blurb p {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.3;
}

/* ───── Home: 4 category cards ───── */
.cats4 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px 18px 0;
  flex: 0 0 auto;
}
.cats4 .c {
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  background: #fffdf6;
  padding: 8px 10px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 78px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}
.cats4 .c::after {
  content: "";
  position: absolute;
  inset: 2px -2px -2px 2px;
  border: 1.5px solid var(--ink);
  border-radius: 11px;
  opacity: .3;
  pointer-events: none;
}
.cats4 .c:active { transform: translate(1px, 1px); }
.cats4 .c h4 {
  margin: 0;
  font-family: 'Patrick Hand', sans-serif;
  font-size: 18px;
  font-weight: 400;
}
.cats4 .c .bar {
  height: 8px;
  border: 1.2px solid var(--ink);
  border-radius: 99px;
  background: #fffdf6;
  overflow: hidden;
}
.cats4 .c .bar i {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width .4s ease;
}
.cats4 .c .nums {
  font-family: 'Patrick Hand', sans-serif;
  font-size: 14px;
  color: var(--ink-2);
}

/* ───── Home: latest finds sticker wall ───── */
.recent2 { padding: 10px 18px 4px; flex: 0 0 auto; }
.recent2 h4 {
  margin: 0 0 6px;
  font-family: 'Patrick Hand', sans-serif;
  font-size: 16px;
  font-weight: 400;
}
.stickers {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow: hidden;
}
.stickers .st {
  appearance: none;
  font: inherit;
  color: inherit;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border: 2px dashed var(--ink);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Patrick Hand', sans-serif;
  font-size: 11px;
  text-align: center;
  color: var(--ink-2);
  padding: 4px;
  line-height: 1.05;
  overflow: hidden;
  background-size: cover;
  background-position: center;
}
.stickers .st.on {
  border-style: solid;
  border-color: var(--ink);
  background-color: var(--accent);
  color: #fffdf6;
  cursor: pointer;
}
.stickers .st.on:active { transform: scale(.95); }
.stickers .st.on:nth-child(odd)  { transform: rotate(-6deg); }
.stickers .st.on:nth-child(even) { transform: rotate(4deg); }
.stickers .st.on.has-photo { color: transparent; }

/* ───── Home: bottom CTA ───── */
.cta-row {
  margin: auto 18px calc(var(--safe-bottom) + 12px);
  display: flex;
  gap: 8px;
  padding-top: 10px;
  flex: 0 0 auto;
}
.cta-row .btn { flex: 1; }

/* ───── Checklist: tabs ───── */
.tabs {
  display: flex;
  gap: 0;
  padding: 8px 12px 0;
  border-bottom: 1.5px solid var(--ink);
  background: var(--paper);
  flex: 0 0 auto;
}
.tab {
  flex: 1;
  text-align: center;
  padding: 8px 4px 10px;
  font-family: 'Patrick Hand', sans-serif;
  font-size: 15px;
  border: 1.5px solid var(--ink);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: #e9dfc4;
  color: var(--ink-2);
  margin-right: -1.5px;
  position: relative;
  cursor: pointer;
  font-weight: 400;
}
.tab:last-child { margin-right: 0; }
.tab.on {
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
  z-index: 1;
}
.tab.on::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 3px;
  background: var(--paper);
}
.tab .n {
  display: block;
  font-family: 'Kalam', sans-serif;
  font-size: 11px;
  color: var(--ink-2);
  font-weight: 400;
}

/* ───── Checklist: card grid — page is fixed; this scrolls inside ───── */
.grid {
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  align-content: start;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.grid::-webkit-scrollbar { width: 0; }
.card {
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  background: #fffdf6;
  padding: 8px;
  position: relative;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}
.card::after {
  content: "";
  position: absolute;
  inset: 2px -2px -2px 2px;
  border: 1.5px solid var(--ink);
  border-radius: 11px;
  opacity: .3;
  pointer-events: none;
}
.card:active { transform: translate(1px, 1px); }

.ph {
  height: 70px;
  border: 1.5px dashed var(--ink);
  border-radius: 8px;
  background:
    repeating-linear-gradient(45deg, transparent 0 8px, rgba(0,0,0,.05) 8px 9px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
  font-family: 'Patrick Hand', sans-serif;
  font-size: 10px;
  text-align: center;
  background-size: cover;
  background-position: center;
}
.card .nm {
  font-family: 'Patrick Hand', sans-serif;
  font-size: 17px;
  line-height: 1.05;
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 6px;
}
.card .meta {
  font-family: 'Kalam', sans-serif;
  font-size: 11px;
  color: var(--ink-2);
  margin-top: auto;
  line-height: 1.2;
}

/* ───── Checkbox ───── */
.cb {
  width: 22px; height: 22px;
  flex: 0 0 22px;
  border: 1.8px solid var(--ink);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fffdf6;
  position: relative;
}
.cb::after {
  content: "";
  position: absolute;
  inset: 2px 0 -2px 2px;
  border: 1.8px solid var(--ink);
  border-radius: 5px;
  opacity: .25;
  pointer-events: none;
}
.cb.on { background: var(--accent); border-color: var(--ink); }
.cb.on::before {
  content: "";
  width: 14px; height: 8px;
  border-left: 3px solid #fffdf6;
  border-bottom: 3px solid #fffdf6;
  transform: rotate(-50deg) translate(1px, -1px);
}

/* ───── Card "done" state — FOUND stamp ───── */
.card.done { background: #e8efd6; }
.card.done .ph {
  border-color: var(--accent);
  border-style: solid;
  color: transparent;
  position: relative;
  background-color: transparent;
  background-image:
    repeating-linear-gradient(45deg, transparent 0 8px, rgba(107,138,74,.08) 8px 9px);
}
.card.done .ph::after {
  content: "FOUND";
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(-8deg);
  font-family: 'Patrick Hand', sans-serif;
  font-size: 18px;
  letter-spacing: 1px;
  color: var(--accent-2);
  border: 2px solid var(--accent-2);
  border-radius: 6px;
  padding: 2px 10px;
  background: rgba(255,253,246,.9);
  box-shadow: inset 0 0 0 2px rgba(184,92,58,.25);
  z-index: 1;
}
.card.done .meta { color: var(--accent-2); }

/* (bottombar removed — back button moved to topbar to free vertical space) */

/* ───── Entry sheet ───── */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet[hidden] { display: none; }
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(42, 37, 32, .35);
  animation: fade .18s ease both;
}
.sheet-card {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: var(--paper);
  border-top: 2px solid var(--ink);
  border-left: 2px solid var(--ink);
  border-right: 2px solid var(--ink);
  border-radius: 18px 18px 0 0;
  padding: 14px 18px calc(var(--safe-bottom) + 18px);
  box-shadow: 0 -10px 30px rgba(0,0,0,.18);
  animation: slideUp .24s cubic-bezier(.2, .7, .3, 1) both;
  font-family: 'Kalam', sans-serif;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.sheet-handle {
  width: 40px; height: 4px;
  border-radius: 2px;
  background: var(--rule);
  margin: 0 auto 12px;
}
.sheet-photo {
  height: 160px;
  border: 1.5px dashed var(--ink);
  border-radius: 10px;
  background:
    repeating-linear-gradient(45deg, transparent 0 8px, rgba(0,0,0,.05) 8px 9px);
  background-size: cover;
  background-position: center;
  margin-bottom: 12px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
  font-family: 'Patrick Hand', sans-serif;
  font-size: 14px;
}
.sheet-photo.has-photo { border-style: solid; border-color: var(--accent); color: transparent; }
.sheet-photo.has-photo::after {
  content: "FOUND";
  position: absolute;
  top: 12px; right: 12px;
  transform: rotate(-8deg);
  font-family: 'Patrick Hand', sans-serif;
  font-size: 16px;
  color: var(--accent-2);
  border: 2px solid var(--accent-2);
  border-radius: 6px;
  padding: 2px 10px;
  background: rgba(255,253,246,.9);
  box-shadow: inset 0 0 0 2px rgba(184,92,58,.25);
}
.sheet-name {
  margin: 0 0 4px;
  font-family: 'Patrick Hand', sans-serif;
  font-size: 26px;
  line-height: 1.1;
  font-weight: 400;
}
.sheet-fact {
  margin: 0 0 6px;
  font-size: 15px;
  color: var(--ink);
}
.sheet-where {
  margin: 0;
  font-size: 13px;
  color: var(--accent);
}
.sheet-where::before { content: "📍 "; }
.sheet-when {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--ink-2);
  font-family: 'Patrick Hand', sans-serif;
}
.sheet-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.sheet-actions .btn { flex: 1; cursor: pointer; }
.sheet-actions label.btn { padding: 12px 14px; }
.sheet-undo {
  display: block;
  margin: 10px auto 0;
  background: transparent;
  border: none;
  font-family: 'Kalam', sans-serif;
  font-size: 12px;
  color: var(--ink-2);
  text-decoration: underline dotted;
  cursor: pointer;
}

/* ───── Login page ───── */
.page-login {
  justify-content: center;
  align-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
}
.login-title {
  font-family: 'Patrick Hand', sans-serif;
  font-size: 32px;
  margin: 0 0 8px;
  font-weight: 400;
  text-align: center;
}
.login-sub {
  text-align: center;
  color: var(--ink-2);
  font-size: 13px;
  margin: 0 0 24px;
  line-height: 1.5;
}
.login-field {
  display: block;
  margin-bottom: 14px;
}
.login-field span {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--ink-2);
  font-family: 'Patrick Hand', sans-serif;
  font-size: 15px;
}
.login-field input {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: #fffdf6;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}
.login-field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
#login-form .btn { width: 100%; margin-top: 8px; }
.login-error {
  color: var(--accent-2);
  margin: 14px 0 0;
  font-size: 13px;
  text-align: center;
  background: rgba(184, 92, 58, 0.08);
  padding: 8px 10px;
  border-radius: 6px;
}

/* Switch-user button in the home topbar */
.topbar-logout {
  background: transparent;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  font-family: 'Patrick Hand', sans-serif;
  font-size: 14px;
  color: var(--ink);
  padding: 6px 10px;
  cursor: pointer;
  flex: 0 0 auto;
}
.topbar-logout:active { transform: translate(1px, 1px); }

/* Sync indicator (small dot in the topbar text area) */
.sync-pill {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 99px;
  margin-left: 6px;
  vertical-align: middle;
}
.sync-pill.ok    { background: rgba(107, 138, 74, 0.18); color: var(--accent); }
.sync-pill.err   { background: rgba(184, 92, 58, 0.18); color: var(--accent-2); }
.sync-pill.busy  { background: rgba(0,0,0,0.06); color: var(--ink-2); }

/* ───── Export page ───── */
.export-actions {
  display: flex;
  gap: 8px;
  padding: 12px 18px 6px;
  flex: 0 0 auto;
}
.export-actions .btn { flex: 1; font-size: 15px; padding: 10px 12px; }
.export-gallery {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 18px calc(var(--safe-bottom) + 18px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}
.export-gallery::-webkit-scrollbar { width: 0; }
.export-empty {
  text-align: center;
  color: var(--ink-2);
  font-family: 'Patrick Hand', sans-serif;
  font-size: 16px;
  padding: 40px 12px;
}
.export-row {
  display: flex;
  gap: 10px;
  align-items: center;
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  background: #fffdf6;
  padding: 8px;
  position: relative;
}
.export-row::after {
  content: "";
  position: absolute;
  inset: 2px -2px -2px 2px;
  border: 1.5px solid var(--ink);
  border-radius: 11px;
  opacity: .3;
  pointer-events: none;
}
.export-thumb {
  width: 56px; height: 56px;
  flex: 0 0 56px;
  border-radius: 6px;
  border: 1.5px solid var(--ink);
  background:
    repeating-linear-gradient(45deg, transparent 0 6px, rgba(0,0,0,.05) 6px 7px) center/cover;
}
.export-meta { flex: 1; min-width: 0; }
.export-meta .nm {
  font-family: 'Patrick Hand', sans-serif;
  font-size: 17px;
  line-height: 1.1;
  margin: 0 0 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.export-meta .when {
  font-size: 11px;
  color: var(--ink-2);
}
.export-dl {
  appearance: none;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: var(--accent);
  color: #fffdf6;
  font-family: 'Patrick Hand', sans-serif;
  font-size: 14px;
  padding: 6px 10px;
  cursor: pointer;
  text-decoration: none;
  flex: 0 0 auto;
}
.export-dl:active { transform: translate(1px, 1px); }

/* ───── Toast ───── */
.toast {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 24px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  font-family: 'Patrick Hand', sans-serif;
  font-size: 16px;
  padding: 10px 16px;
  border-radius: 99px;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
  z-index: 200;
  animation: toast .3s ease both;
  pointer-events: none;
}
.toast[hidden] { display: none; }
@keyframes toast {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ───── Reduced motion ───── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
