/* static/css/04_paper.css
   The paper layer: ako.ma on dark paper, inked in cream, with painted
   headings. Loaded last, so it re-tints the design tokens (00_tokens.css)
   and dresses the shell (02_shell.css) without touching either; delete the
   <link> in index.html to go back.

   Paper is near-black stock, #131010, with a fine pale fibre grain and
   small, dense markings, very faint (within one level of #131010 on a
   screenshot). The site is dark paper only.

   Kept cheap to paint: both textures are small tiles that scroll with the
   page, rasterised once. No background-attachment: fixed, which repaints
   the whole window on every scroll, and no blur behind the top bar. The
   noise tiles seamlessly because each filter region is the tile itself and
   baseFrequency x tile size is a whole number (.85 x 220, .076923 x 260,
   .1 x 260).
*/

/* ---------- Paper (dark) ---------- */

:root,
:root[data-theme="light"],
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #131010;
  --bg-elevated: #1a1615;
  --surface: #1c1817;
  --surface-2: #211c1a;
  --border: #3a312b;

  --text: #e4d9c3;
  --text-muted: #a6977e;
  --heading: #f2e9d6;

  /* Akoma green, as on the brand mark: bright ink on dark stock. */
  --accent: #24d599;
  --accent-600: #1fbf86;
  --accent-700: #3fdda6;
  --accent-800: #10734f;
  --accent-contrast: #0b1712;

  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);

  --shadow-1:
    0 1px 0 rgba(242, 233, 214, 0.04) inset,
    0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-2:
    0 1px 0 rgba(242, 233, 214, 0.05) inset,
    0 2px 3px rgba(0, 0, 0, 0.35),
    0 10px 26px rgba(0, 0, 0, 0.45);

  --wiki-glow: transparent;
  --wiki-panel: color-mix(in srgb, var(--surface) 90%, transparent);
  --wiki-panel-strong: color-mix(in srgb, var(--surface-2) 94%, transparent);
  --wiki-hairline: rgba(228, 217, 195, 0.07);

  --font-display: "EB Garamond", "Cormorant Garamond", Georgia, "Times New Roman", serif;

  /* Fine pale fibres and small paper markings, both as tiles. */
  --paper-grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='g' x='0' y='0' width='100%' height='100%'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .89  0 0 0 0 .85  0 0 0 0 .76  0 0 0 .005 0'/></filter><rect width='100%' height='100%' filter='url(%23g)'/></svg>");
  --paper-mottle: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='260' height='260'><filter id='m' x='0' y='0' width='100%' height='100%'><feTurbulence type='fractalNoise' baseFrequency='.076923 .1' numOctaves='3' seed='7' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .42  0 0 0 0 .36  0 0 0 0 .30  0 0 0 .016 -.007'/></filter><rect width='100%' height='100%' filter='url(%23m)'/></svg>");
  --paper-ink-line: rgba(228, 217, 195, 0.13);

  /* The whole texture, for any area: fibres over markings. Both SVGs carry
     their tile size, so no background-size is needed. */
  --paper: var(--paper-grain), var(--paper-mottle);

  /* The bare stock under the grain and markings, which only add light: a
     shade under --bg so the finished page measures #131010 (median, on a
     screenshot). */
  --paper-stock: #121010;
}

/* ---------- The sheet ---------- */

body {
  background-color: var(--paper-stock);
  background-image: var(--paper);
}

/* The shell lets the sheet show through instead of repainting its own. */
.shell {
  background: transparent;
}

/* The rail and the bar are the same paper, a shade lifted, ruled off in ink.
   The bar is opaque: a blur behind it re-renders on every scroll. */
.topbar {
  background-color: var(--bg-elevated);
  background-image: var(--paper);
  border-bottom: 1px solid var(--paper-ink-line);
  backdrop-filter: none;
}

.topbar__brandwrap,
.shell-body > .sidebar {
  background-color: var(--surface-2);
  background-image: var(--paper), linear-gradient(90deg, transparent 92%, rgba(0, 0, 0, 0.18));
  border-color: var(--paper-ink-line);
}

/* ---------- Every other area is the same paper ----------
   03_components.css paints each panel with the background shorthand, which
   clears any image, so the paper is laid back on here (this file loads
   last). Hover states keep their own colours; the texture is too faint to
   miss on them. */

