:root {
    --header-height: 130px;
}

body {
    font-family: system-ui, sans-serif;
    margin: 0;
    background: #f6f6f6;
}

/* HEADER */
header {
    background: #222;
    color: white;
    padding: 18px 24px;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}


/* top row */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* logo */
.logo {
    font-size: 22px;
    font-weight: bold;
    letter-spacing: 0.5px;
}

/* navigation */
nav {
    display: flex;
    gap: 28px;
    justify-content: flex-end;
    margin-top: 8px;
}

nav a {
    color: white;
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
    transition: border-color 0.2s ease, color 0.2s ease;
}

nav a:hover {
    border-bottom-color: #ffffff;
    text-decoration: none;
}

/* hamburger */
.hamburger {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0 8px;
    line-height: 1;
    transition: transform 0.2s ease;
}

/* controls */
.controls {
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    flex-wrap: nowrap;
}

/* flexible search */
#searchBox {
    padding: 10px 14px;
    font-size: 16px;
    flex: 1;
    min-width: 0;
    max-width: 400px;
    border: 1px solid #555;
    border-radius: 6px;
    background-color: #333;
    color: white;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#searchBox::placeholder {
    color: #aaa;
}

#searchBox:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
    background-color: #3a3a3a;
}


.language-select {
    padding: 10px 14px;
    font-size: 16px;
    border: 1px solid #555;
    border-radius: 6px;
    background-color: #333;
    color: white;
    cursor: pointer;
    min-width: 140px;
    flex-shrink: 0;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    appearance: none;
    /* Remove default arrow for custom styling */
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
    /* Make room for custom arrow */
}

.language-select:hover {
    background-color: #3a3a3a;
}

.language-select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

.language-select option {
    background-color: #333;
    color: white;
    padding: 8px;
}

/* main */
main {
    padding: 24px;
    margin-top: 10px;
}

#status {
    margin-bottom: 15px;
    color: #444;
}

/* results */
#results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    grid-auto-rows: auto;
}

.resultCard {
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    padding: 10px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.resultCard:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.resultCard img {
    width: 100%;
    border-radius: 4px;
}

.resultTitle {
    font-size: 14px;
    margin-bottom: 8px;
}

.resultCard.ad-card {
    cursor: default;
    background: linear-gradient(to bottom, #f9f9f9, #f0f0f0);
    border: 1px dashed #ccc;
    padding: 12px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.resultCard.ad-card .resultTitle {
    color: #666;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.resultCard.ad-card .ad-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 4px;
    margin: 10px 0;
    min-height: 100px;
}

.resultCard.ad-card .ad-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    min-height: 120px;
    width: 100%;
}

.resultCard.ad-card:hover {
    background: linear-gradient(to bottom, #f0f0f0, #e8e8e8);
    border-color: #999;
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.resultCard.ad-card .ad-label {
    color: #666;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    margin-bottom: 8px;
    font-weight: 500;
}

.resultCard.ad-card ins.adsbygoogle {
    min-width: 200px;
    min-height: 100px;
    max-width: 100%;
}

.adsbygoogle {
    display: block !important;
    width: 100%;
}

.home-ad {
    margin: 30px auto;
    max-width: 900px;
    min-height: 120px;
    background: linear-gradient(to bottom, #f9f9f9, #f0f0f0);
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.home-ad .ad-label {
    position: absolute;
    top: 8px;
    left: 12px;
    color: #888;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.home-ad ins.adsbygoogle {
    min-width: 320px;
    min-height: 100px;
    margin: 0 auto;
}


/* -------------------------------------------------- */
/* READER LAYOUT */
/* -------------------------------------------------- */

#reader {
    max-width: 1200px;
    margin: 0 auto;
}

#reader-header {
    position: sticky;
    top: var(--header-height);
    background: #f6f6f6;
    padding: 10px 0;
    z-index: 900;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.reader-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.reader-nav button {
    font-size: 24px;
    padding: 8px 24px;
    cursor: pointer;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.reader-nav button:hover {
    background: #f0f0f0;
    border-color: #999;
}

.reader-nav button:active {
    background: #e0e0e0;
}

.reader-page-indicator {
    text-align: center;
    font-weight: 600;
    font-size: 16px;
    padding: 4px 0;
    color: #444;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 4px;
    margin: 0 10px;
}

#reader-body {
    display: grid;
    grid-template-columns: 55% 45%;
    grid-template-areas:
        "image side";
    gap: 24px;
    align-items: start;
}

#reader-side {
    grid-area: side;
}

#reader-image {
    grid-area: image;
}

#reader-side {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#support-button {
    grid-area: support;
    display: block;
    align-self: start;
}

#reader-image img {
    width: 100%;
    height: auto;
    display: block;
}

#reader-text {
    grid-area: text;
    background: #ffffff;
    padding: 20px;
}

