/* ============================================================
   HACKMD THEME - Full Dark Theme for Ghost
   Tech-focused minimal design
   ============================================================ */

/* 1. Variables
/* ---------------------------------------------------------- */

:root {
    /* Dark Palette */
    --color-bg-primary: #121212;
    --color-bg-nav: #1a1a1a;
    --color-bg-elevated: #1e1e1e;
    --color-bg-hover: #252525;
    --color-bg-card: #181818;
    
    /* Text colors */
    --color-text-primary: #e8e8e8;
    --color-text-secondary: #a0a0a0;
    --color-text-muted: #666666;
    
    /* Border colors */
    --color-border: #333333;
    --color-border-light: #2a2a2a;
    
    /* Link color */
    --color-link: #6eb5ff;
    --color-link-hover: #99ccff;
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
    /* Ghost font settings (used by design panel) */
    --gh-font-heading: var(--font-sans);
    --gh-font-body: var(--font-sans);
    
    /* Spacing */
    --container-width: 1200px;
    --content-width: 720px;
    --container-gap: clamp(16px, 4vw, 40px);
}

/* 2. Resets
/* ---------------------------------------------------------- */

*, *::before, *::after {
    box-sizing: border-box;
}

* {
    margin: 0;
}

html {
    font-size: 62.5%;
}

