/* SPDX-License-Identifier: GPL-3.0-or-later */
/* NT-Toaster on the web: three columns (inputs, the Switcher, outputs); a phone in portrait stacks them. */
:root {
  --bg: #161618; --fg: #d8d8dc; --dim: #8a8a90; --amber: #ecd450; --green: #78dc78; --red: #e04848;
  --tw: 200px;          /* input tile width (16:9) */
  --mw: 240px;          /* monitor width (4:3) */
  --gap: 8px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 13px/1.3 -apple-system, "Segoe UI", system-ui, sans-serif; overflow: hidden; overscroll-behavior: none; }
button { font: inherit; }
#app {
  display: flex; flex-direction: row; align-items: flex-start; gap: var(--gap);
  height: 100%; width: 100%;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  touch-action: none; user-select: none; -webkit-user-select: none;
}
#inputs { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; width: var(--tw); }
.tile { position: relative; width: var(--tw); aspect-ratio: 16 / 9; background: #000; border: 2px solid #46464c; border-radius: 3px; overflow: hidden; }
.tile video, .tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.tile img { display: none; }
.tile.still img { display: block; } .tile.still video { display: none; }
.tile.on-program { border-color: var(--red); }
.tile.stalled::after { content: "B6  tap"; position: absolute; left: 50%; top: 55%; transform: translate(-50%, -50%); background: rgba(0,0,0,.7); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 4px; pointer-events: none; }
.tile.on-preview { border-color: var(--green); }
.tile .label { position: absolute; left: 0; top: 0; right: 0; height: 15px; background: rgba(0,0,0,.75); color: var(--amber); font-size: 10px; font-weight: 600; line-height: 15px; padding: 0 4px; white-space: nowrap; overflow: hidden; display: flex; gap: 5px; }
.tile .label .name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }
.tile .label .src { flex: 0 0 auto; background: none; border: 0; color: #fff; padding: 0 4px; line-height: 15px; cursor: pointer; }
#panelbox { flex: 1 1 auto; min-width: 0; max-width: 662px; }
#panel { display: block; width: 100%; height: auto; aspect-ratio: 662 / 510; max-height: calc(100vh - 20px); cursor: pointer; }
#outputs { display: flex; flex-direction: column; gap: 4px; flex: 0 0 auto; width: var(--mw); }
.mon .title { font-size: 10px; font-weight: 700; letter-spacing: .5px; color: var(--amber); }
.mon.preview .title { color: var(--green); }
.mon canvas { display: block; width: var(--mw); height: auto; aspect-ratio: 4 / 3; background: #000; border: 2px solid #46464c; border-radius: 3px; }
.mon.preview canvas { width: calc(var(--mw) * .86); }
#status { font-size: 10px; color: var(--dim); line-height: 1.35; margin-top: 4px; min-height: 2.7em; }
#status1 { color: var(--fg); }
#buttons { display: flex; gap: 6px; margin-top: 4px; }
#buttons button { background: #3a3a40; color: #fff; border: 0; border-radius: 5px; padding: 5px 9px; font-size: 10px; font-weight: 700; cursor: pointer; }
#buttons button.off { color: #8a8a90; text-decoration: line-through; }

/* overlays */
#splash, #sheet, #helpbox { position: fixed; inset: 0; background: rgba(0,0,0,.72); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 12px; }
#splash .card, #sheet .card, #helpbox .card { background: #2c2c30; border-radius: 12px; padding: 18px 22px; max-width: 520px; max-height: 100%; overflow: auto; box-shadow: 0 8px 30px rgba(0,0,0,.6); }
#splash h1 { margin: 0 0 8px; font-size: 22px; color: var(--amber); }
#splash h1::after { content: ""; display: block; width: 120px; height: 3px; background: linear-gradient(90deg, var(--red), var(--amber), var(--green)); margin-top: 6px; }
#splash p, #helpbox p { margin: 6px 0; }
#splash .small, #helpbox .small { color: var(--dim); font-size: 11px; }
#start { display: block; width: 100%; margin: 12px 0 6px; padding: 12px; font-size: 16px; font-weight: 700; background: var(--amber); color: #000; border: 0; border-radius: 8px; cursor: pointer; }
#start:disabled { background: #55524a; color: #999; }
#sheet h2, #helpbox h2 { margin: 0 0 8px; font-size: 16px; }
#sheetlist { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; max-height: 60vh; overflow: auto; }
#sheetlist button, .close { display: block; width: 100%; text-align: left; background: #3a3a40; color: #fff; border: 0; border-radius: 6px; padding: 9px 12px; cursor: pointer; }
#sheetlist button:active { background: #55555c; }
.sheethead { color: var(--dim); font-size: 11px; font-weight: 700; letter-spacing: .5px; margin: 6px 0 0; text-transform: uppercase; }
#sheetlist button.current { outline: 2px solid var(--amber); }
.close { background: #27272b; margin-top: 4px; }
#helpbox code { background: #1c1c20; padding: 0 4px; border-radius: 3px; }
#helpbox a { color: var(--amber); }
#tip { position: fixed; z-index: 20; max-width: 280px; background: #f4f0d8; color: #111; border: 1px solid #000; border-radius: 3px; box-shadow: 2px 3px 8px rgba(0,0,0,.5); padding: 5px 8px; font-size: 12px; line-height: 1.35; white-space: pre-line; pointer-events: none; }
[hidden] { display: none !important; }

/* a big screen: the panel at twice its size, whole pixels (as the Windows shell's 2x) */
@media (min-width: 1900px) and (min-height: 1100px) {
  :root { --tw: 320px; --mw: 400px; }
  #panelbox { max-width: 1324px; }
  #panel { image-rendering: pixelated; }
}
/* a phone in landscape: smaller tiles and monitors, the panel takes what is left (about 72% of 662 on an iPhone 15 Pro) */
@media (max-height: 500px) {
  :root { --tw: 120px; --mw: 150px; --gap: 6px; }
  .tile .label { height: 13px; font-size: 9px; line-height: 13px; }
  #inputs { gap: 4px; }
  #status { font-size: 9px; min-height: 0; }
  #buttons button { padding: 4px 7px; font-size: 9px; }
}
@media (max-height: 400px) {
  :root { --tw: 112px; --mw: 140px; }
}
/* a phone in portrait: three rows */
@media (orientation: portrait) and (max-width: 700px) {
  html, body { overflow: auto; }
  #app { flex-direction: column; align-items: center; height: auto; min-height: 100%; }
  #inputs { flex-direction: row; width: 100%; justify-content: space-between; }
  :root { --tw: calc((100vw - 40px) / 4); --mw: 46vw; }
  #panelbox { width: 100%; max-width: 100%; flex: 0 0 auto; }
  #panel { max-height: none; }
  #outputs { flex-direction: row; flex-wrap: wrap; width: 100%; justify-content: space-between; align-items: flex-start; }
  #status { width: 100%; }
}
