/* The Smelling Assistant: a sheet of scratch-and-sniff stickers. */

:root {
  --ink: oklch(24% 0.07 305);
  --paper: oklch(99% 0.006 100);

  /* sticker inks */
  --grape: oklch(43% 0.2 300);
  --lemon: oklch(90% 0.17 100);
  --bubblegum: oklch(78% 0.15 352);
  --lime: oklch(85% 0.19 135);
  --tangerine: oklch(78% 0.16 60);
  --sky: oklch(83% 0.1 222);

  --ground: var(--grape);
  --on-ground: var(--paper);
  --sticker: var(--lemon);

  --display: 'Chango', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --body: 'Gabarito', system-ui, sans-serif;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --lift: 0 0.5rem 1.1rem -0.45rem oklch(20% 0.09 305 / 0.55);
  --gutter: clamp(1rem, 4vw, 2.5rem);
}

/* One stock per smell family. Ink text on every one of them. */
body[data-family] { --on-ground: var(--ink); }
body[data-family='sweet'] { --ground: oklch(82% 0.12 352); --sticker: var(--lemon); }
body[data-family='fruity'] { --ground: oklch(80% 0.15 58); --sticker: var(--lemon); }
body[data-family='fresh'] { --ground: oklch(87% 0.16 150); --sticker: var(--paper); }
body[data-family='floral'] { --ground: oklch(81% 0.1 305); --sticker: var(--lemon); }
body[data-family='earthy'] { --ground: oklch(77% 0.1 92); --sticker: var(--paper); }
body[data-family='smoky'] { --ground: oklch(76% 0.045 255); --sticker: var(--tangerine); }
body[data-family='funky'] { --ground: oklch(86% 0.17 112); --sticker: var(--bubblegum); }
body[data-family='chemical'] { --ground: oklch(85% 0.12 200); --sticker: var(--lemon); }
body[data-family='savory'] { --ground: oklch(77% 0.14 36); --sticker: var(--lemon); }
body[data-family='rare'] { --ground: oklch(84% 0.15 86); --sticker: var(--paper); }

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--ink) transparent; }

body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--ground);
  color: var(--on-ground);
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.5;
  overflow-x: clip;
  transition: background-color 0.7s var(--ease-out), color 0.4s;
  caret-color: var(--ink);
}

::selection { background: var(--lemon); color: var(--ink); }

:focus-visible { outline: 3px solid var(--on-ground); outline-offset: 4px; border-radius: 0.4rem; }

h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ---------- header / footer ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem var(--gutter) 0;
}
.wordmark {
  font-family: var(--display);
  font-size: clamp(0.78rem, 3.4vw, 0.95rem);
  color: inherit;
  text-decoration: none;
  text-transform: uppercase;
  line-height: 1.1;
}
.music {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0.3rem 0.9rem 0.3rem 0.6rem;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  font: 700 0.9rem var(--body);
  cursor: pointer;
  box-shadow: var(--lift);
  transform: rotate(2deg);
  transition: transform 0.25s var(--ease-out);
}
.music:hover { transform: rotate(-1deg) scale(1.04); }
.music svg { width: 1.3rem; height: 1.3rem; fill: var(--ink); }
.music .i-pause, .music[aria-pressed='true'] .i-play { display: none; }
.music[aria-pressed='true'] .i-pause { display: inline; }
.music[aria-pressed='true'] { background: var(--lemon); }

main { flex: 1; display: grid; }

.foot {
  padding: 1.5rem var(--gutter) calc(1.25rem + env(safe-area-inset-bottom));
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
}
.foot p { max-width: 46ch; margin-inline: auto; text-wrap: balance; }

/* ---------- sticker primitives (SVG) ---------- */

