:root {
    --emerald: #046865;
    --ivory: #F9F6F1;
    --gold: #C6A664;
    --charcoal: #2E2E2E;
    --beige: #E9DFD1;
}



body {
    background: var(--ivory);
    color: var(--charcoal);
    font-family: Arial, Helvetica, sans-serif;
    margin: 0;
    padding: 0;
}



header {
    width: 100%;
    background-image: url('../img/header.png');
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center top;
    aspect-ratio: 6702 / 1909;
    margin: 0;
    padding: 0;
    display: block;
    position: relative;
    min-height: 350px;
    background-color: var(--emerald);
}



.header-overlay {
    position: relative;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    width: 100vw;
    pointer-events: none;
    z-index: 1;
    min-height: 300px;
}



.header-calligraphy {
    display: block;
    margin: 0 auto;
    width: 80vw;
    max-width: 1100px;
    min-width: 400px;
    filter: drop-shadow(0 0 11px rgba(4, 104, 101, 0.8));
    pointer-events: none;
}



/* Desktop-specific calligraphy size */
@media (min-width: 1000px) {
    .header-calligraphy {
        width: 35vw !important;
        max-width: 600px !important;
        min-width: 400px !important;
        height: auto !important;
    }


}



.header-text {
    margin-top: 1.5rem;
    color: var(--ivory);
    font-family: "Baskerville Old Face", serif;
    text-shadow: 0 2px 8px rgba(0,0,0,0.4);
    pointer-events: auto;
}



.header-name-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}



.header-name-wrap h1 {
    font-size: 3.4rem;
    font-weight: 900;
    margin: 0;
    white-space: nowrap;
    color: var(--ivory);
    -webkit-text-stroke: 4px var(--emerald);
    paint-order: stroke fill;
    text-shadow:
        0 0 6px rgba(198, 166, 100, 0.8),
        0 0 12px rgba(4, 104, 101, 0.6);
    letter-spacing: 0.03em;
}



.horizontal-bar {
    flex-grow: 1;
    height: 3px;
    max-width: 120px;
    background-color: var(--gold);
    border-radius: 2px;
    user-select: none;
}


.horizontal-bar1 {
    flex-grow: 1;
    height: 3px;
    max-width: 300px;
    background-color: var(--gold);
    border-radius: 5px;
    user-select: none;
}



.horizontal-bar-topic {
    flex-grow: 1.5;
    height: 4.5px;
    max-width: 450px;
    background-color: var(--gold);
    border-radius: 7px;
    user-select: none;
}



.horizontal-bar-topic-long {
    max-width: 420px;
}



.header-tagline {
    font-weight: 900;
    font-size: 2.3rem;
    letter-spacing: 0.05em;
    color: var(--ivory);
    margin: 0;
    padding: 0 0.5rem;
    text-shadow:
   -1px -1px 0 var(--emerald),
    1px -1px 0 var(--emerald),
   -1px  1px 0 var(--emerald),
    1px  1px 0 var(--emerald),
   -2px  0px 0 var(--emerald),
    2px  0px 0 var(--emerald),
    0px -2px 0 var(--emerald),
    0px  2px 0 var(--emerald);
}


/* NAVIGATION BAR */
.main-navbar {
    position: sticky;
    top: 0;
    width: 100%;
    z-index: 1000;
    font-family: "Baskerville Old Face", Baskerville, "Hoefler Text", Garamond, "Times New Roman", serif;
    box-shadow: 0 4px 16px 0 rgba(0,0,0,0.18), 0 1.5px 0 0 rgba(255,255,255,0.12) inset;
    border-top: none;
    margin: 0;
    padding: 18px 0;
    background-image: url('../img/nav_bar_texture.png');
    background-repeat: repeat;
    background-size: auto;
    overflow: visible;
    position: relative;
}



.main-navbar::before,
.main-navbar::after {
    content: "";
    position: absolute;
    left: 0;
    width: 100%;
    height: 18px;
    background-image: url('../img/border_nav.png');
    background-repeat: repeat-x;
    background-size: auto 100%;
    z-index: 2;
    pointer-events: none;
}



.main-navbar::before {
    top: 0;
}



.main-navbar::after {
    bottom: 0;
}



.nav-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 100vw;
    margin: 0 auto;
    padding: 0 1.5rem;
    gap: 0;
    min-width: 0;
}



.nav-home-wrap {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-right: 1.5rem;
}



.nav-home-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--ivory);
    border: 2px solid var(--gold);
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
    cursor: pointer;
    transition: box-shadow 0.25s, transform 0.25s;
    overflow: hidden;
    margin-bottom: 4px;
}



.nav-home-text {
    font-family: "Baskerville Old Face", serif;
    font-size: 0.9rem;
    color: var(--gold);
    transition: transform 0.25s;
}



.nav-home-icon:hover + .nav-home-text {
    transform: scale(1.1);
}



.nav-home-bg {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: block;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: filter 0.2s;
}



.nav-home-icon:hover,
.nav-home-icon:focus {
    transform: scale(1.12);
    border-color: transparent;
    box-shadow: 0 0 24px 8px #8B5C2A;
    background: var(--ivory);
    z-index: 10;
}



.nav-home-icon:hover .nav-home-bg,
.nav-home-icon:focus .nav-home-bg {
    filter: brightness(1.1);
}



.nav-home-icon::after {
    content: "Home";
    position: absolute;
    bottom: -2.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(34, 34, 34, 0.9);
    color: #fff;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.95rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
    box-shadow: 0 0 8px rgba(139, 92, 42, 0.8);
    z-index: 10000;
    user-select: none;
    visibility: hidden;
}



.nav-home-icon:hover::after,
.nav-home-icon:focus::after {
    opacity: 1;
    visibility: visible;
}



.nav-search-wrap {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-left: 1.5rem;
}



.nav-search-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--ivory);
    border: 2px solid var(--gold);
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
    cursor: pointer;
    transition: box-shadow 0.25s, transform 0.25s;
    overflow: hidden;
    margin-bottom: 4px;
}



.nav-search-text {
    font-family: "Baskerville Old Face", serif;
    font-size: 0.9rem;
    color: var(--gold);
    transition: transform 0.25s;
}



.nav-search-icon:hover + .nav-search-text {
    transform: scale(1.1);
}



.nav-search-bg {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: block;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: filter 0.2s;
}



.nav-search-icon:hover,
.nav-search-icon:focus {
    transform: scale(1.12);
    border-color: transparent;
    box-shadow: 0 0 24px 8px #8B5C2A;
    background: var(--ivory);
    z-index: 10;
}



.nav-search-icon:hover .nav-search-bg,
.nav-search-icon:focus .nav-search-bg {
    filter: brightness(1.1);
}



.nav-search-icon::after {
    content: "Search";
    position: absolute;
    bottom: -2.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(34, 34, 34, 0.9);
    color: #fff;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.95rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
    box-shadow: 0 0 8px rgba(139, 92, 42, 0.8);
    z-index: 10000;
    user-select: none;
    visibility: hidden;
}



.nav-search-icon:hover::after,
.nav-search-icon:focus::after {
    opacity: 1;
    visibility: visible;
}



.nav-topics-wrap {
    flex: 1 1 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem 1.2rem;
    min-width: 0;
    overflow: visible;
}



.nav-topic {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    margin: 4px 0;
}



.nav-topic > a {
    color: var(--ivory);
    text-decoration: none;
    font-size: 1.35rem;
    white-space: nowrap;
    font-family: "Baskerville Old Face", Baskerville, "Hoefler Text", Garamond, "Times New Roman", serif;
    font-weight: bold;
    padding: 8px 10px;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s, text-shadow 0.2s;
}



.nav-topic > a:hover,
.nav-topic:focus {
    color: var(--ivory) !important;
    background: none;
    text-shadow: 0 0 8px #C6A664, 0 0 16px #C6A664 !important;
    text-decoration: none;
    box-shadow: none !important;
    transform: scale(1.08);
}



/* Remove gold underline on hover */
.nav-topic > a:hover::after,
.nav-topic > a:focus::after {
    display: none;
}



.nav-slash {
    color: var(--gold);
    font-size: 1.3rem;
    padding: 0 0.1rem;
    user-select: none;
    font-family: Arial, Helvetica, sans-serif;
    font-weight: normal;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}



