/*
 * Retroprose: the public home page, the coming soon teaser
 * (app/Views/home/index.php). The theme tokens and fonts are the editor's
 * own (screen.css), so the teaser looks like the real screen.
 */

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin-ext-400.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin-700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin-ext-700.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Themes ----------
 * The same four screens as the editor. --dim is for rules only, never text.
 * --mark is the dimmed Markdown marks, at least 4.5:1 in each theme. */
:root {
  --bg: #0000AA; --fg: #AAAAAA; --hi: #FFFFFF; --head: #FFFF55; --acc: #55FFFF; --dim: #7777FF; --mark: #9090FF;
  --inv-bg: #AAAAAA; --inv-fg: #0000AA; --focus: #FFFF55;
  --font: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  --size: clamp(15px, 1.55vw, 23px); --lh: 1.5; --bw: 700;
  /* Plex Mono is .6em a character, so 80 columns of the text, whatever
   * size the line itself uses. */
  --gutter: max(16px, calc((100% - 80 * .6 * var(--size)) / 2));
  --glow: none; --scan: rgba(0, 0, 0, .08); --vignette: rgba(0, 0, 0, .28);
}
:root[data-skin="green"] {
  --bg: #001800; --fg: #33FF66; --hi: #D2FFDC; --head: #D2FFDC; --acc: #8CFFAA; --dim: #23933F; --mark: #23933F;
  --inv-bg: #33FF66; --inv-fg: #000000; --focus: #D2FFDC;
  --glow: 0 0 6px rgba(51, 255, 102, .5); --scan: rgba(0, 0, 0, .15); --vignette: rgba(0, 0, 0, .5);
}
:root[data-skin="amber"] {
  --bg: #1A1000; --fg: #FFB000; --hi: #FFE6B0; --head: #FFE6B0; --acc: #FFCF5C; --dim: #9A6B00; --mark: #A57400;
  --inv-bg: #FFB000; --inv-fg: #000000; --focus: #FFE6B0;
  --glow: 0 0 6px rgba(255, 176, 0, .45); --scan: rgba(0, 0, 0, .15); --vignette: rgba(0, 0, 0, .5);
}
:root[data-skin="paper"] {
  --bg: #FFFFFF; --fg: #222222; --hi: #000000; --head: #000000; --acc: #0000AA; --dim: #8A8A8A; --mark: #737373;
  --inv-bg: #222222; --inv-fg: #FFFFFF; --focus: #0000AA;
  --lh: 1.6; --scan: rgba(0, 0, 0, .04); --vignette: transparent;
}

/* ---------- Page ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; background: var(--bg); }
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--size);
  line-height: var(--lh);
  -webkit-text-size-adjust: 100%;
  transition: background-color .2s;
}
.sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* The screen: menu bar over the text, then the status line and key bar. */
.screen {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0);
  text-shadow: var(--glow);
  transform-origin: 50% 50%;
  animation: rp-on .8s cubic-bezier(.2, .7, .2, 1) both;
}
/* Rounded tube corners, darker at the edges. Never on paper. */
.screen::before {
  content: "";
  position: fixed; inset: 0; z-index: 30;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, transparent 60%, var(--vignette) 100%);
}
/* Scanlines */
body::after {
  content: "";
  position: fixed; inset: 0; z-index: 40;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0, transparent 2px, var(--scan) 3px);
}

/* ---------- Menu bar ----------
 * Sits over the top of the text, so the page never jumps when it opens. */
.menubar {
  position: absolute; top: env(safe-area-inset-top, 0); left: 0; right: 0; z-index: 5;
  display: flex;
  padding: 0 var(--gutter);
  background: var(--inv-bg);
  color: var(--inv-fg);
  text-shadow: none;
  white-space: nowrap;
}
.mtop { padding: 0 .6ch; }
.mtop:first-child { margin-left: -.6ch; }
.mtop.on { background: var(--inv-fg); color: var(--inv-bg); }
.drop {
  position: absolute; top: 100%; left: calc(var(--gutter) - .6ch);
  min-width: 26ch; max-width: calc(100vw - 32px);
  padding: 2px 0;
  background: var(--bg);
  color: var(--fg);
  border: 3px double var(--fg);
  text-shadow: var(--glow);
}
.it { display: flex; justify-content: space-between; gap: 3ch; padding: 0 1ch; }
.it .k { color: var(--fg); }
.it.sel, .it.sel .k { background: var(--inv-bg); color: var(--inv-fg); text-shadow: none; }
.rule { display: block; border-top: 1px solid var(--dim); margin: 2px 0; }

