:root {
    --font-mono: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace;
    --color-text-primary: #fff;
    --color-text-secondary: rgba(255, 255, 255, 0.8);
    --color-text-muted: rgba(255, 255, 255, 0.5);
    --color-bg: #1a1a1a;
}

/* =========================================
   1. GLOBAL RESET & LAYOUT
   ========================================= */

* {
    box-sizing: border-box;
}

html {
    width: 100%;
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
    margin: 0;
    padding: 0;
    position: relative;
    font-family: var(--font-mono) !important;
    text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: var(--color-bg);
    color: rgba(255, 255, 255, 0.85);
    font-size: 16px;
    line-height: 1.7;
}

h1, h2, h3, h4, h5, h6, p, a, span, div {
    font-family: inherit;
}

/* Prevent image overflow */
img, video, iframe {
    max-width: 100%;
    height: auto;
}

/* Ensure form elements inherit font settings */
input, button, textarea, select {
    font-family: inherit;
}

/* Selective bold removal for typewriter aesthetic - only in body text */
.blog-body strong,
.blog-body b,
.project-body strong,
.project-body b,
.post-item strong,
.post-item b {
    font-weight: normal;
}

/* Allow bold in headings, navigation, and UI elements for hierarchy */
h1 strong, h1 b,
h2 strong, h2 b,
h3 strong, h3 b,
nav strong, nav b,
button strong, button b,
.label strong, .label b {
    font-weight: 600;
}

/* =========================================
   2. BACKGROUNDS & TEXTURES
   ========================================= */

/* Subtle paper texture for typewriter effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(255, 255, 255, 0.01) 0px,
        rgba(255, 255, 255, 0.01) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 0;
}

/* Scrolling multi-color gradient background */
.bg-anim {
    display: none; /* Hidden by default, pages can override */
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: linear-gradient(115deg, #1c1f27 0%, #283048 12%, #414d6b 25%, #4a4d6a 37%, #5a4a60 50%, #4a4d6a 63%, #414d6b 75%, #283048 88%, #1c1f27 100%);
    background-size: 300% 300%;
    animation: scrollGradient 200s linear infinite;
    filter: brightness(0.95) contrast(1.05) saturate(110%);
    will-change: background-position;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.bg-anim::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 40%, rgba(255,255,255,0.06), transparent 60%), radial-gradient(circle at 75% 70%, rgba(255,255,255,0.04), transparent 65%);
    mix-blend-mode: overlay;
    pointer-events: none;
}

.bg-anim::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(0deg, rgba(255,255,255,0.015) 0 1px, transparent 1px 2px);
    opacity: 0.25;
    mix-blend-mode: soft-light;
    pointer-events: none;
}

@keyframes scrollGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.bg-veil {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(0,0,0,0.65) 0%, rgba(0,0,0,0.45) 20%, rgba(0,0,0,0.45) 80%, rgba(0,0,0,0.65) 100%);
    width: 100% !important;
    max-width: 100% !important;
}

/* =========================================
   3. ACCESSIBILITY & UX
   ========================================= */

