:root {
    --bg: #0d1117;
    --bg-raised: #161b22;
    --bg-terminal: #0a0e14;
    --text: #c9d1d9;
    --text-dim: #8b949e;
    --cyan: #58a6ff;
    --green: #3fb950;
    --orange: #d29922;
    --pink: #f778ba;
    --purple: #bc8cff;
    --red: #f85149;
    --border: #21262d;
    --font-mono: 'JetBrains Mono', monospace;
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --max-width: 800px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-mono);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    font-size: 14px;
    line-height: 1.6;
}

a {
    color: var(--cyan);
    text-decoration: none;
}

a:hover {
    color: #79c0ff;
}

::selection {
    background: rgba(88, 166, 255, 0.3);
    color: #fff;
}


/* starfield canvas */

#starCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    pointer-events: none;
}


/* navigation */

.main-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
}

.main-nav.scrolled {
    background: rgba(13, 17, 23, 0.95);
}

.nav-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-home {
    font-size: 0.85rem;
    color: var(--text-dim);
    text-decoration: none;
    white-space: nowrap;
}

.nav-home:hover {
    color: var(--text);
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 1.5rem;
    margin-left: auto;
    align-items: center;
}

.nav-links li a,
.nav-links a,
.nav-link {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-decoration: none;
    transition: color 0.2s;
    padding: 0.25rem 0;
}

.nav-links li a:hover,
.nav-links a:hover,
.nav-links a.active,
.nav-link:hover,
.nav-link.active {
    color: var(--cyan);
}

/* override old gradient underline animation */
.nav-link::after {
    display: none;
}

.cart-icon {
    position: relative;
    cursor: pointer;
    padding: 0.25rem;
}

.cart-icon svg {
    width: 18px;
    height: 18px;
    stroke: var(--text-dim);
    fill: none;
    stroke-width: 1.5;
}

.cart-icon:hover svg {
    stroke: var(--cyan);
}

.cart-count {
    position: absolute;
    top: -6px;
    right: -8px;
    background: var(--green);
    color: var(--bg);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
}

.sky-toggle {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.sky-toggle:hover {
    border-color: var(--cyan);
    color: var(--text);
}

.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: 1px solid var(--border);
    cursor: pointer;
    padding: 8px 10px;
}

