/* ============================================================
   reader.css — Document Reader Styles
   Dario Amodei Study Guide
   ============================================================ */

/* ----- Top Bar ----- */

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.back-link {
  font-size: 0.95rem;
  color: #2563EB;
  text-decoration: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s ease;
}

.back-link:hover {
  color: #6366F1;
  text-decoration: underline;
}

.top-bar-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1E293B;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-counter {
  font-size: 0.9rem;
  color: #64748B;
  white-space: nowrap;
}

/* --- View Toggle --- */

.view-toggle {
  display: flex;
  gap: 4px;
  background: #F1F5F9;
  border-radius: 8px;
  padding: 3px;
}

.view-toggle__btn {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  font-size: 0.825rem;
  font-weight: 600;
  background: transparent;
  color: #64748B;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.view-toggle__btn:hover {
  color: #1E293B;
}

.view-toggle__btn.active {
  background: #fff;
  color: #1E293B;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ----- Page Display (Main Content) ----- */

.page-display {
  margin-top: 72px;
  margin-bottom: 100px;
  padding: 16px;
  display: flex;
  justify-content: center;
  transform-origin: top center;
  transition: transform 0.2s ease;
}

/* ----- Original View ----- */

.original-view {
  max-width: 800px;
  width: 100%;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.1rem;
  line-height: 1.8;
  color: #1E293B;
}

.original-view h1,
.original-view h2,
.original-view h3 {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #0F172A;
  margin-top: 1.5em;
}

.original-view h2 {
  font-size: 1.6rem;
  margin-top: 0;
  margin-bottom: 0.5em;
  padding-bottom: 0.4em;
  border-bottom: 2px solid #E2E8F0;
}

.original-view h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5em;
}

.original-view h4 {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1.05rem;
  color: #0F172A;
  margin-top: 1em;
  margin-bottom: 0.4em;
}

.original-view p {
  margin-bottom: 1em;
}

.original-view blockquote {
  border-left: 3px solid #CBD5E1;
  margin: 1em 0;
  padding: 0.5em 1em;
  color: #64748B;
  background: #F8FAFC;
  border-radius: 0 6px 6px 0;
}

.original-view blockquote p {
  margin-bottom: 0.5em;
}

/* --- Page wrapper --- */
.original-view .page-content {
  padding: 0;
}

/* Empty page marker */
.original-view .empty-page {
  color: #94A3B8;
  text-align: center;
  padding: 3em 1em;
  font-style: italic;
}

/* --- Footnotes --- */
.original-view .footnote {
  font-size: 0.9rem;
  color: #64748B;
  border-top: 1px solid #E2E8F0;
  margin-top: 2em;
  padding-top: 1em;
}

.original-view .footnote-ref {
  font-size: 0.75em;
  vertical-align: super;
  color: #2563EB;
  cursor: pointer;
  text-decoration: none;
}

.original-view .footnote-ref:hover {
  color: #6366F1;
  text-decoration: underline;
}

/* ----- Study View ----- */

.study-view {
  max-width: 800px;
  width: 100%;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.1rem;
  line-height: 1.8;
  color: #1E293B;
}

.study-view h1,
.study-view h2,
.study-view h3 {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #0F172A;
  margin-top: 1.5em;
}

.study-view h2 {
  font-size: 1.6rem;
  margin-top: 0;
  margin-bottom: 0.5em;
  padding-bottom: 0.4em;
  border-bottom: 2px solid #E2E8F0;
}

.study-view h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5em;
}

.study-view h4 {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1.05rem;
  color: #0F172A;
  margin-top: 1em;
  margin-bottom: 0.4em;
}

.study-view p {
  margin-bottom: 1em;
}

.study-view blockquote {
  border-left: 3px solid #CBD5E1;
  margin: 1em 0;
  padding: 0.5em 1em;
  color: #64748B;
  background: #F8FAFC;
  border-radius: 0 6px 6px 0;
}