.topic-description {
    display: none;
    position: absolute;
    top: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(46, 46, 46, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--ivory);
    padding: 10px 16px;
    border-radius: 12px;
    min-width: 220px;
    text-align: center;
    font-size: 1.0rem;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    font-family: "Baskerville Old Face", serif;
    transition: background 0.3s, color 0.3s;
    border: 1px solid rgba(255, 255, 255, 0.1);
}



.nav-topic:hover .topic-description {
    display: block;
}



/* Add gold glow to the topic name on hover */
.nav-topic:hover > a,
.nav-topic:focus-within > a {
    color: var(--gold);
    text-shadow: 0 0 8px #C6A664, 0 0 16px #C6A664;
    transition: color 0.3s, text-shadow 0.3s;
}



/* Add gold glow to the description on hover (already handled by .topic-description) */

.topic-page-description {
    font-size: 1.8rem;
    color: #FFFFF0;
    line-height: 1.7;
    margin: 1.5rem 0 1rem 0;
    text-align: center;
    word-break: break-word;
    white-space: normal !important;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    font-family: "Baskerville Old Face", serif;
    font-weight: normal;
    overflow: visible !important;
    display: block !important;
}



@media (max-width: 1100px) {
    .nav-topic > a {
        font-size: 1.1rem;
    }


}



@media (max-width: 900px) {
    .nav-flex {
        flex-direction: column;
        align-items: stretch;
    }


    .nav-topics-wrap {
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.5rem 1rem;
    }


    .nav-search-wrap, .nav-home-wrap {
        justify-content: flex-end;
        margin: 0.5rem 0;
    }


}



main {
    margin: 0;
    padding: 0;
    max-width: none;
}



.topics-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
}



.topic-item {
    background: var(--beige);
    border: 2px solid var(--gold);
    padding: 1rem;
    border-radius: 8px;
    transition: box-shadow 0.2s;
    margin-bottom: 1.5rem;
}



.topic-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}



a {
    color: var(--emerald);
    text-decoration: none;
}



a:hover {
    text-decoration: underline;
}



/* Hero image wrapper breaks out of container */
.homepage-hero-image-wrapper {
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    overflow: hidden;
    z-index: 1;
}



/* Hero image full viewport with charcoal overlay */
.homepage-hero-image {
    position: relative;
    width: 100vw;
    height: 100vh;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}



.homepage-hero-image::before {
    content: "";
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.85); /* black overlay */
    pointer-events: none;
    z-index: 1;
}



.hero-frame {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 2;
    pointer-events: none;
    object-fit: fill; /* or 'contain' if you want to preserve aspect ratio */
}



/* Ensure any text/content inside the hero image appears above everything */
.homepage-hero-image > *:not(.hero-frame) {
    position: relative;
    z-index: 3;
}



.hero-welcome-text {
    position: relative;
    z-index: 3;
    color: var(--ivory);
    font-family: "Baskerville Old Face", serif;
    font-weight: 400;
    font-size: 3.3rem; /* Bigger font */
    max-width: 1100px;
    margin: -1.5rem auto 0 auto;
    padding: 1.5rem 3rem 2.5rem 3rem;
    text-align: center;
    line-height: 1.25;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.7);
    box-sizing: border-box;
    user-select: text;
    white-space: normal;
    display: block;
}



@media (max-width: 900px) {
    .hero-welcome-text {
        font-size: 2rem;
        padding: 1.2rem 1rem;
        max-width: 98vw;
    }


}



html, body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}


.header-image {
    position: relative;
    width: 100vw;
    min-height: 220px;
    height: auto;
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
    overflow: hidden;
}

@media (max-width: 700px) {
  /* HOMEPAGE HERO MOBILE STYLES */
  .homepage-hero-image {
    width: 100vw !important;
    height: calc(100vh - 180px) !important;
    min-height: 300px;
    background-size: cover !important;
    background-position: center center !important;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .homepage-hero-image::before {
    background-color: rgba(0, 0, 0, 0.7);
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    pointer-events: none;
  }
  .hero-frame {
    display: none !important;
  }
  .hero-welcome-text {
    position: relative;
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    font-size: 1.5rem;
    line-height: 1.7;
    text-align: center;
    z-index: 2;
    color: var(--ivory);
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
  }

  .header-image {
    min-height: 170px ;
    max-height: 200px ;
    background-size: contain ;
    background-position: top center ;
  }

  /* HOMEPAGE HERO MOBILE STYLES */
  .homepage-hero-image {
    width: 100%;
    height: calc(100vh - 180px);
    min-height: 300px;
    background-size: cover;
    background-position: center;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .homepage-hero-image::before {
    background-color: rgba(0, 0, 0, 0.5);
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
  }
  .hero-frame {
    display: none !important;
  }
  .hero-welcome-text {
    position: relative;
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.5;
    text-align: center;
    z-index: 2;
    color: white;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
  }

  .header-image {
    min-height: 170px ;
    max-height: 200px ;
    background-size: cover ;
    background-position: center center ;
  }
}


@media (max-width: 700px) {
  /* HOMEPAGE HERO MOBILE STYLES */
  .homepage-hero-image {
    width: vw !important;
    height: calc(100vh - 1000px) !important;
    min-height: 400px;
    background-size: cover !important;
  
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .homepage-hero-image::before {
    background-color: rgba(0, 0, 0, 0.7);
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    pointer-events: none;
  }
  .hero-frame {
    display: none !important;
  }
  .hero-welcome-text {
    position: relative;
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    font-size: 1.5rem;
    line-height: 1.7;
    text-align: center;
    z-index: 2;
    color: var(--ivory);
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
  }

  .header-image {
    min-height: 1000px ;
    max-height: 1000px ;
    background-size: contain ;
    background-position: center ;
  }

  /* HOMEPAGE HERO MOBILE STYLES */
  .homepage-hero-image {
    width: 100%;
    height: calc(100vh - 180px);
    min-height: 300px;
    background-size: cover;
    background-position: center;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .homepage-hero-image::before {
    background-color: rgba(0, 0, 0, 0.5);
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
  }
  .hero-frame {
    display: none !important;
  }
  .hero-welcome-text {
    position: relative;
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.5;
    text-align: center;
    z-index: 2;
    color: white;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
  }

    .header-image {
        min-height: 100vw;
        height: 10vw ;
        background-size: auto;
        background-position: center;
    }


}



.discord-join-wrapper {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    z-index: 10000;
    user-select: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: auto;
}


@media (max-width: 700px) {
  /* HOMEPAGE HERO MOBILE STYLES */
  .homepage-hero-image {
    width: 100vw !important;
    height: calc(100vh - 180px) !important;
    min-height: 300px;
    background-size: cover !important;
    background-position: center center !important;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .homepage-hero-image::before {
    background-color: rgba(0, 0, 0, 0.7);
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    pointer-events: none;
  }
  .hero-frame {
    display: none !important;
  }
  .hero-welcome-text {
    position: relative;
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    font-size: 1.5rem;
    line-height: 1.7;
    text-align: center;
    z-index: 2;
    color: var(--ivory);
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
  }

  .header-image {
    min-height: 120px ;
    max-height: 170px ;
    background-size: contain ;
    background-position: top center;
  }

  /* HOMEPAGE HERO MOBILE STYLES */
  .homepage-hero-image {
    width: 100vw !important;
    height: 100vh !important;
    background-size: cover !important;
    background-position: center center !important;
    position: relative;
  }
  .homepage-hero-image::before {
    background-color: rgba(0, 0, 0, 0.5);
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
  }
  .hero-frame {
    display: none !important;
  }
  .hero-welcome-text {
    position: relative;
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.5;
    text-align: center;
    z-index: 2;
    color: white;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
  }

    .discord-join-wrapper {
        top: 1.2rem;
        right: 0.5rem;
        z-index: 9990; /* Lower z-index to be below loading overlay */
    }


    .discord-join-wrapper .discord-join-link img.discord-logo {
        width: 24px !important;
        height: 24px !important;
        margin-bottom: 0.15rem !important;
        object-fit: contain;
    }


    .discord-text {
        font-size: 0.48rem;
    }


    .discord-join-link {
        font-size: 0.48rem;
        padding: 0.01rem 0.05rem;
        margin-top: -0.2rem;
        margin-right: 0.3rem;
    }


   


    .header-text {
        margin: 0.02rem 0 0 !important;
        line-height: 1.04;
    }


   


   


}



.discord-join-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--charcoal);
    font-family: "Baskerville Old Face", serif;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.3s ease;
    position: relative;
}



.discord-logo {
    width: 44px;
    height: 44px;
    margin-bottom: 0.4rem;
    transition: inherit;
    position: relative;
    z-index: 10001;
}



.discord-text {
    transition: inherit;
    position: relative;
    z-index: 9995;
    white-space: nowrap;
}



.discord-join-link:hover,
.discord-join-link:focus {
    transform: scale(1.1);
    outline: none;
}



.discord-join-link:hover .discord-logo {
    transform: scale(1.1);
}



/* Removing all popup-related styles */

/* Topics Page Layout */
.topics-container {
    position: relative;
    min-height: 90vh;
    padding: 2rem;
    background-color: rgba(249, 246, 241, 0.85);
    backdrop-filter: blur(5px);
}



.topic-page-title {
    text-align: center;
    font-family: "Baskerville Old Face", serif;
    font-size: 3rem;
    color: var(--emerald);
    margin: 2rem 0 2rem 0;
    padding: 1rem;
    position: relative;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}



.topic-page-title::after {
    content: '';
    display: block;
    width: 150px;
    height: 3px;
    background: var(--gold);
    margin: 1rem auto;
    border-radius: 2px;
}



/* Space for background image */
.topics-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-image: url('../img/topics-background.jpg'); /* Add your image here */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    opacity: 0.15; /* Adjust this value to control image visibility */
    filter: grayscale(20%); /* Optional: adds a subtle grayscale effect */
}



.topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
}



.topic-card {
    background: var(--ivory);
    border: 2px solid var(--gold);
    border-radius: 12px;
    padding: 1.5rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}



.topic-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}



