/* ===========================================================================
   REKHYT  |  SHARED INTERFACE

   One stylesheet for every page, so the reader, the library, the games and
   the sign in screens look like one piece of software rather than five.

   Load it LAST on any page. It is written to override what is already there,
   including rules set with !important, because most of these pages carry
   their own older styling underneath.

   -----------------------------------------------------------------------
   THE ONE RULE ABOUT RED
   -----------------------------------------------------------------------
   Red belongs to the falling letters and nothing else.

   Every page draws that rain itself with a hardcoded #FC1212 in its own
   script, so it is untouched by anything here. The interface on top of it
   used the same red for borders, labels, buttons and panels, which is what
   made everything shout at once.

   The pages ask for that colour through a variable called --red. Rather than
   hunt down every use, the variable is simply given a quiet value below, and
   every one of them turns neutral at once.

   The two exceptions are right and wrong in the games. Those are not
   decoration, they are the answer to a question, and stripping the colour out
   of them would make the games harder to use.
   ========================================================================= */

:root {
  /* Handed to the canvas only. Nothing in the interface should use it. */
  --rain: #FC1212;

  /* Neutralises every existing var(--red) and var(--dim) on these pages. */
  --red: rgba(255, 255, 255, .92);
  --dim: rgba(255, 255, 255, .58);
  --panel: rgba(0, 0, 0, .72);

  --line: rgba(255, 255, 255, .17);
  --line-soft: rgba(255, 255, 255, .09);
  --surface: rgba(0, 0, 0, .72);
  --surface-raised: rgba(10, 10, 10, .88);

  --text: #fff;
  --text-dim: rgba(255, 255, 255, .58);

  /* Right and wrong. Meaning, not decoration. */
  --ok: #3fb950;
  --no: #f85149;
  --green: #3fb950;

  --radius: 5px;
  --label: 14px;
  --gap: 14px;
  --ui-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --read-font: "Libre Baskerville", Georgia, "Times New Roman", serif;
}

/* ---------------------------------------------------------------------------
   Page
   ------------------------------------------------------------------------ */

html, body {
  height: 100%;
  margin: 0;
  background: #000;
  color: var(--text);
  font-family: var(--ui-font);
  font-size: var(--label);
}

/* The rain sits behind everything and costs no layout height. Click through
   so it can never swallow a press. */
#Matrix {
  position: fixed !important;
  inset: 0 !important;
  z-index: 0 !important;
  pointer-events: none !important;
}

/* ---------------------------------------------------------------------------
   Typography

   One face for the interface, one for prose, and every label the same size.
   The pages were running monospace, Arial and a serif together.
   ------------------------------------------------------------------------ */

body, button, input, select, textarea,
h1, h2, h3, h4, label, a, .eyebrow, .tabButton {
  font-family: var(--ui-font);
}

button, input, select, textarea, label, a, .eyebrow, .footer, .hint {
  font-size: var(--label);
}

h1 { font-size: 17px; font-weight: 700; letter-spacing: .04em; margin: 4px 0 0; }
h2 { font-size: 15px; font-weight: 700; }
h3 { font-size: var(--label); font-weight: 700; }

.eyebrow {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}

/* Prose keeps the serif. It is the thing being read, not part of the chrome. */
.content, .reader-word, #prompt, .sentence, blockquote {
  font-family: var(--read-font);
}

/* ---------------------------------------------------------------------------
   Surfaces
   ------------------------------------------------------------------------ */

.panel, .card-surface,
#gamePanel, #empty, #card, .box, .shelf {
  background: var(--surface) !important;
  border: 1px solid var(--line) !important;
  border-radius: var(--radius) !important;
  box-shadow: none !important;
}

/* ---------------------------------------------------------------------------
   Controls

   One shape everywhere: light hairline, 5px corner, 14px, bold, white text.
   Hover fills rather than glows, which is what keeps it quiet.
   ------------------------------------------------------------------------ */

button, .ui-btn, .btn, .reader-nav a {
  padding: 8px 14px;
  border: 1px solid var(--line) !important;
  border-radius: var(--radius) !important;
  background: rgba(255, 255, 255, .04) !important;
  color: var(--text) !important;
  font-size: var(--label) !important;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  box-shadow: none !important;
  transition: background .15s, border-color .15s;
}

button:hover, .ui-btn:hover, .btn:hover, .reader-nav a:hover,
button:focus-visible, .ui-btn:focus-visible, .reader-nav a:focus-visible {
  background: rgba(255, 255, 255, .12) !important;
  border-color: rgba(255, 255, 255, .34) !important;
  outline: none;
}

button:disabled { opacity: .38; cursor: not-allowed; }

/* The one action on a screen that actually does something. Filled rather than
   outlined, which is how you tell it apart without needing a colour. */
button.primary, #checkButton, #sendBtn, #flipButton {
  background: rgba(255, 255, 255, .92) !important;
  border-color: transparent !important;
  color: #000 !important;
}

button.primary:hover, #checkButton:hover, #sendBtn:hover, #flipButton:hover {
  background: #fff !important;
  border-color: transparent !important;
}

.secondary { opacity: .78; }

