/* ============================================================
   SIDEWALK — a city journal you walk through.
   Riso-print visual system: warm paper, ink line-art, one
   overprint color per district. Buildings stand on a pavement
   strip; a tiny pedestrian walks as you scroll the block.
   ============================================================ */

/* ---------- fonts ---------- */
@font-face {
  font-family: 'Oswald';
  src: url('assets/oswald.ttf') format('truetype');
  font-weight: 200 700;
  font-display: swap;
}
@font-face {
  font-family: 'Literata';
  src: url('assets/literata.ttf') format('truetype');
  font-weight: 300 900;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('assets/ibm-plex-mono.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

/* ---------- tokens ---------- */
:root {
  --paper: #f4ecda;
  --paper-2: #eadfc4;
  --paper-3: #fbf5e4;
  --ink: #22201c;
  --ink-2: #57503f;
  --ink-soft: rgba(34, 32, 28, .16);

  --teal: #1f6a58;
  --tomato: #b03a20;
  --cobalt: #2b4c9b;
  --mustard: #8a6206;
  --violet: #7c3580;
  --leaf: #5c6e3f;
  --blade: #17503f;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
[hidden] { display: none !important; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }
button:not(:disabled):hover { cursor: pointer; }

body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Literata', Georgia, serif;
  -webkit-font-smoothing: antialiased;
}

/* paper grain over everything, purely decorative */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  opacity: .16;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='160'%20height='160'%3E%3Cfilter%20id='n'%3E%3CfeTurbulence%20type='fractalNoise'%20baseFrequency='0.9'%20numOctaves='2'/%3E%3CfeColorMatrix%20values='0%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200.6%200'/%3E%3C/filter%3E%3Crect%20width='160'%20height='160'%20filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- a11y helpers ---------- */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}
.skip {
  position: fixed; top: -60px; left: 12px; z-index: 300;
  background: var(--ink); color: var(--paper-3);
  font-family: 'IBM Plex Mono', monospace; font-size: 13px;
  padding: 10px 14px; text-decoration: none;
  transition: top .15s ease;
}
.skip:focus { top: 12px; }

:focus-visible {
  outline: 3px dashed var(--ink);
  outline-offset: 3px;
  border-radius: 1px;
}

::selection { background: var(--mustard); color: var(--paper-3); }

/* ============================================================
   MASTHEAD — the corner blade sign
   ============================================================ */
.masthead {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px 12px;
  background: linear-gradient(var(--paper-3), var(--paper-2));
  border-bottom: 3px solid var(--ink);
  flex: 0 0 auto;
}
.blade {
  margin: 0;
  background: var(--blade);
  color: #f6efdc;
  font-family: 'Oswald', 'Arial Narrow', sans-serif;
  font-weight: 600;
  font-size: 30px;
  letter-spacing: .16em;
  padding: 8px 20px 7px;
  border: 3px solid #f6efdc;
  outline: 3px solid var(--blade);
  box-shadow: 5px 6px 0 var(--ink-soft);
  transform: rotate(-1.2deg);
  white-space: nowrap;
  user-select: none;
}
.mast-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mast-tag {
  margin: 0;
  font-family: 'Oswald', 'Arial Narrow', sans-serif;
  font-weight: 500;
  font-size: 15px;
  letter-spacing: .22em;
  text-transform: uppercase;
}
.mast-note {
  margin: 0;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  letter-spacing: .04em;
  color: var(--ink-2);
}

/* ============================================================
   CONTROLS — the sorting desk
   ============================================================ */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 16px;
  padding: 12px 24px 14px;
  background: var(--paper-2);
  border-bottom: 3px solid var(--ink);
  flex: 0 0 auto;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field label,
.controls .count,
.hint,
.stamp,
.btn,
.clips-toggle,
.no,
.b-meta,
.d-meta,
.window-tag,
.pavement-note,
.d-foot-note,
.d-fig figcaption,
.b-open,
.empty-copy {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
}
.field label {
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-2);
}
input[type="search"], select {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  color: var(--ink);
  background: var(--paper-3);
  border: 2px solid var(--ink);
  border-radius: 0;
  padding: 9px 12px;
  box-shadow: 3px 3px 0 var(--ink-soft);
  appearance: none;
}
.field-search input { width: min(280px, 60vw); }
select {
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2322201c' stroke-width='2.4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  cursor: pointer;
}

.clips-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  letter-spacing: .08em;
  padding: 9px 14px;
  background: var(--paper-3);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink-soft);
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.clips-toggle .ic { width: 16px; height: 16px; flex: 0 0 auto; }
.clips-toggle[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper-3);
  transform: rotate(-.8deg);
}

.count {
  margin: 0 0 0 auto;
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding-bottom: 4px;
}

