/*
 * Editorial system for the blog index and long-form posts.
 * Scoped to .editorial-page so the shared site stylesheet remains untouched.
 */

.editorial-page {
    --editorial-ink: #081827;
    --editorial-navy: #0d2638;
    --editorial-panel: #112d40;
    --editorial-cyan: #73d2d6;
    --editorial-cyan-soft: #b8e6e5;
    --editorial-copper: #c88452;
    --editorial-paper: #f3f0e8;
    --editorial-paper-bright: #faf8f2;
    --editorial-text: #162b38;
    --editorial-muted: #60717a;
    --editorial-line: rgba(32, 76, 91, 0.18);
    color: var(--editorial-text);
    background:
        linear-gradient(rgba(22, 64, 78, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(22, 64, 78, 0.035) 1px, transparent 1px),
        var(--editorial-paper) !important;
    background-size: 32px 32px;
}

.editorial-page header {
    background: rgba(8, 24, 39, 0.96);
    border-bottom: 1px solid rgba(115, 210, 214, 0.24);
    box-shadow: 0 10px 35px rgba(2, 12, 20, 0.22);
}

.editorial-page .nav-container {
    max-width: 1160px;
}

.editorial-page .logo {
    color: var(--editorial-paper-bright);
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: 1.25rem;
    font-weight: 650;
    letter-spacing: 0.08em;
    text-shadow: none;
}

.editorial-page .logo::after {
    content: " / OBSERVATORY";
    color: var(--editorial-cyan);
    font-size: 0.62rem;
    letter-spacing: 0.12em;
}

.editorial-page nav a,
.editorial-page .theme-toggle {
    color: rgba(250, 248, 242, 0.78);
}

.editorial-page .theme-toggle {
    background: rgba(8, 24, 39, 0.42);
    border: 1px solid rgba(115, 210, 214, 0.3);
}

.editorial-page nav a:hover,
.editorial-page nav a.active,
.editorial-page .theme-toggle:hover {
    color: var(--editorial-cyan);
    background: rgba(115, 210, 214, 0.09);
    border-color: rgba(115, 210, 214, 0.58);
    transform: none;
}

.editorial-page nav a::after {
    background: var(--editorial-copper);
}

.editorial-page .menu-toggle {
    color: var(--editorial-paper-bright);
}

.editorial-page main {
    padding-top: 4.5rem;
}

.editorial-page .blog-hero {
    padding: clamp(5rem, 10vw, 8.5rem) 2rem clamp(3.5rem, 7vw, 5.5rem);
    text-align: left;
    border-bottom: 1px solid rgba(115, 210, 214, 0.18);
    background:
        radial-gradient(circle at 82% 18%, rgba(115, 210, 214, 0.14), transparent 24rem),
        linear-gradient(115deg, #081827 0%, #0c2738 62%, #15394b 100%);
}

.editorial-page .blog-hero::before {
    inset: 0;
    background:
        linear-gradient(rgba(115, 210, 214, 0.055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(115, 210, 214, 0.055) 1px, transparent 1px) !important;
    background-size: 40px 40px !important;
    -webkit-mask-image: linear-gradient(to right, black, transparent 82%);
    mask-image: linear-gradient(to right, black, transparent 82%);
}

.editorial-page .blog-hero-content {
    max-width: 1080px;
}

.editorial-kicker {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 1.2rem;
    color: var(--editorial-copper);
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.16em;
}

.editorial-kicker::before {
    content: "";
    width: 2.5rem;
    height: 1px;
    background: currentColor;
}

.editorial-page .blog-hero h1 {
    max-width: 760px;
    margin-bottom: 1.25rem;
    color: var(--editorial-paper-bright);
    background: none;
    -webkit-text-fill-color: currentColor;
    font-family: "Noto Serif SC", serif;
    font-size: clamp(2.8rem, 7vw, 5.2rem);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -0.045em;
}

.editorial-page .blog-hero p {
    max-width: 650px;
    color: rgba(232, 240, 237, 0.72);
    font-size: clamp(1rem, 2vw, 1.18rem);
    line-height: 1.8;
}

.observation-ledger {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    margin-top: 2.4rem;
    color: rgba(232, 240, 237, 0.68);
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
}

.observation-ledger span {
    padding: 0.72rem 1.1rem;
    border: 1px solid rgba(115, 210, 214, 0.18);
    border-right: 0;
}

.observation-ledger span:last-child {
    border-right: 1px solid rgba(115, 210, 214, 0.18);
}

.observation-ledger strong {
    color: var(--editorial-cyan);
    font-weight: 650;
}

.observation-archive {
    max-width: 1080px;
    margin: clamp(3rem, 7vw, 6rem) auto;
    padding-inline: 0;
}

.archive-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.archive-index {
    color: var(--editorial-copper);
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.14em;
}

.archive-heading h2 {
    margin: 0.55rem 0 0;
    color: var(--editorial-ink);
    font-family: "Noto Serif SC", serif;
    font-size: clamp(1.7rem, 4vw, 2.6rem);
    letter-spacing: -0.035em;
}

.blog-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

.blog-filter {
    padding: 0.48rem 0.78rem;
    color: var(--editorial-muted);
    background: transparent;
    border: 1px solid var(--editorial-line);
    border-radius: 2px;
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: 0.7rem;
    cursor: pointer;
}

.blog-filter:hover,
.blog-filter.is-active {
    color: var(--editorial-paper-bright);
    background: var(--editorial-navy);
    border-color: var(--editorial-navy);
}

.editorial-page .blog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    max-width: 1080px;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--editorial-line);
    background: var(--editorial-line);
    box-shadow: 0 24px 60px rgba(8, 24, 39, 0.11);
}

.editorial-page .blog-card {
    min-height: 280px;
    padding: clamp(1.5rem, 4vw, 2.4rem);
    color: var(--editorial-text);
    background: rgba(250, 248, 242, 0.94);
    border: 0;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    transition: background-color 180ms ease, color 180ms ease;
}

.editorial-page .blog-card-content {
    display: flex;
    flex: 1;
    flex-direction: column;
}

.editorial-page .blog-card--featured {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
    min-height: 380px;
    padding: 0;
    overflow: hidden;
}

.editorial-page .blog-card--featured:nth-of-type(2) {
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
}

.editorial-page .blog-card--featured:nth-of-type(2) .blog-card-cover {
    order: 2;
}

.editorial-page .blog-card--featured .blog-card-content {
    padding: clamp(1.6rem, 4vw, 2.7rem);
}

.blog-card-cover {
    min-height: 300px;
    margin: 0;
    overflow: hidden;
    background: var(--editorial-ink);
}

.blog-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: saturate(0.9) contrast(1.03);
    transition: transform 600ms cubic-bezier(0.22, 1, 0.36, 1), filter 300ms ease;
}

