/* Cosmos-inspired Masonry Gallery */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
    background: #fafafa;
    color: #1a1a1a;
    min-height: 100vh;
}

/* Container */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 1rem;
    max-width: 1600px;
    margin: 0 auto;
}

header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

header h1 a {
    color: inherit;
    text-decoration: none;
}

.header-about {
    font-size: 0.875rem;
    color: #666;
    text-decoration: none;
    transition: color 0.2s;
}

.header-about:hover {
    color: #1a1a1a;
}

/* Main */
main {
    padding-bottom: 3rem;
}

/* Masonry Grid */
.masonry {
    column-count: 5;
    column-gap: 40px;
    padding: 0 40px;
}

@media (max-width: 1400px) {
    .masonry {
        column-count: 4;
        column-gap: 32px;
        padding: 0 32px;
    }
}

@media (max-width: 1100px) {
    .masonry {
        column-count: 3;
        column-gap: 24px;
        padding: 0 24px;
    }
}

@media (max-width: 768px) {
    .masonry {
        column-count: 2;
        column-gap: 16px;
        padding: 0 16px;
    }
}

@media (max-width: 480px) {
    .masonry {
        column-count: 2;
        column-gap: 12px;
        padding: 0 12px;
    }
}

/* Card */
.card {
    break-inside: avoid;
    margin-bottom: 40px;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    position: relative;
}

@media (max-width: 1400px) {
    .card {
        margin-bottom: 32px;
    }
}

@media (max-width: 1100px) {
    .card {
        margin-bottom: 24px;
    }
}

@media (max-width: 768px) {
    .card {
        margin-bottom: 16px;
        border-radius: 8px;
    }
}

@media (max-width: 480px) {
    .card {
        margin-bottom: 12px;
        border-radius: 6px;
    }
}

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

.card a {
    display: block;
    text-decoration: none;
    color: inherit;
}

.card-image {
    width: 100%;
    display: block;
    background: #f0f0f0;
}

.card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 3rem 0.75rem 0.75rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.3) 50%, transparent 100%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.card:hover .card-overlay {
    opacity: 1;
}

.card-title {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #fff;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 2rem 1rem;
    margin-top: 1rem;
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #1a1a1a;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s;
}

.pagination-link:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

.pagination-link.disabled {
    color: #ccc;
    pointer-events: none;
    background: #fafafa;
}

.pagination-info {
    font-size: 0.875rem;
    color: #999;
}

/* Single Page */
.single-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1rem 3rem;
}

.single-image-wrap {
    position: relative;
    margin-bottom: 1.5rem;
}

.single-image {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    width: auto;
    height: auto;
    margin: 0 auto;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    cursor: zoom-in;
    transition: transform 0.2s ease;
}

.single-image:hover {
    transform: scale(1.01);
}

.image-hint {
    text-align: center;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: #999;
    opacity: 0;
    transition: opacity 0.2s;
}

.single-image-wrap:hover .image-hint {
    opacity: 1;
}

.single-info {
    max-width: 600px;
    margin: 0 auto;
}

.single-title {
    font-size: 1.375rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.single-description {
    font-size: 0.9375rem;
    color: #666;
    line-height: 1.7;
    margin-bottom: 1.25rem;
}

.single-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.single-tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    color: #666;
    background: #f0f0f0;
    border-radius: 100px;
    text-decoration: none;
    transition: all 0.2s;
}

.single-tag:hover {
    background: #e0e0e0;
    color: #333;
}

.single-footer {
    padding-top: 1.25rem;
    border-top: 1px solid #e0e0e0;
}

.single-details {
    font-size: 0.8125rem;
}

.single-details .detail-row {
    display: flex;
    padding: 0.375rem 0;
}

.single-details dt {
    width: 90px;
    flex-shrink: 0;
    color: #999;
}

.single-details dt a {
    color: #999;
    text-decoration: none;
}

.single-details dt a:hover {
    color: #666;
}

.single-details dd {
    margin: 0;
    color: #333;
}

.single-details dd a {
    color: #333;
    text-decoration: none;
}

.single-details dd a:hover {
    text-decoration: underline;
}

.single-details time {
    color: #333;
}

/* Page Navigation */
.page-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e0e0e0;
}

.page-nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #f5f5f5;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s;
    max-width: 48%;
}

