/**
 * common.css - Shared/Base Styles
 * 
 * This file contains all shared CSS that applies to both light and dark themes.
 * It includes:
 * - Color palette definitions
 * - Light theme default CSS variables (base theme)
 * - All structural and layout styles
 * - Common component styles
 * - Syntax highlighting for all themes
 * 
 * Light and dark theme overrides are split into light.css and dark.css
 * Print-specific styles are in print.css
 */

/* ────────────────────────────────────────────────────────────────────────────
   LOCAL FONT FACES
   ──────────────────────────────────────────────────────────────────────────── */

@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('/static/fonts/JetBrainsMono.ttf') format('truetype');
}

/* ────────────────────────────────────────────────────────────────────────────
   COLOR PALETTE & CSS VARIABLES
   ──────────────────────────────────────────────────────────────────────────── */

:root {
    --c-slate-50: #f8fafc;
    --c-slate-100: #f1f5f9;
    --c-slate-200: #e2e8f0;
    --c-slate-300: #cbd5e1;
    --c-slate-400: #94a3b8;
    --c-slate-500: #64748b;
    --c-slate-600: #475569;
    --c-slate-700: #334155;
    --c-slate-800: #1e293b;
    --c-slate-900: #0f172a;

    --c-blue-50: #eff6ff;
    --c-blue-100: #dbeafe;
    --c-blue-200: #bfdbfe;
    --c-blue-400: #60a5fa;
    --c-blue-500: #3b82f6;
    --c-blue-600: #2563eb;
    --c-blue-700: #1d4ed8;
    --c-blue-800: #1e40af;
    --c-blue-900: #1e3a8a;

    /* Light theme defaults */
    --bg-body: var(--c-slate-50);
    --text-body: var(--c-slate-900);
    --bg-header: #ffffff;
    --border-color: var(--c-slate-200);
    --text-muted: var(--c-slate-500);
    --text-link: var(--c-slate-500);
    --text-link-hover: var(--c-slate-700);
    
    --bg-card: #ffffff;
    --border-card: var(--c-slate-200);
    --shadow-card: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    
    --bg-input: #ffffff;
    --border-input: var(--c-slate-300);
    
    --bg-sidebar: var(--c-slate-50);
    --border-sidebar: var(--c-slate-200);
    
    --prose-headings: var(--c-slate-900);
    --prose-text: var(--c-slate-600);
    --prose-code-bg: #fef2f2;
    --prose-code-text: #b91c1c;
    --prose-table-head-bg: #0b004b;
    --prose-table-head-text: #ffffff;
    --prose-table-head-border: #05001d;
    
    /* Code block colors (light theme defaults) */
    --codeblock-bg: #f0f4ff;
    --codeblock-text: #1e1b4b;
    --codeblock-border: #c7d2fe;
    --codeblock-border-left: #4f46e5;
    --inline-code-bg: #fef2f2;
    --inline-code-text: #b91c1c;
    --inline-code-border: #fecaca;

    /* Editor page styles (light theme defaults) */
    --editor-kbd-bg: var(--c-slate-100);
    --editor-kbd-border: var(--c-slate-300);
    --editor-metadata-bg: #ffffff;
    --editor-metadata-border: var(--c-slate-200);
    --editor-metadata-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --editor-btn-secondary-bg: var(--c-slate-200);
    --editor-btn-secondary-text: var(--c-slate-900);
    --editor-btn-secondary-hover: var(--c-slate-300);
    --editor-btn-edit-bg: var(--c-blue-100);
    --editor-btn-edit-text: var(--c-blue-700);
    --editor-btn-edit-border: var(--c-blue-300);
    --editor-btn-edit-hover: var(--c-blue-200);
    --editor-btn-remove-bg: #fee2e2;
    --editor-btn-remove-text: #dc2626;
    --editor-btn-remove-border: #fecaca;
    --editor-btn-remove-hover: #fecaca;
    --editor-btn-copy-bg: #10b981;
    --editor-btn-copy-text: #ffffff;
    --editor-btn-copy-hover: #059669;
}

/* ────────────────────────────────────────────────────────────────────────────
   SERVER-SIDE SYNTAX HIGHLIGHTING
   ──────────────────────────────────────────────────────────────────────────── */

/* Syntax highlighting colors are defined in light.css and dark.css */

/* ────────────────────────────────────────────────────────────────────────────
   VARIABLE HIGHLIGHTING
   ──────────────────────────────────────────────────────────────────────────── */

