/* ============================================================
   LoreLock App UI — Faction Engine
   Extends theme.css. Never duplicate :root tokens here.
   ============================================================ */

/* ===== APP NAV ===== */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 6%;
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.app-nav-brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--fg);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.01em;
  transition: color 0.2s;
}

.app-nav-brand:hover { color: var(--accent); }

.app-nav-glyph {
  color: var(--accent);
  font-size: 0.9rem;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.65rem 1.4rem;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.01em;
}

.btn-accent {
  background: var(--accent-dim);
  color: #fff;
  border-color: var(--accent-dim);
}

.btn-accent:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--fg-muted);
  border-color: var(--border);
}

.btn-ghost:hover {
  border-color: var(--border-bright);
  color: var(--fg);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: rgba(248, 113, 113, 0.3);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.1);
  border-color: var(--red);
}

.btn-sm {
  padding: 0.45rem 1rem;
  font-size: 0.82rem;
}

.btn-lg {
  padding: 0.9rem 2rem;
  font-size: 1rem;
}

/* ===== HERO CTA (landing) ===== */
.hero-cta {
  margin-top: 2rem;
}

/* ===== APP MAIN ===== */
.app-main {
  min-height: calc(100vh - 65px);
  padding: 3rem 6%;
  max-width: 1200px;
  margin: 0 auto;
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 3rem;
  gap: 1.5rem;
}

.page-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.25em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.page-title {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3.5vw, 3rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.page-sub {
  font-size: 1rem;
  color: var(--fg-muted);
  margin-top: 0.5rem;
  line-height: 1.6;
  max-width: 600px;
}

/* ===== BREADCRUMB ===== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--fg-dim);
  margin-bottom: 1.5rem;
}

.breadcrumb a {
  color: var(--fg-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumb a:hover { color: var(--accent); }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 6rem 2rem;
  border: 1px dashed var(--border);
}

.empty-glyph {
  font-size: 3rem;
  color: var(--accent-dim);
  margin-bottom: 1.5rem;
}

.empty-state h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.empty-state p {
  color: var(--fg-muted);
  margin-bottom: 2rem;
}

.empty-inline {
  padding: 1.5rem 0;
  color: var(--fg-muted);
  font-size: 0.92rem;
}

.empty-inline a {
  color: var(--accent);
  text-decoration: none;
}

.empty-inline a:hover { text-decoration: underline; }

/* ===== UNIVERSE GRID ===== */
.universe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.universe-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 2rem;
  text-decoration: none;
  color: var(--fg);
  transition: all 0.25s ease;
  position: relative;
}

.universe-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-bright);
  transform: translateY(-2px);
}

.universe-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.universe-badge {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--gold);
  text-transform: uppercase;
}

.universe-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--fg-dim);
}

.universe-card-name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
  letter-spacing: -0.01em;
}

.universe-card-desc {
  font-size: 0.88rem;
  color: var(--fg-muted);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.universe-card-footer {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.universe-enter {
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 500;
}

/* ===== UNIVERSE HEADER ===== */
.universe-header {
  margin-bottom: 3rem;
}

.universe-header-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* ===== SECTIONS ===== */
.section {
  margin-bottom: 3.5rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.section-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.25em;
  color: var(--fg-dim);
  text-transform: uppercase;
}

/* ===== FACTION GRID ===== */
.faction-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.faction-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--faction-primary, var(--accent-dim));
  padding: 1.5rem;
  transition: all 0.2s;
}

.faction-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-bright);
  border-top-color: var(--faction-secondary, var(--accent));
}

.faction-card-top {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.faction-symbol {
  font-size: 1.8rem;
  color: var(--faction-primary, var(--accent));
  line-height: 1;
  flex-shrink: 0;
}

.faction-meta { flex: 1; }

.faction-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.faction-motto {
  font-size: 0.8rem;
  color: var(--fg-muted);
  font-style: italic;
}

.faction-desc {
  font-size: 0.85rem;
  color: var(--fg-muted);
  line-height: 1.6;
  margin-bottom: 1rem;
}

.faction-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.faction-count {
  font-size: 0.78rem;
  color: var(--fg-dim);
}

.faction-colors {
  display: flex;
  gap: 0.35rem;
}

.color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.1);
}

