/* ============================================================
   Survival Counts Too — Proofreading Tool
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg:           #faf9f7;
  --color-surface:      #ffffff;
  --color-border:       #e5e2db;
  --color-text:         #2c2825;
  --color-text-muted:   #8a847c;
  --color-accent:       #6b5c4e;
  --color-accent-light: #f0ebe4;

  --status-draft:        #9ca3af;
  --status-pending:      #f59e0b;
  --status-revised:      #10b981;
  --status-approved:     #3b82f6;

  --annotation-open:     #fef3c7;
  --annotation-open-border: #f59e0b;
  --annotation-resolved: #f3f4f6;
  --annotation-resolved-border: #d1d5db;

  --font-body:   'Georgia', 'Times New Roman', serif;
  --font-ui:     -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --max-prose:   68ch;
}

html { font-size: 16px; }
body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-ui);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Header ---- */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 24px 32px 20px;
}
.header-inner { max-width: 1100px; margin: 0 auto; }
.book-title   { font-family: var(--font-body); font-size: 1.5rem; font-weight: normal; letter-spacing: 0.02em; color: var(--color-text); }
.book-author  { font-size: 0.85rem; color: var(--color-text-muted); margin-top: 3px; }
.book-subtitle{ font-size: 0.75rem; color: var(--color-text-muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.1em; }

/* ---- Revision banner ---- */
.revision-banner {
  background: #d1fae5;
  border-bottom: 1px solid #6ee7b7;
  color: #065f46;
  padding: 12px 32px;
  font-size: 0.9rem;
  font-family: var(--font-ui);
  text-align: center;
}
.revision-banner.hidden { display: none; }

/* ---- Chapter tabs ---- */
.chapter-tabs {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  overflow-x: auto;
  padding: 0 32px;
  max-width: 100%;
}
.chapter-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  border: none;
  border-bottom: 3px solid transparent;
  background: none;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.chapter-tab:hover          { color: var(--color-text); }
.chapter-tab.active         { color: var(--color-accent); border-bottom-color: var(--color-accent); font-weight: 600; }
.chapter-tab .tab-num       { font-weight: 700; }
.chapter-tab .tab-status    {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-draft    { background: var(--status-draft); }
.status-pending  { background: var(--status-pending); }
.status-revised  { background: var(--status-revised); }
.status-approved { background: var(--status-approved); }

/* ---- Chapter view ---- */
.chapter-view {
  flex: 1;
  padding: 48px 32px 120px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.loading-state, .empty-state {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  padding: 32px 0;
}
.empty-state code {
  background: var(--color-accent-light);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.85em;
}
.hidden { display: none !important; }

.chapter-header  { margin-bottom: 36px; }
.chapter-num     { font-family: var(--font-ui); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--color-text-muted); display: block; margin-bottom: 8px; }
.chapter-title   { font-family: var(--font-body); font-size: 1.8rem; font-weight: normal; color: var(--color-text); line-height: 1.3; }

/* ---- Prose body ---- */
.chapter-body {
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--color-text);
  max-width: var(--max-prose);
  user-select: text;
}
.chapter-body p   { margin-bottom: 1.4em; }
.chapter-body p:last-child { margin-bottom: 0; }

/* ---- Annotations ---- */
.annotation-highlight {
  cursor: pointer;
  border-radius: 2px;
  border-bottom: 2px solid var(--annotation-open-border);
  background: var(--annotation-open);
  position: relative;
}
.annotation-highlight.resolved {
  background: var(--annotation-resolved);
  border-bottom-color: var(--annotation-resolved-border);
  text-decoration: line-through;
  text-decoration-color: #aaa;
}

/* Tooltip */
.annotation-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #f9fafb;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  line-height: 1.4;
  padding: 7px 10px;
  border-radius: 5px;
  white-space: nowrap;
  max-width: 260px;
  white-space: normal;
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.annotation-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1f2937;
}
.annotation-highlight:not(:hover) .annotation-tooltip { display: none; }

/* ---- Annotation popup ---- */
.annotation-popup {
  position: fixed;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  padding: 14px 16px;
  width: 280px;
  z-index: 200;
  font-family: var(--font-ui);
}
.annotation-input {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  padding: 8px 10px;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  resize: vertical;
  outline: none;
  color: var(--color-text);
  background: var(--color-bg);
}
.annotation-input:focus { border-color: var(--color-accent); }
.annotation-actions     { display: flex; gap: 8px; margin-top: 10px; justify-content: flex-end; }

.btn-submit-annotation {
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 7px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: var(--font-ui);
}
.btn-submit-annotation:hover { background: #594d42; }

.btn-cancel-annotation {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  padding: 7px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--color-text-muted);
  font-family: var(--font-ui);
}
.btn-cancel-annotation:hover { color: var(--color-text); border-color: #aaa; }

/* ---- Deep Truth page ---- */
.deep-truth-page {
  margin: 56px 0 32px;
  padding: 40px 32px;
  background: #faf8f5;
  border: 1px solid #e8e2d9;
  border-radius: 4px;
  max-width: var(--max-prose);
  text-align: center;
  font-family: var(--font-body);
}
.dt-header {
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #8a7e72;
  margin-bottom: 12px;
}
.dt-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
  color: #b5a898;
  font-size: 0.9rem;
}
.dt-divider::before,
.dt-divider::after {
  content: '';
  display: block;
  width: 48px;
  height: 1px;
  background: #c8bfb4;
}
.dt-body {
  font-size: 1rem;
  line-height: 1.9;
  color: #2c2825;
  text-align: left;
}
.dt-body p {
  margin-bottom: 1.2em;
}
.dt-body p:last-child { margin-bottom: 0; }
.dt-key {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  font-style: normal;
}
.dt-footer {
  margin-top: 28px;
  color: #b5a898;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
}

/* ---- Reflection questions ---- */
.reflection-section {
  margin: 40px 0 8px;
  padding: 28px 0 0;
  border-top: 1px solid var(--color-border);
  max-width: var(--max-prose);
}
.reflection-title {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--color-text-muted);
  margin-bottom: 18px;
}
.reflection-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.reflection-list li {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--color-text);
  padding: 10px 0 10px 20px;
  border-bottom: 1px solid var(--color-border);
  position: relative;
}
.reflection-list li:last-child { border-bottom: none; }
.reflection-list li::before {
  content: attr(data-num);
  position: absolute;
  left: 0;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-family: var(--font-ui);
  top: 12px;
}

/* ---- Submit bar ---- */
.submit-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 16px 32px;
  display: flex;
  justify-content: flex-end;
  z-index: 150;
}
.submit-btn {
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 12px 28px;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.submit-btn:hover:not(:disabled) { background: #594d42; }
.submit-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.submit-btn.submitted {
  background: #6b7280;
  opacity: 1;
  cursor: not-allowed;
}
