/* ========================================
   1. Variables & Theme
   ======================================== */
:root {
    --header-min-height: 60px;
    --logo-size-desktop: 140px;
    --logo-size-mobile: 100px;
    --content-max-width: 63rem;
    --viewport-padding: 16px;

    /* Colors - Optimized for Readability & Eye Strain */
    --bg: #323233;
    --text-dark: #2d3748;
    
    /* Softer off-white instead of pure white (reduces halation on dark bg) */
    --text-light: #e8ecf1; 
    
    /* Brightened muted color (passes accessibility contrast checks comfortably) */
    --muted: #b0bec5;    
    
    /* Slightly brighter primary for better "pop" on dark backgrounds */
    --primary: #6a8fbe;    
    --primary-dark: #4a6a9e;

    /* Shadows & Effects */
    --border-radius: 18px;
    --shadow-3d: 
        inset 0 1px 0 rgba(255, 255, 255, 0.15), 
        0 10px 20px rgba(0, 0, 0, 0.2),
        0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-color: 252deg 2% 20%;
    
    /* Missing variables added */
    --transition-speed: 0.3s ease;
    --shadow-elevation-low: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-elevation-medium: 0 8px 16px rgba(0, 0, 0, 0.25);
}

/* ========================================
   2. Reset & Base
   ======================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: var(--bg);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: clamp(16px, 2vw, 18px);
    line-height: 1.6;
    color: var(--text-light);
    min-height: 100vh;
}

h1, h2, h3, .logo-text, code, pre {
    font-family: 'Courier New', Courier, monospace;
    font-weight: 700;
}

img,
picture,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
    height: auto;
}

input,
button,
textarea,
select {
    font: inherit;
}

p,
h1, h2, h3, h4, h5, h6 {
    overflow-wrap: break-word;
}

p {
    margin-bottom: 1.5rem;
}

h1, h2, h3, h4, h5, h6 {
    margin: 1.5rem 0;
    line-height: 1.2;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--text-light);
    outline-offset: 2px;
    border-radius: 4px;
}

/* App root isolation */
#root,
#__next {
    isolation: isolate;
}

/* ========================================
   3. Layout
   ======================================== */
.wrapper {
    display: grid;
    grid-template-columns: 1fr min(75rem, 100%) 1fr;
    justify-content: center;
    padding-inline: var(--viewport-padding);
}

.wrapper > * {
    grid-column: 2;
}

.full-bleed {
    grid-column: 1 / -1;
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    height: auto;
    overflow: hidden;
}

.full-bleed img {
    width: 100%;
    height: 400px;
    object-fit: cover;
    object-position: center;
    border-radius: 4px;
    margin-bottom: 1rem;
}

/* ========================================
   4. Header & Navigation
   ======================================== */
header {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    background: linear-gradient(145deg, var(--primary) 0%, var(--primary-dark) 100%);
    min-height: var(--header-min-height);
    box-shadow: var(--shadow-3d);
    position: sticky;
    top: 0;
    z-index: 9999;
    width: 100%;
}

.logo {
    width: var(--logo-size-desktop);
    height: auto;
    margin-left: 24px;
    border-radius: 50%;
    box-shadow: var(--shadow-elevation-low);
    object-fit: cover;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.logo:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-elevation-medium);
}

.header-nav {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding-right: 32px;
    gap: 28px;
}

.header-nav nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-nav ul {
    display: flex;
    gap: 16px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.header-nav a {
    display: inline-block;
    font-size: 1.08rem;
    font-weight: 500;
    padding: 8px 18px;
    border-radius: 10px;
    color: var(--text-light);
    text-decoration: none;
    letter-spacing: 0.02em;
    transition: background var(--transition-speed), transform var(--transition-speed), box-shadow var(--transition-speed);
}

.header-nav a:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: var(--shadow-elevation-low);
}

.header-nav a.active {
    background: rgba(0, 0, 0, 0.2);
    font-weight: 700;
}

/* ========================================
   5. Footer
   ======================================== */
.site-footer {
    padding: 1.2rem 0;
    color: var(--muted);
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 3rem;
    font-size: 0.9rem;
}

/* ========================================
   6. Shared Card Design & Blog Lists
   ======================================== */
.homepage {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.blog-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 700px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Shared 3D Card Base */
.modern-blog-card, 
.blog-card, 
.post-header {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-3d);
    backdrop-filter: blur(10px);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.modern-blog-card:hover, 
.blog-card:hover {
    transform: translateY(-5px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 15px 30px rgba(0, 0, 0, 0.3);
    border-color: var(--primary);
}

/* Vertical Card (Homepage) */
.modern-blog-card {
    padding: 2rem;
    /* Adjusted from 0.07 to 0.08 for slightly better separation from bg */
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text-light);
}

.modern-blog-card img {
    border-radius: 12px;
    margin-bottom: 1.5rem;
    filter: brightness(0.9);
}

.modern-blog-card p {
    margin: 0;
    line-height: 1.5;
    text-align: left;
}

/* Horizontal Card (List Page) */
.blog-card {
    display: flex;
    flex-direction: row;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(15px);
    overflow: hidden;
    color: var(--text-light);
    width: 100%;
    margin-bottom: 1.5rem;
}

.blog-card__image {
    flex-shrink: 0;
    width: 180px;
    min-height: 140px;
    height: auto;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed), border-color var(--transition-speed);
}

