@import url('post-mongo.css?v=2');

/* ═══════════════════════════════════════════════
   post.css — individual blog post page
═══════════════════════════════════════════════ */

/* ─── Post hero ─── */
.post-hero {
    max-width: 780px;
    margin: 0 auto;
    padding: 72px 32px 56px;
    position: relative;
}

.hero-glow {
    position: absolute;
    top: 0;
    right: -80px;
    width: 400px;
    height: 400px;
    background: radial-gradient(ellipse, rgba(124, 110, 247, .13) 0%, transparent 70%);
    pointer-events: none;
    border-radius: 50%;
}

.back-link {
    display: inline-block;
    font-size: 13px;
    color: var(--text3);
    text-decoration: none;
    margin-bottom: 28px;
    transition: color .2s;
}

.back-link:hover {
    color: var(--text);
}

.hero-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--cat-color, var(--accent2));
    background: var(--cat-bg, var(--accent-glow));
    border: 1px solid color-mix(in srgb, var(--cat-color, var(--accent2)) 30%, transparent);
    padding: 5px 14px;
    border-radius: var(--radius-pill);
    margin-bottom: 28px;
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--cat-color, var(--accent2));
    animation: pulse 2s ease-in-out infinite;
}

.post-hero__title {
    font-family: var(--font-display);
    font-size: clamp(2.2rem, 5.5vw, 4rem);
    font-weight: 800;
    line-height: 1.08;
    letter-spacing: -.03em;
    color: #fff;
    margin-bottom: 22px;
}

.highlight {
    background: linear-gradient(135deg, var(--accent2) 0%, #c0b2ff 50%, var(--teal) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.post-hero__meta {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--text2);
    margin-bottom: 28px;
}

.post-hero__meta .sep {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text3);
}

.post-hero__lead {
    font-size: 18px;
    font-weight: 300;
    color: var(--text2);
    line-height: 1.7;
    border-left: 2px solid var(--accent);
    padding-left: 20px;
    animation: fadeUp 1s ease both;
}

/* ─── Article body ─── */
.post-article {
    max-width: 780px;
    margin: 0 auto;
    padding: 0 32px 80px;
    animation: fadeUp .8s ease .2s both;
}

.post-article h2 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.65rem;
    letter-spacing: -.02em;
    color: #fff;
    margin: 56px 0 18px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.post-article h2::before {
    content: '';
    display: block;
    width: 24px;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    border-radius: 2px;
    flex-shrink: 0;
}

.post-article h3 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.15rem;
    color: var(--text);
    margin: 36px 0 12px;
}

.post-article p {
    color: var(--text2);
    margin-bottom: 18px;
    font-size: 16px;
    font-weight: 300;
}

.post-article p strong {
    color: var(--text);
    font-weight: 500;
}

/* ─── Phase cards ─── */
.phases-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 32px 0;
}

.phase-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px 22px 18px;
    position: relative;
    overflow: hidden;
    transition: transform .2s, border-color .2s;
}

.phase-card:hover {
    transform: translateY(-3px);
    border-color: var(--border2);
}

.phase-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--card-accent, var(--accent));
}

.phase-card .phase-num {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: .1em;
    color: var(--card-color, var(--accent2));
    margin-bottom: 8px;
    text-transform: uppercase;
}

.phase-card .phase-title {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.phase-card p {
    font-size: 13.5px;
    color: var(--text2);
    line-height: 1.6;
    margin: 0;
}

.phase-card .tag {
    display: inline-block;
    margin-top: 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    background: rgba(255, 255, 255, .05);
    color: var(--card-color, var(--accent2));
    border: 1px solid rgba(255, 255, 255, .07);
    padding: 3px 10px;
    border-radius: 6px;
}

/* ─── Code blocks ─── */
.code-block {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin: 28px 0;
    overflow: hidden;
    position: relative;
}

.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, .02);
}

.code-header-right {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

.copy-btn {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 0;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, .35);
    padding: 4px;
    border-radius: 4px;
    cursor: pointer;
    transition: all .25s ease;
    white-space: nowrap;
    line-height: 1;
    overflow: hidden;
}

.copy-btn svg {
    flex-shrink: 0;
}

.copy-btn .copy-label {
    display: block;
    max-width: 0;
    overflow: hidden;
    opacity: 0;
    font-size: 11px;
    font-family: var(--font-mono);
    transition: max-width .25s ease, opacity .25s ease, margin .25s ease;
    margin-left: 0;
}

