/* Tiny Town. One pixel scale, one palette, read off the town's own art:
   lime grass, cream walls, hard black outline, one warm orange for fire.
   Every surface here is a generated picture nine-sliced; the numbers in the
   border-image rules come from tools/measure.mjs, not from guessing. */

@font-face {
  font-family: "Departure Mono";
  src: url("/fonts/DepartureMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  --lime: #a5f83d;
  --lime-dark: #6cc21a;
  --lime-deep: #3d7a0f;
  --cream: #fdf7ea;
  --cream-shade: #ddd6c2;
  --ink: #0c0d0a;
  --void: #07090a;
  --fire: #ff6a18;
  --ember: #b3300c;
  --quiet: #6f6a5c;

  --pad: 34px;
  --bar: 52px;

  font-synthesis: none;
}

* { box-sizing: border-box; }

html {
  background: var(--void);
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--void);
  color: var(--cream);
  font-family: "Departure Mono", ui-monospace, "Cascadia Mono", monospace;
  font-size: 18px;
  line-height: 1.55;
  overflow-x: hidden;
}

img { image-rendering: pixelated; }

h1, h2, h3 { margin: 0; font-weight: 400; }
p { margin: 0; }
a { color: inherit; }

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

/* ============================================================ the town */

.town {
  position: relative;
  /* the tower lockup needs real height, so a short window scrolls rather than clipping it */
  min-height: max(100svh, 880px);
  overflow: hidden;
  background: var(--void);
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#map.dragging { cursor: grabbing; }

/* ---- the landmark: name, ticker, contract and every link on the tower */

.tower {
  position: absolute;
  left: clamp(20px, 2.5vw, 56px);
  bottom: clamp(18px, 3vh, 40px);
  width: clamp(330px, 26vw, 440px);
  z-index: 3;
  display: grid;
  gap: 16px;
}

.tower-stack {
  position: relative;
  line-height: 0;
}

.tower-art {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 8px 0 rgba(0, 0, 0, 0.5));
}

/* the blank face of the tank, measured by tools/measure.mjs */
.wordmark {
  position: absolute;
  left: 11.4%;
  top: 33.3%;
  width: 77%;
  height: 19.7%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(32px, 3.1vw, 50px);
  line-height: 1;
  color: var(--ink);
}

/* the riveted board slung between the legs */
.ticker {
  position: absolute;
  left: 30%;
  top: 66.5%;
  width: 39.8%;
  height: 9.9%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(17px, 1.6vw, 25px);
  line-height: 1;
  color: var(--lime-deep);
}

/* the contract plate bolted at the tower's feet */
.tower-plate {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 18px;
  align-items: center;
  padding: 18px 26px 20px;
  border-image: url("/img/plate.png") 6 26 8 18 fill / 6px 26px 8px 18px / 0 stretch;
  filter: drop-shadow(0 6px 0 rgba(0, 0, 0, 0.45));
}

.plate-label {
  grid-column: 1 / -1;
  font-size: 16px;
  color: var(--quiet);
}

