/* ============================================
   FONTS & RESET
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap');

/* Prevent FOUC */
html {
    visibility: visible;
    opacity: 1;
}

:root {
    --bg-color: #f5f3f0;
    --text-color: #2d2d2d;
    --text-secondary: #666;
    --border-color: #2d2d2d;
    --border-light: #d0ceca;
    --code-bg: #e8e6e3;
    --hover-bg: #eeece9;
    --nav-bg: #f5f3f0;
    --shadow: rgba(0, 0, 0, 0.1);
    --logo-border: #1a1a1a;
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --text-color: #e0e0e0;
    --text-secondary: #a0a0a0;
    --border-color: #404040;
    --border-light: #303030;
    --code-bg: #2d2d2d;
    --hover-bg: #252525;
    --nav-bg: #1a1a1a;
    --shadow: rgba(0, 0, 0, 0.3);
    --logo-border: #d0ceca;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ============================================
   LAYOUT
   ============================================ */
body {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.8;
    font-size: 16px;
    display: flex;
    min-height: 100vh;
    flex-direction: row;
    transition: background-color 0.3s ease, color 0.3s ease;
    word-spacing: 0.1em;
}

body.menu-open {
    overflow: hidden;
}

.container {
    margin-left: 300px;
    flex: 1;
    padding: 60px 60px 0 60px;
    max-width: 1000px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.content {
    width: 100%;
    flex: 1;
    padding-bottom: 40px;
}

/* ============================================
   NAVIGATION
   ============================================ */
nav {
    width: 300px;
    padding: 60px 35px 20px 35px;
    border-right: 2px solid var(--border-color);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    background-color: var(--nav-bg);
    transition: background-color 0.3s ease, border-color 0.3s ease;
    display: flex;
    flex-direction: column;
}

.nav-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 2em;
}

.nav-logo {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    object-fit: cover;
    transition: border-color 0.3s ease;
    border: 4px solid var(--logo-border);
    content-visibility: auto;
}

nav h2 {
    font-size: 1.8em;
    margin-bottom: 1em;
    margin-top: 0;
    color: var(--text-color);
    transition: color 0.3s ease;
}

.burger-menu {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 30px;
    justify-content: space-between;
}

.burger-menu span {
    display: block;
    width: 100%;
    height: 4px;
    background-color: var(--text-color);
    transition: transform 0.3s, opacity 0.3s, background-color 0.3s ease;
}

.burger-menu.active span:nth-child(1) {
    transform: translateY(13px) rotate(45deg);
}

.burger-menu.active span:nth-child(2) {
    opacity: 0;
}

.burger-menu.active span:nth-child(3) {
    transform: translateY(-13px) rotate(-45deg);
}

.nav-spacer {
    flex: 1;
}

.nav-spacer-bottom {
    flex: 5;
}

.nav-links {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.nav-links li {
    margin-bottom: 0.8em;
    padding-left: 0;
}

.nav-links li:before {
    content: none;
}

.theme-toggle-wrapper {
    padding-left: 0 !important;
    margin-top: auto;
    margin-bottom: -30px;
}

.theme-toggle-wrapper:before {
    content: none !important;
}

nav a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    font-size: 1.3em;
    transition: color 0.3s ease;
}

nav a:hover {
    text-decoration: underline;
}


.theme-toggle {
    background: none;
    border: 2px solid var(--border-color);
    color: var(--text-color);
    cursor: pointer;
    padding: 10px;
    border-radius: 5px;
    font-size: 1.2em;
    width: 100%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background-color: var(--hover-bg);
    transform: scale(1.05);
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1 {
    font-size: clamp(0.8rem, 2vw, 2.5rem);
    margin-bottom: 0.5em;
    color: var(--text-color);
    font-weight: 700;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
    transition: color 0.3s ease, border-color 0.3s ease;
    white-space: nowrap;
}

h2 {
    font-size: 1.8em;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    color: var(--text-color);
    font-weight: 500;
    transition: color 0.3s ease;
}

h3 {
    font-size: 1.3em;
    margin-top: 1.2em;
    margin-bottom: 0.3em;
    color: var(--text-color);
    font-weight: 500;
    transition: color 0.3s ease;
}

h4 {
    font-size: 1.1em;
    margin-top: 1em;
    margin-bottom: 0.3em;
    color: var(--text-color);
    font-weight: 500;
    transition: color 0.3s ease;
}

p {
    margin-bottom: 1em;
}

strong, b {
    font-weight: 700;
}

em, i {
    font-style: italic;
}

/* ============================================
   LINKS
   ============================================ */
a {
    color: var(--text-color);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    text-decoration-skip-ink: none;
    transition: text-decoration-thickness 0.2s, color 0.3s ease;
    word-spacing: 0;
    margin-right: 0;
}

a:hover {
    text-decoration-thickness: 2px;
}

/* ============================================
   LISTS
   ============================================ */
ul {
    list-style: none;
    padding-left: 0;
}

ul li {
    margin-bottom: 0.2em;
    line-height: 1.3;
    padding-left: 2em;
    position: relative;
}

ul li:before {
    content: ">";
    position: absolute;
    left: 0.5em;
    top: 0;
    color: var(--text-color);
    font-weight: 700;
    transition: color 0.3s ease;
}

/* Nested lists - different symbols */
ul ul {
    margin-top: 0.2em;
}

ul ul li:before {
    content: "-";
    font-weight: 700;
}

ul ul ul {
}

ul ul ul li:before {
    content: "-";
    font-weight: 400;
}

ol {
    margin-left: 1.5em;
    margin-bottom: 1em;
}

ol li {
    margin-bottom: 0.2em;
    line-height: 1.3;
}

/* Nested ordered lists */
ol ol {
    margin-left: 1.5em;
    margin-top: 0.2em;
}

ol ol ol {
    margin-left: 2em;
}

/* ============================================
   IMAGES & MEDIA
   ============================================ */
img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 2em 0;
    border: 2px solid var(--border-color);
    cursor: zoom-in;
    transition: opacity 0.2s, border-color 0.3s ease;
}

img:hover {
    opacity: 0.9;
}

a img {
    border: none;
    cursor: pointer;
}

a img:hover {
    opacity: 1;
}

figure {
    margin: 2em 0;
}

figcaption {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-top: 0.5em;
    text-align: center;
    font-style: italic;
    transition: color 0.3s ease;
}

/* ============================================
   CODE BLOCKS
   ============================================ */
code {
    background-color: var(--code-bg);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 0.9em;
    transition: background-color 0.3s ease;
}

pre {
    background-color: var(--code-bg);
    padding: 1em;
    border-radius: 3px;
    overflow-x: auto;
    margin: 1.5em 0;
    border: 1px solid var(--border-color);
    position: relative;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
}

.code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 8px 10px;
    background-color: var(--text-color);
    color: var(--bg-color);
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.2s, transform 0.2s, color 0.3s ease;
    user-select: none;
}

