/* Character select, and the expedition board.
 *
 * 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. */

/* --- Character select ----------------------------------------------------
   The roster sits in the same panel the city uses, so arriving at it does not
   feel like leaving the game. */
/* pointer-events is the one that matters. #ui-overlay is `pointer-events: none`
   so the canvas under it can still be reached, and every panel that wants
   clicks has to opt back in - #city-ui does, .control-group does. This rule
   did not, so the whole character-select window was inert: it drew correctly,
   it just never received a click. Nothing caught it, because it was verified
   by calling .click() on the button, which dispatches straight at the element
   and never asks what is on top. */
/* A whole screen, like the town: out from the overlay to the screen's edges,
   and its content back in by the same amounts (base.css, edge to edge). Kept
   to the overlay, the strip under the clock and the one over the home bar
   were the bare canvas, a black bar across the top of a phone held upright. */
#select-ui {
  position: absolute; z-index: 20;
  inset: calc(-1 * var(--edge-top)) calc(-1 * var(--edge-right)) calc(-1 * var(--edge-bottom)) calc(-1 * var(--edge-left));
  display: flex; align-items: flex-start; justify-content: center;
  padding: calc(clamp(16px, 4vh, 40px) + var(--edge-top)) calc(16px + var(--edge-right)) calc(clamp(16px, 4vh, 40px) + var(--edge-bottom)) calc(16px + var(--edge-left));
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-gutter: stable;
  pointer-events: auto;
}
#select-ui.hidden { display: none; }
.select-panel {
  max-width: 1120px;
  width: min(1120px, 100%);
  margin: auto 0;
  padding: clamp(20px, 2.4vw, 32px);
  gap: 0;
  border: 1px solid #615037;
  background: #0d1012;
  box-shadow: 0 0 0 4px #08090a, 0 20px 70px #0008;
}

.select-header {
  text-align: center;
  width: 100%;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid #302d26;
}
.select-header .eyebrow { margin-bottom: 12px; }
.select-header h1 { font-size: clamp(23px, 3.4vw, 38px); letter-spacing: 0.06em; }
.select-header .hint { margin: 12px auto 0; max-width: 540px; line-height: 1.6; }

.select-panel-body {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(380px, 1.2fr);
  gap: 32px;
  width: 100%;
  align-items: start;
}

.select-col-roster,
.select-col-create {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.select-col-title {
  margin-bottom: 8px;
  text-align: center;
}

#create-hero {
  text-align: center;
}
#create-hero-heading { margin-bottom: 16px; font-size: 10px; }
#create-hero .job-picker { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 0; }
#roster-note { margin-top: 20px; font-size: 12px; line-height: 1.5; }

