/*
 * Rise - a CRT terminal.
 *
 * Deliberately does NOT link ../suite.css. That file exists to stop font and
 * sizing drift between the tracker apps; this is a phosphor screen that
 * overrides all of it, and linking it only to fight it would be worse than
 * not linking it. The one suite rule broken on purpose (see rise/CLAUDE.md).
 *
 * Everything colour-shaped is a token, so e-ink is a redefinition rather
 * than a second stylesheet.
 */

:root {
  --bg: #020402;
  --glass: #061009;
  --glass-edge: #010201;
  --fg: #3bd46a;          /* prose */
  --fg-hi: #9dffbf;       /* nouns, titles: a shade brighter */
  --fg-dim: #237f41;      /* exits, system lines */
  --fg-echo: #6dfb95;     /* what you typed */
  --fg-death: #ff5e4d;
  --bar-bg: #3bd46a;
  --bar-fg: #031006;
  --glow: 0 0 1px rgba(80, 255, 130, .55), 0 0 7px rgba(60, 255, 120, .28);
  --glow-hi: 0 0 2px rgba(150, 255, 190, .8), 0 0 10px rgba(80, 255, 140, .45);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

:root[data-eink] {
  --bg: #fff;
  --glass: #fff;
  --glass-edge: #fff;
  --fg: #000;
  --fg-hi: #000;
  --fg-dim: #000;
  --fg-echo: #000;
  --fg-death: #000;
  --bar-bg: #000;
  --bar-fg: #fff;
  --glow: none;
  --glow-hi: none;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 17px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* ------------------------------------------------------------------ glass */

.crt {
  height: 100vh;
  height: 100dvh;
  max-width: 940px;
  margin: 0 auto;
  padding: 14px;
}

.screen {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 26px / 34px;           /* a tube, not a panel */
  background: radial-gradient(ellipse 120% 100% at 50% 45%, var(--glass) 0%, var(--glass) 55%, var(--glass-edge) 100%);
  box-shadow:
    inset 0 0 90px rgba(0, 0, 0, .85),
    inset 0 0 18px rgba(60, 255, 120, .07),
    0 0 0 3px #0b0f0b,
    0 0 40px rgba(40, 255, 100, .07);
  text-shadow: var(--glow);
}

/* Scanlines, and the dark falling away at the curve of the glass. */
.screen::before,
.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}
.screen::before {
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, .28) 0, rgba(0, 0, 0, .28) 1px, transparent 1px, transparent 3px);
}
.screen::after {
  background: radial-gradient(ellipse 100% 90% at 50% 50%, transparent 62%, rgba(0, 0, 0, .55) 100%);
}

:root[data-eink] .crt { padding: 0; }
:root[data-eink] .screen {
  border-radius: 0;
  box-shadow: none;
  background: #fff;
}
:root[data-eink] .screen::before,
:root[data-eink] .screen::after { display: none; }

/* ------------------------------------------------------------- status bar */

.status {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 14px;
  margin: 18px 26px 0;
  padding: 3px 10px;
  background: var(--bar-bg);
  color: var(--bar-fg);
  text-shadow: none;
  font-size: .82rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  box-shadow: 0 0 12px rgba(60, 255, 120, .25);
}
:root[data-eink] .status { box-shadow: none; }
.st-main { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.menu { display: flex; gap: 6px; flex-wrap: wrap; }
.menu form { margin: 0; }
.menu button {
  font: inherit;
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--bar-fg);
  background: transparent;
  border: 1px solid currentColor;
  padding: 1px 6px;
  cursor: pointer;
  border-radius: 0;
}
.menu button:hover,
.menu button:focus-visible { background: var(--bar-fg); color: var(--bar-bg); outline: none; }

/* -------------------------------------------------------------------- log */

.log {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 30px 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--fg-dim) transparent;
  overscroll-behavior: contain;
  /* Text fades as it scrolls up under the status bar instead of being cut. */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 22px);
  mask-image: linear-gradient(to bottom, transparent 0, #000 22px);
}