.input-hl-wrap {
    position: relative;
    display: block;
    border: 1px solid var(--border-input);
    border-radius: 0.5rem;
    background-color: var(--bg-input);
    transition: border-color 0.2s, box-shadow 0.2s;
    overflow: hidden;
}

.input-hl-wrap:focus-within {
    border-color: var(--c-blue-500);
    box-shadow: 0 0 0 1px var(--c-blue-500);
}

.input-hl-wrap .form-input {
    position: relative;
    z-index: 2;
    background: transparent !important;
    color: transparent !important;
    caret-color: var(--text-body) !important;
    border: none !important;
    box-shadow: none !important;
}

.input-hl-wrap .form-input:focus {
    border: none !important;
    box-shadow: none !important;
}

.input-hl-layer {
    position: absolute;
    inset: 0;
    padding: 0.75rem;
    font-size: 0.875rem;
    font-family: inherit;
    line-height: normal;
    color: var(--text-body);
    pointer-events: none;
    white-space: pre;
    overflow: hidden;
    z-index: 1;
}

.var-ref-token {
    color: #c9980a;
    text-shadow: 0 0 8px rgba(201, 152, 10, 0.6);
}

/* ────────────────────────────────────────────────────────────────────────────
   CODE BLOCK STYLING
   ──────────────────────────────────────────────────────────────────────────── */

pre {
    background-color: var(--codeblock-bg);
    color: var(--codeblock-text);
    border: 1px solid var(--codeblock-border);
    border-left: 4px solid var(--codeblock-border-left);
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    font-family: 'JetBrains Mono', 'Courier New', Courier, monospace;
    font-size: 0.9em;
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

code {
    font-family: inherit;
}

code:not(pre code) {
    background-color: var(--inline-code-bg);
    color: var(--inline-code-text);
    border: 1px solid var(--inline-code-border);
    padding: 0.1rem 0.3rem;
    border-radius: 0.2rem;
    font-family: 'JetBrains Mono', 'Courier New', Courier, monospace;
}

/* ────────────────────────────────────────────────────────────────────────────
   RESET & BASE STYLES
   ──────────────────────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }

html { scrollbar-gutter: stable; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-body);
    transition: background-color 0.2s, color 0.2s;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a { text-decoration: none; color: inherit; }

.page-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ────────────────────────────────────────────────────────────────────────────
   LAYOUT
   ──────────────────────────────────────────────────────────────────────────── */

.container {
    width: 100%;
    max-width: 1600px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 2rem;
    padding-right: 2rem;
}

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }

/* ────────────────────────────────────────────────────────────────────────────
   HEADER
   ──────────────────────────────────────────────────────────────────────────── */

.site-header {
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
    transition: background-color 0.2s, border-color 0.2s;
}

.header-inner {
    height: 4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-body);
}

.logo svg {
    width: 2rem;
    height: 2rem;
    color: var(--c-blue-600);
}

.nav-link {
    color: var(--text-link);
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--text-link-hover);
}

.theme-toggle {
    padding: 0.5rem;
    border-radius: 0.5rem;
    color: var(--text-muted);
    transition: background-color 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-only { display: none; }

.header-search {
    max-width: 20rem;
    flex: 1;
    position: relative;
}

.hide-on-homepage .header-search {
    display: none;
}

.header-search .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--c-slate-400);
    pointer-events: none;
    width: 1rem;
    height: 1rem;
}

.header-search .form-input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    font-size: 0.875rem;
}

/* ────────────────────────────────────────────────────────────────────────────
   GRID & CARDS
   ──────────────────────────────────────────────────────────────────────────── */

.cheatsheet-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .cheatsheet-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
    .cheatsheet-grid { grid-template-columns: repeat(3, 1fr); }
}

.card {
    display: block;
    background-color: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 0.5rem;
    padding: 1.5rem;
    transition: all 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-card);
    border-color: var(--c-blue-400);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-body);
    margin: 0 0 0.5rem 0;
    transition: color 0.2s;
}

.card-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0 0 1rem 0;
}

.card-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--c-blue-600);
}

/* ────────────────────────────────────────────────────────────────────────────
   HERO & SEARCH
   ──────────────────────────────────────────────────────────────────────────── */