/* Flat-coloured areas: the paper over their own colour. */
input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select,
.input,
.textarea,
table,
.notice,
.notice.success,
.notice.warn,
.auth-logged-in,
.auth-modal,
.profile-dropdown,
.pill-btn,
.pill-menu,
.notify,
.tooltip,
.store-cart-rail,
.cart-row,
.akoma-balance,
.ako-balance-pill,
.slot,
.user-card,
.user-pill,
.profile-card,
.profile-stat,
.profile__header,
.achievement-card,
.achievement,
.achievement-row,
.board-feed-loading,
.soul-panel,
.soul-reveal,
.soul-side,
.ako-wheel,
.wiki-create,
.devblog-card,
.devblog-post-hero,
.devblog-md,
.chat--full,
.chat__actions,
.chat__composer textarea,
.tx-bubble--in,
.prealpha-box--locked,
.error,
.swapped-modal {
  background-image: var(--paper);
}

/* Areas with a top-down sheen: the paper over the sheen. */
.surface,
.card,
.settings__group,
.board-post-card,
.board-card,
.devblog-post-card,
.devblog-update-card,
.wiki-home-section,
.wiki-search-card,
.wiki-search-item,
.profile__card,
.vault-card {
  background-image:
    var(--paper),
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), rgba(255, 255, 255, 0.004));
}

.devblog-editor-grid {
  background-color: var(--surface);
  background-image: var(--paper), linear-gradient(180deg, var(--bg-elevated), var(--surface));
}

/* ---------- Painted type ---------- */

h1, h2, h3,
.home__title,
.devblog-detail__titleblock h1,
.wiki-head h1 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--heading);
}

.home__title {
  font-size: clamp(2.6rem, 6vw, 4.6rem);
  line-height: 1.02;
}

.home__eyebrow {
  color: var(--accent-700);
}

/* An ink rule that fades out, like a pen lifting. */
.home__rule {
  background: linear-gradient(90deg, var(--accent) 0%, var(--paper-ink-line) 30%, transparent 80%);
}

/* ---------- Cards are sheets laid on the page ---------- */

.home__card,
.home__clip,
.prealpha-box,
.storyprompt {
  background-color: var(--surface);
  background-image: var(--paper);
  border: 1px solid var(--paper-ink-line);
  box-shadow: var(--shadow-2);
}

/* A slight, alternating tilt: hand-placed, not gridded. */
.home__clip:nth-child(odd) { transform: rotate(-0.35deg); }
.home__clip:nth-child(even) { transform: rotate(0.3deg); }
.home__clip:hover { transform: rotate(0) translateY(-2px); }
.home__clip { transition: transform 0.2s ease; }

.home__clip img {
  border-bottom: 1px solid var(--paper-ink-line);
}

.home__clip figcaption {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-style: italic;
  color: var(--text-muted);
}

.home__card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--paper-ink-line));
}

/* The call to action: a wax-green stamp. */
.home__cta {
  background: var(--accent);
  background-image: var(--paper);
  color: var(--accent-contrast);
  border: 1px solid var(--accent-700);
  border-radius: 6px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.25) inset,
    0 2px 0 var(--accent-800),
    0 8px 18px rgba(26, 143, 102, 0.22);
  font-family: var(--font-display);
  font-size: 1.2rem;
  letter-spacing: 0.01em;
}

.home__cta:hover:not(:disabled) {
  background-color: var(--accent-600);
}

/* ---------- Reading pages ---------- */

.devblog-md__image img,
.wiki-md img {
  border: 1px solid var(--paper-ink-line);
  border-radius: 4px;
  box-shadow: var(--shadow-1);
}

blockquote {
  border-left: 3px solid var(--paper-ink-line);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.08em;
}

hr {
  border: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--paper-ink-line), transparent);
}

::selection {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}

/* ---------- Devblog: the change list (+ features, ~ changes, - removals) ---------- */

.changelog {
  display: grid;
  gap: 14px;
  margin: 28px 0 8px;
}

.changelog__section {
  --cl: #8cc95a;        /* features: leaf green */
  --cl-band: rgba(140, 201, 90, 0.14);
  border: 1px solid var(--paper-ink-line);
  border-radius: 8px;
  overflow: hidden;
  background-color: var(--surface);
  background-image: var(--paper);
  box-shadow: var(--shadow-1);
}

.changelog__section--change {
  --cl: #e2b440;        /* changes: ochre yellow */
  --cl-band: rgba(226, 180, 64, 0.14);
}

