/* Mumbai Villagers: the village is the app. The scene fills the screen and pans; the title, pages, CA and keys live in
   one hut window with open shutters. Colours are the art's materials: whitewash, red earth, saffron sky, lungi indigo,
   banyan green, weathered wood and ink-brown outlines. */
:root {
  --ink: oklch(25% 0.045 45);
  --ink-soft: oklch(40% 0.05 50);
  --cream: oklch(95.5% 0.03 85);
  --cream-deep: oklch(90% 0.05 80);
  --paper: oklch(96.5% 0.025 90);
  --saffron: oklch(77% 0.16 62);
  --saffron-deep: oklch(66% 0.18 48);
  --clay: oklch(55% 0.14 38);
  --clay-dark: oklch(44% 0.12 36);
  --indigo: oklch(31% 0.08 268);
  --indigo-soft: oklch(42% 0.09 268);
  --leaf: oklch(50% 0.12 150);
  --turquoise: oklch(60% 0.1 195);
  --turquoise-dark: oklch(48% 0.09 200);
  --marigold: oklch(81% 0.16 80);
  --rose: oklch(62% 0.15 15);
  --wood: oklch(50% 0.08 55);
  --wood-dark: oklch(38% 0.07 50);
  --ledger-red: oklch(55% 0.17 25);

  --display: "Shrikhand", "Georgia", serif;
  --hand: "Kalam", "Comic Sans MS", cursive;
  --body: "Hind", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Menlo", monospace;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --win-left: 74px;
  --win-top: 22px;
  --win-w: 336px;
  --scene-ratio: 2.357; /* the panorama is 6336 × 2688 */
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--saffron);
  color: var(--ink);
  font: 400 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
h1, h2, h3 { margin: 0; font-weight: 400; text-wrap: balance; }
p { margin: 0; }
[hidden] { display: none !important; }

/* ---------- the scene ---------- */
.viewport {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end; /* a screen wider than the panorama crops the sky, never the feet */
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  cursor: grab;
  overscroll-behavior: contain;
}
.viewport::-webkit-scrollbar { display: none; }
.viewport.panning { cursor: grabbing; }
.scene {
  position: relative;
  flex: none;
  height: max(100svh, calc(100vw / var(--scene-ratio)));
  aspect-ratio: 6336 / 2688;
  transition: filter 0.6s var(--ease);
}
.scene.dim { filter: saturate(0.75) brightness(0.62); }
.village { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; user-select: none; -webkit-user-drag: none; }
.scene { container-type: size; }
.stall-sign { /* painted over the generated board, whose letters came out garbled */
  position: absolute;
  left: 58.1%;
  top: 66.5%;
  width: 4.3%;
  height: 7%;
  display: grid;
  place-items: center;
  font: 400 2.5cqh/1 var(--display);
  color: var(--clay-dark);
  background: oklch(93% 0.05 85);
  border: 0.3cqh solid var(--ink);
  border-radius: 0.5cqh;
  rotate: -2deg;
}

.bunting { position: absolute; inset: 0; pointer-events: none; }
.bunting svg { display: block; width: 100%; height: 100%; overflow: visible; }
.bunting .cord { fill: none; stroke: var(--ink); stroke-width: 5; stroke-linecap: round; opacity: 0.85; }
.bunting .cloth { fill: var(--c); stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; }
.bunting .fold { fill: var(--ink); opacity: 0.12; }
.bunting .hem { fill: var(--c); stroke: var(--ink); stroke-width: 4; }
.bunting .back { opacity: 0.82; }
.bunting .back .cord { stroke-width: 4; }
.bunting .flag {
  transform-box: fill-box;
  transform-origin: 50% 0;
  animation: sway 4s ease-in-out infinite alternate;
  animation-delay: var(--d);
}
@keyframes sway { from { transform: rotate(-4deg); } to { transform: rotate(5deg); } }