.code-copy-btn i {
    transition: transform 0.2s;
}

.code-copy-btn:hover {
    background-color: #404040;
}

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

.code-copy-btn.copied i {
    transform: scale(1.1);
}

/* ============================================
   BLOCKQUOTES
   ============================================ */
blockquote {
    border-left: 4px solid var(--border-light);
    padding-left: 1em;
    margin: 1.5em 0;
    color: var(--text-secondary);
    font-style: italic;
    transition: border-color 0.3s ease, color 0.3s ease;
}

blockquote p {
    margin-bottom: 0.5em;
}

blockquote a {
    margin-right: -0.25em;
}

blockquote p:last-child::after {
    content: none;
    margin: 0;
}

/* ============================================
   TABLES
   ============================================ */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 2em 0;
    font-size: 0.95em;
}

table thead {
    background-color: var(--code-bg);
    transition: background-color 0.3s ease;
}

table th {
    padding: 12px 15px;
    text-align: left;
    border: 1px solid var(--border-color);
    font-weight: 700;
    transition: border-color 0.3s ease;
}

table td {
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    transition: border-color 0.3s ease;
}

table tbody tr:nth-child(even) {
    background-color: var(--code-bg);
    transition: background-color 0.3s ease;
}

table tbody tr:hover {
    background-color: var(--hover-bg);
}

table a {
    word-break: break-word;
}

/* ============================================
   POST LIST
   ============================================ */
.post-list {
    margin-top: 2em;
}

.post-list li {
    padding-left: 0;
    margin-bottom: 1em;
}

.post-list li:before {
    content: none;
}

.post-list .date {
    color: var(--text-secondary);
    font-size: 0.9em;
    transition: color 0.3s ease;
}

/* ============================================
   HORIZONTAL RULE
   ============================================ */
hr {
    border: none;
    border-top: 2px solid var(--border-color);
    margin: 2em 0;
    transition: border-color 0.3s ease;
}

/* ============================================
   FOOTER
   ============================================ */
footer {
    padding: 30px 60px;
    text-align: left;
    font-size: 0.9em;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-light);
    margin-top: 40px;
    padding-top: 30px;
    transition: color 0.3s ease, border-color 0.3s ease;
}

footer p {
    margin: 0;
}

