@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:wght@400;700&display=swap');

/* Light theme (default) */
:root {
  --bg-primary: #faf9f6;
  --bg-secondary: #fff;
  --text-primary: #181818;
  --text-secondary: #7a7a7a;
  --text-tertiary: #b0a98f;
  --border-color: #edeae4;
  --button-hover-bg: #181818;
  --button-hover-text: #faf9f6;
  --button-hover-border: #c2bfb7;
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #242424;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-tertiary: #808080;
    --border-color: #333333;
    --button-hover-bg: #e0e0e0;
    --button-hover-text: #1a1a1a;
    --button-hover-border: #404040;
  }
}

/* Smooth theme transitions */
body {
  font-family: 'EB Garamond', Georgia, serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Layout transitions */
.layout {
  display: flex;
  min-height: 100vh;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.sidebar {
  background: var(--bg-primary);
  min-width: 260px;
  max-width: 320px;
  width: 25vw;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  padding: 3rem 2rem 3rem 2.5rem;
  box-sizing: border-box;
  border-right: 1px solid var(--border-color);
  position: relative;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.sidebar-title-link {
  text-decoration: none;
  color: inherit;
  transition: opacity 0.2s;
}

.sidebar-title-link:hover {
  opacity: 0.8;
}

.sidebar-title {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  text-align: left;
}

.sidebar-author {
  font-size: 1.1rem;
  color: var(--text-primary);
  font-family: 'EB Garamond', Georgia, serif;
  margin-bottom: 2rem;
}

.sidebar-sidenote {
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text-secondary);
  margin-top: 2rem;
  margin-bottom: 2rem;
}

.sidebar-privacy {
  font-size: 0.95rem;
  color: var(--text-tertiary);
  margin-top: 2.5rem;
  line-height: 1.5;
  max-width: 220px;
  font-style: italic;
}

.sidebar-privacy-bottom {
  margin-top: auto;
}

.sidebar-image-wrapper {
  width: 100%;
  justify-content: center;
  align-items: center;
  margin: 1.5rem 0 2.2rem 0;
}

.sidebar-poem-image,
.poem-image {
  width: 180px;
  height: 180px;
  object-fit: contain;
  border-radius: 1.2rem;
  background: transparent;
  box-shadow: none;
  display: block;
  max-width: 80%;
}

/* Make SVGs light in dark mode */
@media (prefers-color-scheme: dark) {
  .sidebar-poem-image[src$=".svg"],
  .poem-image[src$=".svg"] {
    filter: invert(1) brightness(0.6);
  }
}

.main-content {
  background: var(--bg-secondary);
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 5rem 0 5rem 5vw;
  box-sizing: border-box;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.poem-image-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 2.2rem;
}

.poem-container-wrapper {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.poem-container {
  font-size: 1.5rem;
  line-height: 1.7;
  white-space: pre-wrap;
  text-align: left;
  font-family: 'EB Garamond', Georgia, serif;
  max-width: 700px;
  margin: 0;
  padding: 2rem 0 0 2rem;
  opacity: 0;
  animation: fadeIn 0.4s ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.poem-container p {
  margin-top: 0em;
  margin-bottom: 0em;
}

.poem-container br {
  display: inline;
}

.poem-navigation {
  display: flex;
  gap: 1rem;
  margin-top: 3rem;
}

.nav-btn {
  color: var(--text-primary);
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1.5rem;
  font-family: system-ui, -apple-system, sans-serif;
  font-weight: 300;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border 0.2s, transform 0.2s ease;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  text-decoration: none;
}

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

.prev-poem-btn:hover:not(:disabled), 
.prev-poem-btn:focus:not(:disabled) {
  background: var(--button-hover-bg);
  color: var(--button-hover-text);
  border: 1px solid var(--button-hover-border);
  transform: translateX(-4px);
}

.next-poem-btn:hover:not(:disabled), 
.next-poem-btn:focus:not(:disabled) {
  background: var(--button-hover-bg);
  color: var(--button-hover-text);
  border: 1px solid var(--button-hover-border);
  transform: translateX(4px);
}

.prev-poem-btn:active:not(:disabled) {
  transform: translateX(-4px) scale(0.98);
}

.next-poem-btn:active:not(:disabled) {
  transform: translateX(4px) scale(0.98);
}

.theme-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.5rem;
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'EB Garamond', Georgia, serif;
  transition: color 0.2s, transform 0.2s;
  border-radius: 0.5rem;
}

.theme-toggle:hover {
  color: var(--text-primary);
  transform: scale(1.05);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-toggle svg {
  width: 1.2rem;
  height: 1.2rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle .sun-icon {
  display: none;
}

.theme-toggle .moon-icon {
  display: block;
}

body.light-theme .theme-toggle .sun-icon {
  display: block;
}

body.light-theme .theme-toggle .moon-icon {
  display: none;
}

/* Poem list styles */
.poem-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 2rem;
  max-width: 800px;
  margin: 0 auto;
}

.poem-link {
  text-decoration: none;
  color: var(--text-primary);
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: all 0.2s ease;
  background: var(--bg-primary);
}

.poem-link:hover {
  transform: translateX(4px);
  border-color: var(--button-hover-border);
  background: var(--button-hover-bg);
  color: var(--button-hover-text);
}

.poem-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.2rem;
  font-weight: 500;
}

/* HEADER & FOOTER for mobile */
.header {
  display: none;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.footer {
  display: none;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

@media (min-width: 901px) {
  .main-content {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 3rem;
  }
  .poem-container-wrapper {
    flex: 1 1 0%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }
  .poem-container {
    padding: 2rem 0 0 0;
    margin: 0;
    flex: 0 0 auto;
    min-width: 0;
  }
  .poem-image-wrapper {
    width: 320px;
    min-width: 220px;
    max-width: 340px;
    margin-bottom: 0;
    margin-top: 0.5rem;
    justify-content: flex-start;
    align-items: flex-start;
  }
  .poem-image {
    width: 320px;
    height: 320px;
    max-width: 100%;
    max-height: 420px;
    margin: 0;
    border-radius: 1.2rem;
  }
  .poem-image-wrapper {
    display: none !important;
  }
}

@media (max-width: 900px) {
  .layout {
    flex-direction: column;
  }
  .sidebar {
    display: none;
  }
  .sidebar-image-wrapper {
    display: none;
  }
  .sidebar-poem-image {
    display: none;
  }
  .header {
    display: block;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 2.2rem 1.5rem 1.5rem 1.5rem;
    text-align: left;
  }
  .header-title {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-family: 'EB Garamond', Georgia, serif;
  }
  .header-author {
    font-size: 1.1rem;
    color: var(--text-primary);
    font-family: 'EB Garamond', Georgia, serif;
    margin-bottom: 1.2rem;
  }
  .header-sidenote {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 0;
    font-style: italic;
    max-width: 320px;
    line-height: 1.5;
  }
  .footer {
    display: block;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 1.2rem 1.5rem 1.2rem 1.5rem;
    text-align: left;
  }
  .footer-privacy {
    font-size: 0.95rem;
    color: var(--text-tertiary);
    font-style: italic;
    max-width: 320px;
    line-height: 1.5;
  }
  .poem-image {
    width: 90vw;
    max-width: 320px;
    height: 90vw;
    max-height: 320px;
    margin-left: auto;
    margin-right: auto;
    border-radius: 1.2rem;
  }
  .poem-image-wrapper {
    margin-bottom: 1.5rem;
    justify-content: center;
    align-items: center;
    display: flex;
  }
  .main-content {
    padding: 2rem 1.5rem 2rem 1.5rem;
    background: var(--bg-secondary);
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 0;
  }
  .poem-container {
    font-size: 1.5rem;
    line-height: 1.7;
    white-space: pre-wrap;
    text-align: left;
    font-family: 'EB Garamond', Georgia, serif;
    max-width: 700px;
    margin: 0;
    padding: 2rem 0 0 0;
    box-sizing: border-box;
  }
}