/* each villager stands at (x, y) in % of the scene, his feet; his height follows the depth (the horizon is at 59 %,
   so h = y - 59 and every head sits on it). Moving him is transform only: a translate in container units plus a
   scale from a 30 % base, so walking never re-lays the page. */
.villager {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 30cqh;
  aspect-ratio: var(--ar, 0.45);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transform: translate(calc(var(--x) * 1cqw - 50%), calc((var(--y) - 100) * 1cqh)) scale(var(--s));
  transform-origin: 50% 100%;
  will-change: transform;
}
.villager .body { display: block; width: 100%; height: 100%; transition: translate 0.35s var(--ease); }
.villager .gait { display: block; width: 100%; height: 100%; transform-origin: 50% 100%; animation: breathe 3.2s ease-in-out infinite; }
.villager.left .gait { scale: -1 1; }
.villager.walking .gait { animation: waddle 0.46s ease-in-out infinite; }
.villager.shout .gait { animation: hop 0.6s var(--ease); }
@keyframes breathe { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(1.012) translateY(-0.2%); } }
@keyframes waddle {
  0%, 100% { transform: translateY(0) rotate(-3.5deg); }
  25% { transform: translateY(-3.5%) rotate(0deg); }
  50% { transform: translateY(0) rotate(3.5deg); }
  75% { transform: translateY(-3.5%) rotate(0deg); }
}
@keyframes hop { 0% { transform: none; } 35% { transform: translateY(-9%) scaleY(1.03); } 70% { transform: translateY(0) scaleY(0.97); } 100% { transform: none; } }
.villager img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 0.6cqh 0 oklch(25% 0.06 40 / 0.22)); user-select: none; -webkit-user-drag: none; pointer-events: none; }
.villager .body::after { /* his shadow on the earth */
  content: "";
  position: absolute;
  left: 20%; right: 20%; bottom: -1.5%;
  height: 4%;
  border-radius: 50%;
  background: oklch(30% 0.06 40 / 0.28);
  z-index: -1;
}
.villager:hover .body, .villager:focus-visible .body, .villager.lit .body { translate: 0 -2.5%; }
.villager:focus-visible { outline: none; }
.villager:focus-visible img, .villager.lit img { filter: drop-shadow(0 0 0.5cqh var(--marigold)) drop-shadow(0 0 0.2cqh var(--cream)); }

/* his tag rides on his head: inside the villager, so it walks with him to the pixel, and counter-scaled so it reads
   the same near and far. Over his head, not the picture's middle (--head), mirrored when he faces left. */
.tag {
  position: absolute;
  left: calc(var(--head, 0.5) * 100%);
  bottom: 100%;
  display: grid;
  grid-template-columns: auto auto;
  gap: 1px 7px;
  align-items: center;
  padding: 5px 10px 5px 6px;
  white-space: nowrap;
  text-align: left;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 9px;
  box-shadow: 2px 2px 0 var(--ink);
  transform-origin: 50% 100%;
  translate: -50% -4px;
  scale: calc(1 / var(--s, 1));
  transition: opacity 0.35s var(--ease);
}
.villager.left .tag { left: calc((1 - var(--head, 0.5)) * 100%); }
.tag::after { /* the tail down to his head */
  content: "";
  position: absolute;
  left: 50%; bottom: -7px;
  width: 10px; height: 10px;
  translate: -50% 0;
  rotate: 45deg;
  background: var(--paper);
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
}
.tag.shy { opacity: 0.14; }
.badge {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--coin);
  border: 2px solid var(--ink);
  font: 400 13px/1 var(--display);
  color: var(--paper);
  text-shadow: 1px 1px 0 var(--ink);
  overflow: hidden;
}
.badge img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tag-ticker { font: 400 15px/1 var(--display); color: var(--clay-dark); }
.tag-who { font-size: 11px; line-height: 1.2; }
.tag-who b { font-weight: 600; }
.tag-who code { margin-left: 4px; font: 500 10px/1 var(--mono); color: var(--ink-soft); }

