:root {
  --paper: #d4ba82;
  --paper-light: #e2cd98;
  --paper-dark: #b8975a;
  --ink: #26150a;
  --ink-soft: #553a1c;
  --line: rgba(48, 28, 10, 0.4);
  --red: #6e1c10;
  --print: #5e1a0b;
  /* the aged sheet: fine grain multiplied over a stained, worn wash (both made by art-src/make-paper.mjs) */
  --grain: url(/art/paper-grain.webp) 0 0 / 256px 256px;
  --wash: url(/art/paper-wash.webp);
  --rough: 255px 12px 225px 14px / 14px 225px 12px 255px; /* corners no ruler drew */
  --serif: "IM Fell English", "Iowan Old Style", Palatino, Georgia, serif;
  --caps: "IM Fell English SC", "IM Fell English", Georgia, serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

.paper {
  background: var(--grain), var(--wash) center / 100% 100% no-repeat, var(--paper);
  background-blend-mode: multiply, normal;
}
/* small scraps of the same sheet: labels, buttons, notes */
.scrap {
  background: var(--grain), var(--wash) 30% 38% / 900px 1600px, var(--paper);
  background-blend-mode: multiply, normal;
  border: 1.5px solid rgba(38, 21, 10, 0.82);
  border-radius: var(--rough);
  box-shadow:
    inset 0 0 8px 1px rgba(120, 76, 24, 0.42),
    inset 0 0 2px rgba(38, 21, 10, 0.6),
    1px 2px 5px rgba(30, 16, 4, 0.45);
}

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

/* The sheet of parchment lies under everything: fine grain multiplied over a stained, folded
   wash (two still images, no live filters). The map is see-through ink drawn on top of it
   (see inkmap.js), and the name scrolls and footprints sit on top of that, at full strength. */
#map {
  position: fixed;
  inset: 0;
  background: var(--grain), var(--wash) center / 100% 100% no-repeat, var(--paper);
  background-blend-mode: multiply, normal;
}

/* Only used if the inked map can't load: ordinary street tiles, browned and thinned. */
.plain-tiles { filter: grayscale(1) contrast(1.2) sepia(0.7); opacity: 0.5; }

.leaflet-container { font-family: var(--serif); }
.leaflet-control-attribution {
  background: rgba(196, 164, 104, 0.6) !important;
  color: var(--ink-soft);
  font-size: 10px;
  font-style: italic;
  margin-bottom: var(--safe-bottom) !important;
}
.leaflet-control-attribution a { color: var(--ink-soft); }

/* Glide between position updates, but not while Leaflet animates a zoom. */
.leaflet-container.smooth .leaflet-marker-icon.walker { transition: transform 1.4s linear; }
.leaflet-container:not(.smooth) .leaflet-marker-icon.walker { transition-duration: 0s !important; }
.leaflet-container .leaflet-zoom-anim .leaflet-marker-icon.walker { transition-duration: 0.25s !important; }

.walker { width: 0 !important; height: 0 !important; }

.walker .feet {
  position: absolute;
  left: -21px;
  top: -21px;
  width: 42px;
  height: 42px;
  color: var(--print);
  opacity: 0.92;
  transition: transform 0.25s linear;
}
.walker .feet svg { width: 100%; height: 100%; display: block; overflow: visible; }
.walker.moving .foot-l { animation: step 0.9s steps(1) infinite; }
.walker.moving .foot-r { animation: step 0.9s steps(1) infinite 0.45s; }
@keyframes step { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.walker .label {
  position: absolute;
  left: 0;
  bottom: 10px;
  transform: translateX(-50%);
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  animation: float 4.2s ease-in-out infinite;
}
/* The painted scroll: one image, the name lettered onto its flat band. */
.walker .scroll {
  position: relative;
  width: 186px;
  aspect-ratio: 720 / 320;
  background: url(/art/scroll.webp) center / 100% 100% no-repeat;
}
.walker .name {
  position: absolute;
  left: 11%;
  top: 25%;
  width: 70%;
  height: 46%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: rotate(3.2deg);
  font-family: "Felipa", "Macondo Swash Caps", "Apple Chancery", cursive;
  line-height: 0.86;
  /* dip-pen ink: the letters are cut out of a blotchy brown-black wash, so the ink sits
     heavy in places and thin in others, with a faint bleed into the paper around them */
  color: transparent;
  -webkit-text-stroke: 0.35px #1c0f06;
  filter: drop-shadow(0 0 0.4px rgba(28, 15, 6, 0.55));
}
.walker .name span, .walker .name b {
  background: url(/art/ink.webp) 0 0 / 96px 96px;
  -webkit-background-clip: text;
  background-clip: text;
}
/* the padding gives the swash capital room, so none of its flourish is clipped away */
.walker .name b { font-weight: 400; font-size: 1.45em; line-height: 0; padding: 0.5em 0.15em; margin: -0.5em -0.15em; }
.walker .name span + span { margin-left: 1.1em; }
.walker .ago {
  display: block;
  margin-top: -6px;
  font-style: italic;
  font-size: 12px;
  color: var(--ink);
}
.walker .ago:empty { display: none; }
@keyframes float {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(-1deg); }
  50% { transform: translateX(-50%) translateY(-4px) rotate(1deg); }
}

