/* assets/css/style.css */

* {
    box-sizing: border-box;
}

:root {
    --bg-color: #f8fafc;
    --text-main: #1e293b;
    --text-sub: #64748b;
    --accent-blue: #0ea5e9;
    --dark-blue: #202f55;
    --border-color: #e2e8f0;
}

img {
    max-width: 100%;
    height: auto;
}

body {
    font-family: "Helvetica Neue", "Arial", "Hiragino Kaku Gothic ProN", sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    line-height: 1.8;
}

/* Navigation */
header {
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

header nav {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
}

.logo {
    font-weight: 800;
    letter-spacing: -0.5px;
    font-size: 1.4rem;
    color: var(--dark-blue);
}

header nav ul {
    list-style: none;
    display: flex;
    gap: 25px;
    margin: 0;
    padding: 0;
}

header nav a {
    text-decoration: none;
    color: var(--text-sub);
    font-size: 0.9rem;
    font-weight: 500;
    transition: 0.3s;
}

header nav a:hover,
header nav a.active {
    color: var(--accent-blue);
}

/* Sections */
main {
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 20px;
}

main section {
    margin-bottom: 50px;
}

main section:last-child {
    margin-bottom: 0;
}

.section-title {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent-blue);
    font-weight: bold;
    margin-bottom: 20px;
}

/* About Grid */
.about-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 40px;
    margin-bottom: 80px;
}

.about-text p {
    margin-top: 0;
    margin-bottom: 1.2rem;
}

.about-stats {
    background: #ffffff;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.stat-item:last-child {
    border: none;
}

.stat-item span:first-child {
    color: var(--text-sub);
}

/* Card Grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 30px;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    border-radius: 12px;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    border-color: var(--accent-blue);
}

.card h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--dark-blue);
}

.card p {
    font-size: 0.95rem;
    color: var(--text-sub);
    margin-bottom: 20px;
}

.card-link {
    font-weight: bold;
    color: var(--accent-blue);
    font-size: 0.9rem;
}

footer {
    text-align: center;
    padding: 30px 0;
    border-top: 1px solid var(--border-color);
    color: var(--text-sub);
    font-size: 0.8rem;
}

/* --- Blog Specific Styles --- */

.archive-header {
    margin-bottom: 40px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 30px;
}

.archive-header h1 {
    font-size: 2.5rem;
    margin: 10px 0;
    font-weight: 800;
}

.tab-nav {
    display: flex;
    gap: 12px;
    margin-bottom: 30px;
    overflow-x: auto;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.tab-button {
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-sub);
    cursor: pointer;
    white-space: nowrap;
    transition: 0.2s;
    border-radius: 6px;
}

.tab-button.active {
    background-color: var(--dark-blue);
    color: #ffffff;
    border-color: var(--dark-blue);
}

.tab-button:hover:not(.active) {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.month-group {
    display: none;
    animation: fadeIn 0.5s ease forwards;
}

.month-group.active {
    display: block;
}

.post {
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 30px;
    margin-bottom: 20px;
    border-radius: 8px;
}

.post-date {
    font-size: 0.8rem;
    color: var(--accent-blue);
    font-weight: bold;
    margin-bottom: 15px;
    font-family: monospace;
}

.post-content {
    font-size: 1rem;
    line-height: 1.8;
    white-space: pre-wrap;
    color: var(--text-main);
}

.loading {
    text-align: center;
    padding: 100px 0;
    color: var(--text-sub);
    font-style: italic;
}

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

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

/* Breadcrumb */
.breadcrumb {
    max-width: 1000px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 15px 0;
    font-size: 0.8rem;
    color: var(--text-sub);
}

.breadcrumb a {
    text-decoration: none;
    color: var(--accent-blue);
    font-size: 0.9rem;
    font-weight: 500;
}

.breadcrumb-separator {
    color: #cbd5e1;
    font-size: 0.7rem;
}

/* --- AtCoder Table Styles --- */

.table-wrapper {
    overflow-x: auto;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
    font-size: 0.9rem;
}

.stats-table th,
.stats-table td {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    vertical-align: middle;
}

.stats-table th {
    background-color: #f8fafc;
    color: var(--text-sub);
    font-weight: 600;
    text-transform: uppercase;
}

.stats-table tr:last-child td {
    border-bottom: none;
}

.detail-link {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: bold;
    border: 1px solid var(--accent-blue);
    padding: 4px 12px;
    border-radius: 4px;
    transition: 0.2s;
}

.detail-link:hover {
    background: var(--accent-blue);
    color: white;
}

/* Card Header */
.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
}

