/* Doors — terminal page. The screen takes its colours, font and size from
   CSS variables that app.js sets from the chosen computer and settings. */
:root {
  --fg: #33ff66; --bg: #001b06; --border: #000;
  --font: ui-monospace, Menlo, Consolas, monospace;
  --fs: 18px; --lh: 1.3; --w: 80ch; --glow: 0.55;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: #0b0b0c; }
body {
  display: flex; flex-direction: column; height: 100vh; height: 100dvh; height: var(--vvh, 100dvh); overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; color: #d6d9df;
}

/* ---- top bar ---- */
#bar {
  flex: none; display: flex; align-items: center; gap: .4rem;
  padding: .3rem .6rem; background: #17181b; border-bottom: 1px solid #2a2c31; font-size: .85rem;
}
.brand { font-weight: 700; letter-spacing: .18em; color: #fff; }
.bar-game { color: #8f95a3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.spacer { flex: 1; }
#bar button {
  font: inherit; color: #d6d9df; background: #23252a; border: 1px solid #353840;
  border-radius: 6px; padding: .3rem .6rem; cursor: pointer; white-space: nowrap;
}
#bar button[hidden] { display: none; }
#bar button:hover { background: #2e3138; }
#bar button:focus-visible, dialog button:focus-visible, dialog select:focus-visible, dialog input:focus-visible {
  outline: 2px solid #6aa9ff; outline-offset: 1px;
}
@media (max-width: 480px) {
  #bar { gap: .25rem; padding: .3rem .35rem; }
  #bar button { padding: .3rem .45rem; }
  .bar-game { display: none; }
}

/* ---- the monitor ---- */
#bezel {
  flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center;
  background: var(--border); overflow: hidden;
}
#screen {
  position: relative; width: 100%; height: 100%; background: var(--bg); color: var(--fg);
  font-family: var(--font); font-size: var(--fs); line-height: var(--lh);
  display: flex; justify-content: center; overflow: hidden;
  font-variant-ligatures: none; -webkit-font-smoothing: antialiased;
}
body.crt #screen { box-shadow: 0 0 0 1px rgba(0,0,0,.35); }
body.curve #screen { border-radius: 1.2vmin; }
body.curve.crt #screen { border-radius: 2.4vmin; }
#inner { width: var(--w); max-width: 100%; height: 100%; display: flex; flex-direction: column; min-width: 0; }
body.upper #inner { text-transform: uppercase; }
body.glow #inner { text-shadow: 0 0 .28em color-mix(in srgb, var(--fg) calc(var(--glow) * 100%), transparent); }

#status {
  flex: none; display: flex; justify-content: space-between; gap: 1ch;
  background: var(--fg); color: var(--bg); white-space: pre; overflow: hidden; text-shadow: none;
}
#status[hidden] { display: none; }
#statusL { overflow: hidden; text-overflow: clip; min-width: 0; }
#statusR { flex: none; }

#out {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal;
  padding: .5em 0 3.4rem; outline: none;
  scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--fg) 45%, transparent) transparent;
}
#out ::selection, #out::selection { background: var(--fg); color: var(--bg); text-shadow: none; }
#line[hidden] { display: none; }
#cursor { background: var(--fg); color: var(--bg); text-shadow: none; animation: blink 1.06s steps(1) infinite; }
@keyframes blink { 50% { background: transparent; color: inherit; } }
body.nofocus #cursor { animation: none; background: transparent; color: inherit; outline: 1px solid var(--fg); outline-offset: -1px; }

/* glass: scanlines and a soft vignette, drawn over the text */
#screen::before, #screen::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2; }
body.scan #screen::before {
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0, rgba(0,0,0,0) 2px, rgba(0,0,0,var(--scan, .2)) 2px, rgba(0,0,0,var(--scan, .2)) 3px);
}
body.curve #screen::after {
  background: radial-gradient(ellipse at center, rgba(255,255,255,.035) 0, rgba(0,0,0,0) 55%, rgba(0,0,0,.34) 100%);
}

