/* ==========================================
   NARRATIVE VIEWER
   ========================================== */

.narrative-viewer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.narrative-viewer.active {
  opacity: 1;
}

.narrative-viewer.closing {
  opacity: 0;
}

.narrative-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(45, 49, 66, 0.95);
  backdrop-filter: blur(10px);
}

.narrative-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, rgba(248, 249, 250, 0.98) 0%, rgba(255, 255, 255, 0.95) 100%);
}

.narrative-header {
  position: relative;
  padding: 2rem 3rem;
  border-bottom: 2px solid rgba(45, 49, 66, 0.1);
  background: linear-gradient(180deg, rgba(255, 255, 255, 1) 0%, rgba(248, 249, 250, 1) 100%);
}

.narrative-close {
  position: absolute;
  top: 1.5rem;
  right: 2rem;
  background: rgba(45, 49, 66, 0.1);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10;
}

.narrative-close:hover {
  background: rgba(45, 49, 66, 0.2);
  transform: rotate(90deg);
}

.narrative-close svg {
  color: var(--color-primary);
}

.narrative-title-section {
  max-width: 800px;
}

.narrative-title {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  font-weight: 400;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.narrative-verb-label {
  font-size: 1.1rem;
  color: var(--color-secondary);
  font-weight: 300;
}

.narrative-verb-label strong {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  color: var(--color-primary);
  font-weight: 500;
}

.narrative-body {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  overflow: hidden;
}

.narrative-sidebar {
  background: linear-gradient(180deg, rgba(248, 249, 250, 0.95) 0%, rgba(255, 255, 255, 0.9) 100%);
  border-right: 2px solid rgba(45, 49, 66, 0.08);
  padding: 2.5rem 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  box-shadow: inset -8px 0 16px rgba(0, 0, 0, 0.02);
}

.narrative-toc { flex-shrink: 0; }

.toc-title {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1.25rem;
  opacity: 0.7;
}

.toc-items {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toc-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.25s ease;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.5);
  position: relative;
}

.toc-item:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(45, 49, 66, 0.15);
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.toc-item.active {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  color: white;
  border-color: var(--color-primary);
  box-shadow: 0 4px 12px rgba(45, 49, 66, 0.2);
  transform: translateX(2px);
}

.toc-item.active .toc-label {
  font-weight: 600;
}

.toc-item.completed:not(.active) {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.2);
}

.toc-item.completed:not(.active):hover {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
}

