/* Poop Map — a hazard sign for dog walkers.
   Caution-tape yellow, chocolate ink, and one loud thing: the poop on the map. */

@font-face { font-family: 'Atkinson Hyperlegible'; font-weight: 400; font-style: normal; font-display: swap;
  src: url(../vendor/fonts/atkinson-hyperlegible-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Atkinson Hyperlegible'; font-weight: 700; font-style: normal; font-display: swap;
  src: url(../vendor/fonts/atkinson-hyperlegible-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Fredoka'; font-weight: 600; font-style: normal; font-display: swap;
  src: url(../vendor/fonts/fredoka-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Fredoka'; font-weight: 700; font-style: normal; font-display: swap;
  src: url(../vendor/fonts/fredoka-latin-700-normal.woff2) format('woff2'); }

:root {
  --sheet: #fffdf5;
  --paper: #f1ead9;        /* sand: placeholders, code, photo backgrounds */
  --ink: #3a2312;          /* chocolate */
  --ink-soft: #6c5846;
  --line: #e4d9c3;
  --edge: #a8977b;         /* outlines of quiet buttons */
  --hazard: #ffc61a;       /* caution tape */
  --hazard-soft: #fff0b3;
  --danger: #c2371f;
  --water: #1f6fa8;        /* you are here */
  --grass: #4a7f2a;        /* a good GPS fix */
  --poop: #7b4a24;
  --poop-dark: #43250f;
  --poop-hi: #b27a46;
  --poop-ghost: #dcc3a6;   /* a poop that is not saved yet */
  --tape: repeating-linear-gradient(-45deg, var(--hazard) 0 10px, var(--ink) 10px 20px);
  --ui: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Fredoka', 'Atkinson Hyperlegible', system-ui, sans-serif;
  --tap: 48px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--sheet);
  color: var(--ink);
  font: 400 17px/1.5 var(--ui);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.noscript { padding: 24px; }

:focus-visible { outline: 3px solid var(--water); outline-offset: 2px; border-radius: 6px; }
h1:focus, h2:focus { outline: none; }

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

.stage { position: relative; flex: 1 1 auto; min-height: 120px; }
#map { position: absolute; inset: 0; background: #e6e4d8; }
.leaflet-container { font-family: var(--ui); background: #e6e4d8; }
.leaflet-control-attribution {
  font-size: 12px;
  color: var(--ink-soft);
  background: rgba(255, 253, 245, 0.9) !important;
}
.leaflet-control-attribution a { color: var(--ink); }

/* caution tape between the map and the sheet */
.tape {
  flex: 0 0 auto;
  height: 9px;
  background: var(--tape);
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}

.fab {
  position: absolute;
  z-index: 1000;
  top: 12px;
  right: 12px;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--sheet);
  color: var(--ink);
  box-shadow: 0 3px 0 var(--ink);
}
.fab:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.fab .ico { width: 26px; height: 26px; }
.fab.is-busy { color: var(--water); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

/* the poop (one drawing, used on the map, in the header and in the list) */
.poop-svg { display: block; overflow: visible; }
.poop-svg .tier { fill: var(--poop); stroke: var(--poop-dark); stroke-width: 3.5; stroke-linejoin: round; }
.poop-svg .shine { fill: none; stroke: var(--poop-hi); stroke-width: 3; stroke-linecap: round; }
.poop-svg .eye { fill: #fff; stroke: var(--poop-dark); stroke-width: 1.6; }
.poop-svg .pupil { fill: var(--poop-dark); }
.poop-svg .mouth { fill: none; stroke: var(--poop-dark); stroke-width: 2.8; stroke-linecap: round; }
.poop-svg .shadow { fill: rgba(58, 35, 18, 0.22); }

.poop { background: none; border: 0; }
.poop .poop-svg {
  width: 52px;
  height: 52px;
  transform-origin: 50% 90%;
  filter: drop-shadow(0 1px 1px rgba(58, 35, 18, 0.35));
}
.poop.is-selected .poop-svg { transform: scale(1.25); }
.poop.is-draft .tier { fill: var(--poop-ghost); stroke-dasharray: 5 4; }
/* A friend's poop: same poop, outlined in that friend's colour (the colour is also shown next to their name). */
.poop.is-theirs .tier { stroke: var(--who, var(--poop-dark)); stroke-width: 6; }
.poop.is-draft .shine { display: none; }
.poop.is-new .poop-svg { animation: plop 0.55s cubic-bezier(0.3, 0.7, 0.4, 1) 1; }
@keyframes plop {
  0% { transform: translateY(-34px); opacity: 0; }
  55% { transform: translateY(0) scale(1.18, 0.78); opacity: 1; }
  80% { transform: scale(0.94, 1.08); }
  100% { transform: none; }
}
.leaflet-marker-icon.poop:focus-visible { outline: 3px solid var(--water); outline-offset: 0; border-radius: 12px; }

/* ---------- sheet ---------- */

#sheet {
  flex: 0 1 auto; /* shrinks (and scrolls) on very short screens so the map keeps its minimum height */
  max-height: 62vh;
  max-height: 62dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--sheet);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
}

h1, h2 { margin: 0; font-family: var(--display); font-weight: 700; line-height: 1.2; }
h1 { font-size: 26px; }
h2 { font-size: 23px; }

.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand .poop-svg { flex: none; width: 40px; height: 40px; }
.count { color: var(--ink-soft); font-size: 15px; }
.status { margin: 4px 0 14px; color: var(--ink-soft); font-size: 15px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 20px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: transparent;
  font-family: var(--display);
  font-weight: 600;
  font-size: 18px;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary {
  width: 100%;
  min-height: 58px;
  border-color: var(--ink);
  background: var(--hazard);
  color: var(--ink);
  font-size: 21px;
  box-shadow: 0 4px 0 var(--ink);
}
.btn-primary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn-secondary { border-color: var(--ink); }
.btn-quiet { border-color: var(--edge); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger[data-armed] { background: var(--danger); border-color: var(--danger); color: #fff; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.stack { display: grid; gap: 12px; }

.sheet-head { display: flex; align-items: center; gap: 4px; margin: -6px 0 8px -8px; }
.sheet-head h2 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.icon-btn {
  flex: none;
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
}
.ico { width: 24px; height: 24px; }

/* compose */

.fixline { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; color: var(--ink-soft); font-size: 15px; }
.fixline .dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--ink-soft); }
.fixline[data-quality='good'] .dot { background: var(--grass); }
.fixline[data-quality='ok'] .dot { background: #c98a00; }
.fixline[data-quality='poor'] .dot,
.fixline[data-quality='bad'] .dot { background: var(--danger); }

.title-input {
  width: 100%;
  padding: 8px 0;
  border: 0;
  border-bottom: 2px solid var(--line);
  border-radius: 0;
  background: transparent;
  font: 600 23px/1.3 var(--display);
}
.title-input:focus { outline: none; border-bottom-color: var(--water); }
.body-input {
  display: block;
  width: 100%;
  min-height: 6em;
  padding: 10px 0;
  border: 0;
  background: transparent;
  font: 400 18px/1.6 var(--ui);
  resize: none;
  overflow: hidden; /* it grows instead (see autoGrow in app.js) */
}
.body-input:focus { outline: none; }
::placeholder { color: #6f6253; opacity: 1; }

/* more room for writing; the map keeps its minimum height above it */
#sheet[data-view='compose'] { max-height: 70vh; max-height: 70dvh; }

.photos { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; }
.thumb { position: relative; flex: none; width: 84px; height: 84px; border-radius: 12px; overflow: hidden; background: var(--paper); }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb-x {
  position: absolute; top: 3px; right: 3px; width: 34px; height: 34px;
  display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 50%; background: rgba(58, 35, 18, 0.82); color: #fff;
}
.thumb-x .ico { width: 18px; height: 18px; }
.thumb-add {
  display: grid; place-items: center; align-content: center; gap: 2px; padding: 0;
  border: 2px dashed var(--ink-soft); background: transparent; font-size: 13px; color: var(--ink);
}

.hint { margin: 0 0 8px; color: var(--ink-soft); font-size: 15px; }
.actions {
  position: sticky; bottom: calc(-14px - env(safe-area-inset-bottom));
  display: flex; gap: 10px;
  margin: 0 -16px calc(-14px - env(safe-area-inset-bottom));
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(255, 253, 245, 0), var(--sheet) 12px);
}
.actions .btn-primary { flex: 1 1 auto; width: auto; }
.actions .btn-quiet { flex: 0 0 auto; background: var(--sheet); }

/* all poops */

.entries { list-style: none; margin: 0; padding: 0; }
.entry {
  display: grid; grid-template-columns: 56px 1fr; align-items: center; gap: 12px;
  width: 100%; min-height: 72px; padding: 10px 4px; text-align: left;
  border: 0; border-top: 1px solid var(--line); background: transparent;
}
.entries li:first-child .entry { border-top: 0; }
.entry-thumb { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; background: var(--hazard-soft); display: grid; place-items: center; }
.entry-thumb .poop-svg { width: 40px; height: 40px; }
.entry-title { display: block; font: 600 18px/1.3 var(--display); overflow-wrap: anywhere; }
.entry-excerpt, .entry-date { display: block; color: var(--ink-soft); font-size: 15px; }
.entry-excerpt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-date { font-size: 14px; }
.empty { margin: 18px 0 8px; color: var(--ink-soft); }

/* one poop */

.meta { display: flex; flex-wrap: wrap; gap: 0 14px; margin: 2px 0 12px; color: var(--ink-soft); font-size: 15px; }
.meta span { white-space: nowrap; }
.gallery { display: flex; gap: 8px; margin: 0 -16px 12px; padding: 0 16px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; }
.gallery button { flex: none; width: 132px; height: 132px; padding: 0; border: 0; border-radius: 14px; overflow: hidden; background: var(--paper); scroll-snap-align: start; cursor: zoom-in; }
.gallery img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* one photo: show it large, like the header image of a post */
.gallery.gallery--single { margin: 0 0 12px; padding: 0; overflow: visible; }
.gallery.gallery--single button { width: 100%; height: auto; max-height: 240px; aspect-ratio: 3 / 2; }

.prose { font: 400 18px/1.6 var(--ui); max-width: 62ch; overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote { margin: 0.8em 0; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose h3, .prose h4, .prose h5 { margin: 1.1em 0 0.3em; font: 600 1.15em/1.3 var(--display); }
.prose blockquote { padding-left: 14px; border-left: 4px solid var(--poop); color: var(--ink-soft); }
.prose a { color: var(--water); text-underline-offset: 2px; }
.prose code { padding: 0.1em 0.35em; border-radius: 5px; background: var(--paper); font: 0.88em ui-monospace, Menlo, Consolas, monospace; }

/* backup */

.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 14px; margin: 4px 0 6px; }
.facts div { padding-top: 6px; border-top: 2px solid var(--ink); }
.facts dt { color: var(--ink-soft); font-size: 14px; }
.facts dd { margin: 0; font: 700 24px/1.3 var(--display); }
.note { margin: 10px 0; color: var(--ink-soft); font-size: 15px; }

/* accounts */

.form { display: grid; gap: 12px; margin: 10px 0 4px; }
.field { display: grid; gap: 4px; color: var(--ink-soft); font-size: 15px; }
.text-input {
  width: 100%;
  min-height: var(--tap);
  padding: 8px 12px;
  border: 2px solid var(--edge);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 18px;
}
.text-input:focus { outline: none; border-color: var(--water); }
.form-msg { min-height: 1.5em; margin: 0; }
.form-msg[data-bad] { color: var(--danger); font-weight: 700; }
.syncline { margin: -8px 0 12px; color: var(--ink-soft); font-size: 14px; }
.linklike {
  padding: 0 2px;
  border: 0;
  background: none;
  color: var(--water);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  min-height: 32px;
}
.account { margin: 2px 0 14px; padding-bottom: 12px; border-bottom: 2px solid var(--line); }
.account .who-line { margin: 0 0 4px; font-size: 19px; }
.account .who-line .note { display: block; margin: 0; }
.more > summary { cursor: pointer; padding: 12px 0 6px; font-weight: 700; }
.more .form + .form { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.who { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.who::before { content: ''; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--who, var(--ink-soft)); }

/* overlays */

#toast {
  position: fixed; z-index: 3000; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; max-width: min(92vw, 460px);
  padding: 10px 16px; border-radius: 12px; background: var(--ink); color: #fff; font-size: 16px;
  box-shadow: 0 2px 10px rgba(58, 35, 18, 0.35);
}
.toast-btn { flex: none; min-height: 36px; padding: 0 12px; border: 2px solid #fff; border-radius: 10px; background: transparent; color: #fff; font-weight: 700; }

#lightbox {
  position: fixed; inset: 0; z-index: 4000;
  display: grid; place-items: center; padding: 56px 8px 8px;
  background: rgba(30, 18, 9, 0.94);
}
#lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
#lightbox .icon-btn { position: absolute; top: 4px; right: 4px; color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .fab.is-busy { animation: none; }
  .poop.is-new .poop-svg { animation: none; }
  .btn:active, .btn-primary:active, .fab:active { transform: none; }
}
