/*
Theme Name: Menhj Watch
Theme URI: https://menhj.com
Author: Menhj
Description: Auto-fetches YouTube data from API and creates posts on /watch/{slug} URLs. Styled to match menhj.com.
Version: 1.6.4
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 7.4
License: GPL-2.0-or-later
Text Domain: menhj
*/

/* ===== Self-hosted Cairo font (variable, supports 200-1000 weight) ===== */
@font-face {
    font-family: 'Cairo';
    font-style: normal;
    font-weight: 200 1000;
    font-display: swap;
    src: url('assets/fonts/cairo-variable.woff2') format('woff2-variations'),
         url('assets/fonts/cairo-variable.woff2') format('woff2');
}

:root {
    --bg:           #f1f1f1;
    --surface:      #ffffff;
    --primary:      #5DC3E5;   /* sky blue accent */
    --primary-dk:   #2ba8ce;
    --header-bg:    #1c2777;   /* deep navy */
    --header-fg:    #ffffff;
    --pink:         #cd2653;   /* download / secondary CTA */
    --pink-hover:   #ee4682;
    --text:         #29333f;
    --text-muted:   #6d6d6d;
    --border:       #dcd7ca;
    --border-soft:  #ececec;
    --cream:        #f5efe0;
    --shadow:       0 2px 6px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 6px 20px rgba(28, 39, 119, 0.12);
    --radius:       12px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: "Cairo", "Tajawal", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    direction: rtl;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ===== Header ===== */
.site-header {
    background: var(--header-bg);
    color: var(--header-fg);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-title {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.site-title::before {
    content: "▶";
    color: var(--primary);
    margin-left: 8px;
    font-size: 18px;
}

.site-search {
    display: flex;
    flex: 1;
    max-width: 560px;
    margin: 0 auto;
    background: #fff;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.site-search input {
    flex: 1;
    padding: 10px 18px;
    border: 0;
    background: transparent;
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    outline: none;
}

.site-search button {
    padding: 10px 22px;
    background: var(--primary);
    color: #fff;
    border: 0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    transition: background 0.15s;
}

.site-search button:hover { background: var(--primary-dk); }

/* ===== Main ===== */
.site-main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 24px;
}

.page-title {
    font-size: 28px;
    font-weight: 800;
    margin: 0 0 24px;
    color: var(--text);
    padding-right: 14px;
    border-right: 5px solid var(--primary);
    line-height: 1.2;
}

/* ===== Featured player ===== */
.featured-player {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}

.featured-player iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.featured-meta {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 18px 22px;
    margin-bottom: 32px;
    box-shadow: var(--shadow);
}

.featured-meta h2 {
    font-size: 20px;
    margin: 0 0 10px;
    color: var(--text);
    font-weight: 700;
    line-height: 1.4;
}

.featured-meta .meta-row {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 12px;
}

.featured-meta .meta-duration {
    color: var(--primary-dk);
    font-weight: 700;
}

/* ===== v1.4.0: Auto-intro paragraph ===== */
.menhj-intro-wrap {
    background: linear-gradient(135deg, #fafbff 0%, #f5efe0 100%);
    border-right: 4px solid var(--primary);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}
.menhj-intro {
    margin: 0;
    line-height: 1.85;
    color: var(--text);
    font-size: 15px;
}

/* ===== v1.4.0: Reading-time badge ===== */
.read-badge {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    background: var(--cream);
    color: #664d03;
    padding: 7px 14px;
    border-radius: 18px;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 14px;
    border: 1px solid #e6dec7;
}

/* ===== v1.4.0: Transcript subheadings ===== */
.transcript-h {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-dk);
    margin: 18px 0 8px;
    padding-right: 10px;
    border-right: 3px solid var(--primary);
    line-height: 1.4;
}
.transcript-body p {
    margin: 0 0 12px;
    line-height: 1.95;
}

/* ===== Transcript ===== */
.video-transcript {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-right: 4px solid var(--primary);
    border-radius: var(--radius);
    padding: 18px 22px;
    margin-bottom: 32px;
    box-shadow: var(--shadow);
}

.video-transcript h3 {
    margin: 0 0 14px;
    color: var(--text);
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.video-transcript h3::before {
    content: "📝";
    font-size: 20px;
}

.transcript-body {
    max-height: 420px;
    overflow-y: auto;
    line-height: 1.95;
    color: var(--text);
    font-size: 15px;
    padding-left: 8px;
    white-space: pre-wrap;
    word-break: break-word;
}

.transcript-body::-webkit-scrollbar { width: 8px; }
.transcript-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.transcript-body::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== Video grid ===== */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 22px 18px;
}

.video-card {
    cursor: pointer;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
    display: flex;
    flex-direction: column;
}

.video-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary);
}

.thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #e8e8e8;
    overflow: hidden;
}

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

.duration {
    position: absolute;
    bottom: 8px;
    left: 8px;          /* RTL: bottom-left looks natural */
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 12px;
    padding: 3px 7px;
    border-radius: 5px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

html[dir="ltr"] .duration { right: 8px; left: auto; }

.video-info { padding: 12px 14px 14px; }

.video-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.45;
    min-height: 2.9em;
}

.video-channel {
    font-size: 13px;
    color: var(--primary-dk);
    margin: 0 0 4px;
    font-weight: 600;
}

.video-stats {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

/* ===== Download button ===== */
.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 9px 18px;
    background: var(--pink);
    color: #fff !important;
    border-radius: 22px;
    font-size: 14px;
    font-weight: 700;
    transition: background 0.15s, transform 0.1s;
    box-shadow: 0 2px 6px rgba(205, 38, 83, 0.25);
}

.download-btn:hover { background: var(--pink-hover); transform: translateY(-1px); }
.download-btn:active { transform: translateY(0); }

.download-btn.small {
    margin-top: 10px;
    padding: 6px 13px;
    font-size: 12px;
    border-radius: 16px;
    box-shadow: none;
}

/* ===== Homepage / recent list ===== */
.recent-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}

.recent-card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 18px 20px;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
    box-shadow: var(--shadow);
}

.recent-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.recent-card h3 {
    margin: 0 0 8px;
    font-size: 17px;
    color: var(--text);
    font-weight: 700;
    line-height: 1.4;
}

.recent-card .recent-meta {
    color: var(--text-muted);
    font-size: 13px;
}

/* ===== Footer ===== */
.site-footer {
    text-align: center;
    padding: 28px;
    color: var(--text-muted);
    font-size: 14px;
    background: var(--surface);
    border-top: 3px solid var(--primary);
    margin-top: 48px;
}

.site-footer a { color: var(--primary-dk); font-weight: 600; }

/* ===== Notices ===== */
.notice {
    background: var(--cream);
    color: #664d03;
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 18px;
    border-right: 4px solid var(--pink);
}

/* ===== Lite YouTube embed (loads only when clicked) ===== */
.lite-yt {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    box-shadow: var(--shadow);
}
.lite-yt::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,.55) 0%, transparent 25%, transparent 75%, rgba(0,0,0,.55) 100%);
    z-index: 1;
}
.lite-yt > img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: 0;
}
.lite-yt > .lite-yt-play {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 78px;
    height: 78px;
    background: var(--pink);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(0,0,0,.4);
    z-index: 2;
    transition: transform .18s, background .18s;
}
.lite-yt > .lite-yt-play::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-style: solid;
    border-width: 14px 0 14px 22px;
    border-color: transparent transparent transparent #fff;
}
.lite-yt:hover > .lite-yt-play { transform: scale(1.08); background: var(--pink-hover); }
.lite-yt > iframe { width: 100%; height: 100%; border: 0; position: absolute; inset: 0; z-index: 3; }