.cut { fill: var(--paper); }
.fill { stroke: var(--ink); stroke-width: 4; }
.glyph { stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; }
.line { fill: none; stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.ink { fill: var(--ink); }
.lemon { fill: var(--lemon); }
.lime { fill: var(--lime); }
.sky { fill: var(--sky); }
.tangerine { fill: var(--tangerine); }
.bubblegum { fill: var(--bubblegum); }
.paper { fill: var(--paper); }

/* ---------- the sheet (idle + sniffing) ---------- */

.sheet {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: clamp(1.25rem, 4vh, 2.5rem);
  padding: 1.5rem var(--gutter) 1rem;
}

.nose-sticker {
  position: relative;
  z-index: 1;
  width: min(80vw, 54svh, 30rem);
  aspect-ratio: 1;
  border-radius: 50%;
  cursor: pointer;
  filter: drop-shadow(0 0.7rem 0.9rem oklch(18% 0.1 305 / 0.5));
  transform: rotate(-3deg);
  transition: transform 0.5s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.nose-sticker svg { display: block; width: 100%; height: 100%; overflow: visible; }
.nose-sticker:hover { transform: rotate(1deg) scale(1.03); }
.nose-sticker:active { transform: rotate(0deg) scale(0.97); }
#photo:focus-visible + .pitch, .nose-sticker:has(+ #photo:focus-visible) { outline: 3px solid var(--paper); outline-offset: 6px; }

.rim { transform-box: fill-box; transform-origin: center; animation: spin 40s linear infinite; }
.rim-text { font-family: var(--display); font-size: 10.5px; fill: var(--ink); }
.banner { fill: var(--paper); stroke: var(--ink); stroke-width: 4; }
.banner-text { font-family: var(--display); font-size: 14px; fill: var(--ink); }
.nose, .whiffs { transform-box: fill-box; transform-origin: 50% 80%; }
.whiffs { animation: waft 3.2s ease-in-out infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes waft { 50% { transform: translateY(-3px); opacity: 0.55; } }
@keyframes sniff {
  0%, 100% { transform: scale(1); }
  12% { transform: scale(1.12, 1.06); }
  24% { transform: scale(0.98); }
  36% { transform: scale(1.14, 1.08); }
  52% { transform: scale(1); }
}
@keyframes inhale {
  0% { transform: translateY(-10px); opacity: 0; }
  40% { opacity: 1; }
  100% { transform: translateY(12px) scale(0.6); opacity: 0; }
}

body[data-state='sniffing'] .nose-sticker { pointer-events: none; transform: rotate(0deg); }
body[data-state='sniffing'] .nose { animation: sniff 1.3s var(--ease-out) infinite; }
body[data-state='sniffing'] .whiffs { animation: inhale 1.3s ease-in infinite; }
body[data-state='sniffing'] .rim { animation-duration: 6s; }

.pitch { position: relative; z-index: 1; text-align: center; display: grid; gap: 0.75rem; justify-items: center; }
.pitch h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.1rem, 9.5vw, 4.5rem);
  line-height: 1;
  text-transform: uppercase;
  text-wrap: balance;
}
.pitch h1 span { color: var(--lemon); display: block; }
.sub { max-width: 34ch; font-size: 1.125rem; font-weight: 500; text-wrap: balance; min-height: 3.4em; }
body[data-state='sniffing'] .sub { font-family: var(--display); font-size: 1.05rem; text-transform: uppercase; }
body[data-state='error'] .sub { color: var(--lemon); }

.mini {
  position: absolute;
  width: clamp(5rem, 22vw, 9.5rem);
  filter: drop-shadow(0 0.35rem 0.45rem oklch(18% 0.1 305 / 0.45));
}
.mini-a { top: 3%; left: -5%; transform: rotate(-14deg); }
.mini-b { top: 30%; right: -8%; transform: rotate(12deg); }
.mini-c { bottom: 20%; left: -7%; transform: rotate(9deg); }
.mini-d { bottom: -3%; right: 4%; transform: rotate(-10deg); width: clamp(4rem, 16vw, 7rem); }

@media (min-width: 60rem) {
  .sheet {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    align-items: center;
    gap: 3rem;
    max-width: 78rem;
    width: 100%;
    margin-inline: auto;
  }
  .nose-sticker { grid-column: 2; grid-row: 1; width: min(40vw, 66svh, 34rem); }
  .pitch { grid-column: 1; grid-row: 1; text-align: left; justify-items: start; }
  .pitch h1 { font-size: clamp(3rem, 5.6vw, 5.5rem); }
  .sub { font-size: 1.3rem; }
  .mini-a { top: 4%; left: 38%; }
  .mini-b { top: 6%; right: -2%; }
  .mini-c { bottom: 1%; left: 24%; }
  .mini-d { bottom: 5%; right: 43%; }
}

/* ---------- result ---------- */

.result {
  width: 100%;
  max-width: 36rem;
  margin-inline: auto;
  padding: 1.25rem var(--gutter) 1rem;
  display: grid;
  gap: 2rem;
  align-content: start;
}

.reveal { display: grid; justify-items: center; }

.photo {
  position: relative;
  z-index: 2;
  width: min(62%, 17rem);
  margin-bottom: -1.75rem;
  padding: 0.45rem;
  background: var(--paper);
  border-radius: 1.4rem;
  box-shadow: var(--lift);
  transform: rotate(-4deg);
}
.photo img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 1rem; border: 3px solid var(--ink); }

.label-sticker {
  position: relative;
  width: 100%;
  min-height: 11rem;
  display: grid;
  place-items: center;
  padding: 0.5rem;
  background: var(--paper);
  border-radius: 2rem;
  box-shadow: var(--lift);
  transform: rotate(1.2deg);
}
.label-sticker h2 {
  width: 100%;
  min-height: 10rem;
  display: grid;
  place-items: center;
  padding: 2.6rem 1.25rem 1.6rem;
  background: var(--sticker);
  border: 4px solid var(--ink);
  border-radius: 1.55rem;
  color: var(--ink);
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.45rem, 6.4vw, 2.3rem);
  line-height: 1.08;
  text-align: center;
  text-transform: uppercase;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
#scratch {
  position: absolute;
  inset: 0.5rem;
  width: calc(100% - 1rem);
  height: calc(100% - 1rem);
  border-radius: 1.55rem;
  touch-action: none;
  cursor: grab;
  transition: opacity 0.6s var(--ease-out), filter 0.6s var(--ease-out);
}
#scratch.is-gone { opacity: 0; filter: blur(6px); pointer-events: none; }

