/*
Theme Name: CodeMarket
Theme URI: https://yoursite.com
Author: Your Name
Description: A clean, professional affiliate website theme for CodeCanyon and Codester products.
Version: 1.0.0
Requires at least: 5.8
Tested up to: 6.7
Requires PHP: 7.4
License: GNU General Public License v2 or later
Text Domain: codemarket
Tags: affiliate, marketplace, custom-colors, custom-menu, featured-images
*/

/* ============================================================
   RESET & BASE
============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --brand-dark: #0f3460; --brand-mid: #16213e; --brand-deep: #1a1a2e;
    --accent: #e94560; --accent-hover: #c73650;
    --cc-green: #21ba45; --cc-green-bg: rgba(33,186,69,0.08); --cc-green-bdr: rgba(33,186,69,0.25);
    --cs-blue: #2185d0;  --cs-blue-bg: rgba(33,133,208,0.08);  --cs-blue-bdr: rgba(33,133,208,0.25);
    --bg: #f7f8fc; --surface: #ffffff; --surface-2: #f0f2f8;
    --border: #e4e6ef; --border-light: #edeef5;
    --text: #1a1a2e; --text-muted: #6b7280; --text-light: #9ca3af; --star: #f59e0b;
    --radius-sm: 6px; --radius-md: 10px; --radius-lg: 14px; --radius-xl: 20px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06); --shadow-md: 0 4px 16px rgba(0,0,0,0.08); --shadow-lg: 0 8px 32px rgba(0,0,0,0.10);
    --transition: 0.18s ease;
    --font-sans: 'DM Sans','Segoe UI',sans-serif; --font-display: 'DM Serif Display',Georgia,serif;
}
html { scroll-behavior: smooth; }
body { font-family: var(--font-sans); font-size: 16px; line-height: 1.6; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { cursor: pointer; font-family: inherit; }
h1,h2,h3,h4,h5,h6 { font-family: var(--font-display); line-height: 1.25; color: var(--text); }
h1 { font-size: 2.6rem; } h2 { font-size: 2rem; } h3 { font-size: 1.4rem; }
p { margin-bottom: 1rem; } p:last-child { margin-bottom: 0; }

/* LAYOUT */
.cm-container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }

/* HEADER */
#masthead { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 200; box-shadow: var(--shadow-sm); }
.site-header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 1.5rem; }
.site-branding { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.site-logo-icon { width: 36px; height: 36px; background: var(--brand-dark); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: white; font-size: 14px; font-weight: 700; font-family: var(--font-display); }
.site-title { font-family: var(--font-display); font-size: 1.35rem; color: var(--brand-dark); margin: 0; }
.site-title span { color: var(--accent); }
.primary-menu-wrapper { flex: 1; }
.primary-menu { display: flex; gap: 0.25rem; align-items: center; }
.primary-menu li a { display: block; padding: 6px 12px; font-size: 0.875rem; font-weight: 500; color: var(--text-muted); border-radius: var(--radius-sm); transition: color var(--transition), background var(--transition); }
.primary-menu li a:hover, .primary-menu li.current-menu-item a { color: var(--brand-dark); background: var(--surface-2); }
.header-search-form { display: flex; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); height: 38px; overflow: hidden; transition: border-color var(--transition); }
.header-search-form:focus-within { border-color: var(--brand-dark); box-shadow: 0 0 0 3px rgba(15,52,96,0.08); }
.header-search-form input[type="search"] { border: none; background: none; outline: none; padding: 0 12px; font-size: 0.875rem; font-family: inherit; color: var(--text); width: 200px; }
.header-search-form input::placeholder { color: var(--text-light); }
.header-search-form button { border: none; background: none; padding: 0 12px; color: var(--text-muted); height: 100%; transition: color var(--transition); }
.header-search-form button:hover { color: var(--brand-dark); }
.menu-toggle { display: none; border: 1px solid var(--border); background: var(--surface); padding: 7px 10px; border-radius: var(--radius-sm); font-size: 18px; color: var(--text); }

