@import url("https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&family=Nunito+Sans:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Open+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,300;1,400;1,500;1,600;1,700;1,800&family=Source+Sans+Pro:ital,wght@0,200;0,300;0,400;0,600;0,700;0,900;1,200;1,300;1,400;1,600;1,700;1,900&display=swap");
@import "./menu_popup.css";

:root {
  --bg: #f8f8d4;
  --text: #111827;
  --muted-text: #334155;
  --accent: #0000ff;
  --surface: #fdfaf2;
  --card: floralwhite;
  --border: #cbd5e1;
  --nav-shadow: 1px 2px 7px rgba(0, 0, 0, 0.35);
  --float-bg: #ffffff;
  --page-bg-image: url("https://pub-04cc3e731d514ccd8bd75e6061be07b0.r2.dev/Image_Files/parchmnt.jpg");

  /* Off-canvas nav closed position (flips automatically for RTL) */
  --navBar-closed-x: -1000px;
}

html {
  direction: ltr;
}

html[dir="rtl"] {
  direction: rtl;
  --navBar-closed-x: 1000px;
}

.dark-mode {
  --bg: #0f172a;
  --text: #e5e7eb;
  --muted-text: #cbd5e1;
  --accent: #7dd3fc;
  --surface: #111827;
  --card: #1f2937;
  --border: #334155;
  --nav-shadow: 1px 2px 7px rgba(0, 0, 0, 0.55);
  --float-bg: #1f2937;
  --page-bg-image: none;
}

.light-mode {
  --bg: #f8f8d4;
  --text: #111827;
}

body {
  font-family: "Nunito Sans", "Lato", Arial, sans-serif;
  position: relative;
  background-image: var(--page-bg-image);
  background-color: var(--bg);
  color: var(--text);
  max-width: 100vw;
  transition: background-color 0.25s ease, color 0.25s ease;

  &.desktop {
    max-width: 1440px;
    margin-inline: calc(100% / 8);
  }
}

a {
  color: var(--accent);
}

/* Optional: lock background scroll when nav is open (toggle this class in JS) */
html.nav-open {
  overflow: hidden;
  height: 100%;
}

body.nav-open {
  overflow: hidden;
  height: 100vh;
}

/* ===================== FLOATING MENU BUTTON (legacy class: theme-toggle) ===================== */
.theme-toggle {
  position: fixed;
  bottom: 2em;
  inset-inline-start: 1em;
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 0.5em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;

  border: none;

  &.show {
    opacity: 0.9;
    pointer-events: auto;
  }

  button {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.4em 0.9em;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease,
      box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.4em;
    line-height: 1.1;
  }

  button:hover {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  }
}

/* ===================== UTILITY ===================== */
.display-none {
  display: none !important;
}

/* ===================== "Ori" TOGGLE (original paragraph placeholder) ===================== */
.ori-toggle-container {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.ori-toggle-btn {
  align-self: flex-end;

  /* Finger-friendly tap target (>= 44px) */
  min-width: 3.25rem;
  min-height: 2.75rem;
  padding: 0.5rem 0.85rem;

  border-radius: 999px;
  border: 1px solid var(--border);

  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1;

  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;

  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease,
    box-shadow 0.15s ease;

  margin: 0 0 0.25rem 0;
}

.ori-toggle-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.ori-toggle-btn:hover {
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.ori-toggle-btn:not(.is-active) {
  background: var(--surface);
  color: var(--text);
}

.ori-toggle-btn.is-active {
  background: #16a34a; /* green */
  border-color: #16a34a;
  color: #ffffff;
}

/* Dark-mode adjustments */
.dark-mode .ori-toggle-btn:not(.is-active) {
  background: var(--card);
  border-color: var(--border);
  color: var(--text);
}

.dark-mode .ori-toggle-btn.is-active {
  background: #22c55e;
  border-color: #22c55e;
  color: #052e16;
}

/* Slightly larger tap target on small screens */
@media screen and (max-width: 768px) {
  .ori-toggle-btn {
    min-width: 3.75rem;
    min-height: 3rem;
    padding: 0.65rem 1rem;
  }
}

.theme-toggle__icon {
  font-size: 1.15em;
  line-height: 1;
}

.theme-toggle__text {
  font-weight: 700;
}

.dark-mode .theme-toggle button {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
}

/* ===================== NAVBAR (BASE, ALL MODES) ===================== */
/* Key fix: Make #navBar a flex column so .scrollable can take remaining height and scroll. */
#navBar {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;

}

/* Key fix: scroll area must be allowed to shrink (min-height:0) so overflow can scroll. */
#navBar .scrollable {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;

  width: 100%;

  ul {
    margin-block-start: 0;
    margin-inline-start: 0;
    padding-inline-start: 0;
  }

  .relatedLinks ul,
  li,
  ol {
    list-style-type: none;
    padding-inline-start: 0;
    margin-bottom: 6px;

    a {
      margin-bottom: 12px;
      display: block;
      color: var(--text);
    }
  }
}

/* Keep relatedLinks styling */
.relatedLinks {
  font-weight: bold;
  color: var(--text);
}