.hero { text-align: center; padding: 3rem 0; margin-bottom: 2rem; }
.hero-title { font-size: 2.25rem; font-weight: 700; margin: 0 0 0.75rem 0; color: var(--text-body); }
.hero-subtitle { font-size: 1.125rem; color: var(--text-muted); margin: 0 0 0.5rem 0; }
.hero-promo { font-size: 0.875rem; color: var(--c-blue-600); font-weight: 500; margin: 0 0 2rem 0; }

.search-wrapper { max-width: 36rem; margin: 0 auto; position: relative; }

.search-icon {
    position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%);
    color: var(--c-slate-400); pointer-events: none;
    width: 1.25rem; height: 1.25rem;
}

.form-input {
    display: block;
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-input);
    border-radius: 0.5rem;
    background-color: var(--bg-input);
    color: var(--text-body);
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-wrapper .form-input { padding-left: 2.5rem; }

.form-input:focus {
    outline: none;
    border-color: var(--c-blue-500);
    box-shadow: 0 0 0 1px var(--c-blue-500);
}

/* ────────────────────────────────────────────────────────────────────────────
   SIDEBAR & SHEET LAYOUT
   ──────────────────────────────────────────────────────────────────────────── */

.sheet-layout { 
    display: flex; 
    width: 100%;
    position: relative;
}

.sidebar {
    width: 16rem;
    background: linear-gradient(to bottom, var(--bg-sidebar), var(--bg-body));
    border-right: 1px solid var(--border-sidebar);
    height: calc(100vh - 4rem);
    position: sticky;
    top: 4rem;
    flex-shrink: 0;
    transition: width 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
}

.sidebar.collapsed {
    width: 3.5rem;
}

