/* ---- dog-vision: cute & playful theme ---------------------------------- */
:root {
  /* OKLCH palette: warm cream surface, golden-retriever gold identity,
     playful teal as the "dog vision" accent. No pure black/white. */
  --surface:     oklch(0.972 0.022 84);
  --surface-2:   oklch(0.992 0.012 86);
  --ink:         oklch(0.34 0.035 62);
  --ink-soft:    oklch(0.52 0.03 65);
  --gold:        oklch(0.82 0.13 78);
  --gold-deep:   oklch(0.68 0.15 66);
  --teal:        oklch(0.74 0.11 205);
  --teal-deep:   oklch(0.55 0.10 215);
  --line:        oklch(0.86 0.03 80);
  --shadow-c:    oklch(0.62 0.06 60 / 0.18);

  /* mascot fur */
  --fur:        oklch(0.82 0.11 72);
  --fur-dark:   oklch(0.70 0.13 62);
  --fur-light:  oklch(0.94 0.05 82);
  --shadow:     oklch(0.62 0.06 60 / 0.16);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);          /* ease-out-quint */
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);     /* tasteful overshoot */
  --r: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* beat display:flex/grid on hidden els */

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--surface);
  overflow-x: hidden;
}

/* soft sun-glow backdrop */
.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60% 50% at 50% -8%, oklch(0.92 0.09 88) 0%, transparent 60%),
    radial-gradient(40% 40% at 90% 10%, oklch(0.9 0.06 200 / 0.5) 0%, transparent 55%);
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.6rem 1.1rem 3.5rem;
}

/* ---- header + mascot --------------------------------------------------- */
.hero {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.8rem;
}
.hero-text { min-width: 0; }

/* phones: stack the mascot above the title, center everything */
@media (max-width: 480px) {
  .hero { flex-direction: column; text-align: center; gap: 0.4rem; margin-bottom: 1.4rem; }
  .mascot { width: 96px; height: 96px; }
  .mascot svg { width: 96px; height: 96px; }
  .sub { margin-inline: auto; }
  .actions { justify-content: center; }
  .toggles { justify-content: center; }
}

h1 {
  font-family: "Fredoka", system-ui, sans-serif;
  font-weight: 700;
  font-size: clamp(2.1rem, 7vw, 3.1rem);
  line-height: 0.95;
  margin: 0;
  color: var(--gold-deep);
  letter-spacing: -0.01em;
}
.sub {
  font-size: 1.02rem;
  color: var(--ink-soft);
  margin: 0.35rem 0 0;
  max-width: 48ch;
}
.paw { display: inline-block; }

.mascot { flex: none; width: 120px; height: 120px; }
.mascot svg { display: block; overflow: visible; }

/* animatable sub-parts pivot around their own box */
.m-tail, .m-ear, .m-eyes, .m-tongue { transform-box: fill-box; }
.m-tail  { transform-origin: 0% 100%; }
.m-ear-l { transform-origin: 60% 0%; }
.m-ear-r { transform-origin: 40% 0%; }
.m-eyes  { transform-origin: 50% 50%; }
.m-tongue{ transform-origin: 50% 0%; transform: scaleY(0); }

/* idle: gentle breathing bob + slow tail sway + occasional blink */
.mascot svg            { animation: bob 3.4s var(--ease) infinite; }
.m-tail                { animation: wag 1.6s ease-in-out infinite; }
.m-eyes                { animation: blink 4.2s steps(1) infinite; }

