/* =========================================
   1. Fonts & Variables
========================================= */
@font-face {
    font-family: "SiteFont";
    src: url("/fonts/font-regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "SiteFont";
    src: url("/fonts/font-italic.woff2") format("woff2");
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: "SiteFont";
    src: url("/fonts/font-bold.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "SiteFont";
    src: url("/fonts/font-bold-italic.woff2") format("woff2");
    font-weight: 700;
    font-style: italic;
    font-display: swap;
}

:root {
    --bg-color: #ffffff;
    --text-color: #2c2c2c;
    --sidebar-bg: #f5f5f5;
    --border-color: #e0e0e0;
    --link-color: #a43;
    --link-hover: #374;
}

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

body {
    font-family:
        "SiteFont",
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        sans-serif;
    line-height: 1.75;
    color: var(--text-color);
    background: var(--bg-color);
    font-size: clamp(1rem, 0.95rem + 0.4vw, 1.125rem);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Minimal Workspace Scrollbars --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

/* =========================================
   2. Typography & Natural Reading Flow
========================================= */
h1,
h2,
h3 {
    line-height: 1.3;
    color: #1a1a1a;
    font-weight: 400;
    text-transform: none;
    letter-spacing: -0.01em;
}

h1 {
    position: relative;
    padding-left: 0;
    margin-top: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 2.2rem;
}
h1::before {
    content: "_";
    margin-right: 0.6rem;
    color: #999;
    font-weight: 300;
}

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

h3 {
    font-size: 1.15rem;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: #555;
    font-weight: 500;
}

p,
ul,
ol,
blockquote {
    margin-bottom: 1.6rem;
}

.content-body {
    max-width: 68ch;
    margin: 0;
    text-align: left;
}

ul,
ol {
    padding-left: 1.5rem;
}
li {
    margin-bottom: 0.5rem;
}
li::marker {
    color: #888;
}

blockquote {
    padding: 0.5rem 0 0.5rem 1.5rem;
    border-left: 3px solid #d4d4d4;
    color: #555;
    font-style: italic;
    margin-left: 0;
    margin-right: 0;
}

strong,
b {
    font-weight: 700;
    color: #1a1a1a;
}
em,
i {
    font-style: italic;
}

a {
    color: var(--link-color);
    text-decoration: none;
    transition:
        color 0.2s ease,
        border-color 0.2s ease;
}
a:hover {
    color: var(--link-hover);
}
a:focus-visible,
button:focus-visible {
    outline: 3px solid var(--link-color);
    outline-offset: 2px;
}

.content-body img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 2.5rem 0;
    border-radius: 4px;
}

code {
    font-family: monospace;
    font-size: 0.85em;
    background: #f5f5f5;
    padding: 0.15rem 0.35rem;
    border-radius: 3px;
    border: 1px solid #e5e5e5;
    color: #444;
}

::selection {
    background: #e6dfdc;
    color: #1a1a1a;
}
::-moz-selection {
    background: #e6dfdc;
    color: #1a1a1a;
}

/* =========================================
   3. Layout & Sidebar
========================================= */
.site-wrapper {
    display: grid;
    grid-template-columns: 280px minmax(auto, 900px);
    justify-content: center;
    min-height: 100vh;
}

.sidebar {
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
}
.sidebar-header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color);
}

.content {
    padding: 3rem 4rem;
    min-width: 0;
}

/* --- Site Title (Logo) --- */
.site-title {
    font-size: 1.1rem;
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: lowercase;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
}
.site-title a:hover {
    text-decoration: none !important;
    opacity: 0.6;
    color: var(--link-color);
}
.site-title::before {
    content: ">";
    margin-right: 0.5rem;
    color: var(--link-color);
    font-weight: 700;
}
.site-title::after {
    content: "_";
    animation: blink 1s step-end infinite;
    color: #999;
    margin-left: 0.2rem;
}
@keyframes blink {
    50% {
        opacity: 0;
    }
}

/* =========================================
   4. Primary Navigation
========================================= */
.main-nav {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    max-width: 160px;
}
.nav-item {
    width: 100%;
    margin-bottom: 0.8rem;
}
.nav-list a {
    color: var(--text-color);
    display: inline-block;
    padding: 0.15rem 0;
    font-size: 1rem;
}

.nav-list a:hover {
    color: var(--link-color);
    text-decoration: none;
}
.nav-list a[aria-current="page"] {
    color: var(--link-color);
    font-weight: bold;
    text-decoration: none;
}

.main-nav-disclosure {
    width: 100%;
    max-width: 160px;
    margin: 0;
}
.main-nav-summary {
    list-style: none;
    cursor: pointer;
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
    display: block;
}
.main-nav-summary::-webkit-details-marker {
    display: none;
}
.main-nav-summary:hover {
    color: var(--link-color);
}