/* ===================== MOBILE ===================== */
.mobile {
  max-width: 100vw;
  font-size: 14px;

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

  #globalNav {
    display: flex;
    width: 90vw;
    gap: 0.5em;
    position: relative;

    .navbar-border {
      display: none;
      border: solid 1px var(--border);
      position: absolute;
      bottom: -1em;
    }
  }

  .navbar-toggle {
    position: fixed;
    top: 0;
    inset-inline-start: 0;
    cursor: pointer;

    .navbar-relative {
      position: relative;

      #navBar {
        /* Make it a proper overlay drawer on mobile */
        position: fixed;
        top: 0;
        inset-inline-start: 0;

        width: calc(100vw - 2em);
        max-width: 100vw;

        height: 100vh;
        padding: 1em;
        padding-bottom: 2em;
        margin-top: 0;
        border-radius: 0;

        background-color: var(--card);
        color: var(--text);
      }
    }
  }

  #masthead {
    max-width: 90vw;
    overflow-x: auto;

    #siteName {
      font-size: 1.5em;
      width: fit-content;
    }
  }

  #content {
    font-size: 16px;
    overflow-x: hidden;
    float: none;
    width: calc(100vw - 20px);
    padding: 0 2px;
    word-wrap: break-word;

    .style96 {
      font-size: 1.125em;
    }

    .journal {
      word-wrap: break-word;
      padding-right: initial;

      &>table {
        width: 93vw !important;
        max-width: 93vw;
      }

      table>tbody>tr>td {
        width: 50vw !important;
      }
    }

    .style116 {
      /* width: 100vw; */
      display: block;

      &>table {
        transform: scale(0.80) translateX(-10%);
        width: auto !important;

        &>tbody>tr>td {
          width: auto !important;
        }
      }
    }
  }

  /* Accordion / message */
  .message-from-lord {
    float: none;
    width: initial;
    max-height: 0;
    margin-top: 1em;
    position: relative;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0 4px;
    background-color: #ffff99;
    color: var(--text);
  }

  .accordion-toggle[type="checkbox"] {
    display: none;

    &~.comments.accordion-content {
      max-height: 0;
      overflow-y: hidden;
    }

    &:checked~.message-from-lord,
    &:checked~.accordion-content,
    &:checked~.comments.accordion-content {
      max-height: 87vh;
      overflow-y: auto;
      border: solid 8px var(--accent);
      background-color: #ffff99;
    }
  }

  .accordion-label {
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    margin-inline-start: 1em;
    color: var(--accent);
  }
}

/* ===================== DESKTOP ===================== */
body {
  #masthead {
    #globalNav {
      display: flex;
      gap: 0.75em;

      a {
        margin-inline-start: 12px;
      }
    }
  }

  .message-from-lord {
    float: inline-end;
    width: 30%;
    max-width: 400px;
    max-height: 30000px;
    margin-top: 1em;
    margin-inline-end: 1em;
    position: relative;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0 4px;
    background-color: #ffff99;
    border: solid 8px #0000ff;
    color: var(--text);
  }

  .journal {
    font-size: 13pt;
    padding-right: 1em;
  }

  .navbar-toggle {
    position: fixed;
    top: 5em;
    inset-inline-start: 2em;
    cursor: pointer;

    .navbar-relative {
      position: relative;
    }

    .right-caret {
      background-color: var(--card);
      width: 2em;
      height: 2em;
      margin-top: 1em;
      border-radius: 0.2em;
      box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.5);
      display: flex;
      align-items: center;
      justify-content: center;
      opacity: 0.8;

      &::before {
        content: " ";
        display: inline-block;
        width: 0;
        height: 0;
        border-top: 8px solid transparent;
        border-bottom: 8px solid transparent;
        border-left: 12px solid var(--accent);
        margin-left: 0.5em;
      }
    }
  }

  #navBar {
    font-size: 1em;
    top: 10px;
    inset-inline-start: 0;
    transition: transform 0.3s ease-in-out;
    position: absolute;
    transform: translateX(var(--navBar-closed-x));

    height: 90vh;
    width: 100vw;
    max-width: 16em;

    background-color: var(--card);
    color: var(--text);
    padding: 20px;
    padding-bottom: 60px;
    margin-top: -35px;
    border-radius: 15px;
    box-shadow: var(--nav-shadow);

    .closeBtn {
      padding: 1em;
      position: absolute;
      cursor: pointer;
      inset-inline-end: 1em;
      color: var(--accent);
      font-weight: bold;
      font-size: 1.2em;
    }

    .scrollable {
      margin-top: 1em;
      margin-bottom: 2em;
    }
  }

  #content {
    padding: 0 21px;
    float: none;
    width: 100%;
  }

  .float-btn-container {
    position: fixed;
    bottom: 2em;
    inset-inline-end: 1em;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--float-bg);
    border-radius: 50%;
    box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.5);

    &.show {
      opacity: 0.8;
    }

    button {
      position: absolute;
      background: transparent;
      font-size: 2em;
      border: 0;
      width: 2em;
      height: 2em;
      color: var(--text);
    }

    .icon {
      --icon-width: 0.7em;
      display: inline-block;
      width: 0;
      height: 0;
      border-left: var(--icon-width) solid transparent;
      border-right: var(--icon-width) solid transparent;
      border-bottom: var(--icon-width) solid var(--accent);
    }
  }
}