.mobile-menu-toggle span {
    width: 18px;
    height: 1.5px;
    background: var(--text-dim);
    transition: all 0.2s;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(4px, 4px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(4px, -4px);
}


/* site content wrapper */

.site-content {
    position: relative;
    z-index: 1;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
    padding-top: 4rem;
}


/* name header */

.name-header {
    text-align: center;
    padding: 3rem 0 1rem;
}

.ascii-name {
    font-family: var(--font-mono);
    font-size: clamp(0.35rem, 1.2vw, 0.75rem);
    line-height: 1.15;
    color: var(--cyan);
    white-space: pre;
    display: inline-block;
    text-align: left;
}

.site-name {
    font-family: var(--font-mono);
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 300;
    color: var(--text);
    letter-spacing: 0.1em;
}


/* terminal */

.terminal-section {
    padding: 1rem 0 2.5rem;
}

.terminal {
    background: var(--bg-terminal);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    overflow: hidden;
}

.terminal-header {
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    color: var(--text-dim);
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.terminal-dots {
    display: flex;
    gap: 6px;
}

.terminal-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.terminal-dots span:nth-child(1) { background: #f85149; }
.terminal-dots span:nth-child(2) { background: #d29922; }
.terminal-dots span:nth-child(3) { background: #3fb950; }

.terminal-title {
    color: var(--text-dim);
}

.terminal-body {
    padding: 0.75rem 1rem;
    min-height: 60px;
    max-height: 400px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.terminal-body::-webkit-scrollbar {
    width: 6px;
}

.terminal-body::-webkit-scrollbar-track {
    background: transparent;
}

.terminal-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.terminal-line {
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.terminal-prompt {
    color: var(--green);
}

.terminal-user {
    color: var(--green);
}

.terminal-host {
    color: var(--green);
}

.terminal-path {
    color: var(--cyan);
}

.terminal-cmd {
    color: var(--text);
}

.terminal-result {
    color: var(--text-dim);
}

.terminal-error {
    color: var(--red);
}

.terminal-accent {
    color: var(--cyan);
}

.terminal-highlight {
    color: var(--orange);
}

.terminal-success {
    color: var(--green);
}

.terminal-bold {
    font-weight: 700;
}

.terminal-input-line {
    display: flex;
    align-items: center;
    line-height: 1.6;
}

.terminal-input {
    background: none;
    border: none;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: inherit;
    outline: none;
    flex: 1;
    caret-color: transparent;
    line-height: 1.6;
}

.terminal-cursor {
    display: inline-block;
    width: 0.55em;
    height: 1.15em;
    background: var(--green);
    animation: cursor-blink 1s step-end infinite;
    vertical-align: text-bottom;
    margin-left: 1px;
}

@keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* neofetch layout in terminal */
.neofetch-container {
    display: flex;
    gap: 2rem;
    margin: 0.5rem 0;
}

.neofetch-art {
    color: var(--cyan);
    white-space: pre;
    line-height: 1.2;
    font-size: 0.7rem;
    flex-shrink: 0;
}

.neofetch-info {
    line-height: 1.6;
}

.neofetch-label {
    color: var(--cyan);
    font-weight: 700;
}

.neofetch-separator {
    color: var(--border);
}


/* sections */

.section {
    padding: 2rem 0;
}

.section-heading {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.75rem;
    margin-bottom: 1.25rem;
}

.section-more {
    display: inline-block;
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--text-dim);
}

.section-more:hover {
    color: var(--cyan);
}


/* article list — homepage compact view */

.article-list {
    list-style: none;
}

.article-list-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.4rem 0;
    gap: 1.5rem;
}

.article-list-item a {
    color: var(--text);
    font-size: 0.85rem;
    transition: color 0.2s;
}

.article-list-item a:hover {
    color: var(--cyan);
}

.article-list-date {
    color: var(--text-dim);
    font-size: 0.8rem;
    white-space: nowrap;
    flex-shrink: 0;
}


/* project list — homepage compact view */

.project-list {
    list-style: none;
}

.project-list-item {
    padding: 0.35rem 0;
    display: flex;
    align-items: baseline;
    gap: 1.25rem;
}

.project-name {
    color: var(--cyan);
    font-size: 0.85rem;
    white-space: nowrap;
    text-decoration: none;
    flex-shrink: 0;
}

.project-name:hover {
    color: #79c0ff;
}

.project-desc {
    color: var(--text-dim);
    font-size: 0.8rem;
    font-style: italic;
}


/* racing link */

.racing-link {
    display: flex;
    align-items: baseline;
    gap: 1.25rem;
    padding: 0.35rem 0;
}

.racing-link a {
    font-size: 0.85rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.racing-desc {
    color: var(--text-dim);
    font-size: 0.8rem;
    font-style: italic;
}


/* pattern widget — ambient homepage element */

.pattern-widget-wrap {
    padding: 2rem 0 0.5rem;
    display: flex;
    justify-content: center;
}

.pattern-widget {
    border: 1px solid var(--border);
    border-radius: 2px;
    image-rendering: pixelated;
}

/* home pattern preview (compact) */

.pv-home .pv-canvas-wrap {
    max-width: 425px;
}

.pv-home .pv-controls {
    max-width: 100%;
}

.pv-home .pv-btn {
    font-size: 0.6rem;
    padding: 0.15rem 0.4rem;
}


/* page header — subpages */

.page-header {
    padding: 3rem 0 1.5rem;
}

.page-title {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.75rem;
}


/* filters — writing, gallery */

.writing-filters,
.gallery-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-btn {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 0.25rem 0.6rem;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.filter-btn:hover,
.filter-btn.active {
    border-color: var(--cyan);
    color: var(--cyan);
}


/* writing cards */

.writing-section {
    padding: 0 0 4rem;
}

.writing-list {
    max-width: var(--max-width);
    margin: 0 auto;
}


/* patterns viewer */

.patterns-section {
    padding: 0 0 4rem;
}

.patterns-viewer {
    max-width: var(--max-width);
    margin: 0 auto;
}


/* gallery */

.gallery-section {
    padding: 0 0 3rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.gallery-item {
    position: relative;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 3/4;
    transition: border-color 0.2s;
}

.gallery-item:hover {
    border-color: var(--text-dim);
}

.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(100%);
    transition: filter 0.3s;
}

.gallery-item:hover .gallery-image {
    filter: grayscale(70%);
}

.gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(10, 14, 20, 0.9), transparent);
    padding: 1.25rem 0.75rem 0.75rem;
    transform: translateY(100%);
    transition: transform 0.2s;
}

.gallery-item:hover .gallery-overlay {
    transform: translateY(0);
}

.gallery-title {
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 0.2rem;
}

.gallery-price {
    color: var(--green);
    font-size: 0.75rem;
}


/* store / products */

.store-section {
    padding: 0 0 3rem;
}

.store-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.75rem;
}

.product-card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 2px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.product-card:hover {
    border-color: var(--text-dim);
}

.product-image-container {
    position: relative;
}

.product-image {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
    filter: grayscale(100%);
}

.product-info {
    padding: 1rem;
}

.product-title {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.3rem;
}

.product-description {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 0.6rem;
    line-height: 1.5;
}

.product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.product-price {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--green);
}

.add-to-cart {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    background: none;
    border: 1px solid var(--green);
    color: var(--green);
    padding: 0.25rem 0.6rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.add-to-cart:hover {
    background: var(--green);
    color: var(--bg);
}


/* shopping cart */

.shopping-cart {
    position: fixed;
    right: -400px;
    top: 0;
    width: 400px;
    height: 100vh;
    background: var(--bg);
    border-left: 1px solid var(--border);
    z-index: 2000;
    transition: right 0.3s;
    display: flex;
    flex-direction: column;
    font-family: var(--font-mono);
}

.shopping-cart.active {
    right: 0;
}

.cart-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
}

.cart-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.25rem;
}

.cart-close:hover {
    color: var(--red);
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.cart-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 2px;
    margin-bottom: 0.5rem;
}

.cart-item-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 2px;
    filter: grayscale(100%);
}

.cart-item-info {
    flex: 1;
}

.cart-item-title {
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 0.2rem;
}

.cart-item-price {
    color: var(--green);
    font-size: 0.75rem;
}

.cart-item-remove {
    background: none;
    border: none;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    cursor: pointer;
    padding: 0.25rem;
}

.cart-item-remove:hover {
    color: var(--red);
}

.cart-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.btn-checkout {
    display: block;
    width: 100%;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: var(--green);
    color: var(--bg);
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    font-weight: 600;
    text-align: center;
    transition: opacity 0.2s;
}

.btn-checkout:hover {
    opacity: 0.85;
}

.cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    display: none;
}