input, textarea, select {
  padding: 9px 12px;
  border: 1px solid var(--line) !important;
  border-radius: var(--radius) !important;
  background: rgba(0, 0, 0, .55) !important;
  color: var(--text) !important;
  font-size: var(--label) !important;
}

input:focus, textarea:focus, select:focus {
  border-color: rgba(255, 255, 255, .38) !important;
  box-shadow: none !important;
  outline: none;
}

input::placeholder { color: rgba(255, 255, 255, .34); }

/* ---------------------------------------------------------------------------
   Right and wrong

   The only colour left, and only where it answers a question.
   ------------------------------------------------------------------------ */

.correct, .is-correct { color: var(--ok) !important; }
.wrong, .is-wrong { color: var(--no) !important; }

/* ---------------------------------------------------------------------------
   Odds and ends the pages share
   ------------------------------------------------------------------------ */

.progress { height: 3px; background: rgba(255, 255, 255, .12) !important; }

#progressBar {
  background: rgba(255, 255, 255, .82) !important;
  box-shadow: none !important;
}

.blank {
  border-bottom: 2px solid rgba(255, 255, 255, .6) !important;
  color: transparent;
}

.footer, .hint, .label, #count, #counts, #score, #translation {
  color: var(--text-dim) !important;
  font-size: var(--label);
}

hr, .divider { border: 0; height: 1px; background: var(--line-soft); }

::selection { background: rgba(255, 255, 255, .22); }

/* Scrollbars, on the panes that are allowed to scroll. */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
*::-webkit-scrollbar-track { background: transparent; }

/* An empty shelf should say so rather than look broken. */
.shelf-empty {
  align-self: center;
  max-width: 460px;
  color: var(--text-dim);
  font-size: var(--label);
  line-height: 1.6;
}

/* Caught by the gate, not by eye.

   The Save history button kept a red tint on its background. I had changed its
   border and stopped looking, which is the same mistake as fixing one route to
   a feature and not the others.

   The three transport buttons were rendering at the browser default of 16px
   because nothing had ever set them, so they sat next to 14px controls. */
#chat_history,
#chatHistory {
  background: rgba(255, 255, 255, .04) !important;
}

.box-right-2 .buttonsound,
#backwardBtn, #playPauseBtn, #forwardBtn {
  font-size: var(--label) !important;
}

/* ===========================================================================
   More faults the sweep found
   ======================================================================== */

/* FILL IN THE BLANK prompt. #prompt was display:flex, so every word of the
   sentence became its own flex item and .blank refused to shrink, squeezing
   real dictionary sentences into vertical columns of one letter per line that
   overflowed the card off the top and bottom with no way to scroll. Normal
   text flow fixes it. */
#prompt {
  display: block !important;
  text-align: center;
  overflow-wrap: anywhere;
  line-height: 1.6;
}
#prompt .blank {
  display: inline-block;
  min-width: 64px !important;
  vertical-align: baseline;
}
/* If a card's sentence is genuinely long, let the panel scroll rather than
   pushing the buttons off the screen. */
#gamePanel { max-height: 100%; overflow-y: auto; }

/* THE LAST HARDCODED REDS. ui.css neutralises var(--red), but these were
   written as literal #FC1212 / rgba(252,18,18,...) in tts-ui.css and the
   library page, so the neutralisation never reached them. */
.book { box-shadow: none !important; }
.book:hover, .book.selected {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .34) !important;
}
#chat_history, #chatHistory { background: rgba(255, 255, 255, .04) !important; }
.dictionary-audio-button {
  background: rgba(255, 255, 255, .04) !important;
  border-color: rgba(255, 255, 255, .17) !important;
  color: var(--text) !important;
}
.dictionary-audio-button:hover {
  background: rgba(255, 255, 255, .12) !important;
  border-color: rgba(255, 255, 255, .34) !important;
}
code { color: rgba(255, 255, 255, .82) !important; }

/* Last of the odd sizes and the stray monospace, all from selectors in the
   older sheets that out-specify the plain element rules above. */
.key, #prev, #next,
.box-right-2 .buttonsound, .box-right-2 .buttonsound i {
  font-size: var(--label) !important;
  font-family: var(--ui-font) !important;
}
.dictionary-entry h2, #tab2 .dictionary-entry h2 {
  font-size: 15px !important;
}
/* The counter, the filename and the chat input were monospace, one gap away
   from sans controls in the same bar. */
#ui-filename, #page-number, #userInput, .chatbox input, .tab-hint {
  font-family: var(--ui-font) !important;
}

/* Way back from the games to the library and to each other. They were dead
   ends before: once you were in a game the only way out was the browser back
   button. */
.topbar-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.game-nav { display: flex; gap: 8px; flex-wrap: wrap; }
.game-nav a {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  font-size: var(--label);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.game-nav a:hover { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .34); }

/* Review game literals: .fact separators and the progress track were written
   as rgba(252,18,18,...) rather than var(--red), so neutralising the variable
   never reached them. */
.fact { border-bottom-color: var(--line) !important; }
.reviewgame .progress, .progress { background: rgba(255, 255, 255, .12) !important; }
.secondary { border-color: var(--line) !important; }

/* The dictionary tab content had a red top border, unseen until the reader
   began opening on that tab. */
#tab2, .tabContent { border-color: var(--line) !important; }
