/* Core styles — layered on top of Pico CSS */

/* ---- Color Palette: Dark (default) ---- */
:root[data-theme="dark"] {
    --pico-background-color: #101012;
    --pico-card-background-color: #18191c;
    --pico-card-border-color: #25262b;
    --pico-card-sectioning-background-color: #18191c;
    --pico-color: #a8a8b3;
    --pico-h1-color: #e4e4e9;
    --pico-h2-color: #e4e4e9;
    --pico-h3-color: #e4e4e9;
    --pico-h4-color: #e4e4e9;
    --pico-h5-color: #e4e4e9;
    --pico-h6-color: #e4e4e9;
    --pico-muted-color: #7a7a86;
    --pico-muted-border-color: #25262b;
    --pico-primary: #b0a690;
    --pico-primary-hover: #c0b6a0;
    --pico-primary-background: #201e18;
    --pico-primary-inverse: #b0a690;
    --pico-secondary: #7a7a86;
    --pico-secondary-hover: #82828d;
    --pico-code-background-color: #18191c;
    --pico-code-color: #b0a690;
    --pico-border-color: #25262b;
    --pico-table-border-color: #25262b;
    --pico-contrast: #e4e4e9;
    --pico-contrast-hover: #fff;

    /* Custom vars */
    --color-bg: #101012;
    --color-card: #18191c;
    --color-card-border: #25262b;
    --color-text: #a8a8b3;
    --color-heading: #e4e4e9;
    --color-muted: #7a7a86;
    --color-accent: #b0a690;
    --color-accent-bg: #201e18;
}

/* ---- Color Palette: Light ---- */
:root[data-theme="light"] {
    --pico-background-color: #F0EEE9;
    --pico-card-background-color: #ffffff;
    --pico-card-border-color: #e0ded9;
    --pico-card-sectioning-background-color: #ffffff;
    --pico-color: #3c3c43;
    --pico-h1-color: #18181b;
    --pico-h2-color: #18181b;
    --pico-h3-color: #18181b;
    --pico-h4-color: #18181b;
    --pico-h5-color: #18181b;
    --pico-h6-color: #18181b;
    --pico-muted-color: #8a8882;
    --pico-muted-border-color: #e0ded9;
    --pico-primary: #8a7e6b;
    --pico-primary-hover: #7a6e5b;
    --pico-primary-background: #ece8e0;
    --pico-primary-inverse: #8a7e6b;
    --pico-secondary: #8a8882;
    --pico-secondary-hover: #7c7a75;
    --pico-code-background-color: #ffffff;
    --pico-code-color: #8a7e6b;
    --pico-border-color: #e0ded9;
    --pico-table-border-color: #e0ded9;
    --pico-contrast: #18181b;
    --pico-contrast-hover: #000;

    /* Custom vars */
    --color-bg: #F0EEE9;
    --color-card: #ffffff;
    --color-card-border: #e0ded9;
    --color-text: #3c3c43;
    --color-heading: #18181b;
    --color-muted: #8a8882;
    --color-accent: #8a7e6b;
    --color-accent-bg: #ece8e0;
}

/* ---- Typography ---- */
:root {
    --font-family: "Noto Serif", "Noto Serif KR", Georgia, "Times New Roman", serif;
    font-size: clamp(14px, 0.5vw + 14px, 18px);
}

html {
    overflow-y: scroll;
}

body {
    font-family: var(--font-family);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

body > main {
    flex: 1;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-family);
    font-weight: 600;
    letter-spacing: -0.01em;
}

h1 {
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* ---- Keyframes ---- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.97);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ---- Site Name ---- */
.site-name {
    text-align: center;
    padding-top: 1.5rem;
    padding-bottom: 0;
}

.site-title {
    text-decoration: none;
    font-size: 1.6rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--color-heading);
}

.site-title:hover {
    color: var(--color-accent);
}

/* ---- Navigation ---- */
header nav {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    justify-content: center;
    border-bottom: 1px solid var(--color-card-border);
}

header nav ul:first-child li a {
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-decoration: none;
    position: relative;
    padding-bottom: 2px;
}

