/* Base reset and typography */
*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    /* Gruvbox light. Let the browser render form controls and scrollbars in
       the active theme. */
    color-scheme: light dark;
    --color-bg: #fbf1c7;
    --color-text: #3c3836;
    --color-text-muted: #7c6f64;
    --color-link: #076678;
    --color-link-hover: #458588;
    --color-accent: #af3a03;
    --color-accent-hover: #8f3003;
    --color-on-accent: #fbf1c7;
    --color-border: #d5c4a1;
    --color-card-bg: #f2e5bc;
    --color-code-bg: #ebdbb2;
    --color-tag-bg: #ebdbb2;
    --color-tag-text: #076678;
    --color-notice-bg: #f2e5bc;
    --color-notice-border: #b57614;
    --color-notice-text: #504945;
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Fira Code', 'Consolas', 'Monaco', monospace;
    --max-width: 48rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        /* Gruvbox dark. */
        --color-bg: #282828;
        --color-text: #ebdbb2;
        --color-text-muted: #a89984;
        --color-link: #83a598;
        --color-link-hover: #8ec07c;
        --color-accent: #fe8019;
        --color-accent-hover: #e86f10;
        --color-on-accent: #282828;
        --color-border: #3c3836;
        --color-card-bg: #32302f;
        --color-code-bg: #32302f;
        --color-tag-bg: #3c3836;
        --color-tag-text: #83a598;
        --color-notice-bg: #32302f;
        --color-notice-border: #d79921;
        --color-notice-text: #fabd2f;
    }
}

/* "Not reviewed in a while" banner on stale content pages. */
.stale-notice {
    margin: 0 0 1.5rem;
    padding: 0.75rem 1rem;
    border-left: 4px solid var(--color-notice-border);
    border-radius: 4px;
    background-color: var(--color-notice-bg);
    color: var(--color-notice-text);
    font-size: 0.95rem;
}

html {
    font-size: 16px;
    line-height: 1.6;
}

body {
    font-family: var(--font-sans);
    background-color: var(--color-bg);
    color: var(--color-text);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Container */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1rem;
    width: 100%;
}

/* Header */
header {
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 0;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.site-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
}

.site-title:hover {
    color: var(--color-link);
}

/* Navigation */
nav ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 1.5rem;
    flex-wrap: wrap;
}

nav a {
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.9rem;
}

nav a:hover {
    color: var(--color-link);
}

/* Main content */
main {
    flex: 1;
    padding: 2rem 0;
}

/* Article */
article {
    width: 100%;
}

.article-header {
    margin-bottom: 2rem;
}

.article-header h1 {
    margin: 0 0 0.5rem 0;
    font-size: 2rem;
    line-height: 1.2;
}

/* Date and tags */
.date {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.tags {
    margin-top: 0.5rem;
}

.tag {
    display: inline-block;
    background-color: var(--color-tag-bg);
    color: var(--color-tag-text);
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.8rem;
    margin-right: 0.5rem;
    text-decoration: none;
}

a.tag:hover {
    background-color: var(--color-tag-text);
    color: var(--color-bg);
}

/* Content typography */
.content h2 {
    font-size: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0.5rem;
}

.content h3 {
    font-size: 1.25rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.content h4, .content h5, .content h6 {
    font-size: 1rem;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
}

.content p {
    margin: 1rem 0;
}

.content a {
    color: var(--color-link);
    text-decoration: none;
}

.content a:hover {
    text-decoration: underline;
}

/* Lists */
.content ul, .content ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.content li {
    margin: 0.5rem 0;
}

.page-list, .section-list {
    list-style: none;
    padding: 0;
}

.page-list li, .section-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
}

.page-list a, .section-list a {
    color: var(--color-link);
    text-decoration: none;
    font-weight: 500;
}

.page-list a:hover, .section-list a:hover {
    text-decoration: underline;
}

/* Code */
code {
    font-family: var(--font-mono);
    background-color: var(--color-code-bg);
    padding: 0.15rem 0.3rem;
    border-radius: 0.25rem;
    font-size: 0.9em;
}

pre {
    background-color: var(--color-code-bg);
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 1rem 0;
}

pre code {
    background: none;
    padding: 0;
    font-size: 0.85rem;
    line-height: 1.5;
}

/* Blockquote */
blockquote {
    margin: 1rem 0;
    padding: 0.5rem 1rem;
    border-left: 4px solid var(--color-border);
    color: var(--color-text-muted);
    background-color: var(--color-code-bg);
}

blockquote p {
    margin: 0.5rem 0;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

th {
    font-weight: 600;
    background-color: var(--color-code-bg);
}

tr:hover {
    background-color: var(--color-code-bg);
}

/* Horizontal rule */
hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 2rem 0;
}

/* Task lists */
input[type="checkbox"] {
    margin-right: 0.5rem;
}

/* Images */
img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
}

/* Strikethrough */
del {
    color: var(--color-text-muted);
}

/* Footer */
footer {
    border-top: 1px solid var(--color-border);
    padding: 1.5rem 0;
    margin-top: auto;
}

footer .container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
}

.copyright {
    margin: 0;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    text-align: center;
}

/* Social / feed links: a row of icon-only round buttons. */
.social {
    display: flex;
    gap: 0.5rem;
}

.social a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}

.social a:hover {
    color: var(--color-accent);
    border-color: var(--color-accent);
    background-color: var(--color-card-bg);
}

.social svg {
    width: 1.2rem;
    height: 1.2rem;
}