.study-view blockquote p {
  margin-bottom: 0.5em;
}

.study-view .page-content {
  padding: 0;
}

.study-view .empty-page {
  color: #94A3B8;
  text-align: center;
  padding: 3em 1em;
  font-style: italic;
}

/* --- Definition boxes: green (core definitions, key terms) --- */

.definition-box {
  border-left: 4px solid #059669;
  background: #ECFDF5;
  padding: 14px 18px;
  margin: 20px 0;
  border-radius: 0 8px 8px 0;
  font-size: 1.02rem;
  line-height: 1.7;
}

.definition-box strong {
  color: #065F46;
}

.definition-box p {
  margin-bottom: 0.5em;
}

.definition-box p:last-child {
  margin-bottom: 0;
}

/* --- Highlight boxes: blue (important data, key findings) --- */

.highlight-box {
  border-left: 4px solid #2563EB;
  background: #EFF6FF;
  padding: 14px 18px;
  margin: 20px 0;
  border-radius: 0 8px 8px 0;
  font-size: 1.02rem;
  line-height: 1.7;
}

.highlight-box strong {
  color: #1E40AF;
}

.highlight-box p {
  margin-bottom: 0.5em;
}

.highlight-box p:last-child {
  margin-bottom: 0;
}

/* --- Figure boxes: amber (figure descriptions, data points) --- */

.figure-box {
  border-left: 4px solid #D97706;
  background: #FFFBEB;
  padding: 14px 18px;
  margin: 20px 0;
  border-radius: 0 8px 8px 0;
  font-size: 1.02rem;
  line-height: 1.7;
}

.figure-box strong {
  color: #92400E;
}

.figure-box p {
  margin-bottom: 0.5em;
}

.figure-box p:last-child {
  margin-bottom: 0;
}

/* --- Commentary layer (analysis & digest) --- */

.commentary {
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 24px;
  margin-top: 2em;
}

.commentary > h3 {
  font-size: 1.15rem;
  color: #64748B;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-top: 0;
  margin-bottom: 1em;
  padding-bottom: 0.5em;
  border-bottom: 1px solid #E2E8F0;
}

/* --- Commentary sub-sections --- */

.commentary-section {
  background: #fff;
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 12px;
  border: 1px solid #E2E8F0;
}

.commentary-section:last-child {
  margin-bottom: 0;
}

.commentary-section h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: #2563EB;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0;
  margin-bottom: 0.5em;
}

.commentary-section p {
  margin-bottom: 0;
  color: #334155;
  font-size: 1.02rem;
  line-height: 1.75;
}

/* Commentary section color variants */
.commentary-section--analysis h4 {
  color: #6366F1;
}

.commentary-section--context h4 {
  color: #059669;
}

.commentary-section--critique h4 {
  color: #D97706;
}

.commentary-section--connection h4 {
  color: #2563EB;
}

/* Definition box inside commentary */
.commentary .definition-box {
  margin: 12px 0;
}

/* Highlight box inside commentary */
.commentary .highlight-box {
  margin: 12px 0;
}

/* Figure box inside commentary */
.commentary .figure-box {
  margin: 12px 0;
}

/* --- Key Quotes --- */

.key-quote {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 1.15rem;
  color: #334155;
  border-left: 4px solid #6366F1;
  padding: 16px 20px;
  margin: 20px 0;
  background: #EEF2FF;
  border-radius: 0 8px 8px 0;
  line-height: 1.7;
}

.key-quote .attribution {
  display: block;
  font-style: normal;
  font-size: 0.85rem;
  color: #64748B;
  margin-top: 8px;
}

/* ----- Zoom Panel ----- */

.zoom-panel {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translate(-90%, -50%);
  transition: transform 0.25s ease;
  z-index: 150;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 10px;
  background: rgba(15, 23, 42, 0.88);
  border-radius: 0 10px 10px 0;
  backdrop-filter: blur(6px);
}