header nav ul:first-child li a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 0;
    height: 1px;
    background: var(--color-accent);
    transition: width 0.3s ease;
}

header nav ul:first-child li a:hover::after {
    width: 100%;
}

/* ---- Site Tagline ---- */
.site-tagline {
    text-align: center;
    color: var(--color-muted);
    font-size: 0.9rem;
    font-style: italic;
    padding-bottom: 0;
    margin-bottom: 0;
}

/* ---- Theme Toggle Button ---- */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 1.2rem;
    line-height: 1;
    color: var(--color-muted);
    transition: color 0.3s ease;
    margin: 0;
    outline: none;
    box-shadow: none;
}

.theme-toggle:hover {
    color: var(--color-accent);
    background: none;
    border: none;
    box-shadow: none;
}

.theme-toggle:focus {
    box-shadow: none;
}

/* ---- Feed: Header ---- */
.feed-header {
    max-width: 720px;
    margin: 0 auto;
    padding: 0.5rem 0 0;
    animation: fadeIn 0.6s ease both;
}

.feed-header h1 {
    animation: fadeInUp 0.5s ease both;
}

/* ---- Feed: Timeline ---- */
.feed {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
    padding-left: 1.5rem;
    padding-bottom: 2rem;
}

/* Vertical line */
.feed::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--color-card-border);
}

/* ---- Feed: Item ---- */
.feed-item {
    display: block;
    position: relative;
    padding: 1.25rem 1.5rem;
    margin-top: 1.25rem;
    background: var(--color-card);
    border: 1px solid var(--color-card-border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--color-text);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    animation: fadeInUp 0.4s ease both;
}

/* Dot on the timeline */
.feed-item::before {
    content: "";
    position: absolute;
    left: -1.5rem;
    top: 1.6rem;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-card-border);
    transform: translateX(-3px);
    transition: background 0.2s ease;
}

/* Staggered entrance */
.feed-item:nth-child(1) { animation-delay: 0.1s; }
.feed-item:nth-child(2) { animation-delay: 0.18s; }
.feed-item:nth-child(3) { animation-delay: 0.26s; }
.feed-item:nth-child(4) { animation-delay: 0.34s; }
.feed-item:nth-child(5) { animation-delay: 0.42s; }
.feed-item:nth-child(6) { animation-delay: 0.50s; }
.feed-item:nth-child(7) { animation-delay: 0.58s; }
.feed-item:nth-child(8) { animation-delay: 0.66s; }
.feed-item:nth-child(9) { animation-delay: 0.74s; }

a.feed-item:hover,
.feed-item-photo:hover {
    transform: translateY(-2px);
    border-color: var(--color-accent);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

a.feed-item:hover::before,
.feed-item-photo:hover::before {
    background: var(--color-accent);
}

/* Sentinel — invisible trigger for infinite scroll */
.feed-sentinel {
    height: 1px;
}

.feed-meta {
    display: block;
    font-size: 0.78rem;
    color: var(--color-muted);
    letter-spacing: 0.02em;
    margin-bottom: 0.5rem;
}

.feed-item h3 {
    font-size: 1.1rem;
    margin-bottom: 0.3rem;
    color: var(--color-heading);
}

.feed-item p {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--color-text);
}

/* Photo items */
.feed-item-photo {
    padding: 1.25rem 1.5rem;
    cursor: pointer;
}

.feed-photo {
    margin-top: 0.5rem;
    border-radius: 6px;
    overflow: hidden;
}

.feed-photo img {
    width: 100%;
    height: auto;
    max-height: 320px;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.feed-photo:hover img {
    transform: scale(1.02);
}

.feed-caption {
    font-size: 0.82rem;
    color: var(--color-muted);
    margin: 0.6rem 0 0;
}

/* Feed preview — image */
.feed-preview-img {
    margin-bottom: 0.5rem;
    border-radius: 6px;
    overflow: hidden;
}

.feed-preview-img img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}


/* ---- Card grid ---- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1rem;
}

/* ---- Card list (single column) ---- */
.card-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 720px;
    margin: 0 auto 1rem;
}