.cart-overlay.active {
    display: block;
}


/* about / contact */

.about-section {
    padding: 0 0 2rem;
}

.about-content {
    max-width: 600px;
}

.contact-section {
    padding: 0 0 4rem;
}

.contact-content {
    max-width: 600px;
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.form-group label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.3rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg-terminal);
    border: 1px solid var(--border);
    border-radius: 2px;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--cyan);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.btn-submit {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: none;
    border: 1px solid var(--cyan);
    color: var(--cyan);
    padding: 0.4rem 1.25rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    align-self: flex-start;
}

.btn-submit:hover {
    background: var(--cyan);
    color: var(--bg);
}

.contact-links {
    margin-top: 1.5rem;
}

.contact-links a {
    display: inline-block;
    margin-right: 1.5rem;
    font-size: 0.8rem;
}


/* projects page */

.projects-section {
    padding: 0 0 4rem;
}

.project-card {
    background: rgba(22, 27, 34, 0.65);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 0.5rem;
    transition: border-color 0.2s;
}

.project-card:hover {
    border-color: var(--text-dim);
}

.project-card-name {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.2rem;
}

.project-card-name a {
    color: var(--cyan);
}

.project-card-desc {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 0.4rem;
}

.project-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.project-tag {
    font-size: 0.55rem;
    color: var(--purple);
    border: 1px solid rgba(188, 140, 255, 0.3);
    padding: 0.1rem 0.3rem;
    border-radius: 2px;
}


/* footer */

.site-footer,
.main-footer {
    position: relative;
    z-index: 1;
    border-top: 1px solid var(--border);
    padding: 1rem 1.5rem;
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-dim);
}

.footer-astro {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.footer-astro span {
    white-space: nowrap;
}

.footer-note {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 0.3rem;
}


/* common layout helper */

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}


/* responsive */

@media (max-width: 768px) {
    .nav-links {
        display: none;
    }

    .nav-links.mobile-open {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: rgba(13, 17, 23, 0.95);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        padding: 0.75rem 1.5rem;
        gap: 0.6rem;
        border-bottom: 1px solid var(--border);
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .sky-toggle {
        margin-left: auto;
    }

    .shopping-cart {
        width: 100%;
        right: -100%;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

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

    .article-list-item {
        flex-direction: column;
        gap: 0.15rem;
    }

    .project-list-item {
        flex-direction: column;
        gap: 0.1rem;
    }

    .ascii-name {
        font-size: clamp(0.22rem, 2.5vw, 0.6rem);
    }

    .terminal-body {
        max-height: 300px;
    }

    .footer-astro {
        flex-direction: column;
        gap: 0.2rem;
    }

    .neofetch-container {
        flex-direction: column;
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .nav-container {
        padding: 0.6rem 1rem;
    }

    .site-content {
        padding: 0 1rem;
        padding-top: 3.5rem;
    }

    .terminal {
        font-size: 0.75rem;
    }

    .name-header {
        padding: 2rem 0 0.5rem;
    }
}
