/* Modern Reset and Variables */
:root {
    --brand-color: #0B5E56;
    --bg-color: #041412;
    /* Very dark teal/black */
    --text-color: #e2e8f0;
    --accent-color: #ff7f50;
    /* Coral */
    /* Bright Teal for text accessibility replaced with Coral */
    --accent-glow: rgba(255, 127, 80, 0.3);
    --secondary-bg: #092320;
    --card-bg: #0d2e2a;
    --border-color: #1a423d;
    --font-heading: 'Montserrat', system-ui, -apple-system, sans-serif;
    --font-body: 'Inter', system-ui, -apple-system, sans-serif;
    --container-width: 1200px;
    --header-height: 70px;
    --focus-ring: 0 0 0 2px var(--bg-color), 0 0 0 4px var(--accent-color);
    --code-bg: #0d1117;
}

mark {
    background: var(--accent-glow);
    color: var(--accent-color);
    padding: 0.1em 0.3em;
    border-radius: 4px;
}

del {
    text-decoration: line-through;
    opacity: 0.6;
}

ins {
    text-decoration: underline;
    color: var(--accent-color);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-body);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--accent-color);
}

a:focus-visible,
button:focus-visible,
.Card:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: 4px;
}

img {
    max-width: 100%;
    display: block;
}

/* Layout */
.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 2rem;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1rem;
    color: #fff;
}

h1 {
    font-size: 3rem;
    letter-spacing: -0.02em;
}

h2 {
    font-size: 2.25rem;
}

h3 {
    font-size: 1.5rem;
}

/* Utilities */
.text-accent {
    color: var(--accent-color);
}

.text-center {
    text-align: center;
}

.mb-4 {
    margin-bottom: 2rem;
}

.grid {
    display: grid;
    gap: 2rem;
}

.grid-cols-3 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* Header */
.site-header {
    height: var(--header-height);
    background: var(--brand-color);
    /* Correct Deep Teal from image */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
}

.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.logo {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.15rem;
    /* Reduced size to fit two lines comfortably */
    line-height: 1.1;
    /* Tighter line-height for the "stacked" look */
    color: #ffffff;
    text-decoration: none;
    letter-spacing: -0.02em;
    transition: transform 0.2s ease;
    display: block;
    /* Ensure it behaves as a block for the two lines */
    text-align: center;
    /* Center align the two lines */
    text-transform: none;
    /* Corporate image uses sentence case */
}

.logo:hover {
    color: #ffffff;
    transform: scale(1.02);
}

nav ul {
    display: flex;
    gap: 2rem;
    list-style: none;
}

nav a {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.7);
    /* Slightly dimmed white for inactive */
    text-transform: uppercase;
    transition: color 0.2s ease;
}

nav a:hover,
nav a[aria-current="page"] {
    color: #ffffff;
    /* Active/Hover is pure white */
}