/* what he says about his coin: a speech bubble over his tag while he shouts, or while you point at him */
.say {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 12px);
  width: max-content;
  max-width: 250px;
  padding: 10px 14px 9px;
  white-space: normal;
  font: 400 16px/1.3 var(--hand);
  color: var(--ink);
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 18px 18px 18px 6px;
  box-shadow: 3px 3px 0 var(--ink);
  translate: -50% 0;
  opacity: 0;
  scale: 0.6;
  transform-origin: 30% 100%;
  pointer-events: none;
  transition: opacity 0.3s var(--ease), scale 0.45s var(--ease);
}
.say b { font: 400 15px/1 var(--display); color: var(--clay-dark); }
.say::after {
  content: "";
  position: absolute;
  left: 28%; bottom: -11px;
  width: 16px; height: 14px;
  background: var(--paper);
  border-right: 2.5px solid var(--ink);
  border-bottom: 2.5px solid var(--ink);
  transform: skewX(-35deg) rotate(10deg);
}
.villager.saying, .villager:hover { z-index: 5000 !important; }
.villager.saying .tag, .villager:hover .tag { opacity: 1; }
.villager.saying .say, .villager:hover .say { opacity: 1; scale: 1; }

.arrive .villager .body { animation: arrive 0.9s var(--ease) both; animation-delay: var(--delay); }
.arrive .villager .tag { animation: pop 0.7s var(--ease) both; animation-delay: calc(var(--delay) + 350ms); }
@keyframes arrive { from { opacity: 0; transform: translateY(4%); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.85); } to { opacity: 1; transform: none; } }

/* ---------- the window ---------- */
.window {
  position: fixed;
  top: var(--win-top);
  left: var(--win-left);
  width: var(--win-w);
  z-index: 20;
  perspective: 900px;
}
.pane {
  position: relative;
  padding: 20px 20px 16px;
  background:
    linear-gradient(oklch(97% 0.025 90 / 0.97), oklch(94% 0.035 85 / 0.97));
  border: 7px solid var(--wood);
  outline: 3px solid var(--ink);
  border-radius: 4px;
  box-shadow: 0 0 0 3px var(--ink) inset, 8px 10px 0 oklch(25% 0.05 45 / 0.55);
}
.pane::before { /* the lintel over the window */
  content: "";
  position: absolute;
  left: -26px; right: -26px; top: -24px;
  height: 14px;
  background: var(--wood-dark);
  border: 3px solid var(--ink);
  border-radius: 3px;
}
.shutter {
  position: absolute;
  top: 0;
  bottom: 12px;
  width: 64px;
  border: 3px solid var(--ink);
  border-radius: 3px;
  background:
    repeating-linear-gradient(0deg, transparent 0 20px, oklch(30% 0.06 220 / 0.55) 20px 23px),
    linear-gradient(90deg, var(--turquoise), var(--turquoise-dark));
  transition: transform 1.1s var(--ease);
}
.shutter-l { right: 100%; transform-origin: 100% 50%; transform: rotateY(-62deg); animation: swing-l 1.4s var(--ease) both 0.2s; }
.shutter-r { left: 100%; transform-origin: 0 50%; transform: rotateY(62deg); animation: swing-r 1.4s var(--ease) both 0.2s; }
@keyframes swing-l { from { transform: rotateY(-8deg); } to { transform: rotateY(-62deg); } }
@keyframes swing-r { from { transform: rotateY(8deg); } to { transform: rotateY(62deg); } }
.sill {
  display: block;
  height: 14px;
  margin: 0 -18px;
  background: var(--wood-dark);
  border: 3px solid var(--ink);
  border-radius: 2px;
  box-shadow: 4px 5px 0 oklch(25% 0.05 45 / 0.5);
}

