/* ===================================================
   XHale - Literary Dark Mode Stylesheet
   Branding: Slate Dark (#0D0F12) & Crimson Accent (#DD204D)
   =================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Lora:ital,wght@0,400;0,600;1,400&family=Outfit:wght@400;600;700;800&display=swap');

:root {
  --bg-main: #0d0f12;
  --bg-surface: #14171e;
  --bg-surface-elevated: #1b202a;
  --bg-glass: rgba(20, 23, 30, 0.75);
  
  --color-brand: #DD204D;
  --color-brand-hover: #f52959;
  --color-brand-glow: rgba(221, 32, 77, 0.25);
  
  --color-text-primary: #f0f3f8;
  --color-text-secondary: #9da6b8;
  --color-text-muted: #647087;
  
  --color-border: rgba(255, 255, 255, 0.08);
  --color-border-brand: rgba(221, 32, 77, 0.35);

  --badge-naturel: #3b82f6;
  --badge-suggestif: #8b5cf6;
  --badge-chaud: #DD204D;
  --badge-tabou: #f59e0b;
  --badge-libre: #10b981;

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

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-glow: 0 0 25px rgba(221, 32, 77, 0.18);
  --transition-fast: all 0.2s ease;
  --transition-normal: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-main);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(221, 32, 77, 0.05) 0%, transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(59, 130, 246, 0.03) 0%, transparent 45%);
  background-attachment: fixed;
}

a {
  color: inherit;
  text-decoration: none;
  transition: var(--transition-fast);
}

/* Typography */
h1, h2, h3, h4, h5 {
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
}

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

/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 2rem;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-logo {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-logo .dot {
  color: var(--color-brand);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  list-style: none;
}

.nav-link {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius-sm);
}

.nav-link:hover, .nav-link.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.4rem;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-normal);
}

.btn-primary {
  background: var(--color-brand);
  color: #fff;
  box-shadow: 0 4px 15px var(--color-brand-glow);
}

.btn-primary:hover {
  background: var(--color-brand-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(221, 32, 77, 0.4);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--color-text-primary);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-outline-brand {
  background: transparent;
  color: var(--color-brand);
  border-color: var(--color-border-brand);
}

.btn-outline-brand:hover {
  background: var(--color-brand-glow);
  color: #fff;
}

/* Main Container */
.main-wrapper {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

/* Cards & Surfaces */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  transition: var(--transition-normal);
}

.card-hover:hover {
  border-color: var(--color-border-brand);
  transform: translateY(-4px);
  box-shadow: var(--shadow-glow);
}

/* Hero Section */
.hero-section {
  text-align: center;
  padding: 4rem 1rem 3rem;
  max-width: 800px;
  margin: 0 auto;
}

.hero-title {
  font-size: 3.2rem;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 1.2rem;
}

.hero-subtitle {
  font-size: 1.2rem;
  color: var(--color-text-secondary);
  margin-bottom: 2rem;
}

/* Story Catalog Grid */
.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.8rem;
  margin-top: 2rem;
}

.story-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.story-card-body {
  padding: 1.8rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.story-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.3rem 0.7rem;
  border-radius: 50px;
  background: var(--color-brand-glow);
  color: var(--color-brand);
  border: 1px solid var(--color-border-brand);
  margin-bottom: 1rem;
}

.story-title {
  font-size: 1.4rem;
  margin-bottom: 0.8rem;
}

.story-synopsis {
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin-bottom: 1.5rem;
  flex: 1;
}

.story-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* Story Reader Page */
.reader-container {
  max-width: 820px;
  margin: 0 auto;
}

.reader-header {
  text-align: center;
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--color-border);
}

.reader-title {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

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

.chapter-card {
  background: var(--bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem;
  margin-bottom: 2.5rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.chapter-title {
  font-size: 1.8rem;
  color: var(--color-brand);
  margin-bottom: 2rem;
  text-align: center;
  font-weight: 700;
}

.chapter-body {
  font-family: var(--font-reader);
  font-size: 1.15rem;
  line-height: 1.95;
  color: #e2e8f0;
  white-space: pre-line;
}

.chapter-body p {
  margin-bottom: 1.6rem;
}

/* Choices Section */
.choices-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px dashed var(--color-border);
}

.choices-heading {
  font-size: 1.2rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.choices-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.choice-option {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.2rem 1.5rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-normal);
  text-align: left;
  width: 100%;
}

.choice-option:hover {
  border-color: var(--color-border-brand);
  background: rgba(221, 32, 77, 0.08);
  transform: translateX(4px);
}

.choice-tag {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  width: fit-content;
}

.choice-tag.naturel   { background: rgba(59, 130, 246, 0.15); color: var(--badge-naturel); }
.choice-tag.suggestif { background: rgba(139, 92, 246, 0.15); color: var(--badge-suggestif); }
.choice-tag.chaud     { background: rgba(221, 32, 77, 0.15); color: var(--badge-chaud); }
.choice-tag.tabou     { background: rgba(245, 158, 11, 0.15); color: var(--badge-tabou); }
.choice-tag.libre     { background: rgba(16, 185, 129, 0.15); color: var(--badge-libre); }

.choice-text {
  font-size: 1rem;
  color: var(--color-text-primary);
  line-height: 1.5;
}

.libre-input-group {
  display: flex;
  gap: 0.8rem;
  margin-top: 0.8rem;
}

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

.form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 0.5rem;
}

.form-control {
  width: 100%;
  padding: 0.85rem 1.1rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px var(--color-brand-glow);
}

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

/* Alerts */
.alert {
  padding: 1rem 1.2rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.alert-danger {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.alert-success {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

/* Loading Overlay for AI Generation */
.loading-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: var(--color-brand);
  animation: spin 0.8s linear infinite;
}

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

/* Footer */
.footer {
  margin-top: auto;
  border-top: 1px solid var(--color-border);
  padding: 2rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

/* Responsive */
@media (max-width: 768px) {
  .nav-container { flex-direction: column; gap: 1rem; }
  .hero-title { font-size: 2.2rem; }
  .chapter-card { padding: 1.8rem 1.2rem; }
  .chapter-body { font-size: 1.05rem; }
}
