/* === ARTICLE HERO (STICKY TEXT + OVERLAY IMAGE) === */
.article-hero {
    position: relative;
    width: 100%;
    padding-top: 56px;
}

.article-header {
    position: sticky;
    top: 60px;
    width: 100%;
    height: 32vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0 24px;
    z-index: 1;
}

.article-date {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: rgba(var(--text-rgb), 0.65);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.article-title {
    text-align: center;
    max-width: 1000px;
    font-size: clamp(2.2rem, 5vw, 4rem);
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin: 0;
}

.featured-image-wrapper {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 0 4vw;
}

.featured-image-wrapper img {
    display: block;
    width: 100%;
    /* 16:9 on the image itself, so the horizontal padding above can't skew it. */
    aspect-ratio: 16 / 9;
    height: auto;
    object-fit: cover;
    border-radius: 1.5rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

/* === TOOLBAR & TOC (ACCORDION) === */
.toolbar-wrapper {
    max-width: 800px;
    margin: 1rem auto 3rem auto;
    padding: 0 24px;
    position: relative;
    z-index: 10;
}

.article-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid rgba(var(--text-rgb), 0.1);
}

.toc-toggle {
    background: none;
    border: none;
    font-family: var(--font);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

.toc-toggle:hover { color: var(--accent); }
.toc-toggle svg { transition: transform 0.3s ease; }
.toc-toggle.open svg { transform: rotate(180deg); }

.toc-dropdown {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.toc-dropdown.open {
    grid-template-rows: 1fr;
}

.toc-dropdown-inner {
    overflow: hidden;
}

.toc-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0;
    padding: 1.5rem 0;
}

.toc-item { position: relative; }

.toc-item::before {
    content: '';
    position: absolute;
    left: -16px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toc-item a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    opacity: 0.6;
    transition: all 0.2s ease;
    display: block;
    line-height: 1.3;
}

.toc-item:hover a, .toc-item.active a { opacity: 1; color: var(--accent); transform: translateX(4px); }
.toc-item.active a { font-weight: 800; }
.toc-item.active::before { transform: translateY(-50%) scale(1); }
.toc-item.depth-h3 { padding-left: 16px; font-size: 0.9rem; }

.share-actions { display: flex; gap: 12px; align-items: center; }

.copy-feedback {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent);
    opacity: 0;
    transform: translateX(6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
    white-space: nowrap;
}

.copy-feedback.show {
    opacity: 1;
    transform: translateX(0);
}

.share-icon {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: all 0.2s ease;
}

.share-icon:hover { opacity: 1; color: var(--accent); transform: translateY(-2px); }
.share-icon svg { width: 20px; height: 20px; }

/* === POST CONTENT TYPOGRAPHY & ELEMENTS === */
.article-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 24px;
    font-size: 1.15rem;
    line-height: 1.75;
    opacity: 0.95;
}

.article-content p {
    margin-bottom: 1.8rem;
}

.article-content h2 {
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    font-weight: 900;
    letter-spacing: -0.01em;
    margin: 3.5rem 0 1.5rem 0;
    line-height: 1.2;
}

.article-content h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 2rem 0 1rem 0;
}

.article-content h4 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 1.5rem 0 0.5rem 0;
}

.article-content p a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
    box-shadow: inset 0 -3px 0 var(--accent-light);
    transition: all 0.2s ease;
    padding: 0 0.1em;
}

.article-content p a:hover {
    box-shadow: inset 0 -1.5em 0 var(--accent-light);
    color: var(--text);
}

.abstract {
    background-color: var(--card-bg);
    padding: 2.5rem;
    border-radius: 1.5rem;
    margin-bottom: 4rem;
}

.abstract p {
    margin-bottom: 1.25rem;
    font-size: 1.2rem;
    line-height: 1.6;
}

.abstract p:last-child { margin-bottom: 0; }

.abstract strong {
    color: var(--accent);
    font-weight: 900;
    font-size: 1.3rem;
}

.article-content ul:not(.toc-list), .article-content ol:not(.toc-list) {
    margin-bottom: 1.8rem;
    padding-left: 1.5rem;
}

.article-content li { margin-bottom: 0.5rem; }

.article-content blockquote {
    margin: 3rem 0;
    padding: 2.5rem;
    background: var(--card-bg);
    border-radius: 1.5rem;
    font-style: italic;
    text-align: center;
}

