/* ========================================
   Falanga Blog — Juniper-Inspired Theme
   ======================================== */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    letter-spacing: -0.04em;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

img {
    max-width: 100%;
    display: block;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

/* --- Container --- */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* --- Header --- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--bg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 72px;
}

.site-logo {
    font-family: 'DM Sans', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    color: var(--text);
}

.site-logo-img {
    height: 120px;
    width: auto;
    display: block;
}

.site-nav {
    display: flex;
    gap: 32px;
}

.nav-link {
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0.7;
    transition: opacity 0.2s;
}

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

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    width: 28px;
    padding: 4px 0;
}

.nav-toggle span {
    display: block;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform 0.3s, opacity 0.3s;
}

.nav-toggle.open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.nav-toggle.open span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* --- Hero Carousel --- */
.hero-carousel {
    position: relative;
    width: 100%;
    height: 520px;
    overflow: hidden;
    margin-bottom: 60px;
}

.carousel-track {
    position: relative;
    width: 100%;
    height: 100%;
}

.carousel-slide {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 0.8s ease;
    z-index: 0;
}

.carousel-slide.active {
    opacity: 1;
    z-index: 1;
}

.carousel-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, var(--bg) 0%, rgba(14, 16, 17, 0.6) 50%, rgba(14, 16, 17, 0.3) 100%);
}

.carousel-content {
    position: absolute;
    bottom: 60px;
    left: 0;
    right: 0;
    z-index: 2;
}

.carousel-tag {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--tag);
    margin-bottom: 12px;
}

.carousel-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    line-height: 1.15;
    max-width: 700px;
    margin-bottom: 12px;
}

.carousel-title a:hover {
    color: var(--accent);
    transition: color 0.2s;
}

.carousel-desc {
    font-size: 1rem;
    opacity: 0.7;
    max-width: 550px;
    margin-bottom: 16px;
    line-height: 1.5;
}

.carousel-meta {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
    opacity: 0.6;
}

.carousel-dots {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    display: flex;
    gap: 8px;
}

.carousel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transition: background 0.3s, transform 0.3s;
}

.carousel-dot.active {
    background: var(--accent);
    transform: scale(1.2);
}

.carousel-dot:hover {
    background: rgba(255, 255, 255, 0.6);
}

/* --- Section Title --- */
.section-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    margin-bottom: 32px;
}

/* --- Article Grid --- */
.articles-section {
    padding-bottom: 80px;
}

.article-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
}

/* --- Article Card --- */
.article-card {
    background: var(--card);
    border-radius: 16px;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
}

.article-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.card-link {
    display: block;
}

.card-image {
    width: 100%;
    height: 200px;
    background-size: cover;
    background-position: center;
}

.card-body {
    padding: 20px;
}

.card-tag {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--tag);
    margin-bottom: 10px;
}

.card-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1.3;
    margin-bottom: 8px;
}

.card-desc {
    font-size: 0.875rem;
    opacity: 0.65;
    line-height: 1.5;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    opacity: 0.5;
}

/* --- Load More --- */
.load-more-wrap {
    display: flex;
    justify-content: center;
    margin-top: 48px;
}

.btn-load-more {
    padding: 14px 40px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.3s, border-color 0.3s;
}

.btn-load-more:hover {
    background: var(--accent);
    border-color: var(--accent);
}

/* htmx loading indicator */
.btn-load-more.htmx-request {
    opacity: 0.6;
    pointer-events: none;
}

/* --- Article Page --- */
.article-page {
    padding-top: 48px;
    padding-bottom: 80px;
}

.article-header {
    max-width: 720px;
    margin: 0 auto 40px;
    text-align: center;
}

.article-tag {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--tag);
    margin-bottom: 16px;
}

.article-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    line-height: 1.15;
    margin-bottom: 20px;
}

.article-meta {
    display: flex;
    justify-content: center;
    gap: 16px;
    font-size: 0.9rem;
    opacity: 0.6;
}

.article-viewer {
    max-width: 900px;
    margin: 0 auto;
}

.drive-embed {
    width: 100%;
    height: 80vh;
    min-height: 500px;
    border: none;
    border-radius: 16px;
    background: var(--card);
}

/* --- About Page --- */
.about-page {
    padding-top: 60px;
    padding-bottom: 80px;
    max-width: 720px;
}

.about-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    margin-bottom: 24px;
}

.about-content {
    font-size: 1.05rem;
    line-height: 1.7;
    opacity: 0.8;
}

/* --- About Authors --- */
.about-authors {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.author-card {
    display: flex;
    gap: 32px;
    align-items: flex-start;
    background: var(--card);
    border-radius: 16px;
    padding: 32px;
}

.author-photo-wrap {
    flex-shrink: 0;
}

.author-photo {
    width: 128px;
    height: 128px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 25%;
    display: block;
}

.author-info {
    flex: 1;
}

.author-name {
    font-family: 'DM Sans', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    margin-bottom: 12px;
}

.author-bio {
    font-size: 0.95rem;
    line-height: 1.75;
    opacity: 0.75;
}

@media (max-width: 600px) {
    .author-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 24px;
        gap: 20px;
    }

    .author-photo-wrap {
        display: flex;
        justify-content: center;
    }
}

/* --- Footer --- */
.site-footer {
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: 60px 0 32px;
}

.footer-grid {
    margin-bottom: 40px;
}

