/* Paper & Pencil skin + play layer for rebus collections (.rebus-play pages only).
   Loaded ONLY on collections whose dataFile starts with "rebus-"; the rest of
   the site never sees this file. global.css is untouched (ARCADE_SPEC rule). */

@font-face {
  font-family: "Baloo 2";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/fonts/baloo2-800.woff2") format("woff2");
}
@font-face {
  font-family: "Caveat";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/caveat-700.woff2") format("woff2");
}

/* Tokens live on :root, not .rebus-play: the play layer injects .rp-bar,
   .rp-tabs and .rp-badges as SIBLINGS of #puzzle-list, outside .rebus-play,
   where scoped vars resolve to nothing (transparent sticky bar overlapping
   the level chips on mobile was exactly this). rebus.css only loads on
   rebus pages, so :root scope is safe. */
:root {
  --rp-card: #fffdf7;
  --rp-ink: #241456;
  --rp-ink-soft: #5d4e96;
  --rp-accent: #ff5a5f;
  --rp-border: #e7e2f4;
  --rp-gold: #e8a417;
  --rp-green: #2e9e6b;
  --rp-chip: #f4f0e6;
}

/* --- pilot parity: page ground + card grid ----------------------------- */
body:has(.rebus-play) {
  background: #241456;
}
ol.rebus-play {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
  list-style: none;
  padding: 0;
}
.rebus-play li.riddle-card { margin: 0; }
.rebus-play li.riddle-card.rp-hide { display: none; }

/* --- level tabs -------------------------------------------------------- */
.rp-tabs {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  margin: 0 0 16px;
}
.rp-tabs button {
  font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 13px;
  color: #EDE9FB; background: transparent;
  border: 2px dashed #A99BD8; border-radius: 10px;
  padding: 6px 13px; cursor: pointer;
}
.rp-tabs button.active {
  background: var(--rp-card); color: var(--rp-ink);
  border-style: solid; border-color: var(--rp-border);
}
.rp-tabs button.locked { opacity: 0.45; }
.rp-tabs button b { color: var(--rp-gold); font-size: 11px; }
.rp-locknote {
  text-align: center; font-family: "Caveat", cursive; font-weight: 700;
  font-size: 24px; color: #A99BD8; margin: 26px 0;
}

/* --- badges ------------------------------------------------------------ */
.rp-badges {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  margin: 0 0 14px;
}
.rp-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: #A99BD8;
  border: 1.5px dashed #A99BD8; border-radius: 10px;
  padding: 4px 10px; opacity: 0.55;
}
.rp-badge.earned {
  opacity: 1; background: var(--rp-card); color: var(--rp-ink);
  border: 1.5px solid var(--rp-border);
}
.rp-badge .bico { filter: grayscale(1); font-size: 14px; }
.rp-badge.earned .bico { filter: none; }

/* --- paper card ------------------------------------------------------- */
.rebus-play li.riddle-card {
  background: var(--rp-card);
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="180" height="180"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="2" stitchTiles="stitch"/><feComponentTransfer><feFuncA type="linear" slope="0.045"/></feComponentTransfer></filter><rect width="100%25" height="100%25" filter="url(%23n)"/></svg>');
  border: 1.5px solid var(--rp-border);
  border-radius: 20px;
  color: var(--rp-ink);
  box-shadow: 0 10px 26px rgba(36, 20, 86, 0.18);
}
.rebus-play li.riddle-card.rp-done {
  border-color: #7acb9f;
  border-width: 2px;
}
.rebus-play li.riddle-card .riddle-q {
  font-family: "Baloo 2", sans-serif;
  font-weight: 800;
  color: var(--rp-ink-soft);
}
.rebus-play li.riddle-card .riddle-num {
  color: var(--rp-accent);
}
.rebus-play li.riddle-card .svg-wrap {
  color: var(--rp-ink); /* currentColor ink lands on paper, not on the dark theme */
}
/* Compactness: scale the whole SVG down instead of cropping its canvas.
   Empty space inside the 480x360 frame is often MEANINGFUL (a small word in
   a big empty canvas reads as "little"), so proportions must survive; the
   card just should not eat two phone screens. */
.rebus-play li.riddle-card .svg-wrap svg {
  max-height: min(300px, 40vh);
  width: auto;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}
.rebus-play li.riddle-card .reveal,
.rebus-play li.riddle-card .reveal summary {
  color: var(--rp-ink-soft);
}
.rebus-play li.riddle-card .reveal p {
  color: var(--rp-ink);
}

