/* ===========================
   JetBrains Mono Font
   =========================== */
@font-face {
    font-family: 'JetBrains Mono';
    src: url('./vendor/fonts/JetBrainsMono-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'JetBrains Mono';
    src: url('./vendor/fonts/JetBrainsMono-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* ===========================
   Markdown Post Page Layout
   =========================== */

.post-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 110px 24px 80px;
}

.post-page__back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 40px;
    transition: color 0.25s ease;
}

.post-page__back:hover {
    color: var(--primary);
}

.post-page__back svg {
    width: 16px;
    height: 16px;
}

/* ===========================
   Markdown Body Typography
   =========================== */

.markdown-body {
    font-size: 1.05rem;
    line-height: 1.85;
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Headings */
.markdown-body h1 {
    font-size: 2.5rem;
    font-weight: 700; /* Bold */
    margin: 0 0 24px;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.markdown-body h2 {
    font-size: 2rem;
    font-weight: 650; /* Demibold */
    margin: 48px 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--divider);
    letter-spacing: -0.01em;
}

.markdown-body h3 {
    font-size: 1.5rem;
    font-weight: 600; /* Semibold */
    margin: 36px 0 12px;
}

.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 28px 0 8px;
    color: var(--text-secondary);
}

/* Paragraphs */
.markdown-body p {
    margin: 0 0 20px;
}

/* Links */
.markdown-body a {
    color: var(--text-primary);
    font-weight: 500;
    text-decoration: underline;
    text-decoration-color: var(--text-secondary);
    text-underline-offset: 3px;
    transition: text-decoration-color 0.25s ease;
}

.markdown-body a:hover {
    color: var(--primary);
    text-decoration-color: var(--primary);
}

/* Lists */
.markdown-body ul,
.markdown-body ol {
    margin: 0 0 20px;
    padding-left: 24px;
}

.markdown-body ul {
    list-style: disc;
}

.markdown-body ol {
    list-style: decimal;
}

.markdown-body li {
    margin-bottom: 6px;
}

.markdown-body li>ul,
.markdown-body li>ol {
    margin-top: 6px;
    margin-bottom: 0;
}

/* Blockquote */
.markdown-body blockquote {
    margin: 0 0 20px;
    padding: 12px 20px;
    border-left: 3px solid var(--text-secondary);
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-radius: 0 8px 8px 0;
}

.markdown-body blockquote p:last-child {
    margin-bottom: 0;
}

/* Code (inline) */
.markdown-body code {
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
    font-size: 0.88em;
    background: var(--tag-bg);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Code (block) */
.markdown-body pre {
    margin: 0 0 24px;
    padding: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow-x: auto;
    font-size: 0.88rem;
    line-height: 1.65;
}

.markdown-body pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
}

/* Horizontal rule */
.markdown-body hr {
    border: none;
    height: 1px;
    background: var(--divider);
    margin: 40px 0;
}

/* Images */
.markdown-body img {
    border-radius: 10px;
    margin: 24px 0;
    box-shadow: var(--shadow-card);
}

/* Tables */
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 24px;
    font-size: 0.92rem;
}

.markdown-body th,
.markdown-body td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--divider);
}

.markdown-body th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.markdown-body tbody tr:hover {
    background: var(--bg-secondary);
}

/* ===========================
   404 Error State
   =========================== */

.error-state {
    text-align: center;
    padding: 120px 24px;
}

.error-state__code {
    font-size: 5rem;
    font-weight: 800;
    color: var(--border-color);
    line-height: 1;
    margin-bottom: 16px;
}

