/* DBOTech Grid — original editorial theme layer */
:root,
:root[data-theme="dark"] {
    --db-bg: #07110f;
    --db-bg-elevated: #0d1917;
    --db-surface: #10211d;
    --db-surface-hover: #142a25;
    --db-text: #e9f8f4;
    --db-text-strong: #ffffff;
    --db-muted: #8fa9a2;
    --db-border: rgb(148 184 174 / 0.18);
    --db-grid-line: rgb(45 212 191 / 0.055);
    --db-accent-soft: rgb(45 212 191 / 0.12);
    --db-code: #06100e;
    --db-shadow: 0 22px 70px rgb(0 0 0 / 0.28);
    --background-color: var(--db-bg) !important;
    --color-lighter-gray: var(--db-border) !important;
    --color-light-gray: #718a84 !important;
    --color-mid-gray: var(--db-muted) !important;
    --color-dark-gray: var(--db-text) !important;
    --color-darker-gray: var(--db-text-strong) !important;
    color-scheme: dark;
}

:root[data-theme="light"] {
    --db-bg: #f4f8f7;
    --db-bg-elevated: #ffffff;
    --db-surface: #ffffff;
    --db-surface-hover: #edf7f4;
    --db-text: #20332f;
    --db-text-strong: #0b1714;
    --db-muted: #61766f;
    --db-border: rgb(27 73 63 / 0.16);
    --db-grid-line: rgb(15 118 110 / 0.055);
    --db-accent-soft: rgb(13 148 136 / 0.11);
    --db-code: #eaf3f0;
    --db-shadow: 0 20px 55px rgb(30 64 56 / 0.12);
    --background-color: var(--db-bg) !important;
    --color-lighter-gray: var(--db-border) !important;
    --color-light-gray: #849891 !important;
    --color-mid-gray: var(--db-muted) !important;
    --color-dark-gray: var(--db-text) !important;
    --color-darker-gray: var(--db-text-strong) !important;
    color-scheme: light;
}

html {
    scroll-behavior: smooth;
    background: var(--db-bg);
}

body.db-theme {
    min-height: 100vh;
    color: var(--db-text);
    background-color: var(--db-bg) !important;
    background-image:
        linear-gradient(var(--db-grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--db-grid-line) 1px, transparent 1px),
        radial-gradient(circle at 82% 4%, var(--db-accent-soft), transparent 28rem);
    background-size: 54px 54px, 54px 54px, auto;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    transition: color 180ms ease, background-color 180ms ease;
}

body.db-theme::before {
    position: fixed;
    z-index: -1;
    inset: 0;
    content: "";
    pointer-events: none;
    background: linear-gradient(to bottom, transparent 0, var(--db-bg) 55rem);
}

::selection {
    color: #03110e;
    background: var(--db-accent);
}

:focus-visible {
    outline: 2px solid var(--db-accent);
    outline-offset: 4px;
}

a {
    color: inherit;
}

.gh-inner {
    max-width: 1240px;
}

/* Navigation */
.gh-navigation {
    position: sticky;
    z-index: 1000;
    top: 0;
    height: 78px;
    color: var(--db-text);
    border-bottom: 1px solid var(--db-border);
    background: color-mix(in srgb, var(--db-bg) 82%, transparent);
    backdrop-filter: blur(18px) saturate(130%);
}

.gh-navigation-inner {
    grid-template-columns: 1fr auto 1fr;
    min-height: 78px;
}

