/* ==========================================================================
   Story Time — App-specific CSS (prefix: st-)
   Loaded after global papupa.css. Do NOT add selectors here to Layer 1.
   ========================================================================== */

/* Leaderboard theme overrides */
:root {
  --lb-primary:   #d97706;
  --lb-secondary: #92400e;
  --lb-bg:        #fffbf0;
  --lb-gold:      #f59e0b;
  --lb-silver:    #9ca3af;
  --lb-bronze:    #d97706;
}

/* --------------------------------------------------------------------------
   Page background
   -------------------------------------------------------------------------- */
body {
  background-color: #fffbf0;
  background-image:
    radial-gradient(ellipse at top left,  rgba(251,191, 36, 0.18) 0%, transparent 55%),
    radial-gradient(ellipse at bottom right, rgba(217,119,  6, 0.14) 0%, transparent 55%);
}

/* --------------------------------------------------------------------------
   Root container
   -------------------------------------------------------------------------- */
#st-app {
  max-width: 580px;
  margin: 0 auto;
  padding: var(--space-sm);
}

/* --------------------------------------------------------------------------
   Shared primitives
   -------------------------------------------------------------------------- */

/* Progress bar */
.st-progress-bar {
  width: 100%;
  height: 5px;
  background: #e5e7eb;
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.st-progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #d97706);
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* Pills */
.st-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
  background: #fef3c7;
  color: #92400e;
  white-space: nowrap;
}
.st-pill--amber {
  background: #d97706;
  color: #fff;
}

/* Buttons */
.st-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1.5rem;
  border-radius: 99px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.12s;
  text-decoration: none;
}
.st-btn:active { transform: scale(0.97); }
.st-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.st-btn--primary {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(217,119,6,0.35);
}
.st-btn--primary:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(217,119,6,0.45);
}

.st-btn--ghost {
  background: #fff;
  color: #d97706;
  border: 2px solid #d97706;
}
.st-btn--ghost:hover:not(:disabled) {
  background: #fef3c7;
}

.st-btn--nav {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
}
.st-btn--nav:hover:not(:disabled) { background: #e5e7eb; }

.st-btn--next {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(217,119,6,0.3);
}

.st-btn--wide { width: 100%; max-width: 300px; }

/* Back / skip links */
.st-back-link,
.st-skip-link {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  color: #9ca3af;
  text-decoration: underline;
  padding: 0.5rem 0;
}
.st-back-link:hover, .st-skip-link:hover { color: #6b7280; }

/* --------------------------------------------------------------------------
   Welcome screen
   -------------------------------------------------------------------------- */
.st-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem 0 2rem;
}

.st-welcome__header {
  text-align: center;
}

.st-welcome__icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.st-welcome__title {
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #d97706 0%, #92400e 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0 0 0.4rem;
  filter: drop-shadow(0 2px 4px rgba(217,119,6,0.2));
}

.st-welcome__subtitle {
  font-size: 1rem;
  color: #6b7280;
  margin: 0;
}

/* Level selection grid */
.st-level-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  width: 100%;
}

.st-level-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 1rem 0.5rem;
  border-radius: 16px;
  border: 2px solid #e5e7eb;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  text-align: center;
}
.st-level-card:hover {
  border-color: #d97706;
  background: #fffbf0;
}
.st-level-card--active {
  border-color: #d97706;
  background: #fef3c7;
  box-shadow: 0 0 0 3px rgba(217,119,6,0.18);
}

.st-level-card__icon { font-size: 1.75rem; }

.st-level-card__label {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1f2937;
}

.st-level-card__desc {
  font-size: 0.68rem;
  color: #9ca3af;
  line-height: 1.3;
}

/* Feature badges */
.st-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.st-badge {
  padding: 0.3rem 0.8rem;
  border-radius: 99px;
  background: #fef9ee;
  border: 1px solid #f59e0b;
  font-size: 0.8rem;
  color: #92400e;
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   Cover screen
   -------------------------------------------------------------------------- */
.st-cover {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0 2rem;
  text-align: center;
}

.st-cover__badge {
  padding: 0.3rem 1rem;
  border-radius: 99px;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.85rem;
  font-weight: 700;
  border: 1px solid #f59e0b;
}

.st-cover__image {
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.st-cover__image-placeholder {
  width: 160px;
  height: 160px;
  border-radius: 20px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.st-cover__title {
  font-size: 1.75rem;
  font-weight: 800;
  color: #1f2937;
  margin: 0.25rem 0 0;
  line-height: 1.25;
}

.st-cover__tagline {
  font-size: 1rem;
  color: #6b7280;
  margin: 0;
  max-width: 320px;
  line-height: 1.5;
  font-style: italic;
}

.st-cover__meta {
  font-size: 0.85rem;
  color: #d97706;
  font-weight: 600;
  margin: 0;
}

.st-cover__actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

/* Loading */
.st-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 3rem 0;
  color: #9ca3af;
}

.st-loading__spinner {
  font-size: 2.5rem;
  animation: st-pulse 1.2s ease-in-out infinite;
}

@keyframes st-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.15); opacity: 0.7; }
}

/* --------------------------------------------------------------------------
   Reading screen
   -------------------------------------------------------------------------- */
