/* Rorschach's Halloween Journal
   The page is a comic panel at dusk: a flat, hot magenta-red sky going
   violet at the bottom, a halftone dot screen over it, heavy black
   outlines, and pale yellow caption boxes for the journal, lettered by hand. */

:root {
  --sky-high: #e2385d;
  --sky: #c91c4a;
  --sky-low: #9b1442;
  --dusk: #4f2463;

  --ink: #111014;
  --text: #111014;
  --paper: #f5f0e2;      /* the mask */
  --caption: #f8e7a2;    /* journal caption boxes */
  --mustard: #e8b22a;    /* the coat */
  --muted: #5a4a32;      /* secondary text on caption / paper */
  --on-sky: #fff3f5;     /* text set straight on the sky */
  --stamp: #b0102c;
  --focus: #111014;

  --sign: 'Permanent Marker', 'Marker Felt', 'Comic Sans MS', cursive;
  --type: 'Patrick Hand', 'Comic Sans MS', 'Chalkboard SE', cursive;

  --line: 3px;
  --shadow: 5px 5px 0 var(--ink);
  --gutter: 20px;
  --measure: 34rem;
}

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

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

body {
  margin: 0;
  color: var(--text);
  font-family: var(--type);
  font-size: 1.15rem;
  line-height: 1.4;
  min-height: 100vh;
  background: var(--sky);
}

/* The sky sits on its own fixed layer so it doesn't stretch with long pages.
   Flat colour bands, the way the comic was coloured, then a dot screen. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(rgba(40, 0, 20, 0.22) 1.1px, transparent 1.7px) 0 0 / 7px 7px,
    linear-gradient(180deg,
      var(--sky-high) 0 22%,
      var(--sky) 22% 64%,
      var(--sky-low) 64% 88%,
      var(--dusk) 88% 100%);
}

.page {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 28px var(--gutter) 48px;
}

/* ---------- the sign headline ---------- */
.sign {
  margin: 0;
  font-family: var(--sign);
  font-weight: 400;
  font-size: clamp(3rem, 17vw, 5.6rem);
  line-height: 0.95;
  color: var(--paper);
  text-transform: uppercase;
  -webkit-text-stroke: 7px var(--ink);
  paint-order: stroke fill;
  text-shadow: 5px 6px 0 var(--ink);
  transform: rotate(-2deg);
  transform-origin: left center;
}
/* the line under the headline is the first caption box */
.sign .trail {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin-top: 1rem;
  padding: 8px 12px;
  font-family: var(--type);
  font-size: 1.2rem;
  line-height: 1.3;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--caption);
  border: var(--line) solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  -webkit-text-stroke: 0;
  text-shadow: none;
  transform: rotate(2.6deg);
}

/* ---------- the blot: a white panel, like the mask ---------- */
.plate {
  position: relative;
  margin: 30px auto 10px;
  width: min(100%, 340px);
  aspect-ratio: 4 / 5;
  padding: 10px;
  background: var(--paper);
  border: 4px solid var(--ink);
  box-shadow: 7px 7px 0 var(--ink);
}
.plate canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: auto;
}
.plate-number {
  width: fit-content;
  margin: 16px auto 28px;
  padding: 2px 12px;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink);
}

/* ---------- panels: forms and the entry ---------- */
form,
.result {
  background: var(--caption);
  border: var(--line) solid var(--ink);
  box-shadow: var(--shadow);
  padding: 20px 18px;
}

form { display: grid; gap: 18px; }
label {
  display: grid;
  gap: 6px;
  font-size: 1.2rem;
  text-transform: uppercase;
  color: var(--ink);
}
.hint { text-transform: none; color: var(--muted); font-size: 1.05rem; }
input[type="text"],
input[type="password"] {
  font: inherit;
  font-family: var(--type);
  font-size: 1.3rem;
  padding: 8px 10px;
  border: var(--line) solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  width: 100%;
}
input[type="text"]::placeholder,
input[type="password"]::placeholder { color: #8a7f6c; }
input[type="text"]:focus,
input[type="password"]:focus { outline: none; box-shadow: 4px 4px 0 var(--ink); }

.honey { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.button {
  appearance: none;
  font: inherit;
  font-family: var(--type);
  font-size: 1.4rem;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--mustard);
  color: var(--ink);
  border: var(--line) solid var(--ink);
  border-radius: 0;
  box-shadow: 4px 4px 0 var(--ink);
  padding: 12px 18px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-block;
}
.button:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.button:disabled { opacity: 0.6; cursor: progress; }
.button.secondary { background: var(--paper); }

:focus-visible { outline: 3px dashed var(--focus); outline-offset: 4px; }

.form-error {
  margin: 0;
  color: var(--stamp);
  min-height: 1.4em;
}

/* ---------- the entry (result + archive): a journal caption ---------- */
.entry {
  font-family: var(--type);
  font-size: 1.3rem;
  line-height: 1.35;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0;
}
.entry .stamp { color: var(--stamp); }

.result { margin-top: 8px; }
.result .entry { font-size: 1.5rem; min-height: 5em; }
.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 22px;
}
.result-actions .button { width: 100%; font-size: 1.2rem; padding: 12px 8px; }
.result-actions .wide { grid-column: 1 / -1; }