@keyframes bob   { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes wag   { 0%,100% { transform: rotate(-9deg); } 50% { transform: rotate(9deg); } }
@keyframes blink { 0%,93%,100% { transform: scaleY(1); } 96% { transform: scaleY(0.1); } }

/* processing: head tilts, ears perk, tail wags faster */
.mascot[data-state="sniffing"] svg     { animation: tilt 1.1s ease-in-out infinite; }
.mascot[data-state="sniffing"] .m-tail { animation-duration: 0.5s; }
.mascot[data-state="sniffing"] .m-ear-l{ animation: perkL 1.1s ease-in-out infinite; }
.mascot[data-state="sniffing"] .m-ear-r{ animation: perkR 1.1s ease-in-out infinite; }
@keyframes tilt  { 0%,100% { transform: rotate(-5deg) translateY(0); } 50% { transform: rotate(5deg) translateY(-3px); } }
@keyframes perkL { 0%,100% { transform: rotate(0); } 50% { transform: rotate(-12deg); } }
@keyframes perkR { 0%,100% { transform: rotate(0); } 50% { transform: rotate(12deg); } }

/* happy: bouncy celebration with tongue out (user asked for bouncy) */
.mascot[data-state="happy"] svg      { animation: hop 0.6s var(--spring) infinite; }
.mascot[data-state="happy"] .m-tail  { animation-duration: 0.32s; }
.mascot[data-state="happy"] .m-tongue{ transform: scaleY(1); transition: transform 0.3s var(--spring); }
@keyframes hop { 0%,100% { transform: translateY(0); } 30% { transform: translateY(-12px); } 60% { transform: translateY(0); } }

/* ---- upload zone ------------------------------------------------------- */
.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 2.8rem 1.5rem;
  background: var(--surface-2);
  border: 3px dashed var(--line);
  border-radius: var(--r);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease), transform 0.3s var(--spring);
  animation: breathe 3s ease-in-out infinite;
}
@keyframes breathe { 0%,100% { border-color: var(--line); } 50% { border-color: var(--gold); } }
.drop:hover { background: oklch(0.985 0.02 84); transform: translateY(-2px); }
.drop.drag  { border-color: var(--teal); background: oklch(0.96 0.05 200); transform: scale(1.02); animation: none; }
.drop-emoji { font-size: 2.6rem; animation: wiggle 2.6s ease-in-out infinite; }
@keyframes wiggle { 0%,100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
.drop-title { font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 1.2rem; color: var(--ink); }
.drop-hint  { font-size: 0.9rem; color: var(--ink-soft); }

/* tiny "best results" infographic under the drop zone */
.tips { margin-top: 1.1rem; animation: rise 0.5s var(--ease) both; }
.tips-lead {
  text-align: center;
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin: 0 0 0.7rem;
}
.tips-row {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}
.tips-row li {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.7rem 0.8rem;
  transition: transform 0.25s var(--spring), border-color 0.25s var(--ease);
}
.tips-row li:hover { transform: translateY(-2px); border-color: var(--gold); }
.tip-ico { font-size: 1.5rem; line-height: 1; flex: none; }
.tip-txt { display: flex; flex-direction: column; gap: 0.1rem; font-size: 0.8rem; color: var(--ink-soft); line-height: 1.3; }
.tip-txt b { font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 0.9rem; color: var(--ink); }
@media (max-width: 560px) {
  .tips-row { grid-template-columns: 1fr; }
  .tips-row li { align-items: center; }
}

/* ---- progress + paw trail --------------------------------------------- */
#progress-zone { animation: rise 0.5s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.paw-track {
  height: 16px;
  border-radius: 999px;
  background: oklch(0.91 0.03 82);
  overflow: hidden;
  box-shadow: inset 0 2px 4px var(--shadow-c);
}
.paw-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), var(--gold-deep));
  transition: width 0.6s linear;     /* grows smoothly between status polls */
  position: relative;
  overflow: hidden;
}
/* a soft sheen sweeping left -> right adds continuous motion */
.paw-fill::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 35%, oklch(1 0 0 / 0.3) 50%, transparent 65%);
  background-size: 220% 100%;
  animation: pawSheen 1.9s linear infinite;
}
/* paw prints marching left -> right along the filled trail (seamless tile) */
.paw-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='20' viewBox='0 0 30 20'%3E%3Cg fill='%233a2a1c'%3E%3Cellipse cx='15' cy='14' rx='5' ry='3.6'/%3E%3Cellipse cx='9' cy='8' rx='2' ry='2.4'/%3E%3Cellipse cx='14' cy='6' rx='2.1' ry='2.6'/%3E%3Cellipse cx='19' cy='6.5' rx='2.1' ry='2.6'/%3E%3Cellipse cx='23' cy='10' rx='1.9' ry='2.3'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-position: 0 center;
  background-size: 24px 16px;
  opacity: 0.5;
  animation: pawMarch 2.2s linear infinite;
}
@keyframes pawSheen { from { background-position: -60% 0; } to { background-position: 160% 0; } }
@keyframes pawMarch { from { background-position-x: 0; } to { background-position-x: 24px; } }
.progress-label {
  text-align: center;
  font-family: "Fredoka", sans-serif;
  font-weight: 500;
  color: var(--ink-soft);
  margin: 0.7rem 0 1.2rem;
}

