/*
Theme Name: Majlis Traders
Theme URI: https://majlistraders.com
Description: Arabic (RTL) reference theme for Islamic (swap-free) trading account pages: broker directory, updates ledger, A-Z index and account pages at /islamic/.
Version: 1.1.2
Requires at least: 6.0
Requires PHP: 7.4
Text Domain: majlistraders
*/

:root {
  --bg: #fbf8f1;
  --bg-alt: #f3ede0;
  --surface: #ffffff;
  --text: #1c2a22;
  --muted: #5d6a61;
  --border: #e5dbc5;
  --primary: #0b5d3b;
  --primary-dark: #08442b;
  --primary-soft: #e7f1ea;
  --gold: #b0842a;
  --gold-text: #8a6520;
  --gold-soft: #f6eedb;
  --footer-bg: #0a2e20;
  --ok-bg: #e3f2e8; --ok-text: #0b6b3f;
  --warn-bg: #fdf0d5; --warn-text: #8a5a00;
  --no-bg: #fbe4e2; --no-text: #a2271c;
  --muted-bg: #eef0ee; --muted-text: #5d6a61;
  --radius: 14px;
  --font-body: "IBM Plex Sans Arabic", system-ui, sans-serif;
  --font-head: "Amiri", "IBM Plex Sans Arabic", serif;
  --octagram: polygon(50% 0, 64% 14%, 85% 15%, 86% 36%, 100% 50%, 86% 64%, 85% 85%, 64% 86%, 50% 100%, 36% 86%, 15% 85%, 14% 64%, 0 50%, 14% 36%, 15% 15%, 36% 14%);
}

* { box-sizing: border-box; }
/* Smooth scrolling only for in-page jumps (A-Z letters), never while a page is loading or restoring its position. */
@media (prefers-reduced-motion: no-preference) {
  html:focus-within { scroll-behavior: smooth; }
}
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.85;
  color: var(--text);
  background: var(--bg);
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.35; margin: 0 0 .5em; font-weight: 700; }
p { margin: 0 0 .9em; }
[hidden] { display: none !important; }

.container { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 860px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.screen-reader-text { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(1px, 1px, 1px, 1px); white-space: nowrap; }

.btn {
  display: inline-block; background: var(--primary); color: #fff;
  border: 0; border-radius: 6px; padding: 10px 22px;
  font: inherit; font-weight: 700; cursor: pointer;
}
.btn:hover { background: var(--primary-dark); }
.link { color: var(--primary); font-weight: 700; }
.link:hover { text-decoration: underline; text-decoration-color: var(--gold); }

/* ---------- Ornament: star between two gold rules ---------- */
.ornament { display: flex; align-items: center; justify-content: center; gap: 14px; color: var(--gold); margin: 0 auto 12px; }
.ornament::before, .ornament::after { content: ""; height: 1px; width: 80px; background: linear-gradient(to left, transparent, var(--gold)); }
.ornament::after { background: linear-gradient(to right, transparent, var(--gold)); }
.ornament svg { width: 20px; height: 20px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface);
  border-top: 4px solid var(--primary);
  box-shadow: 0 1px 0 var(--border), 0 3px 0 -1px var(--gold-soft);
}
.admin-bar .site-header { top: 32px; }
.header-inner { display: flex; align-items: center; gap: 22px; height: 70px; }
.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand-mark { position: relative; width: 42px; height: 42px; display: grid; place-items: center; }
.brand-star { position: absolute; inset: 0; width: 100%; height: 100%; color: var(--gold); }
.brand-letter { position: relative; font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; line-height: 1; color: #10261b; margin-top: -2px; }
.brand-name { font-family: var(--font-head); font-size: 1.5rem; font-weight: 700; color: var(--primary); white-space: nowrap; }
.custom-logo-link img { max-height: 48px; width: auto; display: block; }

.main-nav { display: flex; align-items: center; gap: 22px; flex: 1; justify-content: flex-end; }
.main-nav .menu { display: flex; align-items: center; gap: 22px; list-style: none; margin: 0; padding: 0; font-weight: 500; }
.main-nav .menu a:hover, .main-nav .current-menu-item > a { color: var(--primary); }

/* Small live filter line above the broker mosaic and the A-Z index. */
.broker-filter {
  display: flex; align-items: center; gap: 10px;
  max-width: 420px; margin: 0 0 18px;
  padding: 0 14px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface);
}
.broker-filter:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.broker-filter svg { width: 18px; height: 18px; flex: none; color: var(--gold); }
.broker-filter input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 10px 0; font: inherit; font-size: .95rem; color: var(--text); }
.broker-filter input:focus { outline: none; }

