/* ── Storytime — Page-Specific CSS ──
   Story browser, reading column, ending screen.
   Parchment theme via shared.css (.parchment-page on <body>).
*/

/* ── Page header ── */
.storytime-header {
  text-align: center;
  padding: 36px 24px 16px;
}
.storytime-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 2rem;
  color: #3d3225;
  margin-bottom: 6px;
}
.storytime-subtitle {
  font-size: 0.95rem;
  color: rgba(61, 50, 37, 0.6);
  max-width: 500px;
  margin: 0 auto;
}

/* ══════════════════════════════════════════════════════════
   STORY BROWSER
   ══════════════════════════════════════════════════════════ */

.story-category {
  margin-bottom: 32px;
}
.story-category-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 0 4px 10px;
  border-bottom: 1px solid rgba(160, 140, 110, 0.2);
  margin-bottom: 16px;
}
.story-category-label {
  font-family: Georgia, serif;
  font-size: 0.8rem;
  font-variant: small-caps;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.story-category-legend {
  color: #8B6914;
}
.story-category-crossroads {
  color: #4A6FA5;
}
.story-category-sub {
  font-size: 0.8rem;
  color: rgba(61, 50, 37, 0.45);
}

/* ── Story card grid ── */
.story-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ── Story card ── */
.story-card {
  display: flex;
  flex-direction: column;
  background: rgba(255, 250, 240, 0.5);
  border: 1px solid rgba(160, 140, 110, 0.2);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s ease;
}
.story-card:hover {
  background: rgba(255, 250, 240, 0.7);
  border-color: rgba(160, 140, 110, 0.4);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}
.story-card-locked {
  opacity: 0.7;
  cursor: default;
}
.story-card-locked:hover {
  transform: none;
  box-shadow: none;
}

.story-card-cover {
  position: relative;
  height: 140px;
  background: linear-gradient(135deg, rgba(139, 105, 20, 0.08), rgba(80, 60, 30, 0.12));
  background-size: cover;
  background-position: center;
}
.story-card-cover .story-badge {
  position: absolute;
  top: 12px;
  left: 12px;
}

.story-card-lock {
  position: absolute;
  inset: 0;
  background: rgba(61, 50, 37, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.story-card-lock span {
  background: rgba(61, 50, 37, 0.85);
  color: #e8dcc8;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
}

.story-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.story-badge-legend {
  background: rgba(139, 105, 20, 0.15);
  color: #8B6914;
}
.story-badge-crossroads {
  background: rgba(74, 111, 165, 0.15);
  color: #4A6FA5;
}

.story-card-body {
  padding: 12px 14px 14px;
}
.story-card-title {
  font-family: Georgia, serif;
  font-size: 1.05rem;
  color: #3d3225;
  margin-bottom: 4px;
}
.story-card-philosopher {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: rgba(61, 50, 37, 0.7);
}
.story-card-mono {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.story-card-setting {
  font-size: 0.82rem;
  color: rgba(61, 50, 37, 0.55);
  margin-bottom: 8px;
}
.story-card-premise {
  font-size: 0.82rem;
  color: rgba(61, 50, 37, 0.65);
  line-height: 1.45;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.story-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: rgba(61, 50, 37, 0.45);
}
.story-card-new {
  color: #8B6914;
  font-weight: 600;
}
.story-card-progress {
  color: rgba(61, 50, 37, 0.5);
}
.story-card-time {
  color: rgba(61, 50, 37, 0.4);
}

.story-empty {
  text-align: center;
  padding: 60px 20px;
  color: rgba(61, 50, 37, 0.4);
  font-size: 0.95rem;
}

/* ══════════════════════════════════════════════════════════
   STORY READER
   ══════════════════════════════════════════════════════════ */

#storyReader {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

/* Progress bar */
.story-progress {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 10px 0 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.progress-bar {
  flex: 1;
  height: 3px;
  background: rgba(160, 140, 110, 0.15);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: rgba(139, 105, 20, 0.4);
  border-radius: 2px;
  transition: width 0.5s ease;
}
.progress-label {
  font-size: 0.7rem;
  color: rgba(61, 50, 37, 0.35);
  white-space: nowrap;
}

/* Back button */
.scene-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: rgba(61, 50, 37, 0.45);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 16px;
  transition: color 0.2s;
}
.scene-back-btn:hover {
  color: rgba(61, 50, 37, 0.7);
}

/* Scene title */
.scene-title {
  font-family: Georgia, serif;
  font-size: 0.8rem;
  font-variant: small-caps;
  letter-spacing: 0.08em;
  color: rgba(139, 105, 20, 0.5);
  margin-bottom: 4px;
}

/* Scene setting */
.scene-setting {
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 0.92rem;
  color: rgba(61, 50, 37, 0.5);
  margin-bottom: 20px;
  line-height: 1.5;
}

/* Scene image */
.scene-image-wrap {
  margin: 0 -20px 28px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
}
.scene-image {
  width: 100%;
  display: block;
  border-radius: 12px;
}

/* Ending atmosphere image */
.ending-image-wrap {
  margin: 0 auto 28px;
  max-width: 480px;
  border-radius: 12px;
}
.ending-image-wrap .scene-image {
  border-radius: 12px;
}

/* Text paragraphs */
.scene-paragraph {
  font-family: Georgia, serif;
  font-size: 1.05rem;
  line-height: 1.75;
  color: #3d3225;
  margin-bottom: 18px;
  opacity: 0;
  animation: fadeInUp 0.6s ease forwards;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Choice buttons */
.scene-choices {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  animation: fadeInUp 0.6s ease forwards;
}

.choice-btn {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  padding: 16px 20px;
  font-family: Georgia, serif;
  font-size: 0.98rem;
  line-height: 1.5;
  color: #3d3225;
  background: rgba(255, 250, 240, 0.6);
  border: 1.5px solid rgba(139, 105, 20, 0.25);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.choice-btn:hover {
  background: rgba(139, 105, 20, 0.1);
  border-color: rgba(139, 105, 20, 0.5);
  transform: translateY(-1px);
  box-shadow: 0 3px 12px rgba(139, 105, 20, 0.08);
}
.choice-btn:active {
  transform: translateY(0);
}

.choice-continue {
  text-align: center;
  font-style: italic;
  color: rgba(61, 50, 37, 0.6);
  max-width: 200px;
  margin: 0 auto;
}

.choice-prev {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(139, 105, 20, 0.35);
  margin-right: 8px;
  vertical-align: middle;
}

/* ══════════════════════════════════════════════════════════
   ENDING SCREEN
   ══════════════════════════════════════════════════════════ */

#storyEnding {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

/* Philosopher reveal */
.ending-reveal {
  text-align: center;
  padding: 40px 0 28px;
}
.ending-portrait {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  object-fit: cover;
}
.ending-title {
  font-family: Georgia, serif;
  font-size: 1.8rem;
  color: #3d3225;
  margin-bottom: 6px;
}
.ending-school {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.ending-philosopher-name {
  font-size: 0.85rem;
  color: rgba(61, 50, 37, 0.5);
}

/* Journal entry */
.ending-journal {
  background: rgba(255, 250, 240, 0.5);
  border: 1px solid rgba(160, 140, 110, 0.2);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 28px;
}
.ending-journal-label {
  font-size: 0.78rem;
  font-variant: small-caps;
  letter-spacing: 0.05em;
  color: rgba(139, 105, 20, 0.5);
  margin-bottom: 14px;
}
.ending-journal-text {
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 0.95rem;
  line-height: 1.7;
  color: #3d3225;
  margin-bottom: 14px;
}
.ending-journal-text:last-child {
  margin-bottom: 0;
}

/* Reflection text */
.ending-reflection {
  margin-bottom: 28px;
}
.ending-reflection p {
  font-size: 0.95rem;
  line-height: 1.7;
  color: rgba(61, 50, 37, 0.8);
  margin-bottom: 12px;
}

/* Choice trail */
.ending-trail {
  margin-bottom: 24px;
}
.ending-trail-label {
  font-size: 0.78rem;
  font-variant: small-caps;
  letter-spacing: 0.05em;
  color: rgba(139, 105, 20, 0.5);
  margin-bottom: 12px;
}
.trail-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-left: 2px solid rgba(160, 140, 110, 0.15);
  margin-left: 6px;
  padding-left: 16px;
  position: relative;
}
.trail-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
  position: absolute;
  left: -7px;
}
.trail-content {
  padding-left: 10px;
}
.trail-choice {
  font-size: 0.9rem;
  color: #3d3225;
  line-height: 1.4;
  margin-bottom: 2px;
}
.trail-school {
  font-size: 0.78rem;
  font-weight: 600;
}

/* Instinct summary */
.ending-instinct {
  text-align: center;
  font-size: 0.95rem;
  color: rgba(61, 50, 37, 0.7);
  padding: 20px;
  background: rgba(255, 250, 240, 0.4);
  border-radius: 10px;
  margin-bottom: 28px;
}
.ending-instinct strong {
  font-weight: 700;
}

/* Reflection prompt */
.ending-prompt {
  margin-bottom: 28px;
}
.ending-prompt-label {
  font-size: 0.78rem;
  font-variant: small-caps;
  letter-spacing: 0.05em;
  color: rgba(139, 105, 20, 0.5);
  margin-bottom: 8px;
}
.ending-prompt-text {
  font-family: Georgia, serif;
  font-size: 0.95rem;
  color: #3d3225;
  line-height: 1.6;
  margin-bottom: 14px;
}
.ending-textarea {
  width: 100%;
  min-height: 100px;
  padding: 14px 16px;
  font-family: Georgia, serif;
  font-size: 0.95rem;
  line-height: 1.6;
  color: #3d3225;
  background: rgba(255, 250, 240, 0.5);
  border: 1px solid rgba(160, 140, 110, 0.25);
  border-radius: 10px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}
.ending-textarea:focus {
  border-color: rgba(139, 105, 20, 0.4);
}
.ending-textarea::placeholder {
  color: rgba(61, 50, 37, 0.3);
}
.ending-save-btn {
  display: block;
  margin-top: 10px;
  padding: 10px 24px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #3d3225;
  background: rgba(139, 105, 20, 0.12);
  border: 1px solid rgba(139, 105, 20, 0.3);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.ending-save-btn:hover:not(:disabled) {
  background: rgba(139, 105, 20, 0.2);
  border-color: rgba(139, 105, 20, 0.5);
}
.ending-save-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.ending-save-btn.saved {
  background: rgba(46, 111, 87, 0.15);
  border-color: rgba(46, 111, 87, 0.3);
  color: #2E6F57;
}

/* Alternate hint */
.ending-hint {
  padding: 16px 20px;
  background: rgba(139, 105, 20, 0.05);
  border-radius: 10px;
  margin-bottom: 20px;
}
.ending-hint p {
  font-size: 0.88rem;
  font-style: italic;
  color: rgba(61, 50, 37, 0.55);
  line-height: 1.5;
}

/* Endings counter */
.ending-counter {
  text-align: center;
  font-size: 0.82rem;
  color: rgba(61, 50, 37, 0.4);
  margin-bottom: 24px;
}

/* Action buttons */
.ending-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.ending-action-btn {
  padding: 12px 28px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1.5px solid;
}
.ending-replay-btn {
  background: rgba(139, 105, 20, 0.1);
  border-color: rgba(139, 105, 20, 0.3);
  color: #3d3225;
}
.ending-replay-btn:hover {
  background: rgba(139, 105, 20, 0.2);
  border-color: rgba(139, 105, 20, 0.5);
}
.ending-back-btn {
  background: transparent;
  border-color: rgba(160, 140, 110, 0.25);
  color: rgba(61, 50, 37, 0.6);
}
.ending-back-btn:hover {
  border-color: rgba(160, 140, 110, 0.45);
  color: rgba(61, 50, 37, 0.8);
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════ */

@media (max-width: 600px) {
  .story-card-grid {
    grid-template-columns: 1fr;
  }
  .storytime-title {
    font-size: 1.6rem;
  }
  .story-card-cover {
    height: 160px;
  }
  .scene-paragraph {
    font-size: 1rem;
    animation-delay: 0s !important; /* faster on mobile */
  }
  .scene-choices {
    animation-delay: 0.3s !important;
  }
  .scene-image-wrap {
    margin: 0 -12px 20px;
  }
  #storyReader,
  #storyEnding {
    padding: 0 14px 40px;
  }
  .ending-title {
    font-size: 1.5rem;
  }
  .ending-actions {
    flex-direction: column;
  }
  .ending-action-btn {
    width: 100%;
    text-align: center;
  }
}
