/* === Rug Wash === */

main { max-width: 720px; }

/* compact header so the rug + tools fit on one screen (hints replace the rulebook) */
.header { margin-bottom: 0.3rem; }
.subtitle { margin: 0 0 0.7rem; }

/* --- Tools --- */
.rw-tools { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.rw-tool {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--card);
  font-weight: 600;
  font-size: 0.9rem;
}
.rw-tool:hover { border-color: var(--primary); transform: translateY(-1px); }
.rw-tool.picked { background: var(--pick-bg); border-color: var(--pick-border); color: var(--primary-dark); font-weight: 700; }
.rw-tool-dot { display: inline-block; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.rw-tool-dot.big { width: 18px; height: 18px; }
.rw-tool-dot.mid { width: 13px; height: 13px; }
.rw-tool-dot.sm  { width: 8px;  height: 8px; }
.rw-tool-dot.jet { width: 14px; height: 14px; background: linear-gradient(90deg, var(--accent), transparent); border-radius: 4px; }
.rw-tool-sep { width: 2px; height: 26px; background: var(--border); border-radius: 2px; align-self: center; margin: 0 0.15rem; }
.rw-soap.picked { background: #eafaf0; border-color: #8fd6ad; color: #2f7d52; }

/* --- Progress --- */
.rw-progress {
  height: 12px;
  border-radius: 999px;
  background: var(--card);
  border: 2px solid var(--border);
  overflow: hidden;
  margin-bottom: 0.6rem;
}
.rw-progress-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--primary));
  transition: width 0.2s ease;
}

.rw-hint {
  margin: 0 0 0.8rem;
  padding: 0.55rem 0.85rem;
  background: var(--card);
  border: 2px solid var(--border);
  border-left: 5px solid var(--accent);
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.86rem;
}
.rw-hint b { color: var(--ink); font-weight: 700; }

/* --- Stage --- */
.rw-stage {
  position: relative;
  width: 100%;
  margin: 0 auto;          /* center when narrowed to fit a tall (portrait) rug */
  border-radius: 14px;
  overflow: hidden;
  background: #2a2118;
  box-shadow: var(--shadow);
  min-height: 220px;
  touch-action: none;
}
/* smooth "expand" when the rug is revealed clean */
.rw-stage.rw-grown { transition: width 0.5s ease, height 0.5s ease; }
.rw-rug {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.rw-dirt {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
}
.rw-dirt:active { cursor: grabbing; }
.rw-layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.rw-cursor {
  position: absolute;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 4px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: none;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.4);
}
/* Scrubber — small chunky pad with a hatched scrub face */
.rw-cursor.scrub {
  border-radius: 3px;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.25) 0 2px, transparent 2px 5px),
    rgba(120, 110, 130, 0.25);
}
/* Brush — wide head with bristles along the bottom edge */
.rw-cursor.brush {
  border-radius: 5px 5px 2px 2px;
  background: rgba(180, 130, 80, 0.22);
}
.rw-cursor.brush::after {
  content: "";
  position: absolute;
  left: 1px; right: 1px; bottom: -6px;
  height: 7px;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,0.95) 0 2px, transparent 2px 5px);
}
/* Power washer — narrow nozzle with a spray tip */
.rw-cursor.washer {
  border-radius: 3px;
  background: rgba(120, 200, 255, 0.22);
  border-color: rgba(180, 225, 255, 0.95);
}
.rw-cursor.washer::before {
  content: "";
  position: absolute;
  top: -7px; left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 7px solid rgba(180, 225, 255, 0.95);
}
/* Sponge — big soft rounded block, warm tint */
.rw-cursor.sponge {
  border-radius: 28% / 36%;
  background: rgba(255, 232, 130, 0.2);
  border-color: rgba(255, 240, 165, 0.95);
  border-width: 3px;
}
/* Soap applicators — bubbly suds and a degreaser bottle */
.rw-cursor.suds {
  border-radius: 42%;
  border-style: dashed;
  background: rgba(255, 255, 255, 0.26);
  border-color: rgba(255, 255, 255, 0.95);
}
.rw-cursor.degrease {
  border-radius: 16% 16% 45% 45%;
  background: rgba(150, 230, 185, 0.26);
  border-color: rgba(175, 235, 200, 0.95);
}

/* Tool icon centered on the cleaning spot, so the cursor matches where it bites */
.rw-cursor-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}
.rw-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d8c8b4;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* "why won't this lift?" nudge — a banner across the top of the stage */
.rw-resist[hidden] { display: none; }
.rw-resist {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  max-width: 90%;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: rgba(30, 24, 18, 0.86);
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  animation: rw-resist-in 0.18s ease;
}
@keyframes rw-resist-in { from { opacity: 0; } to { opacity: 1; } }

