/* The fit page. Shared house style in ../common.css. */
#app { max-width: 60rem; }
#app section { margin-top: var(--space-6); padding-top: var(--space-4); border-top: 1px solid var(--border); }
#app h3 { font-size: var(--fs-md); margin: var(--space-5) 0 var(--space-2); }
.busy { position: sticky; top: 0; z-index: 5; margin: 0; min-height: 0; }
.busy:not(:empty) { padding: var(--space-2) var(--space-3); background: var(--fg-1); color: var(--bg); border-radius: var(--radius-sm); font-weight: 600; }
body[data-busy] #plan-body, body[data-busy] #result-body { opacity: 0.55; }

#input select { display: block; width: 100%; max-width: 40rem; margin: var(--space-1) 0 var(--space-2); }
#input textarea { width: 100%; font-family: var(--font-mono); font-size: var(--fs-xs); }
label.file { position: relative; overflow: hidden; }
label.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3) var(--space-3); margin: var(--space-3) 0; min-width: 0; }
legend { font-weight: 600; padding: 0 var(--space-1); }

.big { font-size: var(--fs-lg); }
/* option cards: one even grid, every card the same width (a column of full-width cards on a phone) */
.presets { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: var(--space-2); margin: var(--space-2) 0; }
.presets button { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; text-align: left; height: auto; width: 100%; padding: 8px 12px; }
.presets button .note { font-weight: 400; font-size: var(--fs-xs); }
.presets button[aria-pressed="true"] { border: 2px solid var(--fg-1); font-weight: 700; }
.target-grid, .rules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 0 var(--space-4); }
.target-grid input[type=number] { width: 4.5em; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr)); gap: 0 var(--space-3); }

ol.order { list-style: none; padding: 0; margin: var(--space-2) 0; }
ol.order li { display: flex; align-items: center; gap: var(--space-2); padding: 2px 0; border-bottom: 1px solid var(--border-subtle); }
ol.order .pos { width: 1.6em; text-align: right; color: var(--fg-2); font-variant-numeric: tabular-nums; }
ol.order .pname { flex: 1; min-width: 0; }
ol.order .moves { display: flex; gap: 4px; }
ol.order .moves button { min-width: 2.5rem; padding: 2px 8px; }
ul.forbidden { padding-left: 1.2em; }
details.advanced { margin: var(--space-3) 0; }
details.advanced textarea { width: 100%; font-family: var(--font-mono); font-size: var(--fs-xs); }

table.plan { font-size: var(--fs-sm); }
table.plan td, table.plan th { padding: 4px 8px 4px 0; vertical-align: top; text-align: left; }
table.plan td.n, table.plan th.n { text-align: right; white-space: nowrap; }
table.plan td.step { min-width: 14rem; }
table.plan td.step .title { display: block; }
table.plan td.step code.id { display: inline-block; margin-top: 2px; font-size: var(--fs-xs); color: var(--fg-2); }
table.plan td:nth-child(5), table.plan td button { white-space: nowrap; }
.pointnav { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin: var(--space-2) 0; }
.pointnav p { order: 3; flex: 1 1 100%; margin: 0; min-width: 0; }
.pointnav button { flex: none; }
table.compare .by { display: block; font-size: var(--fs-xs); color: var(--fg-2); margin-top: 2px; }
#not-carried { border-left: 4px solid var(--fg-1); padding-left: var(--space-3); }
#rules-box > summary { cursor: pointer; font-weight: 600; }
.cls { white-space: nowrap; }