.article-content blockquote p {
    margin-bottom: 1rem;
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--accent);
}

.article-content blockquote footer {
    font-style: normal;
    font-size: 1rem;
    font-weight: 700;
    opacity: 0.8;
}

.article-content figure { margin: 3rem 0; }

.article-content figure img {
    border-radius: 1.5rem;
    box-shadow: var(--shadow-out);
    width: 100%;
    /* Keep the intrinsic ratio from the width/height attributes: without
       height:auto the attribute height would apply literally and stretch. */
    height: auto;
    display: block;
}

.article-content figcaption {
    font-size: 0.9rem;
    opacity: 0.7;
    text-align: center;
    margin-top: 1rem;
    font-weight: 600;
}

.article-content figure.image-breakout {
    width: 100vw;
    max-width: var(--content-max-width);
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    margin: 4rem 0;
    padding: 0 4vw;
}

.article-content figure.image-breakout img {
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    width: 100%;
    height: auto;
    border-radius: 1.5rem;
    display: block;
}

.article-content hr {
    border: none;
    height: 2px;
    background: var(--card-bg);
    margin: 3rem 0;
}

.article-content pre {
    background: var(--text);
    color: var(--bg);
    padding: 1.5rem;
    border-radius: 1rem;
    overflow-x: auto;
    font-family: monospace;
    font-size: 0.95rem;
    margin-bottom: 1.8rem;
    box-shadow: inset 2px 2px 8px rgba(0, 0, 0, 0.4);
}

.article-content :not(pre) > code {
    background: var(--card-bg);
    padding: 0.2em 0.4em;
    border-radius: 0.4em;
    font-family: monospace;
    font-size: 0.9em;
}

/* Tables are wrapped in .table-scroll by article-page.js so wide tables
   scroll horizontally on small screens instead of widening the page. */
.article-content .table-scroll {
    overflow-x: auto;
    margin: 2.5rem 0;
    border-radius: 1rem;
}

.article-content table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow-out);
    border: none !important;
}

.article-content th, .article-content td {
    padding: 1rem 1.25rem !important;
    border: none !important;
}

.article-content th {
    background-color: var(--text);
    color: var(--bg);
    font-weight: 700;
    text-align: left;
}

.article-content tr:nth-child(even) { background-color: var(--card-bg); }

/* === READ NEXT === */
.read-next-section {
    max-width: 1200px;
    margin: 6rem auto 0 auto;
    padding: 4rem 24px 0 24px;
    border-top: 1px solid rgba(var(--text-rgb), 0.1);
    width: 100%;
}

.read-next-title {
    font-size: 1.8rem;
    font-weight: 900;
    margin-bottom: 2.5rem;
    color: var(--text);
    text-align: center;
}

.read-next-card {
    display: flex;
    flex-direction: row;
    gap: 3rem;
    align-items: center;
    text-decoration: none;
    color: inherit;
    background-color: var(--bg);
    padding: 1.5rem;
    border-radius: 2rem;
    box-shadow: 10px 10px 20px rgba(26, 26, 26, 0.05), -10px -10px 20px var(--neu-hi);
    transition: box-shadow 0.2s ease;
}

.read-next-card:active {
    box-shadow: inset 6px 6px 12px rgba(26, 26, 26, 0.05), inset -6px -6px 12px var(--neu-hi);
}

.read-next-card .card-image {
    width: 45%;
    aspect-ratio: 16 / 9;
    border-radius: 1rem;
    overflow: hidden;
    background-color: var(--card-bg);
    flex-shrink: 0;
}

.read-next-card .card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.read-next-card:hover .card-image img { transform: scale(1.03); }

.read-next-card .card-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-right: 2rem;
}

.read-next-card .card-title {
    font-size: clamp(1.4rem, 2.5vw, 1.8rem);
    font-weight: 800;
    line-height: 1.3;
    color: var(--text);
    transition: color 0.3s ease;
    margin: 0;
}

.read-next-card:hover .card-title { color: var(--accent); }

.read-next-card .card-desc {
    font-size: 1.1rem;
    opacity: 0.8;
    line-height: 1.6;
    margin: 0;
}

@media (max-width: 768px) {
    .read-next-card { flex-direction: column; gap: 1.5rem; }
    .read-next-card .card-image { width: 100%; }
    .read-next-card .card-content { padding-right: 0; }
}