/* The empty roster is an introduction, not an empty management column. */
.is-first-hero .select-panel-body { grid-template-columns: 1fr; }
.is-first-hero #create-hero .job-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
#create-hero .create-job {
  --calling-accent: #bc9567;
  min-width: 0;
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  text-align: left;
  text-transform: none;
  border: 1px solid #3e3a32;
  outline: none;
  background: #171b1e;
  box-shadow: inset 0 2px var(--calling-accent);
}
#create-hero .create-job[data-job="Mage"] { --calling-accent: #849fbe; }
#create-hero .create-job[data-job="Rogue"] { --calling-accent: #9ba879; }
#create-hero .create-job:hover:not(:disabled) { background: #202529; border-color: var(--calling-accent); }
#create-hero .create-job:focus-visible { outline: 2px solid var(--calling-accent); outline-offset: 4px; }
#create-hero .create-job:active:not(:disabled) { transform: translateY(1px); }
#create-hero .job-portrait-frame {
  width: 80px; height: 96px; flex: none; margin: 0;
  background: none; border: 0; box-shadow: none; transition: none;
  align-self: start;
}
#create-hero .calling-copy { display: flex; flex-direction: column; min-width: 0; gap: 8px; }
#create-hero .calling-role { color: var(--calling-accent); font-size: 9px; letter-spacing: 0.12em; }
#create-hero .calling-copy strong { font-size: 24px; line-height: 1.1; color: #f3e5c3; }
#create-hero .calling-description { color: #c2baaa; font-size: 12px; font-weight: 400; line-height: 1.6; letter-spacing: 0; }
#create-hero .calling-stats { color: #a8a292; font-size: 10px; line-height: 1.7; letter-spacing: 0; }
#create-hero .calling-choose {
  display: flex; justify-content: space-between; gap: 8px;
  padding-top: 10px; margin-top: 4px; border-top: 1px solid #353932;
  color: var(--calling-accent); font-size: 11px;
}
.is-first-hero #create-hero .create-job { grid-template-columns: 1fr; gap: 16px; padding: 22px 24px 20px; }
.is-first-hero #create-hero .job-portrait-frame { width: 144px; height: 144px; justify-self: center; }
.is-first-hero #create-hero .calling-description { min-height: 58px; }
#select-ui:not(.is-first-hero) #create-hero .create-job { grid-template-columns: 64px minmax(0, 1fr); gap: 12px; padding: 12px; }
#select-ui:not(.is-first-hero) #create-hero .job-portrait-frame { width: 64px; height: 80px; }
#select-ui:not(.is-first-hero) #create-hero .calling-copy { gap: 5px; }
#select-ui:not(.is-first-hero) #create-hero .calling-copy strong { font-size: 20px; }
#select-ui:not(.is-first-hero) #create-hero .calling-description { font-size: 11px; line-height: 1.45; }
#select-ui:not(.is-first-hero) #create-hero .calling-choose { font-size: 10px; padding-top: 6px; margin-top: 0; }

@media (max-width: 819px) {
  .select-panel {
    max-width: 560px;
    width: min(560px, 100%);
  }
  .select-panel-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  .select-col-roster, .select-col-create { width: 100%; }
  .is-first-hero .select-panel { max-width: 1120px; width: min(1120px, 100%); }
  #create-hero {
    border: none;
    border-top: 1px solid #3b3328;
    background: none;
    padding: 20px 0 0;
  }
  .is-first-hero #create-hero { border: 0; padding: 0; }
  .is-first-hero #create-hero .create-job { padding: 20px 16px 16px; }
  .is-first-hero #create-hero .calling-description { min-height: 96px; }
}
@media (max-width: 700px) {
  .select-header { padding-bottom: 20px; margin-bottom: 20px; }
  .select-header .hint { font-size: 12px; }
  .is-first-hero #create-hero .job-picker { grid-template-columns: 1fr; gap: 12px; }
  #create-hero .create-job, .is-first-hero #create-hero .create-job { grid-template-columns: 72px minmax(0, 1fr); gap: 6px 14px; padding: 16px; }
  #create-hero .calling-copy { display: contents; }
  #create-hero .job-portrait-frame, .is-first-hero #create-hero .job-portrait-frame { width: 72px; height: 104px; grid-column: 1; grid-row: 1 / span 3; }
  #create-hero .calling-role, #create-hero .calling-copy strong, #create-hero .calling-description { grid-column: 2; }
  #create-hero .calling-stats, #create-hero .calling-choose { grid-column: 1 / -1; }
  #create-hero .calling-choose { padding-top: 8px; margin-top: 0; }
  .is-first-hero #create-hero .calling-description { min-height: 0; }
}
@media (max-width: 360px) {
  .select-panel { padding: 18px 12px; }
  #create-hero .create-job, .is-first-hero #create-hero .create-job { grid-template-columns: 64px minmax(0, 1fr); gap: 12px; padding: 16px 12px; }
  #create-hero .job-portrait-frame, .is-first-hero #create-hero .job-portrait-frame { width: 64px; height: 88px; }
}
/* A phone held sideways - the way the game is played - is under 500 tall, and
   the first-hero picker above wanted 680: the portraits showed and the names,
   descriptions and Choose buttons were under the fold, or at 667 wide the
   three callings stood one under another, the last two screens down. Here the
   three stand side by side, each portrait beside its name, and the header
   gives up the room it does not need. */
