/**
 * Shared Components Styles
 * Unified styling for codebase components using CSS variables for theming
 */

/* Standard Theme Variables defining defaults, which can be overridden by section classes */
:root {
    --primary: #3b82f6;        /* Default blue */
    --primary-light: #60a5fa;
    --accent-purple: #8b5cf6;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
}

/* Core Base Modules (M1...M6) - Blue */
.core-section {
    --primary: #3b82f6;
    --primary-light: #60a5fa;
    --accent-purple: #2563eb;
}

/* Supplemental 'B' Modules (1B, 3B, 4B) - Purple */
.b-section {
    --primary: #8b5cf6;
    --primary-light: #a855f7;
    --accent-purple: #7c3aed;
}

/* Architecture 'C' Modules (3C, 4C) - Emerald */
.c-section {
    --primary: #10b981;
    --primary-light: #34d399;
    --accent-purple: #059669;
}

/* Tagline Box - Prominent callout for key concepts */
.tagline-box {
    background: linear-gradient(135deg, rgba(240, 249, 255, 0.5) 0%, rgba(224, 242, 254, 0.8) 50%, rgba(240, 249, 255, 0.5) 100%);
    border: 1px solid var(--primary-light);
    color: var(--text-primary);
    border-radius: 12px;
    padding: 1.5rem 2rem;
    margin: 2rem 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.tagline-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border-color: var(--primary);
}



.tagline-box h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.tagline-box p {
    margin: 0.5rem 0;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
}

/* Compact version for inline callouts */
.tagline-box.compact {
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
}

.tagline-box.compact h3 {
    font-size: 1.2rem;
    margin-bottom: 0.25rem;
}

.tagline-box.compact p {
    font-size: 0.9rem;
    margin: 0.25rem 0;
}




/* Navigation Subsection Styling */
.nav-subsection {
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    margin-top: 0rem;
}

.nav-subsection h4 {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin: 0.3rem 0 0.15rem 0;
    padding-left: 2rem;
}

.nav-subsection .nav-link {
    font-size: 0.875rem;
    padding: 0.25rem 1.5rem 0.25rem 3rem;
    line-height: 1.3;
}


/* SQL Code Blocks - Dark theme */
pre {
    background: linear-gradient(135deg, #0d1117 0%, #161b22 100%);
    color: #e6edf3;
    padding: 1.5rem 1.75rem;
    border-radius: 12px;
    margin: 1.5rem auto;
    overflow-x: auto;
    font-family: 'JetBrains Mono', 'Fira Code', 'Monaco', 'Menlo', monospace;
    font-size: 14px;
    line-height: 1.7;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1),
        0 0 40px rgba(0, 0, 0, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    max-width: 850px;
    position: relative;
    transition: all 0.3s ease;
}

pre:hover {
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.15),
        0 0 60px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    border-color: var(--primary-light);
}

/* Data blocks label */
pre::before {
    content: 'CODE';
    position: absolute;
    top: 0.75rem;
    right: 1rem;
    font-size: 10px;
    color: var(--primary-light);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    font-family: 'Inter', -apple-system, sans-serif;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

/* Disable generic CODE label globally if we prefer specific ones, for now lets leave it as CODE or default depending on what was there */


/* Inline Code */
code {
    background: #f1f5f9;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-family: 'Fira Code', 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 0.9em;
}

pre code {
    background: transparent;
    padding: 0;
}


/* Slides mode overrides */
body.slides-mode pre {
    font-size: 20px;
    padding: 2rem 2.5rem;
    max-width: 90%;
    margin: 2rem auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3),
        0 0 80px rgba(0, 0, 0, 0.15);
}