#kbd {
  position: absolute; left: 0; bottom: 0; width: 2px; height: 2px; opacity: 0; border: 0; padding: 0;
  font-size: 16px; background: transparent; color: transparent; caret-color: transparent;
}
#meas { position: absolute; left: -9999px; top: 0; visibility: hidden; white-space: pre; font-size: 100px; line-height: 1; }

@media (prefers-reduced-motion: reduce) { #cursor { animation: none; } }

/* ---- dialogs (plain modern UI, on purpose: they must stay readable) ---- */
dialog {
  border: 1px solid #3a3d45; border-radius: 12px; background: #1b1c20; color: #dfe2e8;
  padding: 0; width: min(34rem, calc(100vw - 1.5rem)); max-height: calc(100dvh - 1.5rem);
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog form { padding: 1.1rem 1.2rem; display: flex; flex-direction: column; gap: .8rem; }
dialog h2 { margin: 0; font-size: 1.15rem; }
dialog h3 { margin: .3rem 0 0; font-size: .95rem; color: #fff; }
dialog p, dialog ul { margin: 0; font-size: .9rem; line-height: 1.5; }
dialog ul { padding-left: 1.2rem; }
dialog a { color: #8cc0ff; }
dialog label { display: flex; flex-direction: column; gap: .25rem; font-size: .82rem; color: #a9aeba; flex: 1; min-width: 0; }
dialog label.inline, .checks label { flex-direction: row; align-items: center; gap: .45rem; flex: none; }
dialog select, dialog input[type="text"] {
  font: inherit; font-size: .92rem; color: #eef0f4; background: #26282e; border: 1px solid #40434c;
  border-radius: 6px; padding: .4rem .5rem; min-width: 0;
}
dialog input[type="color"] { width: 2.4rem; height: 1.8rem; padding: 0; border: 1px solid #40434c; border-radius: 4px; background: none; }
dialog input[type="range"] { width: 100%; }
dialog fieldset { border: 1px solid #33363d; border-radius: 8px; padding: .6rem .7rem; margin: 0; display: flex; flex-direction: column; gap: .55rem; }
dialog legend { font-size: .8rem; color: #a9aeba; padding: 0 .3rem; }
.row { display: flex; gap: .8rem; flex-wrap: wrap; align-items: flex-end; }
.checks { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .88rem; }
.checks label { color: #dfe2e8; font-size: .88rem; }
.note { color: #9197a4; font-size: .82rem !important; }
.note:empty { display: none; }
.actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .2rem; }
dialog button, .filebtn {
  font: inherit; font-size: .88rem; color: #e6e8ee; background: #2b2e35; border: 1px solid #454953;
  border-radius: 6px; padding: .4rem .8rem; cursor: pointer;
}
dialog button:hover, .filebtn:hover { background: #363a43; }
dialog button.primary { background: #2f6fb8; border-color: #2f6fb8; color: #fff; }
dialog button.quiet { background: transparent; }
dialog button.danger { color: #ff9c9c; }
.filebtn { flex: none !important; flex-direction: row !important; color: #e6e8ee !important; align-items: center; }
.filebtn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
kbd { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85em; background: #2b2e35; border-radius: 4px; padding: .05em .35em; }

.swatches { display: flex; gap: .4rem; flex-wrap: wrap; }
.swatches button { display: flex; align-items: center; gap: .4rem; padding: .3rem .55rem; }
.swatches button[aria-pressed="true"] { border-color: #6aa9ff; background: #233247; }
.swatches i { width: .9rem; height: .9rem; border-radius: 50%; border: 1px solid rgba(255,255,255,.35); }

#saveList { display: flex; flex-direction: column; gap: .5rem; max-height: 40vh; overflow-y: auto; }
#saveList h3 { margin-top: .2rem; }
.save-row { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.save-row .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-row .dt { color: #9197a4; font-size: .78rem; white-space: nowrap; }
.save-row button { padding: .25rem .55rem; font-size: .8rem; }

/* ---- Display dialog: the carousel of computers ---- */
#dlgDisplay { width: min(44rem, calc(100vw - 1.5rem)); }
#dlgDisplay h2 { text-align: center; }
.carousel { display: flex; align-items: center; gap: .3rem; margin: 0 -.5rem; }
.car-track {
  flex: 1; min-width: 0; display: flex; gap: .7rem; overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; padding: .7rem calc(50% - 6.6rem); scrollbar-width: none; outline: none; border-radius: 10px;
}
.car-track::-webkit-scrollbar { display: none; }
.car-track:focus-visible { box-shadow: 0 0 0 2px #6aa9ff; }
dialog button.car-item {
  flex: 0 0 13.2rem; scroll-snap-align: center; display: flex; flex-direction: column; align-items: center; gap: .3rem;
  padding: .7rem .6rem .5rem; border-radius: 12px; background: #24262b; border: 1px solid #353840;
  opacity: .45; transform: scale(.86); transition: opacity .2s, transform .2s, border-color .2s, background .2s;
}
dialog button.car-item:hover { opacity: .8; background: #2a2c32; }
dialog button.car-item[aria-selected="true"] { opacity: 1; transform: none; border-color: #6aa9ff; background: #262b35; }
.car-item svg { width: 100%; height: auto; display: block; }
.car-cap { font-size: .72rem; color: #9197a4; letter-spacing: .04em; text-transform: uppercase; }
dialog button.car-arrow {
  flex: none; width: 2.4rem; height: 2.4rem; border-radius: 50%; padding: 0; font-size: 1.5rem; line-height: 1;
  display: grid; place-items: center;
}
dialog p.car-name { text-align: center; font-size: 1.1rem; font-weight: 600; color: #fff; margin-top: -.2rem; }
dialog p.car-note { text-align: center; margin-top: -.5rem; min-height: 1.2em; }
#optWrap { border: 1px solid #33363d; border-radius: 8px; }
#optWrap summary {
  cursor: pointer; padding: .55rem .8rem; font-size: .9rem; color: #e6e8ee; display: flex; align-items: baseline; gap: .6rem; list-style: none;
}
#optWrap summary::-webkit-details-marker { display: none; }
#optWrap summary::before { content: "\25B8"; color: #9197a4; }
#optWrap[open] summary::before { content: "\25BE"; }
#optWrap summary small { color: #9197a4; font-size: .78rem; }
#optWrap summary:focus-visible { outline: 2px solid #6aa9ff; outline-offset: 1px; border-radius: 8px; }
.opt-body { padding: .2rem .8rem .8rem; display: flex; flex-direction: column; gap: .8rem; }
@media (max-width: 520px) {
  .car-track { padding-left: calc(50% - 5.4rem); padding-right: calc(50% - 5.4rem); }
  dialog button.car-item { flex-basis: 10.8rem; }
  dialog button.car-arrow { display: none; }
}
@media (prefers-reduced-motion: reduce) { dialog button.car-item { transition: none; } }

/* photographs in the carousel */
.car-photo { display: block; width: 100%; aspect-ratio: 4 / 3; background: #fff; border-radius: 8px; overflow: hidden; }
.car-photo img { width: 100%; height: 100%; object-fit: contain; display: block; }
dialog p.car-credit { text-align: center; margin-top: -.55rem; font-size: .72rem !important; min-height: 1.1em; }
dialog p.car-credit:empty { display: block; }
dialog p.car-credit a { color: #9197a4; }

/* the bar can scroll sideways on very narrow phones rather than wrap or clip */
#bar { overflow-x: auto; scrollbar-width: none; }
#bar::-webkit-scrollbar { display: none; }
#bar button, .brand { flex: none; }
@media (max-width: 480px) { #bar { font-size: .78rem; gap: .2rem; } #bar button { padding: .3rem .38rem; } .brand { letter-spacing: .06em; } .spacer { min-width: 0; } }

/* phone held upright: screen sits at the top, 4:3, with room below for the keyboard */
body.tall #bezel { align-items: flex-start; }