.topic-header {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--gold);
}



.topic-icon {
    width: 40px;
    height: 40px;
    margin-right: 1rem;
    /* Icon image will be added here */
    /* background-image: url('../img/topic-icon.png'); */
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}



.topic-title-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}



.topic-title {
    font-family: "Baskerville Old Face", serif;
    font-size: 2.5rem;
    color: var(--gold);
    margin: 0;
    text-align: center;
    white-space: normal;
}



.topic-title-wrap.topic-title-gap-tight {
    margin-bottom: 0rem !important;
}



.subtopics-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 per row on desktop */
    gap: 3rem 5rem;
    justify-items: center; /* Center grid items horizontally */
    align-items: stretch;
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
    padding: 0;
    list-style: none;
}



.subtopic-item {
    min-width: 0;
    max-width: 100%;
    padding: 2rem 1.5rem;
    border-radius: 10px;
    transition: transform 0.3s ease;
    text-align: center;
    background: none;
    flex: unset;
    margin: 0 auto 1.5rem auto; /* Ensure individual items are centered if needed */
}



.subtopic-item:hover {
    transform: translateY(-3px);
    background: none;
}



.subtopic-link {
    color: var(--gold);
    text-decoration: none;
    font-size: 2rem;
    display: block;
    transition: color 0.3s ease;
    margin-bottom: 0.8rem;
    font-family: "Baskerville Old Face", serif;
    opacity: 0.9;
}



.subtopic-link:hover {
    color: var(--gold);
    opacity: 1;
    text-shadow: 0 0 8px rgba(198, 166, 100, 0.4);
}



/* Responsive adjustments */
@media (max-width: 1100px) {
    .subtopics-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem 2rem;
        justify-items: center; /* Ensure centering on smaller screens */
    }
}


@media (max-width: 700px) {
  /* HOMEPAGE HERO MOBILE STYLES */
  .homepage-hero-image {
    width: 100vw !important;
    height: calc(100vh - 180px) !important;
    min-height: 300px;
    background-size: cover !important;
    background-position: center center !important;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .homepage-hero-image::before {
    background-color: rgba(0, 0, 0, 0.7);
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    pointer-events: none;
  }
  .hero-frame {
    display: none !important;
  }
  .hero-welcome-text {
    position: relative;
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    font-size: 1.5rem;
    line-height: 1.7;
    text-align: center;
    z-index: 2;
    color: var(--ivory);
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
  }

  .header-image {
    min-height: 120px ;
    max-height: 170px ;
    background-size: contain ;
    background-position: top center ;
  }

  /* HOMEPAGE HERO MOBILE STYLES */
  .homepage-hero-image {
    width: 100vw !important;
    height: 100vh !important;
    background-size: cover !important;
    background-position: center center !important;
    position: relative;
  }
  .homepage-hero-image::before {
    background-color: rgba(0, 0, 0, 0.5);
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
  }
  .hero-frame {
    display: none !important;
  }
  .hero-welcome-text {
    position: relative;
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.5;
    text-align: center;
    z-index: 2;
    color: white;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
  }

  .subtopics-list {
    grid-template-columns: 1fr;
    gap: 1.2rem 0.5rem;
    justify-items: center; /* Ensure centering on very small screens */
  }
}


@media (max-width: 480px) {
    .topics-container {
        padding: 1rem;
    }



    .topics-grid {
        grid-template-columns: 1fr;
    }


}


@media (max-width: 600px) {
    .subtopic-container {
      background-size: 40vw auto !important; /* Fewer, bigger tiles on small screens */
    }


  }



.subtopic-container {
    padding: 2rem;
    margin: 0;
    min-height: calc(100vh - 350px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}



.subtopic-content {
    max-width: 1200px;
    width: 100%;
    text-align: left;
    padding: 2rem;
}



.subtopics-heading {
    font-family: "Baskerville Old Face", serif;
    font-size: 1.8rem;
    color: var(--emerald);
    margin: 2rem 0 1.5rem 0;
    text-align: center;
}



.topic-banner-image {
    display: block;
    width: 100%;
    max-width: 1600px;
    min-width: 0;
    margin: 0 auto 2.5rem auto;
    border-radius: 20px;
    object-fit: contain;
    background: transparent;
}



@media (max-width: 600px) {
    .topic-banner-image {
        width: 100vw;
        max-width: 100vw;
        min-width: 0;
        margin: 1.2rem 0;
        border-radius: 12px;
    }


}



.subtopic-preview {
    font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
    color: var(--ivory);
    font-size: 1.25rem;
    margin: 1.2rem 0 0.7rem 0;
    min-height: 3.5em;
    line-height: 1.5;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 10;
    -webkit-box-orient: vertical;
}


.subtopic-main-content {
    font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
    color: var(--ivory);
    font-size: 1.25rem;
    margin: 1.2rem 0 0.7rem 0;
    line-height: 1.5;
    text-align: left;
}


.subtopic-image {
    max-width: 120px;
    max-height: 120px;
    display: block;
    margin: 0 auto 1rem auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    object-fit: cover;
  }


  

.continue-reading {
    text-align: left;
    margin-top: 0.5rem;
}



.continue-reading a {
    color: var(--gold);
    font-family: "Baskerville Old Face", serif;
    font-size: 1.25rem;
    text-decoration: none;
    transition: color 0.2s;
}



.continue-reading a:hover {
    color: var(--emerald);
    text-decoration: underline;
}



.subtopic-item {
    cursor: pointer;
    margin-bottom: 1.5rem;
    margin-top: 1.5rem;
    transition: box-shadow 0.2s, background 0.2s;
}



.subtopic-item:hover {
    box-shadow: 0 2px 16px rgba(198, 166, 100, 0.15);
    background: rgba(198, 166, 100, 0.04);
}



.subtopic-link {
    pointer-events: none;
}



.subtopic-divider {
    display: block;
    width: 95%;
    max-width: 320px;
    margin: 1.2rem auto 1.2rem auto;
    opacity: 0.85;
}



.topic-hierarchy-name {
  font-size: 1.7rem;
  font-family: "Baskerville Old Face", serif;
  font-weight: bold;
  color: var(--gold);
  padding: 0 0.5rem;
  white-space: nowrap;
  transition: color 0.2s, text-shadow 0.2s;
}



.subtopic-background {
  background-image: url('/static/library/img/subtopic_background.png');
  background-repeat: repeat;
  background-size: 20vw auto;
}



.topic-link-prominent {
  color: var(--gold) !important;
  font-size: 2.7rem;
  font-family: "Baskerville Old Face", serif;
  font-weight: bold;
  margin: 0 1.2rem;
  text-align: center;
  transition: color 0.2s, transform 0.2s;
  line-height: 1.1;
  text-decoration: none !important;
}


.topic-link-prominent:hover, .topic-link-prominent:focus {
  color: var(--gold) !important;
  text-decoration: none !important;
  transform: scale(1.07);
  text-shadow: 0 0 2px #C6A664, 0 0 4px #C6A664;
}



.prominent-topic-title {
  display: flex;
  align-items: center;
  justify-content: center;
}



.content-images {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    margin: 2rem 0;
    justify-content: center;
}



.content-image-container {
    max-width: 500px;
    margin: 0 auto;
}



.content-image {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s ease;
}



.content-image:hover {
    transform: scale(1.02);
}



.image-caption {
    margin-top: 0.8rem;
    font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
    color: var(--ivory);
    font-size: 1.1rem;
    text-align: center;
    font-style: italic;
}



/* Lightbox styles */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    cursor: pointer;
    justify-content: center;
    align-items: center;
}



.lightbox-content {
    position: relative;
    max-width: 95%;
    max-height: 95%;
    margin: auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}



.lightbox-image {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}



.lightbox-caption {
    color: var(--ivory);
    font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
    font-size: 1.2rem;
    margin-top: 1rem;
    text-align: center;
    padding: 0 1rem;
}



.content-image {
    cursor: pointer;
}



.reference-block {
    border-left: 5px solid #666;
    margin: 1.2rem 2.5rem 1.2rem 2.5rem;
    padding: 0.7rem 1.2rem;
    font-style: italic;
    background: none;
    color: inherit;
    font-family: inherit;
    font-size: 1.15em;
    line-height: 1.6;
}



.ai-result-card {
  background: rgba(0,0,0,0.7);
  border-radius: 1.2rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
  padding: 2rem 2.2rem 1.2rem 2.2rem;
  margin: 0 auto 2.5rem auto; /* Center individual items and add bottom margin */
  color: var(--ivory, #FFFFF0);
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
  max-width: 600px;
  position: relative;
  border: 2px solid var(--gold);
}


.ai-result-title {
  color: #C6A664;
  font-size: 1.35rem;
  font-family: inherit;
  font-weight: bold;
  margin-bottom: 1.1rem;
  text-align: center;
}


.ai-result-link {
  display: block;
  color: #C6A664;
  font-size: 1.1rem;
  text-align: right;
  margin-top: 1.2rem;
  text-decoration: none;
  font-family: inherit;
  font-style: italic;
  transition: color 0.2s;
}


.ai-result-link:hover {
  color: #bfa14a;
  text-decoration: underline;
}



.ai-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 2.2rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 0;
  justify-items: center; /* Center grid items horizontally */
}



#ai-search-results .subtopic-link {
  pointer-events: auto;
}