/* HERO */
.hero-section { background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand-mid) 55%, var(--brand-deep) 100%); color: white; padding: 5rem 0 4rem; position: relative; overflow: hidden; }
.hero-section::before { content:''; position: absolute; inset: 0; background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none'%3E%3Cg fill='%23ffffff' fill-opacity='0.025'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") repeat; }
.hero-inner { position: relative; text-align: center; max-width: 680px; margin: 0 auto; }
.hero-badge { display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.18); border-radius: 30px; padding: 5px 16px; font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; color: rgba(255,255,255,0.85); margin-bottom: 1.5rem; }
.hero-section h1 { color: white; font-size: 3rem; line-height: 1.18; margin-bottom: 1.2rem; }
.hero-section h1 em { color: var(--accent); font-style: italic; }
.hero-section .hero-desc { color: rgba(255,255,255,0.68); font-size: 1.05rem; margin-bottom: 2rem; }
.hero-search-wrap { display: flex; max-width: 520px; margin: 0 auto 2rem; background: white; border-radius: var(--radius-lg); overflow: hidden; box-shadow: 0 8px 32px rgba(0,0,0,0.18); }
.hero-search-wrap input[type="search"] { flex: 1; border: none; outline: none; padding: 14px 20px; font-size: 0.95rem; font-family: inherit; color: var(--text); }
.hero-search-wrap button[type="submit"] { background: var(--accent); color: white; border: none; padding: 0 28px; font-size: 0.9rem; font-weight: 600; white-space: nowrap; transition: background var(--transition); font-family: inherit; }
.hero-search-wrap button:hover { background: var(--accent-hover); }
.hero-source-pills { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.source-pill { display: flex; align-items: center; gap: 7px; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); border-radius: 8px; padding: 6px 14px; font-size: 0.82rem; color: rgba(255,255,255,0.85); }
.pill-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.pill-dot--green { background: var(--cc-green); }
.pill-dot--blue  { background: var(--cs-blue); }

/* STATS BAR */
.stats-bar { background: var(--surface); border-bottom: 1px solid var(--border); }
.stats-bar-inner { display: flex; justify-content: center; align-items: center; padding: 1rem 0; flex-wrap: wrap; }
.stat-item { text-align: center; padding: 0.5rem 2.5rem; border-right: 1px solid var(--border-light); }
.stat-item:last-child { border-right: none; }
.stat-number { font-size: 1.4rem; font-weight: 700; color: var(--brand-dark); font-family: var(--font-display); line-height: 1; }
.stat-label { font-size: 0.73rem; color: var(--text-light); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.05em; }

/* FILTER BAR */
.filter-bar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0.9rem 0; position: sticky; top: 64px; z-index: 100; }
.filter-bar-inner { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-label { font-size: 0.78rem; font-weight: 600; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.05em; margin-right: 4px; flex-shrink: 0; }
.filter-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); padding: 5px 14px; border-radius: 20px; font-size: 0.82rem; font-weight: 500; transition: all var(--transition); white-space: nowrap; }
.filter-btn:hover, .filter-btn.is-active { background: var(--brand-dark); border-color: var(--brand-dark); color: white; }
.source-filters { margin-left: auto; display: flex; gap: 6px; }
.source-filter-btn { display: flex; align-items: center; gap: 6px; border: 1px solid; border-radius: var(--radius-sm); padding: 5px 12px; font-size: 0.8rem; font-weight: 600; transition: all var(--transition); background: transparent; }
.source-filter-btn--cc { color: #0d6e24; border-color: var(--cc-green-bdr); background: var(--cc-green-bg); }
.source-filter-btn--cs { color: #0d4f8a; border-color: var(--cs-blue-bdr); background: var(--cs-blue-bg); }
.source-filter-btn:hover { opacity: 0.75; }

/* PRODUCT CARDS */
.products-section { padding: 2.5rem 0 4rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.section-head h2 { font-size: 1.3rem; }
.section-head .see-all { font-size: 0.85rem; color: var(--brand-dark); font-weight: 600; border-bottom: 1px solid transparent; transition: border-color var(--transition); }
.section-head .see-all:hover { border-color: var(--brand-dark); }
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.25rem; }
.product-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition); display: flex; flex-direction: column; }
.product-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--brand-dark); }
.card-thumbnail { position: relative; aspect-ratio: 16/10; overflow: hidden; background: var(--surface-2); display: block; width: 100%; }
.card-thumbnail a { display: block; width: 100%; height: 100%; }
.card-thumbnail img,
.card-thumbnail a img,
.card-thumbnail .wp-post-image,
.card-thumbnail a .wp-post-image { width: 100% !important; height: 100% !important; max-width: 100% !important; object-fit: cover !important; display: block !important; transition: transform 0.4s ease; }
.product-card:hover .card-thumbnail img,
.product-card:hover .card-thumbnail .wp-post-image { transform: scale(1.04); }
.card-thumbnail-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 2.5rem; }

