/* Design tokens — warm-neutral editorial palette, soft-blue accent */
:root {
    color-scheme: light dark;
    --accent: #A2BFE6;
    --accent-strong: #6f9bd1;
    --header-height: 64px;
    --container-max: 1080px;
    --serif: "Iowan Old Style", "Charter", "Source Serif Pro", "Source Serif 4", Georgia, "Times New Roman", serif;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
    :root, [data-theme="light"] {
        --bgColor-default: #ffffff;
        --bgColor-muted: #f4f4f5;
        --bgColor-elevated: #ffffff;
        --bgColor-neutral-muted: rgba(20, 24, 30, 0.06);
        --fgColor-default: #1f2328;
        --fgColor-muted: #636c76;
        --fgColor-subtle: #8a8f98;
        --fgColor-accent: #406ea0;
        --borderColor-default: #e2e4e8;
        --borderColor-muted: #ececef;
        --shadowColor: rgba(20, 24, 30, 0.06);
    }
}

@media (prefers-color-scheme: dark) {
    :root, [data-theme="dark"] {
        --bgColor-default: #15120e;
        --bgColor-muted: #1d1a14;
        --bgColor-elevated: #1f1c16;
        --bgColor-neutral-muted: rgba(236, 230, 217, 0.08);
        --fgColor-default: #ece6d9;
        --fgColor-muted: #918a7c;
        --fgColor-subtle: #6c6557;
        --fgColor-accent: #e8a36b;
        --borderColor-default: #2c271f;
        --borderColor-muted: #221e18;
        --shadowColor: rgba(0, 0, 0, 0.5);
        /* Warm amber accent — pairs with the warm-neutral dark palette */
        --accent: #d98e5a;
        --accent-strong: #e8a36b;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background-color: var(--bgColor-default);
    color: var(--fgColor-default);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Page shell — replaces Bootstrap container.
   .container is a shim for sub-pages still using Bootstrap markup. */
.page,
.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 24px;
}

.page { padding-bottom: 64px; }

/* Reserve space for the async-loaded header so first paint matches final */
#header_loc {
    min-height: var(--header-height);
}

/* Hero banner — slim, locked aspect ratio prevents reflow */
.hero-banner {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 5.75;
    overflow: hidden;
    border-radius: 14px;
    margin: 24px 0 8px;
    background: var(--bgColor-muted);
    border: 1px solid var(--borderColor-muted);
}

.hero-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
    transition: transform 0.6s ease;
}

.hero-banner:hover img {
    transform: scale(1.02);
}

.hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.35) 100%);
    pointer-events: none;
}

.hero-caption {
    position: absolute;
    left: 20px;
    bottom: 16px;
    color: #fff;
    font-family: var(--serif);
    font-style: italic;
    font-size: 0.95rem;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

/* Markdown body — editorial typography over GitHub-md base.
   gitlab_md.css redefines its color tokens on .markdown-body, so we must
   restate ours here (rather than inherit from :root) for the article. */
@media (prefers-color-scheme: light) {
    .markdown-body, [data-theme="light"] .markdown-body {
        --bgColor-default: #ffffff;
        --bgColor-muted: #f4f4f5;
        --bgColor-neutral-muted: rgba(20, 24, 30, 0.06);
        --fgColor-default: #1f2328;
        --fgColor-muted: #636c76;
        --fgColor-accent: #406ea0;
        --borderColor-default: #e2e4e8;
        --borderColor-muted: #ececef;
    }
}

@media (prefers-color-scheme: dark) {
    .markdown-body, [data-theme="dark"] .markdown-body {
        --bgColor-default: #15120e;
        --bgColor-muted: #1d1a14;
        --bgColor-neutral-muted: rgba(236, 230, 217, 0.08);
        --fgColor-default: #ece6d9;
        --fgColor-muted: #918a7c;
        --fgColor-accent: #e8a36b;
        --borderColor-default: #2c271f;
        --borderColor-muted: #221e18;
    }
}

.markdown-body {
    background-color: var(--bgColor-default);
    color: var(--fgColor-default);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.65;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    font-family: var(--serif);
    font-weight: 500;
    letter-spacing: -0.015em;
    color: var(--fgColor-default);
    border-bottom: none;
}

.markdown-body h1 {
    font-size: clamp(2rem, 4vw, 2.6rem);
    margin: 32px 0 8px;
    font-weight: 500;
}

.markdown-body h1::after {
    content: "";
    display: block;
    width: 56px;
    height: 2px;
    margin-top: 12px;
    background: var(--accent);
    border-radius: 2px;
}

.markdown-body h2 {
    font-size: 1.55rem;
    margin: 28px 0 12px;
}

.markdown-body h3 {
    font-size: 1.25rem;
    margin: 20px 0 8px;
}

.markdown-body p {
    margin: 0.6em 0;
}

.markdown-body a {
    color: var(--fgColor-accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.markdown-body a:hover {
    border-bottom-color: currentColor;
}

.markdown-body code {
    font-family: var(--mono);
    background: var(--bgColor-muted);
    border: 1px solid var(--borderColor-muted);
    border-radius: 4px;
    padding: 0.1em 0.35em;
    font-size: 0.9em;
}

.markdown-body pre {
    background: var(--bgColor-muted);
    border: 1px solid var(--borderColor-muted);
    border-radius: 8px;
}

/* Feature grid — responsive 2-col, single col under 720px */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin: 16px 0 32px;
}

@media (max-width: 720px) {
    .feature-grid {
        grid-template-columns: 1fr;
    }
}

.markdown-body .feature-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--borderColor-default);
    border-radius: 14px;
    padding: 22px 24px 20px;
    color: inherit;
    text-decoration: none;
    background-color: var(--bgColor-elevated);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    margin: 0;
    min-height: 168px;
    position: relative;
    overflow: hidden;
}