.error-state__message {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.error-state__link {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    border-bottom: 1px solid var(--text-secondary);
    padding-bottom: 2px;
    transition: border-color 0.25s ease;
}

.error-state__link:hover {
    border-color: var(--text-primary);
}

/* ===========================
   Loading Skeleton
   =========================== */

.loading-skeleton {
    animation: pulse 1.8s ease-in-out infinite;
}

.loading-skeleton .skel-line {
    height: 14px;
    background: var(--tag-bg);
    border-radius: 6px;
    margin-bottom: 16px;
}

.loading-skeleton .skel-line:nth-child(1) {
    width: 50%;
    height: 28px;
    margin-bottom: 24px;
}

.loading-skeleton .skel-line:nth-child(2) {
    width: 100%;
}

.loading-skeleton .skel-line:nth-child(3) {
    width: 92%;
}

.loading-skeleton .skel-line:nth-child(4) {
    width: 78%;
}

.loading-skeleton .skel-line:nth-child(5) {
    width: 85%;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* ===========================
   Video & Embeds
   =========================== */

.video-container {
    position: relative;
    padding-bottom: 56.25%;
    /* 16:9 Aspect Ratio */
    height: 0;
    overflow: hidden;
    max-width: 100%;
    margin: 24px 0;
    border-radius: 12px;
    box-shadow: var(--shadow-card);
    background: var(--bg-secondary);
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ===========================
   Post Meta & Navigation
   =========================== */

.post-meta {
    margin-bottom: 24px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.meta-divider {
    opacity: 0.5;
}

.meta-tag {
    background: var(--tag-bg);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.post-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 60px;
    padding-top: 30px;
    border-top: 1px solid var(--divider);
    gap: 16px;
}

.post-navigation.hidden {
    display: none;
}

.nav-link {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    text-decoration: none !important;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-link:hover {
    opacity: 0.8;
}

.nav-link.hidden {
    visibility: hidden;
    pointer-events: none;
}

#nav-prev {
    text-align: left;
    align-items: flex-start;
}

#nav-next {
    text-align: right;
    align-items: flex-end;
}

.nav-home {
    text-align: center;
    align-items: center;
    flex: 0.5;
}

.nav-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.nav-title {
    font-weight: 600;
    font-size: 1.05rem;
    line-height: 1.4;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (max-width: 600px) {
    .post-navigation {
        flex-direction: column;
        gap: 32px;
    }

    #nav-prev,
    #nav-next,
    .nav-home {
        text-align: center;
        align-items: center;
        width: 100%;
    }
}

/* ===========================
   Obsidian-style Highlights
   =========================== */

.markdown-body mark {
    background-color: rgba(255, 222, 0, 0.4);
    color: inherit;
    padding: 0.1em 0.2em;
    border-radius: 3px;
    margin: 0 0.1em;
}

[data-theme="dark"] .markdown-body mark {
    background-color: rgba(255, 222, 0, 0.2);
    color: #ffd60a;
}

/* ===========================
   Obsidian-style Callouts
   =========================== */

.callout {
    margin: 1.5em 0;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Callout Types Styling */
.callout--info { --callout-color: #007aff; --callout-bg: rgba(0, 122, 255, 0.08); }
.callout--tip { --callout-color: #34c759; --callout-bg: rgba(52, 199, 89, 0.08); }
.callout--warning { --callout-color: #ff9500; --callout-bg: rgba(255, 149, 0, 0.08); }
.callout--danger { --callout-color: #ff3b30; --callout-bg: rgba(255, 59, 48, 0.08); }
.callout--success { --callout-color: #34c759; --callout-bg: rgba(52, 199, 89, 0.08); }
.callout--question { --callout-color: #5856d6; --callout-bg: rgba(88, 86, 214, 0.08); }
.callout--todo { --callout-color: #8e8e93; --callout-bg: rgba(142, 142, 147, 0.08); }

.callout {
    border-left: 4px solid var(--callout-color);
    background-color: var(--callout-bg);
}

.callout-title {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    font-weight: 700;
    color: var(--callout-color);
    background-color: rgba(var(--callout-color), 0.05);
    user-select: none;
}

.callout.is-foldable .callout-title {
    cursor: pointer;
}

.callout-icon {
    display: flex;
    align-items: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.callout-icon svg {
    width: 100%;
    height: 100%;
}

.callout-title-inner {
    flex: 1;
    font-size: 0.95rem;
}

.callout-fold {
    display: flex;
    align-items: center;
    transition: transform 0.2s ease;
}

.callout.is-collapsed .callout-fold {
    transform: rotate(-90deg);
}

.callout-content {
    padding: 12px 16px;
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.6;
}

.callout.is-collapsed .callout-content {
    display: none;
}

/* ===========================
   Optimized Code Blocks
   =========================== */

.code-block {
    margin: 1.5em 0;
    background: #1e1e1e; /* Darker background for code */
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-card), 0 10px 30px rgba(0,0,0,0.1);
}

[data-theme="light"] .code-block {
    background: #1e1e1e; /* Keep code blocks dark even in light mode for better contrast */
    border-color: rgba(0,0,0,0.1);
}

.code-block-header {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid var(--divider);
    gap: 12px;
}

[data-theme="dark"] .code-block-header {
    background: rgba(255, 255, 255, 0.03);
}

/* .code-block-dots {
    display: flex;
    gap: 6px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.dot-red { background: #ff5f56; }
.dot-yellow { background: #ffbd2e; }
.dot-green { background: #27c93f; } */

.code-block-lang {
    flex: 1;
    font-size: 0.8rem;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.8;
}

.code-block-copy {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    background: transparent;
}

.code-block-copy:hover {
    background: var(--tag-bg);
    color: var(--text-primary);
}

.code-block-copy.success {
    color: var(--primary);
}

.code-block-copy svg {
    width: 16px;
    height: 16px;
}

.code-block-copy .hidden {
    display: none;
}

.markdown-body .code-block pre {
    margin: 0 !important;
    border: none !important;
    background: transparent !important;
    padding: 16px !important;
}

.markdown-body .code-block pre code {
    padding: 0 !important;
    background: transparent !important;
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace !important;
    font-variant-ligatures: common-ligatures;
    font-feature-settings: "liga", "clig";
    text-shadow: none !important;
}

/* Custom Scrollbar for code blocks */
.markdown-body pre::-webkit-scrollbar {
    height: 8px;
}

.markdown-body pre::-webkit-scrollbar-track {
    background: transparent;
}

.markdown-body pre::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}

.markdown-body pre::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}