/* ===================================================
   AlterToon — Global Design System
   Dark theme, glassmorphism, neon indigo/violet
   =================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&family=Inter:wght@300;400;500;600&display=swap');
@import url('utils.css');

/* ── Variables ───────────────────────────────────── */
:root {
  --bg-base: #080810;
  --bg-surface: #0e0e1a;
  --bg-elevated: #141428;
  --bg-card: rgba(20, 20, 40, 0.7);

  --accent-primary: #6C63FF;
  --accent-glow: rgba(108, 99, 255, 0.35);
  --accent-cyan: #00D4FF;
  --accent-pink: #FF6CDE;
  --accent-gold: #FFD166;

  --text-primary: #F0F0FF;
  --text-secondary: #9090BB;
  --text-muted: #5050AA;

  --border-subtle: rgba(108, 99, 255, 0.15);
  --border-medium: rgba(108, 99, 255, 0.3);
  --border-strong: rgba(108, 99, 255, 0.6);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-xl: 32px;

  --shadow-glow: 0 0 30px rgba(108, 99, 255, 0.25);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.06);

  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;

  --nav-height: 68px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Typography ──────────────────────────────────── */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: var(--transition);
}

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

p {
  color: var(--text-secondary);
}

/* ── Background noise texture ────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(ellipse 80% 60% at 20% -10%, rgba(108, 99, 255, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 90% 110%, rgba(0, 212, 255, 0.07) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── Navigation ──────────────────────────────────── */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  z-index: 1000;
  display: flex;
  align-items: center;
  padding: 0 2rem;
  gap: 1.5rem;
  background: rgba(8, 8, 16, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
  text-decoration: none;
}

.navbar-brand .logo-icon {
  width: 32px;
  height: 32px;
}

.navbar-brand span {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Mobile portrait: hide "AlterToon" text to save space */
@media (max-width: 480px) {
  .navbar-brand span { display: none; }
  .navbar { padding: 0 0.75rem; gap: 0.5rem; }
  .nav-link { padding: 0.35rem 0.5rem; font-size: 0.82rem; }
  .credits-badge { padding: 0.25rem 0.5rem; font-size: 0.8rem; }
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
}

.nav-link {
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
}

.nav-link:hover {
  color: var(--text-primary);
  background: rgba(108, 99, 255, 0.12);
}

.nav-link.active {
  color: var(--accent-primary);
  background: rgba(108, 99, 255, 0.15);
}

.credits-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.8rem;
  background: rgba(255, 209, 102, 0.12);
  border: 1px solid rgba(255, 209, 102, 0.25);
  border-radius: 99px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-gold);
  cursor: default;
}

/* ── Main Content Wrapper ────────────────────────── */
.main-content {
  padding-top: var(--nav-height);
  position: relative;
  z-index: 1;
}

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  outline: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), #8B7FFF);
  color: #fff;
  box-shadow: 0 4px 20px rgba(108, 99, 255, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(108, 99, 255, 0.55);
  color: #fff;
}

.btn-secondary {
  background: rgba(108, 99, 255, 0.12);
  border: 1px solid var(--border-medium);
  color: var(--accent-primary);
}

