/* ========================================================================
   chrisipeters.com — Article & Blog Styling
   Dark editorial magazine — wide-format with sidebar
   ======================================================================== */

/* ── Reading Progress Bar ────────────────────────────────────────────── */
.cp-reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 2px;
    background: linear-gradient(90deg, var(--cp-emerald) 0%, var(--cp-cyan) 100%);
    box-shadow: 0 0 12px rgba(0, 229, 160, 0.4);
    z-index: 9999;
    transition: width 80ms linear;
}

/* ── Article Hero / Header — Full Bleed ──────────────────────────────── */
.cp-article-hero {
    position: relative;
    width: 100%;
    padding: 72px 0 0;
}

.cp-article-hero__viewport {
    position: relative;
    width: 100%;
    max-height: 56vh;
    overflow: hidden;
    border-bottom: 1px solid var(--cp-glass-border);
}

.cp-article-hero__viewport::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        rgba(12, 12, 12, 0.15) 0%,
        transparent 20%,
        transparent 40%,
        rgba(12, 12, 12, 0.5) 70%,
        var(--cp-void) 100%
    );
    z-index: 1;
    pointer-events: none;
}

.cp-article-hero__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ── Article Layout — Sidebar + Content Grid ─────────────────────────── */
.cp-article-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 0 48px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 100px clamp(24px, 4vw, 64px) 0;
}

.cp-article-hero ~ .cp-article-layout {
    padding-top: 0;
}

/* ── Sidebar — Metadata Rail ─────────────────────────────────────────── */
.cp-article-sidebar {
    position: sticky;
    top: 100px;
    align-self: start;
    padding: 32px 0;
    height: fit-content;
}

.cp-article-sidebar__section {
    margin-bottom: 28px;
}

.cp-article-sidebar__label {
    display: block;
    font-family: var(--cp-font-mono);
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--cp-emerald);
    text-transform: uppercase;
    opacity: 0.5;
    margin-bottom: 6px;
}

.cp-article-sidebar__value {
    font-family: var(--cp-font-mono);
    font-size: 12px;
    color: var(--cp-text-secondary);
    line-height: 1.5;
}

.cp-article-sidebar__divider {
    height: 1px;
    background: var(--cp-glass-border);
    margin: 0 0 28px;
}