.ai-results-heading {
  color: var(--gold);
  text-align: center;
  font-family: 'Baskerville Old Face', serif;
  font-size: 2.7rem;
  font-weight: bold;
  margin-bottom: 2.2rem;
  letter-spacing: 1px;
  text-shadow: 0 0 8px rgba(198, 166, 100, 0.18);
  line-height: 1.1;
}



/* Responsive base font size */
html {
  font-size: 18px;
}


@media (max-width: 900px) {
  html {
    font-size: 16px;
  }


  .subtopic-content, .topics-container {
    padding: 1rem;
  }


}


@media (max-width: 600px) {
  html {
    font-size: 15px;
  }


  .subtopic-content, .topics-container {
    padding: 0.5rem;
  }


}



/* Headings and Titles */
.topic-title, .ai-results-heading {
  font-size: 2.5rem;
}


@media (max-width: 900px) {
  .topic-title, .ai-results-heading {
    font-size: 2rem;
  }


}


@media (max-width: 600px) {
  .topic-title, .ai-results-heading {
    font-size: 2rem;
  }


}



/* Subtopic Grid and Cards */
.subtopics-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* 2 per row on desktop */
  gap: 3rem 5rem;
  justify-items: center; /* Center grid items horizontally */
  align-items: stretch;
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
  padding: 0;
  list-style: none;
}


@media (max-width: 1100px) {
  .subtopics-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem 2rem;
    justify-items: center; /* Ensure centering on smaller screens */
  }
}


