:root {
    --bg-color: #000000;
    --text-color: #ffffff;
    --dim-color: #888888;
    --accent-color: #ffffff;
    --border-color: #333333;

    --font-main: 'Hack', monospace;
    --font-code: 'Hack', monospace;

    --nav-h: 60px;
}

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

a,
.btn,
summary,
[onclick] {
    cursor: pointer;
}

.btn.soon {
    cursor: default;
}


html {
    -webkit-text-size-adjust: 100%;
    scroll-padding-top: calc(var(--nav-h) + 1rem);
}
body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    font-size: 16px;
    line-height: 1.4;
    overflow-x: hidden;
}

::selection {
    background: var(--text-color);
    color: var(--bg-color);
}

main {
    max-width: 1000px;
    margin: 0 auto;
    padding: var(--nav-h) 2rem 0 2rem;
    position: relative;
    z-index: 1;
}

.section {
    padding: 6rem 0;
    border-bottom: 1px dashed var(--dim-color);
    /* the linked-section flash measures itself against the element it marks, so
       the element has to be its own containing block — otherwise the overlay
       stretches to <main>, the nearest positioned ancestor */
    position: relative;
}

.section:last-child {
    border-bottom: none;
}

h1,
h2,
h3 {
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 1.5rem;
}

h1 {
    font-size: 4rem;
    line-height: 1;
}

h2.section-title {
    font-size: 2.5rem;
    padding-left: 0;
    margin-bottom: 3rem;
}



p {
    margin-bottom: 1.5rem;
    color: var(--dim-color);
}

a {
    color: var(--text-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

a:hover {
    border-bottom-color: var(--text-color);
}

:focus-visible {
    outline: 2px solid var(--text-color);
    outline-offset: 3px;
}

.tags {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
}

.tag {
    font-family: var(--font-code);
    font-size: 0.8rem;
    color: var(--bg-color);
    background: var(--dim-color);
    padding: 0.2rem 0.5rem;
}

#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.3;
    pointer-events: none;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    font-family: var(--font-code);
    font-size: 0.8rem;
}

.read-more {
    display: inline-block;
    margin-top: 1rem;
    font-family: var(--font-code);
    text-transform: uppercase;
    font-size: 0.8rem;
}

.read-more::after {
    content: ' >>';
}

footer {
    text-align: center;
    padding: 4rem 0;
    border-top: 1px solid var(--border-color);
    color: var(--dim-color);
    font-family: var(--font-code);
    font-size: 0.8rem;
}

.article-content {
    padding-top: 8rem;
}

.glass-panel {
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
    backdrop-filter: none;
}

.article-header h1 {
    font-size: 3rem;
}

.article-body pre {
    background: #111;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 1rem;
    overflow-x: auto;
}

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

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--nav-h);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    background: var(--bg-color);
    z-index: 1000;
}


.top-nav .links a {
    display: inline-block;
    padding: 0 1rem;
}

.hero-section {
    /* pull back main's 60px nav clearance so the hero centres on the viewport,
       not on the space below the fixed nav */
    min-height: 100vh;
    margin-top: calc(var(--nav-h) * -1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: relative;
}

.hero-content {
    max-width: 800px;
}



.btn {
    display: inline-block;
    padding: 0.8rem 2rem;
    background: transparent;
    color: var(--text-color);
    font-family: var(--font-code);
    text-transform: uppercase;
    font-size: 0.9rem;
    margin-right: 1rem;
    transition: all 0.2s;
    position: relative;
    cursor: pointer;
}

.btn::before {
    content: '[ ';
}

.btn::after {
    content: ' ]';
}

.btn:hover {
    background: var(--text-color);
    color: var(--bg-color);
    transform: none;
    box-shadow: none;
}

.card,
.project-card {
    background: #000;
    padding: 2rem; 
    margin-bottom: 2rem;
    position: relative;
    transition: none;
}

.card:hover,
.project-card:hover {
    transform: none;
}

.ascii-box {
    position: relative;
}

.ascii-border-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    white-space: pre !important;
    overflow: hidden;
    color: var(--dim-color);
    font-family: 'Hack', monospace;
    font-size: 16px;
    line-height: 1;
    z-index: 10;
    background: transparent;
}
/* ── /insomniac page ─────────────────────────────────────────── */

.hero-section.compact {
    min-height: auto;
    padding: 8rem 0 4rem 0;
    text-align: left;
    align-items: flex-start;
    border-bottom: 1px dashed var(--dim-color);
}

.hero-section.compact h1 {
    font-size: 3.5rem;
}

.hero-section.compact .badge {
    display: inline-block;
    font-family: var(--font-code);
    font-size: 0.8rem;
    color: var(--dim-color);
    border: 1px solid var(--border-color);
    padding: 0.2rem 0.6rem;
    margin-bottom: 1.5rem;
}