.status {
  color: var(--muted);
  margin: 18px 0 0;
}

/* ---------- archive: a stack of caption panels ---------- */
.archive-head { margin-bottom: 30px; }
.archive-head .sign { font-size: clamp(2.6rem, 13vw, 4.4rem); }
.archive-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
.archive-list li {
  padding: 16px;
  background: var(--caption);
  border: var(--line) solid var(--ink);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: start;
}
.archive-list li:nth-child(odd) { transform: rotate(-0.5deg); }
.archive-list li:nth-child(even) { transform: rotate(0.4deg); }
.archive-list li:target, .archive-list li.highlight { background: var(--mustard); }
.archive-list .entry { font-size: 1.2rem; }

.play {
  appearance: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: var(--line) solid var(--ink);
  background: var(--paper);
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--ink);
  flex: none;
}
.play svg { width: 18px; height: 18px; }
.play[aria-pressed="true"] { background: var(--ink); color: var(--mustard); }
.play:disabled { opacity: 0.35; cursor: default; }

.empty {
  color: var(--ink);
  padding: 16px;
  background: var(--paper);
  border: var(--line) solid var(--ink);
}
.empty a { color: var(--stamp); }

/* ---------- the walk map: a real street map, inked and printed ---------- */
.map-panel { margin: 0 0 34px; }
.map {
  position: relative;
  height: min(68vh, 560px);
  background: var(--paper);
  border: 4px solid var(--ink);
  box-shadow: 7px 7px 0 var(--ink);
  font-family: var(--type);
  z-index: 0;
}
.map.leaflet-container { background: #e6dcc3; }   /* city blocks: newsprint, a shade darker than the roads */
.street-name {
  position: absolute;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  padding: 0 4px;
  font-family: var(--type);
  font-size: 0.82rem;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: rgba(245, 240, 226, 0.88);
}
/* a dot screen over the whole panel, as if printed */
.map::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 450;
  pointer-events: none;
  background: radial-gradient(rgba(40, 0, 20, 0.12) 1px, transparent 1.5px) 0 0 / 5px 5px;
}
.map-key { margin: 16px 0 0; color: var(--on-sky); font-size: 1.1rem; }

.map-mark { background: none; border: 0; }
.map-pin {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--mustard);
  border: 3px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
}
.map-dot, .map-live {
  position: absolute;
  left: -8px;
  top: -8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--paper);
  border: 3px solid var(--ink);
}
.map-live { background: var(--stamp); animation: live 1.6s ease-out infinite; }
@keyframes live {
  0% { box-shadow: 0 0 0 0 rgba(176, 16, 44, 0.6); }
  100% { box-shadow: 0 0 0 16px rgba(176, 16, 44, 0); }
}
.map-tag {
  position: absolute;
  left: 0;
  bottom: 14px;
  transform: translateX(-50%) rotate(-3deg);
  white-space: nowrap;
  padding: 1px 8px;
  font-family: var(--type);
  font-size: 0.95rem;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--caption);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
}

.map .leaflet-popup-content-wrapper {
  background: var(--caption);
  color: var(--ink);
  border: var(--line) solid var(--ink);
  border-radius: 0;
  box-shadow: 4px 4px 0 var(--ink);
}
.map .leaflet-popup-tip { background: var(--caption); border: var(--line) solid var(--ink); box-shadow: none; }
.map .leaflet-popup-content { margin: 12px 14px; font-family: var(--type); line-height: 1.3; }
.map .leaflet-popup-content .entry { font-size: 1.05rem; }
.map .leaflet-popup-content .button { margin-top: 10px; font-size: 1rem; padding: 6px 14px; }
.map a.leaflet-popup-close-button { color: var(--ink); }
.map .leaflet-bar { border: var(--line) solid var(--ink); border-radius: 0; box-shadow: 3px 3px 0 var(--ink); }
.map .leaflet-bar a {
  background: var(--paper);
  color: var(--ink);
  border-bottom-color: var(--ink);
  border-radius: 0 !important;
  font-family: var(--type);
}
.map .leaflet-control-attribution { background: rgba(245, 240, 226, 0.85); font-family: system-ui, sans-serif; font-size: 10px; }

.locate {
  appearance: none;
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 1rem;
  text-transform: uppercase;
  text-decoration: underline;
  color: var(--stamp);
  cursor: pointer;
}

/* ---------- footer, set straight on the sky ---------- */
.foot {
  margin-top: 48px;
  padding-top: 16px;
  border-top: var(--line) solid var(--ink);
  font-size: 1.05rem;
  color: var(--on-sky);
  display: grid;
  gap: 8px;
}
.foot p { margin: 0; }
.foot a { color: var(--on-sky); }
.nav-links { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 4px; }
.nav-links a { text-transform: uppercase; letter-spacing: 0.03em; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