/* ===== Share buttons ===== */
.share-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--border-soft);
}
.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 18px;
    font-size: 13px;
    font-weight: 600;
    color: #fff !important;
    background: #555;
    border: 0;
    cursor: pointer;
    transition: opacity .15s, transform .1s;
    font-family: inherit;
}
.share-btn:hover { opacity: .9; transform: translateY(-1px); }
.share-btn.wa  { background: #25D366; }
.share-btn.tw  { background: #1DA1F2; }
.share-btn.tg  { background: #2AABEE; }
.share-btn.fb  { background: #1877F2; }
.share-btn.cp  { background: #6d6d6d; }
.share-btn.cp.copied { background: #46b450; }

/* ===== Related watch pages ===== */
.related-section { margin-top: 48px; }
.related-section h3 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
    padding-right: 12px;
    border-right: 5px solid var(--pink);
    margin: 0 0 20px;
    line-height: 1.2;
}
.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.related-card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform .18s, box-shadow .18s, border-color .18s;
    display: block;
}
.related-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
    border-color: var(--pink);
}
.related-card .thumb { aspect-ratio: 16 / 9; }
.related-card .title {
    padding: 10px 12px 12px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.8em;
}

/* ===== Pagination ===== */
.menhj-pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-top: 36px;
}
.menhj-pagination .page-numbers {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-soft);
    font-weight: 600;
    transition: background .12s, color .12s, border-color .12s;
}
.menhj-pagination .page-numbers:hover { border-color: var(--primary); }
.menhj-pagination .page-numbers.current {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.menhj-pagination .page-numbers.dots { background: transparent; border: 0; }

/* ===== v1.2.1: Category nav under header ===== */
.cat-nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border-soft);
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    position: sticky;
    top: 64px;
    z-index: 90;
}
.cat-nav-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 10px 20px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}
.cat-nav-inner::-webkit-scrollbar { height: 4px; }
.cat-nav-inner::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.cat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 20px;
    background: #f5f5f5;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: background .15s, color .15s, border-color .15s;
    flex-shrink: 0;
}
.cat-chip:hover { background: #e8e8e8; border-color: var(--primary); }
.cat-chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.cat-chip.cat-home { background: var(--header-bg); color: #fff; }
.cat-chip.cat-home:hover { background: #2c3a99; }
.cat-count {
    background: rgba(0,0,0,0.08);
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 700;
}
.cat-chip.active .cat-count { background: rgba(255,255,255,0.3); }
.cat-chip.cat-home .cat-count { background: rgba(255,255,255,0.18); }

/* ===== v1.2.0: Breadcrumbs ===== */
.menhj-crumbs {
    margin: 0 0 14px;
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}
.menhj-crumbs a { color: var(--primary-dk); font-weight: 600; }
.menhj-crumbs a:hover { text-decoration: underline; }
.menhj-crumbs .sep { color: #ccc; }
.menhj-crumbs [aria-current="page"] { color: var(--text); font-weight: 600; }

/* ===== v1.2.0: Cookie consent bar ===== */
.menhj-cookie {
    position: fixed;
    bottom: 14px;
    left: 14px;
    right: 14px;
    z-index: 1000;
    background: var(--header-bg);
    color: #fff;
    border-radius: 12px;
    padding: 14px 18px;
    box-shadow: 0 6px 24px rgba(0,0,0,.25);
    font-size: 13px;
    line-height: 1.6;
}
.menhj-cookie-inner {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}
.menhj-cookie .share-btn { padding: 7px 22px; }

/* ===== v1.2.0: Ad slots ===== */
.menhj-ad {
    max-width: 1280px;
    margin: 14px auto;
    padding: 0 24px;
    text-align: center;
}
.menhj-ad-header { margin-top: 0; }

/* ===== v1.2.0: Post views indicator ===== */
.post-views { font-weight: 600; }

/* ===== Responsive ===== */
@media (max-width: 720px) {
    .site-header { padding: 12px 14px; flex-wrap: wrap; }
    .site-title { font-size: 18px; }
    .site-search { order: 3; width: 100%; max-width: 100%; margin: 6px 0 0; }
    .site-main { padding: 20px 14px; }
    .page-title { font-size: 22px; }
    .video-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px 10px; }
    .video-info { padding: 10px 10px 12px; }
    .video-title { font-size: 13px; }
    .download-btn.small { padding: 5px 10px; font-size: 11px; }
    .lite-yt > .lite-yt-play { width: 60px; height: 60px; }
    .lite-yt > .lite-yt-play::after { border-width: 11px 0 11px 18px; }
    .related-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    .related-card .title { font-size: 12px; padding: 8px 10px 10px; }
    .cat-nav { top: auto; position: static; }
    .cat-nav-inner { padding: 8px 14px; }
    .cat-chip { padding: 6px 12px; font-size: 12px; }
}
