/* ── style-worldview.css ──────────────────────────────────────────────────────
   Worldview management page. Depends on style.css for :root variables.
*/

/* ── Top bar ── */
#wv-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(15, 15, 19, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

#wv-back {
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--muted);
  font-family: "Noto Sans SC", sans-serif;
  font-size: 0.8rem;
  padding: 6px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}
#wv-back:hover { color: var(--text); border-color: var(--accent2); }

#wv-title-area {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

#wv-title-display {
  font-family: "Noto Serif SC", Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#wv-lang-btn,
#help-lang-btn,
#profile-lang-btn,
#privacy-lang-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--muted);
  font-family: "Noto Sans SC", sans-serif;
  font-size: 0.76rem;
  padding: 6px 14px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}
#wv-lang-btn::before,
#help-lang-btn::before,
#profile-lang-btn::before,
#privacy-lang-btn::before {
  content: '🌐 ';
}

#wv-lang-btn:hover,
#help-lang-btn:hover,
#profile-lang-btn:hover,
#privacy-lang-btn:hover { color: var(--accent2); border-color: var(--accent2); }

/* ── i18n visibility (shared by help + profile pages) ── */
.lang-en { display: none; }
body.help-en .lang-en { display: block; }
body.help-en .lang-zh { display: none; }

/* ── Tabs ── */
#wv-tabs-row {
  display: flex;
  gap: 0;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  overflow-x: auto;
}
#wv-tabs-row::-webkit-scrollbar { height: 0; }

.wv-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: "Noto Sans SC", sans-serif;
  font-size: 0.85rem;
  padding: 12px 18px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
  margin-bottom: -1px;
}
.wv-tab:hover    { color: var(--text); }
.wv-tab.active   { color: var(--accent2); border-bottom-color: var(--accent2); }

/* ── Main content area ── */
#wv-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 20px 100px;
}

.wv-panel { animation: wvFadeIn 0.2s ease; }
@keyframes wvFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ── World settings panel ── */
.wv-world-fields {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 24px;
}

.wv-world-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wv-field-label {
  font-family: "Noto Sans SC", sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.wv-field-value {
  font-family: "Noto Serif SC", Georgia, serif;
  font-size: 0.92rem;
  line-height: 1.8;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.wv-field-value.empty { color: var(--muted); font-style: italic; }

.wv-tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.wv-tag {
  font-family: "Noto Sans SC", sans-serif;
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: var(--accent2);
}

.wv-outline-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-family: "Noto Sans SC", sans-serif;
  font-size: 0.85rem;
  padding: 10px 20px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.wv-outline-btn:hover { border-color: var(--accent2); color: var(--accent2); }

/* ── Worldview inject switch (in topbar) ── */
.wv-switch-btn {
  position: relative;
  width: 36px;
  height: 20px;
  background: rgba(60, 60, 80, 0.5);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}
.wv-switch-btn::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  background: var(--muted);
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.25s ease, background 0.2s;
}
.wv-switch-btn[aria-pressed="true"] {
  background: rgba(139, 92, 246, 0.35);
  border-color: var(--accent2);
}
.wv-switch-btn[aria-pressed="true"]::after {
  transform: translateX(16px);
  background: var(--accent2);
}
.wv-inject-label {
  font-family: "Noto Sans SC", sans-serif;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  user-select: none;
}

/* ── Entry grid ── */
.wv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

/* Entry card */
.wv-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s;
}
.wv-card:hover { border-color: rgba(139, 92, 246, 0.4); }

.wv-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wv-card-icon { font-size: 1.1rem; flex-shrink: 0; }

