/* Python Blocks: files.js. The project's scripts as tabs over the blocks
   (main.py first, then the others, then +), Scratch-like: rounded tabs,
   the one shown tinted, gold under the pointer. They scroll sideways in
   their row when there are many. */

.pb-files { display: flex; align-items: center; gap: 4px; flex: 1 1 auto; min-width: 0; }
.pb-file-list { display: flex; align-items: center; gap: 4px; min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.pb-file { display: flex; flex: none; align-items: center; min-height: 32px; background: var(--bg); border: 1px solid var(--border); border-radius: 0; transition: border-color 160ms ease; }
.pb-file.is-active { background: var(--tint); border-color: var(--accent); }
.pb-file.has-error { border-color: #ff5a5a; box-shadow: inset 0 -2px 0 #ff5a5a; }
.pb-file.has-error .pb-file-tab::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; vertical-align: 1px; background: #ff5a5a; border-radius: 50%; }
.pb-file-tab { min-height: 30px; padding: 0 10px; color: var(--muted); background: none; border: 0; border-radius: 0; font: 600 0.78rem/1 var(--mono); white-space: nowrap; cursor: pointer; -webkit-touch-callout: none; user-select: none; }
.pb-file.is-active .pb-file-tab { color: var(--tint-text, var(--text)); }
/* main.py's small "start" tag: Run starts here. */
.pb-file-start { display: inline-block; margin-left: 6px; padding: 2px 4px; color: var(--accent-strong); border: 1px solid currentColor; font: 600 0.6rem/1 var(--body, Inter, system-ui, sans-serif); letter-spacing: 0.04em; vertical-align: 1px; }
.pb-file-more { display: inline-flex; align-items: center; justify-content: center; width: 28px; min-height: 30px; margin-left: -4px; color: var(--muted); background: none; border: 0; border-radius: 0; cursor: pointer; }
.pb-file-add { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 32px; height: 32px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 0; cursor: pointer; }
.pb-file-tab:focus-visible, .pb-file-more:focus-visible, .pb-file-add:focus-visible { outline: none; box-shadow: var(--focus-ring); }
@media (hover: hover) {
  .pb-file:hover { border-color: var(--gold); }
  .pb-file-tab:hover, .pb-file-more:hover { color: var(--gold); }
  .pb-file-add:hover { color: var(--bg); background: var(--gold); border-color: var(--gold); }
}
.pb-file-tab:active, .pb-file-more:active, .pb-file-add:active { color: var(--bg); background: var(--gold); }
.pb-file-add:active { transform: scale(0.94); }
.pb-file-menu .is-danger { color: #ff8b8b; }
.pb-code-file { margin-left: 6px; color: var(--text); font-family: var(--mono); letter-spacing: 0; text-transform: none; }

/* A new script's name. */
.pb-name-form { display: grid; gap: 8px; }
.pb-name-row { display: flex; align-items: center; gap: 6px; }
.pb-name-input { flex: 1 1 auto; min-width: 0; font-family: var(--mono); font-size: 16px; }
.pb-name-ext { color: var(--muted); font-family: var(--mono); }
.pb-name-err { min-height: 1.2em; margin: 0; color: #ff8b8b; font-size: 0.82rem; }
.pb-name-err:empty { min-height: 0; }

/* A phone: the tabs get a row of their own, under Run, with 36px targets. */
@media (max-width: 760px) {
  .pb-bar .pb-bar-left { display: flex; order: 2; padding: 4px 6px; border-top: 1px solid var(--border); }
  .pb-bar .pb-layout { display: none; }
  .pb-bar .pb-bar-stage { order: 1; }
  .pb-work { grid-template-rows: auto auto minmax(0, 1fr); }
  .pb-file, .pb-file-tab, .pb-file-more { min-height: 36px; }
  .pb-file-more { width: 36px; }
  .pb-file-add { width: 38px; height: 38px; }
}

/* The strip over the blocks: search.js's box over the palette (as wide as
   it, --pb-pal-w from main.js), and the script tabs over the blocks
   themselves, standing on the blocks' top edge. The blocks start under it. */
.pb-strip { position: absolute; top: 0; left: 0; right: 0; z-index: 6; display: flex; height: 44px; background: #1d1929; border-bottom: 1px solid var(--border); }
.pb-search-bar { display: flex; flex: none; align-items: center; width: var(--pb-pal-w, 300px); max-width: 100%; height: 100%; padding: 5px 8px; border-right: 1px solid var(--border); }
.pb-strip-tabs { display: flex; flex: 1 1 auto; min-width: 0; padding-left: 8px; }
.pb-strip-tabs:empty { display: none; }
.pb-blocks .pb-ws { top: 44px; }
.pb-search { display: flex; align-items: center; gap: 6px; width: 100%; height: 34px; padding: 0 4px 0 10px; color: var(--muted); background: var(--bg); border: 1px solid var(--border); border-radius: 0; cursor: text; }
.pb-search:focus-within { border-color: var(--accent); box-shadow: var(--focus-ring); }
.pb-search input { flex: 1 1 auto; min-width: 0; height: 100%; padding: 0; color: var(--text); background: none; border: 0; outline: none; font: 0.86rem var(--body); }
.pb-search input::-webkit-search-cancel-button { display: none; }
.pb-search-clear { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 28px; height: 28px; color: var(--muted); background: none; border: 0; border-radius: 0; cursor: pointer; }
.pb-search-clear[hidden] { display: none; }
@media (hover: hover) { .pb-search-clear:hover { color: var(--bg); background: var(--gold); } }
.pb-search-clear:active { color: var(--bg); background: var(--gold); }
@media (max-width: 760px) {
  .pb-strip { height: 48px; }
  .pb-search-bar { width: 100%; border-right: 0; }
  .pb-blocks .pb-ws { top: 48px; }
  .pb-search { width: 100%; height: 38px; }
  .pb-search input { font-size: 16px; }
  .pb-search-clear { width: 36px; height: 36px; }
}

/* media.js: the Media tab after the scripts, and its grid in place of the blocks and the Python. */
.pb-media-tab { display: inline-flex; flex: none; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px; color: var(--muted); background: var(--bg); border: 1px solid var(--border); border-radius: 0; font: 600 0.78rem var(--body); cursor: pointer; }
.pb-media-tab.is-active { color: var(--tint-text, var(--text)); background: var(--tint); border-color: var(--accent); }
.pb-media-count:not(:empty) { min-width: 18px; padding: 1px 5px; color: var(--text); background: var(--surface-2); border-radius: 0; font: 600 0.66rem var(--mono); text-align: center; }
.pb-files.is-media .pb-file.is-active { background: var(--bg); border-color: var(--border); }
@media (hover: hover) { .pb-media-tab:hover { color: var(--gold); border-color: var(--gold); } }
.pb-media-tab:active { color: var(--bg); background: var(--gold); }
.pb-media-tab:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.pb-body.is-media { grid-template-areas: "media out" "media out"; }
.pb-body.is-media > .pb-blocks, .pb-body.is-media > .pb-code { display: none; }
.pb-media { grid-area: media; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #17131f; }
.pb-media[hidden] { display: none; }
.pb-media-add { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; }
.pb-media-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 14px; }
.pb-media-empty { max-width: 520px; margin: 24px auto; color: var(--muted); font-size: 0.9rem; line-height: 1.5; text-align: center; }
.pb-media-empty[hidden] { display: none; }
.pb-media-empty b { color: var(--text); }
.pb-media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.pb-media-item { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 0; }
.pb-media-pic { display: block; width: 100%; height: 110px; object-fit: contain; image-rendering: pixelated; background: repeating-conic-gradient(#2a2438 0% 25%, #221d31 0% 50%) 0 0 / 16px 16px; border-radius: 0; }
.pb-media-pic.is-sound { position: relative; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--accent-strong); background: #221d31; }
.pb-media-play { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; color: #fff; background: var(--fill, var(--accent)); border: 0; border-radius: 50%; cursor: pointer; }
.pb-media-play.is-on { background: var(--gold); color: var(--bg); }
.pb-media-text { display: grid; gap: 2px; min-width: 0; }
.pb-media-name { overflow: hidden; font: 600 0.8rem var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.pb-media-meta { color: var(--muted); font-size: 0.74rem; }
.pb-media-btns { display: flex; flex-wrap: wrap; gap: 4px; }
.pb-media-btn { display: inline-flex; flex: 1 1 0; align-items: center; justify-content: center; min-width: 0; height: 36px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 0; cursor: pointer; }
/* Use in code, in words, on a row of its own over the small buttons. */
.pb-media-use { flex-basis: 100%; gap: 6px; color: var(--text); font: 600 0.8rem var(--body, Inter, system-ui, sans-serif); }
.pb-media-use span { display: inline-flex; }
.pb-media-btn.is-danger { color: #ff8b8b; }
@media (hover: hover) {
  .pb-media-btn:hover, .pb-media-play:hover { color: var(--bg); background: var(--gold); border-color: var(--gold); }
  .pb-media-btn.is-danger:hover { color: #fff; background: #c43c3c; border-color: #c43c3c; }
}
.pb-media-btn:active, .pb-media-play:active { color: var(--bg); background: var(--gold); transform: scale(0.94); }
.pb-media-btn:focus-visible, .pb-media-play:focus-visible { outline: none; box-shadow: var(--focus-ring); }
@media (max-width: 760px) {
  .pb-media-tab { min-height: 38px; }
  .pb-body[data-layout] .pb-media { display: none; }
  .pb-body.is-media[data-layout] { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); grid-template-areas: "main"; }
  .pb-body.is-media[data-pane="blocks"] .pb-media, .pb-body.is-media[data-pane="code"] .pb-media { display: flex; }
  .pb-body.is-media[data-pane] .pb-blocks, .pb-body.is-media[data-pane] .pb-code { display: none; }
  .pb-media-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .pb-media-body { padding: 10px; }
}

/* objects.js: the names an object has, under the text box of an attribute or method block. */
.pb-suggest { position: absolute; top: calc(100% + 4px); left: 0; z-index: 2; display: grid; min-width: 200px; max-width: 280px; max-height: 240px; padding: 4px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 0; box-shadow: 3px 3px 0 var(--edge); font: 0.82rem/1.2 var(--body); scrollbar-width: thin; }
.pb-suggest[hidden] { display: none; }
.pb-suggest-head, .pb-suggest-none { margin: 4px 8px; color: var(--accent-strong); font: 600 0.62rem var(--mono); letter-spacing: 0.08em; text-transform: uppercase; }
.pb-suggest-none { color: var(--muted); text-transform: none; letter-spacing: 0; font: 0.78rem var(--body); }
.pb-suggest-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 30px; padding: 4px 8px; color: var(--text); background: none; border: 0; border-radius: 0; font: inherit; text-align: left; cursor: pointer; }
.pb-suggest-item b { font: 600 0.82rem var(--mono); }
.pb-suggest-item small { color: var(--faint); font-size: 0.68rem; }
.pb-suggest-item.is-on { background: var(--tint); }
@media (hover: hover) { .pb-suggest-item:hover { color: var(--bg); background: var(--gold); } .pb-suggest-item:hover small { color: var(--bg); } }
.pb-suggest-item:active { color: var(--bg); background: var(--gold); }
@media (max-width: 760px) { .pb-suggest-item { min-height: 40px; } .pb-suggest { max-height: 50vh; } }

/* The scripts and Media as a browser's tabs: they stand on the bar's bottom
   edge, side by side; the one shown is the colour of the blocks under it and
   opens into them, with the accent along its top. Square, as everywhere. */
.pb-bar-left { align-self: stretch; padding-bottom: 0; }
.pb-bar-left > :not(.pb-files) { align-self: center; padding-bottom: 5px; }
.pb-files { align-self: stretch; align-items: flex-end; gap: 0; margin-bottom: -1px; }
.pb-file-list { align-self: stretch; align-items: flex-end; gap: 0; }
/* They scroll sideways (a swipe, the wheel) with no bar over them. */
.pb-file-list::-webkit-scrollbar { display: none; }
.pb-file, .pb-media-tab { min-height: 34px; margin-right: -1px; background: #16131f; border: 1px solid var(--border); border-bottom-color: var(--border); }
.pb-file.is-active, .pb-media-tab.is-active, .pb-files.is-media .pb-file.is-active ~ .pb-media-tab.is-active {
  position: relative; z-index: 1; background: #1d1929; border-color: var(--border); border-bottom-color: #1d1929; box-shadow: inset 0 2px 0 var(--accent);
}
.pb-files.is-media .pb-file.is-active { background: #16131f; border-bottom-color: var(--border); box-shadow: none; }
.pb-file.has-error { box-shadow: inset 0 2px 0 #ff5a5a; }
.pb-file-tab { min-height: 32px; padding: 0 14px; }
.pb-file.is-active .pb-file-tab, .pb-media-tab.is-active { color: var(--text); }
.pb-file-add { align-self: flex-end; width: 34px; height: 34px; margin-left: 2px; color: var(--muted); background: none; border: 0; }
.pb-media-tab { gap: 6px; padding: 0 14px; color: var(--muted); }
@media (hover: hover) {
  .pb-file:hover, .pb-media-tab:hover { background: #221d30; border-color: var(--border); border-bottom-color: var(--border); }
  .pb-file.is-active:hover, .pb-media-tab.is-active:hover { background: #1d1929; border-bottom-color: #1d1929; }
}
@media (max-width: 760px) {
  .pb-bar .pb-bar-left { padding: 4px 6px 0; }
  .pb-file, .pb-media-tab { min-height: 40px; }
  .pb-file-tab { min-height: 38px; }
  .pb-file-add { width: 40px; height: 40px; }
}

/* Over the blocks (or the Python or Media pane), the tab shown is the colour
   of what is under it, open into it. The pane's title gives way to them. */
.pb-strip .pb-files, .pb-pane-head.has-tabs .pb-files { align-self: stretch; margin-bottom: -1px; }
.pb-pane-head.has-tabs { align-items: stretch; min-height: 44px; padding-top: 0; padding-bottom: 0; padding-left: 8px; background: #1d1929; }
.pb-pane-head.has-tabs .pb-pane-title { display: none; }
.pb-pane-head.has-tabs .pb-pane-btns { align-self: center; margin-left: auto; }
.pb-strip .pb-file, .pb-strip .pb-media-tab, .has-tabs .pb-file, .has-tabs .pb-media-tab { background: #1d1929; }
.pb-strip .pb-file.is-active, .pb-strip .pb-media-tab.is-active { background: #16131f; border-bottom-color: #16131f; }
#pb-code .has-tabs .pb-file.is-active { background: var(--surface); border-bottom-color: var(--surface); }
#pb-media .has-tabs .pb-media-tab.is-active { background: #17131f; border-bottom-color: #17131f; }
.pb-files.is-media .pb-file.is-active { background: #1d1929; border-bottom-color: var(--border); }
