/* ─── Heard Planet — town view (alternate home) ──────────────────────────── */

/* View switch (segmented pill, top of home) */
.home-view-switch {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}
.hvs-group {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.hvs-btn {
  border: none;
  background: transparent;
  color: var(--text-2);
  font: 600 12.5px var(--font-body);
  padding: 5px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.hvs-btn:hover { color: var(--text); }
.hvs-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
}

/* Town mode hides the dashboard columns */
#page-home.town-mode .home-2col { display: none; }

/* Frame */
.town-scroll {
  overflow-x: auto;
  border-radius: var(--radius);
  padding-top: 4px; /* matches .cont-scroll convention */
}
.town-frame {
  position: relative;
  min-width: 860px;
  aspect-ratio: 1280 / 480;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #0a0d1d;
  transition: background 1.2s;
}
.town-svg { display: block; width: 100%; height: 100%; }
.town-svg text { pointer-events: none; user-select: none; }

.town-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}

/* ── Phase palettes ── */
.town-frame {
  --win-on: #ffd98a;
  --win-off: #1b1d2c;
}
.town-frame.phase-night {
  --sky-a: #0a0d1d; --sky-b: #221a3e;
  --hill: #171330;
  --walk: #232030; --road: #17151f;
  --bush: #1c2a25;
  --win: var(--win-on);
  --cloud: rgba(255,255,255,0.05);
  --stars-o: 1; --sun-o: 0; --moon-o: 1;
  --lamp-o: 1;
  --sun-x: 0px; --sun-y: 0px;
}
.town-frame.phase-dusk {
  --sky-a: #2c2050; --sky-b: #c25c72;
  --hill: #241b41;
  --walk: #2b2536; --road: #1d1926;
  --bush: #2c3a30;
  --win: var(--win-on);
  --cloud: rgba(255,190,160,0.20);
  --stars-o: 0.35; --sun-o: 0.9; --moon-o: 0;
  --lamp-o: 0.9;
  --sun-x: 1060px; --sun-y: 335px;
}
.town-frame.phase-day {
  --sky-a: #4e8fc7; --sky-b: #a8d4e8;
  --hill: #33584a;
  --walk: #6f6b82; --road: #4c4857;
  --bush: #3f7a52;
  --win: #2c3547;
  --cloud: rgba(255,255,255,0.75);
  --stars-o: 0; --sun-o: 1; --moon-o: 0;
  --lamp-o: 0;
  --sun-x: 640px; --sun-y: 84px;
}
.town-frame.phase-dawn {
  --sky-a: #33406e; --sky-b: #e8a27a;
  --hill: #2b284c;
  --walk: #383349; --road: #262232;
  --bush: #32473b;
  --win: #e8c17d;
  --cloud: rgba(255,205,170,0.30);
  --stars-o: 0.15; --sun-o: 0.85; --moon-o: 0;
  --lamp-o: 0.5;
  --sun-x: 210px; --sun-y: 330px;
}

/* ── Sky ── */
.town-svg .sky-a { stop-color: var(--sky-a); transition: stop-color 1.2s; }
.town-svg .sky-b { stop-color: var(--sky-b); transition: stop-color 1.2s; }

.town-svg .st {
  fill: #fff;
  opacity: var(--stars-o);
  animation: town-twinkle 3.4s ease-in-out infinite;
  transition: opacity 1.2s;
}
@keyframes town-twinkle {
  0%, 100% { fill-opacity: 1; }
  50%      { fill-opacity: 0.25; }
}

.town-svg .sun {
  fill: #f6d67c;
  opacity: var(--sun-o);
  transform: translate(var(--sun-x), var(--sun-y));
  transition: opacity 1.2s, transform 1.2s;
  filter: drop-shadow(0 0 26px rgba(246, 214, 124, 0.75));
}
.town-svg .moon {
  opacity: var(--moon-o);
  transform: translate(1030px, 92px);
  transition: opacity 1.2s;
  filter: drop-shadow(0 0 18px rgba(233, 231, 244, 0.45));
}

