/* Page-specific pieces on top of rim.css: the TV backdrop on the home screen, the green-bar
   printout on the jams page, and the console with its game window. */

/* ---------- Home: every clip in turn, on the CRT behind the desktop ---------- */
.screen.home { overflow: hidden; background: #000; }
.tv { position: absolute; inset: 0; overflow: hidden; background: #000; }
.tv video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0;
  filter: grayscale(1) sepia(1) saturate(2.4) hue-rotate(-12deg) brightness(0.78) contrast(1.2);
}
.tv video.on { opacity: 1; }
:root[data-colour="on"] .tv video { filter: saturate(1.15) contrast(1.08) brightness(0.85); }
/* Aperture grille and a dark wash on the left so the window sits on something calmer */
.tv::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, rgb(10 6 2 / 0.35), transparent 22%),
    repeating-linear-gradient(90deg, rgb(0 0 0 / 0.28) 0 1px, transparent 1px 3px);
}
:root[data-crt="off"] .tv::after { background: linear-gradient(90deg, rgb(10 6 2 / 0.35), transparent 22%); }
.static { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; opacity: 0; pointer-events: none; z-index: 1; }
.static.on { opacity: 0.9; }

.osd {
  position: absolute; z-index: 3; font-family: var(--f-term); color: #e9ffe0; text-shadow: 0 0 6px rgb(160 255 160 / 0.7), 2px 2px 0 rgb(0 0 0 / 0.7);
  letter-spacing: 0.04em;
}
:root[data-colour="off"] .osd, :root:not([data-colour]) .osd { color: #ffe0a8; text-shadow: 0 0 6px var(--glow), 2px 2px 0 rgb(0 0 0 / 0.7); }
.osd-top { top: 18px; right: 26px; display: grid; justify-items: end; gap: 2px; font-size: 2rem; line-height: 1; }
.osd-top .state { font-size: 1.3rem; }
.osd-bottom {
  right: 26px; bottom: 20px; max-width: min(28rem, 60%); display: grid; justify-items: end; gap: 4px; text-align: right;
  font-size: 1.25rem; line-height: 1.1;
}
.osd-bottom .now { font: 400 9px/1 var(--f-pixel); letter-spacing: 0.12em; text-transform: uppercase; }
.osd-bottom .np-title { font: 400 clamp(1rem, 2.4vw, 1.5rem)/1.15 var(--f-pixel); color: inherit; text-decoration: none; }
.osd-bottom .np-title:hover { text-decoration: underline; }
.osd-bottom .np-title::after { content: " \25B8"; }
.osd-btn {
  margin-top: 6px; font: 400 9px/1 var(--f-pixel); text-transform: uppercase; letter-spacing: 0.08em; color: inherit;
  background: rgb(0 0 0 / 0.45); border: 1px solid currentColor; padding: 5px 8px 4px; cursor: pointer; text-shadow: inherit;
}
.osd-btn:hover { background: currentColor; }
.osd-btn:hover span { color: #000; text-shadow: none; }

/* Only desktop icons sit over the picture; the name lives on the badge above the screen. */
.home-desk {
  position: relative; z-index: 2; height: 100%; overflow-y: auto;
  display: grid; grid-template-columns: max-content; align-content: start;
  padding: 1.5rem clamp(16px, 3vw, 2.25rem);
}
.home-desk .icons { display: grid; position: static; gap: 1.3rem; }
.home-desk .icon svg { width: 42px; height: 42px; }
.home-desk .icon span { background: rgb(10 6 2 / 0.72); padding: 2px 4px; }
.home-desk .icon:hover span, .home-desk .icon:focus-visible span { background: var(--title); }

/* Not enough room beside the window: the desktop stops short and the caption gets the band under it. */
@media (max-width: 1279px) {
  .home-desk { height: calc(100% - 6.5rem); }
  .osd-bottom {
    left: clamp(16px, 3vw, 2.25rem); right: clamp(16px, 3vw, 2.25rem); bottom: 14px; max-width: none;
    grid-template-columns: minmax(0, 1fr) auto; justify-items: start; text-align: left; gap: 2px 14px; align-items: end;
  }
  .osd-bottom .now, .osd-bottom .np-title, .osd-bottom .np-meta { grid-column: 1; }
  .osd-btn { grid-column: 2; grid-row: 1 / span 3; align-self: end; }
}
@media (max-width: 760px) {
  .home-desk { padding-top: 0.9rem; }
  .osd-top { display: none; }
  .osd-bottom .now { display: none; }
}

/* ---------- Jams: a green-bar printout feeding out of the window ---------- */
.printer {
  position: relative; display: grid; padding: 0 0 1rem; background: var(--term);
  border: 1px solid var(--edge); box-shadow: inset 2px 2px 0 #000, inset 0 0 22px rgb(0 0 0 / 0.6);
}
.printer-head {
  display: flex; justify-content: space-between; gap: 1rem; padding: 10px 14px; font: 400 9px/1 var(--f-pixel);
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--ph-dim); text-shadow: 0 0 0.3em var(--glow);
}
.printer-head .busy::before { content: "\25CF "; color: var(--ph); }
.slot-bar { height: 8px; margin: 0 10px; background: #050302; border-radius: 2px; box-shadow: inset 0 2px 3px #000, 0 1px 0 #3a332a; }
.paper {
  --band: 42px; --ink: #2b2720;
  position: relative; margin: -4px 22px 0; padding: 21px 48px 42px;
  background: repeating-linear-gradient(to bottom, #f3efe2 0 var(--band), #dfe9d2 var(--band) calc(var(--band) * 2));
  color: var(--ink); font-family: var(--f-term); font-size: 1.32rem; line-height: 21px;
  box-shadow: 0 6px 14px rgb(0 0 0 / 0.5);
}
:root[data-plain="on"] .paper { font-family: var(--f-plain); font-size: 0.98rem; }
/* Tractor-feed strips: holes punched every half band, with a perforation line inside them */
.paper::before, .paper::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 30px;
  background: radial-gradient(circle, #1c1814 0 5px, #9b968a 5.5px 6.5px, transparent 7px) 50% 10px / 30px 21px repeat-y;
}
.paper::before { left: 0; border-right: 1px dashed #a9a597; }
.paper::after { right: 0; border-left: 1px dashed #a9a597; }
.paper a { color: var(--ink); }
.paper a:hover { background: var(--ink); color: #f3efe2; text-decoration: none; }
.paper h1, .paper h2 { margin: 0; font-weight: 400; }
.paper h1 { font: 400 1.6rem/42px var(--f-pixel); letter-spacing: 0.04em; }
.paper h2 { font: 400 1.05rem/21px var(--f-pixel); }
.paper p { margin: 0; max-width: 64ch; }
.paper .rule-print { overflow: hidden; white-space: nowrap; contain: inline-size; }
.paper .rule-print::before { content: "================================================================================================================"; }
.print-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0 1rem; }
.pl + .pl { margin-top: 21px; }
.jam { scroll-margin-top: 16px; display: grid; grid-template-columns: minmax(0, 1fr) 13rem; gap: 0 1.5rem; }
.jam dl { margin: 0; display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); }
.jam dt { text-transform: uppercase; white-space: nowrap; overflow: hidden; }
.jam dt::after { content: " ................"; }
.jam dd { margin: 0; }
.jam .ph { color: #8a5a1c; }
.jam-shot {
  align-self: start; aspect-ratio: 16 / 9; margin-top: 21px; display: grid; place-items: center; text-align: center;
  border: 2px dashed var(--ink); font: 400 9px/1.4 var(--f-pixel); text-transform: uppercase; letter-spacing: 0.08em;
  background: repeating-linear-gradient(45deg, transparent 0 6px, rgb(43 39 32 / 0.08) 6px 8px);
}
.jam-shot img { width: 100%; height: 100%; object-fit: cover; }
.tear { height: 14px; margin: 0 22px; background: linear-gradient(135deg, transparent 50%, #f3efe2 50%) 0 0 / 14px 14px repeat-x, linear-gradient(45deg, #f3efe2 50%, transparent 50%) 0 0 / 14px 14px repeat-x; transform: scaleY(-1); }

@media (prefers-reduced-motion: no-preference) {
  .printing .pl { clip-path: inset(0 100% 0 0); }
  .printing .pl.printed { animation: print-in 0.45s steps(18) both; }
  @keyframes print-in { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
}

@media (max-width: 760px) {
  .jam { grid-template-columns: minmax(0, 1fr); }
  .jam-shot { max-width: 18rem; }
}
@media (max-width: 560px) {
  .paper { margin: -4px 8px 0; padding: 21px 30px 42px; font-size: 1.2rem; }
  .paper::before, .paper::after { width: 20px; background-size: 20px 21px; }
  .jam dl { grid-template-columns: minmax(0, 1fr); }
  .jam dt::after { content: ""; }
  .jam dt { margin-top: 0; }
  .tear { margin: 0 8px; }
}

/* ---------- Console: one terminal window filling the screen; a game opens in a window over it ---------- */
.screen.console-screen { overflow: hidden; display: grid; padding: clamp(8px, 2.4vw, 1.75rem); }
.console-win { grid-template-rows: auto minmax(0, 1fr); min-height: 0; width: 100%; max-width: 60rem; margin: 0 auto; }
.console-win .term { align-content: start; gap: 0; overflow-y: auto; cursor: text; }
.out { display: grid; }
.out .ln { min-height: 1lh; white-space: pre-wrap; overflow-wrap: anywhere; }
.out .echo { color: var(--ph-dim); }
.out .hd, .out .err { color: var(--odds); }
.cmdline { display: flex; align-items: baseline; gap: 0.4em; }
.cmdline label { flex: none; color: var(--ph-dim); }
.cmdline input {
  flex: 1; min-width: 0; padding: 0; border: 0; outline: 0; background: transparent;
  color: var(--ph); font: inherit; text-shadow: inherit; caret-color: var(--ph);
}
/* The game list: each row is a button, inverted on hover like the site's links */
.games { display: grid; margin: 0.25rem 0 0.4rem; }
.term .game {
  display: grid; grid-template-columns: 2ch 10ch minmax(0, 1fr); gap: 0 1ch; padding: 0.2rem 0.35rem; text-align: left;
  font: inherit; color: inherit; text-shadow: inherit; background: none; border: 0; cursor: pointer;
}
.game .n, .game .f { color: var(--odds); }
.game .d { display: block; color: var(--ph-dim); }
.term .game:hover, .term .game:focus-visible { background: var(--ph); color: var(--term); text-shadow: none; }
.game:hover > span, .game:focus-visible > span, .game:hover .d, .game:focus-visible .d { color: inherit; }

.game-win { position: absolute; inset: 0; z-index: 5; grid-template-rows: auto minmax(0, 1fr); }
.game-win iframe { display: block; width: 100%; height: 100%; border: 1px solid var(--edge); background: #000; }
.tb-btn {
  display: grid; place-items: center; flex: none; width: 17px; height: 15px; padding: 0; cursor: pointer; color: var(--edge);
  background: var(--win); border: 1px solid var(--edge); box-shadow: inset 1px 1px 0 var(--win-hi), inset -1px -1px 0 var(--win-lo);
}
.tb-btn svg { width: 8px; height: 7px; fill: currentColor; shape-rendering: crispEdges; }
.tb-btn:active { box-shadow: inset 1px 1px 0 var(--win-lo), inset -1px -1px 0 var(--win-hi); }
.tb-btn + .tb-btn { margin-left: -6px; }
/* While a game is open (html.playing) on a shorter screen, the badge and control deck fold away so the CRT
   gets their room. On a very short one, a phone on its side, the game window takes the whole page. */
@media (max-height: 820px) {
  .playing .plate, .playing .controls { display: none; }
  .playing .terminal { grid-template-rows: minmax(0, 1fr); }
}
@media (max-height: 480px) {
  .playing .game-win { position: fixed; inset: 0; z-index: 100; }
}

@media (max-width: 560px) {
  .screen.console-screen { padding: 6px; }
  .term .game { grid-template-columns: 2ch minmax(0, 1fr); }
  .game .f { display: none; }
}
