/* Town, lot view and the v2 home screen. Animate transform/opacity only. */

/* ---------- Home layout ---------- */

.hm { padding-top: 12px; padding-bottom: 32px; }
.hm > * { min-width: 0; }

.hm-hud {
  display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 16px;
  background: var(--sheet); border: 2px solid var(--ink);
}
.hm-rank { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hm-rank__emblem { width: 36px; height: 38px; flex: none; }
.hm-rank__initial { font-family: var(--f-display); }
.hm-rank__text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.hm-rank__kicker { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); }
.hm-rank__title { font-family: var(--f-display); font-size: var(--t-16); }
.hm-xp { flex: 1 1 200px; min-width: 140px; display: grid; gap: 4px; }
.hm-xp__bar { height: 12px; border: 2px solid var(--ink); background: var(--paper); overflow: hidden; }
.hm-xp__fill { display: block; width: 100%; height: 100%; background: var(--open); transform-origin: left center; }
.hm-xp__text { font-size: 0.8125rem; color: var(--ink-2); }
.hm-badges {
  display: inline-flex; align-items: baseline; gap: 6px; min-height: 44px; align-items: center;
  padding: 0 14px; border: 2px solid var(--ink); background: var(--paper);
  color: var(--ink); text-decoration: none; font-weight: 700;
}
.hm-badges:hover { background: #fff; }
.hm-badges__n { font-family: var(--f-display); font-size: var(--t-20); }

.hm-hero { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 32px; margin-bottom: 20px; }
.hm-hero > * { min-width: 0; }
.hm-hero__who { flex: 1 1 440px; display: flex; align-items: center; gap: 16px; }
.hm-hero__officer { flex: none; }
.hm-hero__copy { flex: 1 1 220px; min-width: 200px; }
.hm-title { font-size: clamp(1.9rem, 7vw, var(--t-49)); margin: 0 0 8px; overflow-wrap: normal; word-break: normal; }
.hm-say {
  position: relative; margin: 0; padding: 10px 14px; min-width: 200px; max-width: 46ch;
  background: var(--sheet); border: 2px solid var(--ink); border-radius: 12px;
  font-size: var(--t-16); line-height: 1.4; overflow-wrap: normal; word-break: normal;
}
.hm-say::before {
  content: ""; position: absolute; left: -9px; top: 18px; width: 14px; height: 14px;
  background: var(--sheet); border-left: 2px solid var(--ink); border-bottom: 2px solid var(--ink);
  transform: rotate(45deg);
}
.hm-join { margin: 0; flex: 0 1 340px; width: 340px; max-width: 100%; }
@media (max-width: 899px) {
  .hm-hero__who { flex-basis: 100%; }
  .hm-join { flex-basis: 100%; width: 100%; }
}

.hm-stage { position: relative; margin-bottom: 36px; }
.hm-loading { padding: 40px 0; }

/* ---------- Town ---------- */

.town-wrap { position: relative; max-width: 100%; }
.town {
  max-width: 100%; overflow-x: auto; overflow-y: hidden;
  background: linear-gradient(#CFE6F0 0%, #E6F0E8 100%);
  border: 2px solid var(--ink);
  overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
}
.town__svg { display: block; width: 100%; height: auto; max-width: none; }
@media (max-width: 639px) {
  .town__svg { height: 460px; width: auto; min-width: 100%; }
}
.town__fx { pointer-events: none; }

.iso-sign__t { font-family: var(--f-display); font-weight: 800; font-stretch: 75%; user-select: none; pointer-events: none; }

.iso-lot { cursor: pointer; outline: none; }
.iso-lift { transition: transform 0.15s ease-out; }
.iso-lot:hover .iso-lift, .iso-lot:focus-visible .iso-lift { transform: translateY(-3px); }
.iso-lot:hover .iso-ring { stroke: var(--ink); stroke-width: 2; stroke-dasharray: 5 4; fill-opacity: 0.08; }
.iso-lot:focus-visible .iso-ring { stroke: var(--pub); stroke-width: 4; fill-opacity: 0.12; }

/* life (only while the town is on-screen: .is-live is toggled by idleLoop) */
@keyframes iso-sway { 0%, 100% { transform: rotate(-2.2deg); } 50% { transform: rotate(2.2deg); } }
@keyframes iso-smoke { 0% { transform: translateY(0); opacity: 0.9; } 100% { transform: translateY(-9px); opacity: 0; } }
@keyframes iso-hint { 0%, 100% { transform: translateX(-3px); } 50% { transform: translateX(3px); } }
.iso-sway { transform-box: fill-box; transform-origin: 50% 100%; }
.is-live .iso-sway { animation: iso-sway 3.6s ease-in-out infinite; }
.is-live .iso-smoke { animation: iso-smoke 2.6s ease-out infinite; animation-delay: calc(var(--i, 0) * 0.8s); }

.town__hint {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px;
  background: var(--ink); color: var(--paper); border-radius: 999px;
  font-size: var(--t-14); font-weight: 700; pointer-events: none; white-space: nowrap;
}
.town__hint-arrows { display: inline-block; animation: iso-hint 1.2s ease-in-out infinite; }
@media (min-width: 640px) { .town__hint { display: none; } }

/* ---------- Case card ---------- */

.hm-card {
  position: absolute; left: 12px; bottom: 12px; z-index: 5;
  width: min(460px, calc(100% - 24px));
  display: grid; gap: 8px; padding: 16px 18px 18px;
  background: var(--sheet); border: 2px solid var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
}
.hm-card[hidden] { display: none; }
.hm-card:focus { outline: none; }
.hm-card:focus-visible { outline: 2px solid var(--pub); outline-offset: 2px; }
.hm-card__close {
  position: absolute; top: 4px; right: 4px; width: 44px; height: 44px;
  display: grid; place-items: center; cursor: pointer;
  background: transparent; border: 0; color: var(--ink); font-size: 1.75rem; line-height: 1;
}
.hm-card__close:hover { background: var(--paper); }
.hm-card__status {
  justify-self: start; padding: 2px 8px; border: 1.5px solid var(--ink); background: var(--paper);
  font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em;
}
.hm-card__title { margin: 0; padding-right: 40px; font-size: var(--t-20); line-height: 1.2; }
.hm-card__meta { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; font-size: var(--t-14); }
.hm-card__k { display: block; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); }
.hm-card__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.hm-card__actions .btn { flex: 1 1 140px; }

@media (max-width: 639px) {
  .hm { padding-top: 8px; }
  .hm-hud { padding: 6px 10px; gap: 6px 12px; margin-bottom: 12px; }
  .hm-rank__emblem { width: 28px; height: 30px; }
  .hm-rank__kicker { display: none; }
  .hm-rank__title { font-size: var(--t-14); }
  .hm-xp { flex-basis: 120px; }
  .hm-badges { padding: 0 10px; }
  .hm-hero__who { gap: 8px; }
  .hm-card {
    position: fixed; left: 0; right: 0; bottom: 0; width: auto; z-index: 40;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    border-width: 2px 0 0; border-radius: 16px 16px 0 0; box-shadow: none;
  }
}

/* ---------- Accessible case list ---------- */

.hm-files { margin-bottom: 8px; }
.hm-list { list-style: none; margin: 0; padding: 0; border: 2px solid var(--ink); background: var(--sheet); }
.hm-list__item {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 12px 14px; border-bottom: 1px solid var(--rule);
}
.hm-list__item:last-child { border-bottom: 0; }
.hm-list__main { flex: 1 1 260px; min-width: 0; }
.hm-list__title { font-family: var(--f-display); font-weight: 800; font-size: var(--t-16); color: var(--ink); text-decoration-thickness: 2px; }
.hm-list__meta { margin: 2px 0 0; font-size: var(--t-14); color: var(--ink-2); }
.hm-list__status { color: var(--ok-ink); }
.hm-list__actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Lot view (case sheet) ---------- */

.lotview { width: 100%; max-width: 420px; margin: 0 auto; }
.lotview__svg { display: block; width: 100%; height: auto; }
.lotview__nbr { filter: saturate(0.5) brightness(1.05); }
.lotview__pin { pointer-events: none; }
@keyframes lot-pin { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.is-live .lotview__pin .iso-pin__bob { animation: lot-pin 1s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .is-live .lotview__pin .iso-pin__bob { animation: none; } }

/* ---------- Reduced motion: no loops, no hover lift ---------- */

@media (prefers-reduced-motion: reduce) {
  .is-live .iso-sway, .is-live .iso-smoke, .town__hint-arrows { animation: none; }
  .iso-lift { transition: none; }
}
