/*
 * Farhold R23 — the title screen, laid out again.
 *
 * "Redesign the main menu, character selector, world selector as the new extensive spell
 *  descriptions and other things have caused the layout to display poorly." Same colours, same type;
 * what changed is the structure. Linked after style.css, whose #boot rules still style the inputs,
 * the buttons and the save rows — this file only arranges them.
 *
 * Before: the character step was a form in the left half with nothing under it and a 340px column on
 * the right holding the figure AND every skill's forty-word description in a 130px sub-column, so
 * the page ran to 1,779px tall at 1280 x 800 and was 460px wide on a 390px phone.
 *
 * Now (js/newgame.js sets `#boot[data-screen]` to whichever screen is showing):
 *   - the two steps fill the window, with a step bar, and the title shrinks to one line;
 *   - the character step is three columns: who (name, class, a class list you can read down),
 *     the 3D figure, and what the class does (facts as chips first, the sentence clamped to two
 *     lines, the whole sentence on click and in the tooltip);
 *   - the world step is two: the knobs as labelled fields in two groups, and the map with its facts;
 *   - on a wide screen only a list scrolls, one per column; under 1000px wide (or 600px tall) it
 *     all stacks into one column and the page scrolls instead — never a scroll box inside a
 *     scrolling page.
 *
 * research/round23-title.md is the write-up, with before and after screenshots.
 */

#boot {
  --b-line: #22304a;
  --b-pane: rgba(10, 16, 28, .66);
  --b-ink: #dfe9f6;
  --b-dim: #9fb0c8;
  --b-faint: #7f8ea4;
  --b-accent: #7fd8ff;
  --b-good: #8fe0a0;
  --b-gold: #ffd24a;
}

/* ---------------------------------------------------------------- the menu
   The controls are a grid of keys now, not a paragraph with bold letters in it. */
#boot .boot-about { max-width: 560px; }
.boot-keys {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 3px 16px;
  max-width: 660px; margin: 14px auto 0; padding: 0; text-align: left; font-size: 12px; color: #8b9ab0;
}
.boot-keys > div { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.boot-keys dt { flex: 0 0 64px; text-align: right; margin: 0; }
.boot-keys dd { margin: 0; min-width: 0; }
#boot kbd {
  display: inline-block; min-width: 18px; padding: 0 5px; border: 1px solid #2c3a52; border-bottom-width: 2px;
  border-radius: 4px; background: #121826; color: #cfe0ef; font: 600 11px/1.5 ui-monospace, Consolas, monospace;
  text-align: center;
}

/* ---------------------------------------------------------------- a step fills the window */
#boot[data-screen="boot-character"], #boot[data-screen="boot-world"] {
  display: flex; flex-direction: column; align-items: center; padding: 14px 20px 10px;
}
/**
 * R26 — THE TITLE HAS TO BE ABLE TO GO AWAY.
 *
 * "Sometimes after creating a character I get stuck at 'waking the wayfarer…'" — the rule above is
 * `#boot[data-screen]`, one id and one attribute, which is EXACTLY as specific as style.css's
 * `#boot.hidden { display: none }`, and this file is linked after that one. So on the world step
 * (the screen Start is on) `display: flex` won, main.js added `.hidden` and nothing disappeared,
 * while the game ran and played its sounds behind the title. `!important` because nothing may ever
 * out-rank "hidden" again; tests/round26-fixes.spec.js checks the computed style, not the class.
 */
#boot.hidden { display: none !important; }
#boot[data-screen="boot-character"] .boot-inner, #boot[data-screen="boot-world"] .boot-inner {
  max-width: 1360px; flex: 1 0 auto; display: flex; flex-direction: column;
}
#boot[data-screen="boot-character"] h1, #boot[data-screen="boot-world"] h1 {
  font-size: 20px; letter-spacing: 5px; margin: 0 0 8px;
}
#boot[data-screen="boot-character"] .tagline, #boot[data-screen="boot-world"] .tagline { display: none; }
#boot .boot-step:not(.hidden) { display: flex; flex-direction: column; flex: 1 0 auto; min-height: 0; text-align: left; }
#boot .status:empty { min-height: 0; margin: 0; }