/* ---------- The text ---------- */
.doc { flex: 1; min-height: 0; overflow: hidden; }
.page {
  margin: 0;
  padding: 2.5em var(--gutter) 1em;
  font: inherit;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  font-variant-ligatures: none;
}
.page .m { color: var(--mark); }
.page .h { color: var(--head); font-weight: var(--bw); }
.page b { color: var(--hi); font-weight: var(--bw); }
.cur { color: var(--hi); font-weight: var(--bw); }
.cur.blink { animation: rp-blink 1.06s steps(1) infinite; }

/* ---------- Status line and key bar ---------- */
.status {
  flex: none;
  display: flex; justify-content: space-between; gap: 2ch;
  padding: 0 var(--gutter);
  white-space: nowrap;
  font-size: clamp(13px, 3.6vw, var(--size));
}
.status .l { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.status .l.note { color: var(--hi); }

.keybar {
  flex: none;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 3ch;
  padding: .2em var(--gutter);
  border-top: 1px solid var(--dim);
  font-size: clamp(13px, 3.6vw, calc(var(--size) * .85));
}
.brand { margin: 0; padding: .45em 0; }
.brand strong { color: var(--hi); font-weight: var(--bw); letter-spacing: .15em; margin-right: 1.5ch; }
.brand span { color: var(--head); }
.keys { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0 1ch; margin-right: -1ch; }
.keys button,
.keys a {
  display: flex; align-items: center; gap: .6ch;
  min-height: 44px;
  padding: 0 1ch;
  font: inherit; color: inherit; text-shadow: inherit;
  background: none; border: 0; border-radius: 0;
  cursor: pointer;
}
.keys b { background: var(--inv-bg); color: var(--inv-fg); font-weight: 400; padding: 0 .4ch; text-shadow: none; }
.keys a { text-decoration: underline; text-underline-offset: .2em; }
.keys button:hover,
.keys a:hover { color: var(--hi); }
.keys button[aria-pressed="true"] { background: var(--inv-bg); color: var(--inv-fg); text-shadow: none; }
.keys button[aria-pressed="true"] b { background: var(--inv-fg); color: var(--inv-bg); }
.keys button:focus-visible,
.keys a:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }

/* ---------- Motion ---------- */
/* Switching on: a bright line that opens into the screen. */
@keyframes rp-on {
  0%   { transform: scale(.7, .004); filter: brightness(4); opacity: .6; }
  45%  { transform: scale(1, .004); filter: brightness(3); opacity: 1; }
  100% { transform: none; filter: none; }
}
/* A short flicker when the screen changes colour. */
@keyframes rp-flick {
  0% { opacity: 1; } 30% { opacity: .35; } 55% { opacity: .9; } 70% { opacity: .6; } 100% { opacity: 1; }
}
.screen.flick { animation: rp-flick .3s linear; }
@keyframes rp-blink { 50% { opacity: 0; } }

/* Paused: the cursor holds still too. */
.paused .cur.blink { animation: none; }

/* Less motion: no switching on, no flicker, no blink and no scanlines.
 * The script shows the first teaser in full and stops there. */
@media (prefers-reduced-motion: reduce) {
  .screen, .screen.flick { animation: none; }
  .cur.blink { animation: none; }
  body { transition: none; }
}
@media (prefers-contrast: more), (prefers-reduced-motion: reduce), (forced-colors: active) {
  body::after, .screen::before { display: none; }
}
@media (prefers-contrast: more) {
  .screen { text-shadow: none; }
}
@media (forced-colors: active) {
  .drop { border: 1px solid CanvasText; }
  .keys b { border: 1px solid CanvasText; }
}
@media (max-width: 30rem) {
  .brand strong { margin-right: 1ch; }
}
