/* ============================================
   Custom Design Overrides for PaperMod
   Modern, clean, and readable
   ============================================ */

/* --- Layout & Spacing --- */
:root {
    --main-width: 860px;
    --nav-width: 1100px;
    --gap: 28px;
    --radius: 10px;
}

/* --- Color refinements --- */
:root {
    --theme: #fafafa;
    --entry: #ffffff;
    --primary: #1a1a2e;
    --secondary: #6b7280;
    --tertiary: #e5e7eb;
    --border: #e5e7eb;
    --accent: #4f46e5;
    --accent-light: #818cf8;
    --code-block-bg: #1e1e2e;
    --code-bg: #f1f5f9;
}

:root[data-theme="dark"] {
    --theme: #0f172a;
    --entry: #1e293b;
    --primary: #e2e8f0;
    --secondary: #94a3b8;
    --tertiary: #334155;
    --border: #334155;
    --accent: #818cf8;
    --accent-light: #a5b4fc;
    --code-block-bg: #1e293b;
    --code-bg: #334155;
}

/* --- Typography --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP",
        "Hiragino Kaku Gothic ProN", sans-serif;
    letter-spacing: 0.01em;
    -webkit-font-smoothing: antialiased;
}

.post-content {
    font-size: 16.5px;
    line-height: 1.85;
    color: var(--content);
}

.post-content h1 { font-size: 1.9em; margin-top: 2em; }
.post-content h2 { font-size: 1.5em; margin-top: 1.8em; padding-bottom: 0.3em; border-bottom: 1px solid var(--border); }
.post-content h3 { font-size: 1.25em; margin-top: 1.5em; }

/* --- Header / Navigation --- */
.nav {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

header.header {
    background: rgba(250, 250, 250, 0.85);
    border-bottom: 1px solid var(--border);
}

[data-theme="dark"] header.header {
    background: rgba(15, 23, 42, 0.85);
}

#menu a {
    font-size: 15px;
    font-weight: 500;
    padding: 4px 0;
    transition: color 0.2s;
}

#menu a:hover {
    color: var(--accent);
}

#menu .active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* --- Post List Cards --- */
.post-entry {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--entry);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.post-entry:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .post-entry:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.post-entry:active {
    transform: scale(0.99);
}

.entry-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
}

/* --- Tags --- */
.post-tags a {
    display: inline-block;
    background: var(--code-bg);
    color: var(--secondary);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
    border: none;
}

.post-tags a:hover {
    background: var(--accent);
    color: #fff;
}

/* Tags list page */
.terms-tags a {
    display: inline-block;
    padding: 6px 14px;
    margin: 4px;
    background: var(--entry);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
}

.terms-tags a:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.terms-tags li {
    display: inline-block;
}

/* --- Code Blocks --- */
.post-content pre {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1em;
}

[data-theme="dark"] .post-content pre {
    border-color: var(--tertiary);
}

.post-content code {
    font-family: "JetBrains Mono", "Fira Code", "SF Mono", Menlo, monospace;
    font-size: 0.88em;
}

.post-content :not(pre) > code {
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.88em;
}

.copy-code {
    border-radius: 6px !important;
    font-size: 12px !important;
}

/* --- Breadcrumbs --- */
.breadcrumbs {
    font-size: 13px;
    color: var(--secondary);
    margin-bottom: 0.5rem;
}

/* --- Table of Contents --- */
.toc {
    background: var(--code-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1em 1.5em;
    margin-bottom: 1.5em;
}

/* --- Footer --- */
.footer {
    border-top: 1px solid var(--border);
}

/* --- Post Navigation --- */
.paginav {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.paginav a {
    transition: background 0.2s;
}

.paginav a:hover {
    background: var(--code-bg);
}

/* --- Page Header --- */
.page-header h1 {
    font-size: 2rem;
    font-weight: 700;
}

.post-header h1 {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.3;
}

.post-meta {
    color: var(--secondary);
    font-size: 14px;
}

/* --- Search --- */
.pagefind-ui__search-input {
    border-radius: var(--radius) !important;
    border: 1px solid var(--border) !important;
    padding: 12px 16px 12px 44px !important;
    font-size: 16px !important;
}

.pagefind-ui__search-clear {
    right: 12px !important;
}

.pagefind-ui__result {
    border-radius: var(--radius) !important;
    padding: 1em !important;
}

/* --- Smooth Scrolling --- */
html {
    scroll-behavior: smooth;
}

/* --- Selection --- */
::selection {
    background: var(--accent);
    color: #fff;
}

/* --- Go to Top Button --- */
.top-link {
    border-radius: 50% !important;
    width: 44px;
    height: 44px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border) !important;
    background: var(--entry) !important;
}

/* --- Language Switcher --- */
.lang-switch a {
    padding: 2px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.lang-switch a:hover {
    background: var(--code-bg);
}

/* --- Category Cards --- */
.category-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.category-card {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 1.5rem;
    text-align: center;
    text-decoration: none;
    color: var(--primary);
    background: var(--entry);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s, box-shadow 0.2s;
}

.category-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .category-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.category-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.75rem;
}

.category-name {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
    text-transform: capitalize;
}

.category-count {
    font-size: 0.95rem;
    color: var(--secondary);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .post-content {
        font-size: 15.5px;
        line-height: 1.8;
    }
    .post-header h1 {
        font-size: 1.6rem;
    }
}