.toc-number {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(45, 49, 66, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  font-family: var(--font-sans);
  transition: all 0.25s ease;
}

.toc-item.active .toc-number {
  background: rgba(255, 255, 255, 0.25);
  color: white;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.toc-item.completed:not(.active) .toc-number {
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
}

.toc-label {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-sans);
}

.toc-item.active .toc-label {
  font-weight: 600;
}

.toc-check {
  color: #10b981;
  font-size: 1.1rem;
  font-weight: bold;
}

.toc-item.active .toc-check {
  color: rgba(255, 255, 255, 0.9);
}

.narrative-progress-section {
  padding-top: 2rem;
  border-top: 2px solid rgba(45, 49, 66, 0.1);
}

.progress-title {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1.25rem;
  opacity: 0.7;
}

.progress-bar {
  width: 100%;
  height: 10px;
  background: rgba(45, 49, 66, 0.08);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 1rem;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981 0%, #059669 100%);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

.progress-text {
  font-size: 0.85rem;
  color: var(--color-secondary);
  text-align: center;
}

.narrative-content {
  padding: 3rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

.narrative-parts {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3rem;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.narrative-part {
  opacity: 0.4;
  transform: translateY(20px);
  transition: all 0.4s ease;
  padding: 2rem;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 12px;
  border: 2px solid transparent;
  cursor: pointer;
}

.narrative-part:hover {
  opacity: 0.6;
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(45, 49, 66, 0.05);
}

.narrative-part.active {
  opacity: 1;
  transform: translateY(0);
  background: white;
  border-color: rgba(45, 49, 66, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  cursor: default;
}

.narrative-part.active:hover {
  border-color: rgba(45, 49, 66, 0.1);
}

.part-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.part-number {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.narrative-audio-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.audio-control-btn {
  background: rgba(212, 165, 116, 0.1);
  border: 2px solid rgba(212, 165, 116, 0.3);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  padding: 0;
  opacity: 0.5;
}

.audio-control-btn.active {
  opacity: 1;
}

.audio-control-btn:hover {
  background: rgba(212, 165, 116, 0.2);
  border-color: rgba(212, 165, 116, 0.5);
  transform: scale(1.08);
}

.audio-control-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.narrative-audio-controls.playing .pause-btn,
.narrative-audio-controls.playing .restart-btn {
  background: rgba(212, 165, 116, 0.2);
}

.narrative-audio-controls.playing .play-btn {
  opacity: 0.3;
}

.narrative-audio-controls.playing {
  animation: pulse-audio-group 1.5s ease-in-out infinite;
}

@keyframes pulse-audio-group {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.9;
  }
}

.audio-control-btn svg {
  width: 18px;
  height: 18px;
  color: rgba(212, 165, 116, 0.8);
  transition: color 0.3s ease;
}

.audio-control-btn.active svg {
  color: rgba(212, 165, 116, 1);
}

.audio-control-btn:hover svg {
  color: rgba(212, 165, 116, 1);
}

.play-btn svg {
  margin-left: 2px;
}

.restart-btn svg {
  width: 16px;
  height: 16px;
}

.part-text {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  line-height: 1.8;
  color: var(--color-primary);
  text-align: justify;
  hyphens: auto;
  word-spacing: normal;
}

.highlighted-verb {
  display: inline !important;
  background: linear-gradient(180deg, rgba(212, 165, 116, 0.3) 0%, rgba(212, 165, 116, 0.15) 100%);
  padding: 0.1em 0.3em;
  border-radius: 3px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 2px solid rgba(212, 165, 116, 0.5);
  white-space: nowrap !important;
  word-break: keep-all !important;
  overflow-wrap: normal !important;
  hyphens: none !important;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.highlighted-verb:hover {
  background: rgba(212, 165, 116, 0.4);
  border-bottom-color: rgba(212, 165, 116, 0.8);
}

.part-text .highlighted-verb,
.example-item .highlighted-verb,
.narrative-part .highlighted-verb {
  white-space: nowrap !important;
  word-break: keep-all !important;
  display: inline-block !important;
  overflow-wrap: normal !important;
  text-align: left !important;
}

/* Override text-align: justify for highlighted spans */
.part-text {
  text-align: justify;
}

.part-text > * {
  text-align: inherit;
}

span.highlighted-verb {
  text-align: left !important;
  display: inline-block !important;
}

.verb-tooltip {
  position: fixed;
  background: white;
  border: 2px solid var(--color-primary);
  border-radius: 8px;
  padding: 1rem;
  max-width: 350px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 3000;
  animation: tooltipFadeIn 0.2s ease;
}

@keyframes tooltipFadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.tooltip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.tooltip-header strong {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  color: var(--color-primary);
}

.tooltip-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-secondary);
  line-height: 1;
  padding: 0;
  width: 24px;
  height: 24px;
}

.tooltip-close:hover { color: var(--color-primary); }

.tooltip-definition {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--color-secondary);
}

/* Navigation removed - parts are clickable */

.narrative-note {
  background: linear-gradient(135deg, rgba(212, 165, 116, 0.1) 0%, rgba(191, 192, 192, 0.1) 100%);
  border-left: 4px solid rgba(212, 165, 116, 0.6);
  padding: 2rem;
  border-radius: 0 12px 12px 0;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  gap: 1.5rem;
}

.note-icon { font-size: 2.5rem; flex-shrink: 0; }
.note-content { flex: 1; }

.note-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--color-primary);
  margin-bottom: 0.75rem;
}

.note-text {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--color-secondary);
  font-style: italic;
}

@media (max-width: 1024px) {
  .narrative-body { grid-template-columns: 240px 1fr; }
  .narrative-content { padding: 2rem; }
  .narrative-title { font-size: 2rem; }
  .part-text { font-size: 1.2rem; }
}

@media (max-width: 768px) {
  .narrative-container { max-width: 100%; }
  .narrative-header { padding: 1.5rem 1rem; }
  .narrative-close { top: 1rem; right: 1rem; }
  .narrative-body { grid-template-columns: 1fr; }
  .narrative-sidebar { display: none; }
  .narrative-content { padding: 1.5rem; }
  .narrative-title { font-size: 1.75rem; }
  .part-text { font-size: 1.1rem; text-align: left; }
  .narrative-navigation { flex-direction: column; gap: 1rem; }
  .nav-button { width: 100%; justify-content: center; }
  .narrative-note { flex-direction: column; padding: 1.5rem; }
  .note-icon { font-size: 2rem; }
}

@media (max-width: 480px) {
  .narrative-title { font-size: 1.5rem; }
  .part-text { font-size: 1rem; }
  .narrative-note { padding: 1rem; }
  .note-title { font-size: 1.1rem; }
  .note-text { font-size: 0.95rem; }
}

@media (prefers-reduced-motion: reduce) {
  .narrative-viewer, .narrative-part, .toc-item, .nav-button { transition: none; }
}

.narrative-close:focus, .nav-button:focus, .toc-item:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.highlighted-verb:focus {
  outline: 2px solid rgba(212, 165, 116, 0.8);
  outline-offset: 2px;
}
