/* Mercury SPA custom styles.
 * Input: static HTML rendered by public/index.html.
 * Output: visual states, animations, and markdown content styling.
 */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d6d3d1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a29e;
}

.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24;
}

.material-symbols-outlined.fill {
    font-variation-settings: 'FILL' 1, 'wght' 300, 'GRAD' 0, 'opsz' 24;
}

body.h-screen {
    height: 100dvh;
}

#scroll-container {
    -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.6s ease-out forwards;
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }

    100% {
        background-position: 1000px 0;
    }
}

.animate-shimmer {
    animation: shimmer 2s infinite linear;
    background: linear-gradient(to right, #f0f0f0 4%, #e0e0e0 25%, #f0f0f0 36%);
    background-size: 1000px 100%;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

.text-justify-cn {
    text-align: justify;
    text-justify: inter-character;
    overflow-wrap: break-word;
}

.article-card h2,
#articles-container > article h1 {
    text-wrap: balance;
}

.summary-text {
    text-wrap: pretty;
}

.text-justify-cn,
.summary-text,
.explanation-content {
    text-spacing-trim: trim-start;
}

#sidebar {
    transition: width 0.3s ease-in-out;
}

.article-card {
    width: 100%;
    max-width: 680px;
    margin-inline: auto;
    opacity: 0;
    animation: fadeIn 0.6s ease-out forwards;
}

.article-thumbnail {
    width: 100%;
}

@media (min-width: 1024px) {
    .article-thumbnail {
        max-width: 520px;
        margin-inline: auto;
    }
}

/* 字体加载前隐藏图标 */
body.fonts-loading .material-symbols-outlined,
body.fonts-loading .source-icon {
    opacity: 0;
    visibility: hidden;
}

/* 字体加载后显示图标 */
body.fonts-loaded .material-symbols-outlined,
body.fonts-loaded .source-icon {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease;
}

/* 低分内容区域样式 */
.low-score-section {
    opacity: 0;
    animation: fadeIn 0.6s ease-out forwards;
    animation-delay: 0.3s;
}

#low-score-articles {
    transition: opacity 0.3s ease-in-out;
}

#low-score-articles.hiding {
    opacity: 0;
}

/* 低分内容卡片的淡化效果 */
.low-score-section .article-card {
    opacity: 0;
    animation: fadeIn 0.5s ease-out forwards;
}

.explanation-content h2 {
    font-family: "Noto Serif SC", "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", "Source Serif 4", serif;
    font-size: 1.875rem;
    line-height: 1.35;
    margin: 2rem 0 1rem;
    color: #202020;
}

.explanation-content h1 {
    font-family: "Noto Serif SC", "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", "Source Serif 4", serif;
    font-size: 1.875rem;
    line-height: 1.35;
    margin: 2rem 0 1rem;
    color: #202020;
}

.explanation-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
    margin: 1.75rem 0 0.75rem;
    color: #202020;
}

.explanation-content h4 {
    font-size: 1.0625rem;
    font-weight: 600;
    line-height: 1.45;
    margin: 1.5rem 0 0.625rem;
    color: #202020;
}

.explanation-content h1:first-child,
.explanation-content h2:first-child,
.explanation-content h3:first-child {
    margin-top: 0;
}

.explanation-content {
    overflow-wrap: break-word;
}

.explanation-content p,
.explanation-content li {
    color: #3a3a3a;
    line-height: 1.9;
    font-size: 1.0625rem;
}

.explanation-content p {
    margin: 0 0 1em;
}

.explanation-content li + li {
    margin-top: 0.375em;
}

.explanation-content ul {
    margin: 0.75rem 0 1.5rem;
    padding-left: 1.25rem;
    list-style: disc;
}

.explanation-content ol {
    margin: 0.75rem 0 1.5rem;
    padding-left: 1.25rem;
    list-style: decimal;
}

.explanation-content a {
    color: #5d7c68;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.explanation-content code {
    background: #f2f0eb;
    border-radius: 0.25rem;
    font-size: 0.875em;
    padding: 0.125em 0.375em;
}

.explanation-content pre {
    margin: 1rem 0 1.5rem;
    overflow-x: auto;
    padding: 1rem;
    background: #f2f0eb;
    border-radius: 0.5rem;
}

.explanation-content pre code {
    background: transparent;
    border-radius: 0;
    padding: 0;
}

.explanation-content table {
    width: 100%;
    margin: 1rem 0 1.5rem;
    border-collapse: collapse;
}

.explanation-content th,
.explanation-content td {
    border: 1px solid #e5e5e0;
    padding: 0.625rem 0.75rem;
}

.explanation-content th {
    text-align: left;
    font-weight: 600;
}

.explanation-content hr {
    margin: 2rem 0;
    border: 0;
    border-top: 1px solid #e5e5e0;
}

.explanation-content img {
    max-width: 100%;
    height: auto;
    border-radius: 0.75rem;
}

.explanation-content blockquote {
    margin: 1.25rem 0;
    padding: 1rem 1.25rem;
    border-left: 3px solid #dcb67a;
    background: #faf9f7;
    color: #3a3a3a;
}

@media (max-width: 640px) {
    .page-shell.page-shell {
        padding: 1rem 0 calc(6rem + env(safe-area-inset-bottom));
    }

    #articles-container {
        gap: 1rem;
        padding-bottom: 0;
    }

    .article-card.article-card {
        border-radius: 0.875rem;
        padding: 1rem;
        max-width: calc(100% - 1.5rem);
    }

    #articles-container > .detail-article {
        border-left: 0;
        border-right: 0;
        border-radius: 0;
        box-shadow: none;
        padding: 1.25rem 1.25rem 2rem;
        max-width: 100%;
    }

    .detail-title {
        font-size: 1.875rem;
        line-height: 1.25;
    }

    .detail-article .summary-text {
        font-size: 0.9375rem;
        line-height: 1.75;
    }

    .explanation-content h1,
    .explanation-content h2 {
        font-size: 1.5rem;
        line-height: 1.35;
        margin: 1.75rem 0 0.875rem;
    }

    .explanation-content h3 {
        font-size: 1.125rem;
        margin: 1.5rem 0 0.625rem;
    }

    .explanation-content h4 {
        font-size: 1rem;
        margin: 1.25rem 0 0.5rem;
    }

    .explanation-content p,
    .explanation-content li {
        font-size: 1rem;
        line-height: 1.8;
    }

    .explanation-content p {
        margin-bottom: 0.875em;
    }

    .explanation-content ul,
    .explanation-content ol {
        padding-left: 1.15rem;
    }

    .explanation-content blockquote {
        padding: 0.875rem 1rem;
    }
}
