/* Ghost Biographer — Registration (Phase 1) page styles
   Page-specific layout and overrides only.
   Shared tokens and components live in design.css. */

/* ── Auth gate (full-screen, shown before login) ────────────── */
#auth-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: var(--paper-2);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-card {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 420px;
  overflow: hidden;
}
.auth-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 28px 28px 0;
}
.auth-logo img { height: 32px; width: 32px; object-fit: contain; }
.auth-logo-name {
  font-family: var(--font-editorial); font-size: 17px; color: var(--ink);
}
.auth-logo-name span { color: var(--plum); }

.auth-tabs {
  display: flex; border-bottom: 1px solid var(--hairline);
  margin: 20px 0 0; padding: 0 28px;
}
.auth-tab {
  flex: 1; padding: 12px 8px;
  font-size: 14px; font-weight: 500;
  color: var(--ink-3); background: none;
  border: none; border-bottom: 2px solid transparent;
  cursor: pointer; transition: color 120ms; margin-bottom: -1px;
}
.auth-tab:hover:not(.active) { color: var(--ink-2); }
.auth-tab.active { color: var(--plum); border-bottom-color: var(--plum); }

.auth-pane { display: none; flex-direction: column; gap: 16px; padding: 24px 28px 28px; }
.auth-pane.active { display: flex; }
.auth-pane h2 {
  font-family: var(--font-editorial); font-size: 22px;
  font-weight: 400; color: var(--ink); margin: 0;
}
.auth-error { font-size: 13px; color: var(--rose); min-height: 18px; }

