/* ==========================================
   notes.css — Shared Editorial Book Styles
   ========================================== */

/* Typography & Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-desk: #eae6db; /* Desk/Surface ambient tone */
    --bg-paper: #fefdfb; /* Fine book paper background */
    --text-main: #1e293b; /* Charcoal ink */
    --text-muted: #57687e; /* Muted ink */
    --border-light: rgba(44, 62, 80, 0.1);
    
    /* Default fallback colors if not overwritten */
    --primary-color: #3b82f6;
    --primary-light: rgba(59, 130, 246, 0.05);
    --border-color: rgba(59, 130, 246, 0.15);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.7;
    color: var(--text-main);
    background-color: var(--bg-desk);
    /* Soft paper/desk texture overlay */
    background-image: 
        radial-gradient(rgba(30, 41, 59, 0.03) 1px, transparent 1px), 
        radial-gradient(rgba(30, 41, 59, 0.03) 1px, var(--bg-desk) 1px);
    background-size: 24px 24px;
    background-position: 0 0, 12px 12px;
    perspective: 1800px;
    overflow-x: hidden;
}

/* STICKY TOP NAVIGATION */
.top-nav {
    background-color: rgba(254, 253, 251, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(44, 62, 80, 0.08);
    padding: 0.75rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.4rem 0.9rem;
    border-radius: 4px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.top-nav a:hover {
    color: var(--primary-color);
    background-color: var(--primary-light);
    border-color: rgba(var(--primary-color), 0.1);
}

.nav-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-style: italic;
    color: var(--text-main);
    font-size: 1.15rem;
}

/* MAIN CONTAINER (The Folio Page Sheet with stacked paper shadows) */
.container {
    max-width: 960px;
    margin: 3rem auto;
    padding: 4.5rem 4rem 4.5rem 5.5rem;
    background-color: var(--bg-paper);
    border: 1px solid rgba(44, 62, 80, 0.15);
    border-radius: 4px;
    position: relative;
    box-shadow: 
        0 1px 2px rgba(0, 0, 0, 0.05),
        0 8px 32px -4px rgba(0, 0, 0, 0.08),
        /* Dynamic Textbook Stacked Paper Shadows */
        4px 4px 0 #ffffff,
        4px 4px 0 rgba(44, 62, 80, 0.05),
        8px 8px 0 #faf9f6,
        8px 8px 0 rgba(44, 62, 80, 0.03),
        12px 12px 0 #f5f2eb,
        12px 12px 0 rgba(44, 62, 80, 0.02);
    /* Tactile notebook ruled papers background */
    background-image: 
        linear-gradient(to right, transparent 71px, rgba(239, 68, 68, 0.08) 71px, rgba(239, 68, 68, 0.08) 73px, transparent 73px),
        linear-gradient(rgba(59, 130, 246, 0.03) 1px, transparent 1px);
    background-size: 100% 100%, 100% 28px;
    background-position: 0 0, 0 4.5rem;
}

/* Inset folio dashed border layout */
.container::before {
    content: '';
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    bottom: 15px;
    border: 1px dashed rgba(44, 62, 80, 0.08);
    pointer-events: none;
    border-radius: 2px;
}

/* Subtle Book Crease shadow overlay */
.container::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(
        to right, 
        rgba(0, 0, 0, 0.18) 0%, 
        rgba(0, 0, 0, 0.08) 2.5%, 
        rgba(0, 0, 0, 0.03) 6%, 
        transparent 12%, 
        transparent 96.5%, 
        rgba(0, 0, 0, 0.03) 98.5%, 
        rgba(0, 0, 0, 0.015) 100%
    );
    pointer-events: none;
    border-radius: 4px;
    z-index: 10;
}

/* CHAPTER TITLE / HEADER INSIDE PARCHMENT */
header {
    text-align: center;
    margin-bottom: 3.5rem;
    position: relative;
    z-index: 2;
}

header h1 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 2.8rem;
    font-weight: 700;
    line-height: 1.15;
    color: #0f172a;
    margin-bottom: 0.5rem;
    letter-spacing: -0.01em;
}

