/* cart.slopped.site: the player (/play/) and the builder (/build/), and the desk's Cartridges window, which loads
   this same file. Brand tokens as on slopped.site; the page styles are in /style.css. Everything here is scoped to
   .player, .bd (the builder) or .cart-console so it can sit inside a desk window. */
.cart-console { position: relative; background: #171815; border-radius: 10px; overflow: hidden; outline: none; }
.cart-console:focus-visible { outline: 3px solid var(--focus, #728600); outline-offset: 4px; }
.cart-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; pointer-events: none; background: #171815; }
.cart-layer { position: absolute; inset: 0; touch-action: none; cursor: pointer; -webkit-user-select: none; user-select: none; }

/* buttons, shared by the player and the builder */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px; border: 2px solid var(--ink, #171815); border-radius: 999px; background: var(--paper, #f4f1e8); color: var(--ink, #171815); font: 700 15px/1 Arial, Helvetica, sans-serif; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--acid, #e3ff59); }
.btn[disabled] { opacity: .45; cursor: default; background: var(--paper, #f4f1e8); }
.btn.primary { background: var(--ink, #171815); color: var(--paper, #f4f1e8); }
.btn.primary:hover { background: #33352f; }
.btn[aria-pressed="true"] { background: var(--acid, #e3ff59); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; }
:where(.btn, .bd button, .bd select, .bd input, .bd textarea):focus-visible { outline: 3px solid var(--focus, #728600); outline-offset: 3px; }

/* the player */
.player { max-width: 1100px; margin: 0 auto; padding: 18px 5% 40px; }
.pl-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 18px; margin-bottom: 14px; }
.pl-head h1 { font-size: clamp(32px, 5vw, 56px); letter-spacing: -2px; }
.pl-about { margin: 0; color: var(--muted, #6b6b62); max-width: 60ch; }
.pl-console { width: 100%; height: clamp(300px, calc(100svh - 300px), 820px); }
.pl-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 6px; }
.pl-how { margin: 8px 0 0; font-size: 15px; }
.pl-msg { min-height: 1.5em; margin: 6px 0 0; color: var(--muted, #6b6b62); white-space: pre-line; }
@media (max-width: 620px) {
  .player { padding: 10px 16px 32px; }
  .pl-console { height: clamp(260px, calc(100svh - 260px), 640px); border-radius: 8px; }
  .pl-bar .btn { flex: 1 1 calc(50% - 8px); }
}

/* the builder: a toolbar, then the editor (left) and the console with its problems (right) */
.app-page.builder-page { min-height: 100svh; }
.bd { --bd-gap: 10px; display: grid; grid-template-rows: auto 1fr; gap: var(--bd-gap); min-height: 0; color: var(--ink, #171815); font-family: Arial, Helvetica, sans-serif; }
.bd-page { height: calc(100svh - 104px); padding: 10px 16px 12px; box-sizing: border-box; }
.bd-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.bd-bar h1 { font-size: 22px; letter-spacing: -.5px; margin: 0 6px 0 0; }
.bd-bar select { min-height: 42px; max-width: 230px; padding: 0 10px; border: 2px solid var(--ink, #171815); border-radius: 10px; background: var(--paper, #f4f1e8); color: var(--ink, #171815); font: 700 14px Arial, sans-serif; }
.bd-status { margin-left: auto; font-size: 14px; color: var(--muted, #6b6b62); }
.bd-status.bad { color: var(--no, #a3245e); font-weight: 700; }
.bd-status.good { color: var(--ok, #4d5c00); font-weight: 700; }
.bd-main { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, 1fr); gap: var(--bd-gap); min-height: 0; }
.bd-left, .bd-right { display: flex; flex-direction: column; min-height: 0; gap: 8px; }
.bd-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--ink, #171815); }
.bd-tabs button { min-height: 40px; padding: 0 14px; border: 2px solid var(--ink, #171815); border-bottom: 0; border-radius: 10px 10px 0 0; background: var(--paper, #f4f1e8); color: inherit; font: 700 14px Arial, sans-serif; cursor: pointer; margin-bottom: -2px; }
.bd-tabs button[aria-selected="true"] { background: var(--ink, #171815); color: var(--paper, #f4f1e8); }
.bd-pane { flex: 1; min-height: 0; border: 2px solid var(--ink, #171815); border-top: 0; border-radius: 0 0 10px 10px; background: var(--card, #fff); overflow: auto; position: relative; }
.bd-pane[hidden] { display: none; }
.bd-code { position: absolute; inset: 0; }
.bd-text { width: 100%; height: 100%; min-height: 360px; box-sizing: border-box; border: 0; padding: 10px; resize: none; font: 14px/1.45 ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace; background: var(--card, #fff); color: var(--ink, #171815); tab-size: 2; }
.bd-console { flex: 0 0 auto; height: min(52vh, 460px); }
.bd-runbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.bd-problems { flex: 1; min-height: 90px; overflow: auto; margin: 0; padding: 0; list-style: none; border: 2px solid var(--ink, #171815); border-radius: 10px; background: var(--paper, #f4f1e8); font-size: 14px; }
.bd-problems li { border-bottom: 1px solid var(--line, #d4d2c9); }
.bd-problems li:last-child { border-bottom: 0; }
.bd-problems button { display: block; width: 100%; padding: 8px 10px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.bd-problems button:hover { background: var(--acid, #e3ff59); }
.bd-problems .where { font-weight: 700; margin-right: 6px; }
.bd-problems .ok { padding: 8px 10px; color: var(--ok, #4d5c00); font-weight: 700; }
.bd-problems .warn { color: var(--muted, #6b6b62); }
.bd-about { font-size: 12px; color: var(--muted, #6b6b62); margin: 0; }
.bd-about a { color: inherit; }
.bd-hide { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* the picture, map and music editors share one frame: a list of things on the left, the editor on the right */
.ed { display: grid; grid-template-columns: 170px minmax(0, 1fr); min-height: 100%; }
.ed-list { border-right: 2px solid var(--line, #d4d2c9); padding: 8px; display: flex; flex-direction: column; gap: 4px; background: var(--paper, #f4f1e8); }
.ed-list button { min-height: 36px; padding: 0 10px; border: 2px solid transparent; border-radius: 8px; background: none; color: inherit; font: 700 14px Arial, sans-serif; text-align: left; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.ed-list button[aria-current="true"] { border-color: var(--ink, #171815); background: var(--card, #fff); }
.ed-list canvas { image-rendering: pixelated; width: 24px; height: 24px; flex: none; }
.ed-list .add { margin-top: 6px; border: 2px dashed var(--muted, #6b6b62); }
.ed-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ed-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ed-row label { font-size: 13px; font-weight: 700; display: inline-flex; gap: 6px; align-items: center; }
.ed-row input[type="number"] { width: 64px; min-height: 34px; border: 2px solid var(--ink, #171815); border-radius: 8px; padding: 0 6px; font: inherit; }
.ed-grid { touch-action: none; image-rendering: pixelated; border: 2px solid var(--ink, #171815); background-color: #fff; background-image: linear-gradient(45deg, #e9e6dc 25%, transparent 25%, transparent 75%, #e9e6dc 75%), linear-gradient(45deg, #e9e6dc 25%, transparent 25%, transparent 75%, #e9e6dc 75%); background-size: 16px 16px; background-position: 0 0, 8px 8px; cursor: crosshair; max-width: 100%; }
.ed-grid:focus-visible { outline: 3px solid var(--focus, #728600); outline-offset: 3px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches button { width: 36px; height: 36px; border: 2px solid var(--ink, #171815); border-radius: 8px; cursor: pointer; position: relative; font: 700 12px ui-monospace, monospace; display: grid; place-items: end start; padding: 2px 4px; }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--paper, #f4f1e8), 0 0 0 6px var(--ink, #171815); }
.swatches .clear { background: repeating-conic-gradient(#e9e6dc 0 25%, #fff 0 50%) 0 0 / 12px 12px; }
.ed-note { margin: 0; font-size: 13px; color: var(--muted, #6b6b62); }
.voice { border: 2px solid var(--ink, #171815); border-radius: 10px; padding: 8px; display: grid; gap: 6px; background: var(--card, #fff); }
.voice-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; }
.voice-head b { font-size: 15px; }
.voice input[type="text"] { width: 100%; min-height: 38px; box-sizing: border-box; border: 2px solid var(--line, #d4d2c9); border-radius: 8px; padding: 0 8px; font: 14px ui-monospace, Menlo, Consolas, monospace; }
.voice input[type="text"][aria-invalid="true"] { border-color: #a3245e; }
.voice canvas.roll { width: 100%; height: 54px; border-radius: 6px; background: #171815; display: block; }
.voice .err { color: var(--no, #a3245e); font-size: 13px; margin: 0; }
.keys { display: flex; gap: 2px; flex-wrap: wrap; }
.keys button { min-width: 34px; min-height: 34px; border: 2px solid var(--ink, #171815); border-radius: 6px; background: #fff; color: #171815; font: 700 12px Arial, sans-serif; cursor: pointer; }
.keys button.sharp { background: #171815; color: #f4f1e8; }

/* phones: one pane at a time (Code, Pictures, Maps, Music, Play), a plain text box instead of Monaco */
@media (max-width: 899px) {
  .bd-page { height: auto; min-height: calc(100svh - 70px); }
  .bd-main { grid-template-columns: 1fr; }
  .bd-pane { min-height: 60svh; }
  .bd-console { height: 56svh; }
  .bd-status { margin-left: 0; flex-basis: 100%; }
  .ed { grid-template-columns: 1fr; }
  .ed-list { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 2px solid var(--line, #d4d2c9); }
  .bd-tabs { overflow-x: auto; }
}
@media (max-width: 899px) { .bd[data-pane="play"] .bd-left .bd-pane { display: none; } .bd:not([data-pane="play"]) .bd-right { display: none; } }
