/* ============================================================
   SeouLink 한국어교실 — Storybook CSS (소설 스타일)
   Extends textbook.css custom properties
   ============================================================ */

/* --- Novel Body --- */
.novel-body {
  max-width: 680px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md);
  font-family: var(--font-ko);
  font-size: 1.05rem;
  line-height: 2.0;
  color: var(--gray-800);
}

/* --- Chapter Title --- */
.novel-chapter {
  text-align: center;
  margin: var(--space-3xl) 0 var(--space-2xl);
  padding: var(--space-xl) 0;
  border-top: 2px solid var(--gray-200);
  border-bottom: 2px solid var(--gray-200);
}

.novel-chapter h2 {
  font-family: var(--font-ko);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--sl-primary);
  margin: 0 0 var(--space-xs);
}

.novel-chapter .chapter-subtitle {
  font-family: var(--font-jp);
  font-size: 0.95rem;
  color: var(--gray-500);
}

.novel-chapter .chapter-number {
  font-family: var(--font-en);
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--sl-accent);
  margin-bottom: var(--space-sm);
}

/* --- Scene Break --- */
.novel-scene-break {
  text-align: center;
  margin: var(--space-2xl) 0;
  color: var(--gray-300);
  font-size: 1.2rem;
  letter-spacing: 0.5em;
}

.novel-scene-break::before {
  content: '★ ★ ★';
}

/* --- Scene Description --- */
.novel-scene-desc {
  margin: var(--space-lg) 0;
  padding: var(--space-md) var(--space-lg);
  background: var(--cream-warm);
  border-left: 3px solid var(--sl-warning);
  border-radius: var(--radius-sm);
  font-style: italic;
  color: var(--gray-600);
  font-size: 0.95rem;
  line-height: 1.8;
}

.novel-scene-desc .scene-jp {
  display: none;
  margin-top: var(--space-sm);
  font-family: var(--font-jp);
  color: var(--gray-500);
  font-size: 0.9rem;
}

body.show-jp .novel-scene-desc .scene-jp {
  display: block;
}

/* --- Dialogue --- */
.novel-dialogue {
  margin: var(--space-sm) 0;
  padding-left: 1.5em;
  text-indent: -1.5em;
}

.novel-speaker {
  font-weight: 700;
  margin-right: 0.3em;
}

.novel-speaker::after {
  content: '';
}

/* Character colors */
.novel-speaker.yuko { color: var(--sl-accent); }
.novel-speaker.ami { color: var(--sl-success); }
.novel-speaker.rui { color: var(--sl-info); }
.novel-speaker.choi,
.novel-speaker.cheoseok { color: var(--sl-primary); }
.novel-speaker.hyeonjeong { color: #9B59B6; }
.novel-speaker.yunseok { color: #E67E22; }
.novel-speaker.junho { color: #16A085; }
.novel-speaker.default { color: var(--gray-600); }

.novel-line {
  color: var(--gray-800);
}

.novel-jp {
  display: none;
  margin-left: 1.5em;
  font-family: var(--font-jp);
  color: var(--gray-400);
  font-size: 0.9rem;
  line-height: 1.6;
}

body.show-jp .novel-jp {
  display: block;
}

/* --- Narration / Stage Direction --- */
.novel-narration {
  margin: var(--space-sm) 0;
  color: var(--gray-500);
  font-style: italic;
  font-size: 0.95rem;
}

/* --- Narrative Bridge (소설 서술문) --- */
.novel-bridge {
  margin: var(--space-lg) 0;
  color: var(--gray-600);
  font-size: 1rem;
  line-height: 2.0;
  text-indent: 1em;
}

/* --- JP Toggle Button --- */
.jp-toggle {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 100;
  background: var(--sl-primary);
  color: white;
  border: none;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: var(--transition-normal);
  display: flex;
  align-items: center;
  justify-content: center;
}

.jp-toggle:hover {
  background: var(--sl-primary-dark);
  transform: scale(1.05);
}

body.show-jp .jp-toggle {
  background: var(--sl-accent);
}

/* --- Lesson Illustration --- */
.novel-illustration {
  text-align: center;
  margin: var(--space-lg) 0 var(--space-xl);
}

.novel-illustration img {
  max-width: 100%;
  width: 480px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* --- Scene Illustration --- */
.novel-scene-illustration {
  text-align: center;
  margin: var(--space-md) 0 var(--space-lg);
}

.novel-scene-illustration img {
  max-width: 100%;
  width: 400px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* --- Storybook Hero --- */
.storybook-hero {
  text-align: center;
  padding: var(--space-3xl) var(--space-lg);
  background: linear-gradient(135deg, var(--sl-primary-light) 0%, var(--cream) 100%);
  border-bottom: 1px solid var(--gray-200);
  position: relative;
  overflow: hidden;
}

.storybook-hero[style*="--cover-bg"] {
  background: var(--cover-bg) center/cover no-repeat;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.storybook-hero[style*="--cover-bg"]::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(2px);
}

.storybook-hero .chapter-number,
.storybook-hero h1,
.storybook-hero .hero-sub {
  position: relative;
  z-index: 1;
}

.storybook-hero h1 {
  font-family: var(--font-ko);
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--sl-primary);
  margin-bottom: var(--space-sm);
}

.storybook-hero .hero-sub {
  font-family: var(--font-jp);
  color: var(--gray-500);
  font-size: 1.1rem;
}

/* --- Chapter Card Grid (Index page) --- */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-lg);
  padding: var(--space-xl);
  max-width: 960px;
  margin: 0 auto;
}

.chapter-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-md);
  transition: var(--transition-normal);
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--gray-100);
}