/* ===================== HAMBURGER ===================== */
.hamburger-menu {
  position: relative;
  width: 2.5rem;
  height: 2.5rem;
  background-color: var(--accent);
  border-radius: 0.25rem;
  cursor: pointer;
  box-shadow: 0.0625rem 0.125rem 0.3125rem rgba(0, 0, 0, 0.4);
}

.hamburger-menu::before,
.hamburger-menu::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 1.5rem;
  height: 0.1875rem;
  background-color: #ffffff;
  border-radius: 0.125rem;
}

.hamburger-menu::before {
  top: 0.75rem;
  box-shadow: 0 0.875rem 0 0 #ffffff;
}

.hamburger-menu::after {
  top: 50%;
  transform: translate(-50%, -50%);
}

@media screen and (max-width: 768px) {
  .hamburger-menu {
    width: 3.5rem;
    height: 3.5rem;
  }

  .hamburger-menu::before,
  .hamburger-menu::after {
    width: 2rem;
    height: 0.45rem;
  }

  .hamburger-menu::before {
    top: 1.225rem;
    box-shadow: 0 0.75rem 0 0 #ffffff;
  }
}

/* ===================== DARK MODE TWEAKS ===================== */
.dark-mode body {
  background-image: var(--page-bg-image);
  background-color: var(--bg);
  color: var(--text);
}

.dark-mode a {
  color: #7dd3fc;
}

.dark-mode #content,
.dark-mode .journal,
.dark-mode #navBar,
.dark-mode .message-from-lord,
.dark-mode .accordion-label,
.dark-mode .float-btn-container,
.dark-mode .right-caret,
.dark-mode .theme-toggle button {
  color: var(--text);
}

.dark-mode #navBar .closeBtn {
  color: var(--accent);
}

.dark-mode .hamburger-menu::before,
.dark-mode .hamburger-menu::after {
  background-color: var(--text);
  box-shadow: 0 0.875rem 0 0 var(--text);
}

.dark-mode .relatedLinks a {
  color: #7dd3fc;
}

.dark-mode .message-from-lord {
  background-color: #1f2937;
  border-color: #7dd3fc;
  color: #e5e7eb;
}

.dark-mode .accordion-toggle[type="checkbox"]:checked~.message-from-lord,
.dark-mode .accordion-toggle[type="checkbox"]:checked~.accordion-content,
.dark-mode .accordion-toggle[type="checkbox"]:checked~.comments.accordion-content {
  border-color: #7dd3fc;
  background-color: #1f2937;
}

.style93 {
  font-size: 24pt;
  line-height: 2.2pc;
  color: var(--accent);
}

.mobile .style93 {
  font-size: 19pt;
}

.style18 {
  /* font-family: Georgia, "Times New Roman", Times, serif; */
  max-height: 999999px;
  font-size: 14pt;
  font-weight: bold;
  line-height: 1.45pc;
}

.style49 {
  font-size: 16pt;
}

.style96 {
  font-size: 18pt;
  line-height: 2.0pc;
  color: var(--accent);
}

.bodystyle {
  color: var(--accent);
}

.dark-mode .bodystyle {
  color: var(--text);
}

.link-preface,
.journal .comments {
  font-size: 10pt;
}

.style0 {
  font-size: 18px;
}

/* there is 1 line for darkmode that will change the color*/
.style39 {
  font-size: 20pt;
  color: var(--accent);
}


.style44,
.style1 {
  color: #990333;
}


.style99 {
  color: #990000;
  font-size: 10pt;
  font-weight: bold;
}

.style98 {
  color: #006600;
  font-size: 10pt;
  font-weight: bold;
}

/* Dark-mode overrides for legacy inline styles */
.dark-mode .style39,
.dark-mode .style18,
.dark-mode .style97,
.dark-mode #masthead h1.style1 {
  color: #6666ff;
  /* brighter blue (from #0000FF) */
}

.dark-mode .style116 {
  color: white;
}

.dark-mode .style44,
.dark-mode .style1 {
  color: #ff4d7a;
  /* brighter red-magenta (from #990333) */
}

.dark-mode .style99 {
  color: #ff4d4d;
  /* brighter red (from #990000) */
}

.dark-mode .style98 {
  color: #33cc33;
  /* brighter green (from #006600) */
}

/* End dark-mode overrides for legacy inline styles */

#content .journal .main-title {
  color: #6666ff;
  /* brighter blue (from #0000FF) */
  font-size: 23pt;
}

/* ===================== RTL OVERRIDES ===================== */
html[dir="rtl"] .right-caret::before {
  border-left: 0;
  border-right: 12px solid var(--accent);
  margin-left: 0;
  margin-right: 0.5em;
}