.auth-pw-wrap { position: relative; }
.auth-pw-wrap .input { padding-right: 76px; }
.auth-pw-toggle {
  position: absolute; right: 40px; top: 50%; transform: translateY(-50%);
  font-size: 12px; font-weight: 600; color: var(--ink-3);
  background: none; border: none; cursor: pointer;
  padding: 4px 6px; border-radius: 6px; transition: color 120ms;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.auth-pw-toggle:hover { color: var(--plum); }

.qr-wrapper { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.qr-wrapper img { border-radius: 8px; border: 3px solid var(--hairline-2); }

/* ── TOTP setup key — readable on small screens, unambiguous glyphs ── */
.qr-secret {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; width: 100%; max-width: 460px;
}
.qr-secret-label {
  font-size: 13px; color: var(--ink-3); text-align: center;
}
.qr-secret-row {
  display: flex; align-items: stretch; gap: 8px;
  width: 100%; justify-content: center;
}
.qr-secret-code {
  /* JetBrains Mono ships a slashed zero by default — solves 0 vs O */
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular,
               'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  /* font-variant-numeric: slashed-zero is a no-op on JetBrains Mono
     (already on) but kicks in if the font fails to load and a generic
     monospace is substituted that supports the OpenType feature. */
  font-variant-numeric: slashed-zero;
  font-feature-settings: 'zero' on, 'cv09' on;
  font-size: 19px; line-height: 1.45; font-weight: 500;
  letter-spacing: 0.04em; word-spacing: 0.5em;  /* widens the gap between groups-of-4 */
  color: var(--ink); background: #f8fafc;
  border: 1px solid var(--hairline-2); border-radius: 8px;
  padding: 10px 14px; text-align: center;
  user-select: all; -webkit-user-select: all;
  word-break: break-word; flex: 1 1 auto; min-width: 0;
}
.qr-secret-copy {
  flex: 0 0 auto; cursor: pointer;
  background: var(--plum); color: #fff; border: none;
  padding: 0 16px; border-radius: 8px; font-size: 14px; font-weight: 600;
  transition: background-color .15s ease, transform .1s ease;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 78px;
}
.qr-secret-copy:hover { background: var(--plum-dark, #6d28d9); }
.qr-secret-copy:active { transform: translateY(1px); }
.qr-secret-copy.qr-secret-copied { background: #16a34a; }
@media (max-width: 480px) {
  .qr-secret-row { flex-direction: column; }
  .qr-secret-copy { width: 100%; padding: 10px; }
  .qr-secret-code { font-size: 18px; }
}
.auth-step-desc { font-size: 13px; color: var(--ink-3); line-height: 1.6; }

/* ── Print: backup-codes pane only, single column, clean paper ─────── */
@media print {
  @page { margin: 0.75in; }
  html, body { background: #fff !important; color: #000 !important; }

  /* Strip everything outside the backup-codes pane */
  body > nav, body > header,
  #main-layout,
  .auth-tabs, .auth-logo,
  .auth-pane:not(#pane-backup-codes),
  #pane-backup-codes button,
  #biographer-bar, #bio-bar {
    display: none !important;
  }

  /* Reset the dark modal overlay so the panel sits on white paper */
  #auth-overlay {
    position: static !important;
    background: transparent !important;
    inset: auto !important;
    display: block !important;
    width: auto !important;
    height: auto !important;
  }
  .auth-card {
    box-shadow: none !important;
    border: none !important;
    background: #fff !important;
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Backup codes — single column, no shading, generous size */
  #pane-backup-codes h2 {
    font-size: 18pt; margin: 0 0 10pt;
  }
  #pane-backup-codes .auth-step-desc,
  #pane-backup-codes p {
    font-size: 11pt; line-height: 1.5; margin: 0 0 14pt; color: #000;
  }
  #backup-codes-list {
    grid-template-columns: 1fr !important;     /* override inline 1fr 1fr */
    background: transparent !important;
    border: 1px solid #94a3b8 !important;
    border-radius: 6pt !important;
    padding: 14pt 18pt !important;
    margin: 0 !important;
    font-size: 14pt !important;
    line-height: 1.85 !important;
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular,
                 Menlo, Consolas, monospace !important;
    font-variant-numeric: slashed-zero !important;
    page-break-inside: avoid;
  }
}

/* ── Page layout ────────────────────────────────────────────── */
body { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
#main-layout {
  display: grid; grid-template-columns: 220px 1fr;
  flex: 1; min-height: 0;
}

/* ── Fact-checklist sidebar ─────────────────────────────────── */
#steps-panel {
  background: var(--paper-2); border-right: 1px solid var(--hairline);
  display: flex; flex-direction: column;
  padding: 16px 12px 12px; gap: 4px; overflow-y: auto;
}
#steps-panel h3 {
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  color: var(--ink-4); text-transform: uppercase; letter-spacing: 0.1em;
  padding: 4px 8px 10px; margin: 0;
}
.fact-item {
  padding: 10px; border-radius: 10px; font-size: 13px;
  border: 1px solid transparent;
  transition: border-color 250ms, background 250ms;
}
.fact-item .fact-label {
  color: var(--ink-3); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.07em;
  margin-bottom: 4px; display: flex; align-items: center; gap: 6px;
}
.fact-item .fact-check {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid var(--hairline-2);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px; flex-shrink: 0; transition: all 250ms;
}
.fact-item .fact-value {
  color: var(--ink-3); font-size: 13px; font-style: italic; min-height: 1.2em;
}
.fact-item.pending .fact-value { color: var(--hairline-2); }
.fact-item.pending .fact-value::before { content: "—"; }
.fact-item.learned { border-color: oklch(0.82 0.04 185); background: var(--sage-bg); }
.fact-item.learned .fact-check { background: var(--sage); border-color: var(--sage); color: white; }
.fact-item.learned .fact-label { color: oklch(0.42 0.07 185); }
.fact-item.learned .fact-value { color: oklch(0.32 0.08 185); font-style: normal; font-weight: 600; }

.fact-edit-row { display: flex; gap: 6px; margin-top: 6px; }
.fact-edit-btn {
  background: var(--sage-bg); border: 1px solid oklch(0.82 0.04 185);
  border-radius: 6px; color: var(--sage); font-size: 11px;
  padding: 3px 8px; cursor: pointer; transition: background 120ms;
}
.fact-edit-btn:hover { background: oklch(0.88 0.03 185); }
.fact-mic-btn {
  background: var(--sage-bg); border: 1px solid oklch(0.82 0.04 185);
  border-radius: 6px; width: 26px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 11px; flex-shrink: 0;
  transition: background 120ms; padding: 0;
}
.fact-mic-btn.recording {
  border-color: var(--rose); background: var(--rose-bg); color: var(--rose);
  animation: fmic-pulse 0.7s infinite;
}
@keyframes fmic-pulse { 0%,100%{opacity:1;} 50%{opacity:.45;} }

.arc-count {
  margin-top: auto; padding: 12px 8px 4px;
  font-family: var(--font-mono); font-size: 11px; color: var(--ink-4);
  border-top: 1px solid var(--hairline);
}
.arc-count span { color: var(--plum); font-weight: 600; }

/* ── Main conversation panel ────────────────────────────────── */
#main-panel { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
#panel-header {
  padding: 12px 20px; border-bottom: 1px solid var(--hairline);
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
  background: var(--paper);
}
#panel-header h1 { font-size: 15px; font-weight: 600; color: var(--ink); flex: 1; }
#step-subtitle { font-size: 12px; color: var(--ink-3); white-space: nowrap; }