.tool-card + .tool-card {
    margin-top: 3rem;
}

.shot {
    border: 1px solid var(--border-color);
    margin: 0 auto 2rem auto;
    background: #000;
    line-height: 0;
}

.shot img {
    display: block;
    width: 100%;
    height: auto;
}

.tool-card code,
.details-body code {
    font-family: var(--font-code);
    font-size: 0.9em;
    color: var(--text-color);
}

.tool-card details {
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    margin: 0 0 1.5rem 0;
}

.tool-card summary {
    font-family: var(--font-code);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
    padding: 0.8rem 0;
    cursor: pointer;
    list-style: none;
    color: var(--dim-color);
}

.tool-card summary::-webkit-details-marker {
    display: none;
}

.tool-card summary::before {
    content: '[+] ';
}

.tool-card details[open] summary::before {
    content: '[-] ';
}

.tool-card summary:hover {
    color: var(--text-color);
}

.details-body {
    padding-bottom: 0.5rem;
}

.details-body ul {
    list-style: none;
    margin: 0 0 1.5rem 0;
    padding: 0;
    color: var(--dim-color);
}

.details-body li {
    padding-left: 1.5rem;
    position: relative;
    margin-bottom: 0.6rem;
}

.details-body li::before {
    content: '>';
    position: absolute;
    left: 0;
    color: var(--border-color);
}

.details-body .req {
    margin-bottom: 0.8rem;
}

.details-body .req span {
    font-family: var(--font-code);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
    color: var(--text-color);
    margin-right: 0.5rem;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0;
}

.actions .btn {
    padding: 0.6rem 1rem;
    margin-right: 0.5rem;
}

.disclaimer {
    margin-top: 3rem;
    font-size: 0.8rem;
    color: var(--border-color);
}

/* shared: keep long rows from overflowing narrow screens */
.tags {
    flex-wrap: wrap;
    gap: 0.5rem;
}

.top-nav .links {
    display: flex;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    main {
        padding: var(--nav-h) 1rem 0 1rem;
    }

    .section {
        padding: 3.5rem 0;
    }

    .card,
    .project-card {
        padding: 1.5rem 1.25rem;
    }

    .hero-section.compact {
        padding: 3rem 0;
    }

    .hero-section.compact h1 {
        font-size: 2.2rem;
        letter-spacing: 1px;
    }

    h2.section-title {
        font-size: 1.8rem;
        margin-bottom: 2rem;
    }

    .tool-card h3 {
        font-size: 1.2rem;
    }

    .actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .btn {
        margin-right: 0;
    }

    /* the ascii border overlay is decorative and mis-measures on small screens */
    .ascii-border-overlay {
        display: none;
    }

    .card,
    .project-card {
        border: 1px solid var(--border-color);
    }
}

.btn.soon {
    color: var(--border-color);
    cursor: default;
}

.btn.soon:hover {
    background: transparent;
    color: var(--border-color);
}

.shot figcaption {
    font-family: var(--font-code);
    font-size: 0.75rem;
    color: var(--dim-color);
    line-height: 1.4;
    padding: 0.6rem 0.8rem;
    border-top: 1px solid var(--border-color);
}



/* ── phones ──────────────────────────────────────────────────── */

@media (max-width: 768px) {
    :root {
        --nav-h: 48px;
    }

    /* taps need to feel like they landed */
    .btn:active,
    .top-nav .links a:active,
    .read-more:active,
    .tool-card summary:active {
        background: var(--text-color);
        color: var(--bg-color);
    }

    a {
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.15);
    }

    /* one compact row that stays put, instead of wrapping into a stack */
    .top-nav {
        padding: 0 max(0.75rem, env(safe-area-inset-right)) 0 max(0.75rem, env(safe-area-inset-left));
        border-bottom: 1px solid var(--border-color);
        gap: 0.5rem;
    }

    .top-nav .logo {
        font-size: 0.85rem;
        letter-spacing: 1px;
        flex-shrink: 0;
    }

    .top-nav .links {
        flex-wrap: nowrap;
        justify-content: flex-end;
    }

    .top-nav .links a {
        font-size: 0.72rem;
        letter-spacing: 0;
        padding: 0.9rem 0.3rem;
        white-space: nowrap;
    }

    /* svh = the viewport with the browser chrome showing, so the buttons
       never end up underneath Safari's address bar */
    .hero-section {
        min-height: 100vh;
        min-height: 100svh;
        padding: 1.5rem 0;
    }

    .hero-section h1 {
        font-size: 2.1rem;
        letter-spacing: 1px;
    }

    .hero-section .bio {
        font-size: 0.95rem;
    }

    .socials {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.75rem;
    }

    .socials .btn {
        margin: 0;
    }

    /* comfortable touch targets everywhere */
    .btn {
        padding: 0.75rem 1.1rem;
        font-size: 0.85rem;
    }

    .read-more {
        padding: 0.5rem 0;
    }

    .tool-card summary {
        padding: 1rem 0;
    }

    .tool-card p,
    .card p,
    .details-body li,
    .details-body .req {
        font-size: 0.95rem;
    }

    .shot figcaption {
        font-size: 0.7rem;
    }

    footer {
        padding: 2.5rem 1rem calc(2.5rem + env(safe-area-inset-bottom)) 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    #particle-canvas {
        display: none;
    }

    .cursor-blink {
        animation: none;
    }

    html {
        scroll-behavior: auto;
    }
}

