:root {
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Crimson Text', Georgia, serif;
    --font-ui: 'Montserrat', -apple-system, sans-serif;
}

[data-fonts="preset1"] {
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Crimson Text', Georgia, serif;
    --font-ui: 'Montserrat', -apple-system, sans-serif;
}

[data-fonts="preset2"] {
    --font-display: 'Cormorant', Georgia, serif;
    --font-body: 'Spectral', Georgia, serif;
    --font-ui: 'Inter', -apple-system, sans-serif;
}

[data-fonts="preset3"] {
    --font-display: 'Lora', Georgia, serif;
    --font-body: 'Source Serif Pro', Georgia, serif;
    --font-ui: 'Work Sans', -apple-system, sans-serif;
}

body {
    font-family: var(--font-body);
    background-color: var(--color-background);
    color: var(--color-text);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 clamp(16px, 5vw, 40px);
    box-sizing: border-box;
}

header {
    position: sticky;
    top: 0;
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0.5rem 0;
    z-index: 10;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: space-between;
    /* Better spacing control */
}

/* Logo on left */
.logo {
    order: 1;
}

/* Mobile menu on left */
.mobile-menu-toggle {
    order: 0;
    margin-right: 0.5rem;
    /* Space between menu and search */
}

/* Search in center */
.search-toggle {
    order: 1;
}

/* Language toggle on right */
.lang-toggle {
    order: 2;
}

/* Mobile language toggle in menu */
.mobile-lang-toggle {
    display: none;
    color: var(--color-secondary);
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    text-decoration: none;
    align-items: center;
    gap: 0.5rem;
}

.mobile-lang-toggle:hover {
    background-color: var(--color-surface);
    color: var(--color-text);
}

/* Search in center */
.search-toggle {
    order: 1;
}

/* Language toggle on right */
.lang-toggle {
    order: 3;
}

/* Mobile menu toggle - hidden on desktop */
.mobile-menu-toggle {
    display: none;
}

/* Mobile navigation - hidden by default */
.mobile-nav {
    display: none;
}

.search-toggle,
.lang-toggle {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.search-toggle:hover,
.lang-toggle:hover {
    background-color: var(--color-surface);
    border-color: var(--color-primary);
}

.lang-toggle {
    font-family: var(--font-ui);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    min-width: 2.5rem;
}

.lang-current {
    color: var(--color-primary);
    font-weight: 600;
}

.logo {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--color-primary);
}

.logo img {
    max-height: 60px;
    width: auto;
    vertical-align: middle;
}

nav a {
    font-family: var(--font-ui);
    text-decoration: none;
    color: var(--color-text);
    margin-left: 1.5rem;
}

.hero-section {
    display: none;
    padding: 4rem 0;
    text-align: center;
    background-color: transparent;
}

.hero-section.active {
    display: block;
}

.hero-section h1 {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 5vw, 4rem);
    color: var(--color-primary);
    margin-bottom: 1rem;
}

.search-form {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
}

.search-form input {
    width: 300px;
    padding: 0.8rem;
    border: 1px solid var(--color-border);
    border-radius: 4px 0 0 4px;
    font-family: var(--font-ui);
}

.search-form button {
    padding: 0.8rem 1.5rem;
    border: 1px solid var(--color-primary);
    background-color: var(--color-primary);
    color: white;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    font-family: var(--font-ui);
}

/* Search Modal */
.search-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.search-modal.active {
    opacity: 1;
    visibility: visible;
}

.search-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.search-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    background-color: var(--color-surface);
    border-radius: 8px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.search-header {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
    gap: 0.5rem;
}

.search-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background-color: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 0.5rem;
    gap: 0.5rem;
}

.search-input-wrapper:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(var(--color-primary-rgb, 59, 130, 246), 0.1);
}

.search-icon {
    color: var(--color-text-secondary);
    flex-shrink: 0;
}

#search-input {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    font-family: var(--font-ui);
    font-size: 1rem;
    color: var(--color-text);
}

#search-input::placeholder {
    color: var(--color-text-secondary);
}