#speaking-indicator { display: none; align-items: center; gap: 4px; font-size: 12px; color: var(--plum); }
#speaking-indicator.active { display: flex; }
.speak-dot {
  width: 5px; height: 5px; border-radius: 50%; background: var(--plum);
  animation: speak-pulse 0.7s ease-in-out infinite;
}
.speak-dot:nth-child(2) { animation-delay: 0.15s; }
.speak-dot:nth-child(3) { animation-delay: 0.30s; }
@keyframes speak-pulse { 0%,100%{opacity:.3;transform:scale(.8);} 50%{opacity:1;transform:scale(1.2);} }

#convo-wrap {
  flex: 1; overflow-y: auto;
  padding: 16px 20px 80px;
  display: flex; flex-direction: column; gap: 12px;
}
.msg { max-width: 78%; display: flex; flex-direction: column; gap: 2px; }
.msg.assistant { align-self: flex-start; }
.msg.user      { align-self: flex-end; }
.msg .bubble { border-radius: 14px; padding: 10px 14px; font-size: 14px; line-height: 1.6; }
.msg.assistant .bubble {
  background: var(--paper); border: 1px solid var(--hairline);
  box-shadow: var(--shadow-sm); color: var(--ink);
  border-bottom-left-radius: 4px;
}
.msg.user .bubble { background: var(--plum); color: white; border-bottom-right-radius: 4px; }
.msg .ts { font-size: 11px; color: var(--ink-4); padding: 0 4px; }
.msg.user .ts { text-align: right; }

.wave-indicator {
  display: flex; align-items: flex-end; gap: 3px; padding: 8px 14px; height: 36px;
}
.wave-indicator span {
  display: inline-block; width: 4px; border-radius: 2px; background: var(--plum);
  animation: wave-pulse 1.1s ease-in-out infinite;
}
.wave-indicator span:nth-child(1){animation-delay:0s;}
.wave-indicator span:nth-child(2){animation-delay:.15s;}
.wave-indicator span:nth-child(3){animation-delay:.30s;}
.wave-indicator span:nth-child(4){animation-delay:.45s;}
.wave-indicator span:nth-child(5){animation-delay:.60s;}
@keyframes wave-pulse { 0%,100%{height:4px;opacity:.4;} 50%{height:18px;opacity:1;} }

#bottom-area {
  border-top: 1px solid var(--hairline); padding: 10px 20px;
  display: flex; flex-direction: column; gap: 6px;
  flex-shrink: 0; background: var(--paper);
}
#status-bar { font-size: 12px; color: var(--ink-3); min-height: 16px; }
#status-bar.error { color: var(--rose); }
#status-bar.ok    { color: var(--sage); }
#action-row { display: flex; gap: 8px; justify-content: space-between; align-items: center; }

#done-banner {
  display: none;
  background: var(--sage-bg); border: 1px solid oklch(0.82 0.04 185);
  border-radius: var(--radius); padding: 16px 20px;
  margin: 12px 20px 0;
  font-size: 14px; color: oklch(0.32 0.07 185);
  text-align: center; line-height: 1.6;
}
#done-banner a { color: var(--sage); font-weight: 600; text-decoration: underline; cursor: pointer; }

