:root {
  --font-heading: 'Cinzel Decorative', serif;
  --font-body: 'Lora', serif;
  
  --color-bg: #1a1a1d;
  --color-parchment: #f5eeda;
  --color-text: #2c2a2a;
  --color-border: #c9b474;
  --color-highlight: #a98e4a;
  --color-hover: #4a4e69;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-bg);
  background-image: url('https://www.transparenttextures.com/patterns/dark-stone-wall.png');
  color: var(--color-parchment);
  line-height: 1.7;
  overflow-x: hidden;
}

body.nav-active {
  overflow: hidden;
}

#root {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 2rem;
}

.storybook-container {
  display: flex;
  width: 100%;
  max-width: 1400px;
  height: 85vh;
  background: var(--color-parchment);
  color: var(--color-text);
  border: 10px solid;
  border-image-slice: 10;
  border-image-source: linear-gradient(45deg, var(--color-border), var(--color-highlight));
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
}

.navigation-panel {
  width: 35%;
  max-width: 400px;
  padding: 2rem;
  overflow-y: auto;
  border-right: 2px solid var(--color-border);
  background-color: rgba(0,0,0,0.03);
}

.main-title {
  font-family: var(--font-heading);
  font-size: 2rem;
  color: var(--color-highlight);
  text-align: center;
  margin-bottom: 2rem;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.navigation-panel ul {
  list-style-type: none;
}

.category-item {
  margin-bottom: 1rem;
}

.category-title {
  font-family: var(--font-body);
  font-size: 1.3rem;
  background: none;
  border: none;
  color: var(--color-text);
  cursor: pointer;
  text-align: left;
  width: 100%;
  padding: 0.5rem 0;
  font-weight: 700;
  transition: color 0.3s ease;
}

.category-title:hover, .category-title.active {
  color: var(--color-highlight);
}

.story-list {
  list-style: none;
  margin-top: 0.5rem;
  padding-left: 1rem;
  border-left: 1px solid var(--color-border);
}

.story-list a.story-link {
  display: block;
  text-decoration: none;
  color: var(--color-text);
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  transition: background-color 0.3s, color 0.3s;
}

.story-list a.story-link:hover {
  background-color: rgba(169, 142, 74, 0.2);
}

.story-list a.story-link.active {
  color: var(--color-parchment);
  background-color: var(--color-highlight);
  font-weight: bold;
}

.content-panel {
  flex-grow: 1;
  padding: 3rem;
  overflow-y: auto;
}

.story-content {
  max-width: 80ch;
  margin: 0 auto;
}

.story-title {
  font-family: var(--font-body);
  font-size: 2.5rem;
  margin-bottom: 1.5rem;
  color: var(--color-highlight);
  text-align: center;
}

.story-content p {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  white-space: pre-wrap;
}

.placeholder {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  text-align: center;
  font-family: var(--font-body);
  color: #9e9e9e;
  font-size: 1.5rem;
}

.placeholder.error {
    color: #b22222;
}

.menu-toggle-button,
.page-overlay {
  display: none;
}

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

::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.1);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-highlight);
}

/* Responsive Design */
@media (max-width: 900px) {
  #root {
    padding: 0;
    display: block;
  }
  
  .menu-toggle-button {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    position: fixed;
    top: 1rem;
    left: 1rem;
    width: 44px;
    height: 44px;
    background: var(--color-highlight);
    border: 1px solid var(--color-parchment);
    border-radius: 8px;
    z-index: 1001;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
    padding: 8px;
    transition: transform 0.3s ease-in-out;
  }

  .menu-toggle-button.hidden {
    transform: translateY(-150%);
  }

  .menu-toggle-button span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--color-parchment);
    transition: all 0.3s ease-in-out;
    transform-origin: center;
  }

  .menu-toggle-button.open span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
  }

  .menu-toggle-button.open span:nth-child(2) {
    opacity: 0;
  }

  .menu-toggle-button.open span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
  }
  
  .page-overlay.active {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 999;
    backdrop-filter: blur(2px);
  }

  .storybook-container {
    display: block;
    width: 100%;
    max-width: none;
    height: 100vh;
    border: none;
    box-shadow: none;
    background: none;
  }
  
  .navigation-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 85%;
    max-width: 320px;
    height: 100%;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    box-shadow: 2px 0 15px rgba(0,0,0,0.3);
    border-right: 2px solid var(--color-border);
    background-color: var(--color-parchment);
    padding-top: 5rem;
  }

  .navigation-panel.open {
    transform: translateX(0);
  }

  .content-panel {
    height: 100vh;
    padding: 2rem 1.5rem;
    padding-top: 5rem;
    background: var(--color-parchment);
  }
  
  .main-title {
    font-size: 1.8rem;
  }
  
  .story-title {
    font-size: 2rem;
  }
}
