/* ============================================================
   nini — a small black cat on warm paper.
   ============================================================ */

:root {
  --paper:     #faf5ec;
  --paper-2:   #fffdf8;
  --ink:       #4a423c;
  --ink-2:     #8b8177;
  --ink-3:     #b3a89b;
  --line:      #e4dacb;
  --line-soft: #efe6d8;
  --accent:    #d98b5f;
  --blush:     #f2d9cd;

  --font:  'Neucha', 'Comic Sans MS', ui-rounded, system-ui, sans-serif;
  --hand:  'Caveat', 'Neucha', cursive;

  --r:    18px;
  --r-lg: 24px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* a whisper of paper grain so the background is not dead flat */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .35;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
}

body > * { position: relative; z-index: 1; }

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }

/* -------------------------------------------------------------- head ---- */

.head {
  flex: none;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 34px) 0;
}

.brand {
  margin: 0;
  font-family: var(--hand);
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .5px;
}

.brand__note {
  margin-left: 12px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  color: var(--ink-3);
}

.model {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  color: var(--ink-2);
  white-space: nowrap;
}

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink-3);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, .03);
}

.dot.is-live  { background: #7fb069; }
.dot.is-dead  { background: #d98b5f; }

@media (max-width: 620px) {
  .brand { font-size: 28px; }
  .brand__note { display: none; }
}

/* ------------------------------------------------------------- stage ---- */

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 clamp(16px, 4vw, 34px);
}

.scene {
  flex: none;
  position: relative;
  width: min(520px, 100%);
  margin: clamp(6px, 2vh, 22px) 0 clamp(10px, 2vh, 18px);
  display: grid;
  place-items: center;
}

.cat {
  position: relative;
  /* The viewport-height cap matters too: without it a short window lets the cat
     eat all the room and the conversation collapses to nothing. */
  width: min(230px, 46vw, 30vh);
  aspect-ratio: 600 / 521;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* Frames sit in a stack: swapping one is a visibility flip, nothing loads. */
.frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  visibility: hidden;
}

.frame.is-on { visibility: visible; }

.cat.is-poked { animation: poke .45s ease; }

@keyframes poke {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.06, .95); }
  70%  { transform: scale(.98, 1.03); }
  100% { transform: scale(1); }
}

/* A heart per poke: it drifts up out of the cat and is gone in under a second. */
.heart {
  position: absolute;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;   /* the click point sits in the middle of the heart */
  pointer-events: none;
  will-change: transform, opacity;
  animation: heart-up .9s cubic-bezier(.3, .7, .4, 1) forwards;
}

@keyframes heart-up {
  0%   { opacity: 0; transform: translate(0, 4px) scale(.45) rotate(-10deg); }
  18%  { opacity: 1; transform: translate(0, -12px) scale(1.08) rotate(5deg); }
  60%  { opacity: .95; }
  100% { opacity: 0; transform: translate(var(--drift, 0px), -110px) scale(.85) rotate(-6deg); }
}

.grass {
  position: absolute;
  bottom: -4px;
  width: 34px;
  color: var(--ink-3);
  opacity: .8;
}

.grass--l { left: -32px; }
.grass--r { right: -32px; }

/* --- the thought card --- */

.thought {
  position: absolute;
  left: 0;
  bottom: 6%;
  padding: 10px 14px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--r);
  background: var(--paper-2);
  box-shadow: 0 6px 16px rgba(120, 100, 80, .07);
  animation: floatIn .5s ease;
}

@keyframes floatIn {
  from { opacity: 0; transform: translateY(6px); }
}

.thought::after {
  content: '';
  position: absolute;
  right: 26px; bottom: -8px;
  width: 13px; height: 13px;
  rotate: 45deg;
  background: var(--paper-2);
  border-right: 1.5px solid var(--line);
  border-bottom: 1.5px solid var(--line);
  border-bottom-right-radius: 4px;
}

.thought__name {
  font-family: var(--hand);
  font-size: 21px;
  font-weight: 600;
  line-height: 1;
}

.thought__mood {
  margin-top: 3px;
  font-size: 14px;
  color: var(--ink-2);
  transition: opacity .25s ease;
}

.thought__mood.is-fading { opacity: 0; }

@media (max-width: 620px) {
  .thought { left: 0; bottom: 2%; padding: 8px 11px 10px; }
  .thought__name { font-size: 18px; }
  .thought__mood { font-size: 13px; }
}

/* ---------------------------------------------------------- the talk ---- */

.talk {
  flex: 1;
  width: min(660px, 100%);
  min-height: 92px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.line {
  max-width: 88%;
  padding: 13px 18px;
  border-radius: var(--r-lg);
  animation: rise .3s ease;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
}

.line--nini {
  align-self: flex-start;
  border: 1.5px solid var(--line);
  background: var(--paper-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.line--me {
  align-self: flex-end;
  background: var(--blush);
  color: #6a4a3c;
  border-bottom-right-radius: 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.line--error { border-color: #e3b7a4; color: #a75c41; }

.dots { display: inline-flex; gap: 5px; padding: 4px 0 2px; }

.dots i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ink-3);
  animation: dot 1.2s ease-in-out infinite;
}

.dots i:nth-child(2) { animation-delay: .16s; }
.dots i:nth-child(3) { animation-delay: .32s; }

@keyframes dot {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30%           { opacity: 1;  transform: translateY(-3px); }
}

/* ------------------------------------------------------------- input ---- */

.composer {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 6px clamp(16px, 4vw, 34px) clamp(16px, 3vh, 26px);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  max-width: 660px;
}

.chip {
  padding: 8px 15px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--paper-2);
  font-size: 15px;
  color: var(--ink-2);
  transition: transform .18s cubic-bezier(.34, 1.56, .64, 1), color .18s, border-color .18s;
}

.chip:hover { transform: translateY(-2px); color: var(--ink); border-color: var(--ink-3); }
.chip:active { transform: translateY(0) scale(.97); }

.say {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(660px, 100%);
  padding: 8px 8px 8px 20px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--paper-2);
  transition: border-color .2s, box-shadow .2s;
}

.say:focus-within {
  border-color: var(--ink-3);
  box-shadow: 0 6px 20px rgba(120, 100, 80, .08);
}

.say__input {
  flex: 1;
  min-width: 0;
  padding: 7px 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--ink);
}

.say__input::placeholder { color: var(--ink-3); }
.say__input:focus { outline: none; }

.say__send {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--line-soft);
  color: var(--ink-2);
  transition: transform .18s cubic-bezier(.34, 1.56, .64, 1), background .18s, color .18s;
}

.say__send:hover:not(:disabled) { background: var(--accent); color: #fff; transform: scale(1.06); }
.say__send:active:not(:disabled) { transform: scale(.94); }
.say__send:disabled { opacity: .45; cursor: default; }

.say--gate { border-style: dashed; }
.say--gate .say__input { letter-spacing: 2px; }

.note {
  margin: 0;
  min-height: 18px;
  font-size: 14px;
  color: var(--ink-3);
  text-align: center;
}

.note.is-warn { color: #a75c41; }

@media (max-width: 620px) {
  body { font-size: 16px; }
  .chip { font-size: 14px; padding: 7px 12px; }
  .line { padding: 11px 15px; }
}

/* Short window: the suggestions go, everything tightens — the talk matters more. */
@media (max-height: 620px) {
  .scene { margin: 4px 0 6px; }
  .chips { display: none; }
  .composer { gap: 6px; padding-bottom: 12px; }
  .note { min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .1s !important;
  }
}