#welcome-back-panel {
  display: none; flex: 1;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; padding: 40px 32px; text-align: center;
}
#welcome-back-panel h2 {
  font-family: var(--font-editorial); font-size: 32px;
  font-weight: 400; color: var(--ink); margin: 0;
}
#welcome-back-panel .wb-sub { font-size: 16px; color: var(--ink-2); max-width: 400px; line-height: 1.65; }
#wb-next-btn {
  background: var(--plum); color: white; border: none;
  border-radius: 999px; padding: 14px 32px;
  font-size: 15px; font-weight: 500; cursor: pointer;
  box-shadow: 0 4px 18px oklch(0.5 0.17 295 / 0.35);
  transition: background 150ms, transform 100ms;
}
#wb-next-btn:hover { background: oklch(0.44 0.18 295); transform: translateY(-1px); }

/* ── What's Next modal ──────────────────────────────────────── */
#wn-overlay {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(20,15,10,0.4);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 16px;
}
#wn-overlay.open { display: flex; }
#wn-modal {
  background: var(--paper); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 560px; width: 100%; max-height: 85vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px;
  padding: 28px; position: relative;
}
#wn-modal h2 {
  font-family: var(--font-editorial); font-size: 24px;
  font-weight: 400; color: var(--ink); margin: 0;
}
#wn-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none; color: var(--ink-3);
  font-size: 20px; line-height: 1; cursor: pointer;
  padding: 4px 6px; border-radius: 6px; transition: background 120ms;
}
#wn-close:hover { background: var(--paper-3); color: var(--ink); }
.wn-guidance {
  font-size: 14px; line-height: 1.7; color: var(--ink-2);
  background: var(--plum-bg); border-radius: var(--radius-sm);
  padding: 14px 16px; border: 1px solid oklch(0.86 0.04 295);
}
.wn-arc-summary { display: flex; flex-wrap: wrap; gap: 6px; }
.wn-arc-chip {
  background: var(--paper-2); border: 1px solid var(--hairline);
  border-radius: 999px; padding: 4px 12px; font-size: 12px; color: var(--ink-2);
}
.wn-arc-chip span { color: var(--plum); font-weight: 600; }
.wn-tip { font-size: 13px; line-height: 1.6; color: var(--ink-3); border-left: 2px solid var(--hairline-2); padding: 4px 12px; font-style: italic; }
.wn-phases { display: flex; flex-direction: column; gap: 4px; }
.wn-phase { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; padding: 8px 10px; border-radius: 8px; }
.wn-phase.complete { color: var(--sage); }
.wn-phase.in_progress { color: var(--terra); background: var(--terra-bg); }
.wn-phase.not_started { color: var(--ink-3); }
.wn-phase .wn-icon { flex-shrink: 0; width: 1.1rem; text-align: center; }
.wn-phase .wn-phase-name { font-weight: 600; min-width: 8rem; }
.wn-phase.clickable { cursor: pointer; transition: background 120ms; }
.wn-phase.clickable:hover { background: var(--paper-3); }
.wn-steps { display: flex; flex-direction: column; gap: 4px; }
.wn-step { font-size: 13px; color: var(--ink); display: flex; gap: 8px; border-radius: 8px; padding: 6px 8px; }
.wn-step::before { content: "→"; color: var(--plum); flex-shrink: 0; }
.wn-step.clickable { cursor: pointer; transition: background 120ms; }
.wn-step.clickable:hover { background: var(--plum-bg); color: var(--plum-ink); }
#wn-loading { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 24px 0; }
#wn-loading span { font-size: 13px; color: var(--ink-3); }
.wn-progress-track { width: 100%; height: 4px; background: var(--hairline); border-radius: 999px; overflow: hidden; }
.wn-progress-bar {
  height: 100%; width: 30%;
  background: linear-gradient(90deg, var(--plum), var(--plum-2), var(--plum));
  background-size: 200% 100%; border-radius: 999px;
  animation: wn-sweep 1.6s ease-in-out infinite;
}
@keyframes wn-sweep { 0%,100%{background-position:0% 50%;} 50%{background-position:100% 50%;} }

.spinner {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid var(--hairline); border-top-color: var(--plum);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
