/* ═══════════════════════════════════════════════════════════
   Article Detail — Typography-first reading experience
   ═══════════════════════════════════════════════════════════ */

:root {
    --bg:                #f0ede8;
    --card-bg:           #ffffff;
    --text:              #1a1a1a;
    --muted:             #6b6b6b;
    --accent:            #2d2d2d;
    --accent-light:      #555;
    --border:            #e5e0d8;
    --code-bg:           #1e1e2e;
    --code-text:         #cdd6f4;
    --inline-code-bg:    #f5f0eb;
    --inline-code-text:  #c0392b;
    --bq-border:         #2d2d2d;
    --bq-bg:             #f8f5f0;
    --link:              #1d4ed8;
    --shadow-sm:         0 2px 8px rgba(0,0,0,.06);
    --shadow-md:         0 8px 28px rgba(0,0,0,.10);
    --radius:            14px;
    --ease:              .25s ease;
}

/* ── Reset / base ────────────────────────────────────────── */
/* Override portfolio.css which sets black bg, white text, cursor:none */
html { background: var(--bg) !important; }

body {
    font-family: 'Nunito', system-ui, -apple-system, sans-serif !important;
    background: var(--bg) !important;
    color: var(--text) !important;
    -webkit-font-smoothing: antialiased;
    cursor: auto !important;
    margin: 0;
}

/* ── Reading-progress bar (fixed top) ───────────────────── */
#reading-progress {
    position: fixed;
    top: 0; left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #2d2d2d 0%, #888 100%);
    z-index: 9999;
    transition: width .1s linear;
    pointer-events: none;
}

/* ── Outer wrapper ───────────────────────────────────────── */
.content-wrapper {
    min-height: 100vh;
    padding: 3rem 1.5rem 6rem;
}

/* ── Article layout (article + TOC sidebar) ─────────────── */
.article-layout {
    display: flex;
    gap: 2.5rem;
    align-items: flex-start;
    max-width: 1120px;
    margin: 0 auto;
}

.article-container {
    flex: 1;
    min-width: 0;
}

/* ── Sticky TOC sidebar ─────────────────────────────────── */
.article-toc {
    display: none;
    width: 220px;
    flex-shrink: 0;
    position: sticky;
    top: 2rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.1rem 1.25rem;
    box-shadow: var(--shadow-sm);
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
}

@media (min-width: 1120px) {
    .article-toc      { display: block; }
    .toc-mobile       { display: none !important; }
    .article-container { max-width: 820px; }
}

.toc-heading {
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 .75rem;
}

.article-toc .toc,
.toc-mobile  .toc { }

.article-toc .toc ul,
.toc-mobile  .toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.article-toc .toc li + li,
.toc-mobile  .toc li + li { margin-top: .1rem; }

.article-toc .toc a,
.toc-mobile  .toc a {
    display: block;
    color: var(--muted);
    text-decoration: none;
    font-size: .8rem;
    font-family: 'Nunito', system-ui, sans-serif;
    line-height: 1.4;
    padding: .28rem .5rem;
    border-left: 2px solid transparent;
    transition: color var(--ease), border-color var(--ease);
}

.article-toc .toc a:hover,
.toc-mobile  .toc a:hover {
    color: var(--text);
    border-left-color: var(--accent);
}

.article-toc .toc ul ul,
.toc-mobile  .toc ul ul { padding-left: .85rem; }

/* ── Mobile TOC (collapsible) ───────────────────────────── */
.toc-mobile {
    margin-bottom: 2rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.toc-mobile details summary {
    padding: .8rem 1.1rem;
    cursor: pointer;
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: .75rem;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--accent-light);
    list-style: none;
    user-select: none;
}
.toc-mobile details summary::-webkit-details-marker { display: none; }
.toc-mobile details[open] summary { border-bottom: 1px solid var(--border); }
.toc-mobile details .toc { padding: .6rem 1rem .8rem; }

/* ── Reaction bar ───────────────────────────────────────── */
.reaction-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.reaction-label {
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: .75rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
}

.reaction-buttons {
    display: flex;
    gap: .5rem;
}

