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

body, html {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: "Georgia", "Times New Roman", serif;
    background-color: #e8dfc5; /* Parchment base */
    color: #2c2421; /* Ink color */
}

/* Home Screen */
#home-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #e8dfc5;
    z-index: 1000;
    transition: opacity 0.5s ease;
    overflow-y: auto;
    padding: 60px 20px;
}

#home-screen::before,
#home-screen::after {
    content: '';
    flex: 1;
    min-height: 20px;
}

#home-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.home-title {
    font-size: 3.5rem;
    margin-bottom: 50px;
    color: #5a3e2b;
    font-variant: small-caps;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

.subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, 280px);
    justify-content: center;
    gap: 40px;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
}

.subject-card {
    background-color: #fcf5e5;
    border: 2px solid #c4b5a2;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 5px 5px 15px rgba(0,0,0,0.05);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 180px;
}

.subject-card:hover {
    transform: translateY(-5px);
    box-shadow: 10px 10px 25px rgba(0,0,0,0.1);
    border-color: #7a583a;
}

.subject-card h2 {
    color: #5a3e2b;
    font-variant: small-caps;
    margin-bottom: 5px;
    font-size: 1.8rem;
}

.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
    width: 100%;
}

.subject-card.active .submenu {
    max-height: 500px;
    margin-top: 15px;
}

.submenu a {
    display: block;
    color: #7a583a;
    text-decoration: none;
    font-style: italic;
    margin-top: 10px;
    font-size: 1.1rem;
}

.submenu a:hover {
    text-decoration: underline;
    color: #2c2421;
}

.submenu-group {
    color: #5a3e2b;
    font-size: 0.9rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 15px;
    padding-bottom: 3px;
    border-bottom: 1px solid #dcd0b3;
    width: 80%;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

.submenu-group:first-child {
    margin-top: 5px;
}

/* Main Container */
.container {
    display: flex;
    height: 100vh;
    width: 100vw;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.container.visible {
    opacity: 1;
}

.pane {
    flex: 1;
    width: 50%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* Back Button */
#back-to-home {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 2000;
    background: #fcf5e5;
    border: 1px solid #c4b5a2;
    padding: 8px 15px;
    cursor: pointer;
    font-family: inherit;
    font-variant: small-caps;
    color: #5a3e2b;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
}

#back-to-home:hover {
    background: #e8dfc5;
}

/* Left Pane: Document View */
#doc-view {
    border-right: 2px solid #c4b5a2;
    overflow-y: auto;
    padding: 80px 60px 60px 60px;
    background-color: #fcf5e5; /* Lighter parchment for readability */
    color: #2c2421;
    box-shadow: inset -10px 0 20px rgba(0,0,0,0.05);
}

.markdown-body {
    max-width: 750px;
    margin: 0 auto;
    line-height: 1.8;
}