/* Site Icon */
.site-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    object-fit: contain;
}

/* --- Articles List --- */

.search-container {
    margin-bottom: 30px;
}

#tag-filter {
    width: 100%;
    max-width: 400px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.tag-badge {
    display: inline-block;
    background: #e0f2fe;
    color: #0369a1;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-right: 5px;
    margin-top: 5px;
}

.article-card {
    display: block;
    text-decoration: none;
    color: inherit;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 15px;
    transition: 0.2s;
}

.article-card:hover {
    border-color: var(--accent-blue);
    background: #f8fafc;
}

.article-date {
    font-size: 0.8rem;
    color: var(--text-sub);
}

.article-title {
    margin: 8px 0;
    font-size: 1.25rem;
    color: var(--dark-blue);
}

.article-desc {
    font-size: 0.9rem;
    color: var(--text-sub);
    margin-bottom: 10px;
}

/* --- Article Detail --- */

.article-content {
    background: white;
    border: 1px solid var(--border-color);
    padding: 40px;
    border-radius: 8px;
    line-height: 1.8;
    color: var(--text-main);
    min-height: 300px;
    text-align: left;
}

/* AtCoder記事の問題リンク */
#markdown-content h2 a {
    color: var(--dark-blue);
}

#markdown-content h2 a:hover {
    color: var(--accent-blue);
}

/* コードブロック */
.article-content pre,
.article-content pre[class*="language-"] {
    margin: 20px 0;
    padding: 15px;
    border-radius: 6px;
    background: #f2f6fc !important;
    max-width: 100%;
    overflow-x: auto;
}

/* コード本文 */
.article-content code,
.article-content code[class*="language-"] {
    font-family: "Consolas", "Courier New", monospace;
    font-size: 0.9rem;
    color: #1f2937;
    text-shadow: none !important;
}

.article-content pre[class*="language-"] {
    color: #1f2937;
    text-shadow: none !important;
}

/* --- Prism Syntax Highlight --- */

/* コメント */
.article-content .token.comment,
.article-content .token.prolog,
.article-content .token.doctype,
.article-content .token.cdata {
    color: #6b7280 !important;
    font-style: italic;
}

/* 文字列 */
.article-content .token.string,
.article-content .token.char,
.article-content .token.attr-value {
    color: #15803d !important;
}

/* Pythonのif / for / while / def / return / importなど */
.article-content .token.keyword {
    color: #cd4187 !important;
}

/* 数値 */
.article-content .token.number,
.article-content .token.boolean {
    color: #b45309 !important;
}

/* 関数名 */
.article-content .token.function {
    color: #0369a1 !important;
}

/* class名 */
.article-content .token.class-name {
    color: #0f766e !important;
}

/* 演算子 */
.article-content .token.operator {
    color: #be123c !important;
}

/* 記号 */
.article-content .token.punctuation {
    color: #475569 !important;
}

/* built-in */
.article-content .token.builtin {
    color: #0369a1 !important;
}

/* 定数 */
.article-content .token.constant {
    color: #b45309 !important;
}

/* decorator */
.article-content .token.decorator,
.article-content .token.annotation {
    color: #9333ea !important;
}

/* inline code */
.article-content :not(pre) > code {
    background: #f2f6fc;
    color: #be123c;
    padding: 2px 6px;
    border-radius: 4px;
}

/* --- Responsive --- */

@media (max-width: 700px) {
    header nav {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 12px 16px;
    }

    header nav ul {
        width: 100%;
        flex-wrap: wrap;
        gap: 6px 16px;
    }

    main {
        padding: 30px 16px;
    }

    .about-grid {
        grid-template-columns: 1fr;
        gap: 24px;
        margin-bottom: 50px;
    }

    .card-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .archive-header {
        margin-bottom: 30px;
        padding-bottom: 22px;
    }

    .archive-header h1 {
        font-size: 2rem;
    }

    .article-content {
        padding: 24px;
    }

    .post {
        padding: 22px;
    }

    .stats-table th,
    .stats-table td {
        padding: 12px 14px;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 1.2rem;
    }

    header nav a {
        font-size: 0.85rem;
    }

    .archive-header h1 {
        font-size: 1.7rem;
    }

    .article-content {
        padding: 18px;
    }

    .card,
    .post {
        padding: 20px;
    }

    #tag-filter {
        max-width: none;
    }
}

