/* style.css - Minimalist UI framework for no-jsbs */
*, *::before, *::after {
    box-sizing: border-box;
}
/* === FOOLPROOF MOBILE SAFEGUARD === */
html, body {
    max-width: 100vw;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%; /* Prevents iOS from auto-zooming text */
}
:root {
    --bg-main: #ffffff;
    --bg-sidebar: #f4f4f5;
    --border-color: #e4e4e7;
    --text-primary: #18181b;
    --text-muted: #71717a;
    --link-color: #2563eb;
    --link-hover: #1d4ed8;
    --tag-bg: #dcfce7;
    --tag-text: #16a34a;
    /* Added missing variables referenced in prose-content */
    --bg-canvas: #f4f4f5;
    --border-ui: #e4e4e7;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-main: #09090b;
        --bg-sidebar: #18181b;
        --border-color: #27272a;
        --text-primary: #f4f4f5;
        --text-muted: #a1a1aa;
        --link-color: #60a5fa;
        --link-hover: #3b82f6;
        --tag-bg: #14532d;
        --tag-text: #4ade80;
        --bg-canvas: #27272a;
        --border-ui: #3f3f46;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-main);
    color: var(--text-primary);
}

.layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    min-height: 100vh;
}

/* --- Dynamic Sidebar Frame --- */
.sidebar {
    background-color: var(--bg-sidebar);
    padding: 24px; /* Slightly reduced from 32px 24px for better proportion */
    border-right: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    height: auto;      /* Shrinks to fit content instead of forcing height */
    max-height: 100vh; /* Prevents it from exceeding the viewport */
    overflow-y: auto;  /* Only scrolls if the list of links gets too long */
    display: flex;
    flex-direction: column;
}

.sidebar h2 {
    font-size: 1.25rem;
    margin: 0 0 16px 0;
    font-weight: 700;
    margin-bottom: 12px; /* Was 16px */
}

.sidebar h2 a, .sidebar h3 a {
    color: var(--text-primary);
    text-decoration: none;
}

.rss-link {
    display: inline-block;
    color: var(--link-color);
    text-decoration: none;
    font-size: 0.875rem;
    margin-bottom: 16px;
}

.search-form {
    display: flex;
    gap: 8px;
    margin-bottom: 32px;
}

.search-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.search-input:focus {
    outline: 2px solid var(--link-color);
}

.search-button {
    padding: 8px 16px;
    background-color: var(--link-color);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    font-size: 0.875rem;
}

.search-button:hover {
    background-color: var(--link-hover);
}

.sidebar h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 0 0 12px 0;
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
}

.sidebar li {
    margin-bottom: 12px;
}

.sidebar li a {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.95rem;
}

.sidebar li a:hover {
    color: var(--link-color);
}

/* --- Main Dashboard View Panel --- */
/* --- Main Dashboard View Panel --- */
.main-panel {
    width: 100%;
    max-width: 90%; /* Leaves a 5% gutters on left/right, scales to any DPI */
    margin: 0 auto; /* Centers the content */
    padding: 48px 0; /* Vertical padding only; horizontal is handled by the 90% width */
}

/* Hide the redundant title injected by the PHP template */
.main-panel > h1:first-child {
    display: none;
}

.main-panel h1 {
    font-size: 2.25rem;
    font-weight: 800;
    margin: 0 0 16px 0;
    letter-spacing: -0.025em;
}

.main-panel hr {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 24px 0;
}

.search-item {
    margin-bottom: 40px;
}

.search-item h3 {
    font-size: 1.5rem;
    margin: 0 0 8px 0;
}

.search-item h3 a {
    color: var(--link-color);
    text-decoration: none;
}

.search-item h3 a:hover {
    text-decoration: underline;
}

.date {
    color: var(--text-muted);
    font-size: 0.85rem;
    display: block;
    margin-bottom: 12px;
}

.search-item p {
    line-height: 1.6;
    margin: 0 0 12px 0;
}

.tags {
    display: inline-block;
    background-color: var(--tag-bg);
    color: var(--tag-text);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin: 0;
}

/* --- Embedded Markdown Content Styling Rules --- */
.prose-content {
    line-height: 1.7;
    font-size: 1.05rem;
}

.prose-content h1, .prose-content h2, .prose-content h3 {
    margin-top: 32px;
    margin-bottom: 16px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.prose-content pre {
    background-color: var(--bg-canvas);
    border: 1px solid var(--border-ui);
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: monospace;
    font-size: 0.9rem;
    display: block;
    white-space: pre;
}

.prose-content :not(pre) > code {
    background-color: var(--bg-canvas);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    display: inline;
}

.prose-content pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
    display: block;
    white-space: pre;
}

.prose-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 32px auto;
    border-radius: 8px;
    border: 1px solid var(--border-ui);
}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-ui);
    margin-bottom: 32px;
}

.nav-social {
    font-size: 0.95rem;
    color: var(--text-muted, #666);
    text-decoration: none;
    border-bottom: 1px dashed transparent;
    transition: border-color 0.2s;
}

.nav-social:hover {
    color: var(--text-primary, #000);
    border-bottom-color: currentColor;
}

/* =========================================
   MOBILE RESPONSIVE ADDITIONS
   ========================================= */
@media (max-width: 768px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 24px 5%; /* Match the 5% horizontal fluid spacing */
    }

    .main-panel {
        padding: 32px 0; /* Reduce vertical padding on mobile */
    }

    .site-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
}

@media (max-width: 480px) {
    /* Stack search form vertically on very small screens */
    .search-form {
        flex-direction: column;
    }

    /* Ensure minimum 44px touch targets for mobile accessibility */
    .search-input,
    .search-button {
        width: 100%;
        min-height: 44px;
    }
}

/* =========================================
   CONTENT OVERFLOW PROTECTION (MARKDOWN)
   ========================================= */

/* 1. The Grid Gotcha Fix: Allow the main panel to shrink below its content size */
.main-panel {
    min-width: 0; /* CRITICAL: Prevents long code blocks from stretching the grid */
    overflow-wrap: break-word; /* Forces long URLs/words to wrap */
    word-wrap: break-word; /* Legacy support */
}

/* 2. Force all text content to wrap safely */
.prose-content {
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
}

/* 3. Contain code blocks so they scroll internally instead of stretching the page */
.prose-content pre,
.prose-content .codehilite, /* Python Markdown wrapper */
.prose-content .highlight {  /* Common alternative wrapper */
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    box-sizing: border-box;
}

/* 4. Ensure inline code doesn't push boundaries */
.prose-content code {
    max-width: 100%;
    white-space: pre-wrap; /* Allows wrapping inside inline code if needed */
    word-break: break-all;
}

/* 5. Nuclear option for any rogue images or iframes in the content */
.prose-content img,
.prose-content iframe,
.prose-content table {
    max-width: 100%;
    width: 100%;
    height: auto;
    display: block;
    box-sizing: border-box;
}

/* 6. Ensure tables don't break layout */
.prose-content table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
}