.markdown-body h1 { border-bottom: 2px solid #dcd0b3; padding-bottom: 0.3em; margin-top: 24px; margin-bottom: 16px; color: #5a3e2b; font-variant: small-caps; }
.markdown-body h2 { border-bottom: 1px solid #dcd0b3; padding-bottom: 0.3em; margin-top: 24px; margin-bottom: 16px; color: #5a3e2b; }
.markdown-body h3 { margin-top: 24px; margin-bottom: 16px; color: #7a583a; }
.markdown-body p { margin-bottom: 16px; }
.markdown-body blockquote { padding: 0 1.5em; color: #5a4b3c; border-left: 4px solid #c4b5a2; font-style: italic; background: rgba(0,0,0,0.02); }
.markdown-body table { border-spacing: 0; border-collapse: collapse; margin-bottom: 32px; width: 100%; overflow: auto; border: 1px solid #c4b5a2; }
.markdown-body table th, .markdown-body table td { padding: 10px 15px; border: 1px solid #c4b5a2; }
.markdown-body table tr { background-color: #fffaf0; }
.markdown-body table tr:nth-child(2n) { background-color: #f5edd6; }
.markdown-body code { background-color: rgba(90, 62, 43, 0.08); border-radius: 3px; font-size: 85%; margin: 0; padding: 0.2em 0.4em; color: #5a3e2b; }

/* Flashcard Carousel Styles */
.flashcard-carousel {
    margin: 40px 0;
    padding: 25px;
    background: rgba(196, 181, 162, 0.1);
    border: 1px solid #c4b5a2;
    border-radius: 8px;
    position: relative;
}

.flashcard-header {
    text-align: center;
    margin-bottom: 25px;
    font-variant: small-caps;
    color: #5a3e2b;
}

.shuffle-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: 1px solid #c4b5a2;
    color: #7a583a;
    font-size: 1.2rem;
    padding: 2px 8px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s ease;
    z-index: 5;
}

.shuffle-btn:hover {
    background: #c4b5a2;
    color: #fff;
}

.shuffle-btn.active {
    background: #7a583a;
    color: #fff;
    border-color: #7a583a;
}

.carousel-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
}

.nav-btn {
    background: none;
    border: none;
    color: #7a583a;
    font-size: 3rem;
    cursor: pointer;
    transition: transform 0.2s ease;
    font-family: serif;
}

.nav-btn:hover {
    transform: scale(1.2);
    color: #2c2421;
}

.active-card-area {
    width: 320px;
    height: 220px;
}

.flashcard {
    width: 100%;
    height: 100%;
    perspective: 1000px;
    cursor: pointer;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
    box-shadow: 5px 5px 15px rgba(0,0,0,0.1);
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 25px;
    border-radius: 6px;
    border: 1px solid #c4b5a2;
}

.flashcard-front {
    background-color: #fcf5e5;
    color: #2c2421;
}

.flashcard-back {
    background-color: #f5edd6;
    color: #2c2421;
    transform: rotateY(180deg);
    text-align: left;
}

.card-content {
    font-size: 1rem;
    line-height: 1.5;
}

.card-content ul {
    list-style-type: none;
    padding: 0;
    margin-top: 10px;
}

.card-content li {
    margin-bottom: 8px;
    position: relative;
    padding-left: 15px;
    white-space: normal;
    word-wrap: break-word;
}

.card-content li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: #7a583a;
}

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 25px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #c4b5a2;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.dot.active {
    background-color: #7a583a;
    transform: scale(1.2);
}

/* Right Pane: Mindmap View */
#mindmap-view {
    background-color: #e8dfc5;
    position: relative;
}

#graph-container {
    width: 100%;
    height: 100%;
}

#explanation-box {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 28%;
    background: rgba(244, 236, 216, 0.96); /* Opaque parchment */
    border-top: 3px double #c4b5a2;
    padding: 25px;
    overflow-y: auto;
    color: #2c2421;
    z-index: 100;
    transition: transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.1);
}

#explanation-box.hidden {
    transform: translateY(100%);
    display: none;
}

#explanation-content {
    flex: 1;
}

#explanation-content h3 {
    color: #5a3e2b;
    margin-bottom: 10px;
    font-variant: small-caps;
}

#close-explanation {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: #7a583a;
    font-size: 24px;
    cursor: pointer;
}

#close-explanation:hover {
    color: #2c2421;
}

/* Custom styles for highlighted content */
.highlight-section {
    background-color: #f0e68c;
    transition: background-color 0.5s ease;
}

/* Document Table of Contents */
.doc-toc {
    background: rgba(196, 181, 162, 0.15);
    border: 1px solid #c4b5a2;
    padding: 30px;
    margin-bottom: 50px;
    border-radius: 8px;
}

.toc-links {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.toc-link {
    color: #7a583a;
    text-decoration: none;
    font-variant: small-caps;
    padding: 5px 15px;
    border: 1px solid #c4b5a2;
    border-radius: 4px;
    background: #fcf5e5;
    transition: all 0.2s ease;
}

.toc-link:hover {
    background: #e8dfc5;
    color: #2c2421;
    border-color: #7a583a;
}

/* Scrollbar styling */
#doc-view::-webkit-scrollbar {
    width: 10px;
}
#doc-view::-webkit-scrollbar-track {
    background: #e8dfc5;
}
#doc-view::-webkit-scrollbar-thumb {
    background: #c4b5a2;
    border-radius: 5px;
    border: 2px solid #e8dfc5;
}
#doc-view::-webkit-scrollbar-thumb:hover {
    background: #a39281;
}

/* Utility */
.hidden {
    display: none !important;
}