.copy-btn:hover {
    color: rgba(255, 255, 255, .7);
}

.copy-btn:hover .copy-label {
    max-width: 50px;
    opacity: 1;
    margin-left: 5px;
}

.copy-btn.copied {
    color: #28c840;
}

.copy-btn.copied .copy-label {
    max-width: 60px;
    opacity: 1;
    margin-left: 5px;
}

.code-header .dots {
    display: flex;
    gap: 6px;
}

.code-header .dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.code-header .dots span:nth-child(1) {
    background: #ff5f57;
}

.code-header .dots span:nth-child(2) {
    background: #febc2e;
}

.code-header .dots span:nth-child(3) {
    background: #28c840;
}

.code-header .lang {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text3);
    letter-spacing: .08em;
}

.code-body {
    padding: 22px 24px;
    overflow-x: auto;
}

pre {
    font-family: var(--font-mono);
    font-size: 13.5px;
    line-height: 1.8;
    color: var(--text);
    white-space: pre;
    margin: 0;
    border: none;
    outline: none;
}

pre[contenteditable="true"] {
    cursor: text;
    caret-color: #fff;
    outline: none !important;
}

pre[contenteditable="true"]:focus,
pre[contenteditable="true"]:active {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
}

/* ─── Syntax colours ─── */
.kw {
    color: #c792ea;
}

.fn {
    color: #82aaff;
}

.str {
    color: #c3e88d;
}

.num {
    color: #f78c6c;
}

.cm {
    color: var(--text3);
    font-style: italic;
}

.punc {
    color: var(--text2);
}

.tag-c {
    color: var(--teal);
}

/* ─── Callouts ─── */
.callout {
    border-radius: var(--radius-md);
    padding: 20px 24px;
    margin: 28px 0;
    display: flex;
    gap: 16px;
    align-items: flex-start;
    border: 1px solid;
}

.callout.info {
    background: rgba(96, 165, 250, .07);
    border-color: rgba(96, 165, 250, .2);
}

.callout.warn {
    background: rgba(251, 191, 36, .07);
    border-color: rgba(251, 191, 36, .2);
}

.callout.tip {
    background: rgba(74, 222, 128, .07);
    border-color: rgba(74, 222, 128, .2);
}

.callout-icon {
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 2px;
}

.callout-body p {
    margin: 0;
    font-size: 14.5px;
    line-height: 1.65;
}

.callout.info .callout-body p {
    color: #93c5fd;
}

.callout.warn .callout-body p {
    color: #fde68a;
}

.callout.tip .callout-body p {
    color: #86efac;
}

.callout-body strong {
    color: #fff;
}

/* ─── Loop diagram ─── */
.diagram-wrap {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    margin: 36px 0;
}

.diagram-label {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text3);
    margin-bottom: 24px;
    text-align: center;
}

/* CSS-only tab inputs */
.loop-tabs input[type=radio] {
    display: none;
}

.loop-ring {
    position: relative;
    width: 320px;
    height: 320px;
    margin: 0 auto 24px;
}

.loop-ring .lp {
    position: absolute;
    width: 88px;
    height: 52px;
    border-radius: 10px;
    border: 1px solid;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    transition: transform .2s, box-shadow .2s;
    font-family: var(--font-body);
}

.loop-ring .lp:hover {
    transform: scale(1.08);
}

.lp-icon {
    font-size: 14px;
}

.lp-name {
    font-size: 10px;
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
}

.loop-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.loop-center-title {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    color: #fff;
}

.loop-center-sub {
    font-size: 11px;
    color: var(--text3);
    margin-top: 4px;
}

/* Detail panels */
.detail-panel {
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: var(--radius-md);
    padding: 20px 22px;
    display: none;
}

/* Show active panel when its radio is checked */
#ph-0:checked~.loop-tabs-body #dp-0,
#ph-1:checked~.loop-tabs-body #dp-1,
#ph-2:checked~.loop-tabs-body #dp-2,
#ph-3:checked~.loop-tabs-body #dp-3,
#ph-4:checked~.loop-tabs-body #dp-4,
#ph-5:checked~.loop-tabs-body #dp-5 {
    display: block;
}