.blog-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.blog-card__content {
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-grow: 1;
}

.blog-card__title {
    margin: 0 0 0.25rem 0;
    font-size: 1.1rem;
    line-height: 1.3;
}

.blog-card__title a {
    color: var(--text-light);
    text-decoration: none;
    font-weight: 600;
    transition: color var(--transition-speed);
}

.blog-card__title a:hover {
    color: var(--primary);
}

.blog-card__excerpt {
    margin: 0 0 0.75rem 0;
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.4;
}

.blog-card__meta {
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.read-more {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-speed);
}

.read-more:hover {
    color: var(--text-light);
    text-decoration: underline;
}

/* ========================================
   7. About Page Specifics
   ======================================== */
.about-grid {
    display: grid;
    grid-template-columns: 1.4fr 2.8fr 1.2fr;
    gap: 2rem;
    align-items: stretch;
    margin: 2rem 0;
    padding: 0 1rem;
}

.about-grid > img {
    display: block;
    width: 100%;
    margin: 0 auto 2rem auto;
    object-fit: contain;
    border-radius: 4px;
    transition: transform var(--transition-speed);
}

.about-grid > ul {
    display: flex;
    flex-direction: column;
    justify-content: center;
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 1.1rem;
    line-height: 1.2;
}

.content-stack {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    margin: 2rem 0;
    padding: 0 1rem;
    max-width: 900px;
    justify-self: center;
}

/* ========================================
   8. Post Detail & Content Styling
   ======================================== */
.post-content {
    padding: 2rem 1rem;
    max-width: 900px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    background-color: var(--bg);
}

.post-header {
    text-align: center;
    background: linear-gradient(145deg, rgba(81, 113, 165, 0.25) 0%, rgba(36, 59, 85, 0.35) 100%);
    padding: 1.5rem 2rem;
    margin: 1rem auto 4rem auto;
    max-width: 90%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 
        inset 0 1px 0 rgba(255, 255, 255, 0.2), 
        var(--shadow-elevation-medium);
    overflow: hidden;
}

.post-header h1 {
    font-size: clamp(1.6rem, 4vw, 2.5rem);
    margin-bottom: 1rem;
    color: var(--text-light);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.post-meta {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.post-date {
    color: #a0c4ff;
    font-weight: 600;
}

/* Post Typography */
.post-content p {
    line-height: 1.7;
    margin-bottom: 1.5rem;
}

.post-content h2 {
    color: var(--primary);
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
    text-align: center;
}

/* Post Images */
img.center {
    display: block;
    width: 50%;
    height: auto;
    margin: 0 auto 2rem auto;
    border-radius: 6px;
    box-shadow: var(--shadow-elevation-low);
}

/* Post Lists */
.post-content ul {
    width: fit-content;
    margin: 2rem auto;
    list-style: none;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1.5rem 2rem;
    text-align: left;
}

.post-content li {
    position: relative;
    padding-left: 1.5rem;
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.post-content li::before {
    content: "›";
    position: absolute;
    left: 0;
    top: 0;
    color: var(--primary);
    font-weight: bold;
    font-size: 1.2rem;
    line-height: 1.4;
}

/* Code Blocks */
pre {
    /* Adjusted from #2d2d2d to #3e4245 to properly lift it off the main background */
    background-color: #3e4245;
    color: #f8f8f2;
    padding: 1.5rem;
    border-radius: 6px;
    overflow-x: auto;
    scrollbar-width: thin;
    white-space: pre-wrap;
    word-wrap: break-word;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin: 1.5rem 0;
    font-size: 0.9rem;
}

code {
    font-family: 'Consolas', 'Courier New', monospace;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

th {
    color: var(--primary);
    font-weight: bold;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: 4px;
    transition: all var(--transition-speed);
    border: 1px solid transparent;
    cursor: pointer;
    color: var(--text-light);
}

.btn-edit {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-edit:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
}

.btn-download {
    background-color: var(--primary);
    color: white;
    margin-top: 2rem;
}

.btn-download:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

/* Post Footer */
.post-footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ========================================
   9. Responsive Adjustments
   ======================================== */
@media (max-width: 900px) {
    .logo {
        width: 130px;
        margin-left: 10px;
    }

    .header-nav {
        padding-right: 10px;
        gap: 14px;
    }
}

@media (max-width: 700px) {
    header {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        padding: 16px 0;
    }

    .logo {
        width: var(--logo-size-mobile);
        margin: 0 auto 12px auto;
    }

    .header-nav {
        flex-direction: column;
        padding-right: 0;
        gap: 10px;
    }

    .header-nav ul {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }

    .wrapper {
        padding: 0 1rem;
    }

    .homepage {
        grid-template-columns: 1fr;
    }

    .about-grid {
        grid-template-columns: 1fr;
    }

    .about-grid > img {
        height: auto;
        max-height: 300px;
    }

    .blog-card {
        flex-direction: column;
    }

    .blog-card__image {
        width: 100%;
        height: 200px;
    }
}

@media (max-width: 600px) {
    .post-content ul {
        width: 100%;
        margin-left: 0;
        margin-right: 0;
    }

    img.center {
        width: 100%;
    }
}