.boot-stephead { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 12px; }
#boot .boot-stephead .boot-h2 { margin: 0; font-size: 17px; }
.boot-steps { display: flex; gap: 6px; list-style: none; margin: 0 0 0 auto; padding: 0; order: 2; flex-wrap: wrap; }
.boot-steps li {
  display: flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px; border: 1px solid var(--b-line);
  border-radius: 999px; color: var(--b-faint); font-size: 12px; background: rgba(12, 18, 30, .7);
}
.boot-steps li span {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  background: #1a2433; color: var(--b-dim); font-size: 11px; font-weight: 600;
}
.boot-steps li.on { color: var(--b-ink); border-color: #2f7ba8; }
.boot-steps li.on span { background: #1b4a6a; color: #dff2ff; }
.boot-steps li.done span { background: #1b3323; color: var(--b-good); }

/* ---------------------------------------------------------------- the columns */
.boot-cols { display: grid; gap: 16px; align-items: stretch; min-height: 0; }
.boot-cols--char { grid-template-columns: minmax(220px, 270px) minmax(260px, 1fr) minmax(340px, 1.35fr); }
.boot-cols--world { grid-template-columns: minmax(360px, 1fr) minmax(340px, 1.05fr); }
.boot-col { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.boot-col > * { min-width: 0; }

/* one labelled control: the label above, the control full width, the explanation under it */
.boot-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
#boot .boot-field > span:first-child, #boot .boot-field > label:first-child:not(.check) {
  color: var(--b-faint); font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
}
#boot .boot-field input:not([type="checkbox"]), #boot .boot-field select { width: 100%; max-width: 100%; min-width: 0; }
#boot .hint { color: #74839a; font-size: 12px; line-height: 1.45; }
.boot-inline { display: flex; gap: 8px; align-items: center; min-width: 0; }
#boot .boot-inline input { width: auto; flex: 1 1 auto; min-width: 0; }
#boot .boot-inline button { flex: 0 0 auto; }
#boot .boot-lock { margin: 0; text-align: left; max-width: none; }

/* ---------------------------------------------------------------- step 1, column 1: the class list
   The same thirty-one entries as the dropdown, with the role under the name and a mark for the
   classes that bring a companion — read down instead of opened and scrolled. */
.boot-class-list {
  display: flex; flex-direction: column; gap: 2px; flex: 1 1 0; min-height: 120px; overflow-y: auto;
  padding: 4px; border: 1px solid var(--b-line); border-radius: 8px; background: var(--b-pane);
  overscroll-behavior: contain;
}
#boot .boot-class-list .cl-row {
  display: grid; grid-template-columns: 1fr auto; gap: 0 8px; align-items: baseline;
  width: 100%; text-align: left; padding: 5px 8px; font-size: 13px; line-height: 1.3;
  background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--b-ink);
}
#boot .boot-class-list .cl-row:hover { background: #16213a; border-color: var(--b-line); }
#boot .boot-class-list .cl-row.on { background: #14243a; border-color: #2f7ba8; }
.cl-row b { font-weight: 600; }
.cl-row .cl-role { grid-column: 1 / -1; color: var(--b-faint); font-size: 11px; }
.cl-row .cl-tag { color: var(--b-good); font-size: 10px; letter-spacing: .04em; text-transform: uppercase; }
.cl-row.custom b { color: var(--b-gold); }

/* ---------------------------------------------------------------- step 1, column 2: the figure
   js/figure3d.js fills the box with a canvas its own size. */
#boot .boot-figure {
  position: relative; flex: 1 1 0; min-height: 300px; margin: 0; padding: 0; display: block;
  background: radial-gradient(ellipse at 50% 85%, #1a2b44 0%, #0d1422 60%, #0a0f19 100%);
  border: 1px solid var(--b-line); border-radius: 10px; overflow: hidden;
}
.figure-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: pan-y; }
.figure-canvas:active { cursor: grabbing; }
.figure-none { padding: 20px; text-align: center; }
#boot #boot-figure-note { text-align: center; margin: 0; }
.boot-figure-buttons { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---------------------------------------------------------------- step 1, column 3: the class card
   A chip's kind is `k-hit`, `k-status`… rather than a bare `status`: style.css has `#boot .status`
   (the boot status line, 12px of top margin), and a chip called "status" picked it up. */
#boot .boot-cardcol .class-card {
  flex: 1 1 0; min-height: 0; overflow-y: auto; margin: 0; max-width: none; padding: 14px 16px;
  overscroll-behavior: contain;
}
.class-card .cc-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.class-card .cc-head h4 { margin: 0; font-size: 18px; }
.class-card .cc-chips, .sc-facts { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 8px; padding: 0; list-style: none; }
.sc-chip, .class-card .cc-chips li {
  display: inline-block; padding: 0 7px; border: 1px solid #2c3a52; border-radius: 999px;
  background: #121a29; color: #9fb0c8; font-size: 11px; line-height: 18px; white-space: nowrap;
}
.sc-chip.k-hit { color: #f2e6c8; border-color: #4a4230; }
.sc-chip.k-heal { color: #8fe0a0; border-color: #2e5a3a; }
.sc-chip.k-status { color: #ffcf9a; border-color: #5a3e2a; }
.sc-chip.k-cost { color: #7f8ea4; }
.sc-chip.el-fire { color: #ff9a5a; border-color: #5a3020; }
.sc-chip.el-ice, .sc-chip.el-frost { color: #9fd8ff; border-color: #24445a; }
.sc-chip.el-lightning { color: #ffe86a; border-color: #58502a; }
.sc-chip.el-poison { color: #9ede6a; border-color: #36502a; }
.sc-chip.el-shadow { color: #c090ff; border-color: #40305a; }
.sc-chip.el-holy { color: #ffe6a0; border-color: #5a4e2a; }
.sc-chip.el-arcane { color: #b8a0ff; border-color: #3a3460; }
.sc-chip.el-physical { color: #cfd6de; }
.class-card .cc-pet { margin: 0 0 10px; }
.class-card h5 {
  margin: 4px 0 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #7f8ea4;
}
.class-card .cc-skills { display: flex; flex-direction: column; gap: 6px; }
.class-card .cc-skills li.cc-skill {
  display: block; padding: 7px 10px; border: 1px solid #1e2a40; border-radius: 7px; background: #0e1523;
  cursor: pointer; font-size: 12px;
}
.class-card .cc-skills li.cc-skill:hover, .class-card .cc-skills li.cc-skill:focus-visible { border-color: #2f7ba8; outline: none; }
.cc-skill .cs-top { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.cc-skill .cs-top b { font-size: 13px; }
.cc-skill .cs-lv { margin-left: auto; color: #ffd24a; font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cc-skill .sc-facts { margin-bottom: 4px; }

/* the sentence: two lines until the card is opened (shared with the class builder's spell cards) */
.sc-desc {
  margin: 0; color: #8b9ab0; font-size: 12px; line-height: 1.45;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
.open > .sc-desc { -webkit-line-clamp: unset; line-clamp: unset; display: block; }

/* R28 — the round-28 mechanics as chips (js/skillcard.js mechFacts): a shape, stance, temper or
   song is green like the bar's form badge, a rule about pressing the key (charges, recast,
   channel) is violet like the recast ring, a class resource is the gold of its pips. */
.sc-chip.k-form { color: #b8f0a0; border-color: #2f5a2a; }
.sc-chip.k-mech { color: #d4b8ff; border-color: #44345e; }
.sc-chip.k-res { color: #ffd58a; border-color: #5a4a26; }

/* R28 — what a shape does to the other skills, and what a skill becomes in each shape. The
   names always show; the sentences only on an opened card. */
.sc-forms { list-style: none; margin: 4px 0 0; padding: 4px 0 0 8px; border-left: 2px solid #2f5a2a; font-size: 11.5px; color: #8b9ab0; }
/* the class card's own `.cc-skills li` is a three-column grid; these rows are plain lines */
.class-card .cc-skills .sc-forms li { display: block; margin: 1px 0; font-size: 11.5px; }
.class-card .cc-skills .sc-forms b, .sc-forms b { display: inline; color: #b8f0a0; font-size: 11.5px; font-weight: 600; }
.sc-forms .sc-form-desc { display: none; }
.open > .sc-forms .sc-form-desc { display: inline; }

/* ---------------------------------------------------------------- the step footer
   Back on the left, the next step on the right, and what you have picked between the two. */
#boot .boot-step .boot-actions { margin-top: 12px; padding-top: 10px; }
.boot-summary { flex: 1 1 auto; text-align: center; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- step 2: the knobs, in two groups */
#boot .boot-cols--world .boot-knobs { margin: 0; text-align: left; }
.boot-group {
  margin: 0; padding: 10px 14px 12px; border: 1px solid var(--b-line); border-radius: 8px;
  background: var(--b-pane); display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.boot-group legend { padding: 0 6px; color: var(--b-accent); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.boot-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
#boot .boot-field label.check { display: flex; align-items: center; gap: 8px; color: var(--b-ink); font-size: 14px; cursor: pointer; }
#boot .boot-field label.check input { accent-color: #7fd8ff; width: 16px; height: 16px; }
#boot .boot-zones-note { margin: 0; }

.boot-mapcol { gap: 8px; }
.boot-mapbox { position: relative; }
#boot #boot-map { width: 100%; height: auto; aspect-ratio: 2 / 1; }
#boot #boot-map-status { position: absolute; left: 10px; bottom: 8px; margin: 0; min-height: 0; text-shadow: 0 1px 2px #000; }
.boot-mapcol .boot-map-where { font-size: 16px; margin: 4px 0 0; }
.boot-subhead {
  margin: 8px 0 0; padding-top: 10px; border-top: 1px solid #1e2738;
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--b-faint);
}

/* ---------------------------------------------------------------- wide and tall enough
   The steps fit the window, and each column scrolls on its own. */
@media (min-width: 1000px) and (min-height: 600px) {
  #boot[data-screen="boot-character"], #boot[data-screen="boot-world"] { overflow: hidden; }
  #boot[data-screen="boot-character"] .boot-inner, #boot[data-screen="boot-world"] .boot-inner { flex: 1 1 0; min-height: 0; }
  #boot .boot-step:not(.hidden) { flex: 1 1 0; }
  .boot-cols { flex: 1 1 0; }
  .boot-col { overflow: hidden; }
  #boot .boot-cols--world .boot-knobs { overflow-y: auto; padding-right: 4px; overscroll-behavior: contain; }
  .boot-mapcol { overflow-y: auto; }
}

/* ---------------------------------------------------------------- narrower
   One column, the figure and the map first, and the page is the only thing that scrolls. The class
   list goes: the dropdown does the same job in a tenth of the height. */
@media (max-width: 999px), (max-height: 599px) {
  .boot-cols--char, .boot-cols--world { grid-template-columns: 1fr; }
  .boot-class-list { display: none; }
  #boot .boot-figure { flex: 0 0 auto; height: min(56vh, 420px); min-height: 260px; }
  #boot .boot-cardcol .class-card { flex: 0 0 auto; overflow: visible; }
  .boot-cols--char .boot-stagecol { order: -1; }
  .boot-cols--world .boot-mapcol { order: -1; }
  .boot-steps { order: 0; margin-left: 0; }
}
@media (max-width: 560px) {
  #boot { padding: 14px 12px; }
  #boot[data-screen="boot-character"], #boot[data-screen="boot-world"] { padding: 10px 12px; }
  .boot-row2 { grid-template-columns: 1fr; }
  .boot-summary { display: none; }
  #boot button { padding: 9px 16px; font-size: 15px; }
  #boot .boot-menu-buttons button { min-width: 0; width: min(260px, 100%); }
  .boot-keys { grid-template-columns: 1fr 1fr; }
  .boot-keys dt { flex-basis: 44px; }
  #boot .tagline { font-size: 13px; }
}

/* ---------------------------------------------------------------- the appearance editor
   It draws the same 3D figure (the canvas is moved into it while it is open), not the paper doll. */
.ap-figure { position: relative; min-height: 360px; overflow: hidden; padding: 0; display: block; }
@media (max-width: 760px) {
  .ap-figure { min-height: 300px; }
  /* the four buttons wrapped into a column 70px wide and pushed the panel off the right edge */
  .appearance { padding: 10px; }
  .ap-inner { padding: 14px; }
  .ap-actions { flex-wrap: wrap; }
  .ap-actions .ap-spacer { display: none; }
  .ap-actions button { flex: 1 1 auto; padding: 8px 12px; font-size: 14px; }
  .ap-label { flex-basis: 84px; }
}

/* R28: the class signature under the name on the class card */
.cc-head .cc-signature { margin: 2px 0 0; color: var(--b-faint); font-size: 12px; font-style: italic; }
