/* Global Reset and CSS Variables */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
  --color-bg: #f9f9f9;
  --color-container: #ffffff;
  --color-header: #9fbeff;
  --color-menu: #8dce83;
  --color-text: #333333;
  --color-border: #e0e0e0;
  --color-sidebar-mobile: #f1f1f1;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Basic Body Styles */
body {
  margin: 0;
  padding: 0;
  font: 100% var(--font-family);
  background-color: var(--color-bg);
  color: var(--color-text);
}

/* Container using CSS Grid with items aligned to start */
.twoColFixRtHdr #container {
  max-width: 980px;
  margin: 20px auto;
  background: var(--color-container);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;

  display: grid;
  grid-template-columns: 1fr 200px;
  grid-template-rows: auto auto minmax(auto, 1fr);
  grid-template-areas:
    "header header"
    "menu menu"
    "mainContent sidebar1";

  /* Prevent grid items (including sidebar) from stretching */
  align-items: start;
}

/* Header */
.twoColFixRtHdr #header {
  grid-area: header;
  background: var(--color-header);
  padding: 20px;
  text-align: center;
  font-size: 1.5rem;
  color: #ffffff;
  border-bottom: 2px solid var(--color-border);
}

.twoColFixRtHdr #header h3 {
  margin: 0;
  padding: 0;
  font-weight: bold;
}

/* Menu */
.twoColFixRtHdr #menu {
  grid-area: menu;
  background: var(--color-menu);
  padding: 10px;
  text-align: center;
  font-size: 1rem;
  line-height: 1.6;
  border-top: 2px solid var(--color-menu);
}

.twoColFixRtHdr #menu a {
  color: #ffffff;
  text-decoration: none;
  white-space: nowrap;
}

.twoColFixRtHdr #menu a:visited {
  color: #ffffff;
}

.twoColFixRtHdr #menu a:hover {
  text-decoration: underline;
}

/* Main Content */
.twoColFixRtHdr #mainContent {
  grid-area: mainContent;
  padding: 20px;
  background: var(--color-container);
}

/* --- Begin Main Section Additions for Sonnet Lines Table --- */
/* Assuming your sonnet lines table has the class "sonnet-lines" */

/* Set the table to fixed layout for equal column widths */
.twoColFixRtHdr #mainContent table.sonnet-lines {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin: 0 auto;
}

/* The first three columns (book, sonnet, line) are given equal fixed widths */
.twoColFixRtHdr #mainContent table.sonnet-lines td.number {
  width: 60px;         /* Adjust this value as needed */
  text-align: center;
  vertical-align: middle;
  padding: 5px;
}

/* The fourth column (text) will take up the remaining space */
.twoColFixRtHdr #mainContent table.sonnet-lines td.sonnet-line {
  padding: 5px;
  text-indent: 30px;
  word-wrap: break-word;
}
/* --- End Main Section Additions for Sonnet Lines Table --- */

/* Sidebar with Flex for dynamic content */
/* Note: align-self: start ensures it only takes up as much vertical space as needed */
.twoColFixRtHdr #sidebar1 {
  grid-area: sidebar1;
  padding: 15px;
  background: var(--color-container);
  border-left: 1px solid var(--color-border);
  
  display: flex;
  flex-direction: column;
  align-items: center;
  align-self: start;
}

.twoColFixRtHdr #sidebar1 img {
  max-width: 100%;
  display: block;
  margin-bottom: 15px;
  height: auto;
  border: none;
}

.twoColFixRtHdr #sidebar1 ul {
  list-style-type: none;
  padding: 0;
  margin: 0;
  width: 100%;
  text-align: left;
}

.twoColFixRtHdr #sidebar1 ul li {
  margin-bottom: 10px;
}

/* For additional dynamic content inside the sidebar */
.twoColFixRtHdr #sidebar1 .dynamic-content {
  flex-grow: 1;
  width: 100%;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .twoColFixRtHdr #container {
    max-width: 100%;
    margin: 0;
    border-radius: 0;
    box-shadow: none;

    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    grid-template-areas:
      "header"
      "menu"
      "mainContent"
      "sidebar1";
      
    /* On mobile, let items use full width and only the necessary height */
    align-items: start;
  }
  
  .twoColFixRtHdr #menu {
    font-size: 1.3rem;
  }
  
  .twoColFixRtHdr #mainContent,
  .twoColFixRtHdr #sidebar1 {
    padding: 15px;
  }
  
  .twoColFixRtHdr #sidebar1 {
    background: var(--color-sidebar-mobile);
    border-left: none;
    border-top: 1px solid var(--color-border);
    align-items: flex-start;
  }
  
  body {
    font-size: 1.5rem;
  }
}
