/* ═══════════════════════════════════════════════════════
   DESTROLA — SITE-WIDE QUEST LAYER  (experiments only)
   One shared source for the rail, drawer, chest, toast,
   reward, and hidden collectibles across every page.
   The DOM is injected by quest-layer.js; this is its skin.
═══════════════════════════════════════════════════════ */

/* ─── LEFT RAIL + DRAWER ──────────────────────────────── */
.ql-rail {
  --ql-offset: -330px;
  position: fixed; top: 50%; left: 0; z-index: 8000;
  display: flex; align-items: stretch;
  transform: translate(var(--ql-offset), -50%);
  transition: transform 0.5s var(--ease-smooth);
  font-family: var(--font-ui);
}
.ql-rail.open { transform: translate(0, -50%); }

.ql-panel {
  width: 330px; max-width: 86vw;
  background: linear-gradient(180deg, rgba(17,38,21,0.98), rgba(9,20,11,0.98));
  border: 1px solid var(--border-mid); border-left: none;
  border-radius: 0 12px 12px 0;
  box-shadow: 0 30px 80px rgba(0,0,0,0.7), 0 0 60px rgba(206,68,39,0.06);
  padding: 20px 20px 22px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}

.ql-tab {
  align-self: center; width: 48px;
  background: linear-gradient(180deg, rgba(206,68,39,0.18), rgba(17,38,21,0.96));
  border: 1px solid var(--border-mid); border-left: none;
  border-radius: 0 12px 12px 0;
  padding: 20px 0; cursor: pointer; user-select: none;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}
.ql-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ql-tab-label {
  writing-mode: vertical-rl; text-orientation: mixed;
  letter-spacing: 0.3em; text-transform: uppercase;
  font-size: 12px; font-weight: 700; color: var(--fg-primary);
}
.ql-tab-count { font-size: 11px; font-weight: 700; color: var(--accent); }
.ql-tab-arrow { font-size: 14px; color: var(--accent); transition: transform 0.4s var(--ease-smooth); }
.ql-rail.open .ql-tab-arrow { transform: rotate(180deg); }

/* First-load nudge — whole rail moves so the drawer body stays flush to
   the screen edge behind the tab (no gap opens up). Runs 3 times. */
.ql-rail.ql-nudge { animation: qlNudge 0.9s var(--ease-smooth) 3; }
@keyframes qlNudge {
  0%, 100% { transform: translate(var(--ql-offset), -50%); }
  50%      { transform: translate(calc(var(--ql-offset) + 12px), -50%); }
}

.ql-head { display: flex; align-items: baseline; justify-content: space-between; }
.ql-title { font-family: var(--font-display); font-size: 1.5rem; color: var(--fg-primary); letter-spacing: 0.02em; }
.ql-count { font-size: 12px; font-weight: 700; color: var(--accent); }
.ql-bar { height: 6px; background: rgba(206,68,39,0.14); border-radius: 3px; overflow: hidden; margin: 10px 0 18px; }
.ql-bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), #ff7a50);
  box-shadow: 0 0 10px var(--accent-glow);
  transition: width 0.5s var(--ease-smooth);
}

