/* Story Nest — kid retention features */

:root {
  --sn-fun-text: #0c4a6e;
  --sn-fun-muted: #0369a1;
  --sn-fun-label: #0284c7;
  --sn-fun-surface: #ffffff;
  --sn-fun-surface-soft: #f0f9ff;
  --sn-fun-border: #bae6fd;
  --sn-fun-cost: #b45309;
  --sn-fun-free: #15803d;
}

.sn-fun-overlay,
.sn-star-goal,
.sn-mascot-bubble,
.sn-bookshelf-bar {
  --text: var(--sn-fun-text);
  --muted: var(--sn-fun-muted);
  --accent-dark: var(--sn-fun-label);
  --border: var(--sn-fun-border);
}

.sn-fun-buttons {
  display: flex;
  gap: 6px;
}

.sn-star-goal {
  grid-column: 1 / -1;
  margin: 0;
  padding: 6px 10px;
  border-radius: 14px;
  background: var(--sn-fun-surface);
  border: 2px solid var(--sn-fun-border);
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--sn-fun-text);
  text-align: center;
  box-shadow: 0 4px 14px rgba(12, 74, 110, 0.08);
}

.sn-star-goal #starGoalLabel {
  display: block;
  color: var(--sn-fun-text);
}

.sn-star-goal-bar {
  height: 6px;
  margin-top: 4px;
  border-radius: 999px;
  background: #e0f2fe;
  overflow: hidden;
}

.sn-star-goal-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #38bdf8, #0284c7);
  transition: width 0.35s ease;
}

.sn-bookshelf-bar {
  grid-column: 1 / -1;
  margin: 0;
  padding: 6px 10px;
  border-radius: 14px;
  background: linear-gradient(180deg, #eef2ff, #ffffff);
  border: 2px solid #a5b4fc;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--sn-fun-text);
  text-align: center;
}

.sn-bookshelf-fill {
  height: 6px;
  margin-top: 4px;
  border-radius: 999px;
  background: #e0e7ff;
  overflow: hidden;
}

.sn-bookshelf-fill span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #818cf8, #4f46e5);
  transition: width 0.35s ease;
}

.sn-practice-notices {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
}

.sn-practice-notices .sn-unlock-banner {
  margin-bottom: 0;
}

.sn-story-header-wrap {
  position: relative;
}

.sn-mascot-bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  top: auto;
  z-index: 4;
  max-width: min(220px, 72vw);
  padding: 6px 12px;
  border-radius: 16px;
  border: 2px solid var(--sn-fun-border);
  background: var(--sn-fun-surface);
  box-shadow: 0 8px 20px rgba(12, 74, 110, 0.16);
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--sn-fun-text);
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 6px) scale(0.92);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.sn-mascot-bubble.is-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.sn-mascot-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  top: auto;
  bottom: -8px;
  width: 12px;
  height: 12px;
  background: var(--sn-fun-surface);
  border-right: 2px solid var(--sn-fun-border);
  border-bottom: 2px solid var(--sn-fun-border);
  transform: translateX(-50%) rotate(45deg);
}

.sn-nest-decor {
  position: relative;
  z-index: 1;
  display: block;
  margin: 0 0 -0.2rem;
  font-size: clamp(1.85rem, 7vw, 2.55rem);
  line-height: 1;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.18));
  pointer-events: none;
  animation: snStickerFloat 2.4s ease-in-out infinite;
  transform-origin: center bottom;
}

.sn-nest-decor.hidden {
  display: none;
}

.sn-banner-hero {
  position: absolute;
  right: 0.35rem;
  bottom: 0.1rem;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  pointer-events: none;
  filter: drop-shadow(0 6px 10px rgba(12, 44, 70, 0.22));
}

.sn-nest-hero {
  display: block;
  font-size: clamp(2.55rem, 10vw, 3.45rem);
  line-height: 1;
  animation: none;
  transform-origin: center bottom;
}

@keyframes snStickerFloat {
  0%, 100% {
    transform: translateY(0) rotate(-8deg);
  }
  50% {
    transform: translateY(-10px) rotate(8deg);
  }
}

@keyframes snHeroBob {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sn-nest-decor,
  .sn-nest-hero {
    animation: none;
  }
}

.sn-fun-overlay {
  position: fixed;
  inset: 0;
  z-index: 88;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(12, 44, 70, 0.58);
  backdrop-filter: blur(5px);
}

.sn-fun-overlay.hidden {
  display: none;
}

.sn-fun-window {
  position: relative;
  width: min(560px, 100%);
  max-height: min(82dvh, 720px);
  overflow-y: auto;
  padding: 20px 18px;
  border: 3px solid var(--sn-fun-border);
  border-radius: 28px;
  background: var(--sn-fun-surface-soft);
  color: var(--sn-fun-text);
  box-shadow: 0 24px 60px rgba(12, 44, 70, 0.28);
}

.sn-fun-window .sn-eyebrow {
  color: var(--sn-fun-label);
}

.sn-fun-window h2 {
  margin: 0 0 8px;
  color: var(--sn-fun-text);
}

.sn-fun-window .sn-close {
  color: var(--sn-fun-text);
  background: var(--sn-fun-surface);
  border: 2px solid var(--sn-fun-border);
}