@media (orientation: landscape) and (max-height: 500px) {
  #select-ui { padding-top: calc(8px + var(--edge-top)); padding-bottom: calc(8px + var(--edge-bottom)); }
  .select-panel { padding: 12px 16px; }
  .select-header { margin-bottom: 10px; padding-bottom: 8px; }
  .select-header .eyebrow { margin-bottom: 2px; }
  .select-header h1 { font-size: 22px; }
  .select-header .hint { margin-top: 4px; }
  .select-header .select-code-link { margin-top: 6px; }
  #create-hero-heading { margin-bottom: 8px; }
  #roster-note { margin-top: 8px; }
  .is-first-hero #create-hero .job-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  #create-hero .create-job, .is-first-hero #create-hero .create-job {
    grid-template-columns: 64px minmax(0, 1fr); grid-template-rows: auto auto auto 1fr auto;
    gap: 4px 10px; padding: 10px 12px;
  }
  #create-hero .calling-copy { display: contents; }
  #create-hero .job-portrait-frame, .is-first-hero #create-hero .job-portrait-frame {
    width: 64px; height: 76px; grid-column: 1; grid-row: 1 / span 3; justify-self: start;
  }
  #create-hero .calling-role, #create-hero .calling-copy strong, #create-hero .calling-stats { grid-column: 2; }
  #create-hero .calling-role { grid-row: 1; align-self: end; }
  #create-hero .calling-copy strong { grid-row: 2; font-size: 20px; }
  #create-hero .calling-stats { grid-row: 3; align-self: start; text-align: left; line-height: 1.5; }
  #create-hero .calling-description { grid-row: 4; }
  #create-hero .calling-choose { grid-row: 5; align-self: end; }
  #create-hero .calling-description, #create-hero .calling-choose { grid-column: 1 / -1; }
  #create-hero .calling-description, .is-first-hero #create-hero .calling-description { min-height: 0; font-size: 11px; line-height: 1.45; margin-top: 4px; }
  #create-hero .calling-choose { padding-top: 6px; margin-top: 2px; }
  /* "Choose your calling" already says it; the eyebrow under it is a line of height. */
  .is-first-hero #create-hero-heading { display: none; }
}
/* Upright the picker is the page, as the town is (city-scene.css says why):
   no frame, the full width, the page around it the panel's own colour, and
   only the safe edges keep it clear of the clock and the home bar. */
@media (max-width: 700px) and (orientation: portrait), (max-width: 560px) {
  #select-ui { padding: var(--edge-top) var(--edge-right) var(--edge-bottom) var(--edge-left); background: #0d1012; }
  #select-ui .select-panel { width: 100%; max-width: none; min-height: 100%; margin: 0; border: 0; box-shadow: none; }
}

.roster { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.roster:empty::after {
  content: "No heroes yet. Raise one below.";
  color: var(--muted); font-size: 12px; letter-spacing: 0.5px;
}
.roster button {
  width: 100%; display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; text-align: left; font-size: 13px;
}
.roster .hero-mark {
  width: 30px; flex: 0 0 30px; height: 30px; display: grid; place-items: center;
  background: #171b1e; border: 2px solid var(--gold-dark); color: #f1c66f; font-size: 15px;
}
.roster .hero-name { flex: 1; min-width: 0; color: #f4e8c9; }
.roster .hero-meta { color: var(--muted); font-size: 11px; letter-spacing: 0.4px; white-space: nowrap; }
.roster li.active button { outline: 2px solid var(--gold); }

/* --- Expeditions ---------------------------------------------------------- */
/* The line under each hero in the roster: what they are doing for the purse
   while you are playing somebody else. */
.hero-expedition {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 12px 2px; font-size: 11px; letter-spacing: 0.3px;
}
.hero-expedition .expedition-status { flex: 1; min-width: 0; color: var(--muted); }
.hero-expedition.is-away .expedition-status,
.hero-expedition.is-helping .expedition-status { color: #9fd3a0; }
.hero-expedition.is-active .expedition-status { color: var(--gold); }
.roster .hero-expedition .expedition-btn {
  width: auto; flex: 0 0 auto; padding: 3px 9px; font-size: 10px;
}

#expedition-board { width: 100%; border-top: 1px solid var(--rule); margin-top: 8px; padding-top: 8px; }
#expedition-board .eyebrow { margin-bottom: 2px; }
#expedition-note { font-size: 11px; margin-bottom: 6px; }
#expedition-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 8px;
}
#expedition-list li, #squad-roster-list li {
  background: var(--row); padding: 6px 2px 4px;
  /* The city panel centres its contents; a list of rows reads as a list. */
  text-align: left;
}
#expedition-list .hero-name, #squad-roster-list .hero-name {
  display: block; padding: 0 12px 2px; font-size: 12px; color: #f4e8c9;
}
#expedition-board .eyebrow, #expedition-note { text-align: center; }