.changelog__section--remove {
  --cl: #e0705f;        /* removals: brick red */
  --cl-band: rgba(224, 112, 95, 0.14);
}

.changelog__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 12px 16px;
  background: linear-gradient(90deg, var(--cl-band), transparent 85%);
  border-bottom: 1px solid var(--paper-ink-line);
  color: var(--cl);
  font-family: var(--font-display);
  font-size: 1.2rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.changelog__mark {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--cl);
  color: var(--bg);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1;
}

.changelog__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.changelog__list li {
  position: relative;
  padding: 9px 16px 9px 34px;
  color: var(--text);
  border-bottom: 1px solid var(--wiki-hairline);
}

.changelog__list li:nth-child(even) {
  background: rgba(228, 217, 195, 0.03);
}

.changelog__list li:last-child {
  border-bottom: 0;
}

.changelog__list li::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 50%;
  width: 5px;
  height: 5px;
  margin-top: -2.5px;
  border-radius: 50%;
  background: var(--cl);
}

/* ---------- Devblog: live edits (admin) ---------- */

.tx-tools {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin: 6px 0 2px;
  opacity: 0.55;
  transition: opacity 0.15s ease;
}

.tx-frag:hover .tx-tools,
.tx-tools--block,
.tx-tools:focus-within {
  opacity: 1;
}

.tx-tools__btn {
  border: 1px solid var(--paper-ink-line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  padding: 2px 10px;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.tx-tools__btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.tx-tools__btn--danger:hover {
  color: #e0705f;
  border-color: #e0705f;
}

.tx-edit {
  display: grid;
  gap: 8px;
  margin: 10px 0;
  padding: 12px;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  background: var(--surface);
}

.tx-edit__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------- Devblog: comments (anyone) ---------- */

.devblog-comments {
  margin: 36px 0 10px;
  padding-top: 18px;
  border-top: 1px solid var(--paper-ink-line);
}

.devblog-comments__title {
  margin: 0 0 12px;
  font-family: var(--font-display);
}

.devblog-comments__list {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.devblog-comment {
  padding: 10px 14px;
  border: 1px solid var(--paper-ink-line);
  border-radius: 8px;
  background-color: var(--surface);
  background-image: var(--paper);
}

.devblog-comment__head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 0.86rem;
}

.devblog-comment__name {
  font-weight: 700;
  color: var(--heading);
}

.devblog-comment__guest {
  padding: 0 6px;
  border: 1px solid var(--paper-ink-line);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.devblog-comment__when {
  color: var(--text-muted);
}

.devblog-comment__head .tx-tools__btn {
  margin-left: auto;
}

.devblog-comment__body {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.devblog-comments__form {
  display: grid;
  gap: 8px;
}

.devblog-comments__form .btn {
  justify-self: end;
}

.devblog-comments__name {
  max-width: 260px;
}

/* ---------- Linux install dialog (launcher_download.rs) ---------- */

.storyprompt.linux-install { width: min(600px, 92vw); max-width: 600px; }
.linux-install__cmd {
  margin: 12px 0 4px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-all;
  user-select: all;
  color: var(--text);
}
.linux-install__cmd code {
  background: none;
  color: inherit;
  padding: 0;
  border: 0;
  box-shadow: none;
  font-family: ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;
}
.linux-install__cmd { text-align: left; }
.linux-install__alt { margin: 12px 0 0; font-size: 0.85rem; }
.linux-install__alt a { color: var(--accent-700); text-decoration: underline; }

/* ---------- Swapped card checkout (store_cart_rail.rs) ---------- */

.swapped-modal {
  width: min(480px, 94vw);
  height: min(720px, 90vh);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.swapped-modal__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.swapped-modal__bar a { margin-left: auto; font-size: 0.85rem; color: var(--accent-700); }
.swapped-modal__close {
  border: 0;
  background: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
}
.swapped-modal__body { position: relative; flex: 1; display: flex; }
.swapped-modal__loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
}
.swapped-modal__frame { flex: 1; width: 100%; border: 0; background: transparent; opacity: 0; transition: opacity .2s; }
.swapped-modal__frame.is-loaded { opacity: 1; }

/* ---------- Codex: pages that come from the game (wiki.rs) ---------- */

.wiki-from-game {
  align-self: center;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--paper-ink-line));
  color: var(--accent-700);
}
