/* Trellis Colors */
:root {
    /* Blacks and Whites */
    --trellis-black: #252525;
    --trellis-pure-black: #000000;
    --trellis-pure-white: #ffffff;

    /* Greys */
    --trellis-charcoal: #535759;
    --trellis-lightest: #f9f9f9;
    --trellis-fundraiser: #f2f2f2;
    --trellis-light-blue: #f2f5fa;
    --trellis-fog: #e9ecef;
    --trellis-steel: #dee1e3;
    --trellis-lavender: #ced2d3;
    --trellis-slate: #9e9e9e;

    /* Blues */
    --trellis-blue-primary: #1d8bf1;
    --trellis-blue-light-background: #ebf3ff;
    --trellis-blue-light: #59acf5;
    --trellis-blue-brand: #4091df;
    --trellis-blue-text: #186fc0;
    --trellis-blue-dark: #145ab8;
    --trellis-blue-link: #0b6efd;
    --trellis-blue-true: #0071d5;

    /* Greens */
    --trellis-green-secondary: #3b963e;
    --trellis-green-donation: #eaffea;
    --trellis-green-mint: #b9deb9;
    --trellis-green-forest: #5bb25f;
    --trellis-green-brand: #198754;
    --trellis-green-android: #93d746;
    --trellis-green-dark: #318335;

    /* Gradient */
    --trellis-gradient-green-start: #129d3d;
    --trellis-gradient-green-end: #0a9067;
    --trellis-gradient-green: linear-gradient(
        180deg,
        var(--trellis-gradient-green-start) 0%,
        var(--trellis-gradient-green-end) 100%
    );
}

/* Reset and Base Styles */
* {
    box-sizing: border-box;
}

html,
body {
    padding: 0;
    margin: 0;
    font-family:
        'Inter',
        -apple-system,
        system-ui,
        sans-serif;
    color: var(--trellis-black);
    background-color: var(--trellis-pure-white);
    line-height: 1.6;
    overflow-x: hidden; /* Prevent horizontal scroll on body */
}

html {
    width: 100%;
    max-width: 100%;
}

body {
    width: 100%;
    max-width: 100%;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Righteous', cursive;
    line-height: 1.3;
    margin: 0 0 1rem 0;
    color: var(--trellis-black);
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: 2rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

h3 {
    font-size: 1.5rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

h4 {
    font-size: 1.25rem;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
}

p {
    margin: 0 0 1rem 0;
}

a {
    color: var(--trellis-blue-link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    width: 100%;
    overflow-x: hidden; /* Prevent horizontal overflow */
}

/* Accessibility */
.visually-hidden {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

/* Header */
header {
    background: var(--trellis-gradient-green-start);
    color: var(--trellis-pure-white);
    padding: 1rem 0;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.home-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--trellis-pure-white);
    text-decoration: none;
    font-weight: 600;
}

.home-link:hover {
    text-decoration: none;
    opacity: 0.9;
}

.logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
}

.site-title {
    font-family: 'Righteous', cursive;
    font-size: 1.5rem;
}

.nav {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 2rem;
}

.nav-item a {
    color: var(--trellis-pure-white);
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 0;
    border-bottom: 2px solid transparent;
    transition: border-color 0.2s ease;
}

.nav-item a:hover,
.nav-item a[aria-current='page'] {
    border-bottom-color: var(--trellis-pure-white);
    text-decoration: none;
}

/* Main Content */
main {
    min-height: calc(100vh - 200px);
    padding: 3rem 0;
}

/* Footer */
footer {
    background: var(--trellis-lightest);
    color: var(--trellis-charcoal);
    padding: 2rem 0;
    margin-top: 4rem;
    border-top: 1px solid var(--trellis-steel);
}

footer p {
    margin: 0;
    text-align: center;
    font-size: 0.9rem;
}

footer a {
    color: var(--trellis-blue-text);
}

/* Posts List */
.postlist {
    list-style: none;
    padding: 0;
    margin: 2rem 0;
}

.postlist-item {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--trellis-steel);
}

.postlist-item:last-child {
    border-bottom: none;
}

.postlist-article {
    display: block;
    background: none;
    box-shadow: none;
    padding: 0;
}

.postlist-title {
    margin: 0 0 0.5rem 0;
    font-size: 1.5rem;
}

.postlist-link {
    color: var(--trellis-black);
    text-decoration: none;
}

.postlist-link:hover {
    color: var(--trellis-blue-link);
    text-decoration: underline;
}

.postlist-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: var(--trellis-charcoal);
}

.postlist-date {
    font-weight: 500;
}

.postlist-author {
    color: var(--trellis-blue-text);
}

.postlist-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
    max-width: 100%;
}

.postlist-description {
    color: var(--trellis-charcoal);
    margin: 0;
    line-height: 1.5;
}

/* Tags */
.tag {
    background: rgba(59, 150, 62, 0.15);
    color: var(--trellis-green-dark);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Post Content */
.post {
    max-width: 800px;
    margin: 0 auto;
}

.post-header {
    margin-bottom: 2rem;
    background: none;
}

.post-title {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    line-height: 1.2;
    background: none;
    color: var(--trellis-black);
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    color: var(--trellis-charcoal);
    font-size: 0.95rem;
}

.post-date a {
    color: var(--trellis-charcoal);
    text-decoration: none;
}

.post-date a:hover {
    color: var(--trellis-blue-link);
    text-decoration: underline;
}

.post-author a {
    color: var(--trellis-blue-text);
    font-weight: 500;
}

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
    width: 100%;
    max-width: 100%;
}

