/* =============================================================================
   article.css — article detail page.

   Loaded only on the public article page (article.jsp), AFTER index.css,
   teacher.css, footer.css, utilities.css and public-polish.css. Builds the
   reading experience on top of the shared design tokens:
     - article hero (breadcrumb, meta chips, title, lead, author)
     - hero image
     - two-column reading layout (body + sticky sidebar w/ TOC & share)
     - author card, tags, related-articles grid

   Nothing in here touches layout of any other page.
   ========================================================================== */

/* ---------------------------------------------------------------------------
   1. Page shell
   --------------------------------------------------------------------------- */

.article-page {
    background: var(--bg-primary);
}

/* ---------------------------------------------------------------------------
   2. Hero
   --------------------------------------------------------------------------- */

.article-hero {
    position: relative;
    overflow: hidden;
    padding: clamp(2rem, 4vw, 3.5rem) 0 2.25rem;
    background:
        radial-gradient(58% 90% at 88% -22%, rgba(32, 77, 72, 0.10), transparent 62%),
        radial-gradient(44% 70% at -6% 12%, rgba(217, 124, 58, 0.08), transparent 60%);
    border-bottom: 1px solid var(--border);
}

[data-theme="dark"] .article-hero {
    background:
        radial-gradient(58% 90% at 88% -22%, rgba(95, 191, 180, 0.12), transparent 62%),
        radial-gradient(44% 70% at -6% 12%, rgba(217, 124, 58, 0.10), transparent 60%);
}

.article-hero-inner {
    max-width: 860px;
}

/* Breadcrumb ---------------------------------------------------------------- */

.article-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.75rem;
    font-size: 0.875rem;
    list-style: none;
}

.article-breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.article-breadcrumb a:hover {
    color: var(--accent-primary);
}

.article-breadcrumb .sep {
    color: var(--text-muted);
    opacity: 0.55;
    font-size: 0.7rem;
    user-select: none;
}

.article-breadcrumb .current {
    color: var(--text-primary);
    font-weight: 600;
    max-width: 24ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Meta chips ---------------------------------------------------------------- */

.article-hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.article-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.38rem 0.9rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1;
    white-space: nowrap;
}

.article-chip i {
    font-size: 0.78rem;
    opacity: 0.9;
}

.article-chip--topic {
    background: var(--polish-accent-teal);
    color: #ffffff;
    box-shadow: 0 6px 18px rgba(32, 77, 72, 0.22);
}

.article-chip--level {
    background: var(--polish-accent-soft);
    color: var(--accent-primary);
}

.article-chip--muted {
    background: var(--surface-2);
    color: var(--text-secondary);
}

/* Title / lead -------------------------------------------------------------- */

.article-hero-title {
    font-size: clamp(2.1rem, 4.6vw, 3.35rem);
    font-weight: 800;
    line-height: 1.12;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
}

.article-hero-lead {
    font-size: 1.2rem;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* Author row ---------------------------------------------------------------- */

.article-hero-author {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.article-hero-author a {
    display: inline-flex;
    align-items: center;
    gap: 0.9rem;
    text-decoration: none;
    color: inherit;
    border-radius: 999px;
}

.article-hero-author img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--surface);
    box-shadow: 0 4px 14px rgba(33, 51, 55, 0.18);
}

.article-hero-author a > span {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.article-hero-author .author-name {
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    transition: color 0.2s ease;
}

.article-hero-author a:hover .author-name {
    color: var(--accent-primary);
}

.article-hero-author .author-date {
    font-size: 0.875rem;
    line-height: 1.2;
    color: var(--text-muted);
}

/* Hero image ---------------------------------------------------------------- */

.article-hero-figure {
    margin: 2rem 0 0;
    border-radius: var(--polish-radius-lg);
    overflow: hidden;
    box-shadow: var(--polish-shadow-lg);
    background: var(--surface-2);
    line-height: 0;
}

.article-hero-figure img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 540px;
    object-fit: cover;
}

/* ---------------------------------------------------------------------------
   3. Reading layout (body + sidebar)
   --------------------------------------------------------------------------- */

