/* =========================================================================
   PDF Viewer for Meta Ray-Ban Display (MRBD) — styles.css  v4
   ========================================================================= */

:root {
  --bg:          #000000;
  --fg:          #ffffff;
  --fg-dim:      #bfc7d1;
  --muted:       #7e8896;
  --accent:      #00d4ff;
  --accent-glow: rgba(0, 212, 255, 0.35);
  --danger:      #ff6b6b;
  --rule:        rgba(255, 255, 255, 0.10);
  --card:        rgba(255, 255, 255, 0.05);
  --overlay-bg:  rgba(0, 0, 0, 0.75);

  --font-ui:      -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-reading: ui-rounded, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

/* ── Glasses stage (600×600) ── */
.stage {
  position: relative;
  width: 600px;
  height: 600px;
  overflow: hidden;
  background: var(--bg);
  flex: 0 0 600px;
}

@media (min-width: 900px) {
  .stage { border: 1px solid var(--rule); border-radius: 8px; margin: 24px; }
  body { overflow: auto; }
}

.view {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}
.view.active { display: flex; }
.hidden { display: none !important; }


/* ═══════════════════════════════════════════════════════════════════════
   LIBRARY VIEW
   ═══════════════════════════════════════════════════════════════════════ */
/* env(safe-area-inset-top) pushes the header below the iPhone notch/status bar */
#view-library { padding: calc(env(safe-area-inset-top, 0px) + 16px) 24px 14px; }

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.brand { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }

/* ── Sync status dot (replaces badge — sync is automatic, no button needed) ── */
.sync-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.4;
  transition: background 0.3s, opacity 0.3s;
  flex: 0 0 auto;
}
.sync-status-dot.synced  { background: var(--accent); opacity: 0.9; }
.sync-status-dot.syncing { background: var(--accent); opacity: 0.5;
  animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 0.3; } 50% { opacity: 1; } }

.library-meta {
  font-size: 12px; color: var(--muted);
  margin-bottom: 12px;
  display: flex; gap: 6px; align-items: center;
}

/* ── PDF list ── */
.pdf-list {
  list-style: none; margin: 0; padding: 0;
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 5px;
}
.pdf-list::-webkit-scrollbar { width: 3px; }
.pdf-list::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 2px; }

.pdf-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: border-color 0.15s, background 0.15s;
  user-select: none; -webkit-user-select: none;
  position: relative;
}
.pdf-item:hover   { background: rgba(255,255,255,0.08); }
.pdf-item.selected { border-color: var(--accent); background: rgba(0,212,255,0.08); }
.pdf-item.remote  { opacity: 0.65; }
.pdf-item.remote.selected { opacity: 1; }

.pdf-item-icon  { font-size: 20px; flex: 0 0 auto; line-height: 1; }
.pdf-item-info  { flex: 1; min-width: 0; }
.pdf-item-name  { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pdf-item-meta  { font-size: 11px; color: var(--muted); margin-top: 1px; }
.pdf-progress   { color: var(--accent); font-weight: 600; }

/* reading progress bar */
.pdf-progress-bar {
  position: absolute; bottom: 0; left: 0;
  height: 2px; width: var(--pct);
  background: var(--accent);
  border-radius: 0 0 8px 8px; opacity: 0.7;
}

/* inline spinner for remote download */
.pdf-item-spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: 0 0 auto;
}

.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; color: var(--muted);
}
.empty-icon  { font-size: 38px; opacity: 0.35; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--fg-dim); }
.empty-sub   { font-size: 12px; text-align: center; max-width: 260px; line-height: 1.4; }

/* ── Footer buttons ── */
.view-footer { display: flex; gap: 6px; padding-top: 12px; }

button, label.primary, label.secondary {
  cursor: pointer; border: none; border-radius: 8px;
  font-size: 13px; font-weight: 600; font-family: var(--font-ui);
  padding: 11px 10px; transition: opacity 0.15s;
  white-space: nowrap; display: inline-flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.primary   { background: var(--accent); color: #000; flex: 1; }
.primary:active { opacity: 0.80; }
.secondary { background: var(--card); color: var(--fg); border: 1.5px solid var(--rule); flex: 1; }
.secondary:active { opacity: 0.70; }
.danger    { color: var(--danger) !important; border-color: rgba(255,107,107,0.30) !important; }
.danger:active { background: rgba(255,107,107,0.12) !important; }

label#label-load input[type="file"] {
  position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none;
}

.focusable:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: 0 0 0 4px var(--accent-glow);
}

/* ── Shared modal overlay (sync + any future overlays) ── */
.modal-overlay {
  position: absolute; inset: 0; z-index: 40;
  background: rgba(0,0,0,0.88);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}

.modal-box {
  background: #0c111a;
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 22px 18px;
  width: 100%;
  display: flex; flex-direction: column; gap: 10px;
}

.modal-title { font-size: 17px; font-weight: 700; }
.modal-sub   { font-size: 12px; color: var(--muted); margin-top: -4px; }
.modal-hint  { font-size: 11px; color: var(--muted); margin-top: -4px; }

