/* ====== Base Reset ====== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ====== Variables ====== */
:root {
    --bg: #ffffff;
    --text: #000000; /* pure black for readability */
    --border: rgba(0,0,0,0.1);
    --accent: #0077ff;
    --link: #0000EE;
    --highlight: #ffffff;
}

body.dark {
    --bg: #121212;
    --text: #f0f0f0; /* light text in dark mode */
    --border: rgba(255,255,255,0.1);
    --accent: #bb86fc;
    --link: #bb86fc;
    --highlight: #222;
}

/* Force text visibility in light mode */
body:not(.dark) h1, body:not(.dark) h2, body:not(.dark) h3,
body:not(.dark) h4, body:not(.dark) h5, body:not(.dark) h6,
body:not(.dark) p, body:not(.dark) span, body:not(.dark) a {
    color: #000 !important;
}

/* ====== Body ====== */
body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* ====== Header ====== */
header.site-header {
    border-bottom: 1px solid var(--border);
    padding: 10px 20px;
    background: var(--bg);
    position: relative;
    z-index: 5;
    margin-top: 14px;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
}

.logo img {
    height: 40px;
    width: auto;
    object-fit: contain;
}

/* ====== Search Bar ====== */
.search-bar {
    position: relative; /* crucial for absolute dropdown */
    flex: 1;
    display: flex;
    justify-content: center;
    margin-top: 10px;
}


.search-bar form {
    position: relative;
    width: 100%;
    max-width: 400px;
}

.search-bar input[type="text"] {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

.search-bar input[type="text"]:focus {
    border-color: var(--accent);
    outline: none;
}

.search-bar input[type="submit"] {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--accent);
    font-weight: bold;
    cursor: pointer;
}

.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    max-height: 400px;
    overflow-y: auto;
    display: none;
    z-index: 9999;
    padding: 0.5rem 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.search-results-dropdown a {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text);
    text-decoration: none;
}

.search-results-dropdown a:hover {
    background: var(--accent);
    color: #fff;
}

.live-search-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-width: 350px;
}

.live-search-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.live-search-item:hover {
    background: var(--accent);
    color: #fff;
}

.live-search-item:hover a,
.live-search-item:hover .search-author {
    color: #fff;
}

.search-thumb img {
    width: 30px;
    height: 45px;
    object-fit: cover;
    border-radius: 4px;
}

.search-info {
    display: flex;
    flex-direction: column;
}

.search-title {
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
}

.search-author {
    font-size: 11px;
    color: #666;
}

.no-results {
    display: block;
    padding: 0.5rem 1rem;
    color: #999;
}

