/* Custom styles to match the specific card design */
[x-cloak] { display: none !important; }

:root {
    --card-bg-hover: var(--pico-card-background-color);
    /* Universal system font stack with Korean support */
    --font-family:
        /* Korean fonts first */
        "Malgun Gothic",
        /* Windows Korean */
        "Apple SD Gothic Neo",
        /* macOS/iOS Korean */
        "Noto Sans KR",
        /* Android/Linux Korean */
        /* System UI fonts */
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        /* Windows */
        Roboto,
        /* Android */
        Oxygen,
        /* KDE */
        Ubuntu,
        Cantarell,
        /* GNOME */
        "Helvetica Neue",
        Arial,
        sans-serif,
        /* Emoji fonts */
        "Apple Color Emoji",
        "Segoe UI Emoji";
}

/* Apply font globally */
body {
    font-family: var(--font-family);
}

/* Page title styling */
.timeline-title {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    text-align: left;
    font-size: 1.25rem;
    height: 3.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0;
    padding: 0 4rem 0 1rem;
    font-weight: 700;
    background-color: var(--pico-background-color);
    z-index: 100;
    border-bottom: 1px solid var(--pico-border-color);
    transition: transform 0.3s ease-in-out;
}

.timeline-title.header-hidden {
    transform: translateY(-100%);
}

.timeline-title__text {
    color: inherit;
    text-decoration: none;
}

.timeline-title__text:hover {
    text-decoration: none;
}

/* Add padding to container to prevent overlap with fixed header */
main.container {
    padding-top: 4rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.sort-toggle {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
    margin: 0.25rem 0 0.85rem;
    padding: 0.25rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--pico-muted-border-color) 28%, transparent);
}

.sort-toggle__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.3rem;
    border-radius: 999px;
    color: var(--pico-muted-color);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.sort-toggle__button:hover {
    text-decoration: none;
    color: var(--pico-color);
}

.sort-toggle__button.is-active {
    background-color: var(--pico-card-background-color);
    color: var(--pico-color);
    box-shadow: 0 0.35rem 0.9rem rgba(15, 23, 42, 0.08);
}

.community-dropdown {
    position: relative;
}

.community-dropdown__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    height: auto;
    font-size: 0.875rem;
    font-weight: 600;
    color: #495057; /* 명시적인 다크 그레이 색상 (라이트 모드용) */
    background-color: transparent;
    border: 1px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0;
}

.community-dropdown__toggle:hover {
    background-color: #f1f3f5;
    border-color: #dee2e6;
    color: #212529;
}

.community-dropdown__icon {
    width: 1.25rem;
    height: 1.25rem;
    transition: transform 0.2s;
}

.community-dropdown__icon.is-open {
    transform: rotate(180deg);
}

.community-dropdown__menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background-color: var(--pico-card-background-color);
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: max-content;
    max-height: 60vh;
    overflow-y: auto;
    z-index: 1000;
    padding: 0.5rem 0;
    display: flex;
    flex-direction: column;
}

.community-dropdown__item {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--pico-muted-color);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.15s, color 0.15s;
}

.community-dropdown__item:hover {
    background-color: var(--pico-card-sectioning-background-color);
    color: var(--pico-color);
    text-decoration: none;
}

.community-dropdown__item.is-active {
    color: var(--pico-primary);
    font-weight: 700;
    background-color: color-mix(in srgb, var(--pico-primary) 10%, transparent);
}

[data-theme="dark"] .sort-toggle {
    background: #14181d;
    box-shadow: inset 0 0 0 1px #2c3440;
}

[data-theme="dark"] .sort-toggle__button {
    color: #98a2b3;
}