.modal-input {
  width: 100%;
  background: rgba(255,255,255,0.07);
  border: 1.5px solid var(--rule);
  border-radius: 8px; color: var(--fg);
  font-size: 15px; font-family: var(--font-ui);
  padding: 10px 12px; outline: none;
}
.modal-input:focus  { border-color: var(--accent); }
.modal-input::placeholder { color: var(--muted); }

.modal-actions { display: flex; gap: 8px; margin-top: 2px; }
.modal-actions .primary, .modal-actions .secondary { flex: 1; }

.link-btn {
  background: none; border: none; color: var(--muted);
  font-size: 12px; cursor: pointer; padding: 4px 0;
  text-align: center; text-decoration: underline;
  -webkit-tap-highlight-color: transparent;
}
.link-btn:hover { color: var(--fg-dim); }


/* ═══════════════════════════════════════════════════════════════════════
   READER VIEW
   ═══════════════════════════════════════════════════════════════════════ */
.reader-topbar {
  position: absolute; top: 0; left: 0; right: 0; height: 44px;
  z-index: 10; display: flex; align-items: center; gap: 2px; padding: 0 6px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.80) 0%, transparent 100%);
}

.reader-title {
  flex: 1; font-size: 12px; font-weight: 600; color: var(--fg-dim);
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 0 4px;
}

.icon-btn {
  background: transparent; border: none; color: var(--fg);
  font-size: 17px; padding: 6px 9px; border-radius: 6px;
  cursor: pointer; transition: background 0.15s;
  -webkit-tap-highlight-color: transparent; line-height: 1; flex: 0 0 auto;
}
.icon-btn:hover  { background: rgba(255,255,255,0.10); }
.icon-btn:active { background: rgba(255,255,255,0.18); }
.icon-btn.active-state { color: var(--accent); }

.canvas-container {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}

#pdf-canvas { display: block; max-width: 600px; max-height: 600px; transition: filter 0.25s; }
#pdf-canvas.inverted { filter: invert(1) hue-rotate(180deg); }

.tap-zone { position: absolute; top: 0; bottom: 0; width: 38%; z-index: 5; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tap-zone--prev { left: 0; }
.tap-zone--next { right: 0; }
.tap-zone:active { background: rgba(255,255,255,0.04); }

.page-counter {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  z-index: 10; background: var(--overlay-bg); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  color: var(--fg-dim); font-size: 13px; font-weight: 600;
  padding: 4px 12px; border-radius: 20px; border: 1px solid var(--rule);
  pointer-events: none; white-space: nowrap;
}
.page-sep { opacity: 0.50; }

.loading-overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; background: var(--bg);
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,0.12); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
#toast {
  position: absolute; bottom: 52px; left: 50%;
  transform: translateX(-50%) translateY(14px);
  z-index: 50; background: rgba(24,28,34,0.96); border: 1px solid var(--rule);
  color: var(--fg); font-size: 13px; padding: 8px 16px;
  border-radius: 20px; pointer-events: none; opacity: 0;
  transition: opacity 0.2s, transform 0.2s; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }


/* ═══════════════════════════════════════════════════════════════════════
   TELEPROMPTER VIEW
   ═══════════════════════════════════════════════════════════════════════ */
.tp-topbar {
  position: absolute; top: 0; left: 0; right: 0; height: 48px; z-index: 10;
  display: flex; align-items: center; gap: 6px; padding: 0 8px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.85) 0%, transparent 100%);
}
.tp-title { flex: 1; font-size: 12px; font-weight: 600; color: var(--fg-dim); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }
.tp-wpm   { font-size: 12px; font-weight: 700; color: var(--accent); min-width: 54px; text-align: right; }

.tp-reading-line {
  position: absolute; top: 200px; left: 28px; right: 28px; height: 2px; z-index: 8;
  background: linear-gradient(to right, transparent 0%, var(--accent) 20%, var(--accent) 80%, transparent 100%);
  box-shadow: 0 0 10px var(--accent-glow), 0 0 20px var(--accent-glow);
  pointer-events: none;
}

.tp-scroll-area {
  position: absolute; inset: 0; overflow: hidden;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.tp-scroll-area::before, .tp-scroll-area::after {
  content: ''; position: absolute; left: 0; right: 0; height: 80px;
  pointer-events: none; z-index: 6;
}
.tp-scroll-area::before { top: 0;    background: linear-gradient(to bottom, var(--bg) 0%, transparent 100%); }
.tp-scroll-area::after  { bottom: 0; background: linear-gradient(to top,   var(--bg) 0%, transparent 100%); }

.tp-text {
  position: absolute; top: 0; left: 0; right: 0; padding: 0 28px;
  font-family: var(--font-reading); font-size: 34px; line-height: 1.55; color: var(--fg);
  white-space: pre-wrap; word-break: break-word; will-change: transform;
}
.tp-play-btn {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  z-index: 10; background: var(--overlay-bg); border: 1.5px solid rgba(255,255,255,0.18);
  color: var(--fg); font-size: 20px; width: 52px; height: 52px; border-radius: 50%;
  cursor: pointer; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: background 0.15s, transform 0.12s;
  -webkit-tap-highlight-color: transparent; display: flex; align-items: center; justify-content: center;
}
.tp-play-btn:active { background: rgba(0,212,255,0.20); transform: translateX(-50%) scale(0.92); }
.tp-loading-msg { font-size: 14px; color: var(--fg-dim); }