.brand {
  font: 400 30px/1 var(--display);
  color: var(--saffron-deep);
  -webkit-text-stroke: 1.5px var(--ink);
  paint-order: stroke fill;
  text-shadow: 2px 2px 0 var(--ink);
  letter-spacing: 0.005em;
}
.tabs { display: flex; gap: 6px; margin-top: 16px; }
.tabs a {
  flex: 1;
  padding: 9px 0 7px;
  text-align: center;
  font: 600 15px/1 var(--body);
  color: var(--ink);
  text-decoration: none;
  background: var(--cream-deep);
  border: 2px solid var(--ink);
  border-radius: 8px;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease);
}
.tabs a:hover { transform: translateY(-2px); }
.tabs a[aria-current="page"] { background: var(--saffron); box-shadow: 2px 2px 0 var(--ink); }
.tabs a:focus-visible, .btn:focus-visible, .ca-copy:focus-visible { outline: 3px solid var(--indigo); outline-offset: 3px; }

.ca {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 8px 8px 8px 12px;
  background: oklch(99% 0.01 90 / 0.8);
  border: 2px dashed oklch(55% 0.06 55);
  border-radius: 8px;
}
.ca-tag { font: 400 14px/1 var(--display); color: var(--clay-dark); }
.ca-value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 16px/1.2 var(--hand); }
.ca.live .ca-value { font: 500 13px/1.2 var(--mono); }
.ca-copy {
  padding: 6px 12px 5px;
  font: 600 13px/1 var(--body);
  color: var(--ink);
  background: var(--marigold);
  border: 2px solid var(--ink);
  border-radius: 6px;
  cursor: pointer;
}
.ca-copy:disabled { opacity: 0.45; cursor: default; }