/* --- 2026-08 UI Updates --- */

/* 修正: ロゴをHomeリンクとして扱う */
.logo {
    text-decoration: none;
    transition: color 0.2s ease;
}

.logo:hover {
    color: var(--accent-blue);
}

/* Home: Recent Updates */
.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.section-title-row .section-title {
    margin-bottom: 0;
}

.section-more-link {
    color: var(--accent-blue);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
}

.section-more-link:hover {
    text-decoration: underline;
}

.recent-updates-list {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.recent-update {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    color: inherit;
}

.recent-update:last-child {
    border-bottom: none;
}

.recent-update-link {
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.recent-update-link:hover {
    background: #f8fafc;
}

.recent-update-date {
    color: var(--accent-blue);
    font-family: monospace;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}

.recent-update-content {
    color: var(--text-main);
    font-size: 0.95rem;
    line-height: 1.7;
    white-space: pre-line;
}

.recent-updates-loading {
    padding: 30px 20px;
}

/* Articles: clickable tags / empty state */
.article-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.tag-button {
    font-family: inherit;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.tag-button:hover,
.article-meta-tag:hover {
    background: #bae6fd;
    color: #075985;
}

.empty-state {
    padding: 35px 20px;
    text-align: center;
    color: var(--text-sub);
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

/* Article Detail: date / tags / table of contents */
.article-header {
    margin-bottom: 24px;
}

.article-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 18px;
    margin-top: 14px;
    color: var(--text-sub);
    font-size: 0.85rem;
}

.article-meta[hidden] {
    display: none;
}

.article-meta time {
    font-family: monospace;
}

.article-meta-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.article-meta-tag {
    margin: 0;
    text-decoration: none;
}

.article-toc {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-left: 4px solid #4f6f8f;
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 24px;
}

.article-toc[hidden] {
    display: none;
}

.article-toc-title {
    color: var(--dark-blue);
    font-weight: 700;
    margin-bottom: 10px;
}

.article-toc ol {
    list-style: none;
    margin: 0;
    padding: 0;
}

.article-toc li {
    margin: 5px 0;
    line-height: 1.55;
}

.article-toc .toc-level-2 {
    padding-left: 16px;
}

.article-toc .toc-level-3 {
    padding-left: 32px;
}

.article-toc a {
    color: var(--text-sub);
    text-decoration: none;
    font-size: 0.9rem;
}

.article-toc a:hover {
    color: var(--accent-blue);
    text-decoration: underline;
}

.article-content h1,
.article-content h2,
.article-content h3 {
    scroll-margin-top: 100px;
}

.article-content h1 {
    position: relative;
    margin: 0 0 0.8em;
    padding-bottom: 0.45em;
    border-bottom: 1px solid #d8e0e7;
    color: #243b53;
    font-size: 1.8rem;
}

.article-content h1::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -1px;
    width: 110px;
    height: 3px;
    background: #4f6f8f;
}

.article-content h2 {
    padding: 0.1em 0.8em;
    border-left: 4px solid #4f6f8f;
    color: #243b53;
}

/* AtCoder: Performance / New Ratingのみ色分け */
.rating-value {
    font-weight: 700;
}

.rating-gray { color: #808080; }
.rating-brown { color: #804000; }
.rating-green { color: #008000; }
.rating-cyan { color: #00c0c0; }
.rating-blue { color: #0000ff; }
.rating-yellow { color: #c0c000; }
.rating-orange { color: #ff8000; }
.rating-red { color: #ff0000; }

@media (max-width: 700px) {
    .recent-update {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .article-toc {
        padding: 18px 20px;
    }
}

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

.article-content th,
.article-content td {
    padding: 10px 14px;
    border: 1px solid #ddd;
}

.article-content th {
    background: #f5f5f5;
    font-weight: 600;
}

.article-content tr:nth-child(even) {
    background: #fafafa;
}

.article-content blockquote {
    margin: 1.2em 0;
    padding: 0.8em 1em;
    border-left: 4px solid #4f6f8f;
    background: #f5f7f9;
    color: #444;
    border-radius: 0 6px 6px 0;
}

.article-content blockquote p {
    margin: 0;
}