/* ============================================
   AEON TRESPASS: ODYSSEY - Thread of Fate
   Interactive Story Website Styles
   ============================================ */

/* --- Fonts loaded via Google Fonts CDN (see HTML <link>) ---
   Cinzel: Latin heading font (~70KB)
   Noto Serif SC: CJK body font (auto-subsetted by Google) */

/* --- CSS Variables --- */
:root {
  --bg-primary: #0B0B0F;
  --bg-secondary: #111116;
  --bg-card: #16161C;
  --bg-card-hover: #1C1C24;
  --text-body: #D4C4A0;
  --text-dim: #9A8E76;
  --text-muted: #6B6252;
  --gold-primary: #B8965A;
  --gold-bright: #D4AD6A;
  --gold-dim: #8A6F3E;
  --gold-glow: rgba(184, 150, 90, 0.3);
  --gold-glow-strong: rgba(184, 150, 90, 0.5);
  --border-gold: rgba(184, 150, 90, 0.3);
  --border-subtle: rgba(184, 150, 90, 0.1);
  --font-body: 'Noto Serif SC', serif;
  --font-heading: 'Cinzel', serif;
  --max-reading-width: 700px;
  --sidebar-width: 280px;
  --transition-fast: 0.2s ease;
  --transition-medium: 0.4s ease;
  --transition-slow: 0.6s ease;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-body);
  line-height: 1.9;
  font-size: 16px;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a:hover {
  color: var(--gold-bright);
}

/* --- Greek Meander Border Pattern --- */
.meander-border-top,
.meander-border-bottom {
  position: fixed;
  left: 0;
  right: 0;
  height: 20px;
  z-index: 1000;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.meander-border-top {
  top: 0;
  border-bottom: 1px solid var(--border-gold);
}

.meander-border-bottom {
  bottom: 0;
  border-top: 1px solid var(--border-gold);
}

.meander-pattern {
  width: 100%;
  height: 12px;
  opacity: 0.4;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='12' viewBox='0 0 40 12'%3E%3Cpath d='M0 6h4v-4h4v4h4v-4h4v4h4v-4h4v4h4v-4h4v4h4v-4h4v4' fill='none' stroke='%23B8965A' stroke-width='1'/%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-position: center;
}

/* --- Landing Page --- */
.landing-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 60px 20px;
  text-align: center;
  position: relative;
}

.landing-page::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(ellipse at center, rgba(184, 150, 90, 0.03) 0%, transparent 70%);
  pointer-events: none;
}

.landing-title {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  color: var(--gold-primary);
  letter-spacing: 0.15em;
  margin-bottom: 0.5rem;
  text-shadow: 0 0 40px rgba(184, 150, 90, 0.2);
  animation: fadeInDown 1s ease forwards;
}

.landing-subtitle {
  font-size: 1.1rem;
  color: var(--text-dim);
  margin-bottom: 3rem;
  letter-spacing: 0.3em;
  animation: fadeInUp 1s ease 0.3s forwards;
  opacity: 0;
}

/* --- Cycle Cards --- */
.cycle-cards {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 3rem;
  animation: fadeIn 1s ease 0.6s forwards;
  opacity: 0;
}

.cycle-card {
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: 4px;
  padding: 2rem 1.8rem;
  width: 260px;
  cursor: pointer;
  transition: all var(--transition-medium);
  position: relative;
  overflow: hidden;
}

.cycle-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-primary), transparent);
  opacity: 0;
  transition: opacity var(--transition-medium);
}

.cycle-card:hover {
  border-color: var(--gold-primary);
  background: var(--bg-card-hover);
  transform: translateY(-4px);
  box-shadow: 0 8px 32px rgba(184, 150, 90, 0.1);
}

.cycle-card:hover::before {
  opacity: 1;
}

.cycle-card-number {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  color: var(--gold-dim);
  letter-spacing: 0.2em;
  margin-bottom: 0.8rem;
}

.cycle-card-title {
  font-size: 1.2rem;
  color: var(--text-body);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.cycle-card-subtitle {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-style: italic;
}

/* --- Memory Palace Button --- */
.palace-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 2rem;
  border: 1px solid var(--border-gold);
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition-medium);
  border-radius: 2px;
  animation: fadeIn 1s ease 0.9s forwards;
  opacity: 0;
}