@media (max-width: 700px) {
  /* HOMEPAGE HERO MOBILE STYLES */
  .homepage-hero-image {
    width: 100vw !important;
    height: calc(100vh - 180px) !important;
    min-height: 300px;
    background-size: cover !important;
    background-position: center center !important;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .homepage-hero-image::before {
    background-color: rgba(0, 0, 0, 0.7);
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    pointer-events: none;
  }
  .hero-frame {
    display: none !important;
  }
  .hero-welcome-text {
    position: relative;
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    font-size: 1.5rem;
    line-height: 1.7;
    text-align: center;
    z-index: 2;
    color: var(--ivory);
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
  }

  .header-image {
    min-height: 120px ;
    max-height: 170px ;
    background-size: contain ;
    background-position: top center ;
  }

  /* HOMEPAGE HERO MOBILE STYLES */
  .homepage-hero-image {
    width: 100vw !important;
    height: 100vh !important;
    background-size: cover !important;
    background-position: center center !important;
    position: relative;
  }
  .homepage-hero-image::before {
    background-color: rgba(0, 0, 0, 0.5);
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
  }
  .hero-frame {
    display: none !important;
  }
  .hero-welcome-text {
    position: relative;
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.5;
    text-align: center;
    z-index: 2;
    color: white;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
  }

  .subtopics-list {
    grid-template-columns: 1fr;
    gap: 1.2rem 0.5rem;
    justify-items: center; /* Ensure centering on very small screens */
  }
}


.subtopic-item {
  padding: 2rem 1.5rem;
  margin: 0 auto 1.5rem auto; /* Ensure individual items are centered if needed */
}


@media (max-width: 600px) {
  .subtopic-item {
    padding: 1rem 0.5rem;
    margin: 0 auto 1.5rem auto; /* Ensure individual items are centered on small screens */
  }
}



/* Image Responsiveness */
.content-image, .subtopic-image, .topic-banner-image {
  max-width: 100%;
  height: auto;
}


@media (max-width: 600px) {
  .content-image, .subtopic-image, .topic-banner-image {
    max-width: 95vw;
    height: auto;
  }


}



/* Font Sizes for Text Blocks */
.subtopic-link {
  font-size: 2rem;
}


.subtopic-preview, .subtopic-main-content, .image-caption {
  font-size: 1.25rem;
}


@media (max-width: 900px) {
  .subtopic-link {
    font-size: 1.3rem;
  }


  .subtopic-preview, .subtopic-main-content, .image-caption {
    font-size: 1.1rem;
  }


}


@media (max-width: 600px) {
  .subtopic-link {
    font-size: 1.1rem;
  }


  .subtopic-preview, .subtopic-main-content, .image-caption {
    font-size: 1rem;
  }


}



/* Navbar and Buttons */
.main-navbar {
  padding: 18px 0;
}


@media (max-width: 900px) {
  .main-navbar {
    padding: 10px 0;
  }


}


button, input[type='submit'] {
  font-size: 1.1rem;
  padding: 0.7rem 1.5rem;
}


@media (max-width: 600px) {
  button, input[type='submit'] {
    font-size: 1rem;
    padding: 0.5rem 1rem;
  }


}



/* General Spacing */
@media (max-width: 600px) {
  .subtopic-container, .topics-container {
    padding: 0.5rem !important;
  }


  .subtopic-content {
    padding: 0.5rem !important;
  }


}



/* Lightbox and Modal */
.lightbox-content {
  max-width: 98vw;
  max-height: 98vh;
}


.lightbox-image {
  max-width: 95vw;
  max-height: 80vh;
}



/* Header text and tagline: scale for mobile */
.header-text {
  margin-top: 1.2rem;
}



/* Mobile Top Bar Styles */

/* --- Mobile Header Top Override --- */
@media (max-width: 700px) {
  /* HOMEPAGE HERO MOBILE STYLES */
  .homepage-hero-image {
    width: 100vw !important;
    height: calc(100vh - 180px) !important;
    min-height: 300px;
    background-size: cover !important;
    background-position: center center !important;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .homepage-hero-image::before {
    background-color: rgba(0, 0, 0, 0.7);
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    pointer-events: none;
  }
  .hero-frame {
    display: none !important;
  }
  .hero-welcome-text {
    position: relative;
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    font-size: 1.5rem;
    line-height: 1.7;
    text-align: center;
    z-index: 2;
    color: var(--ivory);
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
  }

  .header-image {
    min-height: 120px ;
    max-height: 170px ;
    background-size: contain ;
    background-position: top center ;
  }

  /* HOMEPAGE HERO MOBILE STYLES */
  .homepage-hero-image {
    width: 100vw !important;
    height: 100vh !important;
    background-size: cover !important;
    background-position: center center !important;
    position: relative;
  }
  .homepage-hero-image::before {
    background-color: rgba(0, 0, 0, 0.5);
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
  }
  .hero-frame {
    display: none !important;
  }
  .hero-welcome-text {
    position: relative;
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.5;
    text-align: center;
    z-index: 2;
    color: white;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
  }

  header {
    min-height: unset !important;
    aspect-ratio: unset !important;
    height: auto !important;
    padding: 0.5rem 0 !important;
  }


  .header-overlay {
    position: static !important;
    transform: none !important;
    top: 0 !important;
    min-height: unset !important;
    padding: 0 !important;
    width: 100% !important;
    left: 0 !important;
  }


  


  .header-text {
    margin: 0 !important;
    padding: 0 !important;
  }


  


  .discord-join-wrapper {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
  }


}



@media (max-width: 700px) {
  /* HOMEPAGE HERO MOBILE STYLES */
  .homepage-hero-image {
    width: 100vw !important;
    height: calc(100vh - 180px) !important;
    min-height: 300px;
    background-size: cover !important;
    background-position: center center !important;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .homepage-hero-image::before {
    background-color: rgba(0, 0, 0, 0.7);
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    pointer-events: none;
  }
  .hero-frame {
    display: none !important;
  }
  .hero-welcome-text {
    position: relative;
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    font-size: 1.5rem;
    line-height: 1.7;
    text-align: center;
    z-index: 2;
    color: var(--ivory);
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
  }

  .header-image {
    min-height: 120px;
    max-height: 170px ;
    background-size: contain ;
    background-position: top center ;
  }

  /* HOMEPAGE HERO MOBILE STYLES */
  .homepage-hero-image {
    width: 100vw !important;
    height: 100vh !important;
    background-size: cover !important;
    background-position: center center !important;
    position: relative;
  }
  .homepage-hero-image::before {
    background-color: rgba(0, 0, 0, 0.5);
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
  }
  .hero-frame {
    display: none !important;
  }
  .hero-welcome-text {
    position: relative;
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.5;
    text-align: center;
    z-index: 2;
    color: white;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
  }

  .main-navbar .nav-flex,
  .main-navbar .nav-topics-wrap,
  .main-navbar .nav-home-wrap,
  .main-navbar .nav-search-wrap {
    display: none !important;
  }


  .main-navbar::before {
    height: 18px;
    z-index: 3000;
    display: block;
  }


  .main-navbar::after {
    display: none !important;
  }


  .main-navbar {
    overflow: visible !important;
    margin-bottom: 0;
    padding: 0;
    background: var(--emerald);
    background-image: url('../img/nav_bar_texture.png');
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: none;
    min-height: 0;
    height: auto;
  }


  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background: var(--emerald);
    padding: 0.8rem 1rem;
    position: sticky;
    top: 0;
    z-index: 2000;
    width: 100%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-bottom: 2px solid var(--gold);
    gap: 1.2rem;
    min-height: 4.5rem;
  }


}


@media (min-width: 701px) {
  .mobile-topbar, .mobile-topics-dropdown {
    display: none !important;
  }


}



@media (max-width: 700px) {
  /* HOMEPAGE HERO MOBILE STYLES */
  .homepage-hero-image {
    width: 100vw !important;
    height: calc(100vh - 180px) !important;
    min-height: 300px;
    background-size: cover !important;
    background-position: center center !important;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .homepage-hero-image::before {
    background-color: rgba(0, 0, 0, 0.7);
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    pointer-events: none;
  }
  .hero-frame {
    display: none !important;
  }
  .hero-welcome-text {
    position: relative;
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    font-size: 1.5rem;
    line-height: 1.7;
    text-align: center;
    z-index: 2;
    color: var(--ivory);
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
  }

  .header-image {
    min-height: 120px ;
    max-height: 170px ;
    background-size: contain ;
    background-position: top center;
  }

  /* HOMEPAGE HERO MOBILE STYLES */
  .homepage-hero-image {
    width: 100vw !important;
    height: 100vh !important;
    background-size: cover !important;
    background-position: center center !important;
    position: relative;
  }
  .homepage-hero-image::before {
    background-color: rgba(0, 0, 0, 0.5);
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
  }
  .hero-frame {
    display: none !important;
  }
  .hero-welcome-text {
    position: relative;
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.5;
    text-align: center;
    z-index: 2;
    color: white;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
  }

  .nav-flex {
    display: none !important;
  }


  .mobile-navbar {
    display: block;
    position: relative;
    width: 100vw;
    background: var(--emerald);
    background-image: url('../img/nav_bar_texture.png');
    background-repeat: repeat;
    z-index: 2000;
  }


  .mobile-navbar-border {
    width: 100vw;
    height: 18px;
    background-image: url('../img/border_nav.png');
    background-repeat: repeat-x;
    background-size: auto 100%;
  }


  .mobile-navbar-border-top {
    position: absolute;
    top: 0;
    left: 0;
  }


  .mobile-navbar-border-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
  }


  .mobile-navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 26px 0 24px 0;
    position: relative;
    z-index: 2;
  }


  .mobile-navbar-side {
    width: 33%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
  }


  .mobile-navbar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--gold);
    font-family: "Baskerville Old Face", serif;
    font-size: 1.1rem;
    background: none;
    border: none;
    cursor: pointer;
  }


  .mobile-navbar-icon {
    width: 44px;
    height: 44px;
    margin-bottom: 0.18rem;
    border-radius: 50%;
    background: var(--ivory);
    border: 2px solid var(--gold);
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
    object-fit: cover;
  }


  .mobile-navbar-label {
    font-size: 1.1rem;
    color: var(--gold);
    margin-top: 0.1rem;
    text-align: center;
  }


  .mobile-navbar-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: row;
    gap: 0;
    width: 34%;
    position: relative;
    text-align: center;
    height: 100%;
  }


  .mobile-navbar-symbol {
    color: var(--gold);
    font-size: 1.8rem;
    font-family: Arial, serif;
    font-weight: bold;
    margin: 0 0.05rem;
    user-select: none;
    position: relative;
    top: -2px; /* Move symbols up slightly for better visual alignment */
  }


  .mobile-navbar-topics-btn {
    background: none;
    border: none;
    color: var(--ivory);
    font-family: "Baskerville Old Face", serif;
    font-size: 2.2rem;
    font-weight: bold;
    cursor: pointer;
    padding: 0.2rem 1.2rem;
    border-radius: 6px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    height: auto;
    line-height: normal;
    position: relative;
    top: -4px;
  }


  .mobile-navbar-topics-btn:active, .mobile-navbar-topics-btn:focus {
    background: rgba(198,166,100,0.08);
  }


  .mobile-navbar-dropdown {
    display: none;
    position: absolute;
    left: 50%;
    top: 2.2rem;
    transform: translateX(-50%);
    min-width: 160px;
    background: var(--emerald);
    border: 2px solid var(--gold);
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.10);
    z-index: 10000;
    padding: 0.5rem 0;
    max-height: 60vh;
    overflow-y: auto;
    flex-direction: column;
    align-items: stretch;
  }


  .mobile-navbar-dropdown.open {
    display: flex;
  }


  .mobile-navbar-dropdown a {
    display: block;
    color: var(--ivory);
    font-family: "Baskerville Old Face", serif;
    font-size: 1.1rem;
    padding: 0.7rem 1.2rem;
    text-decoration: none;
    border-bottom: 1px solid rgba(198,166,100,0.13);
    transition: background 0.18s, color 0.18s;
    text-align: center;
  }


  .mobile-navbar-dropdown a:last-child {
    border-bottom: none;
  }


  .mobile-navbar-dropdown a:hover, .mobile-navbar-dropdown a:focus {
    background: rgba(198,166,100,0.10);
    color: var(--ivory);
  }


  .mobile-navbar-side.mobile-navbar-home {
    align-items: flex-start;
    padding-left: 0.7rem;
  }


  .mobile-navbar-side.mobile-navbar-ai {
    align-items: flex-end;
    padding-right: 0.7rem;
  }


  .mobile-navbar-label {
    font-size: 0.85rem;
  }


  .mobile-navbar-dropdown {
    background: var(--emerald);
    background-image: url('../img/nav_bar_texture.png');
    background-repeat: repeat;
    border: 2px solid var(--gold);
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.10);
    z-index: 10000;
    padding: 0.5rem 0;
    max-height: 60vh;
    overflow-y: auto;
    flex-direction: column;
    align-items: stretch;
  }


}


