/* ============================================
   Writer's Atelier — 写作者的书房
   A Dark Literary Writing Companion
   ============================================ */

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

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #2d1f1a;
  --bg-card: #1e1e32;
  --bg-card-hover: #252540;
  --text-primary: #f5e6d3;
  --text-secondary: #c4b5a0;
  --text-muted: #8a7a6a;
  --accent-gold: #d4a574;
  --accent-gold-dark: #b8895e;
  --accent-blue: #5b7fa4;
  --accent-orange: #e07c3c;
  --accent-red: #8b3a3a;
  --border-subtle: rgba(212, 165, 116, 0.12);
  --border-glow: rgba(212, 165, 116, 0.25);
  --shadow-card: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 40px rgba(212,165,116,0.06);
  --font-display: 'Playfair Display', 'Times New Roman', serif;
  --font-body: 'Cormorant Garamond', 'Georgia', serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;
  --section-pad: 100px 0;
  --container-max: 1200px;
  --gap: 24px;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  font-size: 18px;
  font-weight: 400;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* --- Ambient Particles --- */
.ambient-particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  opacity: 0.3;
}
.ambient-particles::before {
  content: '✎ ❦ ✦ † ❧ ✿ ❀ ✧ ✤ ❊';
  position: absolute;
  font-size: 14px;
  color: var(--accent-gold);
  letter-spacing: 80px;
  white-space: nowrap;
  animation: particleDrift 120s linear infinite;
  filter: blur(0.5px);
}
@keyframes particleDrift {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  5% { opacity: 0.3; }
  95% { opacity: 0.3; }
  100% { transform: translateY(-100vh) rotate(10deg); opacity: 0; }
}

/* --- Sidebar Navigation --- */
.sidebar-nav {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  height: 100vh;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.nav-toggle {
  position: absolute;
  top: 24px;
  left: 24px;
  z-index: 1001;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  background: rgba(15,15,26,0.8);
  backdrop-filter: blur(12px);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.3s ease;
}
.nav-toggle:hover {
  border-color: var(--accent-gold);
  background: rgba(30,30,50,0.9);
}
.nav-toggle-line {
  display: block;
  width: 18px;
  height: 1.5px;
  background: var(--text-primary);
  transition: all 0.3s ease;
  border-radius: 1px;
}
.nav-toggle.open .nav-toggle-line:nth-child(1) {
  transform: translateY(6.5px) rotate(45deg);
  width: 20px;
}
.nav-toggle.open .nav-toggle-line:nth-child(2) { opacity: 0; }
.nav-toggle.open .nav-toggle-line:nth-child(3) {
  transform: translateY(-6.5px) rotate(-45deg);
  width: 20px;
}

.nav-content {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100vh;
  background: rgba(15,15,26,0.97);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-subtle);
  padding: 80px 30px 30px;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.nav-content.open { transform: translateX(0); }

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 40px;
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--accent-gold);
}
.nav-brand-icon { font-size: 28px; }

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.nav-link {
  display: block;
  padding: 10px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 16px;
  font-family: var(--font-body);
  letter-spacing: 0.5px;
  border-radius: 6px;
  transition: all 0.25s ease;
  position: relative;
}
.nav-link::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background: var(--accent-gold);
  border-radius: 2px;
  transition: height 0.3s ease;
}
.nav-link:hover, .nav-link.active {
  color: var(--text-primary);
  background: rgba(212,165,116,0.06);
}
.nav-link.active::before { height: 60%; }

.nav-footer { 
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}
.nav-quote {
  font-size: 14px;
  font-style: italic;
  color: var(--text-muted);
}

/* --- Container --- */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

/* --- Hero Section --- */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 40px 24px;
}
.hero-bg-layer {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 40%, rgba(212,165,116,0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 60%, rgba(91,127,164,0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(224,124,60,0.02) 0%, transparent 40%);
  z-index: 0;
}
.hero-bg-layer::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(212,165,116,0.015) 2px,
    rgba(212,165,116,0.015) 4px
  );
}

.hero-content {
  text-align: center;
  position: relative;
  z-index: 1;
  max-width: 800px;
}

.hero-badge {
  display: inline-block;
  padding: 6px 20px;
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  font-size: 13px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent-gold);
  margin-bottom: 40px;
  font-family: var(--font-mono);
  backdrop-filter: blur(8px);
  background: rgba(212,165,116,0.04);
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(42px, 8vw, 80px);
  font-weight: 400;
  line-height: 1.15;
  margin-bottom: 24px;
}
.hero-title-line { display: block; }
.hero-title-line.accent {
  font-style: italic;
  color: var(--accent-gold);
  font-weight: 600;
}

