/* Custom styles to match the specific card design */

: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 */
.page-title {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    text-align: left;
    font-size: 1.25rem;
    height: 3.5rem;
    display: flex;
    align-items: center;
    margin: 0;
    padding: 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;
}

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

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

/* Header Actions Container */
.header-actions {
    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;
}

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

.refresh-btn {
    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;

    /* Default (Light Mode) matches theme-toggle */
    background: #e9ecef;
    border: 2px solid #ced4da;
    color: #495057;
}

.refresh-btn .icon {
    width: 0.875rem;
    height: 0.875rem;
}

.refresh-btn:hover {
    background: #dee2e6;
    transform: rotate(180deg);
}

/* Dark Mode Refresh Button */
[data-theme="dark"] .refresh-btn {
    background: #212529;
    border-color: #495057;
    color: #f8f9fa;
}

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

/* Spinner Animation for HTMX Request */
.refresh-btn.htmx-request .icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Theme Toggle Button */
.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 refresh-btn */
    background: #e9ecef;
    border: 2px solid #ced4da;
    color: #495057;
}

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

/* Icons inside Toggle */
.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"] .theme-toggle {
    background: #212529;
    border-color: #495057;
    color: #f8f9fa;
}

[data-theme="dark"] .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-card {
    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-card: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-card,
:root:not([data-theme]) article.post-card {
    background-color: #ffffff;
    border-color: #e0e0e0;
}

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

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

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

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

.post-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-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

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

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

.post-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--pico-muted-color);
    align-items: center;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.meta-time {
    margin-left: auto;
}

.meta-right {
    margin-left: auto;
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.community-name {
    font-weight: bold;
}

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

/* Dark mode community name */
[data-theme="dark"] .community-name {
    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='M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5'/%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 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5'/%3E%3C/svg%3E");
}

.icon-refresh {
    -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='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8'/%3E%3Cpath d='M3 3v5h5'/%3E%3Cpath d='M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16'/%3E%3Cpath d='M16 16h5v5'/%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='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8'/%3E%3Cpath d='M3 3v5h5'/%3E%3Cpath d='M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16'/%3E%3Cpath d='M16 16h5v5'/%3E%3C/svg%3E");
}

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

/* System Dark Mode Preference Support */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) article.post-card {
        background-color: #1a1a1a;
        border-color: #2d2d2d;
    }

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

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

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

    :root:not([data-theme]) .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);
    }
}