/* Partition Planner layout. Tokens, the shell, the lobe and base components come from shared/theme.css.
   Encoding (never colour alone): data read = solid lobe fill with an ink edge; file opens = ink hatch on cream. */
.board > * { min-width: 0; }
.brief p { margin: 0; font-size: 17px; line-height: 1.45; max-width: 65ch; }
.level-title { margin-bottom: 14px; }
.level-title:focus { outline: none; }

/* layout controls: standard radios drawn as capsules with a round chip on the leading edge */
.tools { display: grid; gap: 16px; }
#controls { display: grid; gap: 12px; min-width: 0; }
#controls fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#controls legend { float: left; width: 124px; padding: 0; font: 800 19px/1 var(--display); letter-spacing: -.02em; }
#controls .fixed { margin: 0; font-size: 14px; font-weight: 500; }
.opt { position: relative; cursor: pointer; }
.opt input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.opt span {
  display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; min-height: 48px;
  font: 700 15px/1.15 var(--font); color: var(--ink);
  background: var(--water); border: 2px solid var(--ink); border-radius: 26px; padding: 4px 18px 4px 6px;
  transition: transform var(--t) var(--bounce), background-color .2s, color .2s;
}
.opt span::before { /* the chip: a hollow ring until chosen, then the lobe colour with a tick */
  content: ''; grid-row: span 2; width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--ink); background: var(--water);
}
.opt small { grid-column: 2; font-weight: 500; font-size: 13px; color: var(--muted); }
.opt:hover span { transform: translateY(-2px); background: var(--panel-2); }
.opt input:checked + span { background: var(--ink); color: var(--water); }
.opt input:checked + span::before { border-color: var(--accent); background: var(--accent) var(--pic-tick) center / 16px no-repeat; }
.opt input:checked + span small { color: var(--water); }
.opt input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 3px; } /* the input itself is not drawn */
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
#target { margin-right: auto; flex-wrap: wrap; gap: 0 1ch; }
#target > span { white-space: nowrap; } /* "budget 70,000" stays together */

/* the storage lake and the query bill */
.board { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px 28px; align-items: start; }
.board h2 { font-size: 19px; margin: 0 0 10px; }
.board h2 .mono { font: 600 15px var(--mono); letter-spacing: 0; }
#stats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
#grid { display: block; width: 100%; aspect-ratio: 2 / 1; min-height: 200px; }
#legend { margin: 10px 0 0; font-size: 14px; min-height: 2.9em; }
#formula { margin: 0 0 10px; flex-wrap: wrap; gap: 0 6px; font-family: var(--mono); }
#formula span { white-space: nowrap; } /* wraps between the two terms, never inside one */

/* each query is a cream card; the one shown on the storage grid is joined to the lake by a short path */
#queries { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.q {
  position: relative; width: 100%; text-align: left; cursor: pointer; font: 14px var(--font); color: var(--ink);
  background: var(--water); border: 2px solid var(--ink); border-radius: var(--radius-card); padding: 10px 14px; display: grid; gap: 4px;
  transition: transform var(--t) var(--bounce), background-color .2s;
}
.q:disabled { cursor: default; border-style: dashed; }
.q:enabled:hover { background: var(--panel-2); transform: translateY(-2px); }
.q.active { border-width: 4px; padding: 8px 12px; }
.q.active::before { content: ''; position: absolute; right: 100%; top: 50%; width: 32px; height: 4px; margin-top: -2px; background: var(--ink); }
.q.active::after { content: ''; position: absolute; right: calc(100% + 26px); top: 50%; width: 14px; height: 14px; margin-top: -7px; border-radius: 50%; background: var(--ink); }
.q .head { display: flex; gap: 12px; justify-content: space-between; align-items: baseline; }
.q .head b { font: 800 17px/1.1 var(--display); letter-spacing: -.02em; }
.q .cost { font: 700 17px var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.q:disabled .cost { color: var(--muted); }
.q code { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.q .reads { font: 12px var(--mono); color: var(--muted); }
.q .reads b { color: var(--ink); }
.q .reads b, .q .reads span { white-space: nowrap; }
.q .reads .all { color: var(--amber); } /* nothing skipped: a warning, marked as well as coloured */
.q .reads .all::before { content: '▲ ' / ''; }
.bar { display: flex; height: 12px; background: var(--water); border: 2px solid var(--ink); border-radius: var(--pill); overflow: hidden; }
.bar i { display: block; height: 100%; }
.bar i[style="width:0%"] { display: none; }
.scan { background: var(--accent); border-right: 2px solid var(--ink); }
.open { background: repeating-linear-gradient(135deg, var(--ink) 0 2px, transparent 2px 5px); } /* a flat hatch, not a second colour */

#total { background: var(--water); border: 2px solid var(--ink); border-radius: var(--radius-card); padding: 12px 16px 14px; }
#total .row { display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: space-between; align-items: baseline; font: 600 14px var(--mono); margin-bottom: 4px; }
#total .lbl { font: 800 19px/1 var(--display); letter-spacing: -.02em; margin-right: 8px; }
#total .n { display: inline-block; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
#total .over { background: var(--coral); border-radius: var(--pill); padding: 0 .5em; }
#total .over::before { content: '▲ ' / ''; font-size: 16px; }
.meter { position: relative; padding: 6px 0; }
.meter .bar { height: 22px; }
.meter .mark { position: absolute; left: 50%; top: 0; bottom: 0; width: 4px; margin-left: -2px; border-radius: 2px; background: var(--ink); outline: 2px solid var(--water); } /* fixed: the scale is always 2× budget */
.key { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; margin-top: 6px; }
.key i { display: inline-block; width: 18px; height: 12px; margin-right: 6px; vertical-align: -1px; border: 2px solid var(--ink); border-radius: 4px; }
.key i.mark { width: 4px; height: 14px; border: 0; border-radius: 2px; background: var(--ink); vertical-align: -3px; }

/* result: a small overshoot in, a shake when not solved; confetti in the lobe colour and ink only */
#verdict { isolation: isolate; }
@media (prefers-reduced-motion: no-preference) {
  #verdict[data-state="win"] { animation: pop var(--t) var(--bounce); }
  #verdict[data-state="lose"] { animation: shake var(--t); }
}
@keyframes pop { from { transform: scale(.94); } }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }
.confetti { position: absolute; left: 50%; top: 50%; z-index: -1; pointer-events: none; } /* behind the result text */
.confetti i { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--ink); animation: burst .8s ease-out both; }
.confetti i:nth-child(odd) { background: var(--ink); }
@keyframes burst { to { transform: translate(var(--dx), var(--dy)); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .confetti { display: none; } }

@media (min-width: 1181px) { /* side by side: the lake is as tall as the bill, so the active query's path always lands on it */
  .board { align-items: stretch; }
  #storage { display: flex; flex-direction: column; }
  #grid { flex: 1 1 0; height: 0; aspect-ratio: auto; min-height: 220px; }
}
@media (max-width: 1180px) {
  .board { grid-template-columns: minmax(0, 1fr); }
  .q.active::before, .q.active::after { display: none; } /* stacked: the bill sits under the lake, nothing to join sideways */
}
@media (max-width: 640px) {
  #controls legend { float: none; width: 100%; margin-bottom: 6px; }
  #grid { aspect-ratio: 4 / 3; } /* more area per file on a phone */
}