@media (min-width: 701px) {
  .mobile-navbar {
    display: none !important;
  }


}


@media (max-width: 700px) {
  /* HOMEPAGE HERO MOBILE STYLES */
  .homepage-hero-image {
    width: 100vw !important;
    height: calc(100vh - 180px) !important;
    min-height: 300px;
    background-size: cover !important;
    background-position: center center !important;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .homepage-hero-image::before {
    background-color: rgba(0, 0, 0, 0.7);
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    pointer-events: none;
  }
  .hero-frame {
    display: none !important;
  }
  .hero-welcome-text {
    position: relative;
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    font-size: 1.5rem;
    line-height: 1.7;
    text-align: center;
    z-index: 2;
    color: var(--ivory);
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
  }

  .header-image {
    height: 100px !important;
    min-height: 170px !important;
    max-height: 500px !important;
    background-size: 175% !important;
    background-position: center !important;
  
  }

  /* Increase header text and calligraphy size for mobile */
  
 

  /* HOMEPAGE HERO MOBILE STYLES */
  .homepage-hero-image {
    width: 100vw !important;
    height: 61.5vh !important;
    background-size: cover !important;
    background-position: center !important;
    position: relative;
  }
  .homepage-hero-image::before {
    background-color: rgba(0, 0, 0, 0.8);
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
  }
  .hero-frame {
    display: none !important;
  }
  .hero-welcome-text {
    position: relative;
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.5;
    text-align: center;
    z-index: 2;
    color: white;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
  }

  /* Preserve aspect ratio for content images below navbar on mobile */
  .main-content img:not(.nav-home-icon):not(.nav-search-icon),
  .home-content img:not(.nav-home-icon):not(.nav-search-icon),
  .content img:not(.nav-home-icon):not(.nav-search-icon) {
    width: auto !important;
    max-width: 100% !important;
    height: auto !important;
    object-fit: contain !important;
    display: block;
    margin-left: auto;
    margin-right: auto;
  }

  /* Mobile header calligraphy */


  body, header, .header-overlay, .header-text, .header-name-wrap, .header-name-wrap h1, .header-tagline {
    margin: 0 !important;
    padding: 0 !important;
  }
  header {
    min-height: 110px !important;
    aspect-ratio: unset !important;
    height: auto !important;
    background-position: center top !important;
  }
  .header-overlay {
    position: static !important;
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
    width: 100% !important;
    min-height: unset !important;
    text-align: center !important;
    z-index: 1;
  }
 
  .header-text {
    margin: 0 !important;
    padding: 0 !important;
  }
  
  
}

/* --- Mobile Header Top Override (Consolidated) --- */
@media (max-width: 700px) {
  .header-calligraphy {
    width: 57vw !important;
    min-width: 100px !important;
    max-width: 400px !important;
    height: auto !important;
    display: block !important;
    margin-top: 1.5rem !important;
    margin-bottom: 0.5rem !important;
    /* margin: 0 auto 0rem auto !important; */
    padding: 0 !important;
    vertical-align: top !important;
  }
  .header-text h1,
  .header-name-wrap h1 {
    font-size: 2.0rem !important;
    line-height: 1.2 !important;
    margin: 0 !important;
  }
  .header-tagline {
    font-size: 1.25rem !important;
    margin: 0.2rem 0 0 !important;
    line-height: 1.2 !important;
  }
}

/* Remove or comment out other .header-calligraphy, .header-text h1, .header-name-wrap h1, .header-tagline rules in other mobile media queries to avoid conflicts. */

@media (max-width: 700px) {
  .mobile-banner-top,
  .mobile-banner-bottom {
    display: block;
    width: 80%;
    max-width: 350px;
    margin: 0 auto;
    position: static;
    z-index: 2;
    pointer-events: none;
  }
  .mobile-banner-top {
    margin-bottom: 0;
  }
  .mobile-banner-bottom {
    margin-top: 0;
  }
  .hero-welcome-text {
    margin-top: 0;
    margin-bottom: 0;
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
  }
}
@media (min-width: 701px) {
  .mobile-banner-top,
  .mobile-banner-bottom {
    display: none !important;
  }
}

@media (max-width: 700px) {
  .hero-welcome-container {
    width: 95%;
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
  }
  .mobile-banner-top,
  .mobile-banner-bottom {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    margin: 0;
    position: static;
    z-index: 2;
    pointer-events: none;
  }
  .hero-welcome-text {
    text-align: center;
    font-size: 1.35rem;
    line-height: 1.5;
    padding: 0.4rem 0;
  }
}
@media (min-width: 701px) {
  .mobile-banner-top,
  .mobile-banner-bottom {
    display: none !important;
  }
}

@media (max-width: 700px) {
  .hero-welcome-text {
    text-align: center;
  }
}

@media (max-width: 700px) {
  /* ... other existing 700px rules ... */

  /* --- Topic Detail Page Mobile Styles --- */
  .topic-page-title {
    font-size: 2.2rem !important;
    margin-top: 1.5rem !important;
    margin-bottom: 1rem !important;
    padding: 0.5rem 0.5rem !important;
    line-height: 1.2 !important;
  }

  .topic-page-title::after { /* The gold bar under the title */
    width: 100px !important;
    margin-top: 0.8rem !important;
    margin-bottom: 1rem !important;
  }

  .topic-page-description {
    font-size: 1.1rem !important;
    line-height: 1.6 !important;
    padding: 0 1rem !important;
    margin-bottom: 2rem !important;
  }

  .subtopics-list .subtopic-item {
    padding: 1.5rem 1rem !important;
  }

  .subtopics-list {
    gap: 1rem 0 !important;
  }

  .topics-container { 
    padding: 1.5rem 1rem !important;
  }
  
  .subtopic-link {
    font-size: 2rem !important;
    margin-bottom: 0.5rem !important;
  }

  .topic-banner-image { /* If used on this page */
    margin-left: auto !important;
    margin-right: auto !important;
    width: 95vw !important;
    max-width: 100% !important;
    border-radius: 10px !important;
  }

  /* ... ensure this is within the main @media (max-width: 700px) block ... */
}

/* AI Search Page Mobile Styles */
@media (max-width: 700px) {
  /* Search form styles */
  #ai-search-form {
    flex-direction: row !important;
    gap: 0.5rem !important;
    padding: 0 0.2rem !important;
    max-width: 100vw !important;
  }
  #ai-search-input {
    font-size: 0.95rem !important;
    padding: 0.6rem 0.8rem !important;
    min-width: 0 !important;
    width: 65% !important;
    max-width: 70vw !important;
  }
  #ai-search-form button {
    font-size: 0.95rem !important;
    padding: 0.6rem 0.8rem !important;
    width: 35% !important;
    min-width: 80px !important;
    max-width: 120px !important;
    white-space: nowrap;
  }

  /* --- Top text with images: smaller images, left/right alignment --- */
  .topic-title-wrap {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.3rem !important;
    margin-bottom: 0.5rem !important;
  }
  .topic-title-wrap img {
    height: 1.6rem !important;
    min-width: 18px !important;
    max-width: 30px !important;
    margin: 0 0.1rem !important;
    vertical-align: middle !important;
  }
  .topic-link-prominent, .topic-title {
    font-size: 1.2rem !important;
    margin: 0 0.2rem !important;
    line-height: 1.2 !important;
    white-space: normal !important;
  }
}