.markdown-body .feature-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--accent);
    transform: scaleY(0);
    transform-origin: top;
    transition: transform 0.25s ease;
}

.markdown-body .feature-card:hover,
.markdown-body .feature-card:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px var(--shadowColor);
    border-color: var(--accent);
    text-decoration: none;
    outline: none;
}

.markdown-body .feature-card:hover::before,
.markdown-body .feature-card:focus-visible::before {
    transform: scaleY(1);
}

.markdown-body .feature-card h2 {
    margin: 0 0 10px;
    font-size: 1.35rem;
    color: var(--fgColor-default);
}

.markdown-body .feature-card:hover h2,
.markdown-body .feature-card:focus-visible h2 {
    color: var(--fgColor-accent);
}

.markdown-body .feature-card ul,
.markdown-body .feature-card p {
    margin: 0;
    color: var(--fgColor-muted);
    font-size: 0.96rem;
    line-height: 1.55;
}

.markdown-body .feature-card ul {
    padding-left: 18px;
}

.markdown-body .feature-card li + li {
    margin-top: 4px;
}

/* Skeletons — reserved space until async content swaps in */
@keyframes skeleton-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--bgColor-muted) 0%,
        var(--bgColor-neutral-muted) 50%,
        var(--bgColor-muted) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.6s infinite ease-in-out;
}

.skeleton-h1 {
    height: 2.6rem;
    width: 280px;
    border-radius: 6px;
    margin: 32px 0 24px;
}

.skeleton-card {
    min-height: 168px;
    border-radius: 14px;
    border: 1px solid var(--borderColor-muted);
}

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

/* Image viewer — refined visuals, same behavior */
#image-viewer {
    display: none;
    position: fixed;
    z-index: 999;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.92);
    justify-content: center;
    align-items: center;
    overflow: hidden;
    backdrop-filter: blur(6px);
}

#full-image {
    max-width: 92%;
    max-height: 92%;
    transition: transform 0.3s ease;
    transform-origin: center center;
    cursor: zoom-in;
    border-radius: 4px;
}

#full-image-caption {
    position: absolute;
    bottom: 24px;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    padding: 8px 14px;
    border-radius: 8px;
    font-family: var(--sans);
    font-size: 0.95rem;
    margin: 0;
}

#close-btn {
    position: absolute;
    top: 20px;
    right: 24px;
    color: #fff;
    font-size: 28px;
    line-height: 1;
    font-weight: 300;
    cursor: pointer;
    user-select: none;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 14px;
    border-radius: 100px;
    transition: background 0.15s;
}

#close-btn:hover {
    background: rgba(0, 0, 0, 0.75);
}

.lazyload {
    object-fit: contain;
    transition: box-shadow 0.2s, opacity 0.4s ease;
}