.faction-actions {
  flex-shrink: 0;
}

.icon-btn {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  color: var(--fg-dim);
  text-decoration: none;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  transition: all 0.2s;
}

.icon-btn:hover {
  color: var(--fg);
  border-color: var(--border-bright);
  background: var(--bg-card-hover);
}

/* ===== CHARACTER LIST ===== */
.character-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
}

.character-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  text-decoration: none;
  color: var(--fg);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.character-row:last-child { border-bottom: none; }

.character-row:hover { background: var(--bg-card); }

.character-row-symbol {
  font-size: 1.2rem;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}

.character-row-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.character-row-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.character-row-faction {
  font-size: 0.78rem;
  color: var(--fg-dim);
}

.character-row-allegiance {
  font-size: 0.78rem;
  color: var(--fg-muted);
  font-style: italic;
  padding: 0.2rem 0.65rem;
  border: 1px solid var(--border);
}

.character-row-arrow {
  color: var(--fg-dim);
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* ===== CHARACTER PROFILE ===== */
.character-profile {
  border: 1px solid var(--border);
  background: var(--bg-card);
  margin-bottom: 3rem;
  padding: 2.5rem;
}

.character-profile-header {
  margin-bottom: 2rem;
}

.character-profile-faction {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
  text-transform: uppercase;
}

.character-profile-symbol {
  font-size: 1.1rem;
}

.character-profile-motto {
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--fg-dim);
}

.character-profile-name {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin-bottom: 1rem;
}

.character-allegiance-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  border: 1px solid rgba(251, 191, 36, 0.3);
  padding: 0.3rem 0.8rem;
  margin-bottom: 1.5rem;
}

.character-profile-body {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.profile-block {}

.profile-block-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.25em;
  color: var(--fg-dim);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.profile-block-text {
  font-size: 0.95rem;
  color: var(--fg-muted);
  line-height: 1.7;
}

/* ===== DIALOGUE ENGINE ===== */
.dialogue-section {
  border: 1px solid var(--border);
  padding: 2.5rem;
  position: relative;
  overflow: hidden;
}

.dialogue-section::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -20%;
  width: 60%;
  height: 200%;
  background: radial-gradient(ellipse, rgba(124, 58, 237, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

.dialogue-header {
  margin-bottom: 2rem;
}

.dialogue-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.dialogue-sub {
  font-size: 0.9rem;
  color: var(--fg-muted);
  line-height: 1.6;
  max-width: 600px;
}

.dialogue-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.dialogue-prompt {
  min-height: 80px;
}

.dialogue-output {
  margin-top: 2rem;
  border-top: 1px solid var(--border);
  padding-top: 2rem;
}

.dialogue-output-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.dialogue-quote {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  font-weight: 600;
  line-height: 1.5;
  color: var(--fg);
  border-left: 3px solid var(--accent);
  padding-left: 1.5rem;
  font-style: normal;
}

/* ===== FORMS ===== */
.form-page {
  max-width: 640px;
}

.lore-form {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: 0.03em;
}

.required {
  color: var(--accent);
}

.form-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 0.75rem 1rem;
  font-family: var(--font-body);
  font-size: 0.92rem;
  transition: border-color 0.2s;
  outline: none;
  width: 100%;
}

.form-input:focus {
  border-color: var(--accent-dim);
}

.form-input::placeholder {
  color: var(--fg-dim);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}

.form-select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235a576b' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

.form-symbol {
  max-width: 120px;
  text-align: center;
  font-size: 1.3rem;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--fg-dim);
  line-height: 1.5;
}

.form-error {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--red);
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-top: 0.5rem;
  flex-wrap: wrap;
}

.inline-form {
  display: inline;
}

.color-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.form-color {
  width: 48px;
  height: 40px;
  padding: 0.2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
}

.color-preview-label {
  font-size: 0.8rem;
  color: var(--fg-muted);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .app-main {
    padding: 2rem 5%;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .universe-header-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .universe-grid {
    grid-template-columns: 1fr;
  }

  .faction-grid {
    grid-template-columns: 1fr;
  }

  .character-profile {
    padding: 1.5rem;
  }

  .dialogue-section {
    padding: 1.5rem;
  }
}
