/* Spot the Difference. Builds on /assets/styles.css (site header, footer, .content, .eyebrow, .lede); everything of the
   game itself lives in the sd- namespace. A soft storybook frame around the pictures, the site's ink and focus colours. */
:root {
  --sd-paper: #fffaf1;
  --sd-line: #eadfcd;
  --sd-brown: #5a4636;
  --sd-gold: #f2b544;
  --sd-gold-deep: #9a6510;
  --sd-ring: #ff8f2e;
  --sd-mint: #1f7a5c;
  --sd-mint-soft: #e6f5ee;
  --sd-shadow: 0 6px 18px rgba(90, 70, 54, .12);
}
[hidden] { display: none !important; }
.sd-main .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

.sd-main { padding-block: .5rem 2.5rem; }
.sd-heading { margin: 0 0 .6rem; }
.sd-heading .eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; color: var(--sd-gold-deep); text-transform: none; letter-spacing: .04em; }
.sd-heading h1 { margin: 0; font-size: clamp(1.45rem, 5vw, 2.1rem); line-height: 1.2; letter-spacing: -.02em; }
.sd-heading .lede { margin-top: .45rem; font-size: 1rem; }
.sd-goal { color: var(--ink); font-weight: 750; }

/* small labels: newest / cleared */
.sd-chip { display: inline-flex; align-items: center; gap: .2rem; padding: 0 .55rem; border: 1px solid var(--sd-line); border-radius: 999px; background: var(--sd-paper); color: var(--sd-brown); font-size: .78rem; font-weight: 700; letter-spacing: 0; line-height: 1.6; white-space: nowrap; }
.sd-chip.is-cleared { border-color: #b9e0cf; background: var(--sd-mint-soft); color: var(--sd-mint); }

/* progress: one star slot per difference + "n / N" + the hint button, kept in view while scrolling the pictures */
.sd-status { position: sticky; top: 0; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem .75rem; margin: 0 0 .75rem; padding: .5rem .6rem .5rem .75rem; border: 1px solid var(--sd-line); border-radius: .9rem; background: rgba(255, 250, 241, .96); }
.sd-progress { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.sd-slots { display: flex; gap: .4rem; margin: 0; padding: 0; list-style: none; }
.sd-slot { width: 1.6rem; height: 1.6rem; display: grid; place-items: center; border: 2px dashed #d6c4a4; border-radius: 50%; color: transparent; font-size: .85rem; line-height: 1; transition: transform .25s ease, background-color .25s ease; }
.sd-slot.is-found { border: 2px solid var(--sd-gold-deep); background: var(--sd-gold); color: #fff; transform: scale(1.08); }
.sd-slots.is-complete .sd-slot { animation: sd-dance .5s ease-in-out 2 both; }
.sd-slots.is-complete .sd-slot:nth-child(2) { animation-delay: .08s; }
.sd-slots.is-complete .sd-slot:nth-child(3) { animation-delay: .16s; }
.sd-slots.is-complete .sd-slot:nth-child(4) { animation-delay: .24s; }
.sd-slots.is-complete .sd-slot:nth-child(5) { animation-delay: .32s; }
@keyframes sd-dance { 0%, 100% { transform: scale(1.08) translateY(0); } 50% { transform: scale(1.25) translateY(-5px); } }
.sd-count { margin: 0; font-size: 1.12rem; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sd-count small { margin-left: .2rem; color: var(--muted); font-size: .8rem; font-weight: 650; }
.sd-hint-button { min-height: 2.75rem; display: inline-flex; align-items: center; gap: .3rem; margin-left: auto; padding: 0 .9rem; border: 2px solid #f1d9a6; border-radius: 999px; background: #fff; color: var(--sd-brown); font: inherit; font-size: .92rem; font-weight: 750; cursor: pointer; }
.sd-hint-button:hover:not(:disabled) { border-color: var(--sd-gold-deep); }
.sd-hint-button:disabled { cursor: default; opacity: .55; }
/* narrow phones: smaller slots so up to 5 of them, the count and the hint button share one row */
@media (max-width: 24.5rem) {
  .sd-status { padding-inline: .5rem; gap: .4rem; }
  .sd-progress { gap: .4rem; }
  .sd-slots { gap: .25rem; }
  .sd-slot { width: 1.35rem; height: 1.35rem; font-size: .72rem; }
  .sd-count small { display: none; }
  .sd-hint-button { padding: 0 .7rem; }
}

/* the pictures: stacked on phones, side by side from 46rem */
.sd-pictures { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: .75rem; }
@media (min-width: 46rem) { .sd-pictures { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.sd-pic { position: relative; margin: 0; overflow: hidden; border: 3px solid #fff; border-radius: 1rem; background: var(--sd-paper); box-shadow: var(--sd-shadow); cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.sd-pic img { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; background: #f3ead8; -webkit-user-drag: none; }
.sd-layer { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.sd-pic figcaption { position: absolute; top: .45rem; left: .45rem; min-width: 1.7rem; padding: 0 .5rem; border-radius: 999px; background: rgba(255, 255, 255, .92); color: var(--sd-brown); font-size: .85rem; font-weight: 800; text-align: center; pointer-events: none; }

/* found: a soft ring with a white halo (the last one pops larger); a miss: a faint ripple (no penalty) */
.sd-mark-halo, .sd-mark, .sd-spark, .sd-miss, .sd-hint-glow, .sd-hint-rim, .sd-hint-spark { transform-box: fill-box; transform-origin: center; vector-effect: non-scaling-stroke; }
.sd-mark-halo { fill: none; stroke: #fff; stroke-width: 8; opacity: .85; animation: sd-pop .42s cubic-bezier(.2, 1.4, .4, 1) both; }
.sd-mark { fill: none; stroke: var(--sd-ring); stroke-width: 4; animation: sd-pop .42s cubic-bezier(.2, 1.4, .4, 1) both; }
.sd-spark { fill: var(--sd-gold); animation: sd-spark .7s ease-out both; }
.sd-found.is-final .sd-mark-halo, .sd-found.is-final .sd-mark { animation: sd-pop-final .7s cubic-bezier(.2, 1.5, .35, 1) both; }
.sd-found.is-final .sd-spark { animation: sd-spark 1s ease-out both; }
.sd-miss { fill: none; stroke: rgba(92, 107, 127, .55); stroke-width: 2; animation: sd-miss .5s ease-out both; }
@keyframes sd-pop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes sd-pop-final { 0% { transform: scale(.3); opacity: 0; } 55% { transform: scale(1.45); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
@keyframes sd-spark { 0% { transform: scale(0) rotate(0); opacity: 0; } 40% { opacity: 1; } 100% { transform: scale(1) rotate(45deg); opacity: 0; } }
@keyframes sd-miss { from { transform: scale(.4); opacity: 1; } to { transform: scale(1.3); opacity: 0; } }

/* hint: a soft, wide glow that breathes for a moment and fades by itself (never a ring on the answer) */
.sd-hint-glow { fill: rgba(255, 214, 120, .26); stroke: none; animation: sd-hint 2.6s ease-in-out both; }
.sd-hint-rim { fill: none; stroke: rgba(255, 236, 190, .9); stroke-width: 3; stroke-dasharray: 2 7; stroke-linecap: round; animation: sd-hint 2.6s ease-in-out both; }
.sd-hint-spark { fill: #fff3c4; animation: sd-hint-spark 2.6s ease-in-out both; }
@keyframes sd-hint { 0% { opacity: 0; transform: scale(.92); } 15% { opacity: 1; transform: scale(1); } 45% { opacity: .7; transform: scale(1.03); } 70% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.02); } }
@keyframes sd-hint-spark { 0%, 100% { opacity: 0; transform: scale(.4); } 25%, 75% { opacity: 1; transform: scale(1); } 50% { opacity: .5; transform: scale(.7); } }

.sd-toast { position: absolute; top: 45%; left: 50%; z-index: 4; max-width: calc(100% - 2rem); margin: 0; padding: .45rem 1.1rem; border-radius: 999px; background: #fff; box-shadow: var(--sd-shadow); color: var(--sd-gold-deep); font-size: 1.05rem; font-weight: 800; text-align: center; opacity: 0; pointer-events: none; transform: translate(-50%, -50%) scale(.9); transition: opacity .18s ease, transform .18s ease; }
.sd-toast.is-on { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* the clear: stars and soft paper confetti over the pictures for about 2.5 s; nothing takes pointer input */
.sd-burst { position: absolute; inset: 0; z-index: 5; overflow: hidden; pointer-events: none; }
.sd-burst i { position: absolute; top: 38%; width: .55rem; height: .8rem; border-radius: 2px; opacity: 0; animation: sd-confetti 2.4s cubic-bezier(.2, .7, .3, 1) forwards; }
.sd-burst i.is-star { width: 1rem; height: 1rem; border-radius: 0; background: var(--sd-gold); clip-path: polygon(50% 0, 61% 38%, 100% 50%, 61% 62%, 50% 100%, 39% 62%, 0 50%, 39% 38%); }
@keyframes sd-confetti {
  0% { transform: translate(0, 0) scale(.3) rotate(0); opacity: 0; }
  12% { opacity: 1; }
  40% { transform: translate(calc(var(--sd-drift) * .5), -32vh) scale(1) rotate(calc(var(--sd-spin) * .5)); opacity: 1; }
  100% { transform: translate(var(--sd-drift), 18vh) scale(.9) rotate(var(--sd-spin)); opacity: 0; }
}

.sd-clear { margin-top: 1rem; padding: 1.25rem 1rem; border: 2px solid #f6e3bd; border-radius: 1.1rem; background: #fff; box-shadow: var(--sd-shadow); text-align: center; animation: sd-up .5s cubic-bezier(.2, 1.3, .4, 1) both; }
.sd-clear:focus { outline: none; }
.sd-clear:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
@keyframes sd-up { from { transform: translateY(16px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.sd-clear-stars { margin: 0; color: var(--sd-gold); font-size: 1.2rem; letter-spacing: .4em; }
.sd-clear h2 { margin: .1rem 0 .35rem; font-size: 1.6rem; animation: sd-cheer .6s .2s cubic-bezier(.2, 1.5, .4, 1) both; }
@keyframes sd-cheer { from { transform: scale(.8); } to { transform: none; } }
.sd-cheer { margin: 0 0 .35rem; color: var(--sd-brown); font-weight: 650; }
.sd-time { margin: 0 0 .25rem; color: var(--muted); }
.sd-time b { color: var(--ink); font-variant-numeric: tabular-nums; }
.sd-no-hint { margin: 0 0 .25rem; }
.sd-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; margin-top: .75rem; }
.sd-button { min-height: 2.75rem; display: inline-flex; align-items: center; justify-content: center; padding: 0 1.1rem; border: 2px solid var(--line-strong); border-radius: 999px; background: #fff; color: var(--ink); font: inherit; font-weight: 720; text-decoration: none; cursor: pointer; }
.sd-button.is-primary { border-color: var(--sd-gold-deep); background: var(--sd-gold); color: #3b2a12; }
.sd-button.is-quiet { border-color: transparent; color: var(--muted); }
.sd-later { margin: .8rem 0 0; color: var(--muted); font-size: .92rem; }

/* entry page: the puzzles that can be played */
.sd-list { display: grid; gap: .9rem; margin: 0; padding: 0; list-style: none; }
@media (min-width: 36rem) { .sd-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.sd-card { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); align-items: center; gap: .9rem; padding: .75rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); color: var(--ink); text-decoration: none; }
.sd-card:hover { border-color: var(--sd-gold-deep); box-shadow: 0 12px 28px rgba(16, 35, 63, .09); }
.sd-card img { width: 100%; height: auto; aspect-ratio: 1 / 1; border-radius: .7rem; background: #f3ead8; }
.sd-card-meta { display: block; color: var(--sd-gold-deep); font-size: .85rem; font-weight: 750; }
.sd-card-meta span { color: var(--muted); font-weight: 650; }
.sd-card strong { display: block; font-size: 1.05rem; line-height: 1.35; }
.sd-card-chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; }
.sd-card-chips:empty { display: none; }

@media (prefers-reduced-motion: reduce) {
  .sd-mark-halo, .sd-mark, .sd-spark, .sd-miss, .sd-clear, .sd-clear h2, .sd-slot, .sd-slots.is-complete .sd-slot, .sd-toast, .sd-found.is-final .sd-mark-halo, .sd-found.is-final .sd-mark, .sd-found.is-final .sd-spark { animation: none !important; transition: none !important; }
  .sd-spark, .sd-hint-spark { display: none; }
  /* the hint stays a still, soft area that simply goes away */
  .sd-hint-glow, .sd-hint-rim { animation: sd-hint-still 2.6s linear both !important; }
  @keyframes sd-hint-still { 0%, 92% { opacity: 1; } 100% { opacity: 0; } }
  .sd-burst { display: none; }
}