.post-content {
    font-size: 1.1rem;
    line-height: 1.7;
    margin-bottom: 3rem;
    width: 100%;
    overflow-wrap: break-word; /* Break long words */
    word-wrap: break-word; /* Legacy support */
}

.post-content img {
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    margin: 1.5rem 0;
}

.post-content blockquote {
    border-left: 4px solid var(--trellis-blue-primary);
    background: var(--trellis-blue-light-background);
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    border-radius: 0 8px 8px 0;
}

.post-content blockquote p:last-child {
    margin-bottom: 0;
}

/* Code Blocks - fallback for non-syntax highlighted code */
pre:not([class*='language-']) {
    background: var(--trellis-black);
    color: var(--trellis-pure-white);
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1.5rem 0;
    font-size: 0.9rem;
    line-height: 1.5;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    max-width: 100%; /* Ensure pre blocks don't exceed container */
    word-wrap: break-word; /* Allow long words to wrap */
}

pre:not([class*='language-']) code {
    background: none;
    padding: 0;
    border-radius: 0;
    color: inherit;
}

/* Inline code - only for code not inside pre blocks and not syntax highlighted */
code:not([class*='language-']) {
    background: var(--trellis-steel);
    color: var(--trellis-black);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

/* Legacy highlight class support */
.highlight {
    background: var(--trellis-black);
    color: var(--trellis-pure-white);
    border-radius: 8px;
    overflow-x: auto;
}

.highlight pre {
    margin: 0;
    background: none;
    box-shadow: none;
}

/* Tables */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    margin: 1.5rem 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

table {
    width: 100%;
    min-width: 500px; /* Ensure table has minimum width for readability */
    border-collapse: collapse;
    margin: 0;
    background: var(--trellis-pure-white);
    border-radius: 8px;
    overflow: hidden;
}

table th,
table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--trellis-steel);
}

table th {
    background: var(--trellis-gradient-green-start);
    color: var(--trellis-pure-white);
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

table tbody tr:hover {
    background: var(--trellis-lightest);
}

table tbody tr:last-child td {
    border-bottom: none;
}

table td {
    font-size: 0.95rem;
}

/* Responsive tables */
@media (max-width: 768px) {
    .table-wrapper {
        margin: 1rem 0;
        border-radius: 6px;
    }

    table {
        font-size: 0.85rem;
        min-width: 400px; /* Smaller minimum width on mobile */
    }

    table th,
    table td {
        padding: 0.5rem 0.75rem;
    }
}

/* Author Card */
.post-footer {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--trellis-steel);
}

.author-card {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    background: var(--trellis-lightest);
    padding: 1.5rem;
    border-radius: 8px;
}

.author-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    flex-shrink: 0;
}

.author-info {
    flex: 1;
}

.author-name {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    color: var(--trellis-black);
}

.author-description {
    margin: 0 0 1rem 0;
    color: var(--trellis-charcoal);
    line-height: 1.5;
    text-align: left;
}

.author-links {
    display: flex;
    gap: 1rem;
}

.author-links a {
    color: var(--trellis-blue-link);
    font-weight: 500;
    font-size: 0.9rem;
}

/* Post Navigation */
.post-nav {
    margin-top: 3rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.post-nav-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 2rem;
}

.post-nav-prev,
.post-nav-next {
    display: block;
    padding: 1.5rem;
    background: var(--trellis-lightest);
    border-radius: 8px;
    text-decoration: none;
    color: var(--trellis-black);
    transition: background-color 0.2s ease;
}

.post-nav-prev:hover,
.post-nav-next:hover {
    background: var(--trellis-blue-light-background);
    text-decoration: none;
}

.post-nav-next {
    text-align: right;
}

.post-nav-label {
    display: block;
    font-size: 0.9rem;
    color: var(--trellis-charcoal);
    margin-bottom: 0.5rem;
}

.post-nav-title {
    display: block;
    font-weight: 600;
    font-size: 1.1rem;
    line-height: 1.3;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .nav {
        gap: 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    .post-title {
        font-size: 2rem;
    }

    .post-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .author-card {
        flex-direction: column;
        text-align: center;
    }

    .author-card .author-description {
        text-align: left;
    }

    .author-avatar {
        align-self: center;
    }

    .post-nav-links {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .post-nav-next {
        text-align: left;
    }

    pre {
        padding: 1rem;
        font-size: 0.8rem;
    }
}

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

    main {
        padding: 2rem 0;
    }

    h1 {
        font-size: 1.75rem;
    }

    .post-title {
        font-size: 1.75rem;
    }

    .post-content {
        font-size: 1rem;
    }

    .table-wrapper {
        margin: 0.75rem 0;
    }

    table {
        min-width: 300px; /* Even smaller minimum on very small screens */
        font-size: 0.8rem;
    }

    table th,
    table td {
        padding: 0.4rem 0.5rem;
    }

    pre {
        padding: 1rem;
        font-size: 0.8rem;
    }
}