/* Fix WordPress attachment image classes inside thumbnails */
.card-thumbnail [class*="attachment-"],
.card-thumbnail [class*="size-"] { width: 100% !important; height: 100% !important; max-width: none !important; object-fit: cover !important; }
.card-source-badge { position: absolute; top: 10px; left: 10px; border-radius: 5px; padding: 3px 9px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.card-source-badge--cc { background: var(--cc-green-bg); color: #0d6e24; border: 1px solid var(--cc-green-bdr); }
.card-source-badge--cs { background: var(--cs-blue-bg); color: #0d4f8a; border: 1px solid var(--cs-blue-bdr); }
.card-sale-badge { position: absolute; top: 10px; right: 10px; background: var(--accent); color: white; border-radius: 5px; padding: 3px 9px; font-size: 0.7rem; font-weight: 700; }
.card-body { padding: 14px 16px; flex: 1; display: flex; flex-direction: column; }
.card-category { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-light); margin-bottom: 5px; font-weight: 600; }
.card-title { font-size: 0.9rem; font-weight: 600; color: var(--text); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 10px; font-family: var(--font-sans); flex: 1; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-rating { display: flex; align-items: center; gap: 4px; }
.stars { color: var(--star); font-size: 12px; letter-spacing: -0.5px; }
.rating-number { font-size: 0.75rem; font-weight: 600; color: var(--text); }
.card-sales { font-size: 0.72rem; color: var(--text-light); }
.card-footer { border-top: 1px solid var(--border-light); padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-price { display: flex; align-items: baseline; gap: 5px; }
.price-current { font-size: 1.1rem; font-weight: 700; color: var(--brand-dark); font-family: var(--font-display); }
.price-original { font-size: 0.78rem; color: var(--text-light); text-decoration: line-through; }
.card-cta { background: var(--brand-dark); color: white; border: none; padding: 7px 14px; border-radius: var(--radius-sm); font-size: 0.78rem; font-weight: 600; white-space: nowrap; transition: background var(--transition), transform var(--transition); text-decoration: none; display: inline-block; }
.card-cta:hover { background: var(--accent); transform: scale(1.02); color: white; }

/* FEATURED CARD */
.featured-card { grid-column: 1/-1; display: grid; grid-template-columns: 1.2fr 1fr; border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); border: 1px solid var(--border); transition: box-shadow var(--transition); }
.featured-card:hover { box-shadow: var(--shadow-lg); }
.featured-card .card-thumbnail { aspect-ratio: auto; min-height: 220px; }
.featured-card .card-thumbnail a { width: 100%; height: 100%; display: block; }
.featured-card .card-thumbnail img,
.featured-card .card-thumbnail .wp-post-image { width: 100% !important; height: 100% !important; object-fit: cover !important; }

/* Single product screenshot */
.product-screenshot { border-radius: var(--radius-lg); border: 1px solid var(--border); overflow: hidden; background: var(--surface-2); aspect-ratio: 16/10; width: 100%; display: block; }
.product-screenshot img,
.product-screenshot .wp-post-image,
.product-screenshot [class*="attachment-"],
.product-screenshot [class*="size-"] { width: 100% !important; height: 100% !important; max-width: 100% !important; object-fit: cover !important; display: block !important; }
.product-screenshot a { display: block; width: 100%; height: 100%; }
.featured-card .card-body { padding: 1.8rem; justify-content: center; }
.featured-card .card-title { font-size: 1.15rem; -webkit-line-clamp: 3; margin-bottom: 1rem; font-family: var(--font-display); }
.featured-badge { display: inline-flex; align-items: center; gap: 5px; background: rgba(233,69,96,0.1); color: var(--accent); border: 1px solid rgba(233,69,96,0.2); border-radius: 4px; padding: 3px 10px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 10px; width: fit-content; }

/* CATEGORIES */
.categories-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.category-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.25rem 1rem; text-align: center; transition: all var(--transition); cursor: pointer; display: block; text-decoration: none; color: inherit; }
.category-card:hover { border-color: var(--brand-dark); background: var(--brand-dark); color: white; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.category-icon { font-size: 2rem; margin-bottom: 0.6rem; line-height: 1; }
.category-name { font-size: 0.875rem; font-weight: 600; margin-bottom: 3px; }
.category-count { font-size: 0.73rem; color: var(--text-light); }
.category-card:hover .category-count { color: rgba(255,255,255,0.6); }

/* CTA BANNER */
.cta-banner { background: linear-gradient(135deg, var(--brand-dark), var(--brand-deep)); color: white; padding: 3.5rem 0; text-align: center; }
.cta-banner h2 { color: white; margin-bottom: 0.75rem; }
.cta-banner p { color: rgba(255,255,255,0.65); font-size: 1rem; margin-bottom: 1.5rem; }
.cta-banner .btn-primary { background: var(--accent); color: white; border: none; padding: 13px 32px; border-radius: var(--radius-md); font-size: 0.95rem; font-weight: 600; transition: all var(--transition); display: inline-block; text-decoration: none; }
.cta-banner .btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(233,69,96,0.3); }

/* SIDEBAR */
.content-sidebar-wrap { display: grid; grid-template-columns: 1fr 300px; gap: 2rem; align-items: start; }
.widget-area { display: flex; flex-direction: column; gap: 1.25rem; }
.widget { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.25rem; }
.widget-title { font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-light); margin-bottom: 1rem; padding-bottom: 0.6rem; border-bottom: 1px solid var(--border-light); }
.source-widget-list { display: flex; flex-direction: column; gap: 6px; }
.source-widget-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: var(--radius-sm); transition: background var(--transition); text-decoration: none; color: inherit; }
.source-widget-item:hover { background: var(--surface-2); }
.source-widget-left { display: flex; align-items: center; gap: 8px; font-size: 0.875rem; font-weight: 500; }
.source-dot { width: 10px; height: 10px; border-radius: 50%; }
.source-count { font-size: 0.78rem; background: var(--surface-2); border-radius: 12px; padding: 2px 9px; color: var(--text-muted); }
.disclosure-widget { background: rgba(15,52,96,0.05); border: 1px solid rgba(15,52,96,0.12); border-radius: var(--radius-md); padding: 1rem 1.25rem; }
.disclosure-widget p { font-size: 0.78rem; color: var(--text-muted); line-height: 1.6; }