.hero-typewriter {
  font-size: clamp(16px, 2vw, 22px);
  color: var(--text-secondary);
  margin-bottom: 50px;
  min-height: 1.8em;
  font-style: italic;
}
.typewriter-cursor {
  display: inline-block;
  color: var(--accent-gold);
  animation: blink 1s step-end infinite;
  font-weight: 300;
  margin-left: 2px;
}
@keyframes blink { 50% { opacity: 0; } }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 17px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  background: none;
  color: var(--text-primary);
}
.btn-primary {
  background: var(--accent-gold);
  color: var(--bg-primary);
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--accent-gold-dark);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(212,165,116,0.2);
}
.btn-ghost {
  border: 1px solid var(--border-subtle);
  background: rgba(255,255,255,0.02);
  backdrop-filter: blur(4px);
}
.btn-ghost:hover {
  border-color: var(--accent-gold);
  background: rgba(212,165,116,0.06);
}
.btn-icon { font-size: 18px; }

.hero-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 60px;
}

.hero-scroll-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-family: var(--font-mono);
  letter-spacing: 2px;
  animation: floatDown 2s ease-in-out infinite;
}
@keyframes floatDown {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50% { transform: translateY(8px); opacity: 1; }
}

/* --- Section Common --- */
.section {
  padding: var(--section-pad);
  position: relative;
}
.section-alt {
  background: var(--bg-secondary);
}
.section-bg-ornament {
  position: absolute;
  top: 0;
  right: 0;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle at top right, rgba(212,165,116,0.03) 0%, transparent 60%);
  pointer-events: none;
}

.section-header {
  text-align: center;
  margin-bottom: 60px;
}
.section-number {
  display: block;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent-gold);
  letter-spacing: 4px;
  margin-bottom: 12px;
}
.section-title {
  font-family: var(--font-display);
  font-size: clamp(32px, 4.5vw, 48px);
  font-weight: 400;
  color: var(--text-primary);
  margin-bottom: 12px;
}
.section-subtitle {
  font-size: 19px;
  font-style: italic;
  color: var(--text-muted);
}

/* --- Inspiration Section --- */
.inspiration-card {
  max-width: 700px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 48px 40px;
  text-align: center;
  box-shadow: var(--shadow-card);
  position: relative;
  transition: border-color 0.4s ease;
}
.inspiration-card:hover { border-color: var(--border-glow); }

.inspiration-icon {
  font-size: 36px;
  margin-bottom: 24px;
  color: var(--accent-gold);
}
.inspiration-text {
  font-size: 22px;
  line-height: 1.6;
  color: var(--text-primary);
  margin-bottom: 24px;
  font-style: italic;
  min-height: 4em;
  display: flex;
  align-items: center;
  justify-content: center;
}
.inspiration-tags {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 32px;
}
.tag {
  display: inline-block;
  padding: 4px 16px;
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  background: rgba(212,165,116,0.04);
}
.btn-inspire {
  margin: 0 auto;
}

/* --- Character Workshop --- */
.character-workshop {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: start;
}
@media (max-width: 860px) {
  .character-workshop { grid-template-columns: 1fr; }
}

.character-form {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 36px 32px;
}
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-family: var(--font-mono);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 17px;
  transition: all 0.25s ease;
  outline: none;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px rgba(212,165,116,0.08);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-btn { width: 100%; justify-content: center; margin-top: 8px; }

.character-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 36px;
  box-shadow: var(--shadow-card);
  position: sticky;
  top: 30px;
  transition: all 0.4s ease;
}
.char-card-header {
  display: flex;
  gap: 20px;
  align-items: center;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.char-card-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-orange));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--bg-primary);
  font-weight: 700;
  flex-shrink: 0;
}
.char-card-name {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 4px;
}
.char-card-meta { font-size: 15px; color: var(--text-muted); }
.char-card-section { margin-bottom: 20px; }
.char-card-label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent-gold);
  margin-bottom: 6px;
}
.char-card-traits { font-size: 16px; color: var(--text-secondary); }
.char-card-text { font-size: 16px; line-height: 1.6; color: var(--text-secondary); }
.char-card-arc {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 12px;
  background: rgba(212,165,116,0.08);
  color: var(--accent-gold);
  font-size: 14px;
  font-style: italic;
}
.char-card-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}
.char-card-quote {
  font-size: 15px;
  font-style: italic;
  color: var(--text-muted);
  text-align: center;
  display: block;
}