/* SQL Syntax Highlighting - High contrast dark theme */
.sql-keyword { color: #79c0ff; font-weight: 600; }
.sql-string { color: #a5d6ff; }
.sql-number { color: #ff7b72; }
.sql-operator { color: #c9d1d9; }
.sql-comment {
    color: #8b949e;
    font-weight: normal;
}
.sql-function { color: #d2a8ff; font-weight: 500; }
.sql-table { color: #7ee787; font-weight: 600; }

/* Visual Components (from Systems and Transactions) */

/* Canonical stat-box component (v5). One implementation; module-accented
   via var(--accent) (set by body[data-module]). No per-page <style> blocks. */
.stat-grid, .metrics-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 1.25rem 0;
}

.stat-card, .metric-card {
    flex: 1;
    min-width: 150px;
    background: var(--v5-surface, #FFFFFF);
    border: 1px solid var(--v5-hairline-2, #D4D7DC);
    border-top: 4px solid var(--accent, #475569);
    border-radius: var(--v5-r, 8px);
    padding: 0.9rem 1rem;
    text-align: center;
}

.stat-value, .metric-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent, #475569);
    line-height: 1.15;
}

.stat-label, .metric-label {
    font-size: 0.8rem;
    color: var(--v5-muted, #6B7280);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-top: 0.35rem;
}


/* Collapsible Navigation Headers */
.nav-section-header.collapsible {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    transition: background-color 0.2s;
    padding: 0.5rem 1.5rem;
    margin: 0 -1.5rem;
}

.nav-section-header.collapsible:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.collapse-icon {
    display: inline-block;
    transition: transform 0.3s ease;
    margin-right: 0.5rem;
    font-size: 0.75rem;
    color: var(--primary);
}

.nav-section-header.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.nav-subsections {
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.nav-subsections.collapsed {
    max-height: 0;
    opacity: 0;
}


/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--primary);
    color: white;
}


/* Image Utility Classes */
.expandable-image-container {
    max-width: 600px;
    margin: 2rem auto;
    text-align: center;
}

.zoomable-image {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    cursor: zoom-in;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.zoomable-image.expanded {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1.2);
    width: auto;
    max-width: 90vw;
    max-height: 90vh;
    z-index: 2000;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    cursor: zoom-out;
}


/* Side-by-Side Layout Utilities */
.side-by-side-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin: 2rem 0;
    align-items: start;
}

.side-by-side-wrapper.ratio-1-2 {
    grid-template-columns: 1fr 2fr;
}

.side-by-side-wrapper.ratio-2-1 {
    grid-template-columns: 2fr 1fr;
}

@media (max-width: 768px) {
    .side-by-side-wrapper, .side-by-side-wrapper.ratio-1-2, .side-by-side-wrapper.ratio-2-1 {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* =====================================================
   IMAGE MODAL / LIGHTBOX
   ===================================================== */
.image-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
}

.modal-content {
    margin: auto;
    display: block;
    max-width: 95%;
    max-height: 95%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 8px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
    z-index: 10001;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.modal-close:hover {
    color: #ff6b6b;
}

.modal-caption {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #f1f1f1;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
}

/* ============================================================
   Diagram tokens + figure-caption pattern
   Used under SVG diagrams to give each one a structured caption
   with color swatches keyed to the diagram. See M3B index pages.
   ============================================================ */
:root {
    --diag-ram-fill: #FEE2E2;
    --diag-ram-stroke: #F87171;
    --diag-ram-text: #991B1B;
    --diag-disk-fill: #D1FAE5;
    --diag-disk-stroke: #10B981;
    --diag-disk-text: #065F46;
    --diag-live-fill: #EDE9FE;
    --diag-live-stroke: #A78BFA;
    --diag-live-text: #5B21B6;
}

.figure-caption {
    margin: 0.5rem auto 2rem;
    max-width: 900px;
    padding: 1rem 1.5rem;
    background: #F9FAFB;
    border-radius: 10px;
    border-left: 4px solid #94A3B8;
}
.figure-caption .label {
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}
.figure-caption .title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #0E0E10;
}
.figure-caption ul {
    margin: 0;
    padding-left: 1.25rem;
    font-size: 1rem;
}
.figure-caption li {
    margin: 0.4rem 0;
    line-height: 1.55;
}
.figure-caption li ul { margin-top: 0.3rem; padding-left: 1.25rem; }
.figure-caption li b { color: #0E0E10; }

.swatch {
    display: inline-block;
    width: 0.85em;
    height: 0.85em;
    border-radius: 3px;
    margin-right: 0.3em;
    vertical-align: -1px;
    border: 1.5px solid;
}
.swatch.ram   { background: var(--diag-ram-fill);  border-color: var(--diag-ram-stroke); }
.swatch.disk  { background: var(--diag-disk-fill); border-color: var(--diag-disk-stroke); }
.swatch.live  { background: var(--diag-live-fill); border-color: var(--diag-live-stroke); }

/* ── Algorithm / pseudocode block (course-wide, module-accented) ───────────
   Markup: <div class="algo"><p class="algo-head">ALGORITHM · Name</p>
   <pre class="algo-code"> … </pre></div>  (no cost footer; costs live in
   the SVG descriptions and the IO equation sheet, not in the block)
   build.py wraps `//` comments in .cmt (phase comments get .cmt.phase) and
   the signature line in .sig. Accent shows via the left rule only (m3b/m3c
   accents are too light for text). */
/* The inner <pre class="algo-code"> is already a clean dark code card (styled by
   body[data-module] .v5-article pre in v5-chrome.css). Keep .algo a transparent
   container so that single dark card IS the block: no white wrapper, no left accent
   stripe, no uppercase header bar, no green phase pills -- those read as clutter. */
.algo {
  margin: 1.5rem auto;
  max-width: 1100px;
}
.algo-head { display: none; }   /* the section heading already names the algorithm */
/* Light "paper" code card. The global dark v5-chrome pre rule is !important, so override
   it with a higher-specificity !important selector just for .algo-code. */
body[data-module] .v5-article pre.algo-code {
  background: #FBFBF9 !important;
  color: #2A2F3A !important;
  border: 1px solid #E7EAEE !important;
  box-shadow: 0 1px 2px rgba(14, 14, 16, 0.04) !important;
}
.algo-code {
  margin: 0;
  font: 14px/1.75 'JetBrains Mono', ui-monospace, monospace;
  white-space: pre;
}
.algo-code .sig { font-weight: 700; color: #0E0E10; }
.algo-code .cmt { color: #9AA0AA; font-style: italic; }
.algo-code .cmt.phase {           /* phase = quiet accent section label with a hairline */
  display: block;
  margin: 0.7rem 0 0.15rem;
  padding-top: 0.5rem;
  border-top: 1px solid #ECEFF2;
  font-style: normal;
  font-weight: 700;
  color: var(--accent);
  background: none;
}

/* ============================================================
   WAL-log table widget (.wal-log)
   Mimics the colab print_log screenshot exactly: a bare monospace
   table, mixed-case bold headers, a single rule under the header,
   tight rows, NO outer box / shadow / border / row striping, sized
   to its content (not full width). Reusable for any txn/recovery log.

   Must override the global `table`/`th`/`td` rules in core-styles.css
   (which add a bordered rounded card, uppercase headers, even-row
   striping, hover lift) — hence the !important resets below.
   ============================================================ */
.wal-log-wrap { overflow-x: auto; margin: 1rem 0; }
.wal-log {
  display: inline-table;            /* shrink to content, sit left, not full width */
  width: auto !important;
  max-width: none !important;
  border-collapse: collapse;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  margin: 0 !important;
  overflow: visible !important;
  font-family: var(--v5-mono) !important;
  font-size: 13px;
  line-height: 1.45;
  color: var(--v5-ink);
}
.wal-log:hover { box-shadow: none !important; transform: none !important; }
.wal-log caption {
  caption-side: top;
  text-align: left;
  font-family: var(--v5-mono);
  font-weight: 700;
  font-size: 13px;
  color: var(--m1);                 /* the blue "WAL log" caption in the screenshot */
  padding: 0 0 0.3rem 0;
  text-transform: none;
  letter-spacing: 0;
}
.wal-log th {
  background: transparent !important;   /* kill the gradient header */
  border: 0 !important;
  border-bottom: 2px solid var(--v5-ink) !important;   /* one rule under headers, like the PNG */
  padding: 1px 18px 5px !important;
  font-family: var(--v5-mono) !important;
  font-weight: 700 !important;
  font-size: 13px !important;
  text-transform: none !important;      /* mixed case: Timestamp, not TIMESTAMP */
  letter-spacing: 0 !important;
  text-align: right;
  color: var(--v5-ink) !important;
  white-space: nowrap;
}
.wal-log td {
  background: transparent !important;   /* kill nth-child striping */
  border: 0 !important;
  padding: 1px 18px !important;          /* tight rows, wide column gap */
  font-size: 13px !important;
  text-align: right;
  color: var(--v5-ink) !important;
  white-space: nowrap;
}
/* kill the global even-row stripe + hover highlight inside this widget */
.wal-log tbody tr:nth-child(even) td { background: transparent !important; }
.wal-log tbody tr:hover td { background: transparent !important; }
/* center the categorical columns (Txn, Action, Variable), like the colab */
.wal-log th.txt,
.wal-log td.txt { text-align: center; }
/* structural marker row (e.g. CRASH) */
.wal-log tr.crash td {
  text-align: center;
  font-weight: 700;
  color: var(--v5-muted) !important;
  border-top: 1px dashed var(--v5-hairline-2) !important;
  padding-top: 5px !important;
}
