/* mystery.css - PhotoPieces v2.1 Mystery deck (js/mystery.js).
   Landing tile, the shuffle/reveal stage, the in-game "Deal again" chip and
   the win-card next steps. Uses the shared tokens from styles.css.
   Source is ASCII-only; UTF-8 no BOM. */

[hidden] { display: none !important; }

/* ---------- Card back (shared by the tile and the stage) ---------- */

.mys-card { position: absolute; border-radius: 12px; }
.mys-back {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 5px solid #fff;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.14) 0 5px, transparent 5px 11px),
    linear-gradient(145deg, #F07A3F, #C94F1C);
  box-shadow: 0 4px 14px rgba(35, 38, 43, 0.28);
}
.mys-q {
  font-family: var(--font-display);
  font-weight: 700;
  color: #fff;
  font-size: 64px;
  line-height: 1;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  user-select: none;
}

/* ---------- Landing tile (#mysteryCard) ---------- */

.mystery-card { gap: var(--space-4); }
.mys-tile-deck {
  position: relative;
  flex: none;
  width: 92px;
  height: 112px;
  cursor: pointer;
}
.mys-tile-card {
  width: 72px;
  height: 100px;
  left: 10px;
  top: 6px;
  transition: transform 0.25s ease;
}
.mys-tile-card .mys-back { border-width: 3px; box-shadow: 0 2px 8px rgba(35, 38, 43, 0.22); }
.mys-tile-card .mys-q { font-size: 34px; }
.mys-tile-card--3 { transform: rotate(-10deg) translate(-6px, 2px); }
.mys-tile-card--2 { transform: rotate(6deg) translate(6px, 0); }
.mys-tile-card--1 { transform: rotate(-2deg); }
.mys-tile-deck:hover .mys-tile-card--3,
.mystery-card:focus-within .mys-tile-card--3 { transform: rotate(-16deg) translate(-12px, 4px); }
.mys-tile-deck:hover .mys-tile-card--2,
.mystery-card:focus-within .mys-tile-card--2 { transform: rotate(12deg) translate(12px, 0); }
.mys-tile-info { flex: 1; min-width: 0; }
.mys-tile-title { margin: 0 0 var(--space-1); font-size: 1.25rem; }
.mys-tile-line { margin: 0; color: var(--ink-muted); }
.mys-tile-meta { margin: var(--space-1) 0 0; font-size: 0.85rem; font-weight: 600; color: var(--accent); }
.mys-recent {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.mys-recent-label { font-size: 0.8rem; color: var(--ink-muted); }
.mys-recent-btn {
  width: 60px;   /* >= 44px touch target (QA v2.1 m8) */
  height: 45px;
  padding: 0;
  border: 2px solid var(--surface);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  background: var(--border);
}
.mys-recent-btn:hover, .mys-recent-btn:focus-visible { border-color: var(--accent); }
.mys-recent-img { display: block; width: 100%; height: 100%; object-fit: cover; }
.mys-tile-actions { flex: none; }
/* Pieces picker (Neptune 2026-11-02) */
.mys-size {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}
.mys-size-label { font-size: 0.9rem; font-weight: 600; color: var(--ink-muted); }
.mys-size-btn {
  min-width: 52px;
  min-height: 44px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}
.mys-size-btn:hover, .mys-size-btn:focus-visible { border-color: var(--primary); }
.mys-size-btn[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
/* Beat the clock (opt-in) */
.mys-clock-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  min-height: 40px;
  font-size: 0.9rem;
  cursor: pointer;
}
.mys-clock-toggle input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.mys-face-clock {
  position: relative;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: #E7F5F2;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
}
.mys-tile-btn[disabled] { opacity: 0.6; cursor: progress; }

/* ---------- Stage (shuffle + reveal overlay) ---------- */

body.mys-open { overflow: hidden; }
.mys-stage {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: rgba(20, 22, 26, 0.8);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.18s ease;
  cursor: pointer;
  outline: none;
}
.mys-stage.is-in { opacity: 1; }
.mys-stage.is-out { opacity: 0; transition-duration: 0.25s; }
.mys-table {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  color: #fff;
  text-align: center;
  max-width: 100%;
}
.mys-deck {
  position: relative;
  width: 150px;
  height: 210px;
  margin: 10px 0 var(--space-5);
}
.mys-deck > .mys-card { inset: 0; }
.mys-deck > .mys-card:not(.mys-hero) { transition: opacity 0.3s ease; }
/* Same box as the deck (inset: 0 from the rule above), on top of it */
.mys-deck > .mys-hero {
  perspective: 900px;
  opacity: 0;
}
.mys-hero-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform var(--flip-ms, 450ms) cubic-bezier(0.3, 0.7, 0.3, 1);
}
.mys-hero .mys-back,
.mys-face { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.mys-face {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
  background: #fff;
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.4);
}
/* The face never shows the picture: theme + piece count only */
.mys-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--ink);
  background: linear-gradient(160deg, #FFFFFF, #FBF1E8);
  border: 5px solid #fff;
  padding: 10px;
}
.mys-face-mark {
  position: relative;
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mys-face-piece { position: absolute; inset: 0; width: 100%; height: 100%; color: var(--primary); opacity: 0.16; }
.mys-face-q {
  position: relative;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 54px;
  line-height: 1;
  color: var(--primary);
}
.mys-face-cat {
  position: relative;
  margin-top: 6px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.2;
  text-align: center;
}
.mys-face-n { position: relative; font-size: 0.78rem; color: var(--ink-muted); font-weight: 600; }
/* Reveal: the top card turns over */
.mys-stage.is-reveal .mys-deck > .mys-hero,
.mys-stage.is-still-reveal .mys-deck > .mys-hero { opacity: 1; }
.mys-stage.is-reveal .mys-hero-inner,
.mys-stage.is-still-reveal .mys-hero-inner { transform: rotateY(180deg); }
.mys-stage.is-reveal .mys-deck > .mys-card:not(.mys-hero),
.mys-stage.is-still-reveal .mys-deck > .mys-card:not(.mys-hero) { opacity: 0; }
.mys-stage.is-still-reveal .mys-hero-inner { transition: none; }
.mys-stage.is-still-reveal .mys-hero { transition: opacity 0.2s ease; }
.mys-caption { margin: 0; font-size: 1rem; opacity: 0.9; }
.mys-title {
  margin: 0;
  min-height: 1.3em;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.3rem, 5vw, 1.8rem);
}
.mys-hint { margin: var(--space-1) 0 0; font-size: 0.8rem; opacity: 0.7; }

