/* ---------- reader ---------- */
.rd { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; overflow: hidden;
  --gut: 14px; --bz: 10px; --chin: 62px; --fx: 1600 / 2443;
  --sw: min(calc(100vw - 2 * var(--bz) - 2 * var(--gut)), calc((100vh - var(--bz) - var(--chin) - 2 * var(--gut)) * 1600 / 2443));
  background: radial-gradient(ellipse 70% 60% at 50% 45%, rgba(94, 242, 240, .07), transparent 70%), #020303;
  opacity: 0; transition: opacity .3s ease; }
@supports (height: 100dvh) { .rd { --sw: min(calc(100vw - 2 * var(--bz) - 2 * var(--gut)), calc((100dvh - var(--bz) - var(--chin) - 2 * var(--gut)) * 1600 / 2443)); } }
@media (min-width: 700px) and (min-height: 560px) { .rd { --gut: 22px; --bz: 20px; --chin: 70px; } }
.rd[hidden] { display: none; }
.rd.on { opacity: 1; }
.rd-mon { position: relative; width: calc(var(--sw) + 2 * var(--bz)); padding: var(--bz) var(--bz) 0; border-radius: 22px 22px 16px 16px;
  background: linear-gradient(180deg, #1a2022, #0e1213 60%, #0a0d0e); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), inset 0 -2px 6px rgba(0, 0, 0, .6), 0 30px 80px rgba(0, 0, 0, .7);
  transform: translateY(14px) scale(.985); transition: transform .45s cubic-bezier(.2, .8, .2, 1); }
.rd.on .rd-mon { transform: none; }
.rd-mon::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; box-shadow: 0 0 0 1px rgba(255, 255, 255, .03); }
.rd.lit .rd-mon { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), inset 0 -2px 6px rgba(0, 0, 0, .6), 0 30px 80px rgba(0, 0, 0, .7), 0 0 120px rgba(94, 242, 240, .10); }

/* the screen */
.rd-scr { position: relative; width: var(--sw); aspect-ratio: var(--fx); border-radius: 14px / 16px; overflow: hidden; background: #000;
  box-shadow: inset 0 0 0 2px #050606, 0 0 0 3px #070909; touch-action: none; user-select: none; -webkit-user-select: none; }
.rd-scr::after { content: ""; position: absolute; inset: 0; z-index: 6; pointer-events: none; border-radius: inherit;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .14) 0 1px, transparent 1px 3px), radial-gradient(ellipse 85% 80% at 50% 50%, transparent 62%, rgba(0, 0, 0, .55) 100%);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, .7); }
.rd.zoomed .rd-scr::after { background: radial-gradient(ellipse 85% 80% at 50% 50%, transparent 62%, rgba(0, 0, 0, .5) 100%); }
.rd-glass { position: absolute; inset: 0; z-index: 7; pointer-events: none; border-radius: inherit;
  background: linear-gradient(160deg, rgba(255, 255, 255, .06), transparent 30%); }

/* power on / off: the picture opens out of a bright line, and closes back into one */
.rd-tube { position: absolute; inset: 0; transform-origin: 50% 50%; }
.rd.boot .rd-tube { animation: rd-on .55s cubic-bezier(.2, .7, .2, 1) both; }
.rd.off .rd-tube { animation: rd-off .42s ease-in both; }
@keyframes rd-on { 0% { transform: scale(.9, .004); filter: brightness(6); } 45% { transform: scale(1, .006); filter: brightness(5); } 100% { transform: none; filter: none; } }
@keyframes rd-off { 0% { transform: none; filter: none; } 55% { transform: scale(1, .006); filter: brightness(4); } 100% { transform: scale(0, .004); filter: brightness(8); } }

/* page stage */
.rd-stage { position: absolute; inset: 0; overflow: hidden; }
.rd-zoom { position: absolute; inset: 0; transform-origin: 0 0; will-change: transform; }
.rd-pg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; opacity: 0; -webkit-user-drag: none; }
.rd-pg.show { opacity: 1; }
.rd.zoomed .rd-stage { cursor: grab; }
.rd.zoomed.drag .rd-stage { cursor: grabbing; }

/* boot log */
.rd-boot { position: absolute; inset: 0; z-index: 3; padding: 9% 8%; background: #000; font-family: var(--display); color: var(--cyan);
  font-size: clamp(14px, calc(var(--sw) * .044), 28px); line-height: 1.2; text-shadow: 0 0 10px rgba(94, 242, 240, .45); white-space: pre-wrap; overflow: hidden; }