.blog-card--featured:hover .blog-card-cover img {
    transform: scale(1.035);
    filter: saturate(1) contrast(1.06);
}

.editorial-page .blog-card:hover {
    transform: none;
    color: var(--editorial-paper-bright);
    background: var(--editorial-navy);
    border-color: transparent;
    box-shadow: none;
}

.editorial-page .blog-card-date {
    color: var(--editorial-muted);
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
}

.editorial-page .blog-card-header {
    align-items: center;
    margin-bottom: 1.35rem;
}

.blog-card-sequence,
.blog-card-reading {
    color: var(--editorial-copper);
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.blog-card-reading {
    margin-left: auto;
    color: var(--editorial-muted);
    font-weight: 500;
}

.editorial-page .blog-card-title {
    color: inherit;
    font-family: "Noto Serif SC", serif;
    font-size: clamp(1.45rem, 3vw, 1.9rem);
    font-weight: 700;
    letter-spacing: -0.025em;
}

.editorial-page .blog-card-summary {
    color: var(--editorial-muted);
    line-height: 1.85;
}

.editorial-page .blog-card:hover .blog-card-summary,
.editorial-page .blog-card:hover .blog-card-date,
.editorial-page .blog-card:hover .blog-card-reading {
    color: rgba(250, 248, 242, 0.65);
}

.editorial-page .blog-card--featured .blog-card-title {
    font-size: clamp(1.7rem, 3.5vw, 2.45rem);
}

.editorial-page .blog-card--featured .blog-card-summary {
    margin-bottom: 2rem;
}

.editorial-page .blog-tag,
.editorial-page .keyword {
    padding: 0.28rem 0.68rem;
    color: #28606a;
    background: rgba(115, 210, 214, 0.13);
    border: 1px solid rgba(41, 107, 113, 0.18);
    border-radius: 2px;
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: 0.7rem;
}

.editorial-page .blog-card:hover .blog-tag {
    color: var(--editorial-cyan-soft);
    border-color: rgba(115, 210, 214, 0.32);
    background: rgba(115, 210, 214, 0.08);
}

.editorial-page .blog-read-more {
    color: var(--editorial-copper);
    font-size: 0.86rem;
}

.editorial-page .blog-card:hover .blog-read-more {
    gap: 0.5rem;
}

.editorial-page .blog-empty {
    grid-column: 1 / -1;
    padding: 5rem 2rem;
    color: var(--editorial-muted);
    background: var(--editorial-paper-bright);
}

.editorial-page > footer,
.editorial-page .site-footer {
    color: rgba(250, 248, 242, 0.72);
    background: var(--editorial-ink);
    border-top: 1px solid rgba(115, 210, 214, 0.18);
}

.editorial-page > footer a,
.editorial-page .site-footer a {
    color: var(--editorial-cyan-soft);
}

/* Long-form article: warm paper, restrained measure, strong hierarchy. */
.editorial-post .post-article {
    padding: clamp(3rem, 7vw, 6rem) 0;
}

.reading-progress {
    position: fixed;
    z-index: 1100;
    top: 0;
    right: 0;
    left: 0;
    height: 3px;
    background: rgba(115, 210, 214, 0.08);
}

.reading-progress span {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--editorial-cyan), var(--editorial-copper));
    transform: scaleX(0);
    transform-origin: left center;
    will-change: transform;
}