.gh-navigation-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.gh-navigation-logo,
.db-footer-logo {
    display: inline-flex;
    gap: 10px;
    align-items: center;
    color: var(--db-text-strong) !important;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 1.65rem;
    font-weight: 750;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.db-logo-mark,
.db-footer-logo span {
    color: var(--db-accent);
    font-weight: 800;
}

.gh-navigation .nav {
    gap: 30px;
}

.gh-navigation-menu {
    min-width: 240px;
    justify-content: center;
}

.gh-navigation .nav a {
    position: relative;
    color: var(--db-muted) !important;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 1.3rem;
    letter-spacing: 0.02em;
}

.gh-navigation .nav a:hover,
.gh-navigation .nav-current a {
    color: var(--db-text-strong) !important;
}

.gh-navigation .nav-current a::after {
    position: absolute;
    right: 0;
    bottom: -10px;
    left: 0;
    height: 2px;
    content: "";
    background: var(--db-accent);
}

.gh-navigation-actions,
.db-mobile-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.db-mobile-actions {
    display: none;
}

.gh-icon-button,
.gh-search,
.db-theme-toggle {
    color: var(--db-text) !important;
}

.db-theme-toggle {
    display: grid;
    width: 40px;
    height: 40px;
    padding: 0;
    place-items: center;
    border: 1px solid var(--db-border);
    border-radius: 10px;
    background: var(--db-surface);
    cursor: pointer;
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.db-theme-toggle:hover {
    transform: translateY(-2px);
    border-color: var(--db-accent);
    background: var(--db-surface-hover);
}

.db-theme-toggle svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

:root[data-theme="dark"] .db-icon-moon,
:root[data-theme="light"] .db-icon-sun {
    display: none;
}

/* Hero */
.db-hero {
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid var(--db-border);
}

.db-hero::after {
    position: absolute;
    width: 380px;
    height: 380px;
    right: max(-150px, calc((100vw - 1240px) / 2 - 160px));
    bottom: -250px;
    content: "";
    border: 1px solid color-mix(in srgb, var(--db-accent) 30%, transparent);
    border-radius: 50%;
    box-shadow: 0 0 100px var(--db-accent-soft);
}

.db-hero-inner {
    padding-top: clamp(7rem, 10vw, 13rem);
    padding-bottom: clamp(7rem, 10vw, 12rem);
}

.db-hero-kicker,
.db-section-kicker {
    margin: 0 0 2rem;
    color: var(--db-accent);
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 1.25rem;
    font-weight: 650;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.db-hero-kicker span:first-child {
    margin-right: 0.65rem;
}

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

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

.db-hero h1 {
    max-width: 950px;
    margin: 0;
    color: var(--db-text-strong);
    font-size: clamp(5rem, 9vw, 10.5rem);
    font-weight: 760;
    letter-spacing: -0.065em;
    line-height: 0.92;
}

.db-hero h1 span {
    color: var(--db-muted);
}

.db-hero-copy {
    max-width: 690px;
    margin: 3rem 0 0;
    color: var(--db-muted);
    font-size: clamp(1.75rem, 2.1vw, 2.3rem);
    line-height: 1.55;
}

.db-hero-links {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-top: 4rem;
}

.db-primary-link,
.db-search-link {
    display: inline-flex;
    min-height: 48px;
    padding: 0 20px;
    gap: 20px;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 1.3rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.db-primary-link {
    color: #04110e;
    background: var(--db-accent);
}

.db-primary-link:hover {
    filter: brightness(1.08);
}

.db-search-link {
    color: var(--db-text);
    border: 1px solid var(--db-border);
    background: var(--db-surface);
}

.db-search-link span {
    color: var(--db-accent);
}

/* Feed */
.gh-container {
    margin: 0;
    padding-top: clamp(7rem, 9vw, 11rem);
    padding-bottom: clamp(8rem, 10vw, 13rem);
}

.gh-container-inner {
    display: block !important;
}

.db-section-heading {
    display: flex;
    margin-bottom: 4rem;
    align-items: end;
    justify-content: space-between;
    border-bottom: 1px solid var(--db-border);
}

.db-section-heading .db-section-kicker {
    margin: 0 0 1.6rem;
}

.gh-container-title {
    margin: 0 0 1.4rem;
    color: var(--db-text-strong);
    font-size: clamp(3.4rem, 5vw, 5.6rem);
    letter-spacing: -0.045em;
}

.gh-feed {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
}

.gh-card {
    position: relative;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--db-border);
    border-radius: 16px;
    background: var(--db-surface);
    box-shadow: none;
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.gh-card::before {
    position: absolute;
    z-index: 2;
    top: 0;
    right: 0;
    left: 0;
    height: 2px;
    content: "";
    opacity: 0;
    background: linear-gradient(90deg, var(--db-accent), transparent 70%);
    transition: opacity 180ms ease;
}

.gh-card:hover {
    transform: translateY(-5px);
    border-color: color-mix(in srgb, var(--db-accent) 55%, var(--db-border));
    background: var(--db-surface-hover);
    box-shadow: var(--db-shadow);
}

.gh-card:hover::before {
    opacity: 1;
}

.gh-card-link {
    height: 100%;
    color: var(--db-text);
    text-decoration: none;
}

.gh-card-image {
    aspect-ratio: 16 / 9;
    margin: 0;
    overflow: hidden;
    border-bottom: 1px solid var(--db-border);
}

.gh-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 350ms ease;
}

.gh-card:hover .gh-card-image img {
    transform: scale(1.025);
}

.gh-card-wrapper {
    display: flex;
    min-height: 310px;
    padding: 28px;
    flex-direction: column;
}

.gh-card-tag {
    width: fit-content;
    margin: 0 0 18px;
    padding: 6px 9px;
    color: var(--db-accent);
    border: 1px solid color-mix(in srgb, var(--db-accent) 30%, transparent);
    border-radius: 6px;
    background: var(--db-accent-soft);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1;
    text-transform: uppercase;
}

.gh-card-title {
    margin: 0;
    color: var(--db-text-strong);
    font-size: clamp(2.25rem, 2.4vw, 3rem);
    font-weight: 720;
    letter-spacing: -0.035em;
    line-height: 1.08;
}

.gh-card-excerpt {
    display: -webkit-box;
    margin: 1.7rem 0 2.6rem;
    overflow: hidden;
    color: var(--db-muted);
    font-size: 1.5rem;
    line-height: 1.55;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.gh-card-meta {
    display: flex;
    margin-top: auto;
    padding-top: 18px;
    gap: 10px;
    color: var(--db-muted);
    border-top: 1px solid var(--db-border);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.db-empty-state {
    grid-column: 1 / -1;
    padding: clamp(4rem, 8vw, 9rem);
    text-align: center;
    border: 1px dashed color-mix(in srgb, var(--db-accent) 40%, var(--db-border));
    border-radius: 16px;
    background: var(--db-surface);
}

.db-empty-state h3 {
    margin: 0;
    color: var(--db-text-strong);
    font-size: 3rem;
}

.db-empty-state p:not(.db-section-kicker) {
    color: var(--db-muted);
}

.db-empty-state a,
.db-pagination a {
    color: var(--db-accent);
}

.db-pagination {
    display: flex;
    margin-top: 5rem;
    align-items: center;
    justify-content: space-between;
    color: var(--db-muted);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 1.2rem;
}

/* Post and page */
.gh-article,
.gh-page {
    color: var(--db-text);
}

.gh-article-header,
.gh-page-header {
    padding-top: clamp(6rem, 9vw, 11rem);
}

.gh-article-title,
.gh-page-title {
    color: var(--db-text-strong);
    letter-spacing: -0.055em;
}

.gh-article-excerpt,
.gh-article-meta,
.gh-page-excerpt {
    color: var(--db-muted);
}

.gh-article-tag {
    color: var(--db-accent) !important;
}

.gh-article-author-name,
.gh-article-author-name a {
    color: var(--db-text-strong) !important;
}

.gh-article-meta-content {
    color: var(--db-muted) !important;
}

.gh-button-share {
    color: var(--db-text) !important;
    border-color: var(--db-border) !important;
    background: var(--db-surface) !important;
}

.gh-button-share:hover {
    color: var(--db-text-strong) !important;
    border-color: var(--db-accent) !important;
    background: var(--db-surface-hover) !important;
}

.gh-content {
    color: var(--db-text);
}

.gh-content :is(h1, h2, h3, h4, h5, h6) {
    color: var(--db-text-strong);
    letter-spacing: -0.035em;
}

.gh-content a {
    color: var(--db-accent);
    text-decoration-color: color-mix(in srgb, var(--db-accent) 45%, transparent);
}

.gh-content blockquote {
    color: var(--db-text);
    border-left-color: var(--db-accent);
    background: var(--db-accent-soft);
}

.gh-content pre,
.gh-content code,
.kg-code-card pre {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.gh-content pre,
.kg-code-card {
    border: 1px solid var(--db-border);
    border-radius: 12px;
    background: var(--db-code);
}

.gh-content hr {
    border-color: var(--db-border);
}

.gh-content img,
.kg-card img {
    border-radius: 12px;
}

.gh-read-next,
.gh-navigation,
.gh-footer {
    --background-color: var(--db-bg) !important;
}

/* Footer */
.gh-footer {
    color: var(--db-text);
    border-top: 1px solid var(--db-border);
    background: var(--db-bg-elevated) !important;
}

.gh-footer-inner {
    padding-top: 6rem;
    padding-bottom: 3rem;
}

.db-footer-main {
    display: flex;
    padding-bottom: 5rem;
    align-items: end;
    justify-content: space-between;
}

.db-footer-main p {
    max-width: 470px;
    margin: 0;
    color: var(--db-muted);
    font-size: 1.45rem;
    line-height: 1.5;
    text-align: right;
}

.gh-footer-bar {
    display: flex;
    padding-top: 2rem;
    align-items: center;
    justify-content: space-between;
    color: var(--db-muted);
    border-top: 1px solid var(--db-border);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 1.1rem;
    text-transform: uppercase;
}

.gh-social-links {
    color: var(--db-muted);
}

/* Ghost overlays */
.gh-search-input,
.gh-search-results,
.gh-portal-popup-wrapper {
    color: var(--db-text);
    background: var(--db-surface) !important;
}

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

    .gh-navigation-inner {
        grid-template-columns: 1fr auto;
    }
}

@media (max-width: 767px) {
    .gh-navigation {
        height: 68px;
    }

    .gh-navigation-inner {
        min-height: 68px;
    }

    .gh-navigation-brand {
        width: 100%;
    }

    .db-mobile-actions {
        display: flex;
    }

    .gh-navigation-actions {
        display: none;
    }

    .gh-navigation-menu {
        color: var(--db-text);
        background: var(--db-bg) !important;
    }

    .gh-navigation-menu .nav {
        align-items: flex-start;
    }

    .gh-navigation-menu .nav a {
        font-size: 1.6rem;
    }

    .gh-navigation-brand > .gh-search,
    .db-mobile-actions > .gh-search {
        display: flex !important;
    }

    .db-hero-inner {
        padding-top: 7rem;
        padding-bottom: 7rem;
    }

    .db-hero h1 {
        font-size: clamp(4.6rem, 15vw, 7rem);
    }

    .db-hero-links,
    .db-footer-main {
        align-items: stretch;
        flex-direction: column;
    }

    .db-primary-link,
    .db-search-link {
        width: 100%;
    }

    .db-section-heading {
        display: block;
    }

    .gh-feed,
    .post-template .gh-container.is-grid .gh-feed {
        grid-template-columns: 1fr;
    }

    .gh-card-wrapper {
        min-height: 275px;
        padding: 24px;
    }

    .db-footer-main p {
        margin-top: 2rem;
        text-align: left;
    }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