.subtitle {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 1.25rem;
    color: var(--text-muted);
    margin: 0;
}

/* Book divider decoration */
.book-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin: 1.25rem 0 1.5rem;
}

.book-divider .line {
    height: 1px;
    width: 70px;
    background: linear-gradient(to var(--direction, right), rgba(44, 62, 80, 0.25), transparent);
}

.book-divider .line:first-child {
    --direction: left;
}

.book-divider .ornament {
    font-size: 1rem;
    color: rgba(44, 62, 80, 0.45);
    user-select: none;
    line-height: 1;
}

/* SECTION (Group containers in some pages) */
.section {
    position: relative;
    z-index: 2;
}

.section h2 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    border-bottom: 1px solid rgba(44, 62, 80, 0.08);
    padding-bottom: 0.5rem;
    margin: 2rem 0 1.5rem;
}

.section:first-child h2 {
    margin-top: 0;
}

/* DETAILS & SUMMARY (The Q&A Card Blocks) */
details {
    background-color: #faf9f6;
    border: 1px solid rgba(44, 62, 80, 0.08);
    border-radius: 6px;
    margin-bottom: 1.25rem;
    padding: 1.25rem 1.75rem;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    z-index: 2;
}

details[open] {
    background-color: #ffffff;
    box-shadow: 
        0 4px 20px -2px rgba(44, 62, 80, 0.06),
        0 2px 6px -1px rgba(44, 62, 80, 0.03);
    border-left: 4px solid var(--primary-color);
    padding-left: calc(1.75rem - 3px); /* Compensate for border width shift */
}

summary {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.35;
    cursor: pointer;
    color: #0f172a;
    outline: none;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    user-select: none;
}

/* Remove default triangle */
summary::-webkit-details-marker {
    display: none;
}

/* Custom interactive print-style arrow indicator */
summary::after {
    content: '✦';
    font-size: 0.8rem;
    color: var(--primary-color);
    opacity: 0.5;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

details[open] summary::after {
    content: '✧';
    transform: rotate(45deg);
    opacity: 1;
}

summary:hover {
    color: var(--primary-color);
}

/* THE ANSWER BODY */
.answer {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px dashed rgba(44, 62, 80, 0.1);
    font-size: 0.98rem;
    color: #2c3e50;
    line-height: 1.7;
}

.answer p {
    margin-bottom: 1rem;
}

.answer p:last-child {
    margin-bottom: 0;
}

/* Highlighted subheaders inside answers */
.highlight {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary-color);
    display: block;
    margin: 1.5rem 0 0.5rem 0;
}

.answer p:first-child > .highlight {
    margin-top: 0;
}

/* LIST STYLING */
.answer ul, .answer ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
}

.answer li {
    margin-bottom: 0.5rem;
}

.answer ul {
    list-style: none; /* remove standard bullets */
}

.answer ul li::before {
    content: "—";
    color: var(--primary-color);
    font-weight: bold;
    display: inline-block;
    width: 1.25rem;
    margin-left: -1.25rem;
}

.answer ol {
    list-style-type: decimal;
}

/* FORMULA TEXTBOOK BOX */
.formula-box {
    background-color: #f7f6f2;
    border-left: 3px solid var(--primary-color);
    border-radius: 0 4px 4px 0;
    padding: 1.25rem 1.5rem;
    font-family: 'Courier New', Courier, monospace;
    font-weight: 700;
    color: #0f172a;
    margin: 1.5rem 0;
    overflow-x: auto;
    box-shadow: inset 2px 2px 5px rgba(0,0,0,0.02);
    font-size: 0.95rem;
    border-top: 1px solid rgba(44,62,80,0.04);
    border-right: 1px solid rgba(44,62,80,0.04);
    border-bottom: 1px solid rgba(44,62,80,0.04);
}

/* ACADEMIC BOOKTABS TABLES */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.9rem;
    /* LaTeX booktabs standard borders */
    border-top: 2px solid #0f172a;
    border-bottom: 2px solid #0f172a;
}

th, td {
    padding: 0.65rem 0.75rem;
    text-align: left;
    vertical-align: top;
    border: none;
}