.menu-toggle {
  display: none; width: 42px; height: 42px; margin-inline-start: auto;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
  cursor: pointer; padding: 12px 10px; flex-direction: column; justify-content: space-between;
}
.menu-toggle span { display: block; height: 2px; background: var(--text); border-radius: 2px; }

/* ---------- Intro ---------- */
.intro {
  padding: 46px 0 34px;
  background:
    linear-gradient(var(--bg), var(--bg)) padding-box,
    var(--bg);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.intro::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -7px; height: 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='12' viewBox='0 0 24 12'%3E%3Cpath d='M12 0l3 6-3 6-3-6z' fill='%23b0842a' fill-opacity='.55'/%3E%3C/svg%3E");
  background-size: 24px 12px; background-position: center;
}
.intro h1 { font-size: clamp(1.9rem, 4.4vw, 2.9rem); color: var(--primary); margin-bottom: 10px; }
.intro-sub { font-size: 1.1rem; color: var(--muted); max-width: 680px; margin: 0 auto 10px; }
.intro-count { display: inline-block; font-weight: 700; color: var(--gold-text); border-bottom: 2px solid var(--gold); margin: 0; }

/* ---------- Sections ---------- */
.section { padding: 56px 0; }
.section-alt { background: var(--bg-alt); }
.section-title { font-size: 1.9rem; color: var(--primary); margin-bottom: 18px; padding-inline-start: 16px; border-inline-start: 4px solid var(--gold); line-height: 1.2; }
.section-lead { margin-top: -8px; margin-bottom: 20px; }
.page-header { margin-bottom: 24px; }
.page-title { font-size: clamp(1.8rem, 4vw, 2.5rem); color: var(--primary); margin-bottom: 8px; }
.center-link { text-align: center; margin-top: 24px; }
.empty { text-align: center; color: var(--muted); padding: 28px; }

/* ---------- Logo squares (replaced by the Featured image when set) ---------- */
.acc-logo {
  --logo: #0b5d3b;
  width: 46px; height: 46px; flex: none;
  border-radius: 6px;
  display: grid; place-items: center;
  background: var(--logo); color: #fff;
  font-weight: 700; font-size: .95rem; direction: ltr;
  outline: 1px solid var(--gold); outline-offset: 2px;
  overflow: hidden;
}
.acc-logo.sm { width: 34px; height: 34px; font-size: .75rem; outline-offset: 1px; }
.acc-logo.lg { width: 72px; height: 72px; font-size: 1.35rem; border-radius: 8px; outline-offset: 3px; }
.acc-logo.has-img { background: #fff; }
.acc-logo.has-img img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }

/* ---------- Status badges ---------- */
.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; font-weight: 700;
  padding: 2px 10px; border-radius: 4px; white-space: nowrap;
}
.status::before { content: ""; width: 7px; height: 7px; background: currentColor; transform: rotate(45deg); }
.status-ok { background: var(--ok-bg); color: var(--ok-text); }
.status-warn { background: var(--warn-bg); color: var(--warn-text); }
.status-no { background: var(--no-bg); color: var(--no-text); }
.status-muted { background: var(--muted-bg); color: var(--muted-text); }

