/* ==========================================================================
   Circus — A dark editorial Ghost theme
   ========================================================================== */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #0e0e0e;
    --bg-elevated: #181818;
    --bg-card: #141414;
    --text: #e0dcd7;
    --text-secondary: #8a8580;
    --text-dim: #5a5550;
    --accent: #c9a87c;
    --accent-hover: #dbbf99;
    --border: #2a2725;
    --border-light: #1f1d1b;
    --serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    --mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    --content-width: 720px;
    --wide-width: 1080px;
    --full-width: 1320px;
    --gap: 2rem;
}

html {
    font-size: 18px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-weight: 400;
    line-height: 1.7;
    letter-spacing: -0.01em;
}

a {
    color: var(--text);
    text-decoration: none;
    transition: color 0.2s ease;
}

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

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ---------- Site Wrapper ---------- */
.site-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.site-main {
    flex: 1;
}

/* ---------- Header ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border-light);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.site-header.is-scrolled {
    background: rgba(14, 14, 14, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom-color: var(--border);
}

.site-header-inner {
    max-width: var(--full-width);
    margin: 0 auto;
    padding: 1.2rem var(--gap);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-title {
    font-family: var(--serif);
    font-size: 1.35rem;
    font-weight: 400;
    color: var(--text);
    letter-spacing: -0.02em;
    white-space: nowrap;
}

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

.site-nav {
    display: flex;
    align-items: center;
    gap: 1.8rem;
}

.site-nav ul {
    list-style: none;
    display: flex;
    gap: 1.8rem;
    margin: 0;
    padding: 0;
}

.site-nav a {
    font-size: 0.82rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

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

.nav-search {
    color: var(--text-secondary);
    display: flex;
    align-items: center;
}

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

/* ---------- Hero Post ---------- */
.hero-post {
    position: relative;
    max-width: var(--full-width);
    margin: 0 auto;
    padding: var(--gap);
    padding-top: 2.5rem;
}

.hero-image-link {
    display: block;
    border-radius: 8px;
    overflow: hidden;
}

.hero-image {
    width: 100%;
    height: 520px;
    background-size: cover;
    background-position: center;
    border-radius: 8px;
    position: relative;
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    opacity: 0;
    transform: translateY(8px);
}

.hero-image.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.hero-image-link:hover .hero-image {
    transform: scale(1.015);
}

.hero-image-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 50%, rgba(14, 14, 14, 0.6) 100%);
    border-radius: 8px;
}

.hero-content {
    max-width: var(--content-width);
    padding-top: 1.8rem;
}

.hero-title {
    font-family: var(--serif);
    font-size: 2.4rem;
    font-weight: 400;
    line-height: 1.2;
    letter-spacing: -0.03em;
    margin-bottom: 0.6rem;
}

.hero-title a {
    color: var(--text);
}

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

.hero-excerpt {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 0.8rem;
}