th {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    color: #0f172a;
    border-bottom: 1px solid #0f172a;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    background-color: rgba(44, 62, 80, 0.02);
}

td {
    border-bottom: 1px solid rgba(44, 62, 80, 0.06);
}

tr:last-child td {
    border-bottom: none;
}

tr:nth-child(even) td {
    background-color: rgba(44, 62, 80, 0.01);
}

/* CODE BLOCKS */
pre {
    background-color: #f7f6f2;
    border: 1px solid rgba(44, 62, 80, 0.06);
    border-radius: 4px;
    padding: 1.25rem;
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    color: #334155;
    margin: 1.25rem 0;
}

code {
    font-family: 'Courier New', Courier, monospace;
    font-weight: 700;
    background-color: rgba(44, 62, 80, 0.05);
    padding: 0.15rem 0.35rem;
    border-radius: 3px;
    font-size: 0.9em;
    color: #0f172a;
}

pre code {
    background-color: transparent;
    padding: 0;
    font-weight: normal;
    font-size: inherit;
    color: inherit;
}

/* HARD LEVEL BADGES (used in some multiprocessor / pipelining elements) */
.hard-title {
    display: inline-block;
    background-color: #991b1b;
    color: #fefdfb;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 1.5rem 0 0.75rem 0;
}

/* ==========================================
   INTERACTIVE COMPONENTS
   ========================================== */

/* Progress bar header wrapper */
.progress-wrapper {
    margin-bottom: 2rem;
    background: rgba(44, 62, 80, 0.02);
    border: 1px solid rgba(44, 62, 80, 0.06);
    border-radius: 6px;
    padding: 0.9rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    position: relative;
    z-index: 2;
}

.progress-text {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
}

.progress-text span {
    color: var(--text-main);
}

.progress-bar-container {
    flex-grow: 1;
    height: 6px;
    background-color: rgba(44, 62, 80, 0.08);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background-color: var(--primary-color);
    border-radius: 999px;
    transition: width 0.4s ease;
}

/* Star Bookmark Flag */
.bookmark-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.75rem;
    color: rgba(44, 62, 80, 0.2);
    cursor: pointer;
    font-size: 1.15rem;
    transition: all 0.2s ease;
    user-select: none;
    flex-shrink: 0;
    position: relative;
    z-index: 5;
}

.bookmark-btn:hover {
    color: var(--primary-color);
    transform: scale(1.2);
}

.bookmark-btn::before {
    content: '☆';
}

.bookmark-btn.active {
    color: var(--primary-color);
}

.bookmark-btn.active::before {
    content: '★';
}

/* Search Bar layout */
.search-wrapper {
    margin-bottom: 1.25rem;
    position: relative;
    z-index: 2;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1.25rem 0.75rem 2.4rem;
    border-radius: 6px;
    border: 1px solid rgba(44, 62, 80, 0.12);
    background-color: #faf9f6;
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    color: var(--text-main);
    transition: all 0.2s ease;
    outline: none;
}

.search-input:focus {
    border-color: var(--primary-color);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(var(--primary-color), 0.08);
}

.search-icon {
    position: absolute;
    left: 0.9rem;
    top: 52%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
    opacity: 0.6;
}

.no-results {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 1.3rem;
    border: 1px dashed rgba(44, 62, 80, 0.12);
    border-radius: 6px;
    display: none;
    margin-top: 1rem;
    margin-bottom: 2rem;
}

/* Floating Navigation Drawer */
.drawer-toggle {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    width: 3.2rem;
    height: 3.2rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.drawer-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0,0,0,0.18);
}

.jump-drawer {
    position: fixed;
    top: 0;
    right: -320px;
    width: 320px;
    height: 100vh;
    background-color: var(--bg-paper);
    border-left: 1px solid rgba(44, 62, 80, 0.12);
    box-shadow: -4px 0 24px rgba(0,0,0,0.06);
    z-index: 999;
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 5rem 1.75rem 2rem;
    display: flex;
    flex-direction: column;
}

.jump-drawer.open {
    right: 0;
}

