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

body {
  font-family:
    Garamond,
    Times,
    Times New Roman,
    -serif;
  margin: 0;
  display: grid;
  grid-template-areas:
    "header header header"
    "topmenu topmenu topmenu"
    "menu main sidebar";
  grid-template-columns: 250px 1fr 300px;
  grid-template-rows: auto auto 1fr;
  min-height: 100vh;
}

h1,
h2,
h3 {
  /* font-family: Garamond, Times New Roman, Serif; */
  font-weight: normal;
  color: #7b635c;
  margin-bottom: 0.2em;
  line-height: 120%;
}

a {
  color: #7b635c;
  text-decoration: none;
  &:hover,
  &:focus {
    text-decoration: underline;
  }
}

a.button {
  padding: 0.5em 2em;
  margin-bottom: 1em;
  /* border: 1px solid #7b635c; */
  border: 1px outset buttonborder;
  border-radius: 3px;
  color: black;
  background-color: #ede3ba;
  text-decoration: none;
}

div.site-title {
  margin: 0;
  padding: 0.5em 2em;
  color: white;
  background: #7b635c;
  display: flex;
  align-items: center;
  gap: 1rem;

  & h1 {
    color: white;
    margin: 1rem 0;
    flex: 1;
    & a {
      color: white;
      text-decoration: none;
    }
  }
}

main.content {
  grid-area: main;
  margin: 4rem 4rem;
  line-height: 133%;
  padding-bottom: 3rem;

  & p {
    margin-bottom: 1em;
  }
}

div.more {
  margin-top: 3rem;
}

header {
  grid-area: header;
}

div.topmenu {
  grid-area: topmenu;
}

div.topmenu nav {
  background-color: #ede3ba;
  color: gray;
  padding: 0.5em 2em;
  margin: 0;
  margin-block: 0;
  & ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    & li {
      display: inline;
      margin-right: 1em;

      &.active a {
        font-weight: bold;
        color: #333;
      }
    }
  }

  & a {
    color: gray;
    text-decoration: none;
  }
}

.hamburger {
  display: none;
  flex-direction: column;
  cursor: pointer;
  gap: 4px;
}

.hamburger span {
  width: 25px;
  height: 3px;
  background-color: white;
  transition: 0.3s;
}

/* Add styling for the left menu */
.menu {
  grid-area: menu;
  background-color: #f5f5f5;
  padding: 2rem 1.5rem;

  & nav ul {
    list-style-type: none;
    padding-left: 0;

    & li {
      font-weight: bold;
      margin-left: 0;
      margin-bottom: 0.5em;

      & a {
        display: block;
        padding: 0.25em 0.5em;
        border-radius: 3px;
        transition: background-color 0.2s ease;
      }

      &.active > a {
        background-color: #ede3ba;;
        /* color: white; */

        &:hover {
          background-color: #8b6f69;
        }
      }
    }

    /* Nested menu items */
    & ul {
      margin-left: 1em;
      margin-top: 0;
      margin-bottom: 0.7em;

      & li {
        font-weight: normal;
        margin-bottom: 0.25em;
        font-size: 95%;

        &.active > a {
          color: #333;
          background-color: transparent;
          font-weight: bold;
        }
      }
    }
  }

  & h3 {
    margin-bottom: 1em;
    font-size: 1.1em;
  }
}

/* Add styling for the right sidebar */
.sidebar {
  grid-area: sidebar;
  background-color: #fafaf8;
  padding: 2rem 1.5rem;
  border-left: 1px solid #e0e0e0;

  & h2 {
    font-size: 1.1em;
  }

  & .reviewer {
    font-size: 85%;;
  }
}

main.content {
  grid-area: main;
  margin: 4rem 4rem;
  line-height: 133%;
}

/* Tablet: hide right sidebar */
@media (max-width: 1024px) {
  body {
    grid-template-areas:
      "header header"
      "topmenu topmenu"
      "menu main"
      "menu sidebar";
    grid-template-columns: 250px 1fr;
  }

  /* .sidebar {
    display: none;
  } */
}

/* Mobile: hide both sidebars, show hamburger */
@media (max-width: 768px) {
  body {
    grid-template-areas:
      "header"
      "topmenu"
      "main"
      "sidebar";
    grid-template-columns: 1fr;
  }

  .hamburger {
    display: flex;
  }

  .menu {
    position: fixed;
    top: 0;
    left: -100%;
    width: 280px;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s ease-in-out;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
  }

  .menu.active {
    left: 0;
  }

  .overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
  }

  .overlay.active {
    display: block;
  }
  main.content {
    margin: 2rem 1rem;
  }

  .topmenu nav {
    padding: 0.5em 1em;

    & ul li {
      display: block;
      margin-bottom: 0.5em;
    }
  }
}

/* Small mobile */
@media (max-width: 480px) {
  main.content {
    margin: 1rem 0.5rem;
  }

  .site-title {
    padding: 0.5em 1em;

    & h1 {
      font-size: 1.5rem;
    }
  }
}