/* ====== Header Right Section ====== */
.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.header-links {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.header-links a {
    text-decoration: none;
    color: var(--text);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-links a:hover {
    color: var(--accent);
    opacity: 0.85;
}

.discord-icon,
.bookmark-icon,
.user-avatar {
    width: 36px;
    height: 36px;
    fill: currentColor;
    border-radius: 50%;
    object-fit: cover;
    transition: transform 0.2s ease, color 0.2s ease;
}

.header-links a:hover .discord-icon,
.header-links a:hover .bookmark-icon,
.user-menu:hover .user-avatar {
    transform: scale(1.1);
    color: var(--accent);
}

/* ====== Theme Toggle ====== */
.theme-toggle {
    cursor: pointer;
    font-size: 20px;
    border: none;
    background: none;
    color: var(--text);
    transition: transform 0.3s ease, color 0.3s ease;
}

.theme-toggle:hover {
    transform: rotate(20deg) scale(1.1);
    color: var(--accent);
}

/* ====== User Menu Dropdown ====== */
.user-menu {
    position: relative;
    display: flex;
    align-items: center;
}

.user-dropdown {
    position: absolute;
    top: 46px;
    right: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-radius: 8px;
    display: none;
    flex-direction: column;
    min-width: 160px;
    z-index: 50;
}

.user-dropdown a {
    padding: 10px 15px;
    font-size: 14px;
    text-decoration: none;
    color: var(--text);
    transition: background 0.2s ease;
}

.user-dropdown a:hover {
    background: var(--accent);
    color: #fff;
}

/* ====== Site Message ====== */
.site-message {
    text-align: center;
    background: var(--highlight);
    color: var(--text);
    padding: 10px 15px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 6px;
    margin-top: 10px;
}

.site-message a {
    color: var(--link);
    text-decoration: underline;
    font-weight: 600;
}

/* ====== Modal & Form Styling ====== */
.modal {
    display: none;
    position: fixed;
    z-index: 999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.show {
    display: block;
    opacity: 1;
}

.modal-content {
    background-color: var(--bg);
    color: var(--text);
    margin: 10% auto;
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    transform: translateY(-20px);
    transition: transform 0.3s ease, background-color 0.3s ease, color 0.3s ease;
}

.modal.show .modal-content {
    transform: translateY(0);
}

.modal .close {
    position: absolute;
    top: 10px;
    right: 15px;
    cursor: pointer;
    font-size: 22px;
    color: var(--text);
    transition: color 0.3s ease;
}

.modal .close:hover {
    color: var(--accent);
}

.modal-content form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-content label {
    font-size: 14px;
    margin-bottom: 4px;
}

.modal-content input[type="text"],
.modal-content input[type="email"],
.modal-content input[type="password"] {
    padding: 10px 14px;
    font-size: 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    transition: border 0.3s ease, background 0.3s ease, color 0.3s ease;
}

.modal-content input[type="text"]:focus,
.modal-content input[type="email"]:focus,
.modal-content input[type="password"]:focus {
    outline: none;
    border-color: var(--accent);
}

.modal-content input[type="submit"] {
    cursor: pointer;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    border: none;
    border-radius: 8px;
    padding: 10px 0;
    transition: background 0.3s ease;
}

.modal-content input[type="submit"]:hover {
    opacity: 0.85;
}

.modal-content a {
    color: var(--accent);
    text-decoration: underline;
    font-size: 13px;
    cursor: pointer;
}

.modal-content a:hover {
    opacity: 0.8;
}

/* Dark mode modal overrides */
body.dark .modal-content {
    background: #1c1c1c;
    color: #f0f0f0;
}

body.dark .modal-content input[type="text"],
body.dark .modal-content input[type="email"],
body.dark .modal-content input[type="password"] {
    background: #121212;
    color: #f0f0f0;
    border: 1px solid rgba(255,255,255,0.2);
}

body.dark .modal-content input[type="submit"] {
    background: #bb86fc;
}


/* ===== Fix faint text in light mode ===== */
body:not(.dark) {
    color: #000 !important;
}

body:not(.dark) a,
body:not(.dark) .header-links a,
body:not(.dark) .search-bar input[type="text"],
body:not(.dark) .search-bar input::placeholder,
body:not(.dark) .search-title,
body:not(.dark) .search-author,
body:not(.dark) .theme-toggle,
body:not(.dark) .discord-icon,
body:not(.dark) .bookmark-icon {
    color: #000 !important;
    opacity: 1 !important;
}

body:not(.dark) .search-bar input {
    border-color: rgba(0,0,0,0.2) !important;
    background: #fff !important;
}

body:not(.dark) .header-links a:hover {
    color: #0077ff !important;
}


.mobile-search-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 0;
}
/* --- NEW & IMPROVED: Unify All Icon Sizes (Desktop & Mobile) --- */

/* 1. Set a uniform size for icon CONTAINERS (Bookmark, Discord, Search, Theme Toggle, User) */
.header-right .header-links a[title="Bookmarks"],
.header-right .header-links a[title="Discord"],
.header-right .mobile-search-toggle,
.header-right .theme-toggle, /* Now applies to the button containing the SVGs */
.header-right .user-menu {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0; /* Ensure no padding interferes */
    border-radius: 50%; /* Make background circular if desired */
}

/* 2. Set a uniform size for the actual ICONS (SVGs and user avatar) */
.header-right svg,
.header-right .user-avatar {
    width: 26px;
    height: 26px;
}

/* 3. Initial state for theme toggle SVGs (moon hidden by default for light mode) */
.header-right .theme-toggle .moon-icon {
    display: none; /* Hide moon icon by default in CSS */
}
.dark .header-right .theme-toggle .sun-icon {
    display: none; /* Hide sun icon when dark mode is active */
}
.dark .header-right .theme-toggle .moon-icon {
    display: block; /* Show moon icon when dark mode is active */
}

/* Hides the mobile search icon on desktop */
.mobile-search-toggle {
    display: none !important;
}
 
/* ====== Mobile Layout ====== */
@media (max-width: 768px) {
    .header-inner {
        display: flex !important;
        flex-wrap: wrap !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important; /* Forces vertical center alignment for logo/icons */
        row-gap: 10px !important;
    }
    
    /* Fix Logo Alignment & Size */
    .wrap_branding, .logo {
        width: auto !important;
        order: 1 !important;
    }
    
    .logo img {
        height: 32px !important; /* Matched to icon height to fix alignment */
        object-fit: contain;
        margin-top: 0 !important; /* Removes any top margin pushing it down/up */
    }

    .header-right {
        order: 2 !important;
        /* FIXED: Consistent gap for all mobile icons */
        gap: 8px !important; 
        display: flex !important;
        align-items: center !important;
    }
    
    /* FIXED: Remove margins from 18+ link on mobile so GAP handles the spacing */
    #ageGateToggle {
        margin: 0 !important;
    }
    
    /* FIXED: Smaller Icon Containers for Mobile */
    .header-right .header-links a[title="Bookmarks"],
    .header-right .header-links a[title="Discord"],
    .header-right .mobile-search-toggle,
    .header-right .theme-toggle,
    .header-right .user-menu {
        width: 30px !important; /* Reduced from 38px */
        height: 30px !important;
    }

    /* FIXED: Smaller Icons/SVG for Mobile */
    .header-right svg,
    .header-right .user-avatar {
        width: 30px !important; /* Reduced from 26px */
        height: 30px !important;
    }

    /* The search bar is hidden by default on mobile */
    .search-bar {
        display: none !important;
    }
    
    /* This class, added by JS, makes the search bar appear */
    .search-bar.mobile-visible {
        display: flex !important;
        order: 3 !important;
        width: 100% !important;
        margin: 0 !important;
    }

    /* Show the mobile search icon button */
    .mobile-search-toggle {
        display: flex !important;
    }

    /* Hide the text links on mobile */
    .header-links a[href*="contact"],
    .header-links a[href*="ko-fi"] {
        display: none !important;
    }

    .site-message {
        font-size: 14px;
        padding: 8px 12px;
        margin-top: 10px;
    }
    .modal-content {
        width: 90%;
        padding: 18px 20px;
    }
    .user-dropdown {
        position: absolute !important; /* keep it absolute to avatar */
        top: 46px;
        right: 0; /* aligned to the right of avatar */
        left: auto; /* override any left positioning */
        max-width: calc(100vw - 20px); /* prevent it from exceeding screen */
        box-sizing: border-box;
    }
    
    .manga-card {
        width: 48%;
        margin: 0 1% 15px;
    }
}

.rewarded-ad-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: #0073e6;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s ease;
}
.rewarded-ad-btn:hover {
  background-color: #005bb5;
}
.rewarded-ad-btn svg {
  stroke: #fff;
}