.reaction-btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .45rem .9rem;
    background: var(--inline-code-bg);
    border: 1px solid var(--border);
    border-radius: 99px;
    cursor: pointer;
    font-size: .85rem;
    font-family: 'Nunito', system-ui, sans-serif;
    color: var(--accent-light);
    transition: background var(--ease), border-color var(--ease), transform .1s ease;
    line-height: 1;
}
.reaction-btn:hover  { background: #f5f0eb; border-color: #bbb; }
.reaction-btn:active { transform: scale(.94); }

.reaction-btn--active {
    background: #1a1a1a;
    border-color: #1a1a1a;
    color: #fff;
}
.reaction-btn--active:hover { background: #333; border-color: #333; }

.r-count {
    font-size: .72rem;
    font-weight: 700;
    min-width: .8ch;
}

/* ── Back link ───────────────────────────────────────────── */
.back-to-articles {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    color: var(--accent-light);
    text-decoration: none;
    font-size: .85rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    margin-bottom: 2rem;
    transition: color var(--ease);
}
.back-to-articles:hover { color: var(--text); }

/* ── Main article card ───────────────────────────────────── */
.article-container {
    max-width: 820px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

/* ── Hero image ──────────────────────────────────────────── */
.article-featured-image {
    width: 100%;
    height: 420px;
    object-fit: cover;
    display: block;
}

/* ── Meta bar ────────────────────────────────────────────── */
.article-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .85rem 2.5rem;
    background: #fafaf8;
    border-bottom: 1px solid var(--border);
    font-size: .85rem;
}

.article-category {
    background: var(--accent);
    color: #fff;
    padding: .2rem .8rem;
    border-radius: 99px;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.article-meta-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.reading-time {
    color: var(--muted);
    font-size: .78rem;
    font-family: 'Nunito', system-ui, sans-serif;
    font-weight: 700;
    letter-spacing: .04em;
    background: var(--inline-code-bg);
    padding: .2rem .6rem;
    border-radius: 99px;
    border: 1px solid var(--border);
}

.article-date {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.article-views {
    color: var(--muted);
    font-size: .78rem;
    font-family: 'Nunito', system-ui, sans-serif;
}

/* ── Article body ────────────────────────────────────────── */
.article-body {
    padding: 3rem 3.5rem 3.5rem;
}

.article-title {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 2.8rem;
    font-weight: 700;
    line-height: 1.15;
    color: var(--text);
    margin: 0 0 1rem;
    letter-spacing: -.02em;
}

.article-description {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 1.25rem;
    color: var(--muted);
    font-style: italic;
    margin: 0 0 2.5rem;
    padding-bottom: 2.5rem;
    border-bottom: 1px solid var(--border);
    line-height: 1.6;
}

/* ══════════════════════════════════════════════════════════
   PROSE — everything inside .article-content
   ══════════════════════════════════════════════════════════ */

.article-content {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 1.2rem;
    line-height: 1.9;
    color: #1e1e1e;
}

/* vertical rhythm */
.article-content > * { margin-top: 0; margin-bottom: 0; }
.article-content > * + * { margin-top: 1.5rem; }

/* ── Headings ────────────────────────────────────────────── */
.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4,
.article-content h5,
.article-content h6 {
    font-family: 'Nunito', system-ui, sans-serif;
    color: var(--text);
    line-height: 1.25;
    font-weight: 800;
    margin-top: 3rem;
    margin-bottom: .5rem;
}

.article-content h1 { font-size: 2.1rem; }
.article-content h2 {
    font-size: 1.65rem;
    padding-bottom: .5rem;
    border-bottom: 2px solid var(--border);
}
.article-content h3 { font-size: 1.35rem; }
.article-content h4 { font-size: 1.1rem; text-transform: uppercase; letter-spacing: .05em; }

/* ── Paragraphs ──────────────────────────────────────────── */
.article-content p { margin-top: 0; }

/* ── Links ───────────────────────────────────────────────── */
.article-content a {
    color: var(--link);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}
.article-content a:hover { color: #1e40af; }

/* ── Lists ───────────────────────────────────────────────── */
.article-content ul,
.article-content ol {
    padding-left: 1.75rem;
}
.article-content li + li { margin-top: .3rem; }
.article-content ul li::marker { color: var(--accent-light); }

/* ── Blockquote ──────────────────────────────────────────── */
.article-content blockquote {
    border-left: 4px solid var(--bq-border);
    background: var(--bq-bg);
    padding: 1.25rem 1.6rem;
    margin: 2.5rem 0;
    border-radius: 0 10px 10px 0;
    font-style: italic;
    font-size: 1.15rem;
    color: #444;
    position: relative;
}
.article-content blockquote::before {
    content: '\201C';
    position: absolute;
    top: -.2rem;
    left: 1rem;
    font-size: 3.5rem;
    color: var(--border);
    font-family: Georgia, serif;
    line-height: 1;
    pointer-events: none;
}
.article-content blockquote p { margin: 0; }

/* ── Code blocks ─────────────────────────────────────────── */
.article-content pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 1.4rem 1.75rem;
    border-radius: 10px;
    overflow-x: auto;
    font-family: 'Fira Code', 'Cascadia Code', Consolas, 'Courier New', monospace;
    font-size: .88rem;
    line-height: 1.65;
    margin: 2.5rem 0;
    tab-size: 4;
    -webkit-overflow-scrolling: touch;
}

/* strip code bg when inside pre */
.article-content pre code {
    background: none !important;
    color: inherit !important;
    padding: 0 !important;
    border: none !important;
    font-size: inherit;
    border-radius: 0;
}

/* inline code */
.article-content code {
    background: var(--inline-code-bg);
    color: var(--inline-code-text);
    padding: .15em .45em;
    border-radius: 5px;
    font-family: 'Fira Code', 'Cascadia Code', Consolas, monospace;
    font-size: .84em;
    border: 1px solid #ddd;
    white-space: nowrap;
}

/* ── Tables ──────────────────────────────────────────────── */
.article-content table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: .95rem;
    margin: 2.5rem 0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.article-content thead tr { background: var(--accent); }
.article-content th {
    color: #fff;
    padding: .75rem 1.1rem;
    text-align: left;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    font-size: .8rem;
}
.article-content td {
    padding: .65rem 1.1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.article-content tr:last-child td { border-bottom: none; }
.article-content tbody tr:nth-child(even) td { background: #fafaf8; }
.article-content tbody tr:hover td { background: #f5f0eb; }

/* ── Images ──────────────────────────────────────────────── */
.article-content img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    margin: 2rem auto;
    display: block;
    box-shadow: var(--shadow-sm);
}

/* ── Horizontal rule ─────────────────────────────────────── */
.article-content hr {
    border: none;
    border-top: 2px solid var(--border);
    margin: 3.5rem 0;
}

/* ── Tags ────────────────────────────────────────────────── */
.article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: 3.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.article-tag {
    background: var(--inline-code-bg);
    color: var(--accent-light);
    padding: .3rem .9rem;
    border-radius: 99px;
    font-size: .78rem;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: .04em;
    text-transform: uppercase;
    transition: background var(--ease), color var(--ease);
    border: 1px solid var(--border);
}
.article-tag:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ── Share bar ───────────────────────────────────────────── */
.share-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.share-label {
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: .75rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
}

.share-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--accent-light);
    background: var(--inline-code-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .4rem .85rem;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--ease), color var(--ease), border-color var(--ease);
    white-space: nowrap;
}
.share-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.share-btn--copy { font-family: inherit; }

/* ── Shop promo widget ───────────────────────────────────── */
.shop-promo {
    max-width: 1120px;
    margin: 3rem auto 0;
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
}

.shop-promo-label {
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 1rem;
}

.shop-promo-grid {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.shop-promo-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem;
    flex: 1;
    min-width: 220px;
    transition: border-color var(--ease), transform var(--ease);
}

.shop-promo-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.shop-promo-img {
    width: 72px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.shop-promo-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.shop-promo-title {
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
}

.shop-promo-price {
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: 0.78rem;
    color: var(--muted);
}

/* ── AdSense unit ────────────────────────────────────────── */
.ad-unit {
    max-width: 1120px;
    margin: 2.5rem auto 0;
}

/* ── Related articles ────────────────────────────────────── */
.related-articles {
    max-width: 1120px;
    margin: 4rem auto 0;
}

.related-title {
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: 1.35rem;
    font-weight: 800;
    margin: 0 0 1.5rem;
    letter-spacing: -.01em;
}

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

.related-card {
    background: var(--card-bg);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform var(--ease), box-shadow var(--ease);
    display: flex;
    flex-direction: column;
}
.related-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.related-img-container {
    height: 140px;
    overflow: hidden;
    background: #e8e4de;
}
.related-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--ease);
}
.related-card:hover .related-img { transform: scale(1.05); }

.related-content {
    padding: 1rem 1.1rem 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.related-card-title {
    font-size: .95rem;
    font-weight: 700;
    margin: 0 0 .75rem;
    line-height: 1.35;
    color: var(--text);
}

.read-more-btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    padding: .4rem .9rem;
    border-radius: 6px;
    font-size: .75rem;
    font-weight: 800;
    text-decoration: none;
    letter-spacing: .06em;
    text-transform: uppercase;
    transition: background var(--ease);
    align-self: flex-start;
}
.read-more-btn:hover { background: #000; color: #fff; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
    .article-body { padding: 2.5rem 2rem; }
    .article-meta  { padding: .8rem 2rem; }
}

@media (max-width: 640px) {
    .content-wrapper { padding: 1.5rem 1rem 4rem; }
    .article-body  { padding: 1.75rem 1.25rem 2rem; }
    .article-meta  { padding: .75rem 1.25rem; flex-direction: column; align-items: flex-start; gap: .4rem; }
    .article-title { font-size: 1.9rem; }
    .article-featured-image { height: 220px; }
    .article-content { font-size: 1.1rem; }
    .article-content pre { padding: 1rem 1rem; font-size: .82rem; }
    .related-grid  { grid-template-columns: 1fr; }
}