@media (max-width: 700px) {
  /* ...existing mobile styles... */

  /* Make the first two .topic-title-wrap blocks on AI search page much larger */
  .subtopic-content > .topic-title-wrap:nth-of-type(1),
  .subtopic-content > .topic-title-wrap:nth-of-type(2) {
    gap: 0.7rem !important;
    margin-bottom: 0.7rem !important;
  }
  .subtopic-content > .topic-title-wrap:nth-of-type(1) img {
    height: 2.7rem !important;
    min-width: 40px !important;
    max-width: 80px !important;
  }
  .subtopic-content > .topic-title-wrap:nth-of-type(2) img {
    height: 3.2rem !important;
    min-width: 55px !important;
    max-width: 110px !important;
  }
  .subtopic-content > .topic-title-wrap:nth-of-type(1) .topic-link-prominent {
    font-size: 2.1rem !important;
    margin: 0 0.3rem !important;
    line-height: 1.1 !important;
    letter-spacing: 0.01em !important;
    white-space: normal !important;
  }
  .subtopic-content > .topic-title-wrap:nth-of-type(2) .topic-title {
    font-size: 2.5rem !important;
    margin: 0 0.4rem !important;
    line-height: 1.1 !important;
    letter-spacing: 0.01em !important;
    white-space: normal !important;
  }
}

@media (max-width: 700px) {
  /* Subtopic Detail Page Mobile Styles - Restore previous version */
  .subtopic-container {
    padding: 0.5rem !important;
    min-height: unset !important;
  }
  .subtopic-content {
    padding: 0.5rem !important;
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box;
  }
  /* Top title bars and gold lines */
  .topic-title-wrap {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.3rem !important;
    margin-bottom: 0.5rem !important;
  }
  .topic-title-wrap img {
    height: 1.5rem !important;
    min-width: 16px !important;
    max-width: 28px !important;
    margin: 0 0.1rem !important;
    vertical-align: middle !important;
  }
  .topic-link-prominent, .topic-title {
    font-size: 2.3rem !important;
    margin: 0 0.2rem !important;
    line-height: 1.2 !important;
    white-space: normal !important;
  }
  /* Arrow below title */
  .subtopic-content > div[style*='justify-content: center'] img[alt='Hierarchy Arrow'] {
    height: 1.2rem !important;
    margin: 0.2rem 0 !important;
  }
  /* Subtopic description */
  .topic-page-description {
    font-size: 1.05rem !important;
    line-height: 1.5 !important;
    padding: 0 0.5rem !important;
    margin: 0.7rem 0 1.2rem 0 !important;
    text-align: center !important;
  }
  /* Content blocks */
  .subtopic-main-content {
    font-size: 1rem !important;
    line-height: 1.6 !important;
    margin-bottom: 1.2rem !important;
    letter-spacing: 0 !important;
    padding: 0.2rem 0.1rem !important;
    word-break: break-word !important;
  }
  /* Images inside content */
  .subtopic-main-content img,
  .content-image,
  .subtopic-image {
    max-width: 98vw !important;
    width: 100% !important;
    height: auto !important;
    display: block !important;
    margin: 0.7rem auto !important;
    border-radius: 8px !important;
    object-fit: contain !important;
  }
  /* Reference blocks */
  .reference-block {
    margin: 0.7rem 0.2rem !important;
    padding: 0.5rem 0.7rem !important;
    font-size: 0.98rem !important;
    line-height: 1.5 !important;
  }
  /* Banner image at bottom */
  .topic-banner-image {
    width: 98vw !important;
    /* max-width: 100vw !important; */
    margin: 1.2rem auto 0.5rem auto !important;
    border-radius: 10px !important;
    display: block !important;
  }
  /* Lightbox/modal images and videos */
  .lightbox-content {
    max-width: 98vw !important;
    max-height: 98vh !important;
    padding: 0 !important;
    /* Ensure vertical centering within the flex parent */
    justify-content: center;
  }
  .lightbox-image {
    max-width: 95vw !important;
    max-height: 70vh !important;
    object-fit: contain !important;
    border-radius: 6px !important;
  }
  .lightbox-caption {
    font-size: 1rem !important;
    padding: 0.3rem 0.5rem !important;
  }
  /* Remove excessive list padding */
  .subtopic-content ul, .subtopic-content ol {

    margin: 0.5rem 0 !important;
  }
  .subtopic-content li {
    font-size: 1rem !important;
    margin-bottom: 0.5rem !important;
    line-height: 1.5 !important;
  }
}

@media (max-width: 700px) {
  /* ...existing mobile styles... */

  /* AI Search page: fill bottom white area with repeated background */
  body.ai-search-page {
    background-image: url('/static/library/img/subtopic_background.png') !important;
    background-repeat: repeat !important;
    background-size: 40vw auto !important;
    background-position: top left !important;
    background-attachment: fixed !important;
  }
}

/* Scroll to Top/Bottom Floating Buttons */
.scroll-buttons {
  position: fixed;
  right: 2.1rem;
  bottom: 2.1rem;
  display: none;
  flex-direction: column;
  gap: 0.7rem;
  z-index: 3000;
}
.scroll-buttons button {
  background: linear-gradient(135deg, #C6A664 70%, #046865 100%);
  color: #222;
  border: none;
  border-radius: 50%;
  width: 3.1rem;
  height: 3.1rem;
  font-size: 2rem;
  font-weight: bold;
  box-shadow: 0 2px 12px rgba(4,104,101,0.18);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  font-family: inherit;
}
.scroll-buttons button:hover, .scroll-buttons button:focus {
  background: linear-gradient(135deg, #046865 70%, #C6A664 100%);
  color: #fff;
  transform: scale(1.12);
  box-shadow: 0 4px 18px #C6A66444;
}

@media (max-width: 700px) {
  .scroll-buttons {
    right: 1.1rem;
    bottom: 1.1rem;
    gap: 0.5rem;
  }
  .scroll-buttons button {
    width: 2.3rem;
    height: 2.3rem;
    font-size: 1.3rem;
    box-shadow: 0 1px 6px rgba(4,104,101,0.18);
  }
}

.category-preview {
    font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
    color: #FFFFF0;
    font-size: 1.25rem;
    margin: 1.2rem 0 0.7rem 0;
    min-height: 3.5em;
    line-height: 1.5;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 10;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

@media (min-width: 1101px) {
  .category-preview {
    font-size: 1.5rem;
    line-height: 1.7;
  }
  .subtopic-link {
    font-size: 2.5rem;
  }
}

/* Restore subtopic preview and name font size for subtopics only */
@media (min-width: 1101px) {
  .subtopics-list.subtopics-for-subtopic {
    grid-template-columns: repeat(3, 1fr);
  }
  .subtopics-list.subtopics-for-subtopic .subtopic-link {
    font-size: 2rem;
  }
  .subtopics-list.subtopics-for-subtopic .subtopic-preview {
    font-size: 1.25rem;
  }
}

/* Keep category cards at 2 per row and larger font */
@media (min-width: 1101px) {
  .subtopics-list.subtopics-for-category {
    grid-template-columns: repeat(2, 1fr);
  }
  .subtopics-list.subtopics-for-category .subtopic-link {
    font-size: 2.5rem;
  }
  .subtopics-list.subtopics-for-category .category-preview {
    font-size: 1.5rem;
  }
}

@media (min-width: 1101px) {
  .subtopics-list.ai-search-results {
    grid-template-columns: repeat(3, 1fr);
  }
  .subtopics-list.ai-search-results .subtopic-link {
    font-size: 2rem;
  }
  .subtopics-list.ai-search-results .subtopic-preview {
    font-size: 1.25rem;
  }
}

/* Related Subtopics Section */
.related-subtopics-section {
  margin-top: 4rem;
  text-align: center;
}

.related-subtopics-title {
  color: var(--gold);
  font-family: 'Baskerville Old Face', serif;
  font-size: 2.2rem;
  margin-bottom: 2rem;
}

.related-subtopics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  justify-items: center; /* Center grid items horizontally */
}

.related-subtopic-card {
  background: rgba(0,0,0,0.7);
  border-radius: 1.2rem;
  padding: 1.5rem;
  text-align: left;
  transition: transform 0.2s ease;
  margin: 0 auto; /* Center individual items if needed */
  border: 2px solid var(--gold);
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
}

.related-subtopic-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 16px rgba(198, 166, 100, 0.15);
  background: rgba(0,0,0,0.8);
}

.related-subtopic-link {
  color: var(--gold);
  font-size: 1.4rem;
  text-decoration: none;
  display: block;
  margin-bottom: 1rem;
  font-family: "Baskerville Old Face", serif;
  font-weight: bold;
}

.related-subtopic-preview {
  color: var(--ivory);
  font-size: 1.1rem;
  line-height: 1.5;
}

/* Navigation Arrows */
.subtopic-navigation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4rem;
  padding: 0 2rem;
}