div.subtitle {
  font-size: 120%;
  color: #7b635c;
}

div.author {
  font-size: 110%;
  font-style: italic;
  color: #777777;
  margin-bottom: 1rem;
}

.template-homepage {
  & main.content {
    font-size: 110%;
    max-width: 64rem;
  }
}

.template-general {
  & main.content {
    font-size: 110%;
    max-width: 64rem;
  }

  & img.left {
    float: left;
    margin-right: 1em;
    margin-bottom: 1em;
    border: 1px solid #ccc;
    padding: 0.2em;
    background-color: #f9f9f9;
  }
}

.template-homepage {
  & main.content {
    & .bookshelf {
      text-align: center;
      margin: 1em auto 1em auto;
    }
  }

  & .sidebar {
    font-size: 85%;
  }
}

.template-bookindexpage {
  & main.content {
    max-width: 64rem;

    & .bookshelf {
      text-align: center;

      & .book-entry {
        border: 1px solid gray;
        border-radius: 3px;
        width: 15rem;
        min-height: 15rem;

        & img {
          margin-bottom: 1em;
        }
      }
    }
  }
}

.book-entry {
  display: inline-block;
  padding: 1em;
  margin-right: 2em;
  margin-bottom: 2em;
  text-align: center;
  vertical-align: top;
  max-width: 15rem;
  & h2 {
    margin-top: 0;
    margin-bottom: 1rem;
  }
  &:hover,
  &:focus-within {
    box-shadow: 2px 2px 5px #ccc;
  }
  & img {
    border: 1px solid #ccc;
    padding: 0.2em;
    background-color: #f9f9f9;
  }

  & div.teaser {
    font-size: 90%;
    color: #555555;
    line-height: 125%;
  }
}

.template-book {
  & main.content {
    max-width: 48rem;

    & div.author {
      margin-top: 0;
    }

    & h2 {
      clear: both;
      border-top: 1px dotted gray;
      margin: 1em 0;
      padding: 1rem 0;
    }
  }

  & img.book-theme {
    float: right;
    margin-left: 1em;
    margin-bottom: 1em;
    border: 1px solid #ccc;
    padding: 0.2em;
    background-color: #f9f9f9;
  }

  & ul.editions-list {
    list-style-type: none;
    padding-left: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1.5rem;
    
    & li {
      text-align: center;

      & img.edition-theme {
        display: block;
        margin: 0 auto 1em;
      }
    }
  }

  & div.factoids {
    padding: 0.5em;

    & h2 {
        margin: 1em 0 1em;
        padding: 1em 0 0;
    }
    & ul {
        margin-left: 2em;
    }
  }
}

.template-edition {
  & main.content {
    max-width: 48rem;

    & img.edition-theme {
      display: block;
      float: left;
      margin: 1em 2em 1em 0em;
    }

    & div.info {
      margin-top: 1rem;
      float: left;

      & ul.vendors-list {
        list-style-type: none;
        padding-left: 0;

        & li {
          margin-top: 1.5rem;
          margin-left: 0;
          width: 16rem;
        }
      }
    }

    & h2 {
      clear: both;
      margin-top: 2rem;
    }
  }
}

.template-review {
  & div.review {
    max-width: 32rem;

    & div.review-body {
      font-style: italic;
      margin-top: 2rem;
      margin-bottom: 1rem;
      padding-left: 1rem;
      border-left: 4px solid #ccc;
    }

    & div.reviewer {
      text-align: right;
      color: #555555;
      margin-bottom: 2rem;
    }
    & div.reviewer::before {
      content: "— ";
    }
  }
}

.template-factoid {
  & main.content {
    font-size: 100%;
    max-width: 64rem;
  }
}

.template-articleindexpage {
  & main.content {
    max-width: 64rem;

    & .articleshelf {
      text-align: left;
    }
  }

  .article-entry {
    padding-left: 1rem;
    border-left: 2px solid #ccc;
    margin-bottom: 2em;
  }

  .article-date {
    font-size: 90%;
  }
}

.template-article {
  & main.content {
    max-width: 32rem;

    & div.article-body {
      font-style: italic;
      margin-top: 2rem;
      margin-bottom: 1rem;
      padding-left: 1rem;
      border-left: 4px solid #ccc;
    }

    & div.articleer {
      text-align: right;
      color: #555555;
      margin-bottom: 2rem;
    }
    & div.articleer::before {
      content: "— ";
    }
  }
}

.sidebar  div.review {
    max-width: 32rem;
    & div.review-body {
      font-style: italic;
      margin-top: 2rem;
      margin-bottom: 1rem;
      padding-left: 1rem;
      border-left: 4px solid #ccc;
    }

    & div.reviewer {
      text-align: right;
      color: #555555;
      margin-bottom: 2rem;
    }
    & div.reviewer::before {
      content: "— ";
    }
}