.chartwrap { overflow: hidden; margin: var(--space-2) 0; }
svg.frontier { display: block; max-width: 100%; height: auto; font-family: var(--font-sans); }
svg.frontier text { fill: var(--fg-2); font-size: 0.75rem; }
svg.frontier .vline { stroke: var(--border); stroke-width: 1; }
svg.frontier .axis { stroke: var(--fg-2); stroke-width: 1; }
svg.frontier .axlabel { fill: var(--fg-2); }
svg.frontier .target, .legend .target { stroke: var(--fg-1); stroke-width: 2; stroke-dasharray: 6 4; }
svg.frontier .tlabel { fill: var(--fg-1); font-weight: 600; }
svg.frontier .path { fill: none; stroke: var(--fg-3, #8a94a0); stroke-width: 1.5; }
svg.frontier .pt { cursor: pointer; outline: none; }
svg.frontier .pt .hit { fill: transparent; stroke: none; }
svg .pt circle:not(.hit):not(.ring), svg .pt rect, svg .pt path, svg.lg circle:not(.ring), svg.lg rect, svg.lg path { fill: var(--bg); stroke: var(--fg-1); stroke-width: 1.6; }
svg .pt.planned circle:not(.hit):not(.ring), svg .pt.planned rect, svg .pt.planned path:not(.cross), svg.lg.planned rect { fill: var(--fg-1); }
svg .ring { fill: none; stroke: var(--fg-1); stroke-width: 2.5; }
svg.frontier .pt:focus-visible .hit { stroke: var(--focus); stroke-width: 3; }
svg .cross { stroke-width: 2.4 !important; }
ul.legend { font-size: var(--fs-sm); color: var(--fg-2); gap: var(--space-1) var(--space-3); margin: var(--space-1) 0; }
ul.legend svg { vertical-align: -2px; overflow: visible; }

.result-top { display: grid; grid-template-columns: minmax(0, 20rem) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
@media (max-width: 44rem) { .result-top { grid-template-columns: minmax(0, 1fr); } }
.qrbox .qr svg { width: 100%; max-width: 20rem; height: auto; border: 1px solid var(--border); background: #fff; }
table.compare { font-size: var(--fs-sm); }
table.compare th, table.compare td { padding: 4px 10px 4px 0; text-align: left; vertical-align: top; }
table.compare th[scope=row] { font-weight: 600; }
table.compare tr.changed th[scope=row]::after { content: " (changed)"; font-weight: 400; color: var(--fg-2); }

/* narrow screens: the plan and the comparison as stacked rows, each value labelled */
@media (max-width: 40rem) {
  table.plan thead, table.compare thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.plan, table.plan tbody, table.plan tr, table.plan td, table.compare, table.compare tbody, table.compare tr, table.compare td, table.compare th { display: block; width: auto; }
  table.plan tr, table.compare tr { padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
  table.plan td, table.compare td, table.compare th { padding: 1px 0; text-align: left !important; white-space: normal !important; min-width: 0 !important; border: 0; }
  table.plan tr { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 0.5em; }
  table.plan td:first-child { grid-row: 1 / span 8; font-weight: 600; }
  table.plan td:not(:first-child) { grid-column: 2; }
  table.plan td:first-child::after { content: "."; }
  table.plan td.empty { display: none; }
  table.plan td[data-label]::before, table.compare td[data-label]::before { content: attr(data-label) ": "; color: var(--fg-2); }
  table.plan td button { margin-top: var(--space-1); }
}

/* the rule table: an unchecked row in a lighter weight; the target's size line between rows */
table.rules tr.off td { color: var(--fg-2); }
table.rules tr.size-line td { border-top: 3px solid var(--fg-1); font-weight: 600; padding-top: 4px; }
table.rules td.moves { white-space: nowrap; }
table.rules td.rule select { margin-left: 0.3em; }
table.rules td[data-label="QR"] { white-space: nowrap; }
table.rules td.phone-line, .phone-only { display: none; }
table.rules label.tap { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; margin: -10px -8px; cursor: pointer; }
/* a phone: each rule on two lines (number, switch, rule and rung, moves; then one small line of what it does), the
   column meanings said once above the list */
@media (max-width: 40rem) {
  .phone-only { display: block; }
  .tablewrap.stacks > table.rules > tbody > tr:not(.size-line) { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; column-gap: var(--space-1); align-items: center; padding: var(--space-1) 0; }
  .tablewrap.stacks > table.rules > tbody > tr > td { padding: 0; }
  table.rules td[data-label] { display: none !important; }
  table.rules td.n:first-child { grid-column: 1; grid-row: 1; }
  table.rules td.on-cell { grid-column: 2; grid-row: 1; }
  table.rules td.rule { grid-column: 3; grid-row: 1; }
  table.rules td.moves { grid-column: 4; grid-row: 1; display: flex; gap: 2px; }
  table.rules td.phone-line { display: block; grid-column: 3 / 5; grid-row: 2; font-size: var(--fs-sm); color: var(--fg-2); }
  table.rules td.rule select { padding-top: 2px; padding-bottom: 2px; min-height: 0; }
  table.rules td.moves button { min-width: 44px; min-height: 44px; padding: 0; }
  table.rules td.rule select { max-width: 100%; }
}