[data-theme="dark"] .sort-toggle__button:hover {
    color: #e5e7eb;
    background: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .sort-toggle__button.is-active {
    background: #273142;
    color: #f8fafc;
    box-shadow: 0 0.4rem 1rem rgba(0, 0, 0, 0.35);
    outline: 1px solid #3f4d63;
}

[data-theme="dark"] .community-dropdown__menu {
    background-color: #1a1a1a;
    border-color: #2c3440;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .community-dropdown__item {
    color: #98a2b3;
}

[data-theme="dark"] .community-dropdown__item:hover {
    background-color: #252525;
    color: #e5e7eb;
}

[data-theme="dark"] .community-dropdown__item.is-active {
    color: #4dabf7;
    background-color: rgba(77, 171, 247, 0.15);
}

[data-theme="dark"] .community-dropdown__toggle {
    color: #e5e7eb;
}

[data-theme="dark"] .community-dropdown__toggle:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Header Actions Container */
.toolbar {
    position: fixed;
    top: 0.875rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: transform 0.3s ease-in-out;
}

.toolbar.header-hidden {
    transform: translateY(-200%);
}

/* Theme Toggle Button */
.toolbar__theme-toggle {
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;

    /* Default (Light Mode) matches the toolbar button style */
    background: #e9ecef;
    border: 2px solid #ced4da;
    color: #495057;
}

.toolbar__theme-toggle:hover {
    background: #dee2e6;
}

/* Icons inside Toggle */
.toolbar__theme-toggle i {
    width: 0.875rem;
    height: 0.875rem;
    position: absolute;
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    top: 50%;
    left: 50%;
    margin-top: -0.4375rem;
    /* Half of height */
    margin-left: -0.4375rem;
    /* Half of width */
}

.icon-theme-sun {
    background-color: currentColor;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2'/%3E%3Cpath d='M12 20v2'/%3E%3Cpath d='m4.93 4.93 1.41 1.41'/%3E%3Cpath d='m17.66 17.66 1.41 1.41'/%3E%3Cpath d='M2 12h2'/%3E%3Cpath d='M20 12h2'/%3E%3Cpath d='m6.34 17.66-1.41 1.41'/%3E%3Cpath d='m19.07 4.93-1.41 1.41'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2'/%3E%3Cpath d='M12 20v2'/%3E%3Cpath d='m4.93 4.93 1.41 1.41'/%3E%3Cpath d='m17.66 17.66 1.41 1.41'/%3E%3Cpath d='M2 12h2'/%3E%3Cpath d='M20 12h2'/%3E%3Cpath d='m6.34 17.66-1.41 1.41'/%3E%3Cpath d='m19.07 4.93-1.41 1.41'/%3E%3C/svg%3E");
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.icon-theme-moon {
    background-color: currentColor;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401'/%3E%3C/svg%3E");
    opacity: 0;
    transform: rotate(-90deg) scale(0);
}

/* Dark Mode Styles */
[data-theme="dark"] .toolbar__theme-toggle {
    background: #212529;
    border-color: #495057;
    color: #f8f9fa;
}

[data-theme="dark"] .toolbar__theme-toggle:hover {
    background: #343a40;
}

[data-theme="dark"] .icon-theme-sun {
    opacity: 0;
    transform: rotate(90deg) scale(0);
}

[data-theme="dark"] .icon-theme-moon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Override Pico's article for this specific use case */
article.post-item {
    display: flex;
    flex-direction: column;
    /* Changed to column as content is now stacked */
    align-items: flex-start;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

article.post-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--pico-card-box-shadow);
    background-color: var(--pico-card-sectioning-background-color);
}

/* Light mode card colors */
[data-theme="light"] article.post-item,
:root:not([data-theme]) article.post-item {
    background-color: #ffffff;
    border-color: #e0e0e0;
}

[data-theme="light"] article.post-item:hover,
:root:not([data-theme]) article.post-item:hover {
    background-color: #f8f9fa;
    border-color: #d0d0d0;
}

/* Dark mode improvements */
[data-theme="dark"] article.post-item {
    background-color: #1a1a1a;
    border-color: #2d2d2d;
}

[data-theme="dark"] article.post-item:hover {
    background-color: #252525;
    border-color: #3d3d3d;
}

/* Content Styling */
.post-item__content {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.post-item__title {
    margin: 0 0 0.35rem 0;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Post Link Styling */
.post-item-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

/* Visited post styling (ID-based via localStorage) */
.post-item-link.visited .post-item__title {
    color: #888;
    opacity: 0.7;
}

[data-theme="dark"] .post-item-link.visited .post-item__title {
    color: #666;
    opacity: 0.65;
}

.post-item__meta {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin-top: 0.2rem;
    font-size: 0.75rem;
    color: var(--pico-muted-color);
}

.post-item__meta-line,
.post-item__stats {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.post-item__meta-line {
    gap: 0.95rem;
}

.post-item__meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.post-item__stats {
    margin-top: 0.3rem;
    font-size: 0.75rem;
    color: var(--pico-muted-color);
    gap: 0.85rem;
}

.post-item__meta-separator {
    color: var(--pico-muted-color);
}

.post-item__community {
    font-weight: bold;
}

/* Light mode community name */
[data-theme="light"] .post-item__community,
:root:not([data-theme]) .post-item__community {
    color: #0066cc;
}

/* Dark mode community name */
[data-theme="dark"] .post-item__community {
    color: #4dabf7;
}

/* Icons */
.icon {
    width: 12px;
    height: 12px;
    background-color: currentColor;
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    display: inline-block;
}

.icon-comment {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719'/%3E%3C/svg%3E");
}

.icon-view {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
}

.icon-time {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 6v6l4 2'/%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 6v6l4 2'/%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3C/svg%3E");
}

.icon-heart {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z'/%3E%3Cpath d='M7 10v12'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z'/%3E%3Cpath d='M7 10v12'/%3E%3C/svg%3E");
}

.pagination-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin: 1rem 0 2rem;
    padding: 0.75rem 0.25rem 0;
}

.pagination-pages {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.pagination-link,
.pagination-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 0.75rem;
    border-radius: 999px;
    font-size: 0.875rem;
}

.pagination-link {
    text-decoration: none;
    border: 1px solid var(--pico-muted-border-color);
    color: var(--pico-color);
    background-color: var(--pico-card-background-color);
    white-space: nowrap;
}

.pagination-link:hover {
    background-color: var(--pico-card-sectioning-background-color);
    text-decoration: none;
}

.pagination-link.is-current {
    border-color: var(--pico-primary);
    background-color: var(--pico-primary);
    color: var(--pico-primary-inverse);
    font-weight: 700;
}

.pagination-link.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

.pagination-ellipsis {
    color: var(--pico-muted-color);
}

/* Mobile Responsiveness */
@media (max-width: 576px) {
    .post-item__title {
        font-size: 0.85rem;
    }

    .pagination-nav {
        display: flex;
        justify-content: center;
        gap: 0.5rem;
    }

    .pagination-link,
    .pagination-ellipsis {
        min-width: 2rem;
        height: 2rem;
        padding: 0 0.6rem;
        font-size: 0.8125rem;
    }

    .pagination-pages {
        justify-content: flex-start;
        flex-wrap: nowrap;
        min-width: 0;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .pagination-pages::-webkit-scrollbar {
        display: none;
    }
}

/* System Dark Mode Preference Support */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .sort-toggle {
        background: #14181d;
        box-shadow: inset 0 0 0 1px #2c3440;
    }

    :root:not([data-theme]) .sort-toggle__button {
        color: #98a2b3;
    }

    :root:not([data-theme]) .sort-toggle__button:hover {
        color: #e5e7eb;
        background: rgba(255, 255, 255, 0.03);
    }

    :root:not([data-theme]) .sort-toggle__button.is-active {
        background: #273142;
        color: #f8fafc;
        box-shadow: 0 0.4rem 1rem rgba(0, 0, 0, 0.35);
        outline: 1px solid #3f4d63;
    }

    :root:not([data-theme]) article.post-item {
        background-color: #1a1a1a;
        border-color: #2d2d2d;
    }

    :root:not([data-theme]) article.post-item:hover {
        background-color: #252525;
        border-color: #3d3d3d;
    }

    :root:not([data-theme]) .post-item-link.visited .post-item__title {
        color: #666;
        opacity: 0.65;
    }

    :root:not([data-theme]) .post-item__community {
        color: #4dabf7;
    }

    :root:not([data-theme]) .toolbar__theme-toggle {
        background: #212529;
        border-color: #495057;
    }

    :root:not([data-theme]) .icon-theme-sun {
        opacity: 0;
        transform: rotate(90deg) scale(0);
    }

    :root:not([data-theme]) .icon-theme-moon {
        opacity: 1;
        transform: rotate(0deg) scale(1);
    }
}