/* Scale active ring label */
#ph-0:checked~.loop-ring label[for="ph-0"],
#ph-1:checked~.loop-ring label[for="ph-1"],
#ph-2:checked~.loop-ring label[for="ph-2"],
#ph-3:checked~.loop-ring label[for="ph-3"],
#ph-4:checked~.loop-ring label[for="ph-4"],
#ph-5:checked~.loop-ring label[for="ph-5"] {
    transform: scale(1.12);
}

.detail-phase-name {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.detail-phase-desc {
    font-size: 14px;
    color: var(--text2);
    line-height: 1.6;
    margin-bottom: 12px;
}

.detail-bullets {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.detail-bullets li {
    font-size: 13px;
    color: var(--text2);
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.bullet-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

/* Phase nav */
.phase-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
}

.phase-nav button {
    background: var(--bg3);
    border: 1px solid var(--border2);
    color: var(--text2);
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 13px;
    cursor: pointer;
    transition: background .2s, color .2s;
}

.phase-nav button:hover {
    background: var(--bg);
    color: #fff;
}

.phase-dots {
    display: flex;
    gap: 7px;
    align-items: center;
}

.phase-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--border2);
    cursor: pointer;
    display: inline-block;
    transition: background .2s;
}

/* Active dot colours */
#ph-0:checked~.phase-dots .phase-dot:nth-child(1) {
    background: #a594ff;
}

#ph-1:checked~.phase-dots .phase-dot:nth-child(2) {
    background: #5eead4;
}

#ph-2:checked~.phase-dots .phase-dot:nth-child(3) {
    background: #b0b0c4;
}

#ph-3:checked~.phase-dots .phase-dot:nth-child(4) {
    background: #93c5fd;
}

#ph-4:checked~.phase-dots .phase-dot:nth-child(5) {
    background: #86efac;
}

#ph-5:checked~.phase-dots .phase-dot:nth-child(6) {
    background: #fca5a5;
}

/* ─── Comparison table ─── */
.compare-table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
    font-size: 14px;
}

.compare-table th {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text3);
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.compare-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text2);
    vertical-align: top;
}

.compare-table tr:hover td {
    background: rgba(255, 255, 255, .02);
}

.fn-name {
    font-family: var(--font-mono);
    color: var(--accent2);
    font-size: 13px;
}

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 5px;
    font-family: var(--font-mono);
    font-size: 11px;
}

.badge.fast {
    background: rgba(74, 222, 128, .12);
    color: var(--green);
    border: 1px solid rgba(74, 222, 128, .2);
}

.badge.med {
    background: rgba(251, 191, 36, .12);
    color: var(--amber);
    border: 1px solid rgba(251, 191, 36, .2);
}

.badge.slow {
    background: rgba(248, 113, 113, .12);
    color: var(--coral);
    border: 1px solid rgba(248, 113, 113, .2);
}

/* ─── Microtask banner ─── */
.microtask-banner {
    background: linear-gradient(135deg, rgba(124, 110, 247, .12), rgba(45, 212, 191, .08));
    border: 1px solid rgba(124, 110, 247, .25);
    border-radius: 14px;
    padding: 24px 28px;
    margin: 32px 0;
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.microtask-banner .icon {
    font-size: 28px;
    flex-shrink: 0;
}

.microtask-banner h3 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    color: #fff;
    margin-bottom: 6px;
}

.microtask-banner p {
    font-size: 14px;
    color: var(--text2);
    margin: 0;
    line-height: 1.65;
}

.microtask-banner strong {
    color: var(--accent2);
}

/* ─── Post footer ─── */
.post-footer {
    max-width: 780px;
    margin: 0 auto;
    padding: 36px 32px 40px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.post-footer p {
    font-size: 13px;
    color: var(--text3);
}

.tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ─── Related posts ─── */
.related-posts {
    max-width: 1100px;
    margin: 0 auto;
    padding: 48px 32px 80px;
    border-top: 1px solid var(--border);
}

.related-posts__heading {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 24px;
}

.related-posts__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}

/* ─── Responsive ─── */
@media (max-width: 640px) {
    .post-hero {
        padding: 48px 20px 36px;
    }

    .post-article {
        padding: 0 20px 60px;
    }

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

    .post-footer {
        padding: 28px 20px;
    }

    .related-posts {
        padding: 36px 20px 60px;
    }

    .loop-ring {
        transform: scale(.85);
        transform-origin: top center;
        margin-bottom: 0;
    }
}