.town-svg .cloud { fill: var(--cloud); transition: fill 1.2s; }
.town-svg .cloud.c1 { animation: town-drift 120s linear infinite alternate; }
.town-svg .cloud.c2 { animation: town-drift 160s linear infinite alternate-reverse; }
.town-svg .cloud.c3 { animation: town-drift 95s  linear infinite alternate; }
@keyframes town-drift {
  from { transform: translateX(-70px); }
  to   { transform: translateX(140px); }
}

/* ── Ground ── */
.town-svg .hill-far { fill: var(--hill); transition: fill 1.2s; }
.town-svg .walk { fill: var(--walk); transition: fill 1.2s; }
.town-svg .curb { fill: rgba(255,255,255,0.08); }
.town-svg .road { fill: var(--road); transition: fill 1.2s; }
.town-svg .lane rect { fill: rgba(255,255,255,0.09); }
.town-svg .bushes circle { fill: var(--bush); transition: fill 1.2s; }

/* ── Building shells ── */
.town-svg .bldg-dk { fill: #17141f; }
.town-svg .bldg-md { fill: #201c30; }
.town-svg .bldg-lt { fill: #292440; }
.town-svg .bldg-md, .town-svg .bldg-lt { stroke: rgba(255,255,255,0.06); }
.town-svg .door { fill: #100e18; stroke: rgba(255,255,255,0.09); }
.town-svg .lattice, .town-svg .scope { stroke: #494360; stroke-width: 3.5; fill: none; stroke-linecap: round; }

.town-svg .w {
  fill: var(--win);
  transition: fill 1.2s;
}
.phase-night .town-svg .w, .phase-dusk .town-svg .w {
  filter: drop-shadow(0 0 5px rgba(255, 217, 138, 0.55));
}
.town-svg .w.w-dark { fill: var(--win-off) !important; filter: none !important; }

/* Interactive buildings */
.town-b { cursor: pointer; outline: none; }
.town-b:hover, .town-b:focus-visible { filter: brightness(1.28); }

/* ── Signs ── */
.town-svg .sign {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 1.5px;
}
.town-svg .sign-block { fill: #14111e; stroke: rgba(255,255,255,0.12); }
.town-svg .sign-marquee { font-size: 21px; fill: #ffd98a; }
.town-svg .marquee-canopy { fill: #38304e; stroke: rgba(255,217,138,0.35); }
.phase-night .sign-marquee, .phase-dusk .sign-marquee { filter: drop-shadow(0 0 8px rgba(255,217,138,0.6)); }
.town-svg .poster { fill: #362d52; stroke: rgba(255,255,255,0.14); }

.town-svg .sign-comics { font-size: 17px; fill: #ff8e9e; }
.town-svg .aw-a { fill: #8a3040; }
.town-svg .aw-b { fill: #d8d3e8; }
.town-svg .shopwin { fill: #2c3547; stroke: rgba(255,255,255,0.14); }
.phase-night .town-svg .shopwin, .phase-dusk .town-svg .shopwin { fill: var(--win-on); opacity: 0.85; }

.town-svg .sign-lib { font-size: 15px; fill: #cfc7ef; }
.town-svg .sign-cafe { font-size: 15px; fill: #ffd0a8; }
.town-svg .cafe-awning { fill: #74463a; }

.town-svg .sign-arcade { font-size: 19px; fill: var(--accent); }
.phase-night .neon-wrap, .phase-dusk .neon-wrap, .phase-dawn .neon-wrap {
  filter: drop-shadow(0 0 9px var(--accent));
}
.town-svg .antenna { stroke: #494360; stroke-width: 3; stroke-linecap: round; }
.town-svg .antenna-dot { fill: var(--accent); }
.town-svg .antenna-ring {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  transform-box: fill-box;
  transform-origin: center;
  animation: town-ping 2.6s ease-out infinite;
}
@keyframes town-ping {
  0%   { transform: scale(0.4); opacity: 0.9; }
  100% { transform: scale(2.1); opacity: 0; }
}

/* Billboard + quest board */
.town-svg .board { fill: #14111e; stroke: rgba(255,255,255,0.16); }
.town-svg .board-head {
  font-family: var(--font-display);
  font-size: 15px; font-weight: 800; letter-spacing: 2px;
  fill: var(--accent);
}
.town-svg .board-row { font-family: var(--font-body); font-size: 13px; fill: #e8e6f2; }
.town-svg .board-mini {
  font-family: var(--font-display);
  font-size: 11px; font-weight: 700; letter-spacing: 1.5px;
  fill: #b9b2d6;
}
.town-svg .paper { fill: #ddd8ea; }
.town-svg .paper.p2 { fill: #c9beeb; }

/* Broadcast tower */
.town-svg .beacon {
  fill: #ff5b6a;
  animation: town-beacon 2.2s ease-in-out infinite;
}
.town-svg .beacon-ring {
  fill: none; stroke: #ff5b6a; stroke-width: 1.5;
  transform-box: fill-box; transform-origin: center;
  animation: town-ping 2.2s ease-out infinite;
}
@keyframes town-beacon {
  0%, 100% { fill-opacity: 1; }
  50%      { fill-opacity: 0.35; }
}
.town-svg .wave {
  fill: none; stroke: #ff5b6a; stroke-width: 2; stroke-linecap: round;
  animation: town-beacon 2.2s ease-in-out infinite;
}
.town-svg .wave.w2 { animation-delay: 1.1s; }

/* Observatory + hatchery */
.town-svg .dome {
  fill: rgba(149, 100, 255, 0.13);
  stroke: rgba(255, 255, 255, 0.20);
  stroke-width: 1.5;
}
.town-svg .dome-ribs { fill: none; stroke: rgba(255,255,255,0.10); stroke-width: 1.5; }
.town-svg .hatch-egg {
  fill: #f2ead8;
  filter: drop-shadow(0 0 10px rgba(242, 234, 216, 0.35));
  animation: town-egg-wobble 5s ease-in-out infinite;
  transform-box: fill-box; transform-origin: 50% 90%;
}
.town-svg .egg-spot { fill: #cdb98f; }
@keyframes town-egg-wobble {
  0%, 86%, 100% { transform: rotate(0deg); }
  90%           { transform: rotate(-4deg); }
  94%           { transform: rotate(4deg); }
}

/* Streetlamps */
.town-svg .lamp { fill: #ffe6ac; opacity: calc(0.25 + var(--lamp-o) * 0.75); transition: opacity 1.2s; }
.town-svg .lamp-glow {
  fill: rgba(255, 230, 172, 0.16);
  opacity: var(--lamp-o);
  transition: opacity 1.2s;
}

/* ── Roaming creatures ── */
.town-critters {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 26%;
  pointer-events: none;
}
.critter {
  position: absolute;
  pointer-events: auto;
  background: none; border: none; padding: 0;
  cursor: pointer;
  animation: town-roam var(--dur, 18s) ease-in-out var(--delay, 0s) infinite;
}
.critter img {
  display: block;
  width: 46px; height: 46px;
  image-rendering: pixelated;
  animation: town-bob 0.7s ease-in-out infinite alternate;
}
.critter:hover img, .critter:focus-visible img { filter: brightness(1.2); }
.critter-shiny img {
  filter: drop-shadow(0 0 7px rgba(255, 215, 90, 0.75));
}
.critter-shiny::after {
  content: '✨';
  position: absolute;
  top: -8px; right: -6px;
  font-size: 12px;
  animation: town-twinkle 1.6s ease-in-out infinite;
}
@keyframes town-roam {
  0%   { transform: translateX(0) scaleX(1); }
  46%  { transform: translateX(var(--roam, 90px)) scaleX(1); }
  50%  { transform: translateX(var(--roam, 90px)) scaleX(-1); }
  96%  { transform: translateX(0) scaleX(-1); }
  100% { transform: translateX(0) scaleX(1); }
}
@keyframes town-bob {
  from { transform: translateY(0); }
  to   { transform: translateY(-3px); }
}

/* ── Tooltip ── */
.town-tip {
  position: absolute;
  transform: translate(-50%, -100%);
  background: #1a1625;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 6px 12px;
  text-align: center;
  pointer-events: none;
  z-index: 40;
  box-shadow: var(--shadow-lift);
  white-space: nowrap;
}
.town-tip b {
  display: block;
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--text);
}
.town-tip span { font-size: 11px; color: var(--text-2); }

/* Mobile: the town becomes a scrollable diorama */
@media (max-width: 700px) {
  .home-view-switch { justify-content: center; }
  .critter img { width: 38px; height: 38px; }
}