footer a {
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Tablet layout */
@media (max-width: 1024px) {
    .container {
        max-width: 100%;
        padding: 50px 40px;
    }
}

/* Mobile layout */
@media (max-width: 768px) {
    body {
        flex-direction: column;
        font-size: 16px;
    }
    
    nav {
        width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 2px solid var(--border-color);
        padding: 25px 20px 25px 20px;
        box-sizing: border-box;
        overflow: visible;
    }
    
    .nav-header {
        justify-content: space-between;
        margin-bottom: 0;
    }
    
    .nav-logo {
        width: 80px;
        height: 80px;
    }
    
    .burger-menu {
        margin-right: 15px;
    }
    
    nav h2 {
        font-size: 1.5em;
        margin-bottom: 0;
    }
    
    nav a {
        font-size: 1.25em;
    }
    
    .burger-menu {
        display: flex;
        position: absolute;
        top: 35px;
        right: 20px;
        z-index: 1002;
    }
    
    .nav-links .nav-spacer,
    .nav-spacer-bottom {
        display: none;
    }
    
    .nav-links .theme-toggle-wrapper {
        position: fixed;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        width: 90%;
        max-width: 300px;
        z-index: 1001;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
    
    .nav-links.active .theme-toggle-wrapper {
        opacity: 1;
        pointer-events: auto;
    }
    
    .theme-toggle {
        margin: 0;
        width: 100%;
    }
    
    .nav-links {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background-color: var(--nav-bg);
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        z-index: 1000;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
        margin-top: 0;
        padding-bottom: 100px;
    }
    
    .nav-links.active {
        opacity: 1;
        pointer-events: auto;
    }
    
    .nav-links li {
        margin-bottom: 1.5em;
        text-align: center;
    }
    
    .nav-links a {
        font-size: 1.8em !important;
    }
    
    .container {
        margin-left: 0;
        padding: 30px 20px;
        overflow-x: hidden;
    }
    
    .content {
        overflow-wrap: break-word;
        word-wrap: break-word;
        word-break: break-word;
    }
    
    h1 {
        font-size: 2em;
        line-height: 1.2;
        white-space: normal;
        overflow-wrap: break-word;
        word-wrap: break-word;
    }
    
    h2 {
        font-size: 1.6em;
        margin-top: 1.2em;
    }
    
    h3 {
        font-size: 1.2em;
    }
    
    /* Tables on mobile */
    table {
        font-size: 0.85em;
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    table th,
    table td {
        padding: 8px 10px;
    }
    
    /* Code blocks on mobile */
    pre {
        font-size: 0.85em;
        padding: 0.8em;
    }
    
    .code-copy-btn {
        padding: 6px 8px;
        font-size: 0.9em;
    }
    
    /* Images on mobile */
    img {
        margin: 1.5em 0;
        max-width: 100%;
        height: auto;
        width: auto;
    }
    
    /* Videos and iframes on mobile */
    iframe,
    video {
        max-width: 100%;
        height: auto;
    }
    
    /* YouTube embeds */
    iframe[src*="youtube"],
    iframe[src*="youtu.be"] {
        width: 100%;
        aspect-ratio: 16 / 9;
        height: auto;
    }
    
    /* Lists on mobile */
    ul li {
        padding-left: 1.5em;
    }
    
    /* Blockquotes on mobile */
    blockquote {
        padding-left: 0.8em;
        border-left-width: 3px;
        font-size: 0.95em;
    }

    /* Footer on mobile */
    footer {
        padding: 25px 20px;
        font-size: 0.8em;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }
    
    nav {
        padding: 20px 15px;
    }
    
    nav h2 {
        font-size: 1.2em;
    }
    
    nav ul li {
        margin-right: 1em;
    }
    
    .container {
        padding: 20px 15px;
    }
    
    h1 {
        font-size: 1.8em;
        padding-bottom: 8px;
    }
    
    h2 {
        font-size: 1.4em;
    }
    
    h3 {
        font-size: 1.1em;
    }
    
    table {
        font-size: 0.8em;
    }
    
    table th,
    table td {
        padding: 6px 8px;
    }
    
    pre {
        font-size: 0.8em;
        padding: 0.6em;
    }
    
    .code-copy-btn {
        top: 6px;
        right: 6px;
        padding: 5px 7px;
        font-size: 0.85em;
    }
    
    .image-modal-close {
        top: 10px;
        right: 15px;
        font-size: 30px;
    }
    
    .image-modal img {
        max-width: 98%;
        max-height: 98%;
    }

    /* Footer on small mobile */
    footer {
        padding: 20px 15px;
        font-size: 0.75em;
    }
}

/* ============================================
   IMAGE ZOOM MODAL
   ============================================ */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0);
    z-index: 9999;
    cursor: zoom-out;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

.image-modal.active {
    display: flex;
    background-color: rgba(0, 0, 0, 0.9);
}

.image-modal img {
    max-width: 95%;
    max-height: 95%;
    margin: 0;
    border: 3px solid #f5f3f0;
    cursor: zoom-out;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.image-modal.active img {
    opacity: 1;
    transform: scale(1);
}

.image-modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #f5f3f0;
    font-size: 40px;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
}

.image-modal-close:hover {
    color: #ccc;
}