.fact-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 1.1rem 1.3rem;
  box-shadow: 0 8px 24px var(--shadow-c);
}
.fact-kicker {
  display: inline-block;
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--teal-deep);
  margin-bottom: 0.4rem;
}
.fact-body {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.5;
}
.fact-emoji { font-size: 1.4rem; flex: none; }
.fact-card.swap { animation: factSwap 0.45s var(--ease); }
@keyframes factSwap { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- result: before/after comparison slider --------------------------- */
#result-zone { animation: rise 0.5s var(--ease) both; }

.compare {
  --pos: 50%;
  --ar: 1.3333;                  /* media aspect ratio, set from JS */
  position: relative;
  /* width derives from the aspect ratio so height never exceeds 72vh */
  width: min(100%, calc(72vh * var(--ar)));
  aspect-ratio: var(--ar);
  margin: 0 auto;
  border-radius: var(--r);
  overflow: hidden;
  background: oklch(0.2 0.02 60);
  box-shadow: 0 12px 32px var(--shadow-c);
  touch-action: none;            /* let the range own horizontal drags */
  user-select: none;
  animation: pop 0.5s var(--spring) both;
}
@keyframes pop { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }

.compare-base, .compare-top { position: absolute; inset: 0; width: 100%; height: 100%; }
.compare-base img, .compare-base video,
.compare-top  img, .compare-top  video { display: block; width: 100%; height: 100%; object-fit: cover; }

/* the "You" layer sits on top, revealed from the left up to --pos */
.compare-top { clip-path: inset(0 calc(100% - var(--pos)) 0 0); }

.compare-divider {
  position: absolute;
  top: 0; bottom: 0;
  left: var(--pos);
  width: 3px;
  margin-left: -1.5px;
  background: oklch(0.99 0.01 84);
  box-shadow: 0 0 0 1px oklch(0.4 0.03 60 / 0.25);
  pointer-events: none;
  z-index: 4;
}
.compare-handle {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 46px; height: 46px;
  border-radius: 50%;
  background: oklch(0.99 0.01 84);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 4px 14px oklch(0.4 0.03 60 / 0.35);
  animation: handleNudge 2.6s var(--ease) infinite;
}
@keyframes handleNudge {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50%      { transform: translate(-50%, -50%) scale(1.08); }
}

/* the transparent range is the whole drag/keyboard surface */
.compare-range {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  margin: 0;
  background: transparent;
  cursor: ew-resize;
  -webkit-appearance: none;
  appearance: none;
  opacity: 0;            /* invisible but still draggable (iOS draws a faint thumb otherwise) */
  z-index: 5;
}
.compare-range:focus-visible { outline: none; }
.compare-range:focus-visible ~ .compare-divider .compare-handle {
  outline: 3px solid oklch(0.74 0.11 205 / 0.7);
  outline-offset: 3px;
}
.compare-range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 46px; height: 240px; background: transparent; border: none; cursor: ew-resize; }
.compare-range::-moz-range-thumb { width: 46px; height: 240px; border: 0; background: transparent; cursor: ew-resize; }
.compare-range::-moz-range-track { background: transparent; }

.compare-hint {
  text-align: center;
  font-family: "Fredoka", sans-serif;
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0.6rem 0 0;
}