.walker.me .name { -webkit-text-stroke-color: #4a1006; }
.walker.me .name span, .walker.me .name b {
  background-image: linear-gradient(rgba(104, 20, 8, 0.6), rgba(104, 20, 8, 0.6)), url(/art/ink.webp);
  background-size: auto, 96px 96px;
}
.walker.stale .feet { opacity: 0.4; }
.walker.stale .label { animation: none; opacity: 0.7; }

/* Footprints left behind, fading like drying ink. */
.print { width: 0 !important; height: 0 !important; pointer-events: none; }
.print svg {
  position: absolute;
  left: -8.5px;
  top: -14.5px;
  width: 17px;
  height: 29px;
  overflow: visible;
  color: var(--print);
  animation: dry 30s ease-out forwards;
}
@keyframes dry { 0% { opacity: 0.8; } 60% { opacity: 0.45; } 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .walker .label, .walker.moving .foot-l, .walker.moving .foot-r { animation: none; }
}

/* --------------------------------------------------------------- chrome */

#topbar {
  position: fixed;
  top: calc(var(--safe-top) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 5px 18px 6px;
  white-space: nowrap;
  pointer-events: none;
}
.brand { font-family: var(--caps); font-size: 19px; letter-spacing: 0.06em; }
.status { font-style: italic; font-size: 13px; color: var(--ink-soft); }
.status.live::before { content: "● "; color: #4a5a1e; font-style: normal; }
.status.off::before { content: "● "; color: var(--red); font-style: normal; }

.notice {
  position: fixed;
  top: calc(var(--safe-top) + 58px);
  left: 12px;
  right: 12px;
  z-index: 1000;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  max-width: 460px;
  margin: 0 auto;
  padding: 10px 14px;
  font-size: 15px;
  line-height: 1.35;
}
.notice span { flex: 1; }

#fabs {
  position: fixed;
  right: 12px;
  bottom: calc(var(--safe-bottom) + 26px);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.fab {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  font: inherit;
  color: var(--ink);
  border-radius: 47% 53% 51% 49% / 52% 48% 52% 48%;
  cursor: pointer;
}
.fab svg { width: 22px; height: 22px; }
.fab.wide {
  display: flex;
  gap: 8px;
  width: auto;
  padding: 0 20px;
  border-radius: 26px 21px 25px 22px / 22px 25px 21px 26px;
  font-family: var(--caps);
  font-size: 18px;
  letter-spacing: 0.05em;
}
.fab:active, .btn:active { transform: translateY(1px); }
.badge {
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 11px 9px 10px 9px;
  background: var(--red);
  box-shadow: inset 0 0 4px rgba(30, 6, 2, 0.7);
  color: #ecd6a2;
  font-family: var(--serif);
  font-size: 13px;
  line-height: 20px;
}

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

input:not([type="checkbox"]) {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  font: inherit;
  font-size: 17px; /* 16px+ stops iOS zooming on focus */
  color: var(--ink);
  background: rgba(255, 236, 190, 0.28);
  border: 0;
  border-bottom: 1.5px solid var(--ink);
  border-radius: 2px;
  box-shadow: inset 0 0 8px rgba(92, 54, 16, 0.28);
  outline: none;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
input::placeholder { color: rgba(70, 46, 20, 0.55); font-style: italic; }

.btn {
  padding: 10px 18px;
  font: inherit;
  font-family: var(--caps);
  letter-spacing: 0.05em;
  color: var(--ink);
  background: rgba(92, 54, 16, 0.12);
  border: 1.5px solid var(--ink);
  border-radius: var(--rough);
  box-shadow: inset 0 0 6px rgba(92, 54, 16, 0.3);
  cursor: pointer;
  white-space: nowrap;
}
.btn.primary {
  width: 100%;
  color: #e2c88f;
  background: var(--grain), radial-gradient(120% 160% at 30% 20%, #3a2210, #1d0f06 70%);
  background-blend-mode: multiply, normal;
  box-shadow: inset 0 0 0 1px rgba(226, 200, 143, 0.14), 1px 2px 4px rgba(30, 16, 4, 0.4);
  font-size: 19px;
}
.btn.small { padding: 5px 12px; font-size: 15px; }
.btn:disabled { opacity: 0.5; }

.link {
  padding: 6px;
  font: inherit;
  font-style: italic;
  color: var(--ink-soft);
  background: none;
  border: 0;
  text-decoration: underline;
  cursor: pointer;
}
.danger { color: var(--red); }
.error { min-height: 1.3em; margin: 0; color: var(--red); font-style: italic; font-size: 15px; }
.muted { color: var(--ink-soft); }
.small { font-size: 14px; }

/* ----------------------------------------------------------------- auth */

#auth {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: calc(var(--safe-top) + 20px) 22px calc(var(--safe-bottom) + 20px);
  overflow-y: auto;
}
.auth-card { width: 100%; max-width: 340px; text-align: center; }
.crest { width: 72px; height: 72px; }
h1 { margin: 0; font-family: var(--caps); font-weight: 400; font-size: 40px; letter-spacing: 0.04em; }
.tagline { margin: 6px 0 26px; font-style: italic; color: var(--ink-soft); }
#auth-form { display: grid; gap: 14px; text-align: left; }
label { display: grid; gap: 5px; font-size: 15px; color: var(--ink-soft); }
#auth-switch { margin-top: 14px; }

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

#scrim { position: fixed; inset: 0; z-index: 1400; background: rgba(30, 17, 5, 0.5); }
#sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1500;
  max-width: 520px;
  max-height: 82dvh;
  margin: 0 auto;
  padding: 8px 20px calc(var(--safe-bottom) + 20px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border: 1.5px solid rgba(38, 21, 10, 0.85);
  border-bottom: 0;
  border-radius: 16px 9px 0 0 / 9px 14px 0 0;
  box-shadow: 0 -6px 30px rgba(30, 16, 4, 0.5), inset 0 0 30px rgba(120, 76, 24, 0.28);
  animation: rise 0.22s ease-out;
}
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.grab { width: 44px; height: 3px; margin: 0 auto 10px; border-radius: 2px; background: var(--ink-soft); opacity: 0.6; }

#sheet section { padding: 14px 0; border-bottom: 1px solid var(--line); }
#sheet section:last-child { border-bottom: 0; }
#sheet h2 { margin: 0; font-family: var(--caps); font-weight: 400; font-size: 26px; }
#sheet h3 { margin: 0 0 10px; font-family: var(--caps); font-weight: 400; font-size: 19px; letter-spacing: 0.05em; }
#sheet p { margin: 4px 0 0; }

.switch { display: flex; grid-template-columns: none; align-items: center; gap: 10px; margin-top: 12px; font-size: 17px; color: var(--ink); }
.switch input {
  flex: none;
  display: grid;
  place-content: center;
  width: 24px;
  height: 24px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255, 236, 190, 0.25);
  border: 1.5px solid var(--ink);
  border-radius: 4px 7px 5px 8px / 7px 4px 8px 5px;
  box-shadow: inset 0 0 6px rgba(92, 54, 16, 0.4);
  cursor: pointer;
}
/* a quick pen tick */
.switch input:checked::after {
  content: "";
  width: 15px;
  height: 8px;
  margin-top: -5px;
  border: solid var(--ink);
  border-width: 0 0 3px 2.5px;
  border-radius: 1px 0 0 3px;
  transform: rotate(-50deg) skewX(-8deg);
}

.row { display: flex; gap: 10px; }
.list { margin: 0; padding: 0; list-style: none; }
.list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.list li + li { border-top: 1px dotted var(--line); }
.list .who { flex: 1; min-width: 0; padding: 0; font: inherit; color: inherit; text-align: left; background: none; border: 0; cursor: pointer; }
.list .who b { display: block; font-weight: 400; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .who i { font-size: 14px; color: var(--ink-soft); }
.footer { display: flex; align-items: center; justify-content: space-between; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 96px);
  transform: translateX(-50%);
  z-index: 3000;
  max-width: calc(100vw - 32px);
  padding: 9px 16px;
  color: #e2c88f;
  background: #1f1107;
  border-radius: var(--rough);
  box-shadow: 1px 2px 6px rgba(30, 16, 4, 0.5);
  font-size: 15px;
  font-style: italic;
  text-align: center;
}