/* Native widgets (mcq choices, type-answer, emoji prompts) restyled for the
   paper card so mixed sections read as the same game. */
.rebus-play li.riddle-card .choice {
  background: #fff;
  color: var(--rp-ink);
  border: 2px solid var(--rp-border);
}
.rebus-play li.riddle-card .choice:hover { background: var(--rp-chip); }
.rebus-play li.riddle-card .ta-input {
  background: #fff;
  color: var(--rp-ink);
  border: 2px solid var(--rp-border);
}
.rebus-play li.riddle-card .emoji-q { color: var(--rp-ink); }
.rebus-play li.riddle-card .explain,
.rebus-play li.riddle-card .ta-feedback { color: var(--rp-ink-soft); }

/* JS active: native reveal/hint toggles hide, the play layer replaces them.
   Both stay in the server HTML (SEO + no-JS keep working). */
body:not(.quiz-mode) .rebus-play li.riddle-card.rp-js > details.reveal {
  display: none;
}
body.quiz-mode .rebus-play .rp-top,
body.quiz-mode .rebus-play .rp-form,
body.quiz-mode .rebus-play .rp-note,
body.quiz-mode .rebus-play .rp-hintbtn,
body.quiz-mode .rebus-play .rp-hinttext,
body.quiz-mode .rebus-play .rp-revealbtn,
body.quiz-mode .rebus-play .rp-solvedbox,
body.quiz-mode .rp-bar {
  display: none;
}

/* --- play layer ------------------------------------------------------- */
.rp-bar {
  position: sticky;
  top: calc(var(--topbar-h, 3.5rem) + 8px);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--rp-card);
  border: 1.5px solid var(--rp-border);
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(36, 20, 86, 0.22);
  padding: 8px 16px;
  margin: 0 0 14px;
  font-family: "Baloo 2", sans-serif;
  font-weight: 800;
  color: var(--rp-ink);
}
/* Blitz hides all browse chrome (arcade.css body.arcade-mode block); the
   wallet bar is injected as a sibling of #puzzle-list, so it must opt in.
   Zen (body.quiz-mode) keeps the bar: the play layer stays live there. */
body.arcade-mode .rp-bar { display: none; }

.rp-bar .rp-wallet { color: #946200; font-size: 17px; }
.rp-bar .rp-solved { color: var(--rp-green); font-size: 14px; }

/* Consecutive duplicate prompts collapse; the run's first card keeps its
   prompt so every mechanic switch is still announced. */
.rebus-play li.riddle-card.rp-prompt-dup .rp-prompt { display: none; }

/* Game-cycle cleanup (owner 2026-07-16): the campaign (PLAY -> lobby -> map)
   IS the game on rebus pages. The old browse gamification chrome duplicated
   it inconsistently, so it is hidden here (DOM stays: SEO surfaces, counts
   and the no-JS experience are untouched; this file loads on rebus pages
   only). Cards below remain a clean solvable catalog.
   NOTE for no-JS visitors: these rules only matter when the play layer runs;
   without JS the engine bar is [hidden] server-side anyway. */
body:has(.rebus-play) .engine-bar-slot,
.rp-tabs,
.rp-badges,
.rp-locknote,
.rp-bar,
.rebus-play li.riddle-card .rp-top,
.rebus-play li.riddle-card .rp-playbar { display: none; }
/* the campaign card keeps its (own) power-up row; the hidden rp-playbar is
   the browse economy chrome, which now lives only in the campaign HUD */
/* With the level tabs gone, level pagination has no navigation: neutralize
   rp-hide so the browse catalog shows ALL cards (the campaign is the game;
   browse is the full solvable list). Also lets the campaign stage present
   any card regardless of its browse-level index. */
.rebus-play li.riddle-card.rp-hide { display: list-item; }

.rp-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 6px 0 8px;
}
.rp-hearts { font-size: 13px; letter-spacing: 0.06em; }
.rp-dots i {
  width: 7px; height: 7px; border-radius: 50%;
  border: 1.5px solid var(--rp-border); display: inline-block; margin-left: 2px;
}
.rp-dots i.on { background: var(--rp-gold); border-color: var(--rp-gold); }
.rp-playbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin: 2px 0 6px;
}
.rp-reward {
  font-family: "Baloo 2", sans-serif; font-weight: 800;
  font-size: 15px; color: #946200; font-variant-numeric: tabular-nums;
}
.rp-hintsbox { display: flex; flex-direction: column; gap: 2px; }
.rp-startotal { font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 14px; }
.rp-reset {
  font-size: 11px; color: var(--rp-ink-soft); background: none; border: none;
  cursor: pointer; text-decoration: underline dotted; padding: 4px 6px;
}
body.quiz-mode .rebus-play .rp-playbar,
body.quiz-mode .rebus-play .rp-hintsbox,
body.quiz-mode .rp-tabs,
body.quiz-mode .rp-badges,
body.quiz-mode .rp-locknote,
body.arcade-mode .rp-tabs,
body.arcade-mode .rp-badges,
body.arcade-mode .rp-locknote {
  display: none;
}
/* Zen and Blitz manage card visibility themselves: neutralize level hiding */
body.quiz-mode .rebus-play li.riddle-card.rp-hide,
body.arcade-mode .rebus-play li.riddle-card.rp-hide {
  display: list-item;
}
.rp-check {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--rp-green); color: #fff;
  font-size: 14px; font-weight: 800;
  display: none; align-items: center; justify-content: center; line-height: 1;
}
.rp-done .rp-check { display: inline-flex; }
.rp-stars { font-size: 13px; }