.rare {
  position: absolute;
  z-index: 3;
  top: -1.1rem;
  right: -0.4rem;
  display: grid;
  place-items: center;
  width: 5.2rem;
  aspect-ratio: 1;
  padding: 0.4rem;
  background: var(--bubblegum);
  border: 3px solid var(--ink);
  outline: 0.3rem solid var(--paper);
  border-radius: 50%;
  font-family: var(--display);
  font-size: 0.8rem;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  transform: rotate(14deg);
  box-shadow: var(--lift);
}

.textbtn {
  margin-top: 1rem;
  padding: 0.5rem 0.75rem;
  background: none;
  border: 0;
  color: inherit;
  font: 600 1rem var(--body);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.report { display: grid; gap: 2rem; }
.report.is-held { display: none; }

.notes { display: grid; gap: 1.4rem; }
.tier h3, .meter h3 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1rem;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}
.pills { display: flex; flex-wrap: wrap; gap: 0.55rem 0.5rem; }
.pills li {
  padding: 0.4rem 0.95rem;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 1.3rem;
  font-weight: 700;
  line-height: 1.25;
  box-shadow: var(--lift);
}
.pills li:nth-child(odd) { transform: rotate(-1.5deg); }
.pills li:nth-child(even) { transform: rotate(1.2deg); }
#heart li { background: var(--lemon); }
#base li { background: var(--ink); color: var(--paper); }

.desc { font-size: 1.25rem; line-height: 1.5; font-weight: 500; max-width: 60ch; text-wrap: pretty; }

.dots { display: flex; gap: 0.4rem; }
.dots i {
  flex: 1;
  max-width: 2.4rem;
  aspect-ratio: 1;
  border: 3px solid var(--ink);
  border-radius: 50%;
}
.dots i.on { background: var(--ink); }
.meter-label { margin-top: 0.6rem; font-weight: 700; }

.pairs { font-size: 1.1rem; font-weight: 500; }
.pairs strong { font-family: var(--display); font-weight: 400; font-size: 1rem; text-transform: uppercase; margin-right: 0.35rem; }

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.btn {
  flex: 1 1 13rem;
  display: inline-grid;
  place-items: center;
  min-height: 3.5rem;
  padding: 0.7rem 1.4rem;
  background: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 999px;
  color: var(--paper);
  font: 400 1rem var(--display);
  text-transform: uppercase;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--lift);
  transition: transform 0.25s var(--ease-out);
}
.btn-alt { background: var(--paper); color: var(--ink); }
.btn:hover { transform: translateY(-2px) rotate(-1deg); }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: default; transform: none; }

/* the one authored moment: stickers land after the scratch */
.report.is-landing .pills li,
.report.is-landing .desc,
.report.is-landing .meter,
.report.is-landing .pairs,
.report.is-landing .actions {
  animation: land 0.7s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}
@keyframes land {
  from { opacity: 0; scale: 0.6; translate: 0 1.2rem; filter: blur(4px); }
}

@media (min-width: 60rem) {
  .result {
    max-width: 70rem;
    grid-template-columns: minmax(0, 27rem) minmax(0, 1fr);
    gap: 4rem;
    padding-top: 2.5rem;
  }
  .reveal { position: sticky; top: 2rem; align-self: start; }
  .result:has(.report.is-held) { grid-template-columns: minmax(0, 27rem); justify-content: center; }
  .label-sticker h2 { font-size: 2.1rem; }
  .desc { font-size: 1.35rem; }
}

/* ---------- admin ---------- */

.admin { width: 100%; max-width: 40rem; margin-inline: auto; padding: 2rem var(--gutter); display: grid; gap: 2rem; align-content: start; }
.admin h1 { font: 400 clamp(1.8rem, 6vw, 2.6rem)/1.05 var(--display); text-transform: uppercase; }
.admin h2 { font: 400 1.1rem var(--display); text-transform: uppercase; margin-bottom: 0.75rem; }
.admin form { display: grid; gap: 1rem; }
.admin label { display: grid; gap: 0.35rem; font-weight: 700; }
.admin input[type='text'], .admin input[type='password'], .admin input[type='file'] {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 0.9rem;
  color: var(--ink);
  font: 500 1rem var(--body);
}
.admin input::placeholder { color: oklch(45% 0.06 305); }
.admin .hint { font-weight: 500; font-size: 0.95rem; }
.egg-list { display: grid; gap: 0.6rem; }
.egg-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 1rem; background: var(--paper); color: var(--ink);
  border: 3px solid var(--ink); border-radius: 1rem;
}
.egg-list .who { font-weight: 800; }
.egg-list .said { font-weight: 500; }
.egg-list button { flex: none; padding: 0.4rem 0.8rem; background: none; border: 2px solid var(--ink); border-radius: 999px; color: var(--ink); font: 700 0.9rem var(--body); cursor: pointer; }
.admin .msg { font-weight: 700; min-height: 1.5em; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
}