.post-card,
.project-card {
    position: relative;
    padding: 0;
    border-radius: 8px;
    cursor: pointer;
    background: var(--color-card);
    border: 1px solid var(--color-card-border);
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    animation: fadeInUp 0.5s ease both;
}

.post-card:hover,
.project-card:hover {
    transform: translateY(-2px);
    border-color: var(--color-accent);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Staggered card entrance */
.card-grid > :nth-child(1), .card-list > :nth-child(1) { animation-delay: 0.1s; }
.card-grid > :nth-child(2), .card-list > :nth-child(2) { animation-delay: 0.2s; }
.card-grid > :nth-child(3), .card-list > :nth-child(3) { animation-delay: 0.3s; }
.card-grid > :nth-child(4), .card-list > :nth-child(4) { animation-delay: 0.4s; }
.card-grid > :nth-child(5), .card-list > :nth-child(5) { animation-delay: 0.5s; }
.card-grid > :nth-child(6), .card-list > :nth-child(6) { animation-delay: 0.6s; }
.card-grid > :nth-child(7), .card-list > :nth-child(7) { animation-delay: 0.7s; }
.card-grid > :nth-child(8), .card-list > :nth-child(8) { animation-delay: 0.8s; }
.card-grid > :nth-child(9), .card-list > :nth-child(9) { animation-delay: 0.9s; }

.post-card header,
.project-card header {
    padding: 0;
    margin-bottom: 0.75rem;
    background: transparent;
    border-bottom: none;
}

.post-card footer,
.project-card footer {
    border-top: none;
}

.post-card h3,
.project-card h3 {
    font-size: 1.15rem;
    margin-bottom: 0.35rem;
}

.post-card h3 a,
.project-card h3 a {
    text-decoration: none;
    color: var(--color-heading);
    transition: color 0.3s ease;
}

.post-card h3 a:hover,
.project-card h3 a:hover {
    color: var(--color-accent);
}

.post-card footer,
.project-card footer {
    padding: 0;
    margin-top: 1rem;
    background: transparent;
}

.post-card > *,
.project-card > * {
    margin-left: 1.25rem;
    margin-right: 1.25rem;
    padding-left: 0;
    padding-right: 0;
}

.post-card > header:first-child,
.project-card > header:first-child {
    margin-top: 1.25rem;
}

/* Card preview — image */
.card-preview-img {
    margin: 0;
    overflow: hidden;
}

.card-preview-img img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
}

.post-card > .card-preview-img + header,
.project-card > .card-preview-img + header {
    margin-top: 1rem;
}

.post-card > footer,
.project-card > footer {
    margin-bottom: 1.25rem;
}

.post-card > p,
.project-card > p {
    margin-bottom: 0;
}

/* Stretched link — makes entire card clickable */
.card-link {
    position: absolute;
    inset: 0;
    z-index: 1;
    text-decoration: none;
}

/* ---- Tags ---- */
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.tag-badge {
    display: inline-block;
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    background: color-mix(in srgb, var(--tag-color, var(--color-accent)) 15%, transparent);
    color: var(--tag-color, var(--color-accent));
}

/* ---- Empty state ---- */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--pico-muted-color);
}

/* ---- Date ---- */
.date-label {
    color: var(--color-muted);
    font-size: 0.8rem;
    display: block;
    margin-bottom: 0.25rem;
}

/* ---- Post/Project detail ---- */
.post-detail,
.project-detail {
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem;
    animation: fadeInUp 0.6s ease both;
    animation-delay: 0.1s;
}

.post-detail > *,
.project-detail > * {
    padding: 0;
    margin-left: 0;
    margin-right: 0;
    border: none;
}

.post-detail header,
.project-detail header {
    margin-bottom: 2rem;
}

.post-detail header h1,
.project-detail header h1 {
    margin-bottom: 0.75rem;
}

.post-detail header .date-label,
.project-detail header .date-label {
    margin-bottom: 0.5rem;
}

.post-detail header .tag-list,
.project-detail header .tag-list {
    margin-top: 0.75rem;
}

/* Page-level H1s */
main > h1,
.post-detail h1,
.project-detail h1 {
    animation: fadeInUp 0.5s ease both;
}