/* Hero Section */
.hero {
    padding: 8rem 0;
    text-align: center;
    background: linear-gradient(rgba(4, 20, 18, 0.7), rgba(4, 20, 18, 0.7)), url('/assets/img/hero-bg.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    position: relative;
    border-bottom: 1px solid var(--border-color);
}

.hero h1 {
    font-size: clamp(2.5rem, 6vw, 4rem);
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.hero p {
    font-size: 1.25rem;
    color: #ffffff;
    max-width: 600px;
    margin: 1.5rem auto 0;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

/* Cards */
.card {
    background: var(--brand-color);
    /* Matches header exactly */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    overflow: hidden;
    /* Ensure image stays inside border radius */
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    border-color: var(--accent-color);
}

/* Card Image */
.card-image {
    width: 100%;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: var(--secondary-bg);
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.card:hover .card-image img {
    transform: scale(1.05);
}

.card-content {
    padding: 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card h3 {
    margin-bottom: 0.5rem;
    padding: 0 1.5rem;
    /* Add padding for direct H3 children (homepage) */
}

/* Fix for homepage cards that don't have .card-content wrapper yet */
.card>h3 {
    margin-top: 1.5rem;
}

.card p {
    color: rgba(255, 255, 255, 0.8);
    /* Dimmed white for readability */
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    padding: 0 1.5rem;
    /* Add padding for direct P children */
    flex-grow: 1;
}

.card .meta {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: auto;
    padding: 0 1.5rem 1.5rem 1.5rem;
    /* Add padding for meta */
}

/* Horizontal Card Variant (for lists) */
.card.horizontal {
    flex-direction: row;
    align-items: stretch;
    min-height: 180px;
}

.card.horizontal .card-image {
    width: 250px;
    height: auto;
    /* Fill height */
    aspect-ratio: unset;
    /* Override default aspect ratio */
    flex-shrink: 0;
}

.card.horizontal .card-image img {
    height: 100%;
    object-fit: cover;
}

.card.horizontal .card-content {
    justify-content: center;
    padding: 1.5rem 2rem;
}

.card.horizontal h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.card.horizontal p {
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    /* Limit to 2 lines */
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card.horizontal .meta {
    padding: 0;
    margin-top: 0.5rem;
}

/* Mobile responsive for horizontal cards */
@media (max-width: 768px) {
    .card.horizontal {
        flex-direction: column;
        height: auto;
    }

    .card.horizontal .card-image {
        width: 100%;
        height: 200px;
    }
}

/* Fix duplicate padding if using .card-content */
.card-content h3,
.card-content p {
    padding: 0;
}

.card-content .meta {
    padding: 0;
    margin-top: auto;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: var(--brand-color);
    color: #fff;
    border-radius: 6px;
    font-weight: 600;
    transition: background 0.2s ease;
}

.btn:hover {
    background: var(--accent-color);
    color: #041412;
}

/* Footer */
footer {
    padding: 5rem 0;
    border-top: 1px solid var(--border-color);
    margin-top: 6rem;
    color: #8b949e;
    font-size: 0.9rem;
}

.footer-grid {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 4rem;
    align-items: start;
}

.footer-col h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #ffffff;
    margin-bottom: 1.5rem;
}

.footer-col p {
    line-height: 1.6;
}

.footer-col.about p {
    color: rgba(255, 255, 255, 0.7);
}

.built-with {
    font-size: 0.8rem;
    margin-top: 0.5rem;
    opacity: 0.6;
}

.social-link {
    color: var(--accent-color);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    transition: opacity 0.2s ease;
    display: inline-block;
}

.social-link:hover {
    opacity: 0.8;
}

@media (max-width: 992px) {
    .footer-grid {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }

    .footer-col.about {
        grid-column: span 2;
        order: -1;
    }
}

@media (max-width: 768px) {
    .footer-grid {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .footer-col.about {
        grid-column: span 1;
    }
}

/* Tag */
.tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(255, 127, 80, 0.1);
    border: 1px solid rgba(255, 127, 80, 0.2);
    color: var(--accent-color);
}

/* Animations & Motion Accessibility */
@media (prefers-reduced-motion: no-preference) {
    body {
        animation: fadeIn 0.6s ease-out;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Post Layout */
.post-hero-image {
    width: 100%;
    max-height: 400px;
    overflow: hidden;
    border-radius: 12px;
    margin-bottom: 3rem;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.5);
}

.post-hero-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.post-header {
    margin-bottom: 4rem;
    max-width: 100%;
    /* Use full available width */
}

.post-title {
    font-size: clamp(2.5rem, 5vw, 4rem);
    line-height: 1.1;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, #fff 0%, #e0e6ed 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.post-meta {
    font-size: 1rem;
    opacity: 0.8;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.post-description {
    font-size: clamp(1.25rem, 3vw, 1.5rem);
    line-height: 1.6;
    color: #a1a1aa;
    margin-top: 2rem;
    border-left: 4px solid var(--accent-color);
    padding-left: 1.5rem;
    font-style: italic;
}

.toc-container {
    margin: 3rem 0;
    padding: 1.5rem 2rem;
    background: var(--brand-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toc-container summary {
    list-style: none;
    outline: none;
}

.toc-container summary::-webkit-details-marker {
    display: none;
}

.toc-title {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent-color);
    margin: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toc-title::after {
    content: '↓';
    font-size: 1.25rem;
    transition: transform 0.3s ease;
}

.toc-container[open] .toc-title::after {
    transform: rotate(180deg);
}

.toc-container[open] .toc-title {
    margin-bottom: 1.5rem;
}

.post-toc ul {
    list-style: none;
    padding-left: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.post-toc ul ul {
    margin-top: 0.75rem;
    padding-left: 1.5rem;
}

.post-toc a {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
    transition: color 0.2s ease;
}

.post-toc a:hover {
    color: var(--accent-color);
}

.separator {
    margin: 3rem 0;
    border: none;
    border-top: 1px solid var(--border-color);
    opacity: 0.3;
}

.content {
    max-width: 100%;
    margin: 0 auto;
    font-size: 1.15rem;
    overflow-wrap: break-word;
}

.content h2 {
    margin-top: 4rem;
    margin-bottom: 1.5rem;
    color: #fff;
    font-size: 2rem;
}

.content h3 {
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.content p {
    margin-bottom: 1.5rem;
    color: #d1d5db;
    line-height: 1.8;
}

.content ul,
.content ol {
    margin-bottom: 2rem;
    color: #d1d5db;
    line-height: 1.8;
    padding-left: 2rem;
}

.content li {
    margin-bottom: 0.75rem;
}

/* Blockquotes */
.content blockquote {
    margin: 3rem 0;
    padding: 2rem !important;
    background: var(--secondary-bg) !important;
    border-left: 4px solid var(--accent-color) !important;
    border-radius: 0 12px 12px 0;
    font-style: italic;
    color: #fff;
}

.content blockquote p {
    margin-bottom: 0;
    font-size: 1.25rem;
}

/* Code Blocks */
.content pre[class*="language-"] {
    background: #1e1e1e !important;
    padding: 2.5rem 1.5rem 1.5rem !important;
    border-radius: 12px;
    overflow-x: auto;
    margin: 3rem 0;
    border: 1px solid var(--border-color);
    position: relative !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.content pre[class*="language-"]::before {
    content: attr(data-language);
    position: absolute;
    top: 0;
    left: 1rem;
    padding: 0.2rem 0.8rem;
    background: var(--accent-color);
    /* Use coral for the label bg for better contrast */
    color: var(--brand-color);
    /* Dark text on coral */
    font-size: 0.65rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-radius: 0 0 6px 6px;
    font-family: var(--font-heading);
    z-index: 10;
    display: block !important;
}

.content code {
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.95rem;
    color: #e2e8f0;
    line-height: 1.5;
}

/* Code blocks custom scrollbar */
.content pre {
    max-width: 100%;
}

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

.content pre::-webkit-scrollbar-track {
    background: #1e1e1e;
    border-radius: 0 0 12px 12px;
}

.content pre::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.content pre::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* Tables */
.content table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
    margin: 3rem 0;
    font-size: 1rem;
}

.content th {
    background: var(--secondary-bg);
    color: var(--accent-color);
    text-align: left;
    padding: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.content td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: #cbd5e1;
}

.content tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Images in content */
.content img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
    margin: 3rem auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.content em {
    display: block;
    text-align: center;
    font-size: 0.9rem;
    color: #8b949e;
    margin-top: -2rem;
    margin-bottom: 3rem;
}

/* Footnotes */
.footnotes {
    margin-top: 6rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: #8b949e;
}

.footnotes-list {
    padding-left: 1.5rem;
}

.footnote-item {
    margin-bottom: 1rem;
}

.footnote-backref {
    color: var(--accent-color);
    margin-left: 0.5rem;
    text-decoration: none;
}

/* Task Lists */
.contains-task-list {
    list-style: none;
    padding-left: 0;
}

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

.task-list-item-checkbox {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    background: var(--secondary-bg);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.task-list-item-checkbox:checked {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.task-list-item-checkbox:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--bg-color);
    font-size: 12px;
    font-weight: 800;
}

/* Details & Summary */
details {
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    margin: 2rem 0;
    transition: all 0.3s ease;
}

summary {
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-heading);
    color: #fff;
    outline: none;
}

details[open] summary {
    margin-bottom: 1.5rem;
    color: var(--accent-color);
}

/* GitHub Style Alerts (Admonitions) */
.markdown-alert {
    padding: 1.5rem 1.5rem 1.5rem 1.25rem !important;
    margin: 2.5rem 0 !important;
    border-left: 0.25rem solid !important;
    border-radius: 0 8px 8px 0 !important;
    background: rgba(255, 255, 255, 0.02) !important;
}

.markdown-alert p {
    margin-bottom: 0 !important;
    font-size: 1rem;
    line-height: 1.6;
}

.markdown-alert-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem !important;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    text-transform: capitalize;
}

/* Alert Types */
.markdown-alert-note {
    border-color: #2f81f7 !important;
    background: rgba(47, 129, 247, 0.05) !important;
}

.markdown-alert-note .markdown-alert-title {
    color: #2f81f7 !important;
}

.markdown-alert-tip {
    border-color: #3fb950 !important;
    background: rgba(63, 185, 80, 0.05) !important;
}

.markdown-alert-tip .markdown-alert-title {
    color: #3fb950 !important;
}

.markdown-alert-important {
    border-color: #a371f7 !important;
    background: rgba(163, 113, 247, 0.05) !important;
}

.markdown-alert-important .markdown-alert-title {
    color: #a371f7 !important;
}

.markdown-alert-warning {
    border-color: #d29922 !important;
    background: rgba(210, 153, 34, 0.05) !important;
}

.markdown-alert-warning .markdown-alert-title {
    color: #d29922 !important;
}

.markdown-alert-caution {
    border-color: #f85149 !important;
    background: rgba(248, 81, 73, 0.05) !important;
}

.markdown-alert-caution .markdown-alert-title {
    color: #f85149 !important;
}

.markdown-alert-title svg {
    width: 1.1rem;
    height: 1.1rem;
    fill: currentColor;
    flex-shrink: 0;
}

/* Inline Code Enhancement */
p code,
li code {
    background: var(--code-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    color: var(--accent-color);
}

@media (max-width: 768px) {
    .container {
        padding: 0 1.5rem;
    }

    /* Mobile Header */
    .menu-toggle {
        display: block;
        background: none;
        border: none;
        cursor: pointer;
        padding: 0.5rem;
        z-index: 1000;
        width: 40px;
        height: 40px;
        position: relative;
    }

    .menu-toggle span {
        display: block;
        width: 100%;
        height: 2px;
        background-color: #ffffff;
        margin: 6px 0;
        transition: 0.3s;
        border-radius: 2px;
    }

    /* Transform burger to X when active */
    .menu-toggle[aria-expanded="true"] span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 6px);
    }

    .menu-toggle[aria-expanded="true"] span:nth-child(2) {
        opacity: 0;
    }

    .menu-toggle[aria-expanded="true"] span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -6px);
    }

    .nav-menu {
        position: absolute;
        top: var(--header-height);
        left: 0;
        width: 100%;
        background: var(--brand-color);
        padding: 2rem;
        display: none;
        flex-direction: column;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    }

    .nav-menu.active {
        display: flex;
    }

    .nav-menu ul {
        flex-direction: column;
        gap: 1.5rem;
        align-items: center;
    }

    .nav-menu a {
        font-size: 1.25rem;
    }

    .hero {
        padding: 4rem 1.5rem;
    }

    .hero h1 {
        font-size: 2.25rem;
    }

    .hero p {
        font-size: 1.1rem;
    }

    /* Content adjustments for mobile */
    .toc-container {
        padding: 1.25rem !important;
        margin: 2rem 0 !important;
    }

    .markdown-alert {
        padding: 1.25rem 1rem !important;
        margin: 2rem 0 !important;
    }

    .content blockquote {
        padding: 1.5rem !important;
        margin: 2rem 0 !important;
    }

    .content pre[class*="language-"] {
        padding: 2.25rem 1rem 1rem !important;
        margin: 2rem 0 !important;
        border-radius: 8px !important;
    }
}

/* Hide toggle on desktop */
@media (min-width: 769px) {
    .menu-toggle {
        display: none;
    }
}