/* Interactive tools (e.g. the Netlify bandwidth checker, UUID generator) */
.tool {
    display: block;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    background-color: var(--color-code-bg);
}

.tool p {
    margin: 0.5rem 0;
}

.tool input[type="text"],
.tool input[type="password"],
.tool textarea {
    width: 100%;
    padding: 0.3rem;
    font-family: var(--font-mono);
}

.tool textarea {
    font-size: 0.85rem;
    resize: vertical;
}

.tool button {
    font: inherit;
    padding: 0.4rem 0.9rem;
    margin-right: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: 0.4rem;
    background-color: var(--color-bg);
    color: var(--color-text);
    cursor: pointer;
}

.tool button:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.tool table {
    margin-top: 0.5rem;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .article-header h1 {
        font-size: 1.5rem;
    }

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

    nav ul {
        gap: 1rem;
    }

    /* Let a wide table (e.g. a cheatsheet) scroll on its own instead of
       forcing the whole page to scroll sideways. */
    .content table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
    }
}

/* Keyboard focus: a clear accent ring on every interactive element, since the
   cards, buttons and icon links restyle away the browser default. */
:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Respect a reduced-motion preference: drop transitions and the hover lifts. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .home .card:hover,
    .home .btn:hover {
        transform: none;
    }
}

/* Diagrams (inline SVG, theme-aware via currentColor) */
.diagram {
    margin: 1.5rem 0;
    text-align: center;
}

.diagram svg {
    max-width: 100%;
    height: auto;
}

/* Self-linking heading anchors */
.heading-anchor {
    color: inherit;
    text-decoration: none;
}

.heading-anchor:hover::after {
    content: "#";
    margin-left: 0.35rem;
    color: var(--color-text-muted);
    font-weight: normal;
}

/* Syntax highlighting. Prism-compatible token classes, Gruvbox palette. */
:root {
    --code-comment: #928374;
    --code-keyword: #9d0006;
    --code-string: #79740e;
    --code-number: #8f3f71;
    --code-builtin: #af3a03;
}

@media (prefers-color-scheme: dark) {
    :root {
        --code-comment: #928374;
        --code-keyword: #fb4934;
        --code-string: #b8bb26;
        --code-number: #d3869b;
        --code-builtin: #fe8019;
    }
}

.token.comment {
    color: var(--code-comment);
    font-style: italic;
}

.token.string {
    color: var(--code-string);
}

.token.keyword {
    color: var(--code-keyword);
}

.token.number {
    color: var(--code-number);
}

.token.builtin {
    color: var(--code-builtin);
}

/* ---------------------------------------------------------------------------
   Home page (body.home): portfolio hero, section cards and recent list.
   Selectors are scoped under `.home` so they reliably win over the generic
   `.content` typography rules the home content is nested inside.
   --------------------------------------------------------------------------- */

.home .hero {
    padding: 2.5rem 0 2rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.home .hero-eyebrow {
    margin: 0 0 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--color-accent);
}

.home .hero-name {
    margin: 0;
    font-size: clamp(2rem, 6vw, 3rem);
    line-height: 1.1;
    letter-spacing: -0.01em;
}

.home .hero-role {
    margin: 0.4rem 0 0;
    font-size: 1.2rem;
    color: var(--color-text-muted);
}

.home .hero-blurb {
    margin: 1rem 0 1.5rem;
    max-width: 46ch;
    font-size: 1.05rem;
}

.home .hero-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

/* Buttons (hero call-to-action). Scoped under `.home` so they outrank the
   generic `.content a` colour the hero links are nested inside. */
.home .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.15s, border-color 0.15s, background-color 0.15s, transform 0.15s;
}

.home .btn svg {
    width: 1.1rem;
    height: 1.1rem;
}

.home .btn:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    transform: translateY(-1px);
}

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

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

/* Home sections */
.home .home-section {
    margin: 2.5rem 0;
}

.home .home-section h2 {
    margin: 0 0 1rem;
    padding: 0;
    border: none;
    font-size: 1.3rem;
}

/* Explore cards. `min(15rem, 100%)` keeps a single column from overflowing
   viewports narrower than 15rem. */
.home .card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 1fr));
    gap: 1rem;
}

.home .card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1.1rem 1.2rem;
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    background-color: var(--color-card-bg);
    color: var(--color-text);
    text-decoration: none;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.home .card:hover {
    border-color: var(--color-accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
}

.home .card-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.home .card-desc {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.home .card-meta {
    margin-top: auto;
    padding-top: 0.35rem;
    color: var(--color-accent);
    font-size: 0.85rem;
    font-weight: 500;
}

/* Project cards. Wider than the Explore cards since each holds a description
   and several links; not clickable as a whole, so no hover lift. */
.home .project-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(18rem, 100%), 1fr));
    gap: 1rem;
}

.home .project {
    padding: 1.2rem 1.3rem;
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    background-color: var(--color-card-bg);
}

.home .project-name {
    margin: 0;
    font-size: 1.15rem;
}

.home .project-desc {
    margin: 0.4rem 0 0.85rem;
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

.home .project-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.1rem;
}

.home .project-links a {
    color: var(--color-link);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
}

.home .project-links a:hover {
    text-decoration: underline;
}

/* Recent list */
.home .post-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.home .post-list li {
    margin: 0;
    padding: 0;
    border: none;
}

.home .post-list a {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
    text-decoration: none;
}

.home .post-list a:hover .post-title {
    color: var(--color-link);
}

.home .post-title {
    font-weight: 500;
}

.home .post-date {
    flex-shrink: 0;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
}