/* --- Foam, spray & shine (experimental juice) --- */
.rw-bubble, .rw-droplet, .rw-shine {
  position: absolute;
  pointer-events: none;
  z-index: 5;
}
.rw-bubble {
  border-radius: 50%;
  /* translucent body, a bright top-left highlight, and a clear rim — reads as a
     soap bubble rather than a soft blob */
  background:
    radial-gradient(circle at 34% 30%, rgba(255,255,255,0.95) 0 14%, rgba(255,255,255,0.1) 34%, rgba(255,255,255,0.04) 72%);
  box-shadow: inset 0 0 5px rgba(255,255,255,0.75);
  border: 1.5px solid rgba(255,255,255,0.85);
  opacity: 0;
  animation: rw-bubble-float var(--dur, 1.2s) ease-out forwards;
}
@keyframes rw-bubble-float {
  0%   { opacity: 0;    transform: translate(-50%, -50%) scale(0.4); }
  18%  { opacity: 0.95; }
  82%  { opacity: 0.9; }
  100% { opacity: 0;    transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--rise, -30px))) scale(1.18); }
}
.rw-droplet {
  width: 6px; height: 6px;
  border-radius: 50% 50% 50% 0;
  background: rgba(150, 210, 255, 0.85);
  box-shadow: 0 0 2px rgba(120,190,255,0.6);
  animation: rw-droplet-fly var(--dur, 0.5s) ease-out forwards;
}
@keyframes rw-droplet-fly {
  0%   { opacity: 0.9; transform: translate(-50%, -50%) rotate(45deg) scale(1); }
  100% { opacity: 0;   transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 30px))) rotate(45deg) scale(0.55); }
}
/* a glossy band that sweeps across the rug on reveal */
.rw-shine {
  inset: 0;
  background: linear-gradient(105deg, transparent 36%, rgba(255,255,255,0.5) 50%, transparent 64%);
  transform: translateX(-120%);
  animation: rw-shine-sweep 0.95s ease-out forwards;
}
@keyframes rw-shine-sweep { to { transform: translateX(120%); } }

@media (prefers-reduced-motion: reduce) {
  .rw-bubble, .rw-droplet, .rw-shine { display: none; }
}

/* --- Reveal card (sits BELOW the rug so the art is never covered) --- */
.rw-done[hidden] { display: none; }
.rw-done {
  display: flex;
  justify-content: center;
  margin: 0.85rem auto 0;
  animation: rw-done-in 0.45s cubic-bezier(0.17, 0.89, 0.32, 1.275);
}
@keyframes rw-done-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.rw-done-card {
  position: relative;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 0.95rem 1.4rem 1.05rem;
  text-align: center;
  max-width: 540px;
  box-shadow: var(--shadow);
}
/* Rug-fringe trim along the top and bottom of the card */
.rw-done-card::before,
.rw-done-card::after {
  content: "";
  position: absolute;
  left: 12%; right: 12%;
  height: 9px;
  background: repeating-linear-gradient(90deg, #cbb084 0 2px, transparent 2px 6px);
  opacity: 0.9;
}
.rw-done-card::before { top: -10px; }
.rw-done-card::after { bottom: -10px; }
.rw-sparkle { font-size: 1.4rem; }
.rw-title {
  margin: 0.2rem 0 0.3rem;
  font-family: "Fredoka", "Nunito", sans-serif;
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--ink);
}
.rw-meta { margin: 0 0 0.5rem; color: var(--muted); font-size: 0.9rem; }

/* origin / era tags */
.rw-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin: 0 0 0.55rem;
}
.rw-tags:empty { display: none; }
.rw-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--pick-bg);
  border: 1.5px solid var(--pick-border);
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 700;
}
.rw-blurb {
  margin: 0 0 0.7rem;
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.4;
}
.rw-blurb:empty { display: none; }
.rw-link { color: var(--primary-dark); font-weight: 700; text-decoration: none; font-size: 0.9rem; }
.rw-link:hover { text-decoration: underline; }

/* --- Actions --- */
.rw-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }
#rw-new { background: var(--btn); font-weight: 700; }
#rw-new:hover { border-color: var(--primary); color: var(--primary-dark); }
.rw-sound { background: var(--btn); font-weight: 700; }
.rw-sound:hover { border-color: var(--primary); color: var(--primary-dark); }
.rw-sound.off { opacity: 0.6; }
.rw-credit { color: var(--muted); font-size: 0.85rem; }
.rw-credit a { color: var(--muted); }

/* --- Restored-rugs shelf --- */
.rw-shelf[hidden] { display: none; }
.rw-shelf { margin-top: 1.7rem; }
.rw-shelf-title {
  font-family: "Fredoka", "Nunito", sans-serif;
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--ink);
  margin: 0 0 0.2rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.rw-shelf-count {
  font-size: 0.8rem; font-weight: 700;
  background: var(--pick-bg); color: var(--primary-dark);
  border: 1.5px solid var(--pick-border);
  border-radius: 999px; padding: 0.05rem 0.55rem;
}
.rw-shelf-sub { margin: 0 0 0.75rem; color: var(--muted); font-size: 0.84rem; }
.rw-shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0.6rem;
}
.rw-shelf-item {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--border);
  background: #2a2118;
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.rw-shelf-item:hover { border-color: var(--primary); transform: translateY(-2px); }
.rw-shelf-img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* a faint film of "dust" that wipes away on hover — a little before/after nod */
.rw-shelf-dust {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 30% 25%, rgba(120,105,80,0.5), transparent 60%),
    radial-gradient(circle at 75% 70%, rgba(90,78,58,0.5), transparent 55%),
    linear-gradient(160deg, rgba(150,138,112,0.45), rgba(70,58,42,0.5));
  opacity: 0.7;
  transition: opacity 0.45s ease;
  pointer-events: none;
}
.rw-shelf-item:hover .rw-shelf-dust { opacity: 0; }
.rw-shelf-cap {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 0.5rem 0.4rem 0.3rem;
  font-size: 0.72rem; font-weight: 700; color: #fff;
  text-align: center;
  background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transition: opacity 0.25s ease;
}
.rw-shelf-item:hover .rw-shelf-cap { opacity: 1; }