/* ---------------------------------------------------------
        2. The "18+" Header Button Styles (Clean & Transparent)
        --------------------------------------------------------- */
        #ageGateToggle {
            color: inherit !important;      /* Matches your header text color exactly */
            text-decoration: none !important;
            margin: 0 10px;                 /* Spacing */
            transition: all 0.3s ease;      /* Smooths the glow animation */
            cursor: pointer;
            display: inline-flex;
            align-items: center;
        }

        /* Hover Effect: Red Text + Red Glow */
        #ageGateToggle:hover,
        #ageGateToggle:focus {
            color: #ff0000 !important;      /* Bright Red Text */
            text-shadow: 0 0 8px rgba(255, 0, 0, 0.8), 0 0 15px rgba(255, 0, 0, 0.4); /* The Glow */
            transform: scale(1.05);         /* Slight zoom for better effect */
        }

        /* ---------------------------------------------------------
        3. Modal Content Typography
        --------------------------------------------------------- */
        #ageGateModal .modal-content h2 {
            font-size: 2.5em; 
            font-weight: 900;
            color: var(--heading-color, #333);
            margin: 0 0 20px 0;
            text-align: center;
            line-height: 1;
            letter-spacing: -1px;
        }
        body.dark #ageGateModal .modal-content h2 {
            color: var(--heading-color-dark, #fff);
        }

        #ageGateModal .modal-content p {
            color: var(--body-font-color, #555);
            font-size: 1.1em;
            line-height: 1.5;
            text-align: center;
            margin-bottom: 10px;
        }
        body.dark #ageGateModal .modal-content p {
            color: var(--body-font-color-dark, #ccc);
        }

        /* The small disclaimer text */
        #ageGateModal .modal-content p:last-of-type {
            font-size: 0.85em;
            opacity: 0.7;
            margin-bottom: 30px;
        }

        /* ---------------------------------------------------------
        4. Modal Action Buttons (Yes/No)
        --------------------------------------------------------- */
        .age-gate-buttons {
            display: flex;
            flex-direction: row;
            justify-content: space-between;
            gap: 15px;
        }

        .age-gate-btn {
            flex: 1; /* Both buttons take equal width */
            padding: 12px 15px;
            border: none;
            border-radius: 6px;
            font-size: 1em;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.2s ease;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        /* "No" Button */
        .age-gate-no {
            background-color: #e9ecef;
            color: #495057;
        }
        .age-gate-no:hover {
            background-color: #dee2e6;
            color: #212529;
        }
        /* Dark mode "No" button */
        body.dark .age-gate-no {
            background-color: #343a40;
            color: #dee2e6;
        }
        body.dark .age-gate-no:hover {
            background-color: #495057;
            color: #fff;
        }

        /* "Yes" Button */
        .age-gate-yes {
            background-color: var(--primary-color, #e60000);
            color: #fff;
            box-shadow: 0 4px 6px rgba(230, 0, 0, 0.2);
        }
        .age-gate-yes:hover {
            background-color: var(--primary-color-darker, #cc0000); /* Darker red */
            transform: translateY(-2px);
            box-shadow: 0 6px 8px rgba(230, 0, 0, 0.3);
        }

        /* ---------------------------------------------------------
        5. Mobile Responsiveness
        --------------------------------------------------------- */
        @media (max-width: 480px) {
            .age-gate-buttons {
                flex-direction: column-reverse; /* Stack buttons, "Yes" on top visually or change order as preferred */
                gap: 10px;
            }
            
            .age-gate-btn {
                width: 80%;
                padding: 15px; /* Larger touch target */
            }

        }


/* ====== Front Page Manga Grid ====== */
/* Styles moved from front-page.php for theme consistency */
.page-content-listing.item-default {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 10px;
}

.page-content-listing.item-default .page-item-detail {
    flex: 1 1 calc(20% - 10px);
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.page-content-listing.item-default .page-item-detail:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.page-item-detail .item-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 3/4;
    overflow: hidden;
}

.page-item-detail .item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    display: block;
    transition: opacity 0.2s ease;
}

.page-item-detail:hover .item-thumb img {
    opacity: 0.9;
}

.page-item-detail .item-thumb .meta-item.rating {
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(0,0,0,0.6);
    color: #ffd700;
    font-weight: 600;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 4px;
    z-index: 2;
}

body.dark .page-item-detail .item-thumb .meta-item.rating {
    background: rgba(255, 255, 255, 0.15);
    color: #ffdf80;
}

.page-item-detail .item-summary {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 8px 6px 10px;
    color: var(--text);
}

.page-item-detail .item-summary .list-chapter li:not(:first-child) {
    display: none !important;
}

.page-item-detail .item-summary .list-chapter li:first-child {
    display: block !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.page-item-detail .item-summary .list-chapter li:first-child * {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-item-detail .item-summary .post-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
    font-size: 14px;
    margin-top: 6px;
}

.page-item-detail .item-summary .post-title a {
    color: var(--text);
    text-decoration: none;
    transition: color 0.2s ease;
}

.page-item-detail:hover .item-summary .post-title a {
    color: var(--accent);
}

@media (max-width: 1024px) {
    .page-content-listing.item-default .page-item-detail {
        flex: 1 1 calc(25% - 10px);
    }
}

@media (max-width: 767px) {
    .page-content-listing.item-default .page-item-detail {
        flex: 1 1 calc(50% - 10px);
    }
}

/* Rewarded Ad System (Unique Namespaced Styles) */
.rewarded-modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.85);
  justify-content: center;
  align-items: center;
}
.rewarded-modal.show {
  display: flex;
}
.rewarded-modal-content {
  background: #111;
  color: #fff;
  border-radius: 12px;
  padding: 20px;
  width: 90%;
  max-width: 700px;
  box-shadow: 0 0 25px rgba(0,0,0,0.6);
  position: relative;
}
#closeRewardedAd {
  position: absolute;
  top: 10px;
  right: 10px;
  cursor: pointer;
  font-size: 22px;
}
.go-adfree-btn {
  background: #f39c12;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.3s ease;
}
.go-adfree-btn:hover {
  background: #e67e22;
}