.sidebar-toggle-btn {
    margin: 1rem 0.75rem;
    padding: 0.625rem;
    background: var(--c-blue-50);
    border: 1px solid var(--c-blue-200);
    border-radius: 0.5rem;
    cursor: pointer;
    color: var(--c-blue-600);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.2s;
    height: 2.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sidebar-toggle-btn:hover {
    background-color: var(--c-blue-100);
    border-color: var(--c-blue-300);
    color: var(--c-blue-700);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.sidebar.collapsed .sidebar-toggle-btn span {
    display: none;
}

.toggle-icon { transition: transform 0.3s; width: 1.25rem; height: 1.25rem; }
.sidebar.collapsed .toggle-icon { transform: rotate(180deg); }

.sidebar-content { 
    padding: 1rem; 
    width: 16rem; 
    overflow-y: auto; 
    flex: 1;
    opacity: 1;
    transition: opacity 0.2s;
}

.sidebar.collapsed .sidebar-content {
    opacity: 0;
    pointer-events: none;
}

.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: var(--c-slate-300);
    border-radius: 3px;
}

.back-link {
    display: flex; align-items: center; gap: 0.5rem;
    color: var(--c-blue-600); font-weight: 600; margin-bottom: 1.5rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.back-link:hover { 
    background-color: var(--c-blue-50);
    text-decoration: none;
}

.back-link svg {
    width: 1.25rem;
    height: 1.25rem;
}

.group-title {
    font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-muted); margin-bottom: 0.75rem; margin-top: 1rem;
    padding: 0 0.5rem;
}

.nav-list { margin-bottom: 1.5rem; }

.nav-item {
    display: block; 
    padding: 0.625rem 0.75rem; 
    border-radius: 0.5rem;
    font-size: 0.875rem; 
    color: var(--text-body);
    margin-bottom: 0.125rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover { 
    background-color: var(--c-slate-100);
    border-left-color: var(--c-blue-400);
    padding-left: 0.875rem;
}

.nav-item.active {
    background-color: var(--c-blue-50);
    color: var(--c-blue-700); 
    font-weight: 600;
    border-left-color: var(--c-blue-600);
}

.nav-group {
    margin-top: 1rem;
}

.nav-group .nav-list {
    display: none;
    margin-bottom: 0;
}

.nav-group[open] .nav-list {
    display: block;
    margin-bottom: 0.5rem;
}

.group-toggle {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    color: var(--text-muted);
    transition: background-color 0.15s, color 0.15s;
    margin-bottom: 0.25rem;
    gap: 0.5rem;
    list-style: none;
}

.group-toggle::-webkit-details-marker {
    display: none;
}

.group-toggle:hover {
    background-color: var(--c-slate-100);
    color: var(--text-body);
}

.group-toggle:focus-visible {
    outline: 2px solid var(--c-blue-500);
    outline-offset: 2px;
}

.group-toggle .group-title {
    margin: 0;
    padding: 0;
    flex: 1;
    text-align: left;
}

.group-arrow {
    transition: transform 0.2s;
    flex-shrink: 0;
}

.nav-group:not([open]) .group-arrow {
    transform: rotate(-90deg);
}

/* ────────────────────────────────────────────────────────────────────────────
   MAIN CONTENT & SHEET
   ──────────────────────────────────────────────────────────────────────────── */

.main-content { flex: 1; padding: 2rem; min-width: 0; }

.sheet-container { width: 100%; max-width: 1000px; margin: 0 auto; }

.sheet-header { margin-bottom: 2rem; }

.badge {
    display: inline-block; padding: 0.25rem 0.75rem;
    background-color: var(--c-blue-100); color: var(--c-blue-700);
    font-size: 0.75rem; font-weight: 600; border-radius: 9999px; margin-bottom: 0.75rem;
}

.sheet-title { font-size: 2.25rem; font-weight: 700; margin: 0 0 0.5rem 0; line-height: 1.2; color: var(--text-body); }

.sheet-desc { font-size: 1.125rem; color: var(--text-muted); margin: 0; }

.tags-container { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

.tag {
    display: inline-block; padding: 0.125rem 0.5rem;
    background-color: var(--c-slate-100); color: var(--c-slate-600);
    font-size: 0.75rem; font-weight: 500; border-radius: 9999px;
}

/* ────────────────────────────────────────────────────────────────────────────
   VARIABLES PANEL
   ──────────────────────────────────────────────────────────────────────────── */

.var-panel {
    background-color: var(--c-blue-50);
    border: 1px solid var(--c-blue-200);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
    position: sticky;
    top: 5rem;
    z-index: 40;
    backdrop-filter: blur(4px);
    transition: background-color 0.2s, border-color 0.2s;
}

.panel-header { display: flex; justify-content: space-between; align-items: center; }

.panel-title { font-size: 1.125rem; font-weight: 600; margin: 0; color: var(--text-body); }

.panel-toggle { color: var(--c-blue-600); font-size: 0.875rem; font-weight: 500; cursor: pointer; background: none; border: none; padding: 0; }

.panel-clear-btn { display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); background: none; border: none; cursor: pointer; padding: 0.25rem; border-radius: 0.25rem; transition: all 0.2s; line-height: 1; margin-right: 0.25rem; }

.panel-clear-btn:hover { background: var(--c-slate-200); color: var(--c-blue-600); }

.form-group { margin-bottom: 1rem; }

.form-label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.25rem; color: var(--text-body); }

/* ────────────────────────────────────────────────────────────────────────────
   CHECKBOXES & TASK LISTS
   ──────────────────────────────────────────────────────────────────────────── */

input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
    vertical-align: middle;
    border: 2px solid #d1d5db;
    border-radius: 0.375rem;
    background-color: #ffffff;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin: 0 0.5rem 0 0;
}

input[type="checkbox"]:hover:not(:checked) {
    border-color: #9ca3af;
}

input[type="checkbox"]:checked {
    background-color: #34d399;
    border-color: #34d399;
}

input[type="checkbox"]:checked::after {
    content: "✓";
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: bold;
    font-size: 0.85rem;
    width: 100%;
    height: 100%;
}

ul.contains-task-list {
    list-style: none;
    padding-left: 0.25rem;
}

li.task-list-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

li.task-list-item input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    cursor: default;
    pointer-events: none;
    margin: 0 0.25rem 0 0;
}

li.task-list-item input[type="checkbox"]:checked::after {
    font-size: 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 0.75rem;
    border-radius: 0.5rem;
    transition: background-color 0.2s;
}

.checkbox-label:hover {
    background-color: rgba(59, 130, 246, 0.05);
}

/* ────────────────────────────────────────────────────────────────────────────
   PROSE / CONTENT STYLES
   ──────────────────────────────────────────────────────────────────────────── */

.prose { max-width: 100%; }

.prose h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--prose-headings);
    margin-top: 2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.prose h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--prose-headings);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.prose p {
    margin-bottom: 1rem;
    color: var(--prose-text);
    line-height: 1.75;
}

.prose pre::-webkit-scrollbar {
    height: 8px;
}

.prose pre::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.prose pre::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    transition: background 0.2s;
}

