/* ===== FONTS ===== */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;1,300;1,400&family=Cormorant+SC:wght@300;400&family=EB+Garamond:ital,wght@0,400;0,500;1,400&display=swap');

/* ===== VARIABLES ===== */
:root {
  --bg-dark: #1a1a18;
  --bg-panel: rgba(30, 29, 26, 0.72);
  --bg-panel-hover: rgba(38, 37, 33, 0.85);
  --border-color: rgba(210, 190, 140, 0.18);
  --border-glow: rgba(210, 190, 140, 0.35);
  --gold: #c8a96e;
  --gold-dim: #8a7048;
  --gold-bright: #e2c98a;
  --text-main: #d8cdb8;
  --text-dim: #8a8070;
  --text-poem: #ccc3b0;
  --accent-visited: #6a8060;
  --accent-active: #c8a96e;
  --light-x: 0px;
  --light-y: 0px;
  --font-display: 'Cormorant SC', serif;
  --font-body: 'Cormorant Garamond', serif;
  --font-poem: 'EB Garamond', serif;
  --radius: 12px;
  --sidebar-w: 260px;
  --transition: 0.25s ease;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  min-height: 100vh;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.7;
  overflow-x: hidden;
  position: relative;
}

/* ===== LIGHT SOURCE (top-left warm glow) ===== */
.light-source {
  pointer-events: none;
  position: fixed;
  top: -120px;
  left: -120px;
  width: 700px;
  height: 700px;
  border-radius: 50%;
  background: radial-gradient(
    ellipse at center,
    rgba(200, 160, 80, 0.13) 0%,
    rgba(180, 130, 50, 0.07) 35%,
    transparent 70%
  );
  z-index: 0;
}

/* Background texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  opacity: 0.5;
  z-index: 0;
  pointer-events: none;
}

/* ===== HEADER ===== */
.site-header {
  position: relative;
  z-index: 10;
  padding: 1.4rem 2.5rem 0;
  text-align: right;
}

.header-inner {
  display: inline-block;
}

.author-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 300;
  letter-spacing: 0.12em;
  color: var(--text-main);
  text-transform: uppercase;
}

.header-divider {
  margin: 0.4rem 0 0 auto;
  width: 60%;
  height: 1px;
  background: linear-gradient(to left, transparent, var(--gold-dim));
}

/* ===== MAIN LAYOUT ===== */
.layout {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 1.5rem;
  padding: 1.2rem 2rem 1.5rem;
  min-height: calc(100vh - 120px);
  align-items: start;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: sticky;
  top: 1.2rem;
  height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  /* Gradient border effect from top-left light */
  box-shadow:
    -1px -1px 0 rgba(200, 169, 110, 0.22),
    inset 0 0 40px rgba(0,0,0,0.15);
}

.sidebar-header {
  padding: 1.2rem 1.2rem 0.6rem;
  flex-shrink: 0;
}

.sidebar-title {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 300;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.sidebar-divider {
  margin-top: 0.5rem;
  height: 1px;
  background: linear-gradient(to right, var(--gold-dim), transparent);
  opacity: 0.5;
}

/* ===== POEM LIST ===== */
.poem-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0 1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dim) transparent;
}

.poem-list::-webkit-scrollbar { width: 4px; }
.poem-list::-webkit-scrollbar-track { background: transparent; }
.poem-list::-webkit-scrollbar-thumb {
  background: var(--gold-dim);
  border-radius: 4px;
  opacity: 0.5;
}

.poem-list-loading {
  padding: 1rem 1.2rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.poem-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.38rem 1.2rem;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.93rem;
  font-weight: 400;
  color: var(--text-main);
  transition: color var(--transition), background var(--transition);
  border-left: 2px solid transparent;
  line-height: 1.4;
  user-select: none;
}

.poem-item:hover {
  color: var(--gold-bright);
  background: rgba(200, 169, 110, 0.06);
}

.poem-item.active {
  color: var(--gold);
  border-left-color: var(--gold);
  background: rgba(200, 169, 110, 0.08);
}

.poem-item.visited {
  color: var(--accent-visited);
}

.poem-item.visited.active {
  color: var(--gold);
}

.poem-bullet {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition);
}

.poem-item.active .poem-bullet {
  opacity: 1;
}

/* ===== CONTENT PANEL ===== */
.content-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  min-height: calc(100vh - 140px);
  padding: 2.5rem 3.5rem;
  overflow-y: auto;
  box-shadow:
    -1px -1px 0 rgba(200, 169, 110, 0.18),
    inset 0 0 60px rgba(0,0,0,0.12);
}

/* ===== POEM DISPLAY ===== */
.poem-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: var(--text-dim);
  font-size: 0.95rem;
  font-style: italic;
}

.poem-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--gold);
  text-align: center;
  margin-bottom: 0.4rem;
}

.poem-title-divider {
  display: flex;
  justify-content: center;
  margin: 0.6rem 0 2rem;
}

.poem-title-divider::after {
  content: '•';
  color: var(--gold-dim);
  font-size: 0.7rem;
}

.poem-body {
  font-family: var(--font-poem);
  font-size: 1.13rem;
  line-height: 1.95;
  color: var(--text-poem);
  white-space: pre-wrap;
  max-width: 62ch;
  margin: 0 auto;
}

.poem-body p {
  margin-bottom: 1.4em;
}

.poem-loading {
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.9rem;
  text-align: center;
  padding: 2rem 0;
}

/* ===== FOOTER ===== */
.site-footer {
  position: relative;
  z-index: 5;
  text-align: center;
  padding: 0.8rem 2rem 1.2rem;
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 0.06em;
}

/* ===== BACK BUTTON (mobile) ===== */
.back-btn {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 100;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--gold);
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  transition: background var(--transition);
}

.back-btn:hover {
  background: var(--bg-panel-hover);
}

/* ===== MOBILE ===== */
@media (max-width: 768px) {
  .layout {
    display: block;
    padding: 0.8rem 0.8rem 1rem;
    position: relative;
  }

  .sidebar {
    position: fixed;
    inset: 0;
    height: 100dvh;
    border-radius: 0;
    border: none;
    z-index: 50;
    display: flex;
    transition: transform 0.3s ease;
  }

  .sidebar.hidden-mobile {
    transform: translateX(-100%);
  }

  .content-panel {
    position: fixed;
    inset: 0;
    min-height: 100dvh;
    border-radius: 0;
    border: none;
    padding: 4rem 1.4rem 2rem;
    display: none;
    z-index: 40;
  }

  .content-panel.visible-mobile {
    display: block;
  }

  .back-btn {
    display: block;
  }

  .back-btn[hidden] {
    display: none;
  }

  .poem-title {
    font-size: 1.5rem;
  }

  .poem-body {
    font-size: 1.05rem;
  }

  .site-header {
    padding: 1rem 1.2rem 0;
  }

  .light-source {
    width: 400px;
    height: 400px;
    top: -80px;
    left: -80px;
  }
}

/* ===== TRANSITIONS FOR POEM LOAD ===== */
.poem-display {
  animation: fadeIn 0.35s ease;
}

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