/* =========================================================
   KRUSHCOMICS - SITE-WIDE STYLES

   Loaded on every public page. Holds the font, the colour
   tokens, base typography and every component that is shared
   between apps: navbar, footer, page headers, breadcrumbs,
   section headers, buttons, search, tabs, pagination, link
   rows, carousels and long-form prose.

   App stylesheets only add what is specific to that app.
   ========================================================= */


/* ---------------------------------
   Font

   JetBrainsMono Nerd Font, self-hosted from core/fonts/.
   The files are subsets of the official Nerd Fonts release:
   Latin text, terminal symbols (box drawing, arrows,
   powerline), every Octicon and a handful of other icons.
   Ligatures are kept. Licensed under the SIL OFL 1.1, see
   core/fonts/OFL.txt.
--------------------------------- */

@font-face {
    font-family: "JetBrainsMono Nerd Font";
    src: url("../fonts/JetBrainsMonoNerdFont-Regular.e8920ccb1600.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "JetBrainsMono Nerd Font";
    src: url("../fonts/JetBrainsMonoNerdFont-Italic.e4333948c3d8.woff2") format("woff2");
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: "JetBrainsMono Nerd Font";
    src: url("../fonts/JetBrainsMonoNerdFont-Medium.5bc3b62aa9b3.woff2") format("woff2");
    font-weight: 500 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "JetBrainsMono Nerd Font";
    src: url("../fonts/JetBrainsMonoNerdFont-Bold.f69965d882c5.woff2") format("woff2");
    font-weight: 700 800;
    font-style: normal;
    font-display: swap;
}


/* ---------------------------------
   Tokens
--------------------------------- */

:root {
    color-scheme: dark;

    --font-mono:
        "JetBrainsMono Nerd Font",
        "JetBrains Mono",
        ui-monospace,
        SFMono-Regular,
        Menlo,
        Consolas,
        monospace;

    /* Surfaces, darkest to lightest */
    --bg: #0b0c0f;
    --bg-soft: #0f1115;
    --surface: #14161b;
    --surface-hover: #1a1d23;

    --border: #22262e;
    --border-strong: #313641;

    /* Text */
    --text: #e6e8eb;
    --text-muted: #969ca8;
    --text-faint: #646a76;

    /* Red accent. Previous orange, to switch back:
       #ff8a3d / #ffa766 / rgba(255, 138, 61, …) */
    --accent: #ff4f4f;
    --accent-hover: #ff7a7a;
    --accent-soft: rgba(255, 79, 79, 0.12);
    --accent-line: rgba(255, 79, 79, 0.45);
    --on-accent: #140a03;

    --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;

    /* Layout */
    --gutter: clamp(16px, 4vw, 40px);
    --content: 1240px;
    --reading: 780px;

    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}


/* ---------------------------------
   Reset
--------------------------------- */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;

    box-sizing: border-box;
}


/* ---------------------------------
   Base
--------------------------------- */

html {
    -webkit-text-size-adjust: 100%;

    scroll-padding-top: 80px;

    scrollbar-color: var(--border-strong) var(--bg);
}