/* ---------- Directory tiles ---------- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.acc-tile {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 3px solid var(--gold-soft);
  border-radius: 8px;
  padding: 18px 10px 14px;
  transition: border-color .2s, background .2s;
}
.acc-tile:hover { border-color: var(--gold); background: var(--gold-soft); }
.acc-tile-name { font-weight: 700; direction: ltr; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-tile .status { font-size: .72rem; }

/* ---------- Updates ledger and A-Z index ---------- */
.ledger { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.ledger-row {
  display: grid; grid-template-columns: 58px auto 1fr auto 18px; align-items: center; gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px dashed var(--border);
  transition: background .15s;
}
.ledger-row:last-child { border-bottom: 0; }
.ledger-row:hover { background: var(--gold-soft); }
.ledger-date {
  display: flex; flex-direction: column; align-items: center; line-height: 1.1;
  border: 1px solid var(--gold); border-radius: 6px; padding: 5px 0;
  color: var(--gold-text);
}
.ledger-date b { font-size: 1.25rem; font-family: var(--font-head); }
.ledger-date small { font-size: .7rem; }
.ledger-main { display: flex; flex-direction: column; min-width: 0; }
.ledger-name { font-weight: 700; color: var(--primary); direction: ltr; text-align: right; }
.ledger-title { font-size: .88rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ledger-arrow { color: var(--gold); font-size: 1.4rem; line-height: 1; }

.az-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 26px; direction: ltr; justify-content: flex-end; }
.az-nav a {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
  font-weight: 700; color: var(--primary);
}
.az-nav a:hover { background: var(--gold); border-color: var(--gold); color: #1b140a; }
.az-nav a.is-off { opacity: .3; pointer-events: none; }
.az-group { margin-bottom: 26px; scroll-margin-top: 90px; }
.az-letter { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.az-letter span {
  width: 44px; height: 44px; display: grid; place-items: center;
  background: var(--gold); color: #1b140a;
  font-family: var(--font-body); font-size: 1.1rem;
  clip-path: var(--octagram);
}
.az-letter::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Principles panel ---------- */
.principles {
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: 34px 30px 26px;
  background: var(--surface);
  position: relative;
}
.principles::before {
  content: ""; position: absolute; inset: 8px; border: 1px solid var(--gold-soft); border-radius: 10px; pointer-events: none;
}
.principles-title { text-align: center; font-size: 1.8rem; color: var(--primary); margin-bottom: 22px; }
.principles-cols { display: grid; grid-template-columns: repeat(3, 1fr); }
.principles-cols > div { padding: 0 22px; text-align: center; }
.principles-cols > div + div { border-inline-start: 1px solid var(--border); }
.principle-num { display: block; font-family: var(--font-head); font-size: 2.4rem; line-height: 1; color: var(--gold); margin-bottom: 8px; }
.principles h3 { font-size: 1.25rem; }
.principles p { color: var(--muted); margin: 0; }

/* ---------- Single account page ---------- */
.breadcrumbs { display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: .88rem; margin-bottom: 26px; }
.breadcrumbs a { color: var(--primary); }
.acc-head { text-align: center; margin-bottom: 30px; }
.acc-head .acc-logo { margin: 0 auto 16px; }
.acc-head h1 { font-size: clamp(1.7rem, 3.8vw, 2.4rem); color: var(--primary); max-width: 760px; margin: 0 auto 12px; }
.acc-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 14px; margin-bottom: 18px; }
.updated { color: var(--muted); font-size: .85rem; }

.related { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border); }
.related h2 { font-size: 1.4rem; color: var(--primary); }
.related-links { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.related-links a {
  display: inline-block; direction: ltr;
  padding: 5px 14px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface);
  font-weight: 700; font-size: .92rem;
}
.related-links a:hover { border-color: var(--gold); background: var(--gold-soft); }

/* ---------- Article content ---------- */
.entry-content { font-size: 1.06rem; }
.entry-content h2 { font-size: 1.65rem; margin: 1.6em 0 .55em; display: flex; align-items: center; gap: 10px; color: var(--primary); }
.entry-content h2::before { content: ""; flex: none; width: 14px; height: 14px; background: var(--gold); clip-path: var(--octagram); }
.entry-content h3 { font-size: 1.3rem; margin: 1.3em 0 .5em; }
.entry-content a { color: var(--primary); text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 3px; }
.entry-content ul { list-style: none; padding: 0; margin: 0 0 1em; }
.entry-content ul li { position: relative; padding-inline-start: 22px; margin-bottom: .45em; }
.entry-content ul li::before { content: ""; position: absolute; inset-inline-start: 2px; top: .72em; width: 8px; height: 8px; background: var(--gold); transform: rotate(45deg); }
.entry-content ol { list-style: none; counter-reset: step; padding: 0; margin: 0 0 1em; }
.entry-content ol li { counter-increment: step; position: relative; padding-inline-start: 44px; margin-bottom: .7em; min-height: 32px; }
.entry-content ol li::before {
  content: counter(step); position: absolute; inset-inline-start: 0; top: 0;
  width: 30px; height: 30px; display: grid; place-items: center;
  background: var(--gold-soft); color: var(--gold-text); border: 1px solid var(--gold); border-radius: 50%;
  font-weight: 700; font-size: .9rem;
}

/* "Quick facts": arch-topped panel. */
.entry-content .mj-quick {
  position: relative;
  background: var(--gold-soft);
  border: 1px solid var(--gold);
  border-radius: 180px 180px var(--radius) var(--radius) / 56px 56px var(--radius) var(--radius);
  padding: 46px 28px 18px;
  margin: 0 0 1.6em;
}
.entry-content .mj-quick::before { content: ""; position: absolute; top: 14px; left: 50%; transform: translateX(-50%); width: 20px; height: 20px; background: var(--gold); clip-path: var(--octagram); }
.entry-content .mj-quick-title { text-align: center; font-family: var(--font-head); font-size: 1.35rem; color: var(--gold-text); margin-bottom: .6em; }
.entry-content .mj-quick ul { margin: 0; }
.entry-content .mj-quick li strong { color: var(--primary); }

/* Religious note. */
.entry-content .mj-religious { background: var(--primary-soft); border-inline-start: 4px solid var(--primary); border-radius: 10px; padding: 6px 22px 8px; margin: 1.6em 0; }
.entry-content .mj-religious h2 { margin-top: .6em; }

/* Closing note and sources. */
.entry-content .mj-disclaimer { border: 1px dashed var(--gold); border-radius: 10px; padding: 14px 18px; color: var(--muted); font-size: .95rem; text-align: center; margin: 2em 0 1em; }
.entry-content .mj-sources { font-size: .88rem; color: var(--muted); }

/* ---------- Pages and fallback ---------- */
.post-list { display: flex; flex-direction: column; gap: 16px; }
.post-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.post-card h2 { font-size: 1.4rem; margin-bottom: 4px; }
.pagination { margin-top: 30px; }
.nav-links { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.page-numbers { display: inline-block; min-width: 40px; text-align: center; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); }
.page-numbers.current, a.page-numbers:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.not-found { text-align: center; }
.inline-form { display: flex; gap: 8px; max-width: 460px; margin: 18px auto 0; }
.inline-form input { flex: 1; min-width: 0; padding: 10px 14px; border: 1px solid var(--border); border-radius: 6px; font: inherit; background: var(--surface); }

/* ---------- Footer (centred) ---------- */
.site-footer { background: var(--footer-bg); color: #cfd8cf; padding: 46px 0 24px; text-align: center; border-top: 4px solid var(--gold); }
.footer-inner { max-width: 760px; }
.site-footer .ornament { margin-bottom: 8px; }
.footer-name { font-family: var(--font-head); font-size: 1.7rem; color: #f1e9d4; margin-bottom: 4px; }
.footer-about { color: #a9b6aa; }
.footer-links .menu { list-style: none; margin: 18px 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 22px; }
.footer-links a { color: #e2c27a; }
.footer-links a:hover { color: #fff; }
.footer-notes { border-top: 1px solid rgba(226, 194, 122, .25); padding-top: 16px; font-size: .86rem; color: #a9b6aa; }
.footer-notes p { margin: 0 0 8px; }
.copyright { font-size: .82rem; color: #7f8d82; margin: 12px 0 0; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .principles-cols { grid-template-columns: 1fr; gap: 22px; }
  .principles-cols > div + div { border-inline-start: 0; border-top: 1px solid var(--border); padding-top: 22px; }
}
@media (max-width: 782px) {
  .admin-bar .site-header { top: 46px; }
}
@media (max-width: 760px) {
  .menu-toggle { display: flex; }
  .main-nav {
    display: none;
    position: absolute; top: 70px; right: 0; left: 0;
    flex-direction: column; align-items: stretch; gap: 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 8px 16px 16px;
  }
  .main-nav.open { display: flex; }
  .main-nav .menu { flex-direction: column; align-items: stretch; gap: 0; }
  .main-nav .menu a { display: block; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .brand-name { font-size: 1.3rem; }
  .section { padding: 44px 0; }
  .section-title { font-size: 1.6rem; }
  .ledger-row { grid-template-columns: 50px auto 1fr; gap: 6px 12px; padding: 12px 14px; }
  .ledger-row .status { grid-column: 3; justify-self: start; }
  .ledger-arrow { display: none; }
  .ledger-date { grid-row: span 2; }
  .ledger-row .acc-logo { grid-row: span 2; }
}
@media (max-width: 600px) {
  .admin-bar .site-header { top: 0; }
}
@media (max-width: 480px) {
  .tile-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .principles { padding: 26px 16px 20px; }
}
