:root {
    --bg-color: #ffffff;
    --text-primary: #111111;
    --text-secondary: #737373;
    --border-color: #e5e5e5;
    --hover-bg: #f5f5f5;
    --spacing-unit: 1.5rem;
}

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

body {
    /* Consolidating to JetBrains Mono for a technical, consistent look */
    font-family: 'JetBrains Mono', monospace;
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

a:hover { 
    color: #000; 
}

/* --- Layouts and Structure --- */

.wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 4rem 2rem;
}

header {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
    margin-bottom: 5rem;
}

/* Style for back button (unique to unity.html) */
.back-link {
    display: inline-flex;
    align-items: center;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    transition: color 0.2s ease;
}
.back-link:hover {
    color: var(--text-primary);
}
.back-link i {
    margin-right: 0.5rem;
    font-size: 0.8rem;
}

/* --- Header Meta --- */

.header-meta h1 { 
    font-size: 16px; 
    font-weight: 600; 
    margin-bottom: 0.25rem; 
}
.header-meta p { 
    color: var(--text-secondary); 
}
.header-meta a { 
    text-decoration: underline; 
    text-underline-offset: 3px; 
    color: var(--text-secondary); 
}
.header-meta a:hover { 
    color: var(--text-primary); 
}

/* Tags (unique to unity.html) */
.header-meta .meta-tags span {
    display: inline-block; font-size: 13px;
    border: 1px solid var(--border-color);
    padding: 2px 8px; border-radius: 12px;
    margin-right: 6px; margin-top: 10px;
    color: var(--text-secondary);
}

/* --- Header Bio / Overview --- */

.header-bio p { 
    max-width: 500px; 
    font-size: 16px; 
    color: var(--text-primary); 
    margin-bottom: 1.5rem; 
}
.header-bio a { 
    text-decoration: underline; 
    text-underline-offset: 3px; 
    color: var(--text-secondary); 
}
.header-bio a:hover { 
    color: var(--text-primary); 
}

.section-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    display: block;
}

/* --- Content Section (unique to unity.html) --- */

.content-section p, .content-section ul, .content-section ol { 
    max-width: 800px;
    font-size: 16px;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}
.content-section ul, .content-section ol {
    padding-left: 20px;
}
.content-section li {
    margin-bottom: 0.5rem;
}
.content-section h2 {
    font-size: 20px;
    font-weight: 600;
    margin-top: 2.5rem;
    margin-bottom: 1.5rem;
}
/* FIX: Remove top margin from the H2 when it is the first element in the column layout */
.flex-section .text-content h2:first-child {
    margin-top: 0;
}
.content-section h3 {
    font-size: 18px;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

/* Two-Column Layout for Text/Image (unique to unity.html) */
.flex-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    margin-bottom: 3rem;
    align-items: start;
}

.image-gallery {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.image-container {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    background-color: var(--hover-bg);
}
.image-container img {
    width: 100%;
    height: auto;
    max-height: 350px;
    object-fit: contain;
    display: block;
}
.caption {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
}

/* --- Project List (unique to index.html) --- */

.list-container {
    border-top: 1px solid var(--border-color);
    position: relative;
}

.list-header {
    display: grid;
    grid-template-columns: 1fr 2fr;
    padding: 1rem 0;
    font-size: 12px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.list-item {
    display: none; /* Controlled by JS rotator */
    grid-template-columns: 1fr 2fr;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
}

.list-item:hover { 
    background-color: #fafafa; 
}

.item-left { 
    padding-right: 1rem; 
}

.item-title {
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
}

.item-meta {
    color: var(--text-secondary);
    font-size: 13px;
}

.item-right {
    color: var(--text-secondary);
    padding-right: 2rem;
}

.item-desc {
    margin-bottom: 0.5rem;
}

.item-tags span {
    display: inline-block; font-size: 12px;
    border: 1px solid var(--border-color);
    padding: 2px 8px; border-radius: 12px;
    margin-right: 6px; margin-top: 6px;
}

.arrow-icon {
    opacity: 0;
    margin-left: 5px;
    transition: opacity 0.2s, transform 0.2s;
    display: inline-block;
}

.list-item:hover .arrow-icon {
    opacity: 1;
    transform: translate(2px, -2px);
}

/* Rotator visibility classes */
.rotating-hidden { 
    display: none !important; 
    opacity: 0; 
}

.rotating-visible { 
    display: grid !important; 
    opacity: 1; 
    animation: fadeIn 0.4s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

#project-list {
    /* Stabilize content height to prevent CLS */
    min-height: 450px; 
}

/* Rotator buttons */
.rotator-controls {
    display: flex; 
    gap: 1.5rem;
    justify-content: center;
    margin-top: 2rem;
}
.rotator-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    font-size: 1.2rem;
    transition: color 0.2s ease, transform 0.2s ease;
}
.rotator-btn:hover { 
    color: var(--text-secondary);
    transform: translateY(-2px);
}
.rotator-btn:active {
    transform: translateY(0);
    color: var(--text-primary);
}


/* --- Footer --- */

footer {
    margin-top: 6rem;
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
    font-size: 12px;
    color: var(--text-secondary);
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}

/* --- Responsive Design --- */

@media (min-width: 768px) {
    /* Detail Page Specific Responsive Rules */
    .flex-section {
        grid-template-columns: 3fr 2fr;
    }
    .flex-section.reverse {
        grid-template-columns: 2fr 3fr;
    }
    .flex-section .text-content {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    header, .list-header, .list-item, footer {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .wrapper {
        padding: 2rem 1.5rem;
    }

    .header-bio p {
        font-size: 15px;
    }

    .list-header {
        display: none; /* Hide labels on mobile */
    }

    .list-item {
        /* This is crucial for mobile stacking of project rows */
        grid-template-columns: 1fr; 
    }

    .item-left {
        margin-bottom: 0.5rem;
    }

    /* Detail Page Specific Mobile Rules */
    .flex-section { 
        grid-template-columns: 1fr; 
    }
    .flex-section.reverse .image-gallery { 
        order: -1; 
    }
    .image-gallery {
        margin-top: 1rem;
        margin-bottom: 1rem;
    }
    .content-section h2, .content-section h3 {
        /* Reset these margins on mobile since the grid stacks vertically */
        margin-top: 2rem;
        margin-bottom: 1rem;
    }
    /* Ensure the very first H2/H3 on mobile is still flush with the start of the section */
    .content-section h2:first-of-type,
    .content-section h3:first-of-type {
        margin-top: 0;
    }
}

.code-snippet {
    background: #fafafa;
    padding: 1.25rem;
    border-radius: 8px;
    font-family: "JetBrains Mono", monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;      /* no horizontal scroll */
    word-break: break-word;
    color: #111;
}

/* Tokens */
.code-snippet .kw { color: #c92c2c; font-weight: 600; }
.code-snippet .type { color: #005cc5; }
.code-snippet .fn { color: #6f42c1; }
.code-snippet .num { color: #1b7ada; }
.code-snippet .str { color: #22863a; }
.code-snippet .com { color: #6a737d; font-style: italic; }
.code-snippet .attr { color: #b31d28; }
.code-snippet .using { color: #c92c2c; }