.palace-btn:hover {
  border-color: var(--gold-primary);
  color: var(--gold-primary);
  box-shadow: 0 0 20px rgba(184, 150, 90, 0.1);
}

/* --- Reader Page Layout --- */
.reader-layout {
  display: flex;
  min-height: 100vh;
  padding-top: 20px;
  padding-bottom: 20px;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  position: fixed;
  top: 20px;
  bottom: 20px;
  left: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform var(--transition-medium);
  padding-top: 1rem;
}

.sidebar-header {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-title {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  color: var(--gold-primary);
  letter-spacing: 0.15em;
  margin-bottom: 0.3rem;
}

.sidebar-cycle-name {
  font-size: 0.9rem;
  color: var(--text-dim);
}

.sidebar-list {
  list-style: none;
  padding: 0.5rem 0;
}

.sidebar-item {
  padding: 0.6rem 1.2rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  border-left: 2px solid transparent;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.sidebar-item:hover {
  color: var(--text-body);
  background: rgba(184, 150, 90, 0.05);
}

.sidebar-item.active {
  color: var(--gold-primary);
  border-left-color: var(--gold-primary);
  background: rgba(184, 150, 90, 0.05);
}

.sidebar-item-number {
  font-size: 0.7rem;
  color: var(--gold-dim);
  min-width: 2em;
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 30px;
  left: 10px;
  z-index: 200;
  width: 36px;
  height: 36px;
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: 4px;
  color: var(--gold-primary);
  font-size: 1.2rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
  background: var(--bg-card-hover);
}

/* --- Main Content Area --- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  justify-content: center;
  padding: 2rem;
}

.reading-area {
  max-width: var(--max-reading-width);
  width: 100%;
  padding: 2rem 0;
}

/* --- Paragraph Header --- */
.para-header {
  text-align: center;
  margin-bottom: 2rem;
}

.para-cycle-title {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  color: var(--gold-dim);
  letter-spacing: 0.2em;
  margin-bottom: 0.3rem;
}

.para-number {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

.para-title {
  font-size: 1.4rem;
  color: var(--gold-primary);
  font-weight: 600;
}

/* --- Gold Separator --- */
.gold-separator {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-primary), transparent);
  margin: 1.5rem 0 2rem;
  opacity: 0.5;
}

/* --- Story Text --- */
.story-text {
  font-size: 1.05rem;
  line-height: 2;
  color: var(--text-body);
  text-align: justify;
  margin-bottom: 3rem;
}

.story-text p {
  margin-bottom: 1.2rem;
  text-indent: 2em;
}

/* --- Continue Button --- */
.continue-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 2rem auto;
  padding: 0.9rem 2.5rem;
  background: transparent;
  border: 1px solid var(--border-gold);
  color: var(--gold-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition-medium);
  border-radius: 2px;
}

.continue-btn:hover {
  border-color: var(--gold-bright);
  background: rgba(184, 150, 90, 0.08);
  box-shadow: 0 0 24px rgba(184, 150, 90, 0.1);
  transform: translateX(4px);
}

.continue-btn .arrow {
  transition: transform var(--transition-fast);
}

.continue-btn:hover .arrow {
  transform: translateX(4px);
}

/* --- Thread of Fate (Branching Choices) --- */
.thread-of-fate {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 2rem;
  margin-top: 1rem;
}

.fate-line-start {
  width: 1px;
  height: 40px;
  background: linear-gradient(to bottom, transparent, var(--gold-primary));
}

.fate-node {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold-primary);
  box-shadow: 0 0 10px var(--gold-glow);
  margin: 4px 0;
}

.fate-branches {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: 0;
}

.fate-branch-lines {
  position: relative;
  width: 80%;
  height: 40px;
}

.fate-branch-lines svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.fate-branch-line {
  stroke: var(--gold-primary);
  stroke-width: 1;
  fill: none;
  opacity: 0.6;
}

.fate-choices {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  padding: 0.5rem 0;
}

.fate-choice-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: 4px;
  padding: 1.2rem 1.5rem;
  cursor: pointer;
  transition: all var(--transition-medium);
  overflow: hidden;
}

.fate-choice-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--gold-primary);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.fate-choice-card:hover {
  border-color: var(--gold-primary);
  background: var(--bg-card-hover);
  box-shadow: 0 4px 24px rgba(184, 150, 90, 0.12), inset 0 0 30px rgba(184, 150, 90, 0.03);
  transform: translateX(4px);
}