.prose pre::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.prose pre {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) rgba(0, 0, 0, 0.2);
}

.prose :not(pre) > code {
    background: var(--prose-code-bg);
    color: var(--prose-code-text);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
    font-weight: 600;
}

.prose table {
    width: 100%;
    margin: 1.5rem 0;
    border-collapse: collapse;
}

.prose th {
    background: var(--prose-table-head-bg);
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--prose-table-head-text);
    border-bottom: 2px solid var(--prose-table-head-border);
}

.prose td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--prose-text);
}

.prose ul, .prose ol { margin: 1rem 0; padding-left: 1.5rem; }

.prose li { margin: 0.5rem 0; color: var(--prose-text); }

.prose strong { font-weight: 600; color: var(--prose-headings); }

.prose a {
    color: var(--c-blue-600);
    text-decoration: underline;
    text-decoration-color: var(--c-blue-400);
    text-underline-offset: 2px;
    transition: color 0.2s, text-decoration-color 0.2s;
}

.prose a:hover {
    color: var(--c-blue-700);
    text-decoration-color: var(--c-blue-600);
}

/* ────────────────────────────────────────────────────────────────────────────
   IMAGES
   ──────────────────────────────────────────────────────────────────────────── */

.prose img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 1.5rem 0;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    break-inside: avoid;
    page-break-inside: avoid;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
}

.prose img:hover {
    opacity: 0.9;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* ────────────────────────────────────────────────────────────────────────────
   IMAGE PREVIEW MODAL
   ──────────────────────────────────────────────────────────────────────────── */

.image-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s;
    cursor: pointer;
    overflow: hidden;
}

.image-preview-modal.hidden {
    display: none;
}

.image-preview-container {
    position: relative;
    width: 90vw;
    height: 90vh;
    max-width: 1200px;
    max-height: 800px;
    overflow: hidden;
    border-radius: 0.5rem;
    background: #000;
}

.image-preview-container img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    margin: 0;
    border: none;
    box-shadow: none;
    border-radius: 0;
    cursor: grab;
    transition: transform 0.1s ease-out;
}

.image-preview-container img:active {
    cursor: grabbing;
}

.image-preview-controls {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.8);
    padding: 1rem;
    border-radius: 0.5rem;
    z-index: 10001;
    animation: slideUp 0.3s;
    flex-wrap: wrap;
    justify-content: center;
}

.image-preview-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    background: rgba(59, 130, 246, 0.8);
    border: 1px solid rgba(59, 130, 246, 0.9);
    border-radius: 0.375rem;
    color: #fff;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    padding: 0;
    font-family: monospace;
}

.image-preview-button:hover {
    background: rgba(59, 130, 246, 1);
    border-color: #fff;
    transform: scale(1.1);
}

.image-preview-button:active {
    transform: scale(0.95);
}

.image-preview-info {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-family: monospace;
    z-index: 10001;
    animation: slideDown 0.3s;
}

.image-preview-close {
    position: absolute;
    top: 1rem;
    left: 1rem;
    width: 2.5rem;
    height: 2.5rem;
    background: rgba(239, 68, 68, 0.8);
    border: 1px solid rgba(239, 68, 68, 0.9);
    border-radius: 0.375rem;
    color: #fff;
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10002;
    line-height: 1;
    padding: 0;
    font-family: monospace;
}

.image-preview-close:hover {
    background: rgba(239, 68, 68, 1);
    border-color: #fff;
    transform: scale(1.1);
}

.image-preview-close:active {
    transform: scale(0.95);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-1rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ────────────────────────────────────────────────────────────────────────────
   BLOCKQUOTE
   ──────────────────────────────────────────────────────────────────────────── */

.prose blockquote {
    position: relative;
    border-left: 4px solid var(--c-blue-500);
    background: linear-gradient(135deg, rgba(59,130,246,0.07) 0%, rgba(99,102,241,0.04) 100%);
    padding: 0.6rem 1rem 0.6rem 1.25rem;
    margin: 1.25rem 0;
    border-radius: 0 0.5rem 0.5rem 0;
    color: var(--prose-text);
    font-style: italic;
    box-shadow: 0 1px 4px rgba(59,130,246,0.08);
    break-inside: avoid;
    page-break-inside: avoid;
}

.prose blockquote::before {
    content: '\201C';
    position: absolute;
    top: 0.1rem;
    left: 0.35rem;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--c-blue-400);
    opacity: 0.35;
    font-style: normal;
    pointer-events: none;
}