.editorial-post .post-article .container {
    max-width: 820px;
}

.editorial-post .post-article .post-header {
    position: static;
    margin-bottom: 2.5rem;
    padding-bottom: 1.75rem;
    border-bottom: 1px solid var(--editorial-line);
}

.post-breadcrumb {
    display: inline-block;
    margin-bottom: 1.4rem;
    color: var(--editorial-copper);
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-decoration: none;
}

.editorial-post .post-article .post-header h1 {
    color: var(--editorial-ink);
    font-family: "Noto Serif SC", serif;
    font-size: clamp(2.3rem, 6vw, 4.2rem);
    font-weight: 700;
    line-height: 1.22;
    letter-spacing: -0.04em;
}

.editorial-post .post-meta {
    color: var(--editorial-muted);
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: 0.78rem;
}

.editorial-post .post-meta > span {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.post-cover {
    margin: 0 0 2rem;
    overflow: hidden;
    background: var(--editorial-ink);
    border: 1px solid var(--editorial-line);
    box-shadow: 0 24px 60px rgba(8, 24, 39, 0.11);
}

.post-cover img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.post-cover figcaption {
    padding: 0.7rem 1rem;
    color: rgba(250, 248, 242, 0.64);
    background: var(--editorial-ink);
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: 0.68rem;
    letter-spacing: 0.04em;
}

.editorial-post .post-body {
    padding: clamp(1.5rem, 5vw, 3.4rem);
    color: var(--editorial-text);
    background: rgba(250, 248, 242, 0.94);
    border: 1px solid var(--editorial-line);
    border-radius: 2px;
    box-shadow: 0 24px 60px rgba(8, 24, 39, 0.09);
}

.editorial-post .post-content {
    font-family: "Noto Serif SC", "LXGW WenKai", serif;
    font-size: clamp(1.02rem, 2vw, 1.1rem);
    line-height: 1.95;
    overflow-wrap: anywhere;
}

.editorial-post .post-content h2,
.editorial-post .post-content h3 {
    color: var(--editorial-ink);
    font-family: "Noto Serif SC", serif;
    line-height: 1.4;
}

.editorial-post .post-content h2 {
    margin-top: 3.2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--editorial-line);
}

.editorial-post .post-content a {
    color: #1f6871;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
}

.editorial-post .post-content blockquote {
    margin: 2rem 0;
    padding: 1.25rem 1.5rem;
    color: #354f59;
    background: rgba(115, 210, 214, 0.09);
    border-left: 3px solid var(--editorial-copper);
    font-style: normal;
}

.editorial-post .post-content hr {
    height: 1px;
    margin: 3rem 0;
    background: var(--editorial-line);
    border: 0;
}

.editorial-post .post-content img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 2rem auto;
    border: 1px solid var(--editorial-line);
}

.editorial-post .post-content pre {
    color: #e8f0ed;
    background: var(--editorial-ink);
    border: 1px solid rgba(115, 210, 214, 0.22);
    border-radius: 2px;
}

.editorial-post .post-content code {
    background: rgba(27, 71, 82, 0.1);
    border-radius: 2px;
}

.editorial-post .post-content pre code {
    color: inherit;
    background: transparent;
}

.editorial-post .table-of-contents {
    background: rgba(115, 210, 214, 0.08);
    border: 1px solid var(--editorial-line);
    border-radius: 2px;
}

.editorial-post .post-article .post-footer {
    margin-top: 0;
    color: var(--editorial-text);
    background: transparent;
    border-top-color: var(--editorial-line);
}

.editorial-post .share-btn {
    color: var(--editorial-navy);
    background: transparent;
    border: 1px solid var(--editorial-line);
    border-radius: 2px;
}

