/* =========================================================================
   stories.css  --  LLM Stories presentation page
   ========================================================================= */

/* ----- Page-level layout ----- */
.stories-page {
  overflow-y: scroll;
  height: 100vh;
}
@media (min-width: 900px) {
  .stories-page { scroll-snap-type: y proximity; }
}

/* ----- Screen containers ----- */
.story-screen {
  scroll-snap-align: start;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(64px + 2rem) 1.5rem 2rem;
  position: relative;
}
.story-screen-inner {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

/* ----- Interstitials (act headers + transitions) ----- */
.act-interstitial {
  min-height: 40vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem;
}
.act-header-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.act-numeral {
  font-size: 4rem;
  font-weight: 700;
  line-height: 1;
  color: var(--act-color, #1a237e);
  opacity: 0.25;
}
.act-header h2 {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--act-color, #1a237e);
  margin: 0;
}
.act-tagline {
  font-size: 1.125rem;
  color: #616161;
  margin: 0;
}
.act-transition {
  background: #fafafa;
  border-top: 1px solid #e0e0e0;
  border-bottom: 1px solid #e0e0e0;
}
.act-transition p {
  font-size: 1.25rem;
  font-style: italic;
  color: #424242;
  max-width: 40ch;
  margin: 0 auto;
  line-height: 1.6;
}

/* ----- Act theming ----- */
[data-act="1"] { --act-color: #1a237e; --act-tint: rgba(26,35,126,0.06); }
[data-act="2"] { --act-color: #00897b; --act-tint: rgba(0,137,123,0.06); }
[data-act="3"] { --act-color: #e74c3c; --act-tint: rgba(231,76,60,0.06); }
[data-act="4"] { --act-color: #ff8f00; --act-tint: rgba(255,143,0,0.06); }

/* ----- Hook screen ----- */
.story-hook-screen {
  background: linear-gradient(160deg, #0d1442, #1a237e 50%, #283593);
  color: #fff;
  text-align: center;
}
.story-hook-screen h1 {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1.1;
  margin: 0 0 0.75rem;
}
.hook-subtitle {
  font-size: 1.5rem;
  font-weight: 400;
  opacity: 0.85;
  margin: 0 0 1.5rem;
}
.hook-teaser {
  font-size: 1.125rem;
  max-width: 55ch;
  margin: 0 auto 2rem;
  line-height: 1.7;
  opacity: 0.9;
}
.hook-meta {
  margin-bottom: 2rem;
}
.hook-time {
  display: inline-block;
  background: rgba(255,255,255,0.12);
  padding: 0.35rem 1rem;
  border-radius: 999px;
  font-size: 0.9rem;
}
.hook-objectives {
  text-align: left;
  max-width: 36ch;
  margin: 0 auto 2.5rem;
}
.hook-objectives h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  opacity: 0.85;
}
.hook-objectives ol {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.95rem;
  line-height: 1.8;
}
.hook-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}
#begin-journey {
  background: #ff8f00;
  color: #fff;
  border: none;
  padding: 0.75rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}
#begin-journey:hover { background: #f57c00; }
#begin-journey:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.hook-hint {
  font-size: 0.85rem;
  opacity: 0.6;
}
.hook-hint kbd {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.8rem;
}

/* ----- Content screens ----- */
.story-content-screen {
  border-top: 4px solid var(--act-color, #1a237e);
  background: var(--act-tint, rgba(26,35,126,0.06));
}

/* ----- Screen header ----- */
.story-screen-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: #616161;
}
.story-screen-number {
  font-weight: 600;
  color: var(--act-color, #1a237e);
}
.story-screen-year {
  font-weight: 500;
}

/* ----- Screen title ----- */
.story-screen-title {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 1.5rem;
  color: var(--act-color, #212121);
}

/* ----- Two-panel body ----- */
.story-screen-body {
  display: grid;
  grid-template-columns: minmax(300px, 3fr) minmax(250px, 2fr);
  gap: 2rem;
  margin-bottom: 1.5rem;
}

/* ----- Narrative panel ----- */
.story-narrative-panel {
  font-size: 1.125rem;
  line-height: 1.7;
  color: #212121;
  max-width: 65ch;
}
.story-narrative-panel strong {
  color: var(--act-color, #1a237e);
}

/* ----- Math panel ----- */
.story-math-panel {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 1.25rem;
}
.story-math-panel h5 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--act-color, #1a237e);
  margin: 0 0 0.75rem;
}
.story-math-panel p {
  font-size: 1rem;
  line-height: 1.6;
  color: #424242;
  max-width: 55ch;
  margin: 0.5rem 0;
}
.story-math-panel .formula {
  margin: 0.75rem 0;
  text-align: center;
  overflow-x: auto;
}
.story-math-panel details {
  margin-top: 0.75rem;
}
.story-math-panel details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--act-color, #1a237e);
}

/* ----- Viz containers ----- */
.viz-container {
  min-height: 200px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.viz-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 120px;
  border: 2px dashed #bdbdbd;
  border-radius: 8px;
  background: #fafafa;
}
.viz-fallback-label {
  font-size: 0.9rem;
  color: #9e9e9e;
  font-style: italic;
  margin: 0;
}

/* ----- Hook line at bottom of screen ----- */
.story-screen-hook {
  font-size: 1rem;
  line-height: 1.6;
  color: #424242;
  padding: 0.75rem 1rem;
  background: rgba(255,255,255,0.65);
  border-left: 3px solid var(--act-color, #1a237e);
  border-radius: 0 8px 8px 0;
  margin-bottom: 1rem;
}

/* ----- Active learning ----- */
.story-active-learning {
  background: #f5f5f5;
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.active-learning-prompt {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.5;
  margin: 0 0 0.75rem;
}
.active-learning-game {
  min-height: 100px;
}
.reveal-btn {
  display: inline-block;
  background: #ff8f00;
  color: #fff;
  border: none;
  padding: 0.5rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}
.reveal-btn:hover { background: #f57c00; }
.reveal-btn:focus-visible { outline: 2px solid #ff8f00; outline-offset: 3px; }
.reveal-btn[aria-expanded="true"] { background: #616161; }
.reveal-content {
  margin-top: 0.75rem;
  font-size: 1rem;
  line-height: 1.6;
  color: #212121;
}

/* ----- Sources ----- */
.story-screen-sources {
  font-size: 0.85rem;
  color: #616161;
}
.story-screen-sources summary {
  cursor: pointer;
  font-weight: 600;
}
.story-screen-sources ul {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}
.story-screen-sources li {
  margin-bottom: 0.25rem;
}
.story-screen-sources a {
  color: var(--act-color, #1a237e);
  text-decoration: underline;
}

/* ----- Progress bar ----- */
#story-progress {
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  height: 4px;
  background: #e0e0e0;
  z-index: 999;
  overflow: hidden;
}
#story-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #1a237e, #00897b, #ff8f00);
  transition: width 0.3s ease;
}

/* ----- Navigation dots ----- */
#story-dots {
  position: fixed;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 998;
}
.story-dot-gap {
  height: 8px;
}
.story-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #bdbdbd;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: all 0.25s ease;
}
.story-dot:hover {
  background: #9e9e9e;
  transform: scale(1.2);
}
.story-dot.active {
  width: 14px;
  height: 14px;
  box-shadow: 0 0 0 3px rgba(26,35,126,0.25);
}
.story-dot[data-act="1"] { background: #1a237e; }
.story-dot[data-act="2"] { background: #00897b; }
.story-dot[data-act="3"] { background: #e74c3c; }
.story-dot[data-act="4"] { background: #ff8f00; }
.story-dot[data-act="hook"],
.story-dot[data-act="closing"] { background: #616161; }
.story-dot:not(.active) {
  opacity: 0.45;
}

/* ----- Closing screen ----- */
.story-closing-screen {
  background: linear-gradient(160deg, #0d1442, #1a237e);
  color: #fff;
  text-align: center;
}
.story-closing-screen h2 {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0 0 1rem;
}
.closing-summary {
  font-size: 1.25rem;
  opacity: 0.85;
  margin: 0 0 2rem;
}
.story-closing-screen .benchmark-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  max-width: 800px;
  margin: 0 auto 2rem;
  text-align: left;
}
.story-closing-screen .benchmark-item {
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.story-closing-screen .benchmark-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
}
.story-closing-screen .benchmark-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ff8f00;
}
.story-closing-screen .benchmark-detail {
  font-size: 0.8rem;
  opacity: 0.7;
}
#self-assessment-quiz {
  margin-bottom: 2rem;
}
.closing-cta {
  max-width: 45ch;
  margin: 0 auto;
}
.closing-cta p {
  font-size: 1.1rem;
  line-height: 1.6;
  opacity: 0.9;
  margin: 0 0 1.25rem;
}
.closing-link {
  display: inline-block;
  background: #ff8f00;
  color: #fff;
  text-decoration: none;
  padding: 0.65rem 1.75rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1rem;
  transition: background 0.2s;
}
.closing-link:hover { background: #f57c00; }
.closing-link:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

/* ----- Animations ----- */
@keyframes storyEnter {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}
.story-screen.in-view .story-screen-inner {
  animation: storyEnter 0.5s ease both;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ----- Accessibility ----- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
:focus-visible {
  outline: 2px solid var(--act-color, #1a237e);
  outline-offset: 2px;
}

/* =========================================================================
   RESPONSIVE
   ========================================================================= */
@media (max-width: 899px) {
  .story-screen-body {
    grid-template-columns: 1fr;
  }
  #story-dots { display: none; }
  .story-hook-screen h1 { font-size: 2.25rem; }
  .hook-subtitle { font-size: 1.2rem; }
  .story-screen-title { font-size: 1.6rem; }
  .story-narrative-panel { font-size: 1rem; }
  .act-numeral { font-size: 3rem; }
  .act-header h2 { font-size: 1.75rem; }
}
@media (max-width: 479px) {
  .story-screen {
    padding: calc(56px + 1rem) 1rem 1.5rem;
  }
  .story-hook-screen h1 { font-size: 1.75rem; }
  .hook-subtitle { font-size: 1rem; }
  .hook-teaser { font-size: 0.95rem; }
  .story-screen-title { font-size: 1.35rem; }
  .story-math-panel { padding: 1rem; }
  .story-closing-screen h2 { font-size: 1.75rem; }
}

/* =========================================================================
   SCROLL ANIMATIONS
   ========================================================================= */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.animate-on-scroll.visible {
  opacity: 1;
  transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
  .animate-on-scroll { opacity: 1; transform: none; transition: none; }
}

/* =========================================================================
   PRINT
   ========================================================================= */
@media print {
  #navbar, #story-dots, #story-progress, .hook-cta, .closing-link,
  .reveal-btn, .nav-toggle { display: none !important; }
  .stories-page {
    overflow: visible;
    height: auto;
    scroll-snap-type: none;
  }
  .story-screen {
    min-height: auto;
    scroll-snap-align: none;
    break-inside: avoid;
    padding: 1rem 0;
  }
  .story-screen-body {
    grid-template-columns: 1fr;
  }
  .act-interstitial {
    min-height: auto;
    padding: 1rem 0;
  }
}
