/* Nib — mascot and chat UI styles. Scoped with .nib-* prefix. */

/* ---------- Mascot ---------- */

.nib-mascot {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  gap: 0.25rem;
  flex-shrink: 0;
}

/* ----------------------------------------------------------------------------
   Organic blob backdrop for solo (md/lg) mascot appearances — empty
   states, error pages, hero sections. Gated on size so the small inline
   mascots in chat headers and result headings stay flat. The blob slowly
   morphs between two pseudo-random radii so the surface around Nib reads
   as alive, not a hard rectangle. Tinted with the active --pico-primary
   so it tracks admin theme overrides.
   ---------------------------------------------------------------------------- */
.nib-mascot--md::before,
.nib-mascot--lg::before {
  content: "";
  position: absolute;
  inset: -6%;
  z-index: -1;
  background: color-mix(in srgb, var(--pico-primary, #1565c0) 10%, transparent);
  border-radius: 38% 62% 63% 37% / 41% 44% 56% 59%;
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  .nib-mascot--md::before,
  .nib-mascot--lg::before {
    animation: nib-blob-drift 18s ease-in-out infinite alternate;
  }
}

@keyframes nib-blob-drift {
  to {
    border-radius: 52% 48% 36% 64% / 55% 39% 61% 45%;
  }
}

.nib-mascot-img {
  display: block;
  height: auto;
  image-rendering: -webkit-optimize-contrast;
  animation: nib-float 3.5s ease-in-out infinite;
  transform-origin: center bottom;
  will-change: transform;
}

.nib-mascot-img:hover {
  animation: nib-wiggle 0.6s ease-in-out;
}

.nib-mascot--sm .nib-mascot-img { width: 64px; height: 64px; }
.nib-mascot--md .nib-mascot-img { width: 120px; height: 120px; }
.nib-mascot--lg .nib-mascot-img { width: 200px; height: 200px; }

@keyframes nib-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-6px) rotate(-1.5deg); }
}

@keyframes nib-wiggle {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  20%      { transform: translateY(-4px) rotate(-6deg); }
  60%      { transform: translateY(-4px) rotate(6deg); }
  80%      { transform: translateY(-2px) rotate(-3deg); }
}

@media (prefers-reduced-motion: reduce) {
  .nib-mascot-img,
  .nib-mascot-img:hover {
    animation: none;
  }
}

.nib-mascot figcaption {
  font-size: 0.85em;
  opacity: 0.8;
  text-align: center;
}

/* ---------- Chat header ---------- */

.nib-chat-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.nib-chat-header-text {
  min-width: 0;
}

.nib-chat-header-text h1 {
  margin: 0 0 0.25rem 0;
  line-height: 1.2;
}

.nib-chat-header-text p {
  margin: 0;
  opacity: 0.85;
}

/* ---------- Link/button rows ---------- */

.nib-links,
.nib-profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
  margin-bottom: 0;
}

.nib-links [role="button"],
.nib-profile-actions [role="button"] {
  padding: 0.35rem 0.85rem;
  font-size: 0.9em;
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

/* ---------- Conversation transcript ---------- */

#nib-messages {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 120px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 0.25rem 0;
}

#nib-messages:empty {
  min-height: 0;
}

.nib-msg {
  padding: 0.65rem 0.95rem;
  border-radius: 0.6rem;
  max-width: 85%;
  line-height: 1.45;
  word-wrap: break-word;
}

.nib-msg--user {
  align-self: flex-end;
  background: var(--pico-primary-background, #334);
  color: var(--pico-primary-inverse, #fff);
}

.nib-msg--nib {
  align-self: flex-start;
  background: var(--pico-card-sectioning-background-color, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--pico-muted-border-color, rgba(255, 255, 255, 0.1));
}

.nib-msg p:last-child { margin-bottom: 0; }
.nib-msg p:first-child { margin-top: 0; }

.nib-loading {
  padding: 0.25rem 0;
  font-style: italic;
  opacity: 0.7;
}

/* ---------- Form ---------- */

.nib-form {
  margin: 1.5rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nib-form-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.nib-form-row input[type="text"] {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}

.nib-form-row button[type="submit"] {
  flex: 0 0 auto;
  white-space: nowrap;
  width: auto;
  min-width: 7rem;
  margin: 0;
}

.nib-form-actions {
  display: flex;
  justify-content: flex-start;
  margin: 0;
}

.nib-form-actions button {
  font-size: 0.85em;
  padding: 0.3rem 0.75rem;
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

/* ---------- Memory list on profile page ---------- */

.nib-memory-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nib-memory-list > li.nib-memory-item {
  list-style: none;
}

.nib-memory-item {
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--pico-muted-border-color, rgba(255, 255, 255, 0.1));
  border-radius: 0.5rem;
  background: var(--pico-card-sectioning-background-color, rgba(255, 255, 255, 0.02));
}

.nib-memory-item::marker {
  content: "";
}

.nib-memory-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: space-between;
}

.nib-memory-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nib-memory-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nib-memory-delete {
  margin: 0;
  flex: 0 0 auto;
}

.nib-memory-delete button {
  padding: 0.2rem 0.55rem;
  font-size: 0.9em;
  margin: 0;
  line-height: 1.2;
}

.nib-memory-meta {
  font-size: 0.8em;
  opacity: 0.65;
  margin-top: 0.2rem;
}

.nib-memory-excerpt {
  margin: 0.4rem 0 0 0;
  opacity: 0.88;
  font-size: 0.95em;
}

/* ---------- Skin gallery on profile page ---------- */

.nib-skin-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.nib-skin-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.85rem;
  border: 1px solid var(--pico-muted-border-color, rgba(255, 255, 255, 0.1));
  border-radius: 0.6rem;
  background: var(--pico-card-sectioning-background-color, rgba(255, 255, 255, 0.02));
  text-align: center;
  margin: 0;
}

.nib-skin-card--equipped {
  border-color: var(--pico-primary, #399);
  box-shadow: 0 0 0 2px var(--pico-primary, #399) inset;
}

.nib-skin-card--locked {
  opacity: 0.7;
}

.nib-skin-preview {
  width: 96px;
  height: 96px;
  object-fit: contain;
}

.nib-skin-preview--locked {
  filter: grayscale(1) brightness(0.6);
}

.nib-skin-title {
  margin: 0;
  font-size: 1em;
}

.nib-skin-description {
  margin: 0;
  font-size: 0.85em;
  opacity: 0.8;
}

.nib-skin-equip {
  margin: 0;
}

.nib-skin-equip button {
  padding: 0.3rem 0.85rem;
  font-size: 0.9em;
  margin: 0;
}

.nib-skin-unlock-hint {
  margin: 0;
  font-size: 0.85em;
  opacity: 0.75;
}

.nib-tone-value {
  float: inline-end;
}