.hero-meta {
    font-size: 0.78rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.meta-sep {
    margin: 0 0.4rem;
}

/* ---------- Post Tag ---------- */
.post-tag {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.post-tag:hover {
    color: var(--accent-hover);
}

/* ---------- Post Grid ---------- */
.post-grid {
    max-width: var(--full-width);
    margin: 0 auto;
    padding: 1rem var(--gap) 4rem;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2.5rem;
}

.post-card {
    display: flex;
    flex-direction: column;
}

.post-card-image-link {
    display: block;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.post-card-image {
    width: 100%;
    height: 280px;
    background-size: cover;
    background-position: center;
    border-radius: 6px;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    opacity: 0;
    transform: translateY(8px);
}

.post-card-image.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.post-card-image-link:hover .post-card-image {
    transform: scale(1.03);
}

.post-card-content {
    flex: 1;
}

.post-card-title {
    font-family: var(--serif);
    font-size: 1.5rem;
    font-weight: 400;
    line-height: 1.25;
    letter-spacing: -0.02em;
    margin-bottom: 0.4rem;
}

.post-card-title a {
    color: var(--text);
}

.post-card-title a:hover {
    color: var(--accent);
}

.post-card-excerpt {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 0.6rem;
}

.post-card-meta {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ---------- Single Post ---------- */
.single-post,
.single-page {
    padding-bottom: 4rem;
}

.post-header,
.page-header {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 4rem var(--gap) 2rem;
    text-align: center;
}

.post-header .post-tag {
    margin-bottom: 1rem;
}

.post-title,
.page-title {
    font-family: var(--serif);
    font-size: 3rem;
    font-weight: 400;
    line-height: 1.15;
    letter-spacing: -0.03em;
    margin-bottom: 1rem;
}

.post-subtitle {
    font-size: 1.15rem;
    color: var(--text-secondary);
    line-height: 1.5;
    max-width: 600px;
    margin: 0 auto 1rem;
}

.post-meta-header {
    font-size: 0.78rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Feature image */
.post-feature-image {
    max-width: var(--wide-width);
    margin: 0 auto 3rem;
    padding: 0 var(--gap);
}

.post-feature-image img {
    width: 100%;
    border-radius: 8px;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.post-feature-image img.is-loaded {
    opacity: 1;
}

.post-feature-image figcaption {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-align: center;
    margin-top: 0.8rem;
    font-style: italic;
}

/* ---------- Post Content (gh-content) ---------- */
.post-content {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 0 var(--gap);
    font-size: 1.05rem;
    line-height: 1.78;
}

.post-content p {
    margin-bottom: 1.5rem;
}

.post-content h2 {
    font-family: var(--serif);
    font-size: 1.9rem;
    font-weight: 400;
    line-height: 1.25;
    letter-spacing: -0.02em;
    margin: 3rem 0 1rem;
    color: var(--text);
}

.post-content h3 {
    font-family: var(--serif);
    font-size: 1.45rem;
    font-weight: 400;
    line-height: 1.3;
    margin: 2.5rem 0 0.8rem;
    color: var(--text);
}

.post-content h4 {
    font-family: var(--sans);
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 2rem 0 0.6rem;
    color: var(--text-secondary);
}

.post-content a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: rgba(201, 168, 124, 0.3);
    text-underline-offset: 3px;
    transition: text-decoration-color 0.2s ease;
}

.post-content a:hover {
    text-decoration-color: var(--accent);
}

.post-content strong {
    font-weight: 600;
    color: var(--text);
}

.post-content em {
    font-style: italic;
}

.post-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1.5rem;
    margin: 2rem 0;
    font-family: var(--serif);
    font-size: 1.2rem;
    font-style: italic;
    color: var(--text-secondary);
    line-height: 1.6;
}

.post-content ul,
.post-content ol {
    margin: 0 0 1.5rem 1.5rem;
}

.post-content li {
    margin-bottom: 0.4rem;
}

.post-content code {
    font-family: var(--mono);
    font-size: 0.88em;
    background: var(--bg-elevated);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    color: var(--accent);
}

.post-content pre {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
    overflow-x: auto;
}

.post-content pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text);
}

.post-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 3rem auto;
    max-width: 100px;
}

/* Images in content — allow wider */
.post-content figure,
.post-content .kg-image-card,
.post-content .kg-gallery-card {
    margin: 2.5rem 0;
}

.post-content .kg-image-card img,
.post-content figure img {
    border-radius: 6px;
}

.post-content figcaption {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-align: center;
    margin-top: 0.6rem;
    font-style: italic;
}

/* Wide & full width images */
.post-content .kg-width-wide {
    max-width: var(--wide-width);
    margin-left: calc(50% - min(var(--wide-width)/2, 50vw));
    margin-right: calc(50% - min(var(--wide-width)/2, 50vw));
    width: auto;
}

.post-content .kg-width-full {
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    width: 100vw;
}

.post-content .kg-width-full img {
    border-radius: 0;
}

/* Gallery */
.post-content .kg-gallery-container {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.post-content .kg-gallery-row {
    display: flex;
    gap: 0.6rem;
}

.post-content .kg-gallery-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

/* Bookmark card */
.post-content .kg-bookmark-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin: 2rem 0;
}

.post-content .kg-bookmark-container {
    display: flex;
    text-decoration: none;
    color: var(--text);
}

.post-content .kg-bookmark-content {
    flex: 1;
    padding: 1.2rem;
}

.post-content .kg-bookmark-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.4rem;
}

.post-content .kg-bookmark-description {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    display: -webkit-box;
    overflow: hidden;
}

.post-content .kg-bookmark-metadata {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.post-content .kg-bookmark-thumbnail {
    width: 180px;
    min-height: 100%;
}

.post-content .kg-bookmark-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0;
}

