/* static/css/04_paper.css
   The paper layer: ako.ma on cream paper, inked in sepia, 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 warm cream stock with a fine grain and soft, lighter blotches,
   like watercolour paper. The site is paper only: there is no dark theme.
*/

/* ---------- Paper (light) ---------- */

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

  --bg: #efe6d1;
  --bg-elevated: #f6efdf;
  --surface: #f8f2e4;
  --surface-2: #efe5cf;
  --border: #d3c29f;

  --text: #3a3024;
  --text-muted: #76664d;
  --heading: #2b2117;

  /* Akoma green, deepened to read as ink on cream. */
  --accent: #1a8f66;
  --accent-600: #157a57;
  --accent-700: #116447;
  --accent-800: #0c4c36;
  --accent-contrast: #fffaf0;

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

  --shadow-1:
    0 1px 0 rgba(255, 252, 242, 0.7) inset,
    0 1px 2px rgba(92, 70, 36, 0.12);
  --shadow-2:
    0 1px 0 rgba(255, 252, 242, 0.75) inset,
    0 2px 3px rgba(92, 70, 36, 0.10),
    0 10px 26px rgba(92, 70, 36, 0.14);

  --wiki-glow: rgba(255, 252, 240, 0.65);
  --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(92, 70, 36, 0.10);

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

  /* Fine fibre grain and broad mottling, 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'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .36  0 0 0 0 .28  0 0 0 0 .17  0 0 0 .10 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='1000' height='1000'><filter id='m'><feTurbulence type='fractalNoise' baseFrequency='.005' numOctaves='4' seed='7' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 .99  0 0 0 0 .94  0 0 0 1.4 -.55'/></filter><rect width='100%' height='100%' filter='url(%23m)'/></svg>");
  --paper-ink-line: rgba(92, 70, 36, 0.22);
}

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

body,
.shell {
  background-color: var(--bg);
  background-image: var(--paper-grain), var(--paper-mottle);
  /* The mottling is stretched over the window, never tiled: no seams. */
  background-size: 220px 220px, cover;
  background-repeat: repeat, no-repeat;
  background-attachment: fixed, fixed;
}

/* The rail and the bar are the same paper, a shade deeper, ruled off in ink. */
.topbar {
  background-color: color-mix(in srgb, var(--bg) 86%, transparent);
  background-image: var(--paper-grain);
  border-bottom: 1px solid var(--paper-ink-line);
}

.topbar__brandwrap,
.shell-body > .sidebar {
  background-color: var(--surface-2);
  background-image: var(--paper-grain), linear-gradient(90deg, transparent 92%, rgba(92, 70, 36, 0.06));
  background-size: 220px 220px, 100% 100%;
  border-color: var(--paper-ink-line);
}

/* ---------- 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-grain);
  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-grain);
  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: #4f8a2b;        /* features: leaf green */
  --cl-band: rgba(98, 150, 52, 0.16);
  border: 1px solid var(--paper-ink-line);
  border-radius: 8px;
  overflow: hidden;
  background-color: var(--surface);
  background-image: var(--paper-grain);
  box-shadow: var(--shadow-1);
}

.changelog__section--change {
  --cl: #a87a12;        /* changes: ochre yellow */
  --cl-band: rgba(214, 168, 44, 0.18);
}

.changelog__section--remove {
  --cl: #b0413a;        /* removals: brick red */
  --cl-band: rgba(196, 72, 60, 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: #fffaf0;
  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(92, 70, 36, 0.035);
}

.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: #b0413a;
  border-color: #b0413a;
}

.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-grain);
}

.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; }
