/* The city screen.
 *
 * One of the stylesheets split out of the old style.css. index.html links them
 * in the order they had in that file, so the cascade is unchanged - keep
 * that order when adding a rule, or a later sheet may win where it used to lose. */

/* ---------- city ---------- */

#city-ui {
  position: absolute;
  z-index: 50;
  display: flex;
  /* Centred by the panel's auto margins, not align-items: a centred panel
     taller than the window spilled above its top, where no scroll reaches -
     with a full roster the Audio and Guide buttons were off-screen for good.
     Auto margins centre it when it fits and give way when it does not. */
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  pointer-events: auto;
  background: var(--ink);
  /* A whole screen: out from the overlay to the screen's edges, and its
     content back in by the same amounts (base.css, edge to edge). */
  inset: calc(-1 * var(--edge-top)) calc(-1 * var(--edge-right)) calc(-1 * var(--edge-bottom)) calc(-1 * var(--edge-left));
  padding: calc(24px + var(--edge-top)) calc(24px + var(--edge-right)) calc(24px + var(--edge-bottom)) calc(24px + var(--edge-left));
}
#city-ui::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle, transparent 20%, rgba(0,0,0,0.72) 100%); }
.city-panel {
  position: relative;
  margin: auto;
  width: min(1080px, 96vw);
  padding: 18px clamp(20px, 4vw, 42px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  background: rgba(11,13,16,0.9);
  border: 2px solid var(--gold-dark);
  box-shadow: 0 0 0 4px #08090a, 0 0 70px rgba(217,106,43,0.16);
}
.city-emblem {
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  color: var(--gold);
  border: 2px solid var(--gold-dark);
  transform: rotate(45deg);
  font-size: 28px;
}
/* The frame is a diamond; what sits in it stays upright. */
.city-emblem .px-icon { transform: rotate(-45deg); }
/* A section's name. It was tiny capitals spaced wide, stacked over headings
 * that already said the same; the ones that only repeated a heading are gone,
 * and what is left reads as a heading in sentence case. */
.eyebrow { margin: 0; color: #cdb07a; font-size: 13px; letter-spacing: 0; }
.city-panel h1 { margin: 0; color: #f3e5c3; font-size: clamp(24px, 5vh, 42px); letter-spacing: 0.12em; text-shadow: 3px 3px 0 #000; }
.hint { margin: 0 0 5px; color: var(--muted); font-size: 13px; font-weight: 400; }
.job-picker, .city-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.job-picker { width: 100%; margin: 8px 0; }
.job-picker button { min-width: 130px; flex: 1 1 130px; padding: 12px 10px; flex-direction: column; gap: 6px; }
.job-picker button[aria-pressed="true"] { opacity: 1; color: #fff3d3; outline-color: var(--gold); background-color: #3c3120; }
.job-icon { color: var(--gold); font-size: 26px; }
.job-portrait-frame {
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111518;
  border: 2px solid #2b251d;
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.7);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 2px;
  pointer-events: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.job-picker button:hover .job-portrait-frame,
.job-picker button:focus-visible .job-portrait-frame {
  border-color: var(--gold-dark);
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.5), 0 0 8px rgba(241, 198, 111, 0.25);
}
.job-picker button[aria-pressed="true"] .job-portrait-frame {
  border-color: var(--gold);
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.4), 0 0 10px rgba(241, 198, 111, 0.4);
}
.job-portrait-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: auto;
  pointer-events: none;
}
.job-picker small { color: var(--muted); font-size: 10px; font-weight: 400; }
.city-actions { margin-top: 8px; }
.city-actions .primary { padding-inline: 28px; }

/* ---------- the town: one screen ----------
 * Controls sit at the sides so the painting can use the whole viewport.
 * Keep the full 16:9 painting; where the window is not 16:9, the
 * backdrop, softened and dimmed, fills the room around the scene, so there are
 * no bars. Narrow screens keep the stacked list from city-scene.css. */
@media (min-width: 701px), (min-width: 561px) and (orientation: landscape) {
  #city-ui { padding: 0; overflow: hidden; }
  /* The town itself keeps to the safe area; only the surround behind it
     reaches the screen's edges (base.css, edge to edge). */
  #city-ui .town {
    --city-gutter: 64px;
    position: absolute;
    inset: var(--edge-top) var(--edge-right) var(--edge-bottom) var(--edge-left);
    width: auto;
    margin: 0;
    padding: 0;
    display: block;
    gap: 0;
    overflow: hidden;
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  /* The blurred town behind the panel, to every edge of the glass. The blur
     is drawn 40px past the screen so its soft rim never shows - inside a box
     that clips it to the screen, or the overhang would make the town scroll:
     a focus or scrollIntoView then slid the whole town up 40px on a 375px
     iPhone held sideways, the top tool off the screen. */
  .town-surround {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
  }
  .town-surround::before {
    content: '';
    position: absolute;
    inset: -40px;
    background: url('../assets/city/city-scene-backdrop.webp') center / cover, var(--coal);
    filter: blur(22px) brightness(0.38) saturate(0.8);
  }
  .town-stage { z-index: 1; }
  /* No z-index on .town-top or .city-eyebrow-row so .city-side-controls
     (z-index: 6) and open #city-tools-menu can layer above top town banners
     (z-index: 4) without being trapped in a lower stacking context. */
  .town-top {
    position: absolute; inset: 0;
    pointer-events: none; padding: 0;
  }
  .town-title { position: absolute; top: 12px; left: 8px; width: 56px; text-align: left; z-index: 3; }
  #city-ui .town h1 { font-size: 12px; line-height: 1.45; letter-spacing: .04em; }
  #city-ui .town .city-emblem { display: none; }
  .town-stage {
    position: absolute; inset: 0 var(--city-gutter);
    display: grid;
    place-items: center;
    padding: 0;
    container-type: size;
  }
  #city-ui .city-eyebrow-row { position: absolute; inset: 0; display: block; pointer-events: none; }
  #city-ui #btn-party-roster { position: absolute; bottom: 12px; left: 8px; width: 48px; padding: 6px 4px; flex-direction: column; gap: 5px; pointer-events: auto; z-index: 3; }
  #city-ui .city-party-separator { display: none; }
  #city-ui .city-party-label { display: flex; flex-direction: column; gap: 2px; }
  #city-ui #city-party-count { color: inherit; }
  /* The town's right-hand gutter holds Chat and the Tools menu toggle (44px each).
     All other town utilities open beside it inside #city-tools-menu so small
     screens stay uncluttered while keeping every tool two taps away. */
  #city-ui .city-side-controls {
    position: absolute; top: 12px; right: 12px;
    display: flex; flex-direction: column; justify-content: flex-start; gap: 8px;
    pointer-events: none; z-index: 6;
  }
  #city-ui .city-side-controls > .city-tour-btn {
    pointer-events: auto; /* only the two gutter buttons take taps */
    position: relative; display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; min-width: 44px !important; min-height: 44px !important; padding: 0 !important;
  }
  #city-ui .city-side-controls > .city-tour-btn .city-control-label {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  #city-ui .city-tools-menu:not([hidden]) {
    position: absolute; right: 52px; top: 0;
    display: grid; grid-template-columns: repeat(2, minmax(136px, 1fr)); gap: 8px; padding: 10px;
    width: max-content; max-width: calc(var(--safe-vw) - 88px);
    pointer-events: auto; z-index: 6;
    background: var(--panel); border: 2px solid var(--gold); border-radius: 2px; box-shadow: var(--pixel-shadow);
  }
  #city-ui .city-tools-menu .city-tour-btn {
    pointer-events: auto; position: relative;
    width: 100%; height: auto; min-width: 44px !important; min-height: 44px !important; padding: 8px 12px !important;
    display: flex; align-items: center; justify-content: flex-start; gap: 8px;
    white-space: nowrap;
  }
  #city-ui .city-tools-menu .city-tour-btn .city-control-label {
    position: static; width: auto; height: auto; padding: 0; margin: 0; overflow: visible; clip-path: none;
  }
}
.city-side-controls { display: contents; }
#city-ui .city-tools-menu[hidden] { display: none !important; }
/* All city tools share the same visual weight, including Party. */
#city-ui #btn-party-roster, #city-ui .city-side-controls .city-tour-btn {
  background: var(--panel) !important; color: var(--gold) !important;
  border: 1px solid var(--gold-dark) !important; border-radius: 2px !important;
  box-shadow: none !important; outline: none; opacity: 1;
}
#city-ui #btn-party-roster:hover, #city-ui .city-side-controls .city-tour-btn:hover {
  border-color: var(--gold) !important; color: #fff3d3 !important;
}
#city-ui #btn-party-roster:focus-visible, #city-ui .city-side-controls .city-tour-btn:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px;
}
@media (max-width: 700px) and (orientation: portrait), (max-width: 560px) {
  #city-ui .city-side-controls > .city-tour-btn {
    min-width: 44px !important; min-height: 44px !important; padding: 8px 12px !important;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    white-space: nowrap;
  }
  #city-ui .city-tools-menu:not([hidden]) {
    flex-basis: 100%; width: 100%;
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 10px;
    background: var(--panel); border: 2px solid var(--gold); border-radius: 2px; box-shadow: var(--pixel-shadow);
    z-index: 6;
  }
  #city-ui .city-tools-menu .city-tour-btn {
    width: 100%; min-width: 44px !important; min-height: 44px !important; padding: 8px 10px !important;
    display: flex; align-items: center; justify-content: flex-start; gap: 8px;
    text-align: left; white-space: normal; line-height: 1.25;
  }
}