.sub-nav-list {
    list-style: none;
    padding-left: 0.8rem;
    margin-top: 0.3rem;
    margin-left: 0.15rem;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.sub-nav-item {
    width: 100%;
    margin-bottom: 0.25rem;
}
.sub-nav-item:last-child {
    margin-bottom: 0;
}
.sub-nav-list a {
    font-size: 0.9rem;
    color: #666;
}

/* =========================================
   5. Project Navigation
========================================= */
.project-local-nav {
    width: 100%;
}
.project-local-nav hr {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 0 0 1.2rem 0;
    width: 100%;
    max-width: 160px;
}

.project-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.project-back-arrow {
    display: block;
    font-family: monospace;
    font-size: 1rem;
    color: #999;
    text-decoration: none !important;
    transition: color 0.15s ease;
}

.project-back-arrow:hover {
    color: var(--text-color);
}

.project-back-link {
    display: inline-block;
    font-family: monospace;
    font-size: 0.75rem;
    color: #999;
    text-transform: lowercase;
    margin-bottom: 0.25rem;
    transition: color 0.15s ease;
}

.project-back-link:hover {
    color: var(--text-color);
    text-decoration: none;
}

.project-nav-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    display: block;
    margin: 0;
    width: 100%;
    max-width: 160px;
}

.project-nav-list.nested {
    padding-left: 0;
    list-style: none;
    width: 100%;
    max-width: 160px;
    margin: 0;
}
.project-nav-list.nested .project-nav-list {
    padding-left: 0.8rem;
    margin-top: 0.4rem;
    margin-left: 0.15rem;
    border-left: 1px solid var(--border-color);
}
.project-nav-list.nested details {
    margin-bottom: 0.5rem;
}

.project-nav-list.nested summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    color: var(--text-color);
    padding: 0.3rem 0;
}
.project-nav-list.nested summary::-webkit-details-marker {
    display: none;
}
.project-nav-list.nested summary a::before {
    content: "/ ";
    color: #888;
    font-weight: normal;
}
.project-nav-list.nested summary a {
    display: block;
    flex: 1;
    color: inherit;
    text-decoration: none;
}
.project-nav-list.nested .leaf-node {
    display: block;
    padding: 0.3rem 0;
    margin-bottom: 0.4rem;
    text-decoration: none;
    color: var(--text-color);
}

.project-nav-list.nested summary.active > a,
.project-nav-list.nested .leaf-node.active {
    font-weight: bold;
    color: var(--link-color);
}
.project-nav-list.nested summary a:hover,
.project-nav-list.nested .leaf-node:hover {
    color: var(--link-color);
}

/* =========================================
   6. Components & Post Meta
========================================= */
.post-date {
    display: block;
    color: #666;
    margin-bottom: 2rem;
    font-size: 0.9rem;
}
.post-metadata-divider {
    color: #ccc;
    margin: 0 0.5rem;
    font-weight: 300;
}
.post-updated-inline {
    font-size: 0.9rem;
    font-style: italic;
    color: #888;
}

.archive-list {
    list-style: none;
    padding: 0;
    margin-top: 1rem;
}
.archive-item {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    padding: 0.3rem 0;
    font-size: 1rem;
}
.archive-type {
    font-family: monospace;
    color: #666;
    width: 25px;
    flex-shrink: 0;
}
.archive-date {
    color: #666;
    min-width: 45px;
    flex-shrink: 0;
}
.archive-updated {
    font-size: 0.8rem;
    font-style: italic;
    color: #999;
    margin-left: 0.5rem;
}

/* --- Project Directory Pills --- */
.project-subitems-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.project-subitem-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.75rem;
    font-family: monospace;
    font-size: 0.9rem;
    color: #555;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    transition: all 0.2s ease;
}
.project-subitem-badge:hover {
    border-color: #aaa;
    color: #1a1a1a;
    background: #fafafa;
    text-decoration: none;
}
.project-subitem-badge.is-folder {
    background: #f4f4f4;
    font-weight: bold;
    color: #333;
    border-color: #e5e5e5;
}

/* --- Project Cards (Landing Page) --- */
.project-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 3rem;
}

.project-card {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 0;
    text-decoration: none !important;
    color: var(--text-color) !important;
    transition:
        border-color 0.2s ease,
        background-color 0.2s ease;
}

.project-card:hover {
    border-color: #888;
    background: #fafafa;
}

.project-card-title {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
    font-weight: 400;
    color: #1a1a1a !important;
}

.project-card:hover .project-card-title {
    color: var(--link-color) !important;
}

.project-card-desc {
    font-size: 0.9rem;
    color: #555 !important;
    margin-bottom: 1.5rem;
    flex-grow: 1;
    line-height: 1.6;
}

.project-card-meta {
    font-size: 0.8rem;
    color: #888;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 0.75rem;
    letter-spacing: 0.02em;
}

.project-card-tech {
    text-transform: lowercase;
    color: #777;
}

/* --- Component Features --- */
.audio-player-wrapper {
    margin: 2rem 0;
    background: var(--sidebar-bg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}
.html5-audio {
    width: 100%;
    margin-bottom: 1rem;
}
.audio-transcript summary {
    cursor: pointer;
    font-weight: bold;
}
.transcript-content {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.95em;
}

/* --- Footnotes --- */
.footnotes {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px dashed var(--border-color);
    font-size: 0.85rem;
    color: #666;
    line-height: 1.6;
}
.footnote-backref {
    text-decoration: none !important;
    margin-left: 0.5rem;
    color: var(--link-color);
}

/* =========================================
   7. Mobile Layout
========================================= */
@media (max-width: 768px) {
    .site-wrapper {
        grid-template-columns: 1fr;
    }
    .sidebar {
        padding: 1.5rem;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    .sidebar-header {
        margin-bottom: 0;
    }
    #menu-toggle {
        display: block;
    }
    .main-nav {
        display: none;
        margin-top: 1rem;
    }
    .main-nav.open {
        display: block;
    }
    .content {
        padding: 2.5rem 1.5rem;
    }
}