.reader-ad {
    margin: 30px auto;
    max-width: 900px;
    min-height: 120px;
    background: #f9f9f9;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #eee;
    position: relative;
    padding: 15px;
}

.reader-ad .ad-label {
    position: absolute;
    top: 6px;
    left: 12px;
    color: #999;
    font-size: 10px;
    text-transform: uppercase;
}

.reader-ad ins.adsbygoogle {
    min-width: 300px;
    min-height: 90px;
    margin: 0 auto;
}

.reader-nav button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #e0e0e0;
    border-color: #ccc;
}

.reader-nav button:disabled:hover {
    background: #e0e0e0;
    border-color: #ccc;
    transform: none;
}

.ad-label {
    font-family: system-ui, -apple-system, sans-serif;
    user-select: none;
    pointer-events: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/*-----------------------------------------------------*/
/* MOBILE */
/*-----------------------------------------------------*/

@media (max-width:700px) {

    :root {
        --header-height: 110px;
    }

    header {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        padding: 12px 16px;
    }

    .topbar {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: relative;
    }

    .logo {
        text-align: center;
        font-size: 20px;
        flex: 1;
        /* Allow logo to take available space */
        margin: 0 10px;
        /* Add some margin to prevent touching buttons */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        /* Add ellipsis if title is too long */
    }

    .hamburger {
        display: block;
        position: static;
        /* Changed from 'absolute' to 'static' */
        transform: none;
        /* Remove transform */
        flex-shrink: 0;
        /* Prevent hamburger from shrinking */
        width: 40px;
        /* Give it a fixed width */
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* If you have any other elements in the topbar (like a right-side button), 
       add this to maintain balance */
    .topbar-right {
        width: 40px;
        /* Match hamburger width for balance */
        flex-shrink: 0;
    }

    nav {
        display: none;
        flex-direction: column;
        align-items: center;
        gap: 0;
        margin-top: 16px;
        background-color: #2a2a2a;
        border-radius: 8px;
        padding: 8px 0;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        width: 100%;
    }

    nav.open {
        display: flex;
    }

    nav a {
        width: 100%;
        text-align: center;
        padding: 14px 0;
        border-bottom: 1px solid #444;
        font-size: 18px;
    }

    nav a:last-child {
        border-bottom: none;
    }

    nav a:hover {
        background-color: #3a3a3a;
        border-bottom-color: transparent;
    }

    .controls {
        flex-direction: row;
        justify-content: space-between;
        gap: 8px;
        width: 100%;
        margin-top: 16px;
        flex-wrap: nowrap;
    }

    #searchBox {
        flex: 1;
        min-width: 0;
        max-width: none;
    }

    .language-select {
        min-width: 120px;
        padding: 8px 12px;
        padding-right: 32px;
        font-size: 14px;
        background-position: right 8px center;
    }

    .home-ad {
        margin: 20px 10px;
        min-height: 100px;
        padding: 15px;
    }

    .home-ad ins.adsbygoogle {
        min-width: 250px;
    }

    .resultCard.ad-card {
        min-height: 180px;
        padding: 10px;
    }

    .resultCard.ad-card .ad-container {
        min-height: 100px;
    }

    #reader-header {
        top: 110px;
        gap: 6px;
        padding: 8px 0;
    }

    .reader-nav {
        gap: 12px;
    }

    .reader-nav button {
        font-size: 20px;
        padding: 8px 20px;
    }

    .reader-page-indicator {
        font-size: 14px;
        padding: 6px 0;
        margin: 0 8px;
    }

    #reader-body {
        grid-template-columns: 1fr;
        grid-template-areas:
            "image"
            "side";
    }

    #reader-text {
        position: static;
    }

    .reader-ad {
        margin: 20px 10px;
        min-height: 100px;
        padding: 12px;
    }

    .reader-ad ins.adsbygoogle {
        min-width: 250px;
    }
}

@media (min-width:701px) {

    #reader-side {
        position: sticky;
        top: calc(var(--header-height) + 150px);
    }

}