.search-clear {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 2px;
    display: none;
}

.search-clear:hover {
    background-color: var(--color-border);
}

#search-input:not(:placeholder-shown)~.search-clear {
    display: block;
}

.search-close {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.search-close:hover {
    background-color: var(--color-border);
}

.search-results {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.search-placeholder {
    text-align: center;
    color: var(--color-text-secondary);
    padding: 2rem;
}

.search-no-results {
    text-align: center;
    color: var(--color-text-secondary);
    padding: 2rem;
}

.search-results-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-result {
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.search-result:hover {
    border-color: var(--color-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.search-result h3 {
    margin: 0 0 0.5rem 0;
    font-family: var(--font-display);
    font-size: 1.125rem;
    line-height: 1.4;
}

.search-result h3 a {
    color: var(--color-text);
    text-decoration: none;
}

.search-result h3 a:hover {
    color: var(--color-primary);
}

.search-snippet {
    margin: 0.5rem 0;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}

.search-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
}

.search-date {
    font-family: var(--font-ui);
}

.search-tags {
    font-family: var(--font-ui);
}

mark {
    background-color: rgba(var(--color-primary-rgb, 59, 130, 246), 0.2);
    color: var(--color-primary);
    padding: 0.1em 0.2em;
    border-radius: 2px;
    font-weight: 600;
}

/* Mobile Responsive */
@media (max-width: 960px) {

    /* Mobile navigation */
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.2rem;
        padding: 0.5rem;
        min-height: 44px;
        min-width: 44px;
        background: none;
        border: 1px solid var(--color-border);
        border-radius: 4px;
        cursor: pointer;
    }

    .desktop-nav {
        display: none;
    }

    .mobile-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--color-surface);
        border-bottom: 1px solid var(--color-border);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        z-index: 100;
    }

    .mobile-nav.active {
        display: flex;
        flex-direction: column;
        padding: 1rem;
    }

    .mobile-nav a {
        padding: 0.75rem 0;
        border-bottom: 1px solid var(--color-border);
        font-size: 1rem;
        text-decoration: none;
        color: var(--color-text);
        transition: background-color 0.2s ease;
    }

    .mobile-nav a:hover {
        background-color: var(--color-primary);
        color: white;
    }

    /* Hide desktop language toggle on mobile, show mobile language toggle */
    @media (max-width: 960px) {
        .lang-toggle {
            display: none;
        }

        .mobile-lang-toggle {
            display: block;
        }
    }

    /* Hero carousel mobile optimization */
    .hero-section {
        padding: 1rem 0;
        min-height: 35vh;
        max-height: 45vh;
        margin-bottom: 8rem;
        /* Further increase space between carousel and content */
        background-color: transparent;
        /* Remove gray background */
    }

    /* Remove carousel margins on mobile */
    @media (max-width: 960px) {
        .splide__track {
            margin: 0;
        }

        .splide__list {
            margin: 0;
        }

        .splide__slide {
            margin: 0;
        }
    }

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

    .splide__slide {
        height: 100%;
        margin: 0;
    }





    .splide__slide__caption a {
        color: var(--color-surface);
        text-decoration: none;
    }

    .splide__slide__caption a:hover {
        text-decoration: underline;
    }

    /* Fix carousel container spacing */
    .splide__track {
        margin: 0;
    }

    .splide__list {
        margin: 0;
    }

    .splide__slide img {
        margin: 0;
        display: block;
    }

    /* Content layout mobile */
    .main-content {
        display: flex;
        flex-direction: column;
    }

    .content-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 2rem;
        grid-column: 1 / 2;
        /* Assign to first column */
    }

    .article-card {
        margin-bottom: 1rem;
    }

    .trending-sidebar {
        width: 100%;
        margin-top: 2rem;
        margin-bottom: 1rem;
        order: -1;
    }

    /* Touch-friendly targets */
    .search-toggle,
    .lang-toggle {
        min-height: 44px;
        min-width: 44px;
        padding: 0.5rem;
    }

    .tags a {
        padding: 0.5rem 0.75rem;
        margin: 0.25rem;
        font-size: 0.9rem;
        min-height: 32px;
        display: inline-block;
    }

    /* Search mobile */
    .search-container {
        width: 95%;
        height: 80vh;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 8px;
    }

    .search-input {
        font-size: 16px;
        padding: 1rem;
        height: 48px;
    }

    .search-header {
        padding: 1rem;
    }

    .search-results {
        padding: 1rem;
        max-height: 60vh;
        overflow-y: auto;
    }

    .search-result {
        padding: 1rem;
        margin-bottom: 0.75rem;
    }

    .search-result h4 {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }

    /* Header spacing */
    .container {
        padding: 0 1rem;
    }

    header .container {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Mobile header layout: [menu][logo] on left, [search] on right */
    header .container {
        justify-content: space-between;
        align-items: center;
    }

    .left-header-group {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .logo img {
        max-height: 40px;
    }

    /* Typography mobile */
    h1 {
        font-size: 1.75rem;
        line-height: 1.3;
    }

    h2 {
        font-size: 1.5rem;
        line-height: 1.3;
    }

    h3 {
        font-size: 1.25rem;
        line-height: 1.3;
    }

    .splide__slide__caption {
        bottom: 1rem;
        left: 1rem;
        padding: 0.5rem;
        margin: 0;
    }

    h4 {
        font-size: 1.1rem;
        line-height: 1.3;
    }
}

.main-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    padding: 2rem 0;
}

@media (min-width: 960px) {
    .main-content {
        grid-template-columns: 3fr 1fr;
    }

    .content-grid {
        grid-column: 1 / 2;
    }

    .trending-sidebar {
        grid-column: 2 / 3;
    }
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

.article-card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
}

.article-card img {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.article-card h4 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    margin: 1rem;
}

.article-card h4 a {
    text-decoration: none;
    color: var(--color-text);
}

.article-card p {
    margin: 0 1rem 1rem;
    font-size: 0.9rem;
}

.tags {
    margin: 0 1rem 1rem;
}

.tags a {
    font-family: var(--font-ui);
    font-size: 0.8rem;
    text-decoration: none;
    color: var(--color-secondary);
    margin-right: 0.5rem;
}

.trending-sidebar {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1rem;
    box-sizing: border-box;
}

.trending-sidebar h4 {
    font-family: var(--font-display);
    margin-top: 0;
}

.trending-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.trending-sidebar li a {
    text-decoration: none;
    color: var(--color-text);
    font-size: 0.9rem;
    display: block;
    padding: 0.5rem 0;
}

.tag-rows {
    padding: 2rem 0;
    background-color: var(--color-surface);
    border-top: 1px solid var(--color-border);
}

.tag-rows h4 {
    font-family: var(--font-display);
    margin-top: 0;
    text-align: center;
}

.tag-rows .tags {
    text-align: center;
}

footer {
    text-align: center;
    padding: 2rem 0;
    font-size: 0.9rem;
    color: var(--color-secondary);
}

.article-hero-image {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    margin-bottom: 1.5rem;
    border-radius: 8px;
}

.carousel-item {
    position: relative !important;
}

.carousel-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.9);
    padding: 2rem 1rem;
    box-sizing: border-box;
    z-index: 10;
    top: auto !important;
}

.carousel-caption h3 {
    margin: 0;
    color: #ffffff !important;
    font-family: Arial, sans-serif !important;
    font-size: 24px !important;
    font-weight: bold !important;
    text-shadow: 2px 2px 4px #000000 !important;
    line-height: 1.2 !important;
}

.carousel-caption h3 a {
    color: #ffffff !important;
    text-decoration: none !important;
    font-size: 24px !important;
    font-weight: bold !important;
    font-family: Arial, sans-serif !important;
    display: block !important;
    line-height: 1.2 !important;
}

/* Hide non-active carousel items */
.carousel-item:not(:first-child) {
    display: none !important;
}

.carousel {
    overflow-x: hidden !important;
    overflow-y: hidden !important;
}

.carousel-item {
    overflow: hidden !important;
    max-height: 600px !important;
}