/* ── copy-link buttons and toast ─────────────────────────────── */

.share-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5em;
    height: 1.5em;
    margin-left: 0.6em;
    padding: 0;
    vertical-align: middle;
    font-family: var(--font-code);
    font-size: 0.55em;
    line-height: 1;
    letter-spacing: 0;
    color: var(--dim-color);
    background: transparent;
    border: 1px solid var(--border-color);
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.share-link:hover {
    color: var(--bg-color);
    background: var(--text-color);
    border-color: var(--text-color);
}

/* the glyph stays small; the touch target does not */
.share-link {
    position: relative;
    /* without this the following paragraph paints over the expanded area */
    z-index: 1;
}

.share-link::after {
    content: '';
    position: absolute;
    inset: -14px;
}

.copied-toast {
    position: fixed;
    left: 50%;
    bottom: calc(2rem + env(safe-area-inset-bottom));
    transform: translate(-50%, 0.5rem);
    z-index: 2000;

    padding: 0.55rem 1.1rem;
    white-space: nowrap;

    background: var(--bg-color);
    border: 1px solid var(--text-color);
    color: var(--text-color);
    font-family: var(--font-code);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    line-height: 1;

    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease-out, transform 0.18s ease-out;
}

.copied-toast::before {
    content: '> ';
}

.copied-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
    .copied-toast {
        transition: none;
        transform: translate(-50%, 0);
    }
}

/* ── wide screens: put the screenshot beside the text ────────── */

@media (min-width: 900px) {
    .tool-card .card-content {
        display: grid;
        grid-template-columns: minmax(0, 42%) minmax(0, 1fr);
        column-gap: 2.5rem;
    }

    /* everything except the screenshot stacks in the right-hand column;
       the figure spans them all (its row span is set in the page script) */
    .tool-card .card-content > * {
        grid-column: 2;
        min-width: 0;
    }

    .tool-card .shot {
        grid-column: 1;
        grid-row: 1 / -1;
        align-self: start;
        margin: 0;
        /* long expanded text would otherwise leave this column empty */
        position: sticky;
        top: calc(var(--nav-h) + 1.5rem);
    }

    .tool-card .actions {
        gap: 0.25rem 0;
    }

    .tool-card h3 {
        margin-top: -0.35rem;
    }

    .section {
        padding: 4.5rem 0;
    }

    .tool-card + .tool-card {
        margin-top: 2rem;
    }
}

/* ── the section the URL points at ───────────────────────────── */

.is-linked:not(.ascii-box) {
    animation: linked-flash 1.4s ease-out 1;
}

@keyframes linked-flash {
    from {
        background-color: rgba(255, 255, 255, 0.11);
    }

    to {
        background-color: transparent;
    }
}

/* on wide screens the card's visible edge is the ascii overlay, not a border */
.is-linked .ascii-border-overlay {
    color: var(--text-color);
}

.is-linked.card,
.is-linked.project-card {
    border-color: var(--text-color);
}

/* and mark its [#] so it's obvious which link you followed */
.is-linked > h2 > .share-link,
.is-linked > .card-content > h3 > .share-link {
    color: var(--bg-color);
    background: var(--text-color);
    border-color: var(--text-color);
}

@media (prefers-reduced-motion: reduce) {
    .is-linked {
        animation: none;
    }
}

.linked-field {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* keep card content above the flash */
.ascii-box > *:not(.linked-field):not(.ascii-border-overlay) {
    position: relative;
    z-index: 1;
}


/* ── Insomniac archive gallery ───────────────────────────────── */

.archive-gallery-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 2rem;
    margin-bottom: 2rem;
}

.archive-gallery-heading .section-title {
    margin-bottom: 1rem;
}

.archive-gallery-heading .badge {
    display: inline-block;
    margin-bottom: 1rem;
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--border-color);
    color: var(--dim-color);
    font-size: 0.8rem;
}

.archive-gallery-heading p {
    max-width: 720px;
}