.ql-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ql-quest {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px;
  background: rgba(242,229,225,0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 6px; cursor: pointer;
  transition: border-color 0.3s, background 0.3s;
}
.ql-quest:hover { border-color: var(--border-mid); }
.ql-mark {
  width: 21px; height: 21px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: transparent;
}
.ql-quest-text { font-size: 12.5px; color: var(--fg-secondary); line-height: 1.3; }
.ql-quest-sub { display: block; font-size: 10px; color: var(--fg-muted); letter-spacing: 0.04em; margin-top: 2px; }
.ql-quest.done { border-color: var(--border-orange); background: rgba(206,68,39,0.06); }
.ql-quest.done .ql-mark { background: var(--accent); border-color: var(--accent); color: var(--bg-primary); box-shadow: 0 0 10px var(--accent-glow); }
.ql-quest.done .ql-quest-text { color: var(--fg-primary); }

.ql-chest-wrap { margin-top: 20px; text-align: center; }
.ql-chest-note { display: block; font-size: 10px; color: var(--fg-muted); letter-spacing: 0.14em; text-transform: uppercase; margin-top: 8px; }

/* Real pixel sprite — crisp upscaling, no smoothing */
.ql-chest-img {
  display: block; width: 100%; height: auto;
  image-rendering: pixelated; image-rendering: crisp-edges;
}
.ql-chest-glow {
  position: absolute; inset: -30%;
  background: radial-gradient(circle, rgba(206,68,39,0.55) 0%, transparent 70%);
  opacity: 0; transition: opacity 0.5s ease; pointer-events: none; z-index: 0;
}

.ql-mini-chest {
  width: 60px; margin: 0 auto;
  opacity: 0.35; filter: grayscale(1);
  transition: opacity 0.4s ease, filter 0.4s ease, transform 0.2s ease;
}
.ql-mini-chest.ready { cursor: pointer; }
.ql-mini-chest.ready:hover { transform: scale(1.07); }
.ql-chest-note.ready { color: var(--accent); }
.ql-mini-chest.rattle { animation: qlRattle 0.28s linear infinite; }
@keyframes qlRattle {
  0%, 100% { transform: translateX(0) rotate(0); }
  25%      { transform: translateX(-1.5px) rotate(-2deg); }
  75%      { transform: translateX(1.5px) rotate(2deg); }
}

/* ─── REWARD OVERLAY ──────────────────────────────────── */
.ql-reward {
  position: fixed; inset: 0; z-index: 9998;
  display: none; align-items: center; justify-content: center;
  background: rgba(7,15,8,0.88);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  padding: 24px;
}
.ql-reward.show { display: flex; }
.ql-reward-inner {
  text-align: center; max-width: 440px;
  transform: translateY(12px) scale(0.96); opacity: 0;
  transition: transform 0.5s var(--ease-smooth), opacity 0.5s var(--ease-smooth);
}
.ql-reward.show .ql-reward-inner { transform: none; opacity: 1; }
.ql-big-chest { position: relative; width: 150px; margin: 0 auto 28px; }
.ql-big-chest .ql-chest-img { position: relative; z-index: 1; animation: qlChestPop 0.6s var(--ease-smooth); }
@keyframes qlChestPop {
  0%   { transform: scale(0.4) rotate(-8deg); opacity: 0; }
  60%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.ql-reward.opened .ql-big-chest .ql-chest-img { animation: qlChestOpen 0.32s steps(2, end); }
@keyframes qlChestOpen {
  0%   { transform: translateY(-3px) scale(1.06); }
  100% { transform: none; }
}
.ql-reward.opened .ql-chest-glow { opacity: 1; }
.ql-reward-title { font-family: var(--font-display); font-size: 2.3rem; color: var(--fg-primary); margin: 6px 0; }
.ql-reward-sub { color: var(--fg-secondary); font-size: 14px; margin-bottom: 20px; }
.ql-code-row {
  display: flex; align-items: stretch; justify-content: center;
  gap: 8px; margin-bottom: 22px;
}
.ql-code {
  display: inline-flex; align-items: center; font-family: var(--font-ui);
  font-size: 1.4rem; font-weight: 700; letter-spacing: 0.2em; color: var(--accent);
  border: 1px dashed var(--border-orange); border-radius: 8px;
  padding: 12px 24px; background: rgba(206,68,39,0.08);
}
.ql-copy {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-ui); font-size: 12px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer;
  color: var(--fg-primary); background: rgba(206,68,39,0.14);
  border: 1px solid var(--border-orange); border-radius: 8px;
  padding: 0 16px;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.ql-copy:hover { background: rgba(206,68,39,0.28); }
.ql-copy:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ql-copy.copied { background: var(--accent); color: var(--bg-primary); border-color: var(--accent); }
.ql-reward-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ─── REWARD EMAIL CAPTURE (early-access list) ────────── */
.ql-reward-email { margin-bottom: 18px; }
.ql-reward-emailhead {
  font-family: var(--font-display); font-size: 1.2rem;
  color: var(--fg-primary); letter-spacing: 0.02em;
  margin: 0 0 5px;
}
.ql-reward-emailnote { font-size: 12px; line-height: 1.4; color: var(--fg-muted); margin: 0 auto 9px; max-width: 32ch; }
.ql-email-form {
  display: flex; flex-direction: column; gap: 8px;
  max-width: 280px; margin: 0 auto;
}
.ql-email-input {
  width: 100%;
  font-family: var(--font-ui); font-size: 13px;
  color: var(--fg-primary); background: rgba(242,229,225,0.04);
  border: 1px solid var(--border-mid); border-radius: 8px;
  padding: 9px 12px;
}
.ql-email-input::placeholder { color: var(--fg-muted); }
.ql-email-input:focus { outline: none; border-color: var(--border-orange); }
.ql-email-btn {
  width: 100%;
  font-family: var(--font-ui); font-size: 12px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer;
  color: var(--bg-primary); background: var(--accent);
  border: 1px solid var(--accent); border-radius: 8px; padding: 10px 16px;
  transition: background 0.2s ease;
}
.ql-email-btn:hover { background: #ff7a50; }
.ql-email-btn:disabled { opacity: 0.6; cursor: default; }
.ql-email-feedback { font-size: 11px; margin: 7px 0 0; min-height: 13px; }
.ql-email-feedback.ok  { color: #6fcf97; }
.ql-email-feedback.err { color: var(--accent); }

/* ─── HIDDEN-KEY QUEST (hero window minimize, homepage) ── */
.media-chrome .t-dot { transition: transform 0.15s ease, filter 0.15s ease; }
.media-chrome .t-dot-y[data-ql-minimize] { cursor: pointer; }
.media-chrome .t-dot-y[data-ql-minimize]:hover { transform: scale(1.25); filter: brightness(1.2); }
.media-chrome .t-dot-y[data-ql-minimize]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.media-frame .media-body video { transition: transform 0.45s var(--ease-smooth), opacity 0.35s ease; }
.media-frame.minimized .media-body video { transform: scale(0.04); transform-origin: 6% 0%; opacity: 0; }

.ql-secret-key {
  position: absolute; left: 50%; top: 50%; z-index: 3;
  display: block; width: 140px; height: auto;
  image-rendering: pixelated; image-rendering: crisp-edges;
  transform: translate(-50%, -50%) scale(0.55);
  opacity: 0; pointer-events: none;
  transition: opacity 0.35s ease 0.15s, transform 0.4s var(--ease-smooth) 0.15s;
}
.media-frame.minimized .ql-secret-key {
  opacity: 1; transform: translate(-50%, -50%) scale(1);
  pointer-events: auto; cursor: pointer;
  filter: drop-shadow(0 0 10px rgba(244,200,76,0.55));
  animation: keyBob 1.6s ease-in-out infinite 0.5s;
}
.ql-secret-key:hover { transform: translate(-50%, -50%) scale(1.08); }
.ql-secret-key.collected {
  animation: none;
  opacity: 0; transform: translate(-50%, -150%) scale(1.2);
  transition: opacity 0.5s ease, transform 0.5s var(--ease-smooth);
  pointer-events: none;
}
@keyframes keyBob {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50%      { transform: translate(-50%, -58%) scale(1); }
}

/* ─── HIDDEN COLLECTIBLE (gem / sword / relic on a page) ─ */
.ql-collectible {
  display: inline-block; width: 56px; height: auto;
  cursor: pointer; vertical-align: middle;
  image-rendering: pixelated; image-rendering: crisp-edges;
  filter: drop-shadow(0 0 7px rgba(244,200,76,0.30));
  animation: qlFloat 2s ease-in-out infinite;
  transition: filter 0.2s ease;
}
.ql-collectible:hover { filter: drop-shadow(0 0 16px rgba(244,200,76,0.8)); }
.ql-collectible.collected {
  animation: qlCollect 0.55s var(--ease-smooth) forwards;
  pointer-events: none;
}
@keyframes qlFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes qlCollect {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-46px) scale(1.25); opacity: 0; }
}

/* ─── QUEST TOAST ─────────────────────────────────────── */
.ql-toast {
  position: fixed; left: 50%; top: 78px; z-index: 9500;
  display: flex; align-items: center; gap: 9px;
  transform: translate(-50%, -16px); opacity: 0;
  background: rgba(17,38,21,0.97);
  border: 1px solid var(--border-orange); border-radius: 8px;
  padding: 11px 18px;
  font-family: var(--font-ui); font-size: 13px; font-weight: 600;
  letter-spacing: 0.04em; color: var(--fg-primary);
  box-shadow: 0 14px 40px rgba(0,0,0,0.6), 0 0 26px rgba(206,68,39,0.15);
  pointer-events: none;
  transition: transform 0.35s var(--ease-smooth), opacity 0.35s ease;
}
.ql-toast.show { transform: translate(-50%, 0); opacity: 1; }
.ql-toast-glyph { color: var(--accent); }

/* ─── FLIP CARD (a card whose side tab flips it to reveal a key) ─────────── */
.ql-flip { position: relative; perspective: 1200px; }
.ql-flip-inner {
  position: relative;
  display: grid;       /* both faces share one cell, so the inner sizes to the tallest face */
  min-height: 100%;    /* and still fills the stretched cell when a row neighbour is taller */
  transform-style: preserve-3d;
  transition: transform 0.6s var(--ease-smooth);
}
.ql-flip.flipped .ql-flip-inner { transform: rotateY(180deg); }
.ql-flip-face {
  grid-area: 1 / 1;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
}
.ql-flip-back {
  transform: rotateY(180deg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; text-align: center;
}
.ql-flip-back-label {
  font-family: var(--font-ui); font-size: 12.5px; line-height: 1.4;
  letter-spacing: 0.03em; color: var(--fg-secondary); max-width: 22ch;
}
.ql-flip-tab {
  position: absolute; top: calc(var(--sp-6) + 12px); left: 6px;
  z-index: 6;
  writing-mode: vertical-rl; text-orientation: mixed;
  font-family: var(--font-ui); font-size: 11px; font-weight: 700;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--accent); opacity: 0.8; cursor: pointer;
  background: none; border: none; padding: 2px;
  transition: opacity 0.2s ease;
}
.ql-flip-tab:hover { opacity: 1; }
.ql-flip-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ─── REJECTION REVEAL (coaching: click the ✗, it becomes the key) ──────── */
.ql-reject { position: relative; display: inline-block; opacity: 1; }
.ql-reject-x { display: inline-block; transition: color 0.2s ease, opacity 0.3s ease, transform 0.3s ease; }
.ql-reject:hover .ql-reject-x { color: var(--accent); }
.ql-reject.revealed .ql-reject-x { opacity: 0; transform: scale(0.4) rotate(-25deg); }
.ql-reject-key {
  position: absolute; left: 50%; top: 50%;
  width: 2.6rem; height: auto;
  transform: translate(-50%, -50%) scale(0.4);
  opacity: 0; pointer-events: none;
  image-rendering: pixelated; image-rendering: crisp-edges;
  transition: opacity 0.4s ease, transform 0.45s var(--ease-smooth);
}
.ql-reject.revealed .ql-reject-key {
  opacity: 1; pointer-events: auto; cursor: pointer;
  transform: translate(-50%, -50%) scale(1);
  filter: drop-shadow(0 0 8px rgba(244,200,76,0.5));
}
.ql-reject.revealed .ql-reject-key.collected {
  opacity: 0; pointer-events: none;
  transform: translate(-50%, -90%) scale(1.3);
  transition: opacity 0.5s ease, transform 0.5s var(--ease-smooth);
}

@media (max-width: 768px) {
  .ql-panel { width: 300px; }
  .ql-rail { --ql-offset: -300px; }
  /* Slim, low-profile handle on phones so it barely intrudes on content. */
  .ql-tab {
    width: 30px;
    padding: 12px 0;
    gap: 7px;
    opacity: 0.88;
    box-shadow: 0 10px 28px rgba(0,0,0,0.5);
  }
  .ql-tab-label { font-size: 9.5px; letter-spacing: 0.16em; }
  .ql-tab-count { font-size: 9px; }
  .ql-tab-arrow { font-size: 11px; }
  /* Smaller number on phones — the perfect alignment sits a touch higher. */
  .ql-flip-tab { top: calc(var(--sp-6) + 8px); }
}
@media (prefers-reduced-motion: reduce) {
  .ql-rail.ql-nudge { animation: none; }
  .ql-mini-chest.rattle { animation: none; }
  .ql-big-chest .ql-chest-img { animation: none; }
  .media-frame.minimized .ql-secret-key { animation: none; }
  .ql-collectible { animation: none; }
}