.chapter-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
}

.chapter-card .card-level {
  font-family: var(--font-en);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sl-accent);
  margin-bottom: var(--space-xs);
}

.chapter-card h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--sl-primary);
  margin-bottom: var(--space-xs);
}

.chapter-card .card-desc {
  font-size: 0.9rem;
  color: var(--gray-500);
  line-height: 1.6;
}

.chapter-card .card-cover {
  margin: calc(-1 * var(--space-lg)) calc(-1 * var(--space-lg)) var(--space-md);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow: hidden;
  line-height: 0;
}

.chapter-card .card-cover img {
  width: 100%;
  height: 140px;
  object-fit: cover;
}

.chapter-card .card-desc-jp {
  font-family: var(--font-jp);
  font-size: 0.85rem;
  color: var(--gray-400);
  margin-top: var(--space-xs);
}

/* --- Chapter Navigation --- */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-xl) 0;
  margin-top: var(--space-2xl);
  border-top: 1px solid var(--gray-200);
}

.chapter-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
  color: var(--sl-primary);
  font-weight: 500;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
}

.chapter-nav a:hover {
  background: var(--sl-primary-light);
}

/* --- Spinoff Badge --- */
.spinoff-badge {
  display: inline-block;
  background: var(--sl-accent-light);
  color: var(--sl-accent);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15em 0.6em;
  border-radius: var(--radius-sm);
  margin-left: var(--space-sm);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .novel-body {
    padding: var(--space-md) var(--space-sm);
    font-size: 1rem;
  }

  .novel-chapter h2 {
    font-size: 1.3rem;
  }

  .storybook-hero h1 {
    font-size: 1.6rem;
  }

  .storybook-hero[style*="--cover-bg"] {
    min-height: 200px;
  }

  .novel-illustration img {
    width: 100%;
  }

  .novel-scene-illustration img {
    width: 100%;
  }

  .chapter-grid {
    grid-template-columns: 1fr;
    padding: var(--space-md);
  }

  .jp-toggle {
    bottom: 1rem;
    right: 1rem;
    width: 48px;
    height: 48px;
    font-size: 1rem;
  }
}

/* --- Editor Mode (Traceability) --- */
body.editor-mode [data-src] {
  position: relative;
  cursor: help;
  border-bottom: 1px dashed var(--gray-300);
  transition: background 0.15s;
}

body.editor-mode [data-src]:hover {
  background: rgba(255, 193, 7, 0.12);
}

body.editor-mode [data-src]:hover::after {
  content: attr(data-src);
  position: absolute;
  top: -1.6em;
  right: 0;
  background: var(--sl-primary);
  color: white;
  font-family: var(--font-en);
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 600;
  padding: 0.15em 0.5em;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
  letter-spacing: 0.03em;
}

/* Editor toggle button */
.editor-toggle {
  position: fixed;
  bottom: 2rem;
  right: 5.5rem;
  z-index: 100;
  background: var(--gray-600);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: var(--transition-normal);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
}

.editor-toggle:hover {
  opacity: 1;
  transform: scale(1.05);
}

body.editor-mode .editor-toggle {
  background: var(--sl-warning);
  color: var(--gray-800);
  opacity: 1;
}

/* Source info tooltip panel */
.trace-panel {
  display: none;
  position: fixed;
  bottom: 5.5rem;
  right: 2rem;
  z-index: 101;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  padding: var(--space-md);
  max-width: 340px;
  font-size: 0.85rem;
  line-height: 1.5;
}

body.editor-mode .trace-panel.active {
  display: block;
}

.trace-panel .trace-id {
  font-family: var(--font-en);
  font-weight: 700;
  color: var(--sl-primary);
  font-size: 0.95rem;
  margin-bottom: var(--space-xs);
}

.trace-panel .trace-file {
  color: var(--gray-500);
  font-family: var(--font-en);
  font-size: 0.8rem;
}

.trace-panel .trace-hint {
  color: var(--gray-400);
  font-size: 0.75rem;
  margin-top: var(--space-xs);
  border-top: 1px solid var(--gray-100);
  padding-top: var(--space-xs);
}

@media (max-width: 768px) {
  .editor-toggle {
    bottom: 1rem;
    right: 4.5rem;
    width: 36px;
    height: 36px;
    font-size: 0.8rem;
  }

  .trace-panel {
    bottom: 4rem;
    right: 1rem;
    max-width: 280px;
  }
}

@media print {
  .jp-toggle { display: none; }
  .editor-toggle { display: none; }
  .trace-panel { display: none; }
  .novel-jp { display: block !important; color: #999; }
}