.sn-fun-intro {
  margin: 0 0 14px;
  color: var(--sn-fun-muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.sn-fun-intro strong {
  color: var(--sn-fun-text);
}

.sn-decor-grid,
.sn-favorites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.sn-decor-card,
.sn-favorite-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border: 2px solid var(--sn-fun-border);
  border-radius: 18px;
  background: var(--sn-fun-surface);
  color: var(--sn-fun-text);
  text-align: center;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.sn-decor-card:hover,
.sn-favorite-card:hover,
.sn-decor-card:focus-visible,
.sn-favorite-card:focus-visible {
  transform: translateY(-2px);
  border-color: #0284c7;
}

.sn-decor-card.is-owned {
  border-color: #16a34a;
  background: linear-gradient(180deg, #f0fdf4, #ffffff);
}

.sn-decor-card.is-equipped {
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.16);
}

.sn-decor-card.is-locked {
  opacity: 0.88;
}

.sn-decor-emoji,
.sn-favorite-scene {
  font-size: 2rem;
  line-height: 1;
}

.sn-decor-name,
.sn-favorite-title {
  font-size: 0.82rem;
  font-weight: 900;
  color: var(--sn-fun-text);
}

.sn-favorite-grade {
  display: block;
  margin-top: 4px;
  color: #58756a;
  font-size: .72rem;
  font-weight: 850;
}

.sn-favorites-status {
  min-height: 1.25em;
  margin: -2px 0 10px;
  color: #8a4c2f;
  font-size: .8rem;
  font-weight: 850;
  text-align: center;
}

.sn-favorites-status:empty {
  display: none;
}

.sn-decor-cost {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--sn-fun-cost);
}

.sn-decor-cost.is-free {
  color: var(--sn-fun-free);
}

.sn-journal-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.sn-journal-stat {
  padding: 10px 8px;
  border-radius: 16px;
  border: 2px solid var(--sn-fun-border);
  background: var(--sn-fun-surface);
  text-align: center;
}

.sn-journal-stat span {
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--sn-fun-muted);
}

.sn-journal-stat strong {
  display: block;
  margin-top: 2px;
  font-size: 1.1rem;
  color: var(--sn-fun-text);
}

.sn-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.sn-badge-chip {
  padding: 6px 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, #e0f2fe, #bae6fd);
  border: 1px solid #0284c7;
  font-size: 0.72rem;
  font-weight: 900;
  color: #0c4a6e;
}

.sn-badge-chip.is-locked {
  background: #eef2f7;
  border-color: #cbd5e1;
  color: #475569;
}

.sn-journal-list {
  display: grid;
  gap: 8px;
}

.sn-journal-list .history-empty {
  color: var(--sn-fun-muted);
}

.sn-journal-list .history-empty strong {
  color: var(--sn-fun-text);
}

.sn-journal-list .history-empty p {
  margin: 4px 0 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--sn-fun-muted);
}

.sn-journal-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 2px solid var(--sn-fun-border);
  background: var(--sn-fun-surface);
}

.sn-journal-item-emoji {
  font-size: 1.5rem;
}

.sn-journal-item-copy strong {
  display: block;
  font-size: 0.88rem;
  color: var(--sn-fun-text);
}

.sn-journal-item-copy span {
  font-size: 0.72rem;
  color: var(--sn-fun-muted);
  font-weight: 700;
}

.sn-bookshelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.sn-bookshelf-slot {
  min-width: 0;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  padding: 5px;
  border-radius: 12px;
  border: 2px dashed #cbd5e1;
  background: #f8fafc;
  color: var(--sn-fun-text);
  text-align: center;
  line-height: 1.05;
}

button.sn-bookshelf-slot {
  width: 100%;
  font: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.sn-bookshelf-scene {
  display: block;
  font-size: 1.35rem;
  line-height: 1;
}

.sn-bookshelf-story-title {
  display: -webkit-box;
  max-width: 100%;
  overflow: hidden;
  color: var(--sn-fun-muted);
  font-size: 0.56rem;
  font-weight: 900;
  line-height: 1.05;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.sn-bookshelf-slot.is-read {
  border-style: solid;
  border-color: #818cf8;
  background: linear-gradient(180deg, #eef2ff, #ffffff);
  box-shadow: 0 3px 10px rgba(79, 70, 229, 0.10);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.sn-bookshelf-slot.is-read:hover {
  transform: translateY(-2px);
  border-color: #4f46e5;
  box-shadow: 0 7px 16px rgba(79, 70, 229, 0.18);
}

.sn-bookshelf-slot.is-read:active {
  transform: translateY(0) scale(0.98);
}

.sn-bookshelf-slot.is-read:focus-visible {
  outline: 3px solid rgba(2, 132, 199, 0.35);
  outline-offset: 2px;
}

.sn-bookshelf-slot.is-locked {
  opacity: 0.68;
}

.sn-bookshelf-slot.is-locked .sn-bookshelf-story-title {
  color: #94a3b8;
}

@media (prefers-reduced-motion: reduce) {
  .sn-bookshelf-slot.is-read {
    transition: none;
  }

  .sn-bookshelf-slot.is-read:hover,
  .sn-bookshelf-slot.is-read:active {
    transform: none;
  }
}

.sn-unlock-banner {
  padding: 8px 10px;
  border-radius: 14px;
  border: 2px solid #0284c7;
  background: linear-gradient(180deg, #e0f2fe, #ffffff);
  color: #0c4a6e;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
}

.sn-unlock-banner.hidden {
  display: none;
}

.sn-unlock-banner p {
  margin: 0;
}

.sn-unlock-banner button {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, #38bdf8, #0284c7);
  color: white;
  font-weight: 900;
  font-size: 0.82rem;
}

@media (min-width: 700px) and (min-height: 560px) {
  .sn-stats {
    grid-template-columns: repeat(3, 1fr);
  }
}
