/* ============================================================
   memory.css -- ETH0 // MEMORY (v2.6 DEADSIGNAL), the book.
   js/modes/memory.js. Everything is under .mem-root / .mem-app, so
   nothing here can touch another screen.

   The one place in the game that is NOT a terminal: a printed book on a
   dark desk. Paper, ink and a serif face on purpose -- ETH0 wrote the
   history down, and it reads like something that was meant to last.
   The game's phosphor green stays on the cover and the tools around it.
   ============================================================ */

.mem-root { height: 100%; }
/* GHOST window: the book is sized from the window itself (cqw / cqh), so it
   grows and shrinks as the window is resized. Legacy has no fixed height to
   measure, so it keeps the viewport-based size below. */
.mem-root-ghost { container-type: size; }

.mem-app {
  --mem-desk: #050706;
  /* Readability first: near-white paper and near-black ink. The old warm
     paper (#e7dfca) with brown-grey ink read as yellow mush in-game, worse
     under the scanlines and a lowered screen brightness. */
  --mem-paper: #f4f1ea;
  --mem-paper-edge: #d9d3c6;
  --mem-ink: #121010;
  --mem-ink-dim: #39342b;
  --mem-red: #a3121e;
  --mem-cover: #0b120d;
  --mem-cover-line: #1f3a28;
  --mem-glow: var(--fg, #5fff7e);
  /* Literata: a serif drawn for long reading on screens (index.html loads it) */
  --mem-serif: 'Literata', Georgia, 'Iowan Old Style', 'Palatino Linotype', serif;
  height: 100%;
  min-height: 420px;
  background:
    radial-gradient(ellipse at 50% 35%, rgba(95, 255, 126, 0.05), transparent 60%),
    var(--mem-desk);
  color: var(--fg, #5fff7e);
  font-family: var(--font-mono, monospace);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.mem-legacy { min-height: calc(100vh - 120px); }

.mem-desk {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 14px 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.mem-msg { color: var(--fg-dim, #2a8035); font-size: 13px; text-align: center; padding: 18px 8px; }
.mem-hint { color: var(--fg-dim, #2a8035); font-size: 11px; letter-spacing: 3px; text-transform: uppercase; animation: mem-pulse 2.4s ease-in-out infinite; }
@keyframes mem-pulse { 50% { opacity: 0.35; } }

/* ---------- buttons ---------- */
.mem-btn {
  background: transparent;
  border: 1px solid var(--border-bright, #2a4a35);
  color: var(--fg, #5fff7e);
  font: inherit;
  font-size: 12px;
  letter-spacing: 1px;
  padding: 7px 12px;
  cursor: pointer;
  border-radius: 2px;
}
.mem-btn:hover:not([disabled]) { border-color: var(--fg, #5fff7e); background: rgba(95, 255, 126, 0.06); }
.mem-btn[disabled] { opacity: 0.3; cursor: default; }
.mem-btn-ghost { border-color: transparent; color: var(--fg-dim, #2a8035); }
.mem-btn-sm { padding: 4px 8px; font-size: 11px; }
.mem-page .mem-btn { color: var(--mem-ink); border-color: var(--mem-paper-edge); }
.mem-page .mem-btn-ghost { border-color: transparent; color: var(--mem-ink-dim); }
.mem-page .mem-btn:hover:not([disabled]) { background: rgba(0, 0, 0, 0.05); border-color: var(--mem-ink-dim); }

/* ---------- the closed book ---------- */
.mem-book-closed {
  position: relative;
  container-type: inline-size;   /* every size on the cover is a share of the book's width */
  width: min(300px, 76vw);
  aspect-ratio: 3 / 4.3;
  margin-top: 18px;
  perspective: 1400px;
  cursor: pointer;
  outline: none;
}
.mem-cover {
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.55) 0, rgba(0, 0, 0, 0) 9%, rgba(255, 255, 255, 0.03) 10%, rgba(0, 0, 0, 0) 12%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.012) 0 2px, transparent 2px 5px),
    var(--mem-cover);
  border: 1px solid var(--mem-cover-line);
  border-radius: 3px 8px 8px 3px;
  box-shadow: 0 22px 40px rgba(0, 0, 0, 0.75), inset 0 0 40px rgba(0, 0, 0, 0.6);
  transform-origin: left center;
  transition: transform 0.7s cubic-bezier(0.6, 0, 0.3, 1), box-shadow 0.7s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3.3cqw;
  text-align: center;
  padding: 6cqw 6cqw 6cqw 10cqw;
  backface-visibility: hidden;
}
.mem-cover::before {
  content: '';
  position: absolute;
  inset: 4cqw 4cqw 4cqw 8.7cqw;
  border: 1px solid var(--mem-cover-line);
  pointer-events: none;
}
.mem-cover-mark { font-size: 3.7cqw; color: var(--fg-dim, #2a8035); letter-spacing: 2cqw; }
.mem-cover-title {
  font-family: var(--font-display, monospace);
  font-size: 16cqw;
  letter-spacing: 2.6cqw;
  color: var(--mem-glow);
  text-shadow: 0 0 12px rgba(95, 255, 126, 0.55), 0 0 2px rgba(95, 255, 126, 0.9);
}
.mem-cover-kicker { font-size: 3.1cqw; letter-spacing: 0.7cqw; text-transform: uppercase; color: var(--fg, #5fff7e); opacity: 0.85; }
.mem-cover-sub { font-family: var(--mem-serif); font-style: italic; color: var(--fg-bright, #b8ffb8); opacity: 0.75; font-size: 4.7cqw; line-height: 1.5; }
.mem-cover-foot { position: absolute; bottom: 7cqw; left: 10cqw; right: 6cqw; font-size: 3cqw; letter-spacing: 0.3cqw; line-height: 1.6; color: var(--fg-dim, #2a8035); opacity: 0.8; }
.mem-cover-pages {
  position: absolute;
  inset: 4px 6px 4px 4px;
  z-index: 1;
  background: repeating-linear-gradient(90deg, var(--mem-paper) 0 2px, var(--mem-paper-edge) 2px 3px);
  border-radius: 2px 6px 6px 2px;
}
@container (min-height: 1px) {
  .mem-root-ghost .mem-book-closed { width: clamp(200px, min(72cqw, calc(78cqh * 3 / 4.3)), 640px); margin-top: 3cqh; }
}
.mem-book-closed:hover .mem-cover { transform: rotateY(-8deg); box-shadow: 18px 22px 40px rgba(0, 0, 0, 0.75); }
.mem-book-closed.is-opening .mem-cover { transform: rotateY(-165deg); box-shadow: none; }

/* ---------- the open book ---------- */
.mem-book-open {
  position: relative;
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 560px;
}
.is-entering .mem-book-open { animation: mem-open 0.45s ease-out; }
.mem-book-open.is-spread { max-width: 1060px; }
.mem-book-open.is-spread .mem-page { flex: 1 1 0; max-width: 520px; }
.mem-book-open.is-spread .mem-page:first-of-type { border-radius: 6px 0 0 6px; box-shadow: inset -18px 0 26px -18px rgba(0, 0, 0, 0.45), 0 18px 34px rgba(0, 0, 0, 0.6); }
.mem-book-open.is-spread .mem-page:last-of-type { border-radius: 0 6px 6px 0; box-shadow: inset 18px 0 26px -18px rgba(0, 0, 0, 0.45), 0 18px 34px rgba(0, 0, 0, 0.6); }
@keyframes mem-open { from { opacity: 0; transform: scale(0.97); } }

.mem-book-open.turn-next .mem-page { animation: mem-turn-next 0.26s ease-in forwards; }
.mem-book-open.turn-prev .mem-page { animation: mem-turn-prev 0.26s ease-in forwards; }
@keyframes mem-turn-next { to { transform: perspective(1200px) rotateY(-24deg) translateX(-14px); opacity: 0; } }
@keyframes mem-turn-prev { to { transform: perspective(1200px) rotateY(24deg) translateX(14px); opacity: 0; } }

.mem-page {
  position: relative;
  width: 100%;
  min-height: 520px;
  padding: 30px 30px 44px;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, 0.4), transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(120, 95, 50, 0.05), transparent 55%),
    var(--mem-paper);
  color: var(--mem-ink);
  border-radius: 4px;
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.6), inset 0 0 50px rgba(120, 95, 50, 0.08);
  font-family: var(--mem-serif);
  /* Literata is variable (index.html loads 400..700): a touch heavier than
     regular so small text survives scanlines, dimming and thin rendering */
  font-weight: 460;
  -webkit-font-smoothing: auto;
  text-rendering: optimizeLegibility;
  transform-origin: center;
}
.mem-page-blank { background: var(--mem-paper-edge); }
.mem-page-head {
  font-family: var(--mem-serif);
  font-variant: small-caps;
  letter-spacing: 4px;
  font-size: 22px;
  text-align: center;
  margin-bottom: 8px;
}
.mem-lede { text-align: center; font-style: italic; color: var(--mem-ink); font-size: 16px; margin: 0 auto 18px; max-width: 420px; line-height: 1.5; }

.mem-chap-head { text-align: center; margin-bottom: 22px; font-variant: small-caps; letter-spacing: 5px; font-size: 20px; }
.mem-chap-head span { display: block; font-size: 14px; letter-spacing: 3px; color: var(--mem-ink-dim); margin-bottom: 6px; }
.mem-chap-head em { display: block; font-variant: normal; letter-spacing: 0; font-size: 17px; margin-top: 6px; color: var(--mem-ink); }

.mem-text p { margin: 0 0 1em; text-indent: 1.4em; line-height: 1.7; font-size: 17.5px; text-align: justify; hyphens: auto; }
/* a phone column is too narrow for justify: it opens rivers between words */
@media (max-width: 600px) { .mem-text p { text-align: left; hyphens: manual; font-size: 17px; } }
.mem-text p:first-child { text-indent: 0; }
/* drop cap on the chapter's opening paragraph only (page 1 has the head) */
.mem-chap-head + .mem-text p:first-child::first-letter { float: left; font-size: 3.1em; line-height: 0.9; padding: 4px 6px 0 0; }
.mem-folio { position: absolute; bottom: 16px; left: 0; right: 0; text-align: center; font-size: 13px; color: var(--mem-ink-dim); letter-spacing: 2px; }

/* WpE's paper notes, photographed and taped in */
.mem-fig {
  position: relative;
  margin: 18px auto 26px;
  padding: 8px 8px 10px;
  width: fit-content;
  max-width: 92%;
  background: #f7f3ea;
  box-shadow: 0 6px 14px rgba(40, 30, 10, 0.35);
}
/* a portrait photo of a notebook page must not stretch the page it sits on */
.mem-fig img { display: block; max-width: 100%; max-height: 360px; width: auto; height: auto; margin: 0 auto; filter: contrast(1.06); }
.mem-fig::before, .mem-fig::after {
  content: '';
  position: absolute;
  top: -10px;
  width: 64px;
  height: 20px;
  background: rgba(236, 226, 190, 0.78);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}
.mem-fig::before { left: 14px; transform: rotate(-6deg); }
.mem-fig::after { right: 14px; transform: rotate(5deg); }
.mem-fig figcaption { font-style: italic; font-size: 14px; color: var(--mem-ink-dim); text-align: center; margin-top: 8px; }

/* a translated handwritten note, line by line */
.mem-text p.mem-note { text-indent: 0; text-align: left; margin: 0 0 1.1em 1.4em; padding-left: 12px; border-left: 2px solid var(--mem-paper-edge); font-style: italic; line-height: 1.55; }

/* sentences you can accuse */
.is-markable .mem-s { cursor: pointer; border-radius: 2px; transition: background 0.15s; }
.is-markable .mem-s:hover { background: rgba(163, 18, 30, 0.08); }
.mem-s.is-asking { background: rgba(163, 18, 30, 0.16); }
.mem-s.is-lie {
  color: var(--mem-red);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  text-decoration-color: rgba(163, 18, 30, 0.7);
  cursor: default;
}

.mem-ribbon {
  position: absolute;
  top: -8px;
  right: 22px;
  z-index: 3;
  background: var(--mem-red);
  color: #f6e9d2;
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  letter-spacing: 2px;
  padding: 14px 8px 18px;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%);
  text-transform: uppercase;
  writing-mode: vertical-rl;
}

/* ---------- contents ---------- */
.mem-toc { list-style: none; margin: 0; padding: 0; }
.mem-toc-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 9px 4px;
  border-bottom: 1px dotted var(--mem-paper-edge);
  cursor: pointer;
}
.mem-toc-row:hover:not(.is-sealed) { background: rgba(0, 0, 0, 0.04); }
.mem-toc-row.is-sealed { cursor: default; opacity: 0.55; }
.mem-toc-row.is-freax { opacity: 0.7; }
.mem-toc-num { width: 54px; flex: none; text-align: right; font-size: 15px; color: var(--mem-ink-dim); letter-spacing: 1px; }
.mem-toc-main { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mem-toc-code { font-variant: small-caps; letter-spacing: 2px; font-size: 18px; font-weight: 600; }
.mem-toc-title { font-style: italic; font-size: 16px; color: var(--mem-ink); }
.mem-toc-meta { font-size: 14.5px; color: var(--mem-ink-dim); }
.mem-toc-who b { color: var(--mem-ink); }
.mem-live { color: var(--mem-red); }
.mem-toc-tools { display: flex; justify-content: center; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

.mem-tag {
  flex: none;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 3px 8px;
  border: 1px solid var(--mem-ink-dim);
  color: var(--mem-ink);
  border-radius: 2px;
}
.mem-tag-done { border-color: #2c6a3d; color: #2c6a3d; }
.mem-tag-lock { border-color: var(--mem-red); color: var(--mem-red); }

/* ---------- gate ---------- */
.mem-page-gate { display: flex; flex-direction: column; }
.mem-gate-prompt { font-size: 17px; line-height: 1.7; margin: 8px 0 22px; }
.mem-gate-prompt img { max-width: 100%; }
.mem-gate-hint { font-size: 15px; font-style: italic; color: var(--mem-ink-dim); margin: 0 0 8px; }
.mem-gate-hint b { font-style: normal; font-family: var(--font-mono, monospace); font-size: 12px; }
.mem-gate-form { display: flex; gap: 8px; margin-top: auto; padding-top: 18px; }
.mem-gate-form.is-wrong { animation: mem-shake 0.35s; }
@keyframes mem-shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.mem-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--mem-ink-dim);
  color: var(--mem-ink);
  font-family: var(--mem-serif);
  font-size: 18px;
  padding: 6px 2px;
  outline: none;
}
.modal .mem-input { color: var(--fg, #5fff7e); border-bottom-color: var(--fg-dim, #2a8035); font-family: var(--font-mono, monospace); width: 100%; }
.mem-page-tools { display: flex; justify-content: center; margin-top: 16px; }

/* ---------- status bar + nav ---------- */
.mem-bar, .mem-nav {
  width: 100%;
  max-width: 1060px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
}
.mem-bar { justify-content: flex-start; border-bottom: 1px solid var(--border, #1a2820); padding-bottom: 8px; }
.mem-nav { justify-content: space-between; }
.mem-bar-lies { color: var(--fg-bright, #b8ffb8); letter-spacing: 1px; }
.mem-bar-seal.is-done { color: var(--fg, #5fff7e); letter-spacing: 1px; }
.mem-bar-lock { color: var(--red, #ff4d5a); }
.mem-bar-track { margin-left: auto; display: flex; gap: 6px; }

/* ---------- modals ---------- */
.mem-quote { font-family: Georgia, serif; font-style: italic; font-size: 15px; line-height: 1.6; margin-bottom: 12px; }
.mem-warn { color: var(--red, #ff4d5a); font-size: 12px; }
.mem-history { max-height: 60vh; overflow: auto; text-align: left; }

@media (max-width: 520px) {
  .mem-page { padding: 22px 18px 40px; min-height: 440px; }
  .mem-text p { font-size: 15.5px; text-align: left; }
  .mem-toc-num { width: 40px; }
}