.btn-secondary:hover {
  background: rgba(108, 99, 255, 0.22);
  border-color: var(--border-strong);
  color: var(--accent-primary);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.btn-ghost:hover {
  border-color: var(--border-medium);
  color: var(--text-primary);
}

.btn-danger {
  background: rgba(255, 60, 60, 0.15);
  border: 1px solid rgba(255, 60, 60, 0.3);
  color: #FF6B6B;
}

.btn-danger:hover {
  background: rgba(255, 60, 60, 0.25);
}

.btn-lg {
  padding: 0.85rem 2rem;
  font-size: 1.05rem;
  border-radius: var(--radius-lg);
}

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

.btn-icon {
  padding: 0.65rem;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

/* ── Cards ───────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card), var(--shadow-inset);
  transition: var(--transition);
}

.card:hover {
  border-color: var(--border-medium);
  box-shadow: var(--shadow-card), var(--shadow-glow);
  transform: translateY(-2px);
}

.card-body {
  padding: 1.5rem;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

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

/* ── Forms ───────────────────────────────────────── */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-control {
  width: 100%;
  padding: 0.7rem 1rem;
  background: rgba(14, 14, 26, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.2);
}

.form-control::placeholder {
  color: var(--text-muted);
}

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

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236C63FF' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

/* ── Grid ────────────────────────────────────────── */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.container-sm {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {

  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ── Badges ──────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.badge-primary {
  background: rgba(108, 99, 255, 0.2);
  color: var(--accent-primary);
  border: 1px solid rgba(108, 99, 255, 0.3);
}

.badge-cyan {
  background: rgba(0, 212, 255, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 212, 255, 0.25);
}

.badge-gold {
  background: rgba(255, 209, 102, 0.15);
  color: var(--accent-gold);
  border: 1px solid rgba(255, 209, 102, 0.25);
}

.badge-pink {
  background: rgba(255, 108, 222, 0.15);
  color: var(--accent-pink);
}

.badge-moderated {
  background: rgba(255, 100, 100, 0.2);
  color: #FF8080;
  border: 1px solid rgba(255, 100, 100, 0.35);
}

/* ── Comic Card ──────────────────────────────────── */
.comic-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.comic-card:hover {
  border-color: var(--border-medium);
  transform: translateY(-4px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), var(--shadow-glow);
}

.comic-cover {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  display: block;
}

.comic-cover-placeholder {
  width: 100%;
  aspect-ratio: 3/4;
  background: linear-gradient(135deg, var(--bg-elevated), var(--bg-surface));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 2.5rem;
}

.comic-info {
  padding: 1rem;
}

.comic-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.comic-cta {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-primary);
  margin-top: 0.5rem;
}

.comic-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Alert / Toast ───────────────────────────────── */
.alert {
  padding: 0.85rem 1.2rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  border: 1px solid;
}

.alert-error {
  background: rgba(255, 60, 60, 0.12);
  border-color: rgba(255, 60, 60, 0.3);
  color: #FF8080;
}

.alert-success {
  background: rgba(0, 240, 130, 0.1);
  border-color: rgba(0, 240, 130, 0.25);
  color: #50EFA0;
}

.alert-info {
  background: rgba(0, 212, 255, 0.1);
  border-color: rgba(0, 212, 255, 0.25);
  color: var(--accent-cyan);
}

/* ── Loading Spinner ─────────────────────────────── */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(108, 99, 255, 0.2);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Utility ─────────────────────────────────────── */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-1 {
  gap: 0.5rem;
}

.gap-2 {
  gap: 1rem;
}

.gap-3 {
  gap: 1.5rem;
}

.gap-4 {
  gap: 2rem;
}

.text-center {
  text-align: center;
}

.text-sm {
  font-size: 0.85rem;
}

.text-xs {
  font-size: 0.75rem;
}

.text-lg {
  font-size: 1.1rem;
}

.text-xl {
  font-size: 1.5rem;
}

.text-2xl {
  font-size: 2rem;
}

.font-bold {
  font-weight: 700;
}

.font-heading {
  font-family: var(--font-heading);
}

.text-muted {
  color: var(--text-muted);
}

.text-accent {
  color: var(--accent-primary);
}

.text-cyan {
  color: var(--accent-cyan);
}

.text-gold {
  color: var(--accent-gold);
}

.w-full {
  width: 100%;
}

.mt-1 {
  margin-top: 0.5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.mt-3 {
  margin-top: 1.5rem;
}

.mt-4 {
  margin-top: 2rem;
}

.mb-1 {
  margin-bottom: 0.5rem;
}

.mb-2 {
  margin-bottom: 1rem;
}

.mb-3 {
  margin-bottom: 1.5rem;
}

.mb-4 {
  margin-bottom: 2rem;
}

.hidden {
  display: none;
}

/* ── Divider ─────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 1.5rem 0;
}

/* ── Section ─────────────────────────────────────── */
section {
  padding: 5rem 0;
}

/* ── Gradient text ───────────────────────────────── */
.gradient-text {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gradient-text-pink {
  background: linear-gradient(135deg, var(--accent-pink) 0%, var(--accent-primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Scrollbar ───────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
  background: var(--accent-primary);
  border-radius: 99px;
}

/* ── Section titles ──────────────────────────────── */
.section-title {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 800;
  margin-bottom: 0.75rem;
}

.section-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 560px;
}

/* ── Webtoon Reader ──────────────────────────────── */
.reader-container {
  max-width: 480px;
  margin: 0 auto;
  padding: 0;
}

.panel-image {
  width: 100%;
  display: block;
  border-radius: 0;
}

.panel-image:first-child {
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.panel-separator {
  height: 4px;
  background: var(--bg-base);
}

/* ── Decision Card ───────────────────────────────── */
.decision-card {
  position: sticky;
  bottom: 0;
  background: rgba(8, 8, 16, 0.96);
  backdrop-filter: blur(24px);
  border-top: 1px solid var(--border-medium);
  padding: 1.5rem;
  z-index: 50;
  animation: slideUp 0.4s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.decision-prompt {
  text-align: center;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: var(--text-secondary);
}

.decision-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.decision-btn {
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid;
  cursor: pointer;
  text-align: center;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.3;
  transition: var(--transition);
  background: transparent;
}

.decision-btn.left {
  border-color: rgba(108, 99, 255, 0.4);
  color: var(--accent-primary);
}

.decision-btn.left:hover,
.decision-btn.left.chosen {
  background: rgba(108, 99, 255, 0.2);
  border-color: var(--accent-primary);
  box-shadow: 0 0 20px rgba(108, 99, 255, 0.3);
  transform: scale(1.02);
}

.decision-btn.right {
  border-color: rgba(0, 212, 255, 0.4);
  color: var(--accent-cyan);
}

.decision-btn.right:hover,
.decision-btn.right.chosen {
  background: rgba(0, 212, 255, 0.15);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.25);
  transform: scale(1.02);
}

.decision-arrow {
  font-size: 1.4rem;
  margin-bottom: 0.25rem;
}

.decision-pct {
  font-size: 0.8rem;
  opacity: 0.7;
  font-weight: 400;
  display: block;
  margin-top: 0.25rem;
}

/* ── Branch Tree (Creator) ───────────────────────── */
.branch-tree {
  overflow-x: auto;
  padding: 1rem 0;
}

/* ── Stats bar ───────────────────────────────────── */
.stat-bar {
  height: 6px;
  border-radius: 99px;
  background: var(--bg-elevated);
  overflow: hidden;
  margin-top: 0.4rem;
}

.stat-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-cyan));
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Tabs ────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1.5rem;
}

.tab-btn {
  padding: 0.6rem 1.2rem;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: -1px;
}

.tab-btn.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.tab-btn:hover {
  color: var(--text-primary);
}

/* ── Modal ───────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.6);
  animation: scaleIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
  from {
    transform: scale(0.92);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-header {
  padding: 1.5rem 1.5rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
}

.modal-body {
  padding: 0 1.5rem 1.5rem;
}

/* ── Glow Orbs (decorative) ──────────────────────── */
.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}