.prose blockquote p {
    margin: 0;
    padding-left: 1.25rem;
    color: inherit;
}

.prose blockquote + blockquote {
    margin-top: 0.25rem;
}

.prose blockquote blockquote {
    margin-top: 0.5rem;
    margin-bottom: 0;
    padding: 0.45rem 0.8rem 0.45rem 1rem;
    box-shadow: none;
    border-left-color: #06b6d4;
    background: linear-gradient(135deg, rgba(6,182,212,0.07) 0%, rgba(8,145,178,0.04) 100%);
}

.prose blockquote blockquote::before { display: none; }
.prose blockquote blockquote p { padding-left: 0; }

.prose blockquote blockquote blockquote {
    border-left-color: #10b981;
    background: linear-gradient(135deg, rgba(16,185,129,0.07) 0%, rgba(5,150,105,0.04) 100%);
}

.prose blockquote blockquote blockquote blockquote {
    border-left-color: #8b5cf6;
    background: linear-gradient(135deg, rgba(139,92,246,0.07) 0%, rgba(109,40,217,0.04) 100%);
}

.prose blockquote blockquote blockquote blockquote blockquote {
    border-left-color: #f87171;
    background: linear-gradient(135deg, rgba(248,113,113,0.07) 0%, rgba(239,68,68,0.04) 100%);
}

/* ────────────────────────────────────────────────────────────────────────────
   CSV HIGHLIGHT
   ──────────────────────────────────────────────────────────────────────────── */