.rd-boot[hidden] { display: none; }
.rd-boot .d { color: var(--dim); text-shadow: none; }
.rd-boot .w { color: var(--white); }
.rd-boot .bar { display: inline-block; vertical-align: -.1em; width: 9em; max-width: 60%; height: .7em; border: 1px solid rgba(94, 242, 240, .6); position: relative; }
.rd-boot .bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--cyan); box-shadow: 0 0 10px rgba(94, 242, 240, .6); transition: width .2s; }

/* locked page */
.rd-lock { position: absolute; inset: 0; z-index: 2; display: grid; align-content: center; gap: .55em; padding: 8%; background: #000;
  font-family: var(--display); font-size: clamp(16px, calc(var(--sw) * .056), 32px); line-height: 1.1; color: var(--cyan); text-shadow: 0 0 10px rgba(94, 242, 240, .4); }
.rd-lock[hidden] { display: none; }
.rd-lock p { margin: 0; }
.rd-lock .d { color: var(--dim); text-shadow: none; }
.rd-lock .err { color: #FF6B6B; text-shadow: 0 0 10px rgba(255, 107, 107, .4); }
.rd-lock .big { font-size: 2.1em; line-height: 1; color: var(--white); font-variant-numeric: tabular-nums; }
.rd-lock a { color: var(--cyan); }

/* static between pages */
.rd-static { position: absolute; inset: 0; z-index: 4; width: 100%; height: 100%; image-rendering: pixelated; opacity: 0; pointer-events: none; mix-blend-mode: screen; }

/* ls view: every page as a thumbnail */
.rd-ls { position: absolute; inset: 0; z-index: 5; overflow-y: auto; overscroll-behavior: contain; padding: 6% 5% 8%; background: #000; touch-action: pan-y;
  font-family: var(--display); color: var(--cyan); }
.rd-ls[hidden] { display: none; }
.rd-ls h3 { margin: 0 0 .6em; font-weight: 400; font-size: clamp(16px, calc(var(--sw) * .05), 28px); }
.rd-ls ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 700px) { .rd-ls ol { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.rd-ls button { display: grid; gap: 4px; width: 100%; padding: 4px; border: 1px solid var(--line); background: #050808; color: var(--dim); cursor: pointer; font-family: var(--display); font-size: 16px; line-height: 1; text-align: left; }
.rd-ls button img, .rd-ls .lk { display: block; width: 100%; height: auto; aspect-ratio: 1600 / 2443; object-fit: cover; background: #020303; }
.rd-ls .lk { display: grid; place-items: center; color: #3c5558; font-size: 15px; text-align: center; padding: 4px; border: 1px dashed #15262a; }
.rd-ls button:hover, .rd-ls button:focus-visible { border-color: var(--cyan); color: var(--cyan); }
.rd-ls button[aria-current="page"] { border-color: var(--cyan); color: var(--cyan); box-shadow: 0 0 14px rgba(94, 242, 240, .25); }

/* click zones: left third back, the rest forward */
.rd-hit { position: absolute; top: 0; bottom: 0; z-index: 1; border: 0; padding: 0; background: transparent; cursor: pointer; }
.rd-hit.prev { left: 0; width: 33%; cursor: w-resize; }
.rd-hit.next { right: 0; width: 67%; cursor: e-resize; }
.rd-hit:focus-visible { outline: none; }
.rd.zoomed .rd-hit, .rd.booting .rd-hit { display: none; }

/* the chin: brand, page counter, controls, power light */
.rd-chin { container-type: inline-size; height: var(--chin); display: flex; align-items: center; gap: 6px; padding: 0 2px; }
.rd-brand { flex: none; display: none; font-family: var(--display); font-size: 17px; letter-spacing: .16em; color: #3e5558; text-shadow: 0 1px 0 rgba(0, 0, 0, .8); }
@media (min-width: 700px) and (min-height: 560px) { .rd-brand { display: block; } }
.rd-count { flex: 1 1 auto; min-width: 0; font-family: var(--display); font-size: 22px; line-height: 1; color: var(--cyan); text-shadow: 0 0 10px rgba(94, 242, 240, .4);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; font-variant-numeric: tabular-nums; }
.rd-keys { flex: none; display: flex; gap: 5px; }
.rd-k { width: 42px; height: 40px; display: grid; place-items: center; padding: 0; border-radius: 6px; cursor: pointer; color: #9fbcbe;
  background: linear-gradient(180deg, #1d2427, #121718); border: 1px solid #262f32; box-shadow: 0 2px 0 #050707, inset 0 1px 0 rgba(255, 255, 255, .05); }
.rd-k svg { width: 20px; height: 20px; }
.rd-k:hover, .rd-k:focus-visible { color: var(--cyan); border-color: rgba(94, 242, 240, .5); }
.rd-k:active { transform: translateY(1px); box-shadow: 0 1px 0 #050707; }
.rd-k:disabled { opacity: .35; cursor: default; }
.rd-k[aria-pressed="true"] { color: var(--cyan); border-color: rgba(94, 242, 240, .6); }
.rd-k.pw { color: #6d7f81; }
.rd-k.pw:hover, .rd-k.pw:focus-visible { color: #FF6B6B; border-color: rgba(255, 107, 107, .5); }
.rd-k[hidden] { display: none; }
.rd-led { flex: none; width: 7px; height: 7px; margin: 0 4px 0 2px; border-radius: 50%; background: #1b2a22; }
.rd.lit .rd-led { background: #4BF07A; box-shadow: 0 0 8px #4BF07A; }
@media (max-width: 380px) { .rd-k { width: 38px; } .rd-count { font-size: 19px; } }

/* full screen: no room, just the monitor */
.rd:fullscreen { background: #000; }

@media (prefers-reduced-motion: reduce) {
  .rd, .rd-mon { transition: none; }
  .rd.boot .rd-tube, .rd.off .rd-tube { animation: none; }
}
.rd-count .sm { display: none; }
@container (max-width: 660px) { .rd-brand { display: none !important; } }
@container (max-width: 470px) { .rd-count .lg { display: none; } .rd-count .sm { display: inline; } .rd-keys { gap: 4px; } .rd-k { width: 36px; height: 38px; } .rd-count { min-width: 56px; font-size: 20px; } }

/* the break-in: RED's terminal opens the session, then a strip on the screen says whose screen you're on */
.rd-boot .pr { color: #ff4a4a; text-shadow: 0 0 10px rgba(255, 74, 74, .55); }
.rd-boot .cm { color: #ffd9d9; }
.rd-boot .in { color: #ff9a9a; }
.rd-boot .ok { color: #4bf07a; text-shadow: 0 0 10px rgba(75, 240, 122, .45); }
.rd-boot .w { color: #ff6b6b; text-shadow: 0 0 12px rgba(255, 74, 74, .5); }
.rd-boot .bar { border-color: rgba(255, 74, 74, .65); }
.rd-boot .bar i { background: #ff4a4a; box-shadow: 0 0 10px rgba(255, 74, 74, .6); }
.rd-rv { position: absolute; z-index: 4; top: 2.2%; left: 2.4%; display: none; align-items: center; gap: .55em; max-width: 94%; padding: .32em .6em; border-radius: 4px; border: 1px solid rgba(255, 74, 74, .45); background: rgba(10, 0, 0, .72); font-family: var(--display); font-size: clamp(11px, 1.6vmin, 15px); line-height: 1; letter-spacing: .06em; color: #ffb3b3; white-space: nowrap; overflow: hidden; pointer-events: none; opacity: .92; transition: opacity .6s; animation: rvFade 1.2s 2.6s forwards; }
.rd-rv i { width: .62em; height: .62em; flex: none; border-radius: 50%; background: #ff4a4a; box-shadow: 0 0 8px #ff4a4a; animation: rvDot 1.6s steps(1) infinite; }
.rd-rv b { color: #ff4a4a; font-weight: 400; }
.rd-rv .rv-m { color: rgba(255, 179, 179, .6); }
.rd.remote .rd-rv { display: flex; }
.rd.remote.booting .rd-rv, .rd.zoomed .rd-rv { display: none; }
.rd-mon:hover .rd-rv { animation: none; opacity: .92; }
@keyframes rvDot { 50% { opacity: .25; } }
@keyframes rvFade { to { opacity: 0; } }      /* gone after a few seconds so it never sits on the art; hover brings it back */
@media (max-width: 520px) { .rd-rv .rv-m { display: none; } }
@media (prefers-reduced-motion: reduce) { .rd-rv { animation: none; opacity: .7; } .rd-rv i { animation: none; } }
.rd-boot { color: #ffcfcf; text-shadow: 0 0 8px rgba(255, 74, 74, .28); }
.rd.booting .rd-tube::after { content: "click or press Enter to skip"; position: absolute; z-index: 5; left: 0; right: 0; bottom: 4%; text-align: center; font-family: var(--display); font-size: clamp(11px, 1.6vmin, 15px); letter-spacing: .08em; color: rgba(255, 207, 207, .35); pointer-events: none; }
.rd.remote.booting .rd-tube::after { content: none; }
.rd.bye .rd-tube::after { content: none; }
.rd.remote .rd-led, .rd.booting .rd-led { background: #ff4a4a !important; box-shadow: 0 0 8px #ff4a4a, 0 0 2px #ff4a4a inset !important; animation: rvDot 1.6s steps(1) infinite; }
@media (max-width: 520px) { .rd-rv .rv-h { display: none; } }

/* RED's session: the whole reader takes his colors while it is open (black room, red type and glow, his [#] mark) */
.rd { --cyan: #ff4a4a; --dim: #8a5a5a; background: #000; transition: opacity .12s ease; }
.rd.on .rd-mon, .rd-mon { transform: none; transition: none; }
.rd-mon { background: linear-gradient(180deg, #1a1414, #0f0b0b 60%, #0b0808); }
.rd.lit .rd-mon { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05), inset 0 -2px 6px rgba(0, 0, 0, .6), 0 30px 80px rgba(0, 0, 0, .8), 0 0 120px rgba(255, 74, 74, .10); }
.rd.boot .rd-tube { animation: none; }
.rd-boot { text-shadow: 0 0 8px rgba(255, 74, 74, .3); }
.rd-lock { color: #ff6b6b; text-shadow: 0 0 10px rgba(255, 74, 74, .4); }
.rd-lock .big { color: #ffd9d9; }
.rd-ls { color: #ff6b6b; }
.rd-ls button { border-color: #2a1616; background: #080404; }
.rd-ls .lk { color: #6a3c3c; border-color: #2a1414; }
.rd-ls button:hover, .rd-ls button:focus-visible, .rd-ls button[aria-current="page"] { border-color: #ff4a4a; color: #ff4a4a; box-shadow: 0 0 14px rgba(255, 74, 74, .25); }
.rd-count { color: #ff4a4a; text-shadow: 0 0 10px rgba(255, 74, 74, .45); }
.rd-k { color: #c9a3a3; background: linear-gradient(180deg, #241a1a, #161010); border-color: #352323; }
.rd-k:hover, .rd-k:focus-visible, .rd-k[aria-pressed="true"] { color: #ff4a4a; border-color: rgba(255, 74, 74, .6); }
.rd-k.pw { color: #8a6a6a; }
.rd .rd-brand { display: flex; align-items: baseline; gap: .1em; color: #ff4a4a; text-shadow: 0 0 10px rgba(255, 74, 74, .5); letter-spacing: .08em; }
.rd-brand b { font-weight: 400; }
.rd-brand > span { color: #7a4a4a; text-shadow: none; letter-spacing: .16em; }
.rd :focus-visible { outline-color: #ff4a4a; }
@container (max-width: 660px) { .rd .rd-brand { display: flex !important; } .rd-brand > span { display: none; } }
@container (max-width: 470px) { .rd .rd-brand { display: flex !important; font-size: 14px; letter-spacing: 0; } }

/* ---------- a phone held sideways: the page fills the width and scrolls, the controls become a column on the right ---------- */
@media (orientation: landscape) and (max-height: 540px) {
  .rd { --bz: 6px; --gut: 6px; --chin: 0px; --sw: 70vh; }
  .rd-mon { display: flex; align-items: stretch; gap: 8px; width: auto; height: calc(100vh - 2 * var(--gut)); padding: var(--bz); border-radius: 16px; }
  .rd-scr { width: calc(100vw - 2 * var(--gut) - 2 * var(--bz) - 62px); height: 100%; aspect-ratio: auto; touch-action: pan-y; }
  .rd-stage { overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; scrollbar-width: thin; }
  .rd-zoom { position: relative; inset: auto; width: 100%; aspect-ratio: 1600 / 2443; transform: none !important; }
  .rd-hit, .rd-k[data-k="zoom"], .rd-brand { display: none !important; }
  .rd-chin { flex-direction: column; justify-content: center; align-items: center; width: 54px; height: auto; gap: 6px; padding: 0; }
  .rd-keys { flex-direction: column; gap: 4px; }
  .rd-k { width: 48px; height: 34px; }
  .rd-count { flex: none; font-size: 15px; }
}
@supports (height: 100dvh) { @media (orientation: landscape) and (max-height: 540px) { .rd-mon { height: calc(100dvh - 2 * var(--gut)); } } }