/* Safe Skip Link */
.skip-to-content {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-to-content:focus {
    position: absolute;
    width: auto;
    height: auto;
    padding: 1em;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    top: 20px;
    left: 20px;
    z-index: 9999;
    background: #fff;
    color: #000;
    text-decoration: none;
    font-weight: bold;
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Accessible focus styles */
*:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

/* Selection styling */
::selection {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

::-moz-selection {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

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

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

/* =========================================
   4. SHARED COMPONENTS
   ========================================= */

/* Links */
a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

a:hover {
    color: #e0e0e0;
}

.back-link {
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s ease;
    display: block;
    margin-bottom: 20px;
}
.back-link:hover {
    color: rgba(255, 255, 255, 0.9);
}

.hub-link {
    color: rgba(135, 206, 250, 0.9);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    margin-bottom: 20px;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.2s ease;
    padding: 6px 0;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    border-bottom: 1px solid rgba(135, 206, 250, 0.3);
}
.hub-link:hover {
    color: rgba(135, 206, 250, 1);
    border-bottom-color: rgba(135, 206, 250, 0.6);
}

/* Code Blocks & Copy Button */
.code-block-wrapper {
    position: relative;
    margin: 1em 0;
}

pre {
    background: rgba(0, 0, 0, 0.3) !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0;
    padding: 16px !important;
    overflow-x: auto;
    max-width: 100%;
    white-space: pre;
    position: relative;
}
pre code.hljs {
    background: transparent !important;
    padding: 0 !important;
}

code:not(.hljs) {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 0;
    font-size: 0.9em;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Copy Code Button */
.copy-code-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    padding: 4px 8px;
    cursor: pointer;
    font-family: inherit;
    text-transform: lowercase;
    transition: color 0.2s ease;
    z-index: 10;
}

.copy-code-btn:hover {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: underline;
}

.copy-code-btn.copied {
    color: #4CAF50;
}

/* Ensure pre blocks have enough padding for the button */
.code-block-wrapper pre {
    padding: 1em;
    padding-top: 2.5em;
}

/* Shared Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInPage {
    to { opacity: 1; }
}

/* Shared Lightbox Styles */
#lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    box-sizing: border-box;
    background: rgba(10, 10, 10, 0.95);
    z-index: 12000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(5px);
}
#lightbox.active { opacity: 1; visibility: visible; }
#lightbox img {
    max-width: 95%;
    max-height: 95%;
    width: auto;
    height: auto;
    object-fit: contain;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    transition: transform 0.3s ease, opacity 0.3s ease;
}
#lightbox-close { position: absolute; top: 30px; right: 30px; width: 40px; height: 40px; cursor: pointer; z-index: 12002; display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, 0.1); border-radius: 0; transition: background 0.2s; }
#lightbox-close:hover { background: rgba(255, 255, 255, 0.2); }
#lightbox-close::before, #lightbox-close::after { content: ''; position: absolute; width: 20px; height: 2px; background: #fff; transform: rotate(45deg); }
#lightbox-close::after { transform: rotate(-45deg); }
.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 50px; height: 50px; background: rgba(255,255,255,0.05); border: none; color: #fff; font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.2s; border-radius: 0; z-index: 12002; }
.lightbox-nav:hover { background: rgba(255,255,255,0.15); transform: translateY(-50%); }
.lightbox-prev { left: 30px; }
.lightbox-next { right: 30px; }
.lightbox-loader {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 40px; height: 40px;
    border: 3px solid rgba(255,255,255,0.1); border-top-color: #fff; border-radius: 0;
    animation: spin 1s linear infinite; z-index: 12001; opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
#lightbox.loading .lightbox-loader { opacity: 1; }
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* Page Transitions */
.containgrid,
.masonry-container,
.portfolio-masonry,
.blog-layout,
.container {
    opacity: 0;
    animation: fadeInPage 0.6s ease forwards;
}

/* === Shared Content Typography (Blog & Portfolio) === */
.blog-body, .project-body {
    max-width: 100%;
    font-size: 16px;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.75);
}

.blog-body h2, .project-body h2 {
    font-size: 24px;
    font-weight: 400;
    line-height: 1.3;
    margin: 60px 0 20px 0;
    color: rgba(255, 255, 255, 0.9);
    text-transform: none;
    letter-spacing: 0.02em;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.blog-body h3, .project-body h3 {
    font-size: 18px;
    font-weight: 400;
    line-height: 1.4;
    margin: 40px 0 16px 0;
    color: rgba(255, 255, 255, 0.85);
    text-transform: none;
    letter-spacing: 0.02em;
}

.blog-body p, .project-body p { margin-bottom: 1.5em; }

.blog-body img, .project-body img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 60px 0;
    border: none;
    filter: grayscale(0.15) contrast(1.05);
    cursor: zoom-in;
}

.blog-body a, .project-body a {
    color: rgba(255, 255, 255, 0.75);
    text-decoration: underline;
    text-decoration-style: dotted;
    text-decoration-color: rgba(224, 224, 224, 0.4);
    transition: all 0.2s ease;
}
.blog-body a:hover, .project-body a:hover {
    color: #e0e0e0;
    text-decoration-style: solid;
    text-decoration-color: #e0e0e0;
}

.blog-body ul, .blog-body ol, .project-body ul, .project-body ol { margin-bottom: 1.5em; padding-left: 0; }
.blog-body ul, .project-body ul { list-style: none; }
.blog-body ol, .project-body ol { list-style-type: decimal; }
.blog-body li, .project-body li { margin-bottom: 0.8em; position: relative; }
.blog-body ul li, .project-body ul li { padding-left: 30px; }
.blog-body ul li::before, .project-body ul li::before { content: '→'; position: absolute; left: 0; color: rgba(255,255,255,0.3); }

.blog-body blockquote, .project-body blockquote {
    margin: 40px 0;
    padding: 20px 20px 20px 30px;
    border-left: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.03);
    font-style: italic;
    color: rgba(255, 255, 255, 0.65);
    font-size: 16px;
    line-height: 1.7;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
 
/* --- Compact footer meta (Connections, etc.) --- */
.content-footer-meta {
    margin-top: 50px;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 20px;
}
.content-footer-meta h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.4;
    margin: 0 0 12px 0;
    font-weight: normal;
}
.content-footer-meta .connections-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0 30px;
}

@media (max-width: 768px) {
    .content-footer-meta .connections-list {
        grid-template-columns: 1fr;
    }
}

.content-footer-meta .connection-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 2px;
    margin-bottom: 6px;
    text-decoration: none;
    color: rgba(255,255,255,0.8);
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.content-footer-meta .connection-card:hover {
    background: rgba(0,0,0,0.4);
    border-color: rgba(255,255,255,0.12);
}

.content-footer-meta .type-badge {
    display: inline-block;
    align-self: flex-start;
    padding: 3px 6px;
    font-size: 7px;
    font-family: var(--font-mono);
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    border-radius: 2px;
    line-height: 1.2;
}

.content-footer-meta .type-badge.type-post {
    background: rgba(33, 150, 243, 0.2);
    color: #2196f3;
}

.content-footer-meta .type-badge.type-project {
    background: rgba(156, 39, 176, 0.2);
    color: #9c27b0;
}

.content-footer-meta .type-badge.type-photo {
    background: rgba(76, 175, 80, 0.2);
    color: #4caf50;
}

.content-footer-meta .connection-title {
    font-size: 11px;
    font-family: var(--font-mono);
    white-space: normal;
    line-height: 1.3;
    font-weight: 400;
    letter-spacing: 0.2px;
    color: rgba(255,255,255,0.85);
    transition: color 0.15s;
}

.content-footer-meta .connection-card:hover .connection-title {
    color: rgba(255,255,255,1);
}

.content-footer-meta .connection-reasons {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 2px;
}

.content-footer-meta .reason-line {
    display: grid;
    grid-template-columns: 60px 1fr;
    gap: 8px;
    font-size: 8px;
    line-height: 1.4;
}

.content-footer-meta .reason-label {
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    font-size: 7px;
}

.content-footer-meta .reason-value {
    color: rgba(255,255,255,0.7);
    letter-spacing: 0.2px;
    font-weight: 400;
    text-transform: uppercase;
}