main > h1 {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}

.prose {
    line-height: 1.75;
}

.prose a {
    color: var(--color-accent);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--color-accent) 30%, transparent);
    text-underline-offset: 2px;
    transition: text-decoration-color 0.3s ease;
}

.prose a:hover {
    text-decoration-color: var(--color-accent);
}

.prose pre {
    padding: 1.25rem;
    border-radius: 8px;
    overflow-x: auto;
    background: var(--color-card);
    border: 1px solid var(--color-card-border);
    font-size: 0.85rem;
    line-height: 1.6;
}

.prose code {
    font-size: 0.85em;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    background: var(--color-card);
}

.prose pre code {
    padding: 0;
    background: none;
    font-size: inherit;
}

.prose img {
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--color-card-border);
    margin: 1rem 0;
    display: block;
}

/* ---- Gallery grid ---- */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    max-width: 720px;
    margin: 0 auto;
}

.image-card {
    padding: 0;
    overflow: hidden;
    border-radius: 8px;
    background: var(--color-card);
    border: 1px solid var(--color-card-border);
    cursor: pointer;
    animation: scaleIn 0.5s ease both;
}

/* Staggered gallery entrance */
.gallery-grid > :nth-child(1) { animation-delay: 0.05s; }
.gallery-grid > :nth-child(2) { animation-delay: 0.10s; }
.gallery-grid > :nth-child(3) { animation-delay: 0.15s; }
.gallery-grid > :nth-child(4) { animation-delay: 0.20s; }
.gallery-grid > :nth-child(5) { animation-delay: 0.25s; }
.gallery-grid > :nth-child(6) { animation-delay: 0.30s; }
.gallery-grid > :nth-child(7) { animation-delay: 0.35s; }
.gallery-grid > :nth-child(8) { animation-delay: 0.40s; }
.gallery-grid > :nth-child(9) { animation-delay: 0.45s; }
.gallery-grid > :nth-child(10) { animation-delay: 0.50s; }
.gallery-grid > :nth-child(11) { animation-delay: 0.55s; }
.gallery-grid > :nth-child(12) { animation-delay: 0.60s; }

.image-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.image-card:hover img {
    transform: scale(1.03);
}

.image-caption {
    padding: 0.5rem 0.75rem;
}

.image-title {
    font-size: 0.85rem;
    margin: 0;
}

.image-desc {
    font-size: 0.78rem;
    color: var(--color-muted);
    margin: 0.2rem 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- About ---- */
.about-content {
    max-width: 720px;
    margin: 0 auto;
    animation: fadeInUp 0.6s ease both;
    animation-delay: 0.1s;
}

.about-content p {
    line-height: 1.7;
}

.about-content a {
    color: var(--color-accent);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--color-accent) 30%, transparent);
    text-underline-offset: 2px;
    transition: text-decoration-color 0.3s ease;
}

.about-content a:hover {
    text-decoration-color: var(--color-accent);
}

/* ---- Lightbox ---- */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.9);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox.active {
    display: flex;
    opacity: 1;
}

.lightbox img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
    cursor: default;
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem 0.5rem;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.lightbox-close:hover {
    opacity: 1;
    background: none;
    border: none;
}

.lightbox-caption {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    margin-top: 1rem;
    text-align: center;
}

body.lightbox-open {
    overflow: hidden;
}

/* ---- Footer ---- */
footer {
    margin-top: 3rem;
    padding: 1.5rem 0;
    color: var(--color-muted);
    font-size: 0.85rem;
    text-align: center;
}

/* ---- Accessibility: reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-delay: 0s !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---- Responsive ---- */
@media (max-width: 576px) {
    .feed-header h1 {
        font-size: 1.8rem;
    }

    .feed {
        padding-left: 1.25rem;
    }

    .feed-item {
        padding: 1rem 1.25rem;
    }

    .feed-item::before {
        left: -1.25rem;
        transform: translateX(-3px);
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .gallery-grid {
        grid-template-columns: 1fr;
    }

    .post-detail h1,
    .project-detail h1 {
        font-size: 1.6rem;
    }
}
