/* Portfolio Town — public visitor page. Frosted dark glass overlays over the
   real-time sky, like the Home overlays in the private app. */

:root {
  --bg: #0b1020;
  --card: rgba(21, 27, 35, 0.78);
  --card-solid: #151b23;
  --line: rgba(255, 255, 255, 0.12);
  --tx: #e6edf3;
  --mu: #a8b3bf;
  --ac: #2fbf8f;
  --ac-bg: rgba(47, 191, 143, 0.28);
  --ac-tx: #9ff0cd;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--tx);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

.mono {
  font-family: var(--mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.visitor {
  position: fixed;
  inset: 0;
  background: var(--bg);
}

/* ---- Stage ------------------------------------------------------------- */
.town-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.town-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  outline: none;
}

.town-stage.town-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border: 3px solid var(--line);
  border-top-color: var(--ac);
  border-radius: 50%;
  animation: town-spin 900ms linear infinite;
}

@keyframes town-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- Frosted glass chips --------------------------------------------- */
.hud,
.status,
.fallback,
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--tx);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.hud {
  position: absolute;
  z-index: 5;
  top: calc(12px + var(--safe-top));
  left: calc(12px + var(--safe-left));
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 24px - var(--safe-left) - var(--safe-right));
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.hud-place {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46vw;
}

.hud-sep {
  color: var(--mu);
}

.hud-weather {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.hud-icon {
  font-size: 14px;
  line-height: 1;
}

.wordmark {
  position: absolute;
  z-index: 5;
  left: calc(14px + var(--safe-left));
  bottom: calc(12px + var(--safe-bottom));
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(230, 237, 243, 0.62);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.status {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: calc(18px + var(--safe-bottom));
  transform: translateX(-50%);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--mu);
}

.status[hidden] {
  display: none;
}

.fallback {
  position: absolute;
  z-index: 6;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, calc(100vw - 32px));
  padding: 18px 20px;
  border-radius: 16px;
  text-align: center;
  display: grid;
  gap: 6px;
}

.fallback[hidden] {
  display: none;
}

.fallback span {
  color: var(--mu);
  font-size: 13px;
}

/* ---- Control panel (Alt+T / ?control=1) ------------------------------- */
.panel {
  position: absolute;
  z-index: 7;
  top: calc(12px + var(--safe-top));
  right: calc(12px + var(--safe-right));
  width: min(320px, calc(100vw - 24px - var(--safe-left) - var(--safe-right)));
  max-height: calc(100vh - 24px - var(--safe-top) - var(--safe-bottom));
  overflow: auto;
  border-radius: 16px;
  padding: 12px 14px 14px;
  display: grid;
  gap: 10px;
}

.panel[hidden] {
  display: none;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.panel-close {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--tx);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.panel-body {
  display: grid;
  gap: 10px;
}

.ctl {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "label lock"
    "input input";
  gap: 4px 10px;
  align-items: center;
  font-size: 12px;
}

.ctl > label:first-child {
  grid-area: label;
  display: flex;
  justify-content: space-between;
  color: var(--mu);
}

.ctl > label:first-child output {
  color: var(--ac-tx);
}

.ctl > select,
.ctl > input[type="range"] {
  grid-area: input;
  width: 100%;
}

.ctl select {
  appearance: none;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--tx);
  font: inherit;
}

.ctl input[type="range"] {
  accent-color: var(--ac);
  height: 24px;
  margin: 0;
}

.lock {
  grid-area: lock;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--mu);
  font-size: 11px;
}

.lock input {
  accent-color: var(--ac);
  margin: 0;
}

.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.panel-foot button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--ac-bg);
  color: var(--ac-tx);
  padding: 6px 12px;
  border-radius: 999px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.hint {
  color: var(--mu);
  font-size: 11px;
  text-align: right;
}

@media (max-width: 640px) {
  .hud {
    font-size: 12px;
    padding: 7px 10px;
  }

  .hud-place {
    max-width: 38vw;
  }

  .panel {
    top: auto;
    bottom: calc(12px + var(--safe-bottom));
    right: calc(12px + var(--safe-right));
    left: calc(12px + var(--safe-left));
    width: auto;
    max-height: 70vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .town-stage.town-loading::after {
    animation-duration: 1800ms;
  }
}

/* City control */
.ctl-city .city-row {
  display: flex;
  gap: 6px;
}
.ctl-city input[type="search"] {
  flex: 1;
  min-width: 0;
  min-height: 34px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #e6edf3;
  font: inherit;
  font-size: 14px;
}
.ctl-city button {
  min-height: 34px;
  padding: 4px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(47, 191, 143, 0.22);
  color: #9ff0cd;
  font: inherit;
  font-size: 13px;
}
.city-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}
.city-results button {
  text-align: left;
  min-height: 32px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: #e6edf3;
  font: inherit;
  font-size: 13px;
}
.city-results button:hover {
  border-color: #2fbf8f;
}
.city-results .empty {
  font-size: 12px;
  color: #a8b3bf;
  padding: 4px 2px;
}
