/* ============================================================
   reader.css - Document Reader Styles
   ============================================================ */

/* ----- 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: #1a73e8; text-decoration: none; white-space: nowrap; }
.back-link:hover { text-decoration: underline; }
.top-bar-title { font-size: 1.1rem; font-weight: 600; color: #202124; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-counter { font-size: 0.9rem; color: #5f6368; white-space: nowrap; }

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

/* ----- Image View ----- */
.image-view { max-width: 900px; width: 100%; text-align: center; }
.image-view img {
  max-width: 100%; height: auto; display: block; margin: 0 auto;
  border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

/* ----- 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(32,33,36,0.85);
  border-radius: 0 10px 10px 0;
  backdrop-filter: blur(6px);
}
.zoom-panel:hover { transform: translate(0, -50%); }
.zoom-btn {
  background: transparent; color: #e8eaed;
  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: #1a73e8; color: #fff; border-color: #1a73e8; }
.zoom-link { color: #8ab4f8; 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: #f1f3f4; color: #202124; font-size: 0.95rem;
  cursor: pointer; padding: 0 20px;
  transition: background 0.15s, box-shadow 0.15s;
}
.nav-btn:hover { background: #e8eaed; box-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.nav-btn:active { background: #dadce0; }
.page-input-wrap { display: flex; align-items: center; }
.page-input {
  width: 80px; height: 40px; text-align: center;
  border: 1px solid #dadce0; 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: #1a73e8; }

/* ----- Progress Bar ----- */
.progress-bar-track {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 3px; background: #e8eaed; z-index: 200;
}
.progress-bar-fill { height: 100%; background: #1a73e8; width: 0; transition: width 0.3s ease; }

/* ----- Context Menu FAB ----- */
.context-fab {
  position: fixed; bottom: 24px; right: 24px;
  width: 56px; height: 56px; border-radius: 50%; border: none;
  background: #1a73e8; color: #fff; font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(26,115,232,0.35);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, transform 0.15s;
}
.context-fab:hover { background: #1765cc; transform: scale(1.05); }

/* ----- Context Menu Overlay ----- */
.context-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 250;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { 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;
}
.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: #f1f3f4; font-size: 0.9rem; cursor: pointer;
  transition: background 0.15s;
}
.ctx-nav-btn:hover { background: #e8eaed; }
.ctx-page-label { font-size: 0.9rem; color: #5f6368; }
.ctx-btn {
  height: 44px; border: none; border-radius: 10px;
  background: #1a73e8; color: #fff; font-size: 0.95rem;
  cursor: pointer; transition: background 0.15s;
}
.ctx-btn:hover { background: #1765cc; }
.ctx-btn-close { background: #f1f3f4; color: #202124; }
.ctx-btn-close:hover { background: #dadce0; }
.ctx-link { display: block; text-align: center; color: #1a73e8; text-decoration: none; font-size: 0.9rem; }
.ctx-link:hover { text-decoration: underline; }

/* ----- Doc Nav Links (in context menu) ----- */
.doc-nav-links {
  display: flex; flex-direction: column; gap: 6px;
}
.doc-nav-link {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 8px;
  font-size: 0.9rem; color: #202124;
  text-decoration: none;
  transition: background 0.15s;
}
.doc-nav-link:hover { background: #f1f3f4; text-decoration: none; }
.doc-nav-link.active { background: #e8f0fe; color: #1a73e8; font-weight: 600; }

/* ----- Text View ----- */
.text-view {
  max-width: 800px;
  width: 100%;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.1rem;
  line-height: 1.8;
  color: #202124;
}
.text-view h1, .text-view h2, .text-view h3 {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1a1a2e;
  margin-top: 1.5em;
}
.text-view h2 {
  font-size: 1.6rem;
  margin-top: 0;
  margin-bottom: 0.5em;
  padding-bottom: 0.4em;
  border-bottom: 2px solid #e8eaed;
}
.text-view h3 { font-size: 1.25rem; margin-bottom: 0.5em; }
.text-view p { margin-bottom: 1em; }
.text-view blockquote {
  border-left: 3px solid #dadce0;
  margin: 1em 0;
  padding: 0.5em 1em;
  color: #5f6368;
  background: #fafafa;
  border-radius: 0 6px 6px 0;
}
.text-view .page-content { padding: 0; }
.text-view .empty-page {
  color: #9aa0a6;
  text-align: center;
  padding: 3em 1em;
  font-style: italic;
}
.text-view .definition-box {
  border-left: 4px solid #34a853;
  background: #f0faf3;
  padding: 14px 18px;
  margin: 20px 0;
  border-radius: 0 8px 8px 0;
  font-size: 1.02rem;
  line-height: 1.7;
}
.text-view .definition-box strong { color: #1e7e34; }
.text-view .highlight-box {
  border-left: 4px solid #1a73e8;
  background: #eaf2fd;
  padding: 14px 18px;
  margin: 20px 0;
  border-radius: 0 8px 8px 0;
  font-size: 1.02rem;
  line-height: 1.7;
}
.text-view .highlight-box strong { color: #1557b0; }
.text-view .figure-box {
  border-left: 4px solid #f9ab00;
  background: #fef9e7;
  padding: 14px 18px;
  margin: 20px 0;
  border-radius: 0 8px 8px 0;
  font-size: 1.02rem;
  line-height: 1.7;
}
.text-view .figure-box strong { color: #b77b00; }
.text-view .formula-box {
  border-left: 4px solid #8b5cf6;
  background: #f5f3ff;
  padding: 14px 18px;
  margin: 20px 0;
  border-radius: 0 8px 8px 0;
  font-family: 'SF Mono', SFMono-Regular, ui-monospace, monospace;
  font-size: 1.05rem;
  text-align: center;
  letter-spacing: 0.02em;
}
.text-view .intuition-box {
  border-left: 4px solid #0d9488;
  background: #f0fdfa;
  padding: 14px 18px;
  margin: 20px 0;
  border-radius: 0 8px 8px 0;
}
.text-view .intuition-box strong { color: #0f766e; }
.text-view .commentary {
  background: #f8f9fa;
  border: 1px solid #e8eaed;
  border-radius: 12px;
  padding: 24px;
  margin-top: 2em;
}
.text-view .commentary > h3 {
  font-size: 1.15rem;
  color: #5f6368;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-top: 0;
  margin-bottom: 1em;
  padding-bottom: 0.5em;
  border-bottom: 1px solid #e8eaed;
}
.text-view .commentary-section {
  background: #fff;
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 12px;
  border: 1px solid #eef0f2;
}
.text-view .commentary-section:last-child { margin-bottom: 0; }
.text-view .commentary-section h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1a73e8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0;
  margin-bottom: 0.5em;
}
.text-view .commentary-section p {
  margin-bottom: 0;
  color: #3c4043;
  font-size: 1.02rem;
  line-height: 1.75;
}

/* ----- 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; }
  .page-display { margin-top: 60px; margin-bottom: 90px; padding: 8px; }
  .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; }
  .text-view { font-size: 1rem; line-height: 1.7; }
  .text-view h2 { font-size: 1.3rem; }
  .text-view .commentary { padding: 16px; }
  .text-view .commentary-section { padding: 12px 14px; }
  .text-view .definition-box, .text-view .highlight-box, .text-view .figure-box, .text-view .formula-box, .text-view .intuition-box { padding: 10px 14px; }
}