.drawer-header {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1.25rem;
    border-bottom: 1px solid rgba(44, 62, 80, 0.08);
    padding-bottom: 0.5rem;
}

.drawer-list {
    list-style: none;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding-right: 0.25rem;
}

.drawer-list::-webkit-scrollbar {
    width: 4px;
}

.drawer-list::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 2px;
    opacity: 0.3;
}

.drawer-item {
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    border-left: 2px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drawer-item:hover {
    color: var(--primary-color);
    background-color: var(--primary-light);
    border-left-color: var(--primary-color);
}

/* Landing Page progress indicators */
.card-progress-container {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.card-progress-bar {
    flex-grow: 1;
    height: 4px;
    background-color: rgba(44, 62, 80, 0.08);
    border-radius: 999px;
    overflow: hidden;
}

.card-progress-fill {
    height: 100%;
    width: 0%;
    background-color: var(--chapter-color);
    border-radius: 999px;
    transition: width 0.4s ease;
}

.card-progress-text {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

/* Dynamic Binding Gutter guideline */
.container-gutter {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 24px;
    width: 2px;
    border-left: 1px solid rgba(0, 0, 0, 0.05);
    border-right: 1px solid rgba(0, 0, 0, 0.02);
    pointer-events: none;
    z-index: 11;
}

/* textbook running header and footer styles */
.textbook-header-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(44, 62, 80, 0.15);
    padding-bottom: 0.5rem;
    margin-bottom: 2rem;
    font-family: 'Cormorant Garamond', serif;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-muted);
    position: relative;
    z-index: 2;
}

.textbook-footer-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid rgba(44, 62, 80, 0.1);
    padding-top: 0.75rem;
    margin-top: 3.5rem;
    font-family: 'Cormorant Garamond', serif;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    position: relative;
    z-index: 2;
}

.textbook-page-num {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-weight: 700;
    font-size: 0.95rem;
}

/* RESPONSIVE LAYOUT */
@media (max-width: 768px) {
    body {
        padding: 0;
    }
    .top-nav {
        padding: 0.75rem 1rem;
    }
    .container {
        margin: 1rem auto;
        padding: 2.5rem 1.5rem;
        border-left: none;
        border-right: none;
        border-radius: 0;
        box-shadow: none;
    }
    .container::before {
        top: 8px;
        left: 8px;
        right: 8px;
        bottom: 8px;
    }
    .container::after {
        display: none;
    }
    .container-gutter {
        display: none;
    }
    header h1 {
        font-size: 2rem;
    }
    details {
        padding: 1rem 1.25rem;
    }
    details[open] {
        padding-left: calc(1.25rem - 3px);
    }
    summary {
        font-size: 1.15rem;
    }
    th, td {
        padding: 0.5rem;
    }
}

/* ==========================================
   QA Cards (Replaces details/summary)
   ========================================== */
.qa-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.qa-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
}
.qa-question {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-main);
    margin-top: 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 0.75rem;
    line-height: 1.4;
}
.qa-card .answer {
    margin-top: 0;
    padding: 0;
    border-left: none;
    background: transparent;
}

/* ==========================================
   Flashcard Pagination Controls
   ========================================== */
.flashcard-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 0;
    margin-top: 2rem;
    border-top: 1px solid var(--border-light);
}

.flash-btn {
    background-color: var(--primary-color, #3b82f6);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 30px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

#flash-prev {
    position: fixed;
    top: 50%;
    left: 2vw;
    transform: translateY(-50%);
    z-index: 100;
}

#flash-next {
    position: fixed;
    top: 50%;
    right: 2vw;
    transform: translateY(-50%);
    z-index: 100;
}

#flash-prev:hover:not(:disabled),
#flash-next:hover:not(:disabled) {
    background-color: #2563eb;
    transform: translateY(-50%) scale(1.05);
}

.flash-btn:disabled {
    background-color: #cbd5e1;
    color: #94a3b8;
    cursor: not-allowed;
    box-shadow: none;
}

.flash-count {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.2rem;
    font-style: italic;
    color: var(--text-muted);
    font-weight: 600;
}

#flash-current {
    color: var(--primary-color, #3b82f6);
    font-weight: 700;
}