body {
    font-family: var(--gh-font-body, var(--font-sans));
    font-size: 1.6rem;
    line-height: 1.7;
    color: var(--color-text-primary);
    background-color: var(--color-bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img, picture, video, canvas, svg {
    display: block;
    max-width: 100%;
    height: auto;
}

input, button, textarea, select {
    font: inherit;
}

p, h1, h2, h3, h4, h5, h6 {
    overflow-wrap: break-word;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--gh-font-heading, var(--font-sans));
    font-weight: 700;
    line-height: 1.3;
    color: var(--color-text-primary);
}

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

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

::selection {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* 3. Layout
/* ---------------------------------------------------------- */

.gh-viewport {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.gh-outer {
    padding: 0 var(--container-gap);
}

.gh-inner {
    margin: 0 auto;
    max-width: var(--container-width);
    width: 100%;
}

.gh-main {
    flex-grow: 1;
}

.gh-canvas {
    --main: min(var(--content-width), 100% - var(--container-gap) * 2);
    --wide: minmax(0, calc((var(--container-width) - var(--content-width)) / 2));
    --full: minmax(var(--container-gap), 1fr);

    display: grid;
    grid-template-columns:
        [full-start] var(--full)
        [wide-start] var(--wide)
        [main-start] var(--main) [main-end]
        var(--wide) [wide-end]
        var(--full) [full-end];
}

.gh-canvas > * {
    grid-column: main;
}

.kg-width-wide {
    grid-column: wide;
}

.kg-width-full {
    grid-column: full;
}

/* 4. Navigation - Gray bar with bracket menu
/* ---------------------------------------------------------- */

.gh-navigation {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--color-bg-nav);
    border-bottom: 1px solid var(--color-border-light);
}

.gh-navigation-inner {
    display: flex;
    align-items: center;
    height: 48px;
    max-width: none;
    padding: 0 24px;
    gap: 32px;
    justify-content: center;
}

.gh-navigation-brand {
    position: absolute;
    left: 24px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.gh-navigation-logo {
    display: flex;
    align-items: center;
    color: var(--color-text-primary);
}

.gh-navigation-logo:hover {
    color: var(--color-text-primary);
    opacity: 0.8;
}

.gh-navigation-logo img {
    max-height: 24px;
    width: auto;
}

.gh-navigation-logo span {
    font-family: var(--font-sans);
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.gh-navigation-menu {
    display: flex;
    align-items: center;
}

.gh-navigation .nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Bracket-style menu: [ ITEM ] */
.gh-navigation .nav li a {
    display: block;
    padding: 8px 12px;
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    transition: color 0.15s ease;
}

.gh-navigation .nav li a::before {
    content: '[ ';
    opacity: 0.5;
}

.gh-navigation .nav li a::after {
    content: ' ]';
    opacity: 0.5;
}

.gh-navigation .nav li a:hover {
    color: var(--color-text-primary);
}

.gh-navigation-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    position: absolute;
    right: 24px;
}

.gh-navigation-members {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Buttons */
.gh-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--color-bg-primary);
    background: var(--color-text-primary);
    border: none;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.gh-button:hover {
    opacity: 0.9;
    color: var(--color-bg-primary);
}

/* Search toggle */
.gh-search {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: var(--color-text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color 0.15s ease;
}

.gh-search:hover {
    color: var(--color-text-primary);
}

.gh-search svg {
    width: 16px;
    height: 16px;
}

/* Mobile menu */
.gh-burger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    color: var(--color-text-primary);
    background: transparent;
    border: none;
    cursor: pointer;
}

.gh-burger svg {
    width: 20px;
    height: 20px;
}

.gh-burger svg:last-child {
    display: none;
}

@media (max-width: 768px) {
    .gh-burger {
        display: flex;
    }

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

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

    .is-open .gh-burger svg:first-child {
        display: none;
    }

    .is-open .gh-burger svg:last-child {
        display: block;
    }

    .is-open .gh-navigation-menu {
        display: flex;
        position: fixed;
        inset: 48px 0 0 0;
        flex-direction: column;
        padding: 24px;
        background: var(--color-bg-nav);
        border-top: 1px solid var(--color-border);
    }

    .is-open .gh-navigation .nav {
        flex-direction: column;
        width: 100%;
        gap: 0;
    }

    .is-open .gh-navigation .nav li a {
        padding: 12px 0;
        font-size: 1.4rem;
    }
}

/* 5. Home Header - Minimal
/* ---------------------------------------------------------- */

.gh-header {
    padding: 24px 0 16px;
}

.gh-header-inner {
    max-width: var(--container-width);
    margin: 0 auto;
}

.gh-header-tagline {
    font-family: var(--font-sans);
    font-size: 1.4rem;
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* 6. Post Feed / Cards
/* ---------------------------------------------------------- */

.gh-container {
    padding: 0 0 80px;
}

.gh-container-title {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    padding: 16px 0;
    margin-bottom: 0;
    border-bottom: 1px solid var(--color-border);
}

.gh-feed {
    display: flex;
    flex-direction: column;
}

/* Post Card - Image on left */
.gh-card {
    position: relative;
    padding: 24px 0;
    border-bottom: 1px solid var(--color-border-light);
}

.gh-card:hover {
    background: var(--color-bg-hover);
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
}

.gh-card-link {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 20px;
    align-items: center;
    color: inherit;
}

.gh-card-link:hover {
    color: inherit;
}

/* Image on the left */
.gh-card-image {
    position: relative;
    width: 140px;
    height: 90px;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--color-bg-elevated);
}

.gh-card-image img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.85;
    transition: opacity 0.3s ease;
}

.gh-card:hover .gh-card-image img {
    opacity: 1;
}

/* Content on the right */
.gh-card-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.gh-card-tag {
    display: inline-block;
    width: fit-content;
    font-family: var(--font-mono);
    font-size: 1.05rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

.gh-card-title {
    font-family: var(--font-sans);
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.35;
    color: var(--color-text-primary);
}

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

.gh-card-excerpt {
    font-size: 1.45rem;
    line-height: 1.5;
    color: var(--color-text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gh-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    font-size: 1.25rem;
    color: var(--color-text-muted);
}

.gh-card-date {
    font-family: var(--font-mono);
    font-size: 1.2rem;
}

@media (max-width: 640px) {
    .gh-card-link {
        grid-template-columns: 1fr;
    }

    .gh-card-image {
        width: 100%;
        height: 160px;
        margin-bottom: 8px;
    }
}

/* 7. Article / Post - Clean minimal style
/* ---------------------------------------------------------- */

.gh-article {
    --content-width: 720px;
    padding: 0 0 80px;
}

.gh-article-hero {
    grid-column: main;
    margin: 0;
}

.gh-article-hero img {
    display: block;
    width: 100%;
    height: auto;
}

.gh-article-header {
    margin: 20px 0 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--color-border);
}

.gh-article-title {
    font-family: var(--font-sans);
    font-size: clamp(2.6rem, 4vw, 3.4rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--color-text-primary);
    margin-bottom: 12px;
}

.gh-article-date {
    display: block;
    font-family: var(--font-mono);
    font-size: 1.4rem;
    color: var(--color-text-muted);
}

/* Hide unused elements */
.gh-article-tag,
.gh-article-excerpt,
.gh-article-meta,
.gh-article-author-image {
    display: none;
}

/* 8. Content Styles - White text on dark
/* ---------------------------------------------------------- */

.gh-content {
    font-size: 1.7rem;
    line-height: 1.75;
    color: var(--color-text-primary);
}

.gh-content > * + * {
    margin-top: 24px;
}

/* Reduce gap after Ghost embed blocks (e.g. Twitter card) */
.gh-content .kg-embed-card + * {
    margin-top: 8px !important;
}

.gh-content > [id]:not(:first-child) {
    margin-top: 48px;
}

.gh-content > [id] + p {
    margin-top: 16px;
}

/* Headings */
.gh-content h2 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-top: 32px;
    padding-top: 8px;
    border-top: none;
}

.gh-content h3 {
    font-size: 1.9rem;
    font-weight: 700;
}

.gh-content h4 {
    font-size: 1.7rem;
    font-weight: 700;
}

/* Reduce blank space when a heading comes immediately after a divider */
.gh-content hr + h2,
.gh-content hr + h3,
.gh-content hr + h4 {
    margin-top: 12px;
    padding-top: 0;
    border-top: none;
}

/* Links */
.gh-content a {
    color: var(--color-link);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.gh-content a:hover {
    color: var(--color-link-hover);
}

/* Lists */
.gh-content ul,
.gh-content ol {
    padding-left: 24px;
}

.gh-content li + li {
    margin-top: 8px;
}

.gh-content li::marker {
    color: var(--color-text-muted);
}

/* Blockquotes – wide, high-emphasis quote style */
.gh-content blockquote {
    margin: 32px 0;
    padding: 16px 0 16px 32px;
    font-style: normal;
    font-size: 1.7rem;  /* match article body size */
    line-height: 1.75;  /* match article line-height */
    color: var(--color-text-primary);
    border-left: 4px solid var(--color-border);
}

.gh-content blockquote p {
    margin: 0;
}

.gh-content blockquote p + p {
    margin-top: 12px;
}

/* Horizontal rule */
.gh-content hr {
    margin: 40px 0;
    border: none;
    border-top: 1px solid var(--color-border);
}

/* Reduce blank space when a heading follows a divider */
.gh-content hr + h2,
.gh-content hr + h3,
.gh-content hr + h4 {
    margin-top: 16px;
}

/* Code */
.gh-content code {
    padding: 2px 6px;
    font-family: var(--font-mono);
    font-size: 0.9em;
    color: var(--color-link);
    background: var(--color-bg-elevated);
    border-radius: 3px;
}

.gh-content pre {
    padding: 20px 24px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 1.4rem;
    line-height: 1.5;
    color: var(--color-text-primary);
    background: var(--color-bg-nav);
    border: 1px solid var(--color-border);
}

.gh-content pre code {
    padding: 0;
    color: inherit;
    background: transparent;
    border-radius: 0;
}

/* Tables */
.gh-content table {
    width: 100%;
    margin: 32px 0;
    font-size: 1.4rem;
    border-collapse: collapse;
}

.gh-content th,
.gh-content td {
    padding: 12px 16px;
    border: 1px solid var(--color-border);
}

.gh-content th {
    font-family: var(--font-sans);
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    background: var(--color-bg-elevated);
    text-align: left;
}

.gh-content td {
    font-family: var(--font-mono);
    font-size: 1.35rem;
}

/* Images */
.gh-content img {
    margin-left: auto;
    margin-right: auto;
}

.gh-content figcaption {
    margin-top: 12px;
    font-size: 1.35rem;
    font-style: italic;
    color: var(--color-text-muted);
    text-align: center;
}

/* 9. Ghost Editor Cards
/* ---------------------------------------------------------- */

/* Bookmark card */
.kg-bookmark-card {
    margin: 32px 0;
}

.kg-bookmark-container {
    display: flex;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
}

.kg-bookmark-container:hover {
    border-color: var(--color-text-muted);
}

.kg-bookmark-content {
    flex-grow: 1;
    padding: 16px 20px;
}

.kg-bookmark-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

.kg-bookmark-description {
    margin-top: 8px;
    font-size: 1.35rem;
    color: var(--color-text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.kg-bookmark-metadata {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 1.2rem;
    color: var(--color-text-muted);
}

.kg-bookmark-icon {
    width: 16px;
    height: 16px;
}

.kg-bookmark-thumbnail {
    width: 180px;
    flex-shrink: 0;
}

.kg-bookmark-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Callout card */
.kg-callout-card {
    padding: 20px 24px;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
}

.kg-callout-text {
    color: var(--color-text-secondary);
}

/* Button card */
.kg-btn {
    display: inline-flex;
    padding: 12px 24px;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--color-bg-primary);
    background: var(--color-text-primary);
}

.kg-btn:hover {
    opacity: 0.9;
    color: var(--color-bg-primary);
}

/* 10. Comments
/* ---------------------------------------------------------- */

.gh-comments {
    margin-top: 48px;
    padding-top: 48px;
    border-top: 1px solid var(--color-border);
}

/* 11. Related Posts
/* ---------------------------------------------------------- */

.gh-container.gh-read-more {
    margin-top: 64px;
    padding: 48px 0;
    background: var(--color-bg-nav);
    border-top: 1px solid var(--color-border);
}

/* 12. Footer
/* ---------------------------------------------------------- */

.gh-footer {
    margin-top: auto;
    padding: 32px 0;
    background: var(--color-bg-nav);
    border-top: 1px solid var(--color-border);
}

.gh-footer a {
    color: var(--color-text-secondary);
}

.gh-footer a:hover {
    color: var(--color-text-primary);
}

.gh-footer-inner {
    max-width: var(--container-width);
    margin: 0 auto;
}

.gh-footer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.gh-footer-logo {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

.gh-footer-logo img {
    max-height: 24px;
}

.gh-footer-menu .nav {
    display: flex;
    align-items: center;
    gap: 24px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.gh-footer-menu .nav a {
    font-size: 1.3rem;
}

.gh-footer-copyright {
    font-size: 1.2rem;
    color: var(--color-text-muted);
}

/* Footer signup */
.gh-footer-signup {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 48px 0 32px;
    margin-bottom: 32px;
    border-bottom: 1px solid var(--color-border);
}

.gh-footer-signup-header {
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--color-text-primary);
}

.gh-footer-signup-subhead {
    margin-top: 8px;
    max-width: 400px;
    font-size: 1.5rem;
    color: var(--color-text-secondary);
}

/* Subscribe form */
.gh-form {
    display: flex;
    gap: 0;
    margin-top: 24px;
    width: 100%;
    max-width: 400px;
}

.gh-form-input {
    flex-grow: 1;
    padding: 12px 16px;
    font-size: 1.4rem;
    color: var(--color-text-primary);
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    outline: none;
}

.gh-form-input::placeholder {
    color: var(--color-text-muted);
}

.gh-form-input:focus {
    border-color: var(--color-text-muted);
}

.gh-form .gh-button {
    flex-shrink: 0;
    padding: 12px 20px;
}

/* 13. Archive / Tag / Author pages
/* ---------------------------------------------------------- */

.gh-archive {
    padding: 48px 0 24px;
    border-bottom: 1px solid var(--color-border);
}

.gh-archive-inner {
    max-width: var(--container-width);
    margin: 0 auto;
}

.gh-archive-title {
    font-size: 2.8rem;
    font-weight: 700;
}

.gh-archive-description {
    margin-top: 12px;
    font-size: 1.6rem;
    color: var(--color-text-secondary);
    max-width: 600px;
}

/* 14. Pagination
/* ---------------------------------------------------------- */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--color-border);
}

.pagination a {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    color: var(--color-text-secondary);
}

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

.pagination .page-number {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    color: var(--color-text-muted);
}

/* 15. Error Pages
/* ---------------------------------------------------------- */

.gh-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 80px 24px;
    text-align: center;
}

.gh-error-code {
    font-family: var(--font-mono);
    font-size: 12rem;
    font-weight: 700;
    line-height: 1;
    color: var(--color-bg-elevated);
}

.gh-error-message {
    margin-top: 16px;
    font-size: 2.4rem;
    font-weight: 700;
}

.gh-error-description {
    margin-top: 8px;
    font-size: 1.6rem;
    color: var(--color-text-secondary);
}

.gh-error-link {
    margin-top: 32px;
}

/* 16. Lightbox
/* ---------------------------------------------------------- */

.pswp {
    position: fixed;
    z-index: 9999;
    inset: 0;
    display: none;
    background: rgba(0, 0, 0, 0.95);
}

.pswp--open {
    display: block;
}

.pswp__bg {
    position: absolute;
    inset: 0;
}

.pswp__scroll-wrap {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.pswp__container {
    position: absolute;
    inset: 0;
}

.pswp__item {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.pswp__img {
    position: absolute;
    width: auto;
    height: auto;
}

/* 17. Twitter/X Embeds - Dark theme, article width
/* ---------------------------------------------------------- */

/* Container */
.gh-content .twitter-tweet,
.gh-content .twitter-tweet-rendered,
.gh-content .kg-embed-card,
.gh-content blockquote.twitter-tweet {
    /* Smaller gap above the card, normal gap below */
    margin: 8px 0 24px !important;
    max-width: 100% !important;
    width: 100% !important;
    background: transparent !important;
    overflow: hidden !important;
}

/* Twitter Iframe scaling
   Make iframe fill the article width. We cannot reliably change the
   internal font size (inside the iframe), so we avoid scaling here.
*/
.gh-content iframe[id^="twitter-widget"],
.gh-content iframe[src*="twitter"],
.gh-content iframe[src*="x.com"] {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    transform: none !important;
    display: block !important;
    margin-bottom: 0 !important;
}

/* Hide overflow for the physical width expansion */
.gh-content .kg-embed-card {
    width: 100%;
    overflow: hidden;
    margin-bottom: 0 !important; /* Reset margin, let JS handle the gap */
}

/* 18. Utilities
/* ---------------------------------------------------------- */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
