/* =========================================================================
   學科園地文章內容頁專屬樣式 (assets/css/subject-single.css)
   對應範本：學科園地文章頁 (Subject Single)
   ========================================================================= */

html,
body {
    overflow-x: clip !important;
}

/* =========================================================================
   頂部 Hero Banner（保留原本設計風格）
   ========================================================================= */
.subj-hero {
    position: relative;
    background-color: #1e293b;
    color: #ffffff;
    padding: 4rem 0;
    overflow: hidden;
}

@media (min-width: 640px) {
    .subj-hero {
        padding: 6rem 0;
    }
}

.subj-hero__bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    opacity: 0.8;
    background-size: cover;
    background-position: center;
}

.subj-hero__overlay {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: linear-gradient(
        to right,
        rgba(2, 6, 23, 0.65) 0%,
        rgba(15, 23, 42, 0.3) 50%,
        transparent 100%
    );
}

.subj-hero__inner {
    position: relative;
    z-index: 10;
}

/* 麵包屑導航 */
.subj-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #e2e8f0;
    overflow-x: auto;
    white-space: nowrap;
}

@media (min-width: 640px) {
    .subj-breadcrumb {
        font-size: 0.875rem;
    }
}

.subj-breadcrumb a {
    color: #e2e8f0;
    text-decoration: none;
    transition: color 0.2s ease;
}

.subj-breadcrumb a:hover {
    color: var(--school-gold, #DAA520);
}

.subj-breadcrumb__current {
    color: #f1f5f9;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
}

.subj-hero__content {
    max-width: 48rem;
    padding-top: 0.5rem;
    margin-top: 1rem;
}

.subj-hero__badge {
    display: inline-block;
    background-color: rgba(218, 165, 32, 0.95);
    color: #0f172a;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.875rem;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

@media (min-width: 640px) {
    .subj-hero__badge {
        font-size: 0.875rem;
    }
}

.subj-hero__title {
    margin: 0.75rem 0 0;
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: -0.025em;
    color: #ffffff;
    line-height: 1.2;
}

@media (min-width: 640px) {
    .subj-hero__title {
        font-size: 2.25rem;
    }
}

@media (min-width: 1024px) {
    .subj-hero__title {
        font-size: 3rem;
    }
}

.subj-hero__excerpt {
    margin: 0.75rem 0 0;
    padding-top: 0.25rem;
    max-width: 42rem;
    color: #e2e8f0;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.625;
    opacity: 0.95;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (min-width: 640px) {
    .subj-hero__excerpt {
        font-size: 1rem;
    }
}

/* =========================================================================
   主要內容區與左右雙欄版面（左側 8 欄文章 + 右側 4 欄相關文章）
   ========================================================================= */
.subj-main {
    padding: 2rem 0 3rem;
}

@media (min-width: 640px) {
    .subj-main {
        padding: 3rem 0 4rem;
    }
}

.subj-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    align-items: start;
}

@media (min-width: 1024px) {
    .subj-layout {
        grid-template-columns: repeat(12, minmax(0, 1fr));
    }
}

/* 左側：文章主內容卡片 */
.subj-article {
    background-color: #ffffff;
    border-radius: 1.5rem;
    overflow: hidden;
    border: 1px solid #f1f5f9;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.06), 0 4px 10px -6px rgba(15, 23, 42, 0.04);
    padding: 1.5rem;
    min-width: 0;
}

@media (min-width: 640px) {
    .subj-article {
        padding: 2.5rem;
    }
}

@media (min-width: 1024px) {
    .subj-article {
        grid-column: span 8 / span 8;
    }
}

/* 文章內文基礎排版 */
.subj-prose {
    max-width: none;
    color: #334155;
    line-height: 1.75;
}

.subj-prose > * + * {
    margin-top: 1.25rem;
}

.subj-prose h2,
.subj-prose h3,
.subj-prose h4 {
    color: #0f172a;
    font-weight: 700;
    line-height: 1.35;
}

.subj-prose a {
    color: var(--school-green, #4D602B);
    text-decoration: underline;
}

.subj-prose ul,
.subj-prose ol {
    padding-left: 1.5rem;
}

.subj-prose li + li {
    margin-top: 0.4rem;
}

.subj-prose img {
    max-width: 100%;
    height: auto;
    border-radius: 0.75rem;
}

.subj-prose table {
    width: 100%;
    border-collapse: collapse;
}

.subj-prose table th,
.subj-prose table td {
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
}

/* =========================================================================
   右側：相關文章 Sticky Sidebar
   ========================================================================= */
.subj-sidebar {
    background-color: #ffffff;
    border-radius: 1.5rem;
    padding: 1.5rem;
    border: 1px solid #f1f5f9;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.06), 0 4px 10px -6px rgba(15, 23, 42, 0.04);
    position: sticky;
    top: 6rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

@media (min-width: 1024px) {
    .subj-sidebar {
        grid-column: span 4 / span 4;
    }
}

.subj-sidebar__head {
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 0.75rem;
}

.subj-sidebar__cat {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: #64748b;
}

.subj-sidebar__title {
    margin: 0.125rem 0 0;
    font-size: 1.25rem;
    font-weight: 900;
    color: #0f172a;
}

.subj-related-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-height: 80vh;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.subj-related-item {
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 1.25rem;
}

.subj-related-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.subj-related-link {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    text-decoration: none;
}

.subj-related-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 1rem;
    overflow: hidden;
    background-color: #f1f5f9;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.subj-related-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

.subj-related-link:hover .subj-related-thumb img {
    transform: scale(1.05);
}

.subj-related-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f1f5f9;
    color: #cbd5e1;
    font-size: 1.875rem;
}

.subj-related-title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s ease;
}

.subj-related-link:hover .subj-related-title,
.subj-related-title.is-current {
    color: var(--school-green, #4D602B);
}

.subj-related-empty {
    margin: 0;
    font-size: 0.875rem;
    color: #94a3b8;
}