.footer-logo {
    font-family: 'DM Sans', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    display: inline-block;
    margin-bottom: 12px;
}

.footer-description {
    font-size: 0.9rem;
    opacity: 0.6;
    max-width: 360px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.social-links {
    display: flex;
    gap: 16px;
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    opacity: 0.6;
    transition: opacity 0.2s, background 0.2s;
}

.social-link:hover {
    opacity: 1;
    background: var(--accent);
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 24px;
    font-size: 0.8rem;
    opacity: 0.4;
}

/* --- Background gradient effect --- */
body::before {
    content: '';
    position: fixed;
    top: -200px;
    left: 50%;
    transform: translateX(-50%);
    width: 800px;
    height: 600px;
    background: radial-gradient(ellipse, var(--accent), transparent 70%);
    opacity: 0.07;
    pointer-events: none;
    z-index: -1;
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 1024px) {
    .article-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .nav-toggle {
        display: flex;
    }

    .site-nav {
        position: fixed;
        top: 72px;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--bg);
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 24px;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 99;
    }

    .site-nav.open {
        transform: translateX(0);
    }

    .nav-link {
        font-size: 1.2rem;
    }

    .hero-carousel {
        height: 420px;
    }

    .carousel-title {
        font-size: 1.75rem;
    }

    .carousel-content {
        bottom: 48px;
    }

    .article-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .article-title {
        font-size: 1.75rem;
    }

    .drive-embed {
        height: 60vh;
        min-height: 400px;
        border-radius: 12px;
    }

    .section-title {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 16px;
    }

    .hero-carousel {
        height: 360px;
    }

    .carousel-title {
        font-size: 1.4rem;
    }

    .carousel-desc {
        display: none;
    }

    .card-image {
        height: 160px;
    }

    .book-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* --- Page Title --- */
.page-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    margin-bottom: 40px;
    padding-top: 48px;
}

/* --- Tag Filters --- */
.tag-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 32px;
}

.tag-btn {
    padding: 8px 20px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    color: var(--text);
    opacity: 0.7;
}

.tag-btn:hover {
    opacity: 1;
    border-color: rgba(255, 255, 255, 0.3);
}

.tag-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    opacity: 1;
}

/* --- Clickable card tag --- */
a.card-tag {
    transition: color 0.2s;
}

a.card-tag:hover {
    color: var(--accent);
}

a.carousel-tag {
    transition: color 0.2s;
}

a.carousel-tag:hover {
    color: var(--accent);
}

/* --- Books Page --- */
.books-page {
    padding-bottom: 80px;
}

.books-empty {
    font-size: 1.05rem;
    opacity: 0.6;
}

.book-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 32px;
}

.book-card {
    background: var(--card);
    border-radius: 16px;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.book-link {
    display: block;
}

.book-cover {
    width: 100%;
    aspect-ratio: 2 / 3;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.03);
}

.book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-info {
    padding: 16px 20px 20px;
}

.book-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.3;
    margin-bottom: 6px;
}

.book-date {
    font-size: 0.8rem;
    opacity: 0.5;
}

/* --- Book Card Subtitle --- */
.book-subtitle {
    font-size: 0.78rem;
    opacity: 0.55;
    margin-bottom: 8px;
    line-height: 1.3;
}

/* --- Book Cover Placeholder --- */
.book-cover-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(192, 22, 26, 0.08);
    padding: 20px;
    text-align: center;
}

.book-cover-placeholder span {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    opacity: 0.5;
    line-height: 1.4;
}

/* --- Book Detail Page --- */
.book-detail-page {
    padding-top: 60px;
    padding-bottom: 80px;
}

.book-back-link {
    display: inline-block;
    font-size: 0.85rem;
    opacity: 0.5;
    margin-bottom: 20px;
    transition: opacity 0.2s;
}

.book-back-link:hover {
    opacity: 1;
}

.book-detail-inner {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 60px;
    margin-bottom: 60px;
    align-items: start;
}

.book-detail-cover {
    width: 260px;
    aspect-ratio: 2 / 3;
    border-radius: 12px;
    overflow: hidden;
    background: var(--card);
}

.book-detail-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-detail-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    line-height: 1.2;
    margin-bottom: 10px;
}

.book-detail-subtitle {
    font-size: 1.05rem;
    opacity: 0.6;
    margin-bottom: 32px;
    line-height: 1.4;
}

.book-detail-meta {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 8px;
}

.book-meta-row {
    display: flex;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.9rem;
}

.book-meta-row dt {
    opacity: 0.45;
    min-width: 160px;
    flex-shrink: 0;
}

.book-meta-row dd {
    font-weight: 500;
}

.book-detail-description {
    max-width: 740px;
    font-size: 1.05rem;
    line-height: 1.8;
    opacity: 0.8;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 40px;
}

/* --- Books responsive --- */
@media (max-width: 1024px) {
    .book-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .book-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .book-detail-inner {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .book-detail-cover {
        width: 180px;
        margin: 0 auto;
    }

    .book-detail-title {
        font-size: 1.5rem;
    }

    .book-meta-row dt {
        min-width: 120px;
    }

    .page-title {
        font-size: 1.75rem;
        padding-top: 32px;
        margin-bottom: 28px;
    }

    .tag-filters {
        gap: 8px;
    }

    .tag-btn {
        padding: 6px 14px;
        font-size: 0.7rem;
    }
}