.nav-arrow {
  display: flex;
  align-items: center;
  color: var(--gold);
  text-decoration: none;
  font-size: 1.2rem;
  transition: opacity 0.2s ease;
}

.nav-arrow:hover {
  opacity: 0.8;
}

.nav-arrow.prev span:first-child {
  margin-right: 0.5rem;
}

.nav-arrow.next span:last-child {
  margin-left: 0.5rem;
}

/* Responsive styles for related subtopics */
@media (max-width: 1200px) {
  .related-subtopics-grid {
    grid-template-columns: repeat(2, 1fr);
    padding: 0 1rem;
  }
}

@media (max-width: 768px) {
  .related-subtopics-grid {
    grid-template-columns: 1fr;
    max-width: 500px;
  }
  
  .related-subtopics-title {
    font-size: 1.8rem;
  }
  
  .subtopic-navigation {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
  
  .nav-arrow {
    font-size: 1.1rem;
  }
}

.subtopic-item-link {
  display: block;
  height: 100%;
  color: inherit;
  text-decoration: none;
}
.subtopic-item-link:hover,
.subtopic-item-link:focus {
  background: rgba(198, 166, 100, 0.06);
  box-shadow: 0 2px 16px rgba(198, 166, 100, 0.15);
  text-decoration: none;
}

@media (max-width: 600px) {
  html {
    font-size: 85%; /* Reduce base font size */
  }
  .subtopic-content, .topics-container {
    padding: 0; /* Remove Padding for mobile */
    /* Ensure proper centering */
    margin: 0 auto;
    max-width: 100%; /* Ensure it doesn't exceed viewport width */
  }
  /* ... existing code ... */
}

@media (max-width: 600px) {
  .subtopic-container, .topics-container {
    padding: 0; /* Remove padding to fix centering issue */
    margin: 0 auto; /* Ensure centering */
    max-width: 100%; /* Ensure responsiveness */
  }
  .subtopic-content {
    padding: 0; /* Remove internal padding if container has it */
  }
  /* ... existing code ... */
}

@media (max-width: 700px) {
  .subtopic-container {
    padding: 0; /* Remove padding to fix centering issue */
    margin: 0 auto; /* Ensure centering */
    max-width: 100%; /* Ensure responsiveness */
  }
  .subtopic-content {
    padding: 0;
  }
  /* ... existing code ... */
}

/* Remove default list padding */
ul {
    padding-inline-start: 0;
    padding-left: 0; /* Add padding-left for broader compatibility */
}

/* Loading Spinner Styles */
.spinner {
  /* This div acts as a container, actual spinner is in pseudo-elements */
  display: block; /* Ensure the container is a block element */
  width: 0;
  height: 0; /* Container has no size, pseudo-elements are fixed */
}

.spinner:before,
.spinner:after {
  box-sizing: border-box;
  content: '';
  display: block; /* Crucial for pseudo-elements to render */
  position: fixed;
  top: 50%;
  left: 50%;
  margin-top: -5em;
  margin-left: -5em;
  width: 10em;
  height: 10em;
  transform-style: preserve-3d; /* Re-enable transform-style */
  transform-origin: 50%; /* Re-enable transform-origin */
  perspective-origin: 50% 50%; /* Re-enable perspective-origin */
  perspective: 340px; /* Re-enable perspective */
  background-size: 10em 10em;
  background-repeat: no-repeat; /* Ensure the background doesn't repeat */
  /* Using the direct SVG file path */
  background-image: url('/static/library/img/loading_spinner.svg');
  z-index: 9999; /* Ensure it's on top */
}

.spinner:before {
  transform: rotateX(60deg) rotateY(45deg) rotateZ(45deg); /* Re-enable transform */
  animation: 750ms rotateBefore infinite linear reverse; /* Re-enable animation */
}

.spinner:after {
  transform: rotateX(240deg) rotateY(45deg) rotateZ(45deg); /* Re-enable transform */
  animation: 750ms rotateAfter infinite linear; /* Re-enable animation */
}

/* Animations */
@keyframes rotateBefore {
  from {
    transform: rotateX(60deg) rotateY(45deg) rotateZ(0deg);
  }
  to {
    transform: rotateX(60deg) rotateY(45deg) rotateZ(-360deg);
  }
}

@keyframes rotateAfter {
  from {
    transform: rotateX(240deg) rotateY(45deg) rotateZ(0deg);
  }
  to {
    transform: rotateX(240deg) rotateY(45deg) rotateZ(360deg);
  }
}

/* Optional: Add an overlay to dim the background */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 1); /* Semi-transparent black */
    z-index: 9998; /* Below the spinner */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Make spinner larger on desktop */
@media (min-width: 701px) {
  .spinner:before,
  .spinner:after {
    width: 20em; /* Increased size */
    height: 20em; /* Increased size */
    margin-top: -10em; /* Adjusted margin for centering */
    margin-left: -10em; /* Adjusted margin for centering */
  }
}

.hamburger-icon {
    display: none;
    width: 24px;
    height: 24px;
    vertical-align: middle;
}

@media (max-width: 700px) {
    .hamburger-icon {
        display: inline-block;
    }
    
    .mobile-navbar-topics-btn {
        display: inline-flex;
        flex-direction: column; /* Change to column layout */
        align-items: center; /* Center items horizontally in column */
        justify-content: center;
        gap: 2px; /* Adjust gap for column layout */
    }
    
    .hamburger-icon {
        margin-right: 0;
        margin-bottom: 2px; /* Add margin below the icon */
    }
}

/* Responsive styles for related subtopics */
@media (min-width: 769px) {
  .related-subtopics-grid {
    /* Keep grid display and center the container when items don't fill */
    /* Remove max-width: fit-content; and rely on margin: auto for centering */
    margin: 0 auto; /* Center the grid container */
    gap: 2rem; /* Keep gap between items */
    /* Grid template columns are defined below in other media queries */
    /* Ensure enough space for at least one or two items to be centered */
    max-width: 800px; /* Set a max-width that can accommodate centered items */
  }
}

@media (max-width: 1200px) {
  .related-subtopics-grid {
    grid-template-columns: repeat(2, 1fr); /* 2 per row on medium screens */
    padding: 0 1rem;
    max-width: 800px; /* Limit max width on medium screens if needed */
  }
}

@media (max-width: 768px) {
  .related-subtopics-grid {
    grid-template-columns: 1fr; /* 1 per row on mobile */
    max-width: 500px; /* Limit max width on mobile if needed */
    padding: 0 1rem; /* Add padding on mobile */
    gap: 1.5rem; /* Adjust gap for mobile */
  }
}

/* Base grid styles (for larger desktops > 1200px) */
.related-subtopics-grid {
    display: grid; /* Ensure display is grid */
    grid-template-columns: repeat(3, 1fr); /* 3 per row by default */
    gap: 2rem; /* Default gap */
    max-width: 1200px; /* Default max width */
    margin: 0 auto; /* Center the grid by default */
    justify-items: center; /* Center individual grid items */
}

/* Styles for screens between 769px and 1200px */
@media (max-width: 1200px) {
  .related-subtopics-grid {
    grid-template-columns: repeat(2, 1fr); /* 2 per row on medium screens */
    padding: 0 1rem;
    max-width: 800px; /* Adjust max width for medium screens */
    /* margin: 0 auto; is inherited from base */
    /* justify-items: center; is inherited from base */
  }
}

/* Styles for screens between 601px and 768px */
@media (max-width: 768px) {
  .related-subtopics-grid {
    grid-template-columns: 1fr; /* 1 per row on smaller tablets/large phones */
    max-width: 500px; /* Adjust max width for smaller screens */
    padding: 0 1rem;
    gap: 1.5rem;
    /* margin: 0 auto; is inherited from base */
    /* justify-items: center; is inherited from base */
  }
}

/* Styles for screens up to 600px (mobile) - keep as is or adjust if needed */
@media (max-width: 600px) {
  .related-subtopics-grid {
    grid-template-columns: 1fr; /* 1 per row on mobile */
    max-width: 100%; /* Allow grid to take full width on very small screens */
    padding: 0 0.5rem; /* Adjust padding for very small screens */
    gap: 1rem; /* Adjust gap for very small screens */
    /* margin: 0 auto; is inherited from base */
    /* justify-items: center; is inherited from base */
  }
}