.rp-form { display: flex; gap: 8px; margin-top: 8px; }
.rp-form[hidden] { display: none; }
.rp-input {
  flex: 1; min-width: 0;
  font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 16px;
  color: var(--rp-ink);
  background: #fff;
  border: 2px solid var(--rp-border);
  border-radius: 10px;
  padding: 9px 12px;
}
.rp-input::placeholder { color: #b7b0cc; }
.rp-input:focus-visible {
  outline: none; border-color: var(--rp-ink-soft);
  box-shadow: 0 0 0 3px rgba(93, 78, 150, 0.18);
}
.rp-go {
  font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 14px;
  color: #fff; background: var(--rp-green);
  border: none; border-radius: 10px; padding: 9px 18px;
  box-shadow: 0 3px 0 #1f7a50; cursor: pointer;
}
.rp-go:active { transform: translateY(2px); box-shadow: 0 1px 0 #1f7a50; }
.rp-go:focus-visible { outline: 3px solid var(--rp-gold); outline-offset: 2px; }

.rp-hintbtn {
  font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 13px;
  color: var(--rp-ink-soft); background: transparent;
  border: 2px dashed var(--rp-ink-soft); border-radius: 10px;
  padding: 5px 12px; cursor: pointer; margin-top: 8px;
}
.rp-hintbtn:hover { background: var(--rp-chip); }
.rp-hintbtn:disabled { opacity: 0.35; cursor: default; background: transparent; }
.rp-hintbtn small { color: var(--rp-accent); font-size: 11px; }

.rp-note {
  font-family: "Caveat", cursive; font-weight: 700; font-size: 20px;
  min-height: 26px; color: var(--rp-accent);
  margin: 6px 2px 0; transform: rotate(-0.8deg);
}
.rp-note.ok { color: var(--rp-green); }
.rp-hinttext {
  font-family: "Caveat", cursive; font-weight: 700; font-size: 19px;
  color: var(--rp-ink-soft); margin: 4px 0 0; transform: rotate(-0.6deg);
}
.rp-hinttext::before { content: "✎ "; color: var(--rp-accent); }

.rp-revealbtn {
  font-size: 13px; color: var(--rp-ink-soft);
  background: none; border: none; cursor: pointer;
  text-decoration: underline dotted; padding: 10px 14px; min-height: 40px; margin-top: 2px;
}

.rp-solvedbox { text-align: center; padding-top: 4px; }
.rp-answer {
  font-family: "Caveat", cursive; font-weight: 700; font-size: 32px;
  color: var(--rp-ink); margin: 2px 0 0; transform: rotate(-2deg);
}
.rp-why { font-size: 12.5px; color: var(--rp-ink-soft); margin: 2px 0 0; }

.rp-shake { animation: rp-shake 0.4s ease; }
@keyframes rp-shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}
.rp-pop .svg-wrap { animation: rp-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes rp-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

#rp-fx {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 60;
}

@media (prefers-reduced-motion: reduce) {
  .rp-shake, .rp-pop .svg-wrap { animation: none; }
}

/* Night-town backdrop on rebus pages (owner: one world on the page too, not
   flat purple). Viewport-fixed pseudo-element, NOT background-attachment:
   fixed - iOS Safari degrades that to scroll and zooms `cover` against the
   page height. Sits under all content, above the body background. */
body:has(.rebus-play)::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(26, 14, 66, 0.55) 0%, rgba(26, 14, 66, 0.78) 100%),
    url("/images/map/lobby-bg.webp") center bottom / cover no-repeat;
}