/* --- Plot Workshop --- */
.plot-structure-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 36px;
}
.plot-tab {
  padding: 10px 24px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.plot-tab:hover { border-color: var(--accent-gold); color: var(--text-primary); }
.plot-tab.active {
  background: var(--accent-gold);
  color: var(--bg-primary);
  border-color: var(--accent-gold);
  font-weight: 600;
}

.plot-display {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 40px;
  margin-bottom: 40px;
}
.plot-structure {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}
@media (max-width: 720px) {
  .plot-structure { grid-template-columns: 1fr; }
}
.plot-act {
  background: rgba(255,255,255,0.02);
  border-radius: 12px;
  padding: 28px 24px;
  border: 1px solid var(--border-subtle);
}
.plot-act-num {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-gold);
  letter-spacing: 2px;
  margin-bottom: 8px;
  text-transform: uppercase;
}
.plot-act-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 12px;
}
.plot-act-desc {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}
.plot-beats { list-style: none; padding: 0; }
.plot-beats li {
  position: relative;
  padding-left: 20px;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.plot-beats li::before {
  content: '·';
  position: absolute;
  left: 6px;
  color: var(--accent-gold);
}

.plot-conflict-gen { text-align: center; }
.conflict-title {
  font-family: var(--font-display);
  font-size: 20px;
  margin-bottom: 16px;
  color: var(--text-secondary);
}
.conflict-card {
  max-width: 600px;
  margin: 0 auto 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 24px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.conflict-card p {
  font-style: italic;
  font-size: 18px;
  color: var(--text-primary);
}

/* --- Worldbuilding --- */
.world-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}
@media (max-width: 680px) {
  .world-grid { grid-template-columns: 1fr; }
}
.world-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 32px 28px;
  transition: all 0.35s ease;
  cursor: default;
}
.world-card:hover {
  border-color: var(--border-glow);
  transform: translateY(-4px);
  box-shadow: var(--shadow-card);
}
.world-card-icon { font-size: 32px; margin-bottom: 16px; }
.world-card-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 12px;
}
.world-card-text {
  font-size: 16px;
  line-height: 1.65;
  color: var(--text-secondary);
}
.world-shuffle { display: block; margin: 32px auto 0; }

/* --- Refinery (文字炼金炉) --- */
.refinery-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 36px;
}
.refinery-tab {
  padding: 10px 28px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.refinery-tab:hover { border-color: var(--accent-gold); color: var(--text-primary); }
.refinery-tab.active {
  background: var(--accent-gold);
  color: var(--bg-primary);
  border-color: var(--accent-gold);
  font-weight: 600;
}
.refinery-panel { display: none; }
.refinery-panel.active { display: block; }

.refinery-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}
@media (max-width: 680px) {
  .refinery-compare { grid-template-columns: 1fr; }
}
.refinery-column {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 24px;
}
.refinery-label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 12px;
  padding: 3px 12px;
  border-radius: 4px;
}
.refinery-label.before {
  background: rgba(139,58,58,0.15);
  color: #c96a6a;
}
.refinery-label.after {
  background: rgba(212,165,116,0.12);
  color: var(--accent-gold);
}
.refinery-text {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-secondary);
  font-style: italic;
}

/* --- Guide Accordion --- */
.guide-accordion {
  max-width: 800px;
  margin: 0 auto;
}
.guide-card {
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
  transition: border-color 0.3s ease;
}
.guide-card:hover { border-color: var(--border-glow); }
.guide-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  background: var(--bg-card);
  border: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 18px;
  cursor: pointer;
  text-align: left;
  transition: background 0.25s ease;
}
.guide-trigger:hover { background: var(--bg-card-hover); }
.guide-num {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent-gold);
  min-width: 28px;
}
.guide-q { flex: 1; }
.guide-icon {
  font-size: 22px;
  color: var(--text-muted);
  transition: transform 0.3s ease;
  min-width: 24px;
  text-align: center;
}
.guide-card.open .guide-icon { transform: rotate(45deg); }

.guide-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, padding 0.4s ease;
}
.guide-card.open .guide-content {
  max-height: 500px;
}
.guide-body {
  padding: 0 24px 24px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-subtle);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-secondary);
}
.guide-body p { margin-bottom: 12px; }
.guide-body strong { color: var(--text-primary); }
.guide-example {
  padding: 10px 16px;
  margin: 8px 0;
  border-radius: 8px;
  background: rgba(255,255,255,0.02);
  font-size: 15px;
  font-style: italic;
}
.guide-example-label { 
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Footer --- */
.footer {
  padding: 60px 0;
  text-align: center;
  border-top: 1px solid var(--border-subtle);
}
.footer-content {
  max-width: 500px;
  margin: 0 auto;
}
.footer-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--accent-gold);
  margin-bottom: 20px;
}
.footer-icon { font-size: 24px; }
.footer-quote {
  font-style: italic;
  font-size: 16px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.footer-copy {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 2px;
}

/* --- Misc --- */
::selection {
  background: rgba(212,165,116,0.25);
  color: var(--text-primary);
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { 
  background: var(--border-subtle);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--accent-gold); }