/* ---------- Post Tags Footer ---------- */
.post-tags {
    max-width: var(--content-width);
    margin: 3rem auto 0;
    padding: 0 var(--gap);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-pill {
    font-size: 0.72rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 0.35rem 0.9rem;
    border-radius: 100px;
    transition: all 0.2s ease;
}

.tag-pill:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* ---------- Author Box ---------- */
.post-author {
    max-width: var(--content-width);
    margin: 3rem auto 0;
    padding: 2rem var(--gap) 0;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 1.2rem;
}

.author-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.author-name {
    font-family: var(--sans);
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

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

.author-bio {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ---------- Related Posts ---------- */
.related-posts {
    max-width: var(--full-width);
    margin: 0 auto;
    padding: 4rem var(--gap);
    border-top: 1px solid var(--border-light);
}

.related-title {
    font-family: var(--serif);
    font-size: 1.5rem;
    font-weight: 400;
    margin-bottom: 2rem;
    color: var(--text-secondary);
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
}

/* ---------- Archive Header ---------- */
.archive-header {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 4rem var(--gap) 2rem;
    text-align: center;
}

.archive-title {
    font-family: var(--serif);
    font-size: 2.5rem;
    font-weight: 400;
    margin-bottom: 0.5rem;
}

.archive-description {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 480px;
    margin: 0 auto;
}

.author-header-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 1.2rem;
}

.author-location {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ---------- Pagination ---------- */
.pagination {
    max-width: var(--full-width);
    margin: 0 auto;
    padding: 2rem var(--gap) 4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
}

.pagination a {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

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

.pagination-location {
    font-size: 0.78rem;
    color: var(--text-dim);
}

/* ---------- Error Page ---------- */
.error-page {
    text-align: center;
    padding: 8rem var(--gap);
}

.error-code {
    font-family: var(--serif);
    font-size: 6rem;
    color: var(--text-dim);
    line-height: 1;
    margin-bottom: 1rem;
}

.error-message {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.error-link {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ---------- Footer ---------- */
.site-footer {
    border-top: 1px solid var(--border-light);
    margin-top: auto;
}

.site-footer-inner {
    max-width: var(--full-width);
    margin: 0 auto;
    padding: 2rem var(--gap);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.footer-title {
    font-family: var(--serif);
    font-size: 0.9rem;
    color: var(--text-dim);
}

.footer-copy {
    font-size: 0.78rem;
    color: var(--text-dim);
}

.footer-subscribe {
    font-size: 0.78rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    border: 1px solid var(--accent);
    padding: 0.45rem 1.2rem;
    border-radius: 100px;
    transition: all 0.2s ease;
}

.footer-subscribe:hover {
    background: var(--accent);
    color: var(--bg);
}

/* ---------- Members / Portal ---------- */
.gh-portal-triggerbtn-iframe {
    display: none !important;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
    .hero-image {
        height: 400px;
    }

    .post-grid {
        gap: 2rem;
    }

    .post-card-image {
        height: 220px;
    }

    .related-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    html {
        font-size: 16px;
    }

    :root {
        --gap: 1.25rem;
    }

    .site-header-inner {
        padding: 1rem var(--gap);
    }

    .site-title {
        font-size: 1.15rem;
    }

    .site-nav ul {
        gap: 1.2rem;
    }

    .site-nav a {
        font-size: 0.75rem;
    }

    .hero-image {
        height: 280px;
        border-radius: 6px;
    }

    .hero-title {
        font-size: 1.8rem;
    }

    .post-grid {
        grid-template-columns: 1fr;
        gap: 2.5rem;
    }

    .post-card-image {
        height: 240px;
    }

    .post-title,
    .page-title {
        font-size: 2.2rem;
    }

    .post-header,
    .page-header {
        padding-top: 2.5rem;
    }

    .post-content .kg-width-wide {
        margin-left: calc(-1 * var(--gap));
        margin-right: calc(-1 * var(--gap));
    }

    .post-content .kg-width-wide img {
        border-radius: 0;
    }

    .related-grid {
        grid-template-columns: 1fr;
    }

    .site-footer-inner {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .footer-left {
        flex-direction: column;
        gap: 0.3rem;
    }
}

@media (max-width: 480px) {
    .hero-image {
        height: 220px;
    }

    .hero-title {
        font-size: 1.5rem;
    }

    .post-title {
        font-size: 1.8rem;
    }

    .post-card-title {
        font-size: 1.3rem;
    }

    .post-content {
        font-size: 1rem;
    }

    .post-content h2 {
        font-size: 1.5rem;
    }

    .post-content h3 {
        font-size: 1.2rem;
    }

    .post-content blockquote {
        font-size: 1.05rem;
        padding-left: 1rem;
    }
}

/* ---------- Selection ---------- */
::selection {
    background: rgba(201, 168, 124, 0.3);
    color: var(--text);
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* ---------- Photo Gallery ---------- */
.photo-gallery {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
    margin: 2.5rem 0;
}
.photo-gallery .gallery-item { margin: 0; }
.photo-gallery .gallery-item img {
    width: 100%; height: 100%; object-fit: cover;
    border-radius: 4px; transition: transform 0.3s ease; cursor: pointer;
}
.photo-gallery .gallery-item img:hover { transform: scale(1.02); }
@media (max-width: 600px) {
    .photo-gallery { grid-template-columns: 1fr; }
}

/* ---------- Footer RSS ---------- */
.footer-rss {
    font-size: 0.78rem; font-weight: 500; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--text-dim); transition: color 0.2s ease;
}
.footer-rss:hover { color: var(--accent); }