.plate-ca {
  font-size: 17px;
  line-height: 1.35;
  color: var(--ink);
  overflow-wrap: anywhere;
  min-width: 0;
  user-select: all;
}
.plate-ca.pending { color: #8b8577; }

.tower-keys {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 56px;
  padding: 0 26px;
  font: inherit;
  font-size: 18px;
  line-height: 1.2;
  color: var(--ink);
  text-decoration: none;
  background: none;
  border: 0;
  cursor: pointer;
  border-image: url("/img/keycap.png") 15 19 13 8 fill / 15px 19px 13px 8px / 0 stretch;
  transition: transform 90ms steps(2);
}
.key img { width: 22px; height: 22px; image-rendering: auto; }
.key:hover { transform: translate(1px, 1px); }
.key:active { transform: translate(3px, 3px); }
.key[disabled],
.key.off {
  filter: grayscale(0.85) brightness(1.06);
  cursor: not-allowed;
  color: #5d5a50;
}
.key-buy { grid-column: 1 / -1; }
.key-copy { min-height: 50px; padding: 0 22px; font-size: 17px; }

.tower-note {
  min-height: 24px;
  font-size: 16px;
  color: var(--lime);
}

/* ---- the town's news, on slips pinned up beside the map */

.town .feed {
  position: absolute;
  top: clamp(18px, 3vh, 40px);
  right: clamp(18px, 2vw, 40px);
  width: clamp(300px, 24vw, 380px);
  z-index: 3;
}

.slips {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.slip {
  padding: 16px 20px 16px 26px;
  font-size: 16px;
  line-height: 1.4;
  color: var(--ink);
  border-image: url("/img/slip.png") 2 12 12 25 fill / 2px 12px 12px 25px / 0 stretch;
}
.slip-burned { color: var(--ember); }
.slip-grew,
.slip-built { color: var(--lime-deep); }
.slip-quiet { color: var(--quiet); }

.feed-count {
  margin-top: 14px;
  font-size: 16px;
  color: var(--lime);
}
.feed-sep { color: var(--lime-deep); }

/* ---- the town's wayfinding: four arm boards on a post */

.signpost {
  position: absolute;
  right: clamp(18px, 2vw, 44px);
  bottom: clamp(20px, 4vh, 52px);
  z-index: 3;
  display: grid;
  gap: 8px;
  justify-items: start;
  padding-left: 40px;
}

.post-art {
  position: absolute;
  left: 0;
  bottom: -14px;
  width: auto;
  height: clamp(190px, 24vh, 280px);
}

.arm {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 44px 0 24px;
  font-size: 18px;
  color: var(--ink);
  text-decoration: none;
  border-image: url("/img/arrow.png") 6 44 6 14 fill / 6px 44px 6px 14px / 0 stretch;
  transition: transform 90ms steps(2);
}
.arm:hover { transform: translateX(5px); }

.town-hint {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 2;
  font-size: 16px;
  color: var(--lime);
  text-shadow: 0 2px 0 var(--ink), 0 -2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink);
  transition: opacity 400ms linear;
}
.town-hint.gone { opacity: 0; pointer-events: none; }

/* ============================================================ the screens */

.screen {
  max-width: 1400px;
  margin: 0 auto;
  padding: 96px clamp(20px, 4vw, 56px) 0;
}
.screen:last-of-type { padding-bottom: 104px; }

.screen-title {
  font-size: clamp(28px, 3vw, 44px);
  line-height: 1.22;
  color: var(--lime);
  margin-bottom: 30px;
}

/* ---- the cream window is the one thing you read on */

.win {
  position: relative;
  /* the border area IS the frame, so the box reserves it and nothing overlaps the strip */
  border-style: solid;
  border-width: 50px 10px 10px 4px;
  border-image: url("/img/win-frame.png") 50 10 10 4 fill / 50px 10px 10px 4px / 0 stretch;
  color: var(--ink);
  filter: drop-shadow(0 8px 0 rgba(0, 0, 0, 0.4));
}

/* the striped strip is painted by the frame itself; the label sits on it */
.win-bar {
  position: absolute;
  left: 0;
  right: 0;
  top: -50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 14px 0 20px;
}

.win-name {
  font-size: 17px;
  line-height: 1;
  color: var(--ink);
  background: var(--cream);
  padding: 3px 10px;
}

.win-close {
  width: 26px;
  height: 26px;
  font: inherit;
  font-size: 16px;
  line-height: 1;
  color: var(--cream);
  background: var(--ink);
  border: 0;
  cursor: pointer;
}

.win-body { padding: var(--pad); }

/* ---- how it works */

.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 30px;
  align-items: start;
}

.step img {
  display: block;
  width: 100%;
  height: auto;
  margin-bottom: 18px;
  border: 3px solid var(--ink);
}

.step h3 {
  font-size: 20px;
  line-height: 1.3;
  margin-bottom: 10px;
  color: var(--lime-deep);
}

.step p {
  font-size: 17px;
  line-height: 1.5;
}

/* ---- your plot */

.find-label {
  display: block;
  font-size: 17px;
  color: var(--quiet);
  margin-bottom: 12px;
}

.find-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.find-input {
  flex: 1 1 320px;
  min-width: 0;
  height: 56px;
  padding: 0 18px;
  font: inherit;
  font-size: 18px;
  color: var(--ink);
  background: #fffdf6;
  border: 3px solid var(--ink);
  border-radius: 0;
}
.find-input::placeholder { color: #a9a294; }

.find-out { margin-top: 26px; min-height: 96px; }
.find-idle { color: var(--quiet); font-size: 17px; }
.find-good { color: var(--lime-deep); font-size: 19px; line-height: 1.45; }
.find-bad { color: var(--ember); font-size: 17px; }

/* ---- town hall */

.halls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 34px;
}