/* FOOTER */
#colophon { background: var(--brand-deep); color: rgba(255,255,255,0.65); padding-top: 3.5rem; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 2.5rem; padding-bottom: 3rem; border-bottom: 1px solid rgba(255,255,255,0.08); }
.footer-brand .site-title { font-family: var(--font-display); font-size: 1.4rem; color: white; margin-bottom: 0.75rem; }
.footer-brand .site-title span { color: var(--accent); }
.footer-brand p { font-size: 0.83rem; line-height: 1.7; color: rgba(255,255,255,0.55); }
.footer-disclosure { margin-top: 1rem; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 0.75rem; color: rgba(255,255,255,0.4); line-height: 1.5; }
.footer-col h4 { color: white; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 1rem; font-family: var(--font-sans); }
.footer-col ul { display: flex; flex-direction: column; gap: 8px; }
.footer-col a { font-size: 0.83rem; color: rgba(255,255,255,0.5); transition: color var(--transition); text-decoration: none; }
.footer-col a:hover { color: white; }
.footer-bottom { padding: 1.25rem 0; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem; font-size: 0.78rem; color: rgba(255,255,255,0.3); }

/* PAGINATION */
.pagination { display: flex; justify-content: center; align-items: center; gap: 6px; padding: 2rem 0; }
.pagination a, .pagination span { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: var(--radius-sm); font-size: 0.875rem; font-weight: 500; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); transition: all var(--transition); }
.pagination a:hover { background: var(--brand-dark); color: white; border-color: var(--brand-dark); }
.pagination .current { background: var(--brand-dark); color: white; border-color: var(--brand-dark); }

/* UTILS */
.screen-reader-text { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 20px; border-radius: var(--radius-md); font-size: 0.875rem; font-weight: 600; border: none; transition: all var(--transition); text-decoration: none; cursor: pointer; font-family: inherit; }
.btn-primary { background: var(--brand-dark); color: white; }
.btn-primary:hover { background: var(--accent); color: white; }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-hover); color: white; }

/* RESPONSIVE */
@media (max-width: 1024px) {
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .content-sidebar-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    .hero-section h1 { font-size: 2.2rem; }
    .primary-menu-wrapper { display: none; }
    .menu-toggle { display: flex; }
    .primary-menu-wrapper.is-open { display: block; position: fixed; inset: 64px 0 0 0; background: var(--surface); z-index: 150; padding: 1.5rem; border-top: 1px solid var(--border); overflow-y: auto; }
    .primary-menu-wrapper.is-open .primary-menu { flex-direction: column; gap: 4px; }
    .primary-menu-wrapper.is-open .primary-menu li a { padding: 10px 14px; font-size: 1rem; }
    .header-search-form { display: none; }
    .featured-card { grid-template-columns: 1fr; }
    .source-filters { display: none; }
    .footer-grid { grid-template-columns: 1fr; gap: 1.5rem; }
    .footer-bottom { flex-direction: column; text-align: center; }
    .products-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
    .products-grid { grid-template-columns: 1fr; }
    .categories-grid { grid-template-columns: repeat(2,1fr); }
}