/* ---------- In-game "Deal again" chip ---------- */

.mys-deal-again {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--accent);
  background: #E7F5F2;
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.mys-deal-again:hover { background: var(--accent); color: #fff; }
.mys-deal-icon { font-size: 1.1rem; line-height: 1; }
@media (max-width: 600px) {
  /* nothing placed yet while the chip shows, so "0% placed" can make room */
  .screen-game.has-deal-again .hud-percent { display: none; }
}
@media (max-width: 420px) {
  .mys-deal-again { width: 40px; padding: 0; justify-content: center; }
  .mys-deal-text { display: none; }
}

/* ---------- In-game pill: milestone teasers + the reveal caption ---------- */

.mys-pill {
  position: absolute;
  z-index: 40;
  transform: translate(-50%, 0) translateY(-6px);
  max-width: min(90%, 420px);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  background: rgba(35, 38, 43, 0.86);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  text-align: center;
  white-space: normal;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.mys-pill.is-on { opacity: 1; transform: translate(-50%, 0); }
.mys-pill.is-board { transform: translate(-50%, -100%) translateY(6px); }
.mys-pill.is-board.is-on { transform: translate(-50%, -100%); }
.mys-pill--reveal {
  font-size: 1.2rem;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
}
.mys-pill--reveal strong { color: var(--primary); }
.mys-pill--clue { font-weight: 500; font-style: italic; }
.mys-pill-label { font-style: normal; font-weight: 700; color: #FFD9C7; }

/* ---------- Win card: the reveal line + next steps ---------- */

.mys-win-reveal {
  margin: 0 0 var(--space-2);
  font-size: 1.05rem;
  color: var(--ink);
}
.mys-win-reveal strong { font-family: var(--font-display); color: var(--primary); }

.mys-win-next {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.mys-win-btn { flex: 1 1 130px; }

/* ---------- Phones ---------- */

@media (max-width: 560px) {
  .mystery-card { flex-direction: column; align-items: center; text-align: center; }
  .mys-recent { justify-content: center; }
  .mys-size { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .mys-tile-card, .mys-stage, .mys-hero, .mys-hero-inner { transition: none !important; }
}