.zoom-panel:hover {
  transform: translate(0, -50%);
}

.zoom-btn {
  background: transparent;
  color: #E2E8F0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.zoom-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.zoom-btn.active {
  background: #2563EB;
  color: #fff;
  border-color: #2563EB;
}

.zoom-link {
  color: #93C5FD;
  font-size: 0.75rem;
  text-align: center;
  margin-top: 6px;
  text-decoration: none;
}

.zoom-link:hover {
  text-decoration: underline;
}

/* ----- Navigation ----- */

.page-nav {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 90;
  background: #fff;
  padding: 8px 20px;
  border-radius: 32px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

.nav-btn {
  min-width: 48px;
  height: 48px;
  border: none;
  border-radius: 24px;
  background: #F1F5F9;
  color: #1E293B;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 0 20px;
  transition: background 0.15s, box-shadow 0.15s;
}

.nav-btn:hover {
  background: #E2E8F0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.nav-btn:active {
  background: #CBD5E1;
}

.nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-input-wrap {
  display: flex;
  align-items: center;
}

.page-input {
  width: 80px;
  height: 40px;
  text-align: center;
  border: 1px solid #CBD5E1;
  border-radius: 20px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s;
  -moz-appearance: textfield;
}

.page-input::-webkit-inner-spin-button,
.page-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.page-input:focus {
  border-color: #2563EB;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ----- Progress Bar ----- */

.progress-bar-track {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: #E2E8F0;
  z-index: 200;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #0F172A, #6366F1);
  width: 0;
  transition: width 0.3s ease;
}

/* MOL essay variant */
.progress-bar-fill--mol {
  background: linear-gradient(90deg, #0F172A, #D97706);
}

/* AOT essay variant */
.progress-bar-fill--aot {
  background: linear-gradient(90deg, #0F172A, #6366F1);
}

/* GPT-3 essay variant */
.progress-bar-fill--gpt3 {
  background: linear-gradient(90deg, #0F172A, #0D9488);
}

/* ----- Context Menu FAB ----- */

.context-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: #0F172A;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.35);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
}

.context-fab:hover {
  background: #1E293B;
  transform: scale(1.05);
}

.context-fab:focus-visible {
  outline: 2px solid #2563EB;
  outline-offset: 3px;
}

/* ----- Context Menu Overlay ----- */

.context-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: contextFadeIn 0.2s ease;
}

@keyframes contextFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.context-card {
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px;
  width: 340px;
  max-width: 90vw;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: contextSlideIn 0.25s ease;
}

@keyframes contextSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.context-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ctx-nav-btn {
  height: 40px;
  padding: 0 16px;
  border: none;
  border-radius: 20px;
  background: #F1F5F9;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}

.ctx-nav-btn:hover {
  background: #E2E8F0;
}

.ctx-page-label {
  font-size: 0.9rem;
  color: #64748B;
}

.ctx-btn {
  height: 44px;
  border: none;
  border-radius: 10px;
  background: #0F172A;
  color: #fff;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s;
}

.ctx-btn:hover {
  background: #1E293B;
}

.ctx-btn-close {
  background: #F1F5F9;
  color: #1E293B;
}

.ctx-btn-close:hover {
  background: #CBD5E1;
}

.ctx-btn--mol {
  background: #D97706;
}

.ctx-btn--mol:hover {
  background: #B45309;
}

.ctx-btn--aot {
  background: #6366F1;
}

.ctx-btn--aot:hover {
  background: #4F46E5;
}

.ctx-btn--gpt3 {
  background: #0D9488;
}

.ctx-btn--gpt3:hover {
  background: #0F766E;
}

/* ----- Search ----- */

.ctx-search-wrap {
  position: relative;
}

.ctx-search-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid #CBD5E1;
  border-radius: 10px;
  font-size: 0.95rem;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ctx-search-input:focus {
  border-color: #2563EB;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-results {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  max-height: 240px;
  overflow-y: auto;
}

.search-results:empty {
  display: none;
}

.search-results li {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.9rem;
  border-bottom: 1px solid #F1F5F9;
  transition: background 0.1s;
}

.search-results li:last-child {
  border-bottom: none;
}

.search-results li:hover {
  background: #F1F5F9;
}

.search-results .result-page {
  font-weight: 600;
  color: #2563EB;
  margin-right: 8px;
}

.search-results .result-match {
  color: #334155;
}

.ctx-link {
  display: block;
  text-align: center;
  color: #2563EB;
  text-decoration: none;
  font-size: 0.9rem;
}

.ctx-link:hover {
  text-decoration: underline;
}

/* ----- Table of Contents Panel ----- */

.toc-panel {
  position: fixed;
  right: -320px;
  top: 56px;
  bottom: 0;
  width: 300px;
  background: #fff;
  box-shadow: -2px 0 12px rgba(0, 0, 0, 0.08);
  z-index: 120;
  transition: right 0.3s ease;
  overflow-y: auto;
  padding: 24px 20px;
}

.toc-panel.open {
  right: 0;
}

.toc-panel__title {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748B;
  margin-bottom: 16px;
}

.toc-item {
  display: block;
  padding: 8px 12px;
  font-size: 0.9rem;
  color: #334155;
  text-decoration: none;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.toc-item:hover {
  background: #F1F5F9;
  color: #1E293B;
}

.toc-item.active {
  background: #EFF6FF;
  color: #2563EB;
  font-weight: 600;
}

.toc-item--indented {
  padding-left: 28px;
  font-size: 0.85rem;
}

/* ----- PDF View ----- */

.pdf-view {
  max-width: 900px;
  width: 100%;
}

.pdf-content {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.pdf-pages-header {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748B;
  text-align: center;
  padding-bottom: 8px;
  border-bottom: 1px solid #E2E8F0;
}

.pdf-page-wrapper {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(0, 0, 0, 0.04);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.pdf-page-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #0D9488;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pdf-page-img {
  width: 100%;
  height: auto;
  border-radius: 4px;
  border: 1px solid #E2E8F0;
}

/* PDF toggle button style */
.ctx-btn--pdf {
  background: #0D9488;
  color: #fff;
}

.ctx-btn--pdf:hover {
  background: #0F766E;
}

/* ----- Responsive ----- */

@media (max-width: 768px) {
  .top-bar {
    padding: 0 12px;
    height: 48px;
  }

  .top-bar-title {
    font-size: 0.95rem;
  }

  .back-link {
    font-size: 0.85rem;
  }

  .page-counter {
    font-size: 0.8rem;
  }

  .view-toggle__btn {
    padding: 4px 10px;
    font-size: 0.75rem;
  }

  .page-display {
    margin-top: 60px;
    margin-bottom: 90px;
    padding: 8px;
  }

  .original-view,
  .study-view {
    font-size: 1rem;
    line-height: 1.7;
  }

  .original-view h2,
  .study-view h2 {
    font-size: 1.3rem;
  }

  .commentary {
    padding: 16px;
  }

  .commentary-section {
    padding: 12px 14px;
  }

  .definition-box,
  .highlight-box,
  .figure-box {
    padding: 10px 14px;
  }

  .key-quote {
    font-size: 1.02rem;
    padding: 12px 16px;
  }

  .page-nav {
    padding: 6px 12px;
    gap: 10px;
  }

  .nav-btn {
    padding: 0 14px;
    font-size: 0.85rem;
  }

  .context-card {
    padding: 20px 16px;
    width: 300px;
  }

  .zoom-panel {
    padding: 8px 6px;
  }

  .zoom-btn {
    padding: 4px 10px;
    font-size: 0.75rem;
  }

  .toc-panel {
    width: 260px;
    right: -280px;
  }

  .pdf-page-wrapper {
    padding: 10px;
  }

  .pdf-content {
    gap: 20px;
  }
}