.article-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: clamp(2rem, 4vw, 3.5rem);
    align-items: start;
    padding: clamp(2.5rem, 5vw, 4rem) 0 0;
}

.article-main {
    min-width: 0;
    max-width: 720px;
}

.article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 2.5rem;
    padding-top: 1.75rem;
    border-top: 1px solid var(--border);
}

.article-tags .tag-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.article-tags .tag-item {
    cursor: default;
}

/* Sidebar ------------------------------------------------------------------- */

.article-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: sticky;
    top: 5.5rem;
}

.article-widget {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--polish-radius-md);
    box-shadow: var(--polish-shadow-sm);
    padding: 1.35rem;
}

.article-widget-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.article-widget-title i {
    color: var(--accent-primary);
}

/* Table of contents --------------------------------------------------------- */

.article-toc ol {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.article-toc a {
    display: block;
    padding: 0.4rem 0.65rem;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    line-height: 1.45;
    border-inline-start: 2px solid transparent;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.article-toc a:hover {
    color: var(--accent-primary);
    background: var(--polish-accent-soft);
}

.article-toc a.is-active {
    color: var(--accent-primary);
    background: var(--polish-accent-soft);
    border-inline-start-color: var(--accent-primary);
    font-weight: 600;
}

.article-toc a.toc-h3 {
    padding-inline-start: 1.6rem;
    font-size: 0.84rem;
}

/* Share --------------------------------------------------------------------- */

.article-share {
    display: flex;
    gap: 0.5rem;
}

.article-share .share-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease,
                transform 0.2s ease;
}

.article-share .share-btn:hover {
    color: #ffffff;
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.article-share .share-btn.is-copied {
    color: #ffffff;
    background: var(--success);
    border-color: var(--success);
}

/* ---------------------------------------------------------------------------
   4. Author card (full width, below the body)
   --------------------------------------------------------------------------- */

.article-author-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.5rem;
    margin-top: clamp(2.5rem, 5vw, 4rem);
    padding: 2rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--polish-radius-lg);
    box-shadow: var(--polish-shadow-md);
}

.article-author-card .author-avatar {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--surface);
    box-shadow: 0 10px 26px rgba(33, 51, 55, 0.18);
    flex-shrink: 0;
}

.article-author-card .author-body {
    flex: 1;
    min-width: 220px;
}

.article-author-card .author-eyebrow {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-primary);
    margin-bottom: 0.35rem;
}

.article-author-card .author-name {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.article-author-card .author-bio {
    color: var(--text-secondary);
    line-height: 1.65;
}

.article-author-card .btn {
    flex-shrink: 0;
}

/* ---------------------------------------------------------------------------
   5. Related articles
   --------------------------------------------------------------------------- */

.article-related {
    padding: clamp(2.5rem, 5vw, 4rem) 0 clamp(3rem, 6vw, 5rem);
    margin-top: clamp(2rem, 4vw, 3rem);
    background: var(--bg-secondary);
}

.article-related .section-heading {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 2rem;
}

.article-related .section-heading i {
    color: var(--accent-primary);
    font-size: 1.4rem;
}

.article-related .section-heading h2 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0;
}

/* Keep the author/read-time row aligned to the bottom of every card, so cards
   of different title/summary length still line up at the same level. */
.article-related .article-card {
    display: flex;
    flex-direction: column;
}

.article-related .article-content {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.article-related .article-meta-padded {
    margin-top: auto;
    padding-top: 1.5rem;
}

/* ---------------------------------------------------------------------------
   6. Responsive
   --------------------------------------------------------------------------- */

@media (max-width: 992px) {
    .article-layout {
        grid-template-columns: 1fr;
    }

    .article-sidebar {
        position: static;
        order: 2;
    }

    .article-main {
        order: 1;
    }
}

@media (max-width: 640px) {
    .article-hero-author img {
        width: 42px;
        height: 42px;
    }

    .article-author-card {
        padding: 1.5rem;
        flex-direction: column;
        align-items: flex-start;
    }

    .article-author-card .btn {
        width: 100%;
    }
}