.fate-choice-card:hover::before {
  opacity: 1;
}

.fate-choice-no-target {
  cursor: default;
  opacity: 0.8;
  border-style: dashed;
}

.fate-choice-no-target:hover {
  transform: none;
  box-shadow: none;
  background: var(--bg-card);
  border-color: var(--border-gold);
}

.fate-choice-no-target::before {
  display: none;
}

.fate-choice-label {
  font-size: 1rem;
  color: var(--text-body);
  margin-bottom: 0.3rem;
  font-weight: 500;
}

.fate-choice-desc {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-style: italic;
}

/* --- Fade Transitions --- */
.fade-container {
  opacity: 1;
  transition: opacity var(--transition-medium);
}

.fade-container.fading-out {
  opacity: 0;
}

.fade-container.fading-in {
  opacity: 0;
  animation: fadeIn var(--transition-medium) forwards;
}

/* --- Memory Palace Page --- */
.palace-page {
  min-height: 100vh;
  padding: 60px 20px 40px;
}

.palace-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.palace-title {
  font-family: var(--font-heading);
  font-size: clamp(1.4rem, 3vw, 2rem);
  color: var(--gold-primary);
  letter-spacing: 0.1em;
  margin-bottom: 0.3rem;
}

.palace-subtitle {
  font-size: 0.9rem;
  color: var(--text-dim);
}

.palace-back {
  position: fixed;
  top: 30px;
  left: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: color var(--transition-fast);
  z-index: 100;
}

.palace-back:hover {
  color: var(--gold-primary);
}

/* --- Tabs --- */
.tabs {
  display: flex;
  justify-content: center;
  gap: 0;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border-subtle);
}

.tab-btn {
  padding: 0.8rem 1.5rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

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

/* --- Search --- */
.search-container {
  max-width: 500px;
  margin: 0 auto 2rem;
}

.search-input {
  width: 100%;
  padding: 0.7rem 1.2rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  color: var(--text-body);
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: border-color var(--transition-fast);
  outline: none;
}

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

.search-input:focus {
  border-color: var(--gold-primary);
}

/* --- Glossary Grid --- */
.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.2rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
}

.glossary-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 1.3rem 1.5rem;
  transition: all var(--transition-fast);
}

.glossary-card:hover {
  border-color: var(--border-gold);
}

.glossary-card-name {
  font-size: 1.05rem;
  color: var(--gold-primary);
  margin-bottom: 0.2rem;
  font-weight: 600;
}

.glossary-card-name-en {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-style: italic;
}

.glossary-card-badges {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.7rem;
}

.cycle-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.5rem;
  background: rgba(184, 150, 90, 0.1);
  border: 1px solid var(--border-gold);
  border-radius: 2px;
  color: var(--gold-dim);
  font-family: var(--font-heading);
  letter-spacing: 0.05em;
}

.glossary-card-desc {
  font-size: 0.88rem;
  color: var(--text-dim);
  line-height: 1.7;
}

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

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

::-webkit-scrollbar-thumb {
  background: var(--gold-dim);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gold-primary);
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 8px var(--gold-glow); }
  50% { box-shadow: 0 0 16px var(--gold-glow-strong); }
}

.fate-node {
  animation: pulse 2s ease-in-out infinite;
}

/* --- Responsive Design --- */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: flex;
  }

  .main-content {
    margin-left: 0;
  }

  .cycle-cards {
    flex-direction: column;
    align-items: center;
  }

  .cycle-card {
    width: 100%;
    max-width: 320px;
  }

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

  .tabs {
    flex-wrap: wrap;
  }

  .tab-btn {
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 600px) {
  .reading-area {
    padding: 1rem 0;
  }

  .main-content {
    padding: 1rem;
  }

  .story-text {
    font-size: 0.95rem;
  }

  .para-title {
    font-size: 1.2rem;
  }

  .fate-choices {
    padding: 0;
  }

  .fate-choice-card {
    padding: 1rem;
  }
}

/* --- Loading State --- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.loading::after {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 1px solid var(--gold-dim);
  border-top-color: var(--gold-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 0.5rem;
}

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

/* --- No Results --- */
.no-results {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