.hall-col h3 {
  font-size: 20px;
  line-height: 1.3;
  color: var(--lime-deep);
  padding-bottom: 12px;
  margin-bottom: 6px;
  border-bottom: 3px solid var(--ink);
}

.rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: baseline;
  padding: 13px 0;
  font-size: 17px;
  border-bottom: 2px solid var(--cream-shade);
  cursor: pointer;
}
.row:hover { color: var(--lime-deep); }
.row-who { overflow-wrap: anywhere; min-width: 0; }
.row-what { color: var(--quiet); }
.row-num { font-variant-numeric: tabular-nums; }
.row-burn { color: var(--ember); }
.row-empty { padding: 14px 0; color: #8b8577; font-size: 17px; }

.win-sunday { margin-top: 56px; }

.sunday {
  display: grid;
  grid-template-columns: minmax(320px, 440px) 1fr;
  gap: 40px;
  align-items: start;
}

.sunday-art {
  display: block;
  width: 100%;
  height: auto;
  border: 3px solid var(--ink);
}

.sunday-text h3 {
  font-size: 24px;
  line-height: 1.3;
  color: var(--lime-deep);
  margin-bottom: 14px;
}
.sunday-text p { font-size: 17px; line-height: 1.55; margin-bottom: 14px; }
.sunday-text p:last-child { margin-bottom: 0; }
.sunday-note { color: var(--quiet); }

/* ---- the house dialog */

.house-dialog {
  /* .win supplies the frame through border-image: never zero the border here or it vanishes */
  width: min(560px, calc(100vw - 32px));
  padding: 0;
  margin: auto;
  background: none;
  color: var(--ink);
  overflow: visible;
}
.house-dialog::backdrop { background: rgba(7, 9, 10, 0.74); }

.house-line { font-size: 19px; line-height: 1.45; color: var(--lime-deep); margin-bottom: 20px; }

.house-facts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px 22px;
  margin: 0 0 24px;
  font-size: 17px;
}
.house-facts dt { color: var(--quiet); }
.house-facts dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }
.mono { font-size: 15px; line-height: 1.4; }

.key-link { display: inline-flex; }

/* ============================================================== phone */

@media (max-width: 1240px) {
  .steps { grid-template-columns: repeat(2, 1fr); }
  .halls { grid-template-columns: 1fr; gap: 26px; }
  .sunday { grid-template-columns: 1fr; }
  .sunday-art { max-width: 460px; }
}

@media (max-width: 1000px) {
  body { font-size: 17px; }
  .town { min-height: auto; overflow: visible; }
  #map { position: relative; height: 56svh; min-height: 360px; }
  .tower,
  .town .feed,
  .signpost,
  .town-hint {
    position: static;
    width: auto;
    transform: none;
  }
  .tower {
    margin: 26px clamp(16px, 5vw, 28px) 0;
    grid-template-columns: minmax(150px, 230px) minmax(0, 1fr);
    grid-template-areas: "stack plate" "stack keys" "note note";
    gap: 14px 22px;
    align-items: end;
  }
  .tower-stack { grid-area: stack; }
  .tower-plate { grid-area: plate; }
  .tower-keys { grid-area: keys; }
  .tower-note { grid-area: note; }
  .town .feed { margin: 30px clamp(16px, 5vw, 28px) 0; width: auto; }
  .signpost {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-start;
    margin: 30px clamp(16px, 5vw, 28px) 0;
    padding: 0;
  }
  .post-art { display: none; }
  .town-hint {
    display: block;
    margin: 18px clamp(16px, 5vw, 28px) 0;
    text-shadow: none;
    color: var(--quiet);
  }
  .screen { padding-top: 72px; }
  .steps { grid-template-columns: 1fr; gap: 34px; }
  .step img { max-width: 520px; }
  :root { --pad: 24px; }
}

@media (max-width: 620px) {
  .tower {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "stack" "plate" "keys" "note";
  }
  .tower-stack { max-width: 300px; }
  .find-input { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .key, .arm { transition: none; }
}