/* corner labels (override the top-left badge defaults; .badge.lbl-* keeps
   higher specificity than .badge regardless of source order) */
.badge.lbl-l { top: auto; bottom: 0.6rem; left: 0.6rem; right: auto; z-index: 6; }
.badge.lbl-r { top: auto; bottom: 0.6rem; left: auto; right: 0.6rem; z-index: 6; }

.badge {
  position: absolute;
  top: 0.6rem; left: 0.6rem;
  z-index: 2;
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  color: oklch(0.99 0.01 84);
  box-shadow: 0 2px 8px var(--shadow-c);
}
.badge-human { background: var(--ink-soft); }
.badge-dog   { background: var(--teal-deep); }

/* preview loader over the Kiko pane while /preview is computing */
.pane-loader {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: oklch(0.97 0.022 84 / 0.72);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fadeIn 0.18s var(--ease);
}
.pane-loader[hidden] { display: none; }
.paw-spin {
  font-size: 2rem;
  animation: pawSpin 0.9s var(--ease) infinite;
}
@keyframes pawSpin {
  0%   { transform: scale(0.7) rotate(0deg);   opacity: 0.5; }
  50%  { transform: scale(1.1) rotate(180deg); opacity: 1;   }
  100% { transform: scale(0.7) rotate(360deg); opacity: 0.5; }
}
.loader-text {
  font-family: "Fredoka", sans-serif;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--teal-deep);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.toggles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin: 1.4rem 0;
}
.video-note {
  max-width: 46ch;
  margin: 1.4rem auto;
  text-align: center;
  font-family: "Fredoka", sans-serif;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--ink-soft);
}
.chip {
  position: relative;
  cursor: pointer;
  user-select: none;
  font-family: "Fredoka", sans-serif;
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 2px solid var(--line);
  color: var(--ink-soft);
  transition: transform 0.25s var(--spring), background 0.25s var(--ease), border-color 0.25s var(--ease), color 0.25s var(--ease);
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:hover { transform: translateY(-2px); }
.chip:has(input:checked) {
  background: oklch(0.93 0.08 80);
  border-color: var(--gold);
  color: var(--gold-deep);
}
.chip:has(input:checked).wiggle { animation: chipPop 0.4s var(--spring); }
@keyframes chipPop { 0% { transform: scale(1); } 40% { transform: scale(1.12) rotate(-3deg); } 100% { transform: scale(1); } }
.chip:focus-within { outline: 3px solid oklch(0.74 0.11 205 / 0.5); outline-offset: 2px; }

.actions { display: flex; align-items: center; justify-content: center; gap: 1rem; flex-wrap: wrap; }
.download {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  text-decoration: none;
  padding: 0.7rem 1.4rem;
  border-radius: 999px;
  color: oklch(0.99 0.01 84);
  background: linear-gradient(180deg, var(--gold) 0%, var(--gold-deep) 100%);
  box-shadow: 0 8px 20px oklch(0.68 0.15 66 / 0.4);
  transition: transform 0.25s var(--spring), box-shadow 0.25s var(--ease);
}
.download:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 12px 26px oklch(0.68 0.15 66 / 0.5); }
.download:active { transform: translateY(0) scale(0.98); }
.again {
  font-family: "Fredoka", sans-serif;
  font-weight: 500;
  font-size: 0.95rem;
  background: none;
  border: none;
  color: var(--ink-soft);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.again:hover { color: var(--ink); }

/* ---- confetti ---------------------------------------------------------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.confetti span {
  position: absolute;
  top: -24px;
  font-size: 18px;
  will-change: transform, opacity;
  animation: fall var(--dur, 2.4s) var(--ease) forwards;
}
@keyframes fall {
  0%   { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(105vh) rotate(540deg); opacity: 0; }
}

/* ---- a11y -------------------------------------------------------------- */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
  .m-tongue { transform: scaleY(0); }
  .mascot[data-state="happy"] .m-tongue { transform: scaleY(1); }
}