.cp-article-sidebar__tags {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cp-article-sidebar__tag {
    font-family: var(--cp-font-mono);
    font-size: 11px;
    color: var(--cp-text-muted);
    text-decoration: none;
    padding: 3px 0;
    transition: color 0.2s ease;
}

.cp-article-sidebar__tag::before {
    content: '› ';
    color: var(--cp-emerald);
    opacity: 0.4;
}

.cp-article-sidebar__tag:hover {
    color: var(--cp-emerald);
}

.cp-article-sidebar__back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--cp-font-mono);
    font-size: 11px;
    color: var(--cp-text-muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

.cp-article-sidebar__back:hover {
    color: var(--cp-emerald);
}

.cp-article-sidebar__progress-track {
    width: 100%;
    height: 2px;
    background: var(--cp-glass-border);
    margin-top: 8px;
    overflow: hidden;
}

.cp-article-sidebar__progress-fill {
    width: 0%;
    height: 100%;
    background: var(--cp-emerald);
    transition: width 80ms linear;
}

/* ── Article Main Content Area ───────────────────────────────────────── */
.cp-article-main {
    min-width: 0;
    padding: 32px 0 80px;
}

/* ── Article Meta ────────────────────────────────────────────────────── */
.cp-article-meta {
    max-width: 840px;
    margin: 0 0 40px;
}

.cp-article-meta__title {
    font-family: var(--cp-font);
    font-size: clamp(32px, 4.5vw, 48px);
    font-weight: 800;
    color: var(--cp-text);
    line-height: 1.1;
    letter-spacing: -2px;
    margin: 0 0 16px;
}

.cp-article-meta__excerpt {
    font-family: var(--cp-font);
    font-size: 18px;
    color: var(--cp-text-secondary);
    line-height: 1.65;
    margin: 0 0 24px;
    max-width: 720px;
}

.cp-article-meta__telemetry {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 14px 0;
    border-top: 1px solid var(--cp-glass-border);
    border-bottom: 1px solid var(--cp-glass-border);
    font-family: var(--cp-font-mono);
    font-size: 11px;
    color: var(--cp-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cp-article-meta__telemetry-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cp-article-meta__telemetry-label {
    color: var(--cp-emerald);
    opacity: 0.5;
}

.cp-article-meta__telemetry-value {
    color: var(--cp-text-secondary);
}

/* ── Article Body — Wide ─────────────────────────────────────────────── */
.cp-article-body {
    max-width: 840px;
    margin: 0;
    padding: 0;
    font-family: var(--cp-font);
    font-size: 18px;
    line-height: 1.85;
    color: var(--cp-text-secondary);
}

.cp-article-body h1 {
    font-size: clamp(28px, 3.5vw, 36px);
    font-weight: 800;
    color: var(--cp-text);
    margin: 64px 0 20px;
    letter-spacing: -1px;
    line-height: 1.15;
}

.cp-article-body h2 {
    font-size: clamp(24px, 3vw, 30px);
    font-weight: 700;
    color: var(--cp-text);
    margin: 56px 0 16px;
    padding-left: 16px;
    border-left: 2px solid var(--cp-emerald);
    letter-spacing: -0.5px;
    line-height: 1.25;
}

.cp-article-body h3 {
    font-size: clamp(20px, 2.5vw, 24px);
    font-weight: 600;
    color: var(--cp-text);
    margin: 44px 0 12px;
    letter-spacing: -0.2px;
    line-height: 1.3;
}

.cp-article-body h4 {
    font-family: var(--cp-font-mono);
    font-size: 13px;
    font-weight: 500;
    color: var(--cp-emerald);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin: 36px 0 12px;
}

.cp-article-body p {
    margin: 0 0 28px;
}

.cp-article-body strong {
    color: var(--cp-text);
    font-weight: 600;
}

.cp-article-body em {
    color: var(--cp-text);
    font-style: italic;
}

.cp-article-body a {
    color: var(--cp-emerald);
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 229, 160, 0.25);
    transition: border-color 0.2s ease, color 0.2s ease;
}

.cp-article-body a:hover {
    color: var(--cp-emerald-hover);
    border-bottom-color: var(--cp-emerald);
}

/* — Images: Wide Breakout — */
.cp-article-body img {
    display: block;
    width: calc(100% + 80px);
    margin: 48px 0 48px -40px;
    border: 1px solid var(--cp-glass-border);
    border-radius: 2px;
    transition: border-color 0.3s ease;
}

.cp-article-body img:hover {
    border-color: rgba(0, 229, 160, 0.15);
}

/* — Blockquotes — */
.cp-article-body blockquote {
    position: relative;
    width: calc(100% + 40px);
    margin: 44px 0 44px -20px;
    padding: 24px 28px;
    background: var(--cp-glass-bg);
    border-left: 3px solid var(--cp-emerald);
    font-size: 17px;
    color: var(--cp-text);
    line-height: 1.7;
}

.cp-article-body blockquote p {
    margin: 0 0 8px;
}

.cp-article-body blockquote p:last-child {
    margin-bottom: 0;
}

/* — Code: Inline — */
.cp-article-body code {
    font-family: var(--cp-font-mono);
    font-size: 0.82em;
    padding: 2px 8px;
    background: rgba(0, 229, 160, 0.06);
    border: 1px solid rgba(0, 229, 160, 0.1);
    color: var(--cp-emerald);
    border-radius: 2px;
}

/* — Code: Block — Wide — */
.cp-article-body pre {
    position: relative;
    width: calc(100% + 80px);
    margin: 40px 0 40px -40px;
    padding: 0;
    background: var(--cp-deep);
    border: 1px solid var(--cp-glass-border);
    border-radius: 2px;
    overflow: hidden;
}

.cp-article-body pre::before {
    content: '';
    display: block;
    height: 1px;
    background: linear-gradient(90deg, var(--cp-emerald), transparent);
    opacity: 0.3;
}

.cp-article-body pre code {
    display: block;
    padding: 20px 24px;
    background: transparent;
    border: none;
    color: var(--cp-text-secondary);
    font-size: 14px;
    line-height: 1.7;
    overflow-x: auto;
    border-radius: 0;
}

/* — Lists — */
.cp-article-body ul,
.cp-article-body ol {
    margin: 0 0 28px;
    padding-left: 0;
    list-style: none;
}

.cp-article-body ul li,
.cp-article-body ol li {
    position: relative;
    padding-left: 28px;
    margin-bottom: 14px;
    line-height: 1.75;
}

.cp-article-body ul li::before {
    content: '›';
    position: absolute;
    left: 4px;
    color: var(--cp-emerald);
    font-weight: 700;
    font-size: 16px;
}

.cp-article-body ol {
    counter-reset: cp-counter;
}

.cp-article-body ol li {
    counter-increment: cp-counter;
}

.cp-article-body ol li::before {
    content: counter(cp-counter, decimal-leading-zero);
    position: absolute;
    left: 0;
    font-family: var(--cp-font-mono);
    font-size: 12px;
    color: var(--cp-emerald);
    opacity: 0.6;
}

/* — HR — */
.cp-article-body hr {
    border: none;
    height: 1px;
    margin: 64px -40px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--cp-glass-border) 10%,
        rgba(0, 229, 160, 0.12) 50%,
        var(--cp-glass-border) 90%,
        transparent 100%
    );
}

/* — Tables — */
.cp-article-body table {
    width: calc(100% + 80px);
    margin: 40px 0 40px -40px;
    border-collapse: collapse;
    font-size: 14px;
}

