@font-face {
  font-family: 'Andada SC';
  src: url('font/AndadaSC-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'Andada SC';
  src: url('font/AndadaSC-BoldItalic.ttf') format('truetype');
  font-weight: bold;
  font-style: italic;
}

@font-face {
  font-family: 'Andada SC';
  src: url('font/AndadaSC-Italic.ttf') format('truetype');
  font-weight: normal;
  font-style: italic;
}

@font-face {
  font-family: 'Andada SC';
  src: url('font/AndadaSC-Bold.ttf') format('truetype');
  font-weight: bold;
  font-style: normal;
}

@font-face {
  font-family: 'Solbera Imitation';
  src: url('font/Solbera-Imitation.ttf') format('truetype');
  font-style: normal;
}

html {
  -webkit-print-color-adjust: exact;
  font-size: 10px;
}

body {
  font-family: 'Crimson Text', serif;
  font-size: 1.7rem;
  background-color: #555;
  margin: 0;
  padding: 2rem;
  display: flex;
  justify-content: center;
  background-image: url('https://wa-cdn.nyc3.digitaloceanspaces.com/user-data/production/ff9b9726-973a-4b6f-8022-c5f40938013a/uploads/images/d4e6545b742ad35ea5c7764bbee0f66c.webp');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

/* The Page Wrapper */
.page {
  background-color: #f3e9d2;
  width: 920px;
  min-height: 297mm;
  padding: 0.5in;
  box-sizing: border-box;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  position: relative;
  overflow: hidden;
  line-height: 1.5;
  background-image: url(./img/bg.png);
  background-repeat: repeat;
  background-size: contain;
  background-blend-mode: luminosity;
  box-shadow: 0 6px 12px rgba(43, 21, 10, 0.4);
}

/* Optional Multi-column Support within the page */
.page.two-column {
  column-count: 2;
  column-gap: 0.25in;
  column-fill: auto;
}

/* Standard Element Styling */
p {
  margin-block-start: 0;
  margin-block-end: 1em;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: 'Andada SC', '-apple-system', sans-serif;
  color: #58180d;
  font-weight: normal;
  display: block;
  padding: 0;
  margin: .5rem 0;
  column-span: all;
  /* Make headers span across columns */
}

h1 {
  font-size: 3.3rem;
  line-height: 3.7rem;
  padding-bottom: .5rem;
}

h2 {
  font-size: 2.6rem;
  line-height: 3.1rem;
}

h3 {
  font-size: 2.3rem;
  border-bottom: .1rem solid #58180d;
  line-height: 3.1rem;
  overflow: hidden;
}

h4 {
  font-size: 2.1rem;
  line-height: 2.6rem;
}

/* Medieval Drop Cap (First letter styling) */
h1+p:not(.no-fancy)::first-letter {
  font-family: 'Solbera Imitation' !important;
  font-size: 10.0rem;
  text-decoration: none;
  font-style: normal;
  font-weight: normal;
  line-height: 1;
  margin-top: -.3rem;
  padding-right: .8rem;
  float: left;
}

/* Images and Figures */
figure {
  margin: 0;
  padding: 0;
  page-break-inside: avoid;
}

figcaption {
  text-align: center;
  font-size: 1.5rem;
  line-height: 3.5rem;
  font-style: italic;
}

img {
  max-width: 100%;
  height: auto;
}

figure.size-full,
img.size-full {
  width: 100%;
  height: auto;
}


/* Alignment Utilities */
.center {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.float-left {
  float: left;
  margin-right: 1.0rem;
}

.float-right {
  float: right;
  margin-left: 1.0rem;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

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

/* Fonts for Flavor Text */
@font-face {
  font-family: 'Zatanna Misdirection';
  src: url('font/Zatanna-Misdirection.ttf') format('truetype');
  font-style: normal;
}

@font-face {
  font-family: 'Zatanna Misdirection';
  src: url('font/Zatanna-Misdirection-Bold.ttf') format('truetype');
  font-weight: bold;
  font-style: normal;
}

@font-face {
  font-family: 'Zatanna Misdirection';
  src: url('font/Zatanna-Misdirection-Italic.ttf') format('truetype');
  font-weight: normal;
  font-style: italic;
}

@font-face {
  font-family: 'Zatanna Misdirection';
  src: url('font/Zatanna-Misdirection-Bold-Italic.ttf') format('truetype');
  font-weight: bold;
  font-style: italic;
}

/* Blockquotes */
.blockquote-wrap {
  padding-top: .8rem;
  padding-bottom: .8rem;
  padding-left: 0;
  padding-right: 0;
  margin: 0;
  overflow: hidden;
  page-break-inside: avoid;
}

blockquote {
  font-size: 1.5rem;
  display: block;
  background-color: #e0e4c3;
  padding: 1.0rem 1.5rem;
  margin: 2.0rem 0;
  position: relative;
  border-top: .2rem solid black;
  border-bottom: .2rem solid black;
}

blockquote p:first-child {
  margin-top: 0;
}

blockquote p:last-child {
  margin-bottom: 0;
}

blockquote:before,
blockquote:after {
  content: '';
  position: absolute;
  background-repeat: no-repeat;
  background-position: top center, bottom center;
  width: 1.4rem;
  top: -.8rem;
  bottom: -.8rem;
  background-size: 1.4rem .7rem;
}

blockquote:before {
  left: 0;
  background-image: linear-gradient(to bottom right, #fff0 0%, #fff0 50%, #000 50%, #000 100%),
    linear-gradient(to top right, #fff0 0%, #fff0 50%, #000 50%, #000 100%);
}

blockquote:after {
  right: 0;
  background-image: linear-gradient(to bottom left, #fff0 0%, #fff0 50%, #000 50%, #000 100%),
    linear-gradient(to top left, #fff0 0%, #fff0 50%, #000 50%, #000 100%);
}

.blockquote-read-wrap {
  padding-top: .3rem;
  padding-bottom: .3rem;
  padding-left: .3rem;
  padding-right: .3rem;
  margin: 0rem;
  overflow: hidden;
  page-break-inside: avoid;
}

blockquote.read {
  border-top: none;
  border-bottom: none;
  border-left: .2rem solid #58180d;
  border-right: .2rem solid #58180d;
  background-color: #edebe8;
  box-shadow: none;
}

blockquote.read:before,
blockquote.read:after {
  width: .4rem;
  background-size: .4rem .4rem;
  background-position: top center, bottom center;
  top: -.3rem;
  bottom: -.3rem;
  background-image: radial-gradient(circle at center, #58180d .2rem, transparent 0),
    radial-gradient(circle at center, #58180d .2rem, transparent 0);
}

blockquote.read:before {
  left: -.3rem;
}

blockquote.read:after {
  right: -.3rem;
}

.blockquote-paper-wrap {
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
  padding-left: .1rem;
  padding-right: .1rem;
  margin: 1.0rem;
  overflow: hidden;
  page-break-inside: avoid;
}

blockquote.paper {
  font-family: 'Zatanna Misdirection', '-apple-system', sans-serif !important;
  border-left: .1rem solid #d7d2d0;
  border-right: .1rem solid #d7d2d0;
  border-top: 0;
  border-bottom: 0;
  background-color: #fbf4df;
  padding: 2.0rem;
  box-shadow: none;
}

blockquote.paper:before,
blockquote.paper:after {
  content: '';
  background-image: url('img/note.png');
  background-size: 100% 100%;
  height: 1.5rem;
  position: absolute;
  left: -.1rem;
  right: -.1rem;
  width: auto;
}

blockquote.paper:before {
  transform: rotateY(180deg);
  top: -1.5rem;
  bottom: unset;
}

blockquote.paper:after {
  transform: rotateX(180deg);
  bottom: -1.5rem;
  top: unset;
}

blockquote.flowchart,
blockquote.flowchart-with-link {
  box-shadow: none;
  border-width: 1.6rem 1.6rem 1.6rem 1.6rem;
  border-style: solid;
  border-color: transparent;
  border-image-repeat: repeat;
  border-image-slice: 16 16 16 16 fill;
  background-color: transparent;
  padding: 1.0rem;
  position: relative;
  border-image-source: url('img/flowchart.png');
  margin: 5.0rem 2.5rem;
}

blockquote.flowchart:before,
blockquote.flowchart:after,
blockquote.flowchart-with-link:before,
blockquote.flowchart-with-link:after {
  background-image: none;
}

blockquote.flowchart-with-link:before {
  content: '';
  border-left: .3rem solid #58180d;
  height: 10.0rem;
  left: 50%;
  position: absolute;
  margin-top: -8.0rem;
  z-index: -1;
}

.blockquote-flavortext-wrap {
  padding-top: 5.0rem;
  padding-bottom: 5.0rem;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  overflow: hidden;
  display: table;
  page-break-inside: avoid;
}

blockquote.flavortext {
  font-family: 'Zatanna Misdirection', '-apple-system', sans-serif !important;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  border-bottom: 0;
  background-image: url('img/flavortext.png');
  background-size: cover;
  padding: 2.0rem;
  filter: opacity(1);
  max-width: 50.0rem;
  -webkit-filter: opacity(1);
  transform: rotate(-7deg);
  margin: 0;
}

blockquote.flavortext:before,
blockquote.flavortext:after {
  background-image: none;
}

.blockquote-elegant-wrap {
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
  padding-left: 2.0rem;
  padding-right: 2.0rem;
  overflow: hidden;
  page-break-inside: avoid;
}

blockquote.elegant {
  font-family: 'Tangerine', cursive !important;
  font-size: 3.0rem;
  line-height: 1.2;
  text-align: center;
  background-color: rgba(255, 255, 255, 0.5);
  border: none;
  box-shadow: none;
  color: #333;
  margin: 0;
  padding: 0.5em;
  border: 3px solid rgba(0, 0, 0, 0.25);
  text-shadow: 0em 0px 2px white;

}

blockquote.elegant:before,
blockquote.elegant:after {
  background-image: none;
}

li {
  list-style-position: inside;
}

img.size-cover {
  max-width: calc(100% + 1in);
  width: calc(100% + 1in);
  height: auto;
  margin-top: -0.5in !important;
  margin-left: -0.5in !important;
  mask-image: url(https://watercolors.giantsoup.com/phb/phb_bottom/0001.png);
  mask-position: bottom;
  mask-size: contain;
  margin-bottom: -70px;
}

img.vignette {
  mask-image: url(./img/vignette.png);
  mask-mode: luminance;
  mask-size: 180% 150%;
  mask-position: center;
}


@media print {
  body {
    background-color: #fff !important;
    background-image: none !important;
  }

  .page {
    background-color: #fff !important;
    background-image: none !important;
    box-shadow: none;
  }
}

/* Responsive Breakpoints */
@media screen and (max-width: 900px) {
  .page {
    width: 100%;
    margin: 0 auto;
    padding: 0.25in;
  }

  img.size-cover {
    max-width: calc(100% + 0.5in);
    margin-top: -0.25in !important;
    margin-left: -0.25in !important;
  }

}

@media screen and (max-width: 639px) {
  body {
    padding: 0;
  }

  .page {
    padding: 1.5rem;
    box-shadow: none;
  }



  figure.float-left,
  figure.float-right,
  .float-left,
  .float-right {
    width: 100% !important;
    float: none !important;
    margin: 1.5rem 0 !important;
  }
}

/* Sidebar layout styles */
body {
  justify-content: flex-start;
  padding: 0;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  background: rgba(244, 244, 244, 0.95);
  padding: 20px;
  box-sizing: border-box;
  border-right: 1px solid #ddd;
  overflow-y: auto;
  height: 100vh;
  position: sticky;
  top: 0;
}

.main-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 20px;
}

.nav-section summary {
  cursor: pointer;
  border-bottom: 1px solid #ccc;
  padding-bottom: 5px;
  margin-bottom: 10px;
}

.nav-section summary:hover {
  color: #58180d;
}

.nav-section h3 {
  display: inline;
  margin-top: 0;
  font-size: 1.1em;
  text-transform: capitalize;
  border-bottom: none;
  padding-bottom: 0;
}

.nav-section ul {
  list-style-type: none;
  padding: 0;
  margin: 0;
}

.nav-section li {
  margin-bottom: 5px;
}

.nav-section a {
  text-decoration: none;
  color: #333;
}

.nav-section a:hover {
  text-decoration: underline;
}

.page {
  /* Restrict max width of the page container for readability */
  max-width: 800px;
  margin: 0 auto;
}

/* Character Grid */
.character-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-top: 20px;
  margin-bottom: 30px;
}

.character-card {
  border: 1px solid #d7d2d0;
  border-radius: 8px;
  padding: 15px;
  text-align: center;
  background-color: #fbf4df;
  box-shadow: 0 4px 6px rgba(43, 21, 10, 0.1);
  transition: transform 0.2s, box-shadow 0.2s;
}

.character-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 12px rgba(43, 21, 10, 0.2);
}

.character-card a {
  text-decoration: none;
  color: inherit;
  display: block;
}

.character-profile-pic {
  height: 400px;
  object-fit: cover;
  margin-bottom: 10px;
  mask-image: url(./img/vignette.png);
  mask-mode: luminance;
  mask-size: 180% 150%;
  mask-position: center;
}

.character-card h3 {
  border-bottom: none;
  margin: 0;
}

hr {
  border: 0;
  height: 2px;
  background-image: linear-gradient(to right, rgba(88, 24, 13, 0), rgba(88, 24, 13, 0.75), rgba(88, 24, 13, 0));
  margin: 40px 0;
}

.story-so-far-content li {
  list-style-position: outside;
}

/* Loading Overlay */
#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #f7f1e3;
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.5s ease-out;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(88, 24, 13, 0.2);
  border-top-color: #58180d;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Mobile Menu Button & Sidebar Overlay */
#mobile-menu-btn {
  display: none;
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 1000;
  background: rgba(244, 244, 244, 0.95);
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 8px;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  color: #58180d;
}

#sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
}

@media screen and (max-width: 639px) {
  #mobile-menu-btn {
    display: flex;
    justify-content: center;
    align-items: center;
  }
  
  .page {
    padding-top: 60px; /* Space for the floating button */
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1001;
    box-shadow: 2px 0 10px rgba(0,0,0,0.3);
  }

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

  #sidebar-overlay.sidebar-open {
    display: block;
  }
}