.wv-card-name {
  flex: 1;
  min-width: 0;
  font-family: "Noto Serif SC", Georgia, serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wv-card-actions { display: flex; gap: 4px; flex-shrink: 0; }

.wv-icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}
.wv-icon-btn:hover              { color: var(--text); background: var(--surface2); }
.wv-icon-btn--danger:hover      { color: #f87171; background: rgba(248,113,113,0.1); }

.wv-card-subtitle {
  font-family: "Noto Sans SC", sans-serif;
  font-size: 0.77rem;
  color: var(--accent2);
  opacity: 0.85;
}

.wv-card-preview {
  font-family: "Noto Serif SC", Georgia, serif;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.6;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* Add card */
.wv-add-card {
  background: none;
  border: 2px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  font-family: "Noto Sans SC", sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 24px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: border-color 0.2s, color 0.2s;
  min-height: 100px;
}
.wv-add-card:hover { border-color: var(--accent2); color: var(--accent2); }
.wv-add-icon { font-size: 1.6rem; line-height: 1; }

/* Empty state */
.wv-empty-state {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  font-family: "Noto Sans SC", sans-serif;
  font-size: 0.85rem;
  padding: 32px 0;
  opacity: 0.6;
}

/* Loading placeholder */
.wv-loading {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  font-family: "Noto Sans SC", sans-serif;
  font-size: 0.85rem;
  padding: 32px 0;
  animation: wvPulse 1.4s ease infinite;
}
@keyframes wvPulse { 0%,100%{opacity:0.4} 50%{opacity:1} }

/* ── FAB ── */
#wv-fab {
  position: fixed;
  bottom: 28px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6d28d9, #8b5cf6);
  border: none;
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(109, 40, 217, 0.45);
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 200;
}
#wv-fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(109, 40, 217, 0.6); }

/* ── Modals ── */
.wv-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.wv-overlay[hidden] { display: none !important; }
.wv-overlay.open    { opacity: 1; }

.wv-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px 24px;
  width: min(500px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 24px 60px rgba(0,0,0,0.55);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.wv-modal::-webkit-scrollbar { width: 4px; }
.wv-modal::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.wv-modal--sm {
  width: min(340px, 100%);
  padding: 28px 24px;
}

.wv-modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.2s;
}
.wv-modal-close:hover { color: var(--text); }

.wv-modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.04em;
  padding-right: 24px;
}

/* ── Forms ── */
.wv-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wv-form-label {
  font-family: "Noto Sans SC", sans-serif;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
}
.wv-form-label:first-child { margin-top: 0; }

.wv-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-family: "Noto Serif SC", Georgia, serif;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.wv-input::placeholder { color: var(--muted); }
.wv-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }

select.wv-input { cursor: pointer; font-family: "Noto Sans SC", sans-serif; }
select.wv-input option { background: var(--surface2); }

.wv-textarea { resize: vertical; line-height: 1.7; }

.wv-form-error {
  font-family: "Noto Sans SC", sans-serif;
  font-size: 0.82rem;
  color: #f87171;
  min-height: 0;
  display: none;
}
.wv-form-error.visible { display: block; }

/* ── Buttons ── */
.wv-primary-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #6d28d9, #8b5cf6);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-family: "Noto Sans SC", sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--glow);
  transition: opacity 0.2s, transform 0.15s;
}
.wv-primary-btn:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }
.wv-primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.wv-btn-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.wv-cancel-btn {
  padding: 10px 20px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-family: "Noto Sans SC", sans-serif;
  font-size: 0.88rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.wv-cancel-btn:hover { color: var(--text); border-color: var(--text); }

.wv-danger-btn {
  padding: 10px 20px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 8px;
  color: #f87171;
  font-family: "Noto Sans SC", sans-serif;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.2s;
}
.wv-danger-btn:hover { background: rgba(239, 68, 68, 0.25); }

.wv-delete-msg {
  font-family: "Noto Sans SC", sans-serif;
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 4px;
}

/* ── Toast ── */
.wv-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #134e26;
  color: #86efac;
  border: 1px solid #166534;
  padding: 11px 24px;
  border-radius: 8px;
  font-family: "Noto Sans SC", sans-serif;
  font-size: 13px;
  z-index: 9999;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  white-space: nowrap;
}
.wv-toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.wv-toast--error  { background: #450a0a; color: #fca5a5; border-color: #7f1d1d; }

/* Hide number-input spinner arrows */
.wv-input[type=number]::-webkit-inner-spin-button,
.wv-input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.wv-input[type=number] { -moz-appearance: textfield; }

/* ── Create-worldview hero panel ── */
.wv-create-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 72px 20px;
  gap: 16px;
}
.wv-create-icon  { font-size: 3.2rem; line-height: 1; }
.wv-create-title {
  font-family: "Noto Serif SC", Georgia, serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  letter-spacing: 0.04em;
}
.wv-create-desc {
  font-family: "Noto Sans SC", sans-serif;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.75;
  max-width: 380px;
  margin: 0;
}
.wv-create-btn { max-width: 200px; margin-top: 8px; }

/* ── Responsive ── */
@media (max-width: 480px) {
  #wv-main { padding: 20px 14px 100px; }
  .wv-grid { grid-template-columns: 1fr; }
  .wv-modal { padding: 22px 16px 20px; }
}