.cp-article-body thead th {
    font-family: var(--cp-font-mono);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--cp-emerald);
    text-align: left;
    padding: 10px 16px;
    border-bottom: 1px solid var(--cp-emerald);
    opacity: 0.7;
}

.cp-article-body tbody td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--cp-glass-border);
    color: var(--cp-text-secondary);
}

.cp-article-body tbody tr:hover td {
    background: var(--cp-glass-bg);
}

/* ── Article Tags ────────────────────────────────────────────────────── */
.cp-article-tags {
    max-width: 840px;
    margin: 0;
    padding: 0 0 48px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.cp-article-tags__label {
    font-family: var(--cp-font-mono);
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--cp-text-dim);
    text-transform: uppercase;
    margin-right: 8px;
}

.cp-article-tag {
    font-family: var(--cp-font-mono);
    font-size: 11px;
    background: rgba(0, 229, 160, 0.08);
    color: var(--cp-emerald);
    padding: 4px 12px;
    border-radius: 2px;
    text-decoration: none;
    transition: background 0.2s ease;
}

.cp-article-tag:hover {
    background: rgba(0, 229, 160, 0.16);
}

/* ── Card — Image Variant ────────────────────────────────────────────── */
.cp-card--has-image {
    background-size: cover;
    background-position: center;
    min-height: 260px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
    position: relative;
}

.cp-card--has-image::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        rgba(12, 12, 12, 0.1) 0%,
        rgba(12, 12, 12, 0.4) 35%,
        rgba(12, 12, 12, 0.85) 65%,
        rgba(12, 12, 12, 0.95) 100%
    );
    z-index: 0;
    transition: background 0.3s ease;
}

.cp-card--has-image:hover::before {
    background: linear-gradient(
        180deg,
        rgba(0, 229, 160, 0.05) 0%,
        rgba(12, 12, 12, 0.35) 35%,
        rgba(12, 12, 12, 0.8) 65%,
        rgba(12, 12, 12, 0.93) 100%
    );
}

.cp-card--has-image > * {
    position: relative;
    z-index: 1;
}

/* ── Blog Listing (wide grid) ────────────────────────────────────────── */
.cp-blog-listing {
    max-width: 1400px;
    margin: 0 auto;
    padding: 100px clamp(24px, 4vw, 64px) 80px;
}

.cp-blog-listing__header {
    margin-bottom: 48px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--cp-glass-border);
}

.cp-blog-listing__label {
    display: block;
    font-family: var(--cp-font-mono);
    font-size: 11px;
    letter-spacing: 3px;
    color: var(--cp-emerald);
    text-transform: uppercase;
    margin-bottom: 12px;
    opacity: 0.6;
}

.cp-blog-listing__title {
    font-family: var(--cp-font);
    font-size: clamp(28px, 4vw, 40px);
    font-weight: 800;
    color: var(--cp-text);
    line-height: 1.15;
    letter-spacing: -1px;
    margin: 0 0 8px;
}

.cp-blog-listing__subtitle {
    font-family: var(--cp-font);
    font-size: 15px;
    color: var(--cp-text-muted);
    margin: 0;
}

.cp-blog-listing__count {
    font-family: var(--cp-font-mono);
    font-size: 11px;
    color: var(--cp-text-dim);
    margin-top: 16px;
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .cp-article-layout {
        grid-template-columns: 1fr;
        gap: 0;
        max-width: 840px;
    }

    .cp-article-sidebar {
        position: static;
        display: flex;
        flex-wrap: wrap;
        gap: 20px 40px;
        padding: 24px 0;
        border-bottom: 1px solid var(--cp-glass-border);
        margin-bottom: 8px;
    }

    .cp-article-sidebar__section {
        margin-bottom: 0;
    }

    .cp-article-sidebar__divider {
        display: none;
    }

    .cp-article-sidebar__tags {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px 12px;
    }

    .cp-article-sidebar__progress-track {
        display: none;
    }

    .cp-article-body img,
    .cp-article-body pre,
    .cp-article-body table {
        width: 100%;
        margin-left: 0;
    }

    .cp-article-body blockquote {
        width: 100%;
        margin-left: 0;
    }

    .cp-article-body hr {
        margin-left: 0;
        margin-right: 0;
    }
}

@media (max-width: 768px) {
    .cp-article-hero__viewport {
        max-height: 40vh;
    }

    .cp-article-meta__title {
        font-size: 28px;
        letter-spacing: -1px;
    }

    .cp-article-meta__telemetry {
        flex-wrap: wrap;
        gap: 12px;
    }

    .cp-article-body {
        font-size: 16px;
    }

    .cp-article-body h2 {
        margin-top: 40px;
    }

    .cp-article-body pre code {
        font-size: 13px;
    }

    .cp-blog-grid {
        grid-template-columns: 1fr;
    }

    .cp-article-sidebar {
        flex-direction: column;
        gap: 12px;
    }
}