/* A party member is not "the work roster" - it is who is coming with you.
   Keeping its list visually separate is the point of the split: one glance
   answers "who's with me" without reading a Leave party button meant for a
   different question. */
#squad-roster-section {
  margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}

.confirm-modal { width: min(420px, calc(var(--safe-vw) - 32px)); }
.hero-confirmation {
  display: flex; align-items: center; gap: 12px;
  margin: 4px 0 14px; padding: 12px;
  background: var(--row);
}
.hero-confirmation .hero-mark {
  width: 72px; height: 80px; flex: 0 0 72px;
  object-fit: contain; image-rendering: auto;
}
.hero-confirmation div { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.hero-confirmation strong { color: #f4e8c9; font-size: 16px; overflow-wrap: anywhere; }
.hero-confirmation small { color: var(--muted); font-size: 11px; line-height: 1.4; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.confirm-actions button { flex: 1; min-width: 0; }
.hero-name-field { display: flex; flex-direction: column; gap: 4px; margin: 8px 0 4px; font-size: 11px; color: var(--muted); }
.hero-name-field input {
  padding: 7px 9px; font: inherit; font-size: 12px; color: #f4e8c9;
  background: #0b0d10; border: 2px solid #3b3328;
}
.hero-name-field input:focus { outline: none; border-color: var(--gold-dark); }

#create-hero-modal .hero-name-field { gap: 8px; margin: 18px 0 8px; font-size: 12px; }
#create-hero-modal .hero-name-field input { min-height: 44px; padding: 10px 12px; font-size: 14px; }
#create-hero-modal .hero-name-field input:focus { outline: 2px solid var(--gold); outline-offset: 2px; }
#create-hero-modal .hint { font-size: 12px; line-height: 1.6; }
#hero-name-hint { margin-bottom: 16px; }
#hero-name-status { margin: -8px 0 16px; color: #e0a07a; font-size: 12px; }
#hero-name-status:empty { display: none; }
/* Letting a hero go: quiet in the row, plain about it in the window. */
.roster .hero-expedition .hero-delete-btn { margin-left: auto; color: #e8b8a6; border-color: #825747; }
#delete-hero-warning { margin: 0 0 8px; font-size: 13px; line-height: 1.45; color: #e7d7b4; }
#delete-hero-modal .hero-name-field { gap: 8px; margin: 14px 0 8px; font-size: 12px; }
#delete-hero-modal .hero-name-field input { min-height: 44px; padding: 10px 12px; font-size: 14px; }
#delete-hero-modal .hero-name-field input:focus { outline: 2px solid var(--gold); outline-offset: 2px; }
#delete-hero-status { margin: 0 0 8px; color: #e0a07a; font-size: 12px; }
#delete-hero-status:empty { display: none; }

/* The roster's own window (it used to hang under the town scene). */
.party-modal { width: min(760px, calc(var(--safe-vw) * .94)); }
.party-modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--rule); }
.party-modal-header h2 { margin: 0; padding: 0; border: 0; font-size: 20px; }
.party-modal #expedition-board { border-top: 0; margin-top: 0; padding-top: 0; }
.party-modal #expedition-board .eyebrow, .party-modal #expedition-note { text-align: left; }