.archive-gallery-stat {
    min-width: 150px;
    padding: 1rem;
    border: 1px solid var(--border-color);
    text-align: right;
    font-family: var(--font-code);
}

.archive-gallery-stat strong,
.archive-gallery-stat span {
    display: block;
}

.archive-gallery-stat strong {
    font-size: 2rem;
    font-weight: 400;
    color: var(--text-color);
}

.archive-gallery-stat span {
    font-size: 0.72rem;
    color: var(--dim-color);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.archive-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 0.35fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.archive-controls label {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    color: var(--dim-color);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.archive-controls input,
.archive-controls select {
    width: 100%;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 0;
    outline: none;
    background: #000;
    color: var(--text-color);
    font: inherit;
}

.archive-controls input:focus,
.archive-controls select:focus {
    border-color: var(--text-color);
}

.archive-controls select {
    color-scheme: dark;
}

.archive-count {
    margin: 0 0 1.25rem 0;
    font-size: 0.75rem;
    color: var(--dim-color);
}

.archive-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.archive-card {
    min-width: 0;
    margin: 0;
    border: 1px solid var(--border-color);
    background: #000;
    cursor: zoom-in;
    overflow: hidden;
}

.archive-card:hover,
.archive-card:focus-visible {
    border-color: var(--text-color);
}

.archive-card img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: contain;
    background: #080808;
    border-bottom: 1px solid var(--border-color);
}

.archive-card figcaption {
    display: flex;
    min-height: 118px;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.8rem;
    font-size: 0.72rem;
    line-height: 1.35;
}

.archive-card-project {
    color: var(--dim-color);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.archive-card strong {
    display: -webkit-box;
    overflow: hidden;
    color: var(--text-color);
    font-weight: 400;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.archive-card-detail {
    margin-top: auto;
    color: #666;
}

.archive-load-more {
    display: block;
    margin: 2rem auto 0 auto;
    border: 0;
}

.archive-load-more[hidden] {
    display: none;
}

.archive-empty {
    grid-column: 1 / -1;
    padding: 2rem 0;
}

.archive-lightbox[hidden] {
    display: none;
}

.archive-lightbox {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) 64px;
    align-items: center;
    padding: 2rem;
    background: rgba(0, 0, 0, 0.94);
}

.archive-lightbox-panel {
    width: min(1500px, 100%);
    max-height: calc(100vh - 4rem);
    margin: 0 auto;
    overflow: auto;
    border: 1px solid var(--border-color);
    background: #000;
}

.archive-lightbox-image {
    display: block;
    width: 100%;
    max-height: calc(100vh - 250px);
    object-fit: contain;
    background: #050505;
}

.archive-lightbox-caption {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
}

.archive-lightbox-caption h3 {
    margin-bottom: 0.5rem;
    font-size: 1rem;
    text-transform: none;
    letter-spacing: 0;
}

.archive-lightbox-caption p {
    margin-bottom: 0.7rem;
    font-size: 0.75rem;
}

.archive-lightbox-sources {
    margin-bottom: 0.5rem;
    color: var(--dim-color);
    font-size: 0.7rem;
}

.archive-lightbox-sources > span {
    color: var(--text-color);
    text-transform: uppercase;
}

.archive-lightbox-sources ul {
    margin: 0.35rem 0 0 1.2rem;
}

.archive-lightbox-close,
.archive-lightbox-nav {
    border: 0;
    background: transparent;
    color: var(--text-color);
    font-family: var(--font-code);
    cursor: pointer;
}

.archive-lightbox-close {
    position: absolute;
    top: 0.8rem;
    right: 1.2rem;
    z-index: 2;
    padding: 0.5rem;
    font-size: 2rem;
}

.archive-lightbox-nav {
    width: 52px;
    height: 70px;
    font-size: 3rem;
    line-height: 1;
}

.archive-lightbox-nav:hover,
.archive-lightbox-close:hover {
    color: var(--dim-color);
}

.archive-lightbox-open-body {
    overflow: hidden;
}

@media (max-width: 900px) {
    .archive-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .archive-gallery-heading {
        display: block;
    }

    .archive-gallery-stat {
        width: fit-content;
        margin-bottom: 1.5rem;
        text-align: left;
    }

    .archive-controls {
        grid-template-columns: 1fr;
    }

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

    .archive-card figcaption {
        min-height: 0;
    }

    .archive-lightbox {
        grid-template-columns: 42px minmax(0, 1fr) 42px;
        padding: 2.8rem 0.25rem 0.5rem 0.25rem;
    }

    .archive-lightbox-panel {
        max-height: calc(100svh - 3.3rem);
    }

    .archive-lightbox-image {
        max-height: calc(100svh - 260px);
    }

    .archive-lightbox-nav {
        width: 40px;
        font-size: 2rem;
    }
}