.csv-col-0  { color: #4f46e5; }
.csv-col-1  { color: #0891b2; }
.csv-col-2  { color: #16a34a; }
.csv-col-3  { color: #b45309; }
.csv-col-4  { color: #be123c; }
.csv-col-5  { color: #7c3aed; }
.csv-col-6  { color: #0369a1; }
.csv-col-7  { color: #065f46; }
.csv-col-8  { color: #92400e; }
.csv-col-9  { color: #9f1239; }
.csv-col-10 { color: #6d28d9; }
.csv-col-11 { color: #0e7490; }
.csv-col-12 { color: #15803d; }
.csv-col-13 { color: #b45309; }
.csv-col-14 { color: #db2777; }
.csv-col-15 { color: #1d4ed8; }

/* ────────────────────────────────────────────────────────────────────────────
   VARIABLES HIGHLIGHT
   ──────────────────────────────────────────────────────────────────────────── */

.var-dynamic {
    padding: 0.125rem 0;
    border-radius: 0.25rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', 'Monaco', 'Courier New', monospace;
    transition: background-color 0.2s, color 0.2s;
    cursor: pointer;
}

.var-highlight {
    background: var(--c-blue-100);
    color: var(--c-blue-800);
}

/* ────────────────────────────────────────────────────────────────────────────
   INFO BUTTON & HINTS POPUP
   ──────────────────────────────────────────────────────────────────────────── */

.info-button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.info-button:hover {
    background: var(--c-slate-200);
    color: var(--c-blue-600);
}

.hints-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.2s;
}

.hints-popup-content {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 0.75rem;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    animation: slideUp 0.3s;
}

.hints-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.hints-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.hints-close-btn:hover {
    background: var(--c-slate-200);
    color: var(--text-body);
}

.hints-popup-body {
    padding: 1.25rem;
}

.hint-item {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.hint-item:last-child {
    margin-bottom: 0;
}

.hint-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.hint-item strong {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--text-body);
}

.hint-item p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.875rem;
    line-height: 1.5;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(1rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ────────────────────────────────────────────────────────────────────────────
   FOOTER
   ──────────────────────────────────────────────────────────────────────────── */

.site-footer {
    background-color: var(--bg-header);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ────────────────────────────────────────────────────────────────────────────
   MOBILE RESPONSIVE
   ──────────────────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .mobile-only { display: flex; }
    .hide-on-homepage .mobile-only { display: none; }

    .container { padding-left: 1rem; padding-right: 1rem; }
    
    .site-header {
        position: relative;
    }
    
    .header-inner {
        height: 4rem;
        padding: 0;
        gap: 0.75rem;
    }
    
    .logo {
        flex: 1;
        min-width: 150px;
    }
    
    nav {
        flex-shrink: 0;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    
    .header-search {
        display: none !important;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        padding: 0.75rem 1rem;
        background-color: var(--bg-header);
        border-bottom: 1px solid var(--border-color);
        z-index: 10;
        order: 0;
        width: auto;
        max-width: none;
        margin: 0;
    }

    .search-icon {
        left: 1.75rem !important;
    }

    .header-search.active {
        display: block !important;
    }
    
    .header-search .form-input {
        width: 100%;
    }
    
    .cheatsheet-grid {
        grid-template-columns: 1fr !important;
    }
    
    .nav-list {
        display: block;
    }
    
    .sheet-layout { flex-direction: column; }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 80vh;
        position: relative;
        top: 0;
        border-right: none;
        border-bottom: 1px solid var(--border-sidebar);
        transition: max-height 0.3s ease;
    }
    
    .sidebar.collapsed {
        width: 100%;
        max-height: 3.5rem;
    }
    
    .sidebar-content {
        width: 100%;
    }
    
    .sidebar.collapsed .sidebar-content {
        display: none;
    }
    
    .main-content { padding: 1rem; }
    
    .sidebar-toggle-btn {
        margin: 0;
        border-radius: 0;
        border-top: 1px solid var(--border-sidebar);
        justify-content: center;
        width: 100%;
    }
    
    .sidebar.collapsed .toggle-icon { transform: rotate(-90deg); }
    
    .sidebar.collapsed .sidebar-toggle-btn span {
        display: inline;
    }

    /* Mobile-specific image styles */
    .prose img {
        margin: 1rem 0;
        border-radius: 0.375rem;
    }

    .sheet-container {
        max-width: 100%;
    }

    /* Mobile preview modal adjustments */
    .image-preview-container {
        width: 95vw;
        height: 95vh;
        border-radius: 0.375rem;
    }

    .image-preview-controls {
        bottom: 1rem;
        gap: 0.5rem;
        padding: 0.75rem;
    }

    .image-preview-button {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 0.9rem;
    }

    .image-preview-close {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 1.25rem;
    }

    .image-preview-info {
        font-size: 0.75rem;
        padding: 0.5rem 0.75rem;
    }
}

/* ────────────────────────────────────────────────────────────────────────────
   MERMAID DIAGRAM (server-side rendered SVG)
   ──────────────────────────────────────────────────────────────────────────── */

.mermaid-diagram {
    --mermaid-bg: #f8fafc;
    --mermaid-border: #cbd5e1;
    --mermaid-node-fill: #eef2ff;
    --mermaid-node-soft-fill: #e2e8f0;
    --mermaid-node-stroke: #94a3b8;
    --mermaid-edge: #64748b;
    --mermaid-lifeline: #cbd5e1;
    --mermaid-text: #1f2937;
    --mermaid-text-muted: #334155;
    --mermaid-label-bg: rgb(248 250 252 / 0.78);
    --mermaid-label-border: rgb(148 163 184 / 0.5);
    display: flex;
    justify-content: center;
    margin: 1rem 0;
    overflow-x: auto;
    border-radius: 0.375rem;
    padding: 0.75rem 0.5rem;
    background: var(--mermaid-bg);
    border: 1px solid var(--mermaid-border);
}

.mermaid-diagram svg {
    max-width: 100%;
    height: auto;
    display: block;
}

.mermaid-diagram .mermaid-native {
    overflow: visible;
}

.mermaid-diagram text {
    fill: var(--mermaid-text);
    font-family: ui-sans-serif, system-ui, sans-serif;
    font-size: 12px;
}

.mermaid-diagram .class-title,
.mermaid-diagram .er-entity,
.mermaid-diagram .git-branch {
    font-weight: 700;
}

.mermaid-diagram .class-member,
.mermaid-diagram .er-field,
.mermaid-diagram .seq-label,
.mermaid-diagram .git-label,
.mermaid-diagram .flow-label {
    font-size: 11px;
}

html.dark .mermaid-diagram {
    --mermaid-bg: #0f172a;
    --mermaid-border: #334155;
    --mermaid-node-fill: #162033;
    --mermaid-node-soft-fill: #1e293b;
    --mermaid-node-stroke: #64748b;
    --mermaid-edge: #93c5fd;
    --mermaid-lifeline: #475569;
    --mermaid-text: #e2e8f0;
    --mermaid-text-muted: #cbd5e1;
    --mermaid-label-bg: rgb(15 23 42 / 0.72);
    --mermaid-label-border: rgb(100 116 139 / 0.7);
}