.actions { display: flex; gap: 8px; margin-top: 12px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  font: 600 16px/1 var(--body);
  color: var(--ink);
  text-decoration: none;
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn-buy { flex: 1; background: var(--saffron); }
.btn-x { width: 52px; padding: 0; background: var(--cream); font: 400 19px/1 var(--display); }
.preview { margin-top: 12px; font: 400 13px/1.3 var(--hand); color: var(--ink-soft); text-align: center; }

/* ---------- pages over the village ---------- */
.page {
  position: fixed;
  top: var(--win-top);
  bottom: var(--win-top);
  left: calc(var(--win-left) + var(--win-w) + 96px);
  right: 22px;
  z-index: 15;
  overflow-y: auto;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: 10px 12px 0 oklch(25% 0.05 45 / 0.5);
  animation: page-in 0.55s var(--ease) both;
  overscroll-behavior: contain;
}
.close {
  position: sticky;
  top: 14px;
  float: right;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 48px; height: 48px;
  margin: 14px 14px 0 0;
  font: 400 26px/1 var(--display);
  color: var(--ink);
  text-decoration: none;
  background: var(--marigold);
  border: 3px solid var(--ink);
  border-radius: 50%;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.close:hover { transform: translate(-2px, -2px) rotate(90deg); box-shadow: 5px 5px 0 var(--ink); }
.close:focus-visible { outline: 3px solid var(--indigo); outline-offset: 3px; }
@keyframes page-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.page-inner { padding: clamp(28px, 3vw, 48px); }
.page-head h1 { font: 400 clamp(36px, 3.6vw, 60px)/1 var(--display); }
.page-sub { margin-top: 10px; font-size: 18px; color: var(--ink-soft); }
.page-sub strong { color: var(--ink); }

.doors {
  list-style: none;
  margin: 36px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 40px 24px;
}
.door { display: grid; justify-items: center; text-align: center; scroll-margin: 40px; border-radius: 12px; padding: 14px 8px 18px; transition: background 0.4s var(--ease); }
.door.lit { background: oklch(90% 0.08 80 / 0.6); }
.door-frame {
  position: relative;
  width: 74%;
  aspect-ratio: 3 / 4.2;
  background: var(--door);
  border: 3px solid var(--ink);
  border-radius: var(--shape);
  box-shadow: inset 0 0 0 7px oklch(100% 0 0 / 0.09), 5px 5px 0 var(--ink);
}
.door-frame::after { /* the lamp over the door */
  content: "";
  position: absolute;
  top: -17px; left: 50%;
  width: 13px; height: 13px;
  translate: -50% 0;
  border-radius: 50%;
  background: var(--marigold);
  border: 2px solid var(--ink);
  box-shadow: 0 0 16px 4px oklch(85% 0.15 85 / 0.65);
}
.door-who { position: absolute; left: 50%; bottom: -4px; height: 92%; max-width: none; translate: -50% 0; transition: transform 0.35s var(--ease); }
.door:hover .door-who { transform: translateY(-6px); }
.door-plate {
  margin-top: 16px;
  padding: 6px 14px 3px;
  font: 400 22px/1 var(--display);
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 5px;
  box-shadow: 3px 3px 0 var(--ink);
}
.door-job { margin-top: 9px; font-weight: 600; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--clay-dark); }
.door-note { margin-top: 6px; font: 400 17px/1.3 var(--hand); max-width: 24ch; }
.door-facts { display: grid; gap: 6px; width: 100%; margin-top: 12px; font-size: 13px; }
.fact { display: flex; justify-content: space-between; gap: 10px; padding: 6px 10px; background: var(--paper); border: 1.5px solid oklch(70% 0.05 70); border-radius: 7px; }
.fact span:first-child { color: var(--ink-soft); }
.fact code { font: 500 12px/1.4 var(--mono); }
.fact .coin { display: inline-flex; align-items: center; gap: 6px; font: 400 14px/1 var(--display); color: var(--clay-dark); }
.fact .coin .badge { width: 22px; height: 22px; font-size: 11px; grid-row: auto; }
.door-says { margin-top: 10px; padding: 8px 12px; max-width: 26ch; font: 400 15px/1.3 var(--hand); color: var(--ink); background: var(--paper); border: 2px solid var(--ink); border-radius: 14px 14px 14px 4px; box-shadow: 2px 2px 0 var(--ink); }
.door-says:empty { display: none; }
.door-link { display: block; margin-top: 10px; font-weight: 600; font-size: 14px; color: var(--indigo-soft); text-decoration: none; }
a.door-link:hover { text-decoration: underline; }

/* the docs: a merchant's bahi-khata, red-ruled paper */
.page-docs { background: var(--paper); }
.ledger {
  max-width: 900px;
  background:
    linear-gradient(90deg, transparent 62px, var(--ledger-red) 62px 64px, transparent 64px 68px, var(--ledger-red) 68px 70px, transparent 70px),
    repeating-linear-gradient(to bottom, transparent 0 33px, oklch(80% 0.04 240 / 0.45) 33px 34px);
  padding-left: clamp(84px, 8vw, 104px);
}
.entries { list-style: none; margin: 34px 0 0; padding: 0; counter-reset: entry; display: grid; gap: 30px; }
.entries li { counter-increment: entry; position: relative; }
.entries li::before {
  content: counter(entry);
  position: absolute;
  left: -64px; top: 2px;
  width: 40px;
  text-align: right;
  font: 700 26px/1 var(--hand);
  color: var(--ledger-red);
}
.entries h2 { font: 400 26px/1.15 var(--display); color: var(--indigo); }
.entries p { margin-top: 8px; max-width: 62ch; font-size: 17.5px; line-height: 1.6; }

/* ---------- phones ---------- */
@media (max-width: 760px) {
  :root { --win-left: 12px; --win-top: 12px; }
  .window { right: 12px; width: auto; }
  .shutter { display: none; }
  .pane { padding: 14px 14px 12px; border-width: 5px; }
  .pane::before { left: -12px; right: -12px; top: -16px; height: 10px; }
  .brand { font-size: 24px; }
  .tabs { margin-top: 10px; }
  .tabs a { padding: 8px 0 6px; font-size: 14px; }
  .ca { margin-top: 10px; }
  .actions { margin-top: 10px; }
  .btn { min-height: 42px; }
  .preview { display: none; }
  .sill { margin: 0 -8px; height: 10px; }
  .page { left: 12px; right: 12px; top: 268px; bottom: 12px; }
  .say { max-width: 200px; font-size: 15px; }
}

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