.editorial-post .share-copy {
    width: 2.2rem;
    height: 2.2rem;
    padding: 0;
    cursor: pointer;
}

.editorial-post .share-copy.is-copied {
    color: var(--editorial-paper-bright);
    background: #28606a;
}

.source-link {
    color: #1f6871;
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: 0.72rem;
    text-decoration: none;
}

.source-link:hover {
    color: var(--editorial-copper);
}

.editorial-post .share-btn:hover {
    color: var(--editorial-paper-bright);
    background: var(--editorial-navy);
    transform: none;
}

.editorial-page :is(a, button):focus-visible {
    outline: 3px solid var(--editorial-copper);
    outline-offset: 4px;
}

.editorial-page ::selection {
    color: var(--editorial-ink);
    background: var(--editorial-cyan-soft);
}

html.dark .editorial-page {
    --editorial-text: #dce7e5;
    --editorial-muted: #9dafb2;
    --editorial-line: rgba(115, 210, 214, 0.18);
    background:
        linear-gradient(rgba(115, 210, 214, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(115, 210, 214, 0.035) 1px, transparent 1px),
        #071520 !important;
    background-size: 32px 32px;
}

html.dark .editorial-page .blog-card,
html.dark .editorial-post .post-body {
    background: rgba(13, 38, 56, 0.96);
}

html.dark .archive-heading h2 {
    color: var(--editorial-paper-bright);
}

html.dark .blog-filter:hover,
html.dark .blog-filter.is-active {
    color: var(--editorial-ink);
    background: var(--editorial-cyan);
    border-color: var(--editorial-cyan);
}

html.dark .editorial-page .blog-empty {
    background: rgba(13, 38, 56, 0.96);
}

html.dark .editorial-post .post-article .post-header h1,
html.dark .editorial-post .post-content h2,
html.dark .editorial-post .post-content h3 {
    color: var(--editorial-paper-bright);
}

html.dark .editorial-post .post-content a {
    color: var(--editorial-cyan);
}

html.dark .source-link {
    color: var(--editorial-cyan);
}

html.dark .editorial-post .post-content blockquote {
    color: #c6d7d7;
    background: rgba(115, 210, 214, 0.08);
}

html.dark .editorial-post .share-btn {
    color: var(--editorial-cyan-soft);
    border-color: rgba(115, 210, 214, 0.28);
}

html.dark .editorial-page .blog-tag,
html.dark .editorial-page .keyword {
    color: var(--editorial-cyan-soft);
    background: rgba(115, 210, 214, 0.08);
    border-color: rgba(115, 210, 214, 0.26);
}

@media (max-width: 768px) {
    .editorial-page nav {
        background: rgba(8, 24, 39, 0.99);
        border-bottom-color: rgba(115, 210, 214, 0.2);
    }

    .observation-archive {
        margin: 2.5rem 1rem 4rem;
    }

    .archive-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .blog-filters {
        justify-content: flex-start;
    }

    .editorial-page .blog-grid {
        grid-template-columns: 1fr;
        margin: 0;
    }

    .editorial-page .blog-card {
        min-height: 0;
    }

    .editorial-page .blog-card--featured,
    .editorial-page .blog-card--featured:nth-of-type(2) {
        display: flex;
        grid-template-columns: 1fr;
    }

    .editorial-page .blog-card--featured:nth-of-type(2) .blog-card-cover {
        order: 0;
    }

    .blog-card-cover {
        min-height: 0;
    }

    .blog-card-cover img {
        aspect-ratio: 16 / 9;
    }

    .editorial-post .post-article {
        padding: 2.5rem 0 4rem;
    }
}

@media (max-width: 420px) {
    .editorial-page .nav-container,
    .editorial-post .container {
        padding-inline: 1rem;
    }

    .editorial-page .logo {
        font-size: 1rem;
    }

    .editorial-page .logo::after {
        display: none;
    }

    .editorial-page .blog-hero {
        padding-inline: 1.1rem;
    }

    .observation-ledger {
        display: grid;
        grid-template-columns: 1fr;
    }

    .observation-ledger span,
    .observation-ledger span:last-child {
        border-right: 1px solid rgba(115, 210, 214, 0.18);
        border-bottom: 0;
    }

    .observation-ledger span:last-child {
        border-bottom: 1px solid rgba(115, 210, 214, 0.18);
    }

    .editorial-page .blog-card-footer {
        align-items: flex-start;
        flex-direction: column;
        gap: 1rem;
    }

    .editorial-post .post-body {
        padding-inline: 1.15rem;
    }

    .editorial-post .post-article .post-header h1 {
        font-size: 2.1rem;
    }
}

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