/* ============================================================
   THE STREET — horizontal block of story doors
   ============================================================ */
.street {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 84% 10%, rgba(224, 168, 62, .55) 0 88px, transparent 89px),
    radial-gradient(circle at 76% 6%, rgba(224, 168, 62, .28) 0 130px, transparent 131px),
    linear-gradient(#f7f0dd, var(--paper));
}
.hint {
  position: absolute;
  top: 14px;
  z-index: 8;
  margin: 0;
  font-size: 10.5px;
  letter-spacing: .22em;
  background: var(--ink);
  color: var(--paper-3);
  padding: 6px 10px;
  opacity: .88;
  pointer-events: none;
}
.hint-r { right: 18px; }
.hint-l { left: 18px; }

.street-viewport {
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.street-viewport::-webkit-scrollbar { display: none; }

.street-content {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  height: 100%;
  width: 100%;
  min-width: max-content;
  padding: 30px 7vw 82px 4vw;
}
.street-content.is-empty {
  width: 100%;
  min-width: 0;
  padding-bottom: 96px;
}

/* ---------- street furniture (decorative) ---------- */
.prop { flex: 0 0 auto; user-select: none; pointer-events: none; }

/* ---------- buildings / story items ---------- */
.bldg {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 238px;
  min-height: 400px;
  border: 3px solid var(--ink);
  background: #f8f1de;
  background: color-mix(in srgb, var(--cat) 15%, #f8f1de);
  box-shadow: 7px 8px 0 var(--ink-soft);
  scroll-snap-align: center;
}
/* varied skyline */
.n0 { height: 86%; } .n1 { height: 78%; } .n2 { height: 93%; } .n3 { height: 82%; }
.n4 { height: 76%; } .n5 { height: 89%; } .n6 { height: 80%; } .n7 { height: 91%; }

.cat-places   { --cat: var(--teal); }
.cat-food     { --cat: var(--tomato); }
.cat-movement { --cat: var(--cobalt); }
.cat-people   { --cat: var(--mustard); }
.cat-culture  { --cat: var(--violet); }

.roof { height: 10px; background: var(--ink); flex: 0 0 auto; }
.sign {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--cat);
  color: #f8f1de;
  font-family: 'Oswald', 'Arial Narrow', sans-serif;
  font-weight: 500;
  font-size: 15px;
  letter-spacing: .18em;
  text-transform: uppercase;
  border-bottom: 3px solid var(--ink);
  flex: 0 0 auto;
}
.no {
  font-size: 10.5px;
  letter-spacing: .06em;
  border: 1px solid rgba(248, 241, 222, .8);
  padding: 1px 5px;
  flex: 0 0 auto;
}
.awning {
  position: relative;
  height: 20px;
  background: repeating-linear-gradient(90deg, var(--cat) 0 22px, #f4ecda 22px 44px);
  border-bottom: 3px solid var(--ink);
  flex: 0 0 auto;
}
.awning::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -9px;
  height: 9px;
  background-image: radial-gradient(11px at 11px 0, var(--cat) 10px, transparent 11px);
  background-size: 22px 9px;
  background-repeat: repeat-x;
}
.window {
  position: relative;
  margin: 12px 10px 0;
  height: 104px;
  overflow: hidden;
  border: 2px solid var(--ink);
  background: #3a4750;
  background: color-mix(in srgb, var(--cat) 62%, #262b33);
  flex: 0 0 auto;
}
.window img {
  width: 100%; height: 100%;
  object-fit: cover;
  mix-blend-mode: screen;
  filter: grayscale(1) contrast(1.18) brightness(1.03);
}
.window-tag {
  position: absolute;
  right: 4px; bottom: 4px;
  font-size: 8.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  background: rgba(251, 245, 228, .9);
  color: var(--ink);
  padding: 1px 4px;
  border: 1px solid var(--ink);
}

/* the door is the open-item control; the story bill is pinned on it */
.doorway {
  flex: 1 1 auto;
  display: flex;
  margin: 14px 10px 12px;
  padding: 11px;
  border: 4px solid #3c2a1c;
  background: repeating-linear-gradient(90deg, #6a4b31 0 16px, #5d4029 16px 32px);
  box-shadow: 0 7px 0 rgba(28, 24, 18, .28);
  transform-origin: left center;
  transition: transform .22s ease;
  text-align: left;
  position: relative;
  min-height: 150px;
}
.doorway:hover, .doorway:focus-visible {
  transform: perspective(820px) rotateY(-7deg);
}
.doorway::after {
  content: '';
  position: absolute;
  top: 50%; right: 8px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #d8b25f;
  border: 2px solid #3c2a1c;
  transform: translateY(-50%);
}
.bill {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 100%;
  margin-right: 22px;
  padding: 13px 12px 12px;
  background: var(--paper-3);
  border: 2px solid var(--ink);
  box-shadow: 4px 5px 0 rgba(28, 24, 18, .22);
  transform: rotate(-.7deg);
}
.b-head {
  margin: 0;
  font-family: 'Oswald', 'Arial Narrow', sans-serif;
  font-weight: 600;
  font-size: 19px;
  line-height: 1.16;
  letter-spacing: .01em;
}
.b-meta {
  font-size: 10px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.b-teaser {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  font-style: italic;
  color: #3d382e;
}
.b-open {
  margin-top: auto;
  align-self: flex-start;
  font-size: 10.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  background: var(--cat);
  color: #f8f1de;
  border: 2px solid var(--ink);
  padding: 4px 8px;
}
.clip-pin {
  position: absolute;
  top: -15px; right: -8px;
  width: 22px; height: 22px;
  transform: rotate(26deg);
  color: var(--ink);
  display: none;
}
.clip-pin svg { width: 100%; height: 100%; }
.bldg.clipped .clip-pin { display: block; }

/* ---------- endcap: crosswalk + end-of-block sign ---------- */
.endcap {
  flex: 0 0 auto;
  width: 170px;
  align-self: stretch;
  border: 3px solid var(--ink);
  background:
    repeating-linear-gradient(180deg, #e9e2cf 0 20px, transparent 20px 42px),
    #3a352c;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 26px;
}
.endcap .end-sign {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  background: var(--paper-3);
  border: 2px solid var(--ink);
  padding: 6px 10px;
  color: var(--ink);
  text-align: center;
  transform: rotate(-1.5deg);
  margin-bottom: 10px;
}

/* ---------- sidewalk strip ---------- */
.sidewalk {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 96px;
  z-index: 5;
  pointer-events: none;
  border-top: 3px solid var(--ink);
  background:
    repeating-linear-gradient(90deg, transparent 0 136px, rgba(34, 32, 28, .28) 136px 139px),
    repeating-linear-gradient(180deg, transparent 0 30px, rgba(34, 32, 28, .1) 30px 32px),
    linear-gradient(#d1c39f, #c2b48c);
}
.pavement-note {
  position: absolute;
  left: 0; right: 0; bottom: 7px;
  margin: 0;
  text-align: center;
  font-size: 9.5px;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: rgba(34, 32, 28, .48);
  white-space: nowrap;
  overflow: hidden;
}

/* ---------- the pedestrian ---------- */
.walker {
  position: absolute;
  bottom: 16px;
  width: 44px; height: 62px;
  z-index: 6;
  will-change: left;
}
.walker svg { display: block; }
.walker .leg { transform-box: view-box; transform-origin: 18px 33px; }
.walker .l1 { animation: legA .52s infinite alternate ease-in-out; }
.walker .l2 { animation: legB .52s infinite alternate ease-in-out; }
.walker .arm { transform-box: view-box; transform-origin: 20px 16px; animation: armA .52s infinite alternate ease-in-out; }
.walker { animation: bob .52s infinite alternate ease-in-out; }
.walker.flip svg { transform: scaleX(-1); }
@keyframes legA { from { transform: rotate(-26deg); } to { transform: rotate(22deg); } }
@keyframes legB { from { transform: rotate(22deg); } to { transform: rotate(-26deg); } }
@keyframes armA { from { transform: rotate(16deg); } to { transform: rotate(-18deg); } }
@keyframes bob { from { margin-bottom: 0; } to { margin-bottom: 3px; } }

/* ---------- empty state ---------- */
.empty {
  width: 100%;
  height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  gap: 16px;
  padding: 20px;
}
.deadend {
  font-family: 'Oswald', 'Arial Narrow', sans-serif;
  font-weight: 600;
  font-size: clamp(26px, 5vw, 40px);
  letter-spacing: .24em;
  background: #b04a17;
  color: var(--paper-3);
  border: 3px solid var(--ink);
  padding: 10px 26px 8px;
  transform: rotate(-2deg);
  box-shadow: 6px 7px 0 var(--ink-soft);
}
.empty-title {
  margin: 0;
  font-family: 'Oswald', 'Arial Narrow', sans-serif;
  font-weight: 500;
  font-size: 22px;
  letter-spacing: .04em;
}
.empty-copy {
  margin: 0;
  max-width: 46ch;
  font-size: 12.5px;
  line-height: 1.7;
  letter-spacing: .03em;
  color: var(--ink-2);
  text-transform: none;
}
.empty-recover {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  letter-spacing: .1em;
  background: var(--mustard);
  color: var(--paper-3);
  border: 3px solid var(--ink);
  padding: 12px 18px;
  box-shadow: 4px 5px 0 var(--ink-soft);
  transform: rotate(-.8deg);
  transition: transform .15s ease;
}
.empty-recover:hover { transform: rotate(.4deg) translateY(-2px); }

/* ============================================================
   DETAIL — the handbill inside the doorway
   ============================================================ */
.detail {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow-y: auto;
  background: rgba(26, 21, 15, .78);
  animation: fadeIn .3s both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: relative;
  width: min(760px, 94vw);
  margin: 5vh auto 9vh;
  background: var(--paper-3);
  border: 3px solid var(--ink);
  box-shadow: 10px 12px 0 rgba(10, 8, 5, .38);
  transform: rotate(-.35deg);
  animation: doorIn .5s cubic-bezier(.22, .85, .3, 1.04) both;
}
@keyframes doorIn {
  from { transform: perspective(1100px) rotateY(-16deg) translateX(70px); opacity: .2; }
  to { transform: rotate(-.35deg) translateX(0); opacity: 1; }
}

/* rubber stamp when the story is clipped */
.sheet.clipped::after {
  content: 'CLIPPED';
  position: absolute;
  top: 76px; right: 26px;
  font-family: 'Oswald', 'Arial Narrow', sans-serif;
  font-weight: 600;
  font-size: 34px;
  letter-spacing: .18em;
  color: rgba(176, 58, 32, .55);
  border: 4px solid rgba(176, 58, 32, .55);
  padding: 4px 14px 2px;
  transform: rotate(-13deg);
  pointer-events: none;
  z-index: 3;
}

.sheet-inner { padding: 24px 30px 34px; }
.sheet-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  background: var(--paper-3);
  border: 2px solid var(--ink);
  padding: 9px 13px;
  box-shadow: 3px 3px 0 var(--ink-soft);
  transition: transform .15s ease;
}
.btn:hover { transform: translateY(-2px) rotate(-.5deg); }
.btn .ic { width: 15px; height: 15px; }
#dSave[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper-3);
  transform: rotate(-1deg);
}

.stamp {
  display: inline-block;
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  background: var(--cat, var(--ink));
  color: #f8f1de;
  border: 2px solid var(--ink);
  padding: 4px 10px;
  transform: rotate(-1.2deg);
  margin: 0;
}
#d-title {
  margin: .3em 0 .35em;
  font-family: 'Oswald', 'Arial Narrow', sans-serif;
  font-weight: 600;
  font-size: clamp(30px, 4.6vw, 44px);
  line-height: 1.07;
  letter-spacing: .005em;
  text-wrap: balance;
}
.d-meta {
  margin: 0;
  font-size: 11.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.d-fig {
  margin: 20px 0 22px;
  border: 3px solid var(--ink);
  background: #efe6cf;
}
.d-fig img {
  width: 100%;
  height: 250px;
  object-fit: cover;
  filter: sepia(.22) saturate(1.02) contrast(1.02);
}
.d-fig figcaption {
  padding: 8px 12px;
  border-top: 3px solid var(--ink);
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #4a453a;
}
.d-body p {
  margin: 0 0 1.15em;
  font-size: 17.5px;
  line-height: 1.72;
}
.d-body p:first-child::first-letter {
  font-family: 'Oswald', 'Arial Narrow', sans-serif;
  font-weight: 600;
  font-size: 3.4em;
  line-height: .78;
  float: left;
  padding: 8px 10px 0 0;
}
.d-foot {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 3px dashed rgba(34, 32, 28, .4);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.d-foot-note {
  margin: 0;
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.d-nav { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .masthead { gap: 14px; padding: 10px 16px 9px; }
  .blade { font-size: 20px; padding: 6px 12px 5px; letter-spacing: .14em; }
  .mast-tag { font-size: 12px; letter-spacing: .18em; }
  .mast-note { display: none; }
  .controls { gap: 10px 12px; padding: 10px 16px 12px; }
  .field-search input { width: min(240px, 54vw); }
  .count { display: none; }
  .street-content { gap: 12px; padding: 20px 6vw 82px 16px; }
  .bldg { width: clamp(258px, 74vw, 330px); min-height: 380px; }
  .window { height: 92px; }
  .b-head { font-size: 18px; }
  .sheet { width: 100%; margin: 0; border: none; border-top: 6px solid var(--ink); box-shadow: none; transform: none; min-height: 100%; }
  @keyframes doorIn { from { transform: translateY(36px); opacity: .2; } to { transform: none; opacity: 1; } }
  .sheet-inner { padding: 18px 18px 30px; }
  .d-fig img { height: 190px; }
  .d-body p { font-size: 16.5px; }
  .pavement-note { letter-spacing: .18em; }
  .endcap { display: none; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .walker .leg, .walker .arm, .walker { animation: none !important; }
  .doorway:hover, .doorway:focus-visible { transform: none; }
  .sheet { animation: none !important; }
  .detail { animation: none !important; }
}