.st-reading {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.st-reading__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Book page card */
.st-page-card {
  position: relative;
  background: #fff;
  border-radius: 4px 16px 16px 4px;
  box-shadow:
    -4px 0 0 0 #d97706,
    0 4px 20px rgba(0,0,0,0.1);
  padding: 2rem 1.75rem 2rem 2rem;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.st-page-card__spine {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
  border-radius: 4px 0 0 4px;
}

.st-page-card__content {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.05rem;
  line-height: 1.85;
  color: #1f2937;
  margin: 0;
}

.st-page-card__number {
  position: absolute;
  bottom: 0.75rem;
  right: 1rem;
  font-size: 0.78rem;
  color: #d1d5db;
  font-family: Georgia, serif;
  font-style: italic;
}

/* Reading nav */
.st-reading__nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

/* Page-turn animation */
@keyframes st-page-in {
  from { opacity: 0; transform: translateX(18px); }
  to   { opacity: 1; transform: translateX(0); }
}
.st-page-card { animation: st-page-in 0.25s ease; }

/* --------------------------------------------------------------------------
   Questions screen
   -------------------------------------------------------------------------- */
.st-questions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  position: relative;
}

.st-questions__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Question card */
.st-q-card {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  padding: 1.5rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.st-q-card__text {
  font-size: 1.05rem;
  font-weight: 600;
  color: #1f2937;
  line-height: 1.5;
  margin: 0;
}

/* Options */
.st-options {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.st-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 2px solid #e5e7eb;
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.st-option:hover:not(:disabled) {
  border-color: #f59e0b;
  background: #fffbf0;
}
.st-option--selected {
  border-color: #d97706;
  background: #fef3c7;
}
.st-option--correct {
  border-color: #16a34a;
  background: #f0fdf4;
  animation: st-pop 0.3s ease;
}
.st-option--wrong {
  border-color: #dc2626;
  background: #fef2f2;
  animation: st-shake 0.4s ease;
}

.st-option__key {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f3f4f6;
  font-size: 0.78rem;
  font-weight: 800;
  color: #374151;
  flex-shrink: 0;
}
.st-option--selected .st-option__key  { background: #d97706; color: #fff; }
.st-option--correct  .st-option__key  { background: #16a34a; color: #fff; }
.st-option--wrong    .st-option__key  { background: #dc2626; color: #fff; }

.st-option__text {
  font-size: 0.9rem;
  color: #374151;
  line-height: 1.4;
}

/* Feedback bar */
.st-feedback {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  animation: st-slide-up 0.25s ease;
}
.st-feedback--correct { background: #dcfce7; color: #15803d; }
.st-feedback--wrong   { background: #fee2e2; color: #b91c1c; }

/* Streak bonus popup */
.st-streak-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  background: #f59e0b;
  color: #fff;
  padding: 0.6rem 1.4rem;
  border-radius: 99px;
  font-size: 1.1rem;
  font-weight: 800;
  box-shadow: 0 6px 24px rgba(245,158,11,0.45);
  animation: st-bonus-pop 1.5s ease forwards;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Result screen
   -------------------------------------------------------------------------- */
.st-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem 0 2rem;
  text-align: center;
}

.st-result__header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.st-result__emoji {
  font-size: 3.5rem;
}

.st-result__heading {
  font-size: 1.6rem;
  font-weight: 800;
  color: #4b5563;
  margin: 0;
}
.st-result__heading--win {
  background: linear-gradient(135deg, #d97706 0%, #92400e 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.st-result__note {
  font-size: 0.9rem;
  color: #9ca3af;
  margin: 0;
}

/* Metrics */
.st-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  width: 100%;
}

.st-metric {
  background: #fff;
  border-radius: 14px;
  padding: 1rem 0.5rem;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.st-metric__value {
  font-size: 1.6rem;
  font-weight: 800;
  color: #d97706;
}

.st-metric__label {
  font-size: 0.75rem;
  color: #9ca3af;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.st-result__story-card {
  background: #fef3c7;
  border-radius: 12px;
  padding: 0.75rem 1.25rem;
  width: 100%;
}

.st-result__story-title {
  font-size: 0.9rem;
  color: #92400e;
  margin: 0;
}

.st-result__actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.st-result__signin {
  font-size: 0.85rem;
  color: #9ca3af;
  margin: 0;
}
.st-result__signin a {
  color: #d97706;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Animations
   -------------------------------------------------------------------------- */
@keyframes st-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}

@keyframes st-shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-5px); }
  40%       { transform: translateX(5px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

@keyframes st-slide-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes st-bonus-pop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  15%  { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  25%  { transform: translate(-50%, -50%) scale(1); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(0.9); }
}

/* --------------------------------------------------------------------------
   Responsive — mobile ≤ 480px
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .st-welcome__title { font-size: 1.8rem; }

  .st-level-card { padding: 0.75rem 0.4rem; }
  .st-level-card__icon { font-size: 1.4rem; }
  .st-level-card__label { font-size: 0.8rem; }
  .st-level-card__desc { font-size: 0.62rem; }

  .st-page-card {
    padding: 1.5rem 1.25rem 1.5rem 1.5rem;
    min-height: 200px;
  }
  .st-page-card__content { font-size: 0.95rem; line-height: 1.75; }

  .st-metric__value { font-size: 1.3rem; }

  .st-cover__image,
  .st-cover__image-placeholder { width: 130px; height: 130px; }
  .st-cover__title { font-size: 1.4rem; }
}