.l {
  margin: 0 0 .7em;
  max-width: 72ch;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.l .n { color: var(--fg-hi); text-shadow: var(--glow-hi); }
.l em { font-style: normal; color: var(--fg-hi); }
.l a { color: var(--fg-hi); text-shadow: var(--glow-hi); text-decoration: underline; text-underline-offset: .15em; }
:root[data-eink] .l .n { font-weight: 700; }
:root[data-eink] .l a { font-weight: 700; }
:root[data-eink] .l em { font-style: italic; }

.l-echo { color: var(--fg-echo); margin-top: 1.3em; }
.l-echo::before { content: "> "; }
.l-title {
  margin-top: 1.3em;
  color: var(--fg-hi);
  font-weight: 700;
  letter-spacing: .05em;
  text-shadow: var(--glow-hi);
}
.l-echo + .l-title { margin-top: .6em; }
.l-sys { color: var(--fg-dim); font-size: .92em; }
.l-li { margin: 0 0 .15em 2ch; }
.l-li::before { content: "- "; color: var(--fg-dim); }
.l-death {
  color: var(--fg-death);
  font-weight: 700;
  letter-spacing: .3em;
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(255, 90, 70, .6);
  margin: 1em 0;
}
.l-act {
  margin: 1.2em 0 1em;
  color: var(--fg-hi);
  font-weight: 700;
  letter-spacing: .35em;
  text-shadow: var(--glow-hi);
}
.l-act::before,
.l-act::after { content: " ═══ "; color: var(--fg-dim); letter-spacing: 0; }
.l-rule { height: 0; margin: 1.2em 0; border-top: 1px dashed var(--fg-dim); max-width: 72ch; opacity: .6; }

/* MAP: a grid of box-drawing characters, so it must never wrap. It scrolls
   sideways if it has to, and shrinks on a phone so it rarely needs to. */
.l-map {
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  max-width: none;
  line-height: 1.2;
  font-size: .92em;
  letter-spacing: 0;
  scrollbar-width: thin;
}
:root[data-eink] .l-death { text-shadow: none; }

/* The typewriter: a line waiting its turn stays invisible, not absent, so the
   layout never jumps as it fills in. */
.l.pending { visibility: hidden; }

/* ----------------------------------------------------------------- prompt */

.prompt {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 1ch;
  margin: 0 30px 22px;
  padding-top: 6px;
}
.gt { color: var(--fg-hi); text-shadow: var(--glow-hi); }
.field { position: relative; flex: 1 1 auto; display: block; }
.field input,
.login-row input {
  width: 100%;
  font: inherit;
  font-size: max(16px, 1rem);          /* below 16px iOS zooms in on focus */
  letter-spacing: 0;
  color: var(--fg-echo);
  text-shadow: var(--glow);
  background: transparent;
  border: 0;
  outline: none;
  padding: 2px 0;
  caret-color: var(--fg-hi);
  border-radius: 0;
}
.js .field input { caret-color: transparent; }   /* the block cursor takes over */

/* The block cursor. js/rise.js moves it to the caret; with JavaScript off
   the input simply keeps its own caret. */
.cursor {
  position: absolute;
  top: 3px;
  left: 0;
  width: 1ch;
  height: 1.25em;
  background: var(--fg-hi);
  box-shadow: 0 0 8px rgba(80, 255, 140, .6);
  animation: blink 1.06s steps(1, end) infinite;
  pointer-events: none;
  display: none;
}
.js .cursor { display: block; }
.field input:not(:focus) + .cursor { opacity: .35; animation: none; }
:root[data-eink] .cursor { box-shadow: none; animation: none; }
@keyframes blink { 50% { opacity: 0; } }

/* ------------------------------------------------------------------ login */

.login {
  position: relative;
  z-index: 1;
  overflow-y: auto;
  padding: 7vh 34px 30px;
  max-width: 70ch;
}
.login p { margin: 0 0 1em; }
.logo {
  margin: 0 0 .4em;
  color: var(--fg-hi);
  text-shadow: var(--glow-hi);
  font-size: clamp(11px, 3.4vw, 17px);
  line-height: 1.15;
}
.tag { color: var(--fg-dim); letter-spacing: .25em; text-transform: uppercase; font-size: .85em; }
/* The tag line is the page's h1 (for search engines: the ASCII logo is not readable as a
   title), dressed exactly as the paragraph it used to be. */
h1.tag { font-weight: normal; font-family: inherit; line-height: inherit; margin: 0 0 1em; }
.login-form { margin: 2em 0 1.8em; }
.login-form label { display: block; margin-bottom: .3em; }
.login-row { display: flex; gap: 1ch; align-items: center; border-bottom: 1px dashed var(--fg-dim); margin-bottom: 1em; }
.login-form button {
  font: inherit;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--bar-fg);
  background: var(--bar-bg);
  border: 0;
  padding: 4px 16px;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(60, 255, 120, .3);
}
:root[data-eink] .login-form button { box-shadow: none; }
.err { color: var(--fg-death); }
.note { color: var(--fg-dim); font-size: .88em; }

/* ------------------------------------------------------------------ small */

@media (max-width: 600px) {
  html, body { font-size: 15px; }
  .l-map { font-size: .72em; }
  .crt { padding: 0; }
  .screen { border-radius: 0; }
  .status { margin: 0; }
  .log { padding: 12px 16px 6px; }
  .prompt { margin: 0 16px 14px; }
  .login { padding: 5vh 16px 24px; }
}

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