body {
    display: flex;
    flex-direction: column;

    min-height: 100vh;

    font-family: var(--font-mono);
    font-size: 0.9375rem;
    line-height: 1.7;

    background-color: var(--bg);
    color: var(--text);

    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.site-content {
    flex: 1 0 auto;
}

img {
    max-width: 100%;
}

h1,
h2,
h3,
h4 {
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;

    color: var(--text);

    text-wrap: balance;
}

a {
    color: var(--accent);

    text-decoration-thickness: 1px;
    text-underline-offset: 3px;

    transition: color 0.2s ease;
}

a:hover {
    color: var(--accent-hover);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;

    border-radius: 2px;
}

::selection {
    background-color: var(--accent);
    color: var(--on-accent);
}

/* Nerd Font glyph. The whole site uses the Nerd Font, so this
   only normalises sizing for icons placed next to text. */
.icon {
    display: inline-block;

    font-style: normal;
    font-weight: 400;
    line-height: 1;
}

.visually-hidden {
    position: absolute;

    width: 1px;
    height: 1px;

    overflow: hidden;

    clip-path: inset(50%);

    white-space: nowrap;
}

.skip-link {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 100;

    padding: 8px 14px;

    background-color: var(--accent);
    color: var(--on-accent);

    border-radius: var(--radius-sm);

    transform: translateY(-200%);
}

.skip-link:focus {
    transform: none;

    color: var(--on-accent);
}


/* ---------------------------------
   Navigation
--------------------------------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;

    background-color: rgba(11, 12, 15, 0.8);

    border-bottom: 1px solid var(--border);

    -webkit-backdrop-filter: saturate(140%) blur(12px);
    backdrop-filter: saturate(140%) blur(12px);
}

.navbar {
    display: flex;

    justify-content: space-between;
    align-items: center;

    gap: 24px;

    width: min(100% - 2 * var(--gutter), var(--content));
    min-height: 60px;

    margin: 0 auto;
}

.nav-brand {
    display: inline-flex;
    align-items: center;

    gap: 10px;

    font-size: 1rem;
    font-weight: 700;

    color: var(--text);

    text-decoration: none;
}

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

.nav-brand-prompt {
    color: var(--accent);
}

.nav-brand-cursor {
    display: inline-block;

    width: 0.55em;
    height: 1.1em;

    margin-left: -6px;

    background-color: var(--accent);

    animation: cursor-blink 1.1s steps(1) infinite;
}

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

.nav-links {
    display: flex;

    gap: 4px;
}

.nav-links a {
    padding: 6px 12px;

    font-size: 0.875rem;

    color: var(--text-muted);

    text-decoration: none;

    border-radius: var(--radius-sm);

    transition:
        color 0.2s ease,
        background-color 0.2s ease;
}

.nav-links a:hover {
    color: var(--text);

    background-color: var(--surface);
}

.nav-links a.is-active {
    color: var(--accent);
}


/* ---------------------------------
   Footer
--------------------------------- */

.site-footer {
    margin-top: 96px;

    background-color: var(--bg-soft);

    border-top: 1px solid var(--border);
}

.footer-inner,
.footer-bottom {
    width: min(100% - 2 * var(--gutter), var(--content));

    margin: 0 auto;
}

.footer-inner {
    display: flex;

    justify-content: space-between;
    align-items: flex-start;

    flex-wrap: wrap;

    gap: 24px 48px;

    padding: 40px 0 32px;
}

.footer-brand {
    font-weight: 700;

    color: var(--text);
}

.footer-brand .icon {
    margin-right: 8px;

    color: var(--accent);
}

.footer-about p:not(.footer-brand) {
    max-width: 380px;

    margin-top: 6px;

    font-size: 0.85rem;

    color: var(--text-muted);
}

.footer-links {
    display: flex;

    flex-wrap: wrap;

    gap: 8px 24px;
}

.footer-links a {
    font-size: 0.85rem;

    color: var(--text-muted);

    text-decoration: none;
}

.footer-links a:hover {
    color: var(--accent);
}

.footer-bottom {
    display: flex;

    justify-content: space-between;

    flex-wrap: wrap;

    gap: 8px 24px;

    padding: 18px 0 28px;

    font-size: 0.78rem;

    color: var(--text-faint);

    border-top: 1px solid var(--border);
}


/* ---------------------------------
   Page Layout
--------------------------------- */

.page {
    width: min(100% - 2 * var(--gutter), var(--content));

    margin: 0 auto;

    padding-top: 48px;
}

.page-narrow {
    width: min(100% - 2 * var(--gutter), var(--reading));
}


/* ---------------------------------
   Breadcrumbs

   A shell-style path (~ / thoughts / archive) that replaces
   the old "Back to ..." links.
--------------------------------- */

.crumbs {
    display: flex;

    flex-wrap: wrap;
    align-items: center;

    gap: 2px 8px;

    margin-bottom: 28px;

    font-size: 0.82rem;

    color: var(--text-faint);
}

.crumbs a {
    color: var(--text-muted);

    text-decoration: none;
}

.crumbs a:first-child {
    color: var(--accent);
}

.crumbs a:hover {
    color: var(--accent-hover);
}

.crumbs [aria-current="page"] {
    max-width: 40ch;

    overflow: hidden;

    color: var(--text);

    text-overflow: ellipsis;
    white-space: nowrap;
}


/* ---------------------------------
   Page Header
--------------------------------- */

.page-header {
    max-width: 760px;

    margin-bottom: 48px;
}

.page-header h1 {
    font-size: clamp(2rem, 5vw, 3rem);
}

.page-lead {
    max-width: 62ch;

    margin-top: 16px;

    font-size: 1rem;

    color: var(--text-muted);
}

.page-lead p + p {
    margin-top: 12px;
}

/* Small uppercase label: post types, eyebrows, kinds. */
.tag {
    display: inline-flex;
    align-items: center;

    gap: 6px;

    margin-bottom: 12px;

    font-size: 0.72rem;
    font-weight: 600;

    letter-spacing: 0.1em;

    text-transform: uppercase;

    color: var(--accent);
}


/* ---------------------------------
   Sections
--------------------------------- */

.section + .section {
    margin-top: 72px;
}

.section-head {
    display: flex;

    justify-content: space-between;
    align-items: flex-end;

    gap: 16px;

    margin-bottom: 24px;
    padding-bottom: 16px;

    border-bottom: 1px solid var(--border);
}

.section-kicker {
    display: block;

    margin-bottom: 6px;

    font-size: 0.78rem;

    color: var(--accent);
}

.section-head h2 {
    font-size: clamp(1.3rem, 3vw, 1.65rem);
}

.section-meta {
    margin-top: 4px;

    font-size: 0.82rem;

    color: var(--text-muted);
}

.section-link {
    display: inline-flex;
    align-items: center;

    flex-shrink: 0;

    gap: 8px;

    font-size: 0.85rem;

    color: var(--text-muted);

    text-decoration: none;

    white-space: nowrap;
}

.section-link .icon {
    transition: transform 0.2s var(--ease);
}

.section-link:hover {
    color: var(--accent);
}

.section-link:hover .icon {
    transform: translateX(3px);
}

/* Plain h2 heading for content sections (about, detail pages). */
.block-title {
    margin-bottom: 18px;

    font-size: 1.15rem;
}

.block-title::before {
    content: "## ";

    color: var(--accent);
}


/* ---------------------------------
   Buttons
--------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    gap: 8px;

    padding: 10px 18px;

    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;

    text-decoration: none;

    border: 1px solid transparent;
    border-radius: var(--radius-sm);

    cursor: pointer;

    transition:
        background-color 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease;
}

.btn-primary {
    background-color: var(--accent);
    color: var(--on-accent);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    color: var(--on-accent);
}

.btn-ghost {
    background-color: transparent;
    color: var(--text);

    border-color: var(--border-strong);
}

.btn-ghost:hover {
    color: var(--accent);

    border-color: var(--accent-line);
}


/* ---------------------------------
   Search
--------------------------------- */

.search {
    display: flex;

    gap: 8px;

    width: min(100%, 560px);
}

.search-field {
    display: flex;
    align-items: center;

    flex: 1;

    gap: 10px;

    min-width: 0;

    padding: 0 14px;

    background-color: var(--surface);

    border: 1px solid var(--border);
    border-radius: var(--radius-sm);

    cursor: text;

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.search-field:focus-within {
    border-color: var(--accent-line);

    box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-field .icon {
    color: var(--accent);
}

.search-field input {
    flex: 1;

    min-width: 0;

    padding: 10px 0;

    font: inherit;
    font-size: 0.875rem;

    background: none;
    color: var(--text);

    border: 0;
    outline: none;
}

.search-field input::placeholder {
    color: var(--text-faint);
}


/* ---------------------------------
   Tabs and Chips
--------------------------------- */

.tabs {
    display: inline-flex;

    flex-wrap: wrap;

    gap: 4px;

    padding: 4px;

    background-color: var(--surface);

    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.tabs a {
    padding: 6px 14px;

    font-size: 0.85rem;

    color: var(--text-muted);

    text-decoration: none;

    border-radius: var(--radius-sm);

    transition:
        color 0.2s ease,
        background-color 0.2s ease;
}

.tabs a:hover {
    color: var(--text);
}

.tabs a.active {
    background-color: var(--accent-soft);
    color: var(--accent);
}

.chips {
    display: flex;

    flex-wrap: wrap;

    gap: 8px;
}

.chip {
    display: inline-block;

    padding: 4px 12px;

    font-size: 0.8rem;

    color: var(--text-muted);

    text-decoration: none;

    border: 1px solid var(--border-strong);
    border-radius: 999px;
}

a.chip:hover {
    color: var(--accent);

    border-color: var(--accent-line);
}


/* ---------------------------------
   Toolbar (tabs + search above a list)
--------------------------------- */

.toolbar {
    display: flex;

    justify-content: space-between;
    align-items: center;

    flex-wrap: wrap;

    gap: 16px;

    margin-bottom: 32px;
}


/* ---------------------------------
   Pagination
--------------------------------- */

.pagination {
    display: flex;

    justify-content: center;
    align-items: center;

    flex-wrap: wrap;

    gap: 16px;

    margin-top: 48px;
}

.pagination span {
    font-size: 0.85rem;

    color: var(--text-muted);
}


/* ---------------------------------
   Link Rows

   A directory-listing style menu used for "browse" sections.
--------------------------------- */

.link-list {
    border-top: 1px solid var(--border);
}

.link-row {
    display: grid;

    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;

    gap: 18px;

    padding: 18px 12px;

    color: inherit;

    text-decoration: none;

    border-bottom: 1px solid var(--border);

    transition: background-color 0.2s ease;
}

.link-row:hover {
    background-color: var(--bg-soft);

    color: inherit;
}

.link-row-icon {
    display: grid;
    place-items: center;

    width: 42px;
    height: 42px;

    font-size: 1.2rem;

    color: var(--accent);

    background-color: var(--surface);

    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.link-row h3 {
    font-size: 1rem;
    font-weight: 600;
}

.link-row p {
    margin-top: 2px;

    font-size: 0.85rem;

    color: var(--text-muted);
}

.link-row-arrow {
    color: var(--text-faint);

    transition:
        color 0.2s ease,
        transform 0.2s var(--ease);
}

.link-row:hover h3,
.link-row:hover .link-row-arrow {
    color: var(--accent);
}

.link-row:hover .link-row-arrow {
    transform: translateX(4px);
}


/* ---------------------------------
   Carousel

   Horizontal scroller shared by the Thoughts, Projects and
   Security "latest" rows. Each app sets its own card width.
--------------------------------- */

.carousel {
    display: flex;

    gap: 20px;

    padding: 6px 2px 20px;

    overflow-x: auto;
    overflow-y: hidden;

    overscroll-behavior-x: contain;

    scroll-snap-type: x proximity;

    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.carousel > * {
    flex: 0 0 auto;

    scroll-snap-align: start;
}


/* ---------------------------------
   Empty State
--------------------------------- */

.empty {
    grid-column: 1 / -1;

    padding: 32px;

    text-align: center;

    color: var(--text-muted);

    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
}


/* ---------------------------------
   Prose

   Long-form writing: reviews, posts, write-ups, about text.
--------------------------------- */

.prose {
    max-width: 72ch;

    font-size: 1rem;
    line-height: 1.85;

    color: var(--text);
}

.prose > * + * {
    margin-top: 1.3em;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
    margin-top: 2.2em;

    line-height: 1.35;
}

.prose h1 { font-size: 1.4rem; }
.prose h2 { font-size: 1.25rem; }
.prose h3 { font-size: 1.1rem; }
.prose h4 { font-size: 1rem; }

.prose h1::before { content: "# "; color: var(--accent); }
.prose h2::before { content: "## "; color: var(--accent); }
.prose h3::before { content: "### "; color: var(--accent); }
.prose h4::before { content: "#### "; color: var(--accent); }

.prose strong {
    color: #fff;
}

.prose ul,
.prose ol {
    padding-left: 1.5em;
}

.prose li + li {
    margin-top: 0.4em;
}

.prose li::marker {
    color: var(--accent);
}

.prose blockquote {
    padding-left: 18px;

    color: var(--text-muted);

    border-left: 2px solid var(--accent);
}

.prose code {
    padding: 0.1em 0.4em;

    font-family: inherit;
    font-size: 0.9em;

    color: var(--accent-hover);

    background-color: var(--surface);

    border: 1px solid var(--border);
    border-radius: 4px;
}

.prose pre {
    padding: 18px 20px;

    overflow-x: auto;

    font-size: 0.875rem;
    line-height: 1.65;

    background-color: var(--bg-soft);

    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.prose pre code {
    padding: 0;

    font-size: inherit;

    color: var(--text);

    background: none;

    border: 0;
}

.prose img {
    display: block;

    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.prose hr {
    border: 0;
    border-top: 1px solid var(--border);
}

.prose table {
    display: block;

    max-width: 100%;

    overflow-x: auto;

    font-size: 0.9rem;

    border-collapse: collapse;
}

.prose th,
.prose td {
    padding: 8px 14px;

    text-align: left;

    border: 1px solid var(--border);
}

.prose th {
    background-color: var(--surface);
}


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

@media (min-width: 760px) {

    /* Title and description sit side by side on wider screens. */
    .link-row-text {
        display: grid;

        grid-template-columns: 220px minmax(0, 1fr);
        align-items: baseline;

        gap: 24px;
    }

    .link-row p {
        margin-top: 0;
    }

}

@media (max-width: 720px) {

    /* The navbar wraps onto two rows, so it no longer sticks. */
    .site-header {
        position: static;
    }

    .navbar {
        flex-wrap: wrap;

        gap: 4px;

        padding: 14px 0 8px;
    }

    .nav-links {
        width: calc(100% + 2 * var(--gutter));

        margin: 0 calc(-1 * var(--gutter));
        padding: 0 calc(var(--gutter) - 12px);

        overflow-x: auto;

        scrollbar-width: none;

        /* Fade the right edge to hint that the row scrolls. */
        -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
        mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
    }

    .nav-links a {
        flex-shrink: 0;

        padding: 6px 10px;
    }

    .page {
        padding-top: 32px;
    }

    .section + .section {
        margin-top: 56px;
    }

    .section-head {
        align-items: flex-start;

        flex-direction: column;

        gap: 10px;
    }

    .search {
        width: 100%;
    }

    .toolbar {
        align-items: stretch;

        flex-direction: column;
    }

    .tabs {
        align-self: flex-start;
    }

    .link-row {
        gap: 14px;

        padding: 16px 4px;
    }

    .site-footer {
        margin-top: 72px;
    }

}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }

}
