/* ============================================
   Modern layer: type, colours, header, manga page, chapters, footer.
   Loaded after style.css and mr-home.css, so it wins.
   ============================================ */

/* ---------- Fonts (self-hosted, no external requests) ---------- */
@font-face {
    font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap;
    src: url('fonts/inter-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Cairo'; font-style: normal; font-weight: 200 1000; font-display: swap;
    src: url('fonts/cairo-arabic.woff2') format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

/* ---------- Palette & base ---------- */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --surface: #ffffff;
    --surface-alt: #f1f3f7;
    --card-bg: #ffffff;
    --card-border: rgba(15, 23, 42, .09);
    --mica-bg: rgba(255, 255, 255, .86);
    --text: #0f172a;
    --text-light: #5b6475;
    --text-disabled: #94a3b8;
    --radius-md: 10px; --radius-lg: 14px; --radius-xl: 18px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-md: 0 6px 20px rgba(15, 23, 42, .08);
    --blur-amount: 14px;
    --mr-font: 'Inter', 'Cairo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
body.dark-mode {
    --surface: #14171f;
    --surface-alt: #1a1e28;
    --card-bg: #14171f;
    --card-border: rgba(255, 255, 255, .08);
    --mica-bg: rgba(15, 17, 23, .86);
    --text: #e7e9ef;
    --text-light: #a3abbb;
    --text-disabled: #6b7385;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, .45);
    background: #0b0d12;
}
body { background: #f5f6fa; font-family: var(--mr-font); font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
html[dir="rtl"] body, body.rtl { font-family: 'Cairo', 'Inter', system-ui, sans-serif; }
body::before, body::after { display: none; }                 /* old "mica" pattern */
h1, h2, h3, h4 { font-weight: 650; letter-spacing: -.015em; line-height: 1.25; }
button, input, select, textarea { font-family: inherit; }
.container { max-width: 1120px; padding: 0 20px; }
@media (max-width: 768px) { .container { padding: 0 14px; } }

/* ---------- Header + navigation: slim and tidy ---------- */
.site-header { background: var(--mica-bg); padding: 10px 0; border-bottom: 1px solid var(--card-border); box-shadow: none; }
.site-title { font-size: 20px; font-weight: 750; letter-spacing: -.02em; }
.site-title a { background: none; -webkit-text-fill-color: currentColor; color: var(--text); }
.site-title a::first-letter { color: var(--primary); }
.site-description { display: none; }
.header-actions { gap: 8px; }
.search-toggle, .mobile-menu-toggle { border-radius: 10px; background: var(--surface-alt); border: 0; color: var(--text); }
.main-nav { background: var(--surface); border-bottom: 1px solid var(--card-border); box-shadow: none; }
.mr-nav { gap: 6px; }
.mr-nav > li > a, .mr-dd-btn { padding: 8px 14px; margin: 6px 0; border-radius: 999px; font-size: 14px; font-weight: 550; color: var(--text-light); }
.mr-nav > li > a:hover, .mr-dd-btn:hover, .mr-has-dd.open > .mr-dd-btn { background: var(--surface-alt); color: var(--text); }
.mr-dd { border-radius: 14px; background: var(--card-bg); box-shadow: var(--shadow-md); top: calc(100% - 2px); }
.mr-dd a { padding: 9px 12px; font-size: 14px; color: var(--text); }
@media (max-width: 768px) {
    .main-nav { background: var(--surface); }
    body.dark-mode .main-nav { background: var(--surface); }
    .mr-nav > li > a, .mr-dd-btn { border-radius: 10px; margin: 2px 0; }
}

/* ---------- Buttons ---------- */
.btn { padding: 10px 18px; border-radius: 10px; font-weight: 600; font-size: 14px; border: 1px solid transparent; }
.btn-large { padding: 11px 20px; font-size: 14px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface-alt); color: var(--text); border-color: var(--card-border); }
.btn-secondary:hover { border-color: var(--primary); }

/* ---------- Cards, chips: calmer ---------- */
.mr-card-cover { border-radius: 12px; box-shadow: none; }
.mr-card-title { font-size: 13.5px; font-weight: 600; }
.mr-ch, .mr-chip-link, .mr-lang-chip, .mr-genre-card { background: var(--surface); }
.mr-banner { border-radius: 18px; }

/* ============================================
   MANGA PAGE
   ============================================ */
body .single-manga .manga-header {
    display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start;
    background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 18px;
    padding: 22px; margin: 22px 0; box-shadow: var(--shadow-sm); backdrop-filter: none;
}
body .single-manga .manga-cover-large { width: 100%; border-radius: 12px; display: block; aspect-ratio: 5 / 7; object-fit: cover; box-shadow: var(--shadow-md); }
body .single-manga .manga-details { min-width: 0; }
body .single-manga .manga-details h1 { font-size: clamp(22px, 3.2vw, 30px); margin: 0 0 6px; }

body .single-manga .manga-stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
body .single-manga .stat-box {
    display: inline-flex; flex-direction: row-reverse; align-items: baseline; gap: 6px;
    padding: 6px 12px; border-radius: 999px; background: var(--surface-alt); border: 0; box-shadow: none; min-width: 0;
}
body .single-manga .stat-value { font-size: 14px; font-weight: 700; color: var(--text); }
body .single-manga .stat-label { font-size: 12px; color: var(--text-light); text-transform: none; letter-spacing: 0; }
body .single-manga .manga-meta { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-bottom: 12px; font-size: 13.5px; color: var(--text-light); }
body .single-manga .meta-item { display: inline-flex; gap: 6px; }
body .single-manga .meta-label { font-weight: 600; color: var(--text); }
body .single-manga .genres { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
body .single-manga .genre-tag { padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 550; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); border: 0; }
body .single-manga .genre-tag:hover { background: var(--primary); color: #fff; }
body .single-manga .manga-description { max-width: 68ch; color: var(--text-light); font-size: 14.5px; line-height: 1.75; margin-bottom: 18px; }
body .single-manga .manga-description p { margin-bottom: .7em; }
body .single-manga .manga-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mr-alt-names { margin: 0 0 6px; }

/* Chapters: compact tiles instead of wide rows */
body .single-manga .chapters-section { background: none; border: 0; box-shadow: none; padding: 0; margin: 28px 0 8px; backdrop-filter: none; }
body .single-manga .chapters-header { display: flex; flex-direction: row; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin: 0 0 12px; padding: 0; border: 0; }
body .single-manga .chapters-header h2 { font-size: 18px; margin: 0; }
body .single-manga .chapters-controls { display: flex; gap: 6px; }
body .single-manga .chapter-sort-btn { padding: 6px 12px; font-size: 12px; font-weight: 600; border-radius: 999px; background: var(--surface); border: 1px solid var(--card-border); color: var(--text-light); cursor: pointer; }
body .single-manga .chapter-sort-btn:hover { color: var(--text); border-color: var(--primary); background: var(--surface); }
body .single-manga .chapter-sort-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.mr-manga-chips { margin: 0 0 12px; }

body .single-manga .chapters-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
body .single-manga .chapter-card { min-width: 0; }
body .single-manga .chapter-card-link {
    display: flex; flex-direction: column; align-items: stretch; gap: 4px; position: relative;
    padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--card-border);
    color: var(--text); transform: none; transition: border-color .15s, background .15s;
}
body .single-manga .chapter-card-link:hover { border-color: var(--primary); background: var(--surface); transform: none; }
body .single-manga .chapter-card-number { display: flex; align-items: center; gap: 0; }
body .single-manga .chapter-icon { display: none; }
body .single-manga .chapter-title { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body .single-manga .chapter-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: auto; flex-direction: row; }
body .single-manga .chapter-date { font-size: 11.5px; color: var(--text-light); order: 2; }
body .single-manga .mr-lang-tag { order: 1; padding: 1px 7px; font-size: 10px; letter-spacing: .3px; background: var(--primary); }
body .single-manga .new-badge { position: absolute; top: -7px; inset-inline-end: 10px; padding: 1px 8px; font-size: 10px; font-weight: 700; border-radius: 999px; background: #22c55e; color: #fff; }
@media (max-width: 768px) {
    body .single-manga .manga-header { grid-template-columns: 1fr; gap: 16px; padding: 16px; }
    body .single-manga .manga-cover-wrapper { max-width: 180px; margin: 0 auto; }
    body .single-manga .chapters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Footer ---------- */
.site-footer { background: transparent; border-top: 1px solid var(--card-border); margin-top: 40px; padding: 28px 0 18px; }
.footer-content { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 24px; margin-bottom: 18px; }
.footer-section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-light); margin-bottom: 10px; }
.footer-section p, .footer-section a { font-size: 14px; color: var(--text-light); }
.footer-section a:hover { color: var(--primary); }
.footer-section ul { list-style: none; display: grid; gap: 6px; }
.footer-bottom { text-align: center; font-size: 12.5px; color: var(--text-disabled); padding-top: 14px; border-top: 1px solid var(--card-border); }

/* ---------- Reader toolbar tidy-up ---------- */
.mr-bar { background: var(--mica-bg); }
.mr-btn { border-radius: 10px; font-weight: 550; }
.mr-langs { display: flex; gap: 4px; }
.mr-langs a, .mr-langs span {
    padding: 6px 9px; border-radius: 8px; font-size: 12px; font-weight: 700; text-decoration: none;
    background: var(--surface); border: 1px solid var(--card-border); color: var(--text-light);
}
.mr-langs a:hover { border-color: var(--primary); color: var(--text); }
.mr-langs .is-current { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Banner always fills the content width */
.mr-banner { aspect-ratio: auto; max-height: none; width: 100%; height: clamp(150px, 22vw, 300px); }
@media (max-width: 768px) { .mr-banner { aspect-ratio: auto; height: 150px; } }

/* ===== Language selector (globe button + animated panel) ===== */
.mr-lang { --lang-acc: var(--primary, var(--brand, #6366f1)); --lang-bg: var(--surface-alt, var(--bg2, #f3f4f8)); --lang-bd: var(--card-border, var(--border, rgba(127,127,127,.28))); --lang-tx: var(--text, #1b1d2a); --lang-panel: var(--surface, var(--bg, #fff)); position: relative; display: inline-block; font-size: 14px; line-height: 1.2; }
.mr-lang > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--lang-bd); background: var(--lang-bg); color: var(--lang-tx); font-weight: 700; user-select: none; -webkit-tap-highlight-color: transparent; transition: border-color .2s, box-shadow .2s, background .2s; }
.mr-lang > summary::-webkit-details-marker { display: none; }
.mr-lang > summary::marker { content: ""; }
.mr-lang > summary:hover, .mr-lang[open] > summary { border-color: var(--lang-acc); }
.mr-lang > summary:focus-visible { outline: 2px solid var(--lang-acc); outline-offset: 2px; }
.mr-lang[open] > summary { box-shadow: 0 0 0 3px color-mix(in srgb, var(--lang-acc) 22%, transparent); }
.mr-lang-globe { color: var(--lang-acc); flex: none; }
.mr-lang-chev { opacity: .7; transition: transform .22s ease; flex: none; }
.mr-lang[open] .mr-lang-chev { transform: rotate(180deg); }
.mr-lang-panel { position: absolute; inset-block-start: calc(100% + 8px); inset-inline-end: 0; z-index: 1000; margin: 0; padding: 6px; list-style: none; min-width: 210px; max-width: min(280px, calc(100vw - 24px)); background: var(--lang-panel); color: var(--lang-tx); border: 1px solid var(--lang-bd); border-radius: 18px; box-shadow: 0 22px 44px -14px rgba(0,0,0,.35); transform-origin: top; animation: mrLangIn .2s cubic-bezier(.2,.8,.2,1); }
.mr-lang-panel li { margin: 0; padding: 0; list-style: none; }
.mr-lang-panel a { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 14px; border-radius: 13px; color: inherit; text-decoration: none; font-weight: 700; transition: background .15s, transform .15s; }
.mr-lang-panel a:hover, .mr-lang-panel a:focus-visible { background: color-mix(in srgb, var(--lang-acc) 14%, transparent); outline: none; }
.mr-lang-panel a:active { transform: scale(.98); }
.mr-lang-panel a[aria-current="true"] { background: var(--lang-acc); color: #fff; }
.mr-lang-name { flex: 1; }
.mr-lang-code { font-size: 11px; font-weight: 800; letter-spacing: .06em; opacity: .6; }
.mr-lang-check { flex: none; }
.mr-lang[open] .mr-lang-panel li { animation: mrLangItem .22s ease both; }
.mr-lang[open] .mr-lang-panel li:nth-child(2) { animation-delay: .03s; }
.mr-lang[open] .mr-lang-panel li:nth-child(3) { animation-delay: .06s; }
.mr-lang[open] .mr-lang-panel li:nth-child(4) { animation-delay: .09s; }
@keyframes mrLangIn { from { opacity: 0; transform: translateY(-6px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes mrLangItem { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (max-width: 640px) { .mr-lang > summary { padding: 0 11px; } .mr-lang-panel { min-width: 200px; } }
@media (max-width: 380px) { .mr-lang-cur { display: none; } }
@media (prefers-reduced-motion: reduce) { .mr-lang-panel, .mr-lang[open] .mr-lang-panel li { animation: none; } .mr-lang-chev { transition: none; } }
.footer-section .footer-menu { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }

/* ---------- Team profile page + reader credit ---------- */
.mr-profile { padding-bottom: 30px; }
.mr-pf-banner { height: clamp(120px, 22vw, 240px); margin-top: 20px; border-radius: 18px; background: linear-gradient(135deg, var(--primary), var(--primary-light)) center/cover no-repeat; }
.mr-pf-head { display: flex; align-items: flex-end; gap: 16px; margin: -48px 22px 12px; position: relative; }
.mr-pf-head .mr-pf-avatar { width: 104px; height: 104px; border-radius: 50%; border: 4px solid var(--surface); background: var(--surface); object-fit: cover; flex: none; }
.mr-pf-head h1 { margin: 0; font-size: 24px; }
.mr-pf-role { display: inline-block; margin-top: 4px; padding: 2px 10px; border-radius: 999px; background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); font-size: 12px; font-weight: 700; }
.mr-pf-bio { max-width: 68ch; margin: 8px 22px 12px; color: var(--text-light); line-height: 1.8; }
.mr-pf-social { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 22px 18px; }
.mr-pf-social a { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--card-border); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; text-decoration: none; }
.mr-pf-social a:hover { border-color: var(--primary); color: var(--primary); }
.mr-credit { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; max-width: 520px; margin: 0 auto 36px; padding: 12px 16px; border: 1px solid var(--card-border); border-radius: 16px; background: var(--surface); }
.mr-credit-who { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.mr-credit-who img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.mr-credit-who span { display: flex; flex-direction: column; line-height: 1.3; }
.mr-credit-who small { color: var(--text-light); font-size: 12px; }
.mr-credit-who b { font-size: 15px; }
.mr-credit-who:hover b { color: var(--primary); }
.mr-credit .mr-btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
@media (max-width: 600px) { .mr-pf-head { margin-inline: 8px; } .mr-pf-head .mr-pf-avatar { width: 84px; height: 84px; } }

/* manga page: who translated / published (aligned table) */
.mr-team { margin: 0 0 16px; border: 1px solid var(--card-border); border-radius: 14px; overflow: hidden; background: var(--surface); max-width: 560px; }
.mr-team-head, .mr-team-row { display: grid; grid-template-columns: 46px 1fr 1fr; align-items: center; gap: 12px; padding: 9px 14px; }
.mr-team-head { padding-block: 7px; background: var(--surface-alt); font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-light); }
.mr-team-row + .mr-team-row { border-top: 1px solid var(--card-border); }
.mr-team-row .mr-lang-tag { justify-self: start; }
.mr-team-cell { display: flex; flex-wrap: wrap; gap: 4px 12px; min-width: 0; font-size: 13.5px; }
@media (max-width: 520px) {
    .mr-team-head { display: none; }
    .mr-team-row { grid-template-columns: 40px 1fr; align-items: start; }
    .mr-team-cell::before { content: attr(data-label) ": "; width: 100%; font-size: 11px; color: var(--text-light); }
    .mr-team-cell { grid-column: 2; }
}
.mr-person { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--text); text-decoration: none; vertical-align: middle; }
a.mr-person:hover { color: var(--primary); }
.mr-person img { width: 20px; height: 20px; border-radius: 50%; }
.mr-credit-pub { flex-basis: 100%; margin: 0; padding-top: 8px; border-top: 1px solid var(--card-border); font-size: 12.5px; color: var(--text-light); }
body .single-manga .mr-team-row .mr-lang-tag { order: -1; align-self: center; justify-self: start; width: auto; }
@media (max-width: 520px) { body .single-manga .mr-team-row .mr-lang-tag { grid-row: 1 / span 2; align-self: start; } }

/* ---------- Library / filters / reader extras ---------- */
.mr-browse { max-width: 1200px; margin: 0 auto; padding: 8px 0 32px; }
.mr-browse-bar { display: grid; grid-template-columns: minmax(180px, 2fr) repeat(4, minmax(110px, 1fr)) auto auto; gap: 8px; align-items: center; margin: 14px 0 10px; }
.mr-browse-bar input, .mr-browse-bar select { width: 100%; min-width: 0; height: 40px; padding: 0 12px; border-radius: 10px; font-size: 14px; background: var(--surface); color: var(--text); border: 1px solid var(--card-border); }
.mr-browse-bar .mr-btn { height: 40px; justify-content: center; }
@media (max-width: 900px) { .mr-browse-bar { grid-template-columns: 1fr 1fr; } .mr-browse-bar input[type=search] { grid-column: 1 / -1; } }
.mr-browse-count { color: var(--text-light); font-size: 13px; margin: 4px 0 12px; min-height: 18px; }
/* the results area keeps its height while loading, so the page does not jump */
.mr-browse-results { min-height: 60vh; transition: opacity .15s; }
.mr-browse-results.is-loading { opacity: .45; pointer-events: none; }
.mr-pager { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 26px 0 0; }
.mr-pager-gap { align-self: center; color: var(--text-light); }
.mr-lib-tabs { margin: 12px 0; }
.mr-lib-out { min-height: 40vh; }
.mr-continue-sm { margin-top: 8px; width: 100%; justify-content: center; font-size: 12px; }
.mr-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 10px 0 14px; min-height: 40px; }
.mr-actions .mr-btn { min-height: 38px; }
.mr-continue[hidden] { display: none; }
.mr-bookmark.is-on { background: var(--primary); border-color: var(--primary); color: #fff; }
.mr-rate { display: inline-flex; align-items: center; gap: 2px; }
.mr-rate button { background: none; border: 0; padding: 2px; font-size: 22px; line-height: 1; cursor: pointer; color: rgba(127,127,127,.5); }
.mr-rate button.is-on { color: #f5a623; }
.mr-rate-info, .mr-views { font-size: 12px; color: var(--text-light); margin-inline-start: 6px; }
.mr-resume { position: fixed; z-index: 990; inset-inline: 12px; bottom: 14px; max-width: 460px; margin-inline: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; font-size: 13px; background: var(--surface); color: var(--text); border: 1px solid var(--card-border); box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.mr-resume span { flex: 1 1 100%; }

/* team page */
.mr-team-members { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-bottom: 22px; }
.mr-team-member { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--surface); text-decoration: none; color: inherit; }
.mr-team-member img { border-radius: 50%; }
.mr-team-member small { display: block; opacity: .7; }
.mr-credit-team { margin-bottom: 10px; }