.page-nav-link:hover {
    background: #eee;
}

.page-nav-link svg {
    flex-shrink: 0;
    color: #999;
}

.page-nav-text {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.page-nav-label {
    font-size: 0.75rem;
    color: #999;
}

.page-nav-title {
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page-nav-prev .page-nav-text {
    align-items: flex-start;
}

.page-nav-next .page-nav-text {
    align-items: flex-end;
}

.page-nav-spacer {
    flex: 1;
}

@media (max-width: 480px) {
    .page-nav {
        flex-direction: column;
        gap: 0.75rem;
    }

    .page-nav-link {
        max-width: 100%;
    }

    .page-nav-next {
        flex-direction: row-reverse;
    }

    .page-nav-next .page-nav-text {
        align-items: flex-start;
    }
}

.back-link {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid #e0e0e0;
}

.back-link a {
    font-size: 0.8125rem;
    color: #666;
    text-decoration: none;
}

.back-link a:hover {
    color: #1a1a1a;
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    cursor: zoom-out;
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-content {
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 4px;
}

/* Taxonomy Pages */
.taxonomy-header {
    padding: 1rem;
    margin-bottom: 1rem;
}

.taxonomy-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.taxonomy-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0 1rem 2rem;
}

.taxonomy-list li a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: #333;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 100px;
    text-decoration: none;
    transition: all 0.2s;
}

.taxonomy-list li a:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

.taxonomy-list .count {
    font-size: 0.75rem;
    color: #999;
}

/* About page */
.about-page {
    max-width: 600px;
    margin: 0 auto;
    padding: 2rem 1rem;
    line-height: 1.8;
}

.about-page h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem;
}

.about-page p {
    margin-bottom: 1rem;
    color: #333;
}

.about-page a {
    color: #1a1a1a;
    text-decoration: underline;
}

/* Loading placeholder */
.card-image[data-src] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    body {
        background: #0a0a0a;
        color: #f5f5f5;
    }

    header h1 a {
        color: #f5f5f5;
    }

    .header-about {
        color: #888;
    }

    .header-about:hover {
        color: #f5f5f5;
    }

    .card {
        background: #1a1a1a;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    }

    .card:hover {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    }

    .card-image {
        background: #2a2a2a;
    }

    .pagination-link {
        color: #f5f5f5;
        background: #1a1a1a;
        border-color: #333;
    }

    .pagination-link:hover {
        background: #2a2a2a;
        border-color: #444;
    }

    .pagination-link.disabled {
        color: #555;
        background: #111;
    }

    .pagination-info {
        color: #666;
    }

    .single-image {
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    }

    .image-hint {
        color: #666;
    }

    .single-description {
        color: #999;
    }

    .single-tag {
        color: #999;
        background: #2a2a2a;
    }

    .single-tag:hover {
        background: #333;
        color: #ccc;
    }

    .single-footer {
        border-top-color: #333;
    }

    .single-details dt {
        color: #666;
    }

    .single-details dt a {
        color: #666;
    }

    .single-details dt a:hover {
        color: #888;
    }

    .single-details dd,
    .single-details dd a,
    .single-details time {
        color: #ccc;
    }

    .page-nav {
        border-top-color: #333;
    }

    .page-nav-link {
        background: #1a1a1a;
        color: #ccc;
    }

    .page-nav-link:hover {
        background: #252525;
    }

    .page-nav-link svg {
        color: #666;
    }

    .page-nav-label {
        color: #666;
    }

    .back-link {
        border-top-color: #333;
    }

    .back-link a {
        color: #888;
    }

    .back-link a:hover {
        color: #f5f5f5;
    }

    .lightbox {
        background: rgba(0, 0, 0, 0.98);
    }

    .taxonomy-list li a {
        color: #ccc;
        background: #1a1a1a;
        border-color: #333;
    }

    .taxonomy-list li a:hover {
        background: #2a2a2a;
        border-color: #444;
    }

    .taxonomy-list .count {
        color: #666;
    }

    .about-page p {
        color: #ccc;
    }

    .about-page a {
        color: #f5f5f5;
    }

    .card-image[data-src] {
        background: linear-gradient(90deg, #2a2a2a 25%, #333 50%, #2a2a2a 75%);
        background-size: 200% 100%;
    }
}
