/* ويكي First Empire — ملف التنسيق الوحيد لكل الصفحات */
/* الخطوط متخزنة جوه الويكي نفسه (رخصة OFL في fonts/) — من غير طلبات لمواقع تانية */
@font-face {
  font-family: 'Marcellus';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/marcellus-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Alegreya';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/alegreya-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Alegreya';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/alegreya-latin-400-italic.woff2') format('woff2');
}
@font-face {
  font-family: 'Alegreya';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/alegreya-latin-700-normal.woff2') format('woff2');
}
/* الخطوط العربي (للصفحات العربي بس — المتصفح مش بيحمّلها غير لو فيه حروف عربي) */
@font-face {
  font-family: 'Noto Naskh Arabic';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/noto-naskh-arabic-arabic-400-normal.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;
}
@font-face {
  font-family: 'Noto Naskh Arabic';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/noto-naskh-arabic-arabic-700-normal.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;
}
@font-face {
  font-family: 'Amiri';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/amiri-arabic-400-normal.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;
}
:root {
  --ink: #24170a;
  --ink-deep: #170e05;
  --ink-2: #33220f;
  --ink-line: rgba(243, 201, 90, 0.22);
  --gold: #f3c95a;
  --gold-soft: #f7e2a8;
  --gold-deep: #8f6312;
  --parchment: #f4e7c6;
  --parchment-2: #ead9ae;
  --parchment-line: #d6bf88;
  --text: #2a1c0c;
  --muted: #6a5434;
  --on-dark: #eadcb8;
  --on-dark-muted: #bfa877;
  --lapis: #1d4a82;
  --lapis-hover: #12335e;
  --seal: #8e2a1a;
  --display: 'Marcellus', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --body: 'Alegreya', Georgia, 'Times New Roman', serif;
  --top-h: 58px;
}
/* العربي: نسخ للنص وأميري للعناوين، والأرقام/اللاتيني بتفضل بنفس خطوط الإنجليزي */
:root:lang(ar) {
  --display: 'Amiri', 'Marcellus', 'Palatino Linotype', Palatino, Georgia, serif;
  --body: 'Noto Naskh Arabic', 'Alegreya', Georgia, 'Times New Roman', serif;
}
:lang(ar) body {
  line-height: 1.75;
  font-variant-numeric: lining-nums;
}
:lang(ar) .brand,
:lang(ar) .band h1,
:lang(ar) .sidenav h2 {
  letter-spacing: 0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--top-h) + 14px);
}
body {
  margin: 0;
  background: var(--ink) radial-gradient(ellipse 90% 60% at 50% -10%, #4a3015 0%, rgba(36, 23, 10, 0) 70%) no-repeat;
  color: var(--on-dark);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.6;
  min-height: 100vh;
}
img {
  max-width: 100%;
  height: auto;
}
a {
  color: inherit;
}
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 3px;
}
.skip {
  position: absolute;
  inset-inline-start: -999px;
  top: 8px;
  z-index: 50;
  background: var(--gold);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 6px;
  font-weight: 700;
}
.skip:focus {
  inset-inline-start: 12px;
}

/* ===== الشريط اللي فوق ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(23, 14, 5, 0.97);
  border-bottom: 1px solid var(--ink-line);
}
.topbar-in {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--top-h);
  padding: 0 16px;
  max-width: 1440px;
  margin: 0 auto;
}
.menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid var(--ink-line);
  border-radius: 8px;
  background: transparent;
  color: var(--gold);
  cursor: pointer;
}
.menu-btn svg {
  width: 22px;
  height: 22px;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 7px;
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--display);
  color: var(--gold);
  font-size: 21px;
  letter-spacing: 0.01em;
}
.brand small {
  font-size: 15px;
  color: var(--on-dark-muted);
}
.search {
  position: relative;
  flex: 1 1 auto;
  max-width: 460px;
  margin-inline-start: auto;
}
.search input {
  width: 100%;
  height: 40px;
  padding-block: 0;
  padding-inline: 36px 12px;
  border-radius: 8px;
  border: 1px solid #5a3f1c;
  background: #2b1b0a;
  color: var(--parchment);
  font: inherit;
  font-size: 16px;
}
.search input::placeholder {
  color: #9c8558;
}
.search svg {
  position: absolute;
  inset-inline-start: 11px;
  top: 11px;
  width: 18px;
  height: 18px;
  color: #9c8558;
  pointer-events: none;
}
.results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: min(70vh, 460px);
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--parchment);
  color: var(--text);
  border: 1px solid var(--parchment-line);
  border-radius: 8px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
}
.results[hidden] {
  display: none;
}
.results a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  text-decoration: none;
  line-height: 1.3;
}
.results a b {
  display: block;
  font-weight: 700;
}
.results a span {
  font-size: 14px;
  color: var(--muted);
}
.results a:hover,
.results a.on {
  background: var(--parchment-2);
}
.results .empty {
  padding: 10px;
  color: var(--muted);
  font-size: 15px;
}
.lang {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--ink-line);
  border-radius: 8px;
  color: var(--gold-soft);
  text-decoration: none;
  font-size: 16px;
  white-space: nowrap;
}
.lang:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.lang:lang(ar) {
  font-family: 'Noto Naskh Arabic', var(--body);
}
.play {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 16px;
  border-radius: 9px;
  text-decoration: none;
  font-weight: 800;
  font-size: 16px;
  color: #2a1606;
  background: linear-gradient(180deg, #ffe08a 0%, #f3c95a 50%, #d99a2b 100%);
  border: 1px solid #8a5a12;
  box-shadow: 0 3px 0 #7a4c0e;
  white-space: nowrap;
}
.play:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #7a4c0e;
}

/* ===== التخطيط ===== */
.layout {
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
.sidenav {
  position: fixed;
  z-index: 40;
  top: 0;
  bottom: 0;
  inset-inline-start: 0;
  width: min(300px, 86vw);
  padding: 18px 14px 40px;
  overflow-y: auto;
  background: var(--ink-deep);
  border-inline-end: 1px solid var(--ink-line);
  transform: translateX(-102%);
  transition: transform 0.22s ease;
}
@media (max-width: 1039px) {
  [dir='rtl'] .sidenav {
    transform: translateX(102%);
  }
}
.nav-open .sidenav {
  transform: none;
}
.scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(0, 0, 0, 0.55);
}
.scrim[hidden] {
  display: none;
}
.sidenav h2 {
  margin: 18px 10px 6px;
  font-family: var(--body);
  font-size: 14px;
  font-weight: 700;
  color: var(--on-dark-muted);
  letter-spacing: 0.02em;
}
.sidenav h2:first-of-type {
  margin-top: 4px;
}
.sidenav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sidenav a {
  display: block;
  padding-block: 7px;
  padding-inline: 12px 10px;
  border-inline-start: 3px solid transparent;
  border-radius: 0;
  border-start-end-radius: 6px;
  border-end-end-radius: 6px;
  text-decoration: none;
  color: var(--on-dark);
  font-size: 17px;
  line-height: 1.3;
}
.sidenav a:hover {
  background: rgba(243, 201, 90, 0.07);
}
.sidenav a[aria-current='page'] {
  border-inline-start-color: var(--gold);
  color: var(--gold);
  background: rgba(243, 201, 90, 0.1);
}
.nav-close {
  display: flex;
  justify-content: flex-end;
}
.nav-close button {
  border: 0;
  background: none;
  color: var(--on-dark-muted);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  padding: 4px 8px;
}

main {
  min-width: 0;
  padding: 0 0 48px;
}

/* ===== رأس الصفحة (الحتة الغامقة فوق الورقة) ===== */
.band {
  padding: 22px 16px 54px;
  max-width: 920px;
}
.crumbs {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 15px;
  color: var(--on-dark-muted);
}
.crumbs li + li::before {
  content: '/';
  margin-inline-end: 8px;
  opacity: 0.6;
}
.crumbs a {
  color: var(--on-dark-muted);
}
.band h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  color: var(--gold);
  font-size: clamp(32px, 7vw, 50px);
  line-height: 1.08;
  letter-spacing: 0.005em;
}
.lede {
  margin: 12px 0 0;
  max-width: 62ch;
  font-size: 19px;
  color: var(--on-dark);
}

/* ===== الورقة ===== */
.sheet {
  position: relative;
  margin: -34px 0 0;
  padding: 26px 16px 34px;
  background: var(--parchment) linear-gradient(180deg, #f8edd0 0%, var(--parchment) 220px);
  color: var(--text);
  border-top: 3px solid var(--gold-deep);
  box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.3), 0 20px 50px rgba(0, 0, 0, 0.45);
  max-width: 920px;
}
.sheet > * {
  max-width: 72ch;
}
.sheet > .tblw,
.sheet > .wide,
.sheet > details,
.sheet > .prevnext,
.sheet > .cards {
  max-width: none;
}
.sheet p,
.sheet li {
  hyphens: auto;
}
.sheet a {
  color: var(--lapis);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.sheet a:hover {
  color: var(--lapis-hover);
}
.sheet h2 {
  position: relative;
  margin: 40px 0 12px;
  padding-bottom: 6px;
  font-family: var(--display);
  font-weight: 400;
  font-size: 29px;
  line-height: 1.2;
  color: #3a2208;
  border-bottom: 1px solid var(--parchment-line);
}
.sheet h3 {
  position: relative;
  margin: 28px 0 8px;
  font-size: 22px;
  line-height: 1.25;
  color: #3a2208;
}
.sheet h2:first-child {
  margin-top: 0;
}
.anchor {
  margin-inline-start: 8px;
  font-family: var(--body);
  font-size: 0.7em;
  text-decoration: none;
  color: var(--gold-deep) !important;
  opacity: 0.45;
}
h2:hover .anchor,
h3:hover .anchor,
.anchor:focus {
  opacity: 1;
}
.toc {
  margin: 0 0 8px;
  padding: 12px 16px 14px;
  background: rgba(143, 99, 18, 0.07);
  border: 1px solid var(--parchment-line);
  border-radius: 8px;
}
.toc summary {
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  color: var(--muted);
}
.toc[open] summary {
  margin-bottom: 6px;
}
.toc ol {
  margin: 0;
  padding-inline-start: 22px;
  columns: 2 220px;
  column-gap: 28px;
}
.toc li {
  break-inside: avoid;
  font-size: 16px;
  line-height: 1.5;
}

/* ===== الجداول ===== */
.tblw {
  margin: 14px 0 20px;
}
.tblw figcaption {
  padding: 0 2px 6px;
  font-size: 15px;
  line-height: 1.35;
  color: var(--muted);
}
.tbl {
  margin: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--parchment-line);
  border-radius: 8px;
  background: #fbf3dd;
  background-image: linear-gradient(to right, #fbf3dd 30%, rgba(251, 243, 221, 0)), linear-gradient(to left, #fbf3dd 30%, rgba(251, 243, 221, 0)), radial-gradient(farthest-side at 0 50%, rgba(60, 36, 8, 0.25), transparent), radial-gradient(farthest-side at 100% 50%, rgba(60, 36, 8, 0.25), transparent);
  background-position: left center, right center, left center, right center;
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 16px;
  line-height: 1.35;
  font-variant-numeric: lining-nums tabular-nums;
}
th,
td {
  padding: 7px 10px;
  text-align: start;
  vertical-align: top;
  border-bottom: 1px solid rgba(143, 99, 18, 0.16);
}
thead th {
  position: sticky;
  top: 0;
  background: var(--ink-2);
  color: var(--gold-soft);
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  border-bottom: 0;
}
tbody tr:nth-child(even) {
  background: rgba(143, 99, 18, 0.05);
}
tbody th {
  font-weight: 700;
  white-space: nowrap;
}
/* أول عمود ثابت وانت بتسكرول الجدول بالعرض */
tbody th[scope='row'] {
  position: sticky;
  inset-inline-start: 0;
  z-index: 1;
  background: #fbf3dd;
  box-shadow: 1px 0 0 rgba(143, 99, 18, 0.16);
}
[dir='rtl'] tbody th[scope='row'] {
  box-shadow: -1px 0 0 rgba(143, 99, 18, 0.16);
}
tbody tr:nth-child(even) th[scope='row'] {
  background: #f4e9cd;
}
tbody tr.hl th[scope='row'] {
  background: #f6dc95;
}
thead th:first-child {
  position: sticky;
  inset-inline-start: 0;
  z-index: 2;
}
.num {
  text-align: end;
  white-space: nowrap;
}
td.wrap {
  min-width: 14ch;
}
tr.hl {
  background: rgba(243, 201, 90, 0.28) !important;
}
details.long {
  margin: 14px 0 20px;
}
details.long > summary {
  cursor: pointer;
  padding: 8px 12px;
  border: 1px solid var(--parchment-line);
  border-radius: 8px;
  background: rgba(143, 99, 18, 0.07);
  font-weight: 700;
  color: #3a2208;
}
details.long[open] > summary {
  margin-bottom: 0;
}
details.long .tblw {
  margin-top: 10px;
}

/* ===== صناديق ===== */
.tips {
  margin: 34px 0 10px;
  padding: 16px 18px 6px;
  border: 1px solid #d9b35a;
  border-inline-start: 5px solid var(--gold-deep);
  border-radius: 8px;
  background: #fbefc9;
}
.tips h2 {
  margin: 0 0 6px !important;
  font-size: 23px !important;
  border: 0 !important;
  padding: 0 !important;
}
.tips ul {
  margin: 0 0 10px;
  padding-inline-start: 20px;
}
.tips li {
  margin: 0 0 8px;
}
.note {
  margin: 16px 0;
  padding: 12px 16px;
  border-radius: 8px;
  background: rgba(29, 74, 130, 0.08);
  border: 1px solid rgba(29, 74, 130, 0.25);
  font-size: 17px;
}
.formula {
  display: block;
  margin: 12px 0 16px;
  padding: 10px 14px;
  border-radius: 6px;
  background: #fbf3dd;
  border: 1px dashed var(--parchment-line);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.5;
  white-space: normal;
}
.figure {
  float: right;
  margin: 0 0 10px 16px;
}
[dir='rtl'] .figure {
  float: left;
  margin: 0 16px 10px 0;
  width: 104px;
  text-align: center;
}
.figure img {
  width: 104px;
  height: 104px;
  object-fit: contain;
  filter: drop-shadow(0 4px 6px rgba(60, 36, 8, 0.35));
}
.clear {
  clear: both;
}
.tag {
  display: inline-block;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 14px;
  line-height: 1.6;
  background: rgba(143, 99, 18, 0.14);
  color: #4a3010;
  white-space: nowrap;
}
.tag.atk {
  background: rgba(142, 42, 26, 0.13);
  color: var(--seal);
}
.tag.def {
  background: rgba(29, 74, 130, 0.12);
  color: var(--lapis);
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
  margin: 16px 0 8px;
  padding: 0;
  list-style: none;
}
.cards a {
  display: block;
  height: 100%;
  padding: 14px 16px;
  border: 1px solid var(--parchment-line);
  border-radius: 8px;
  background: #fbf3dd;
  text-decoration: none;
  color: var(--text);
}
.cards a:hover {
  border-color: var(--gold-deep);
  background: #fff8e4;
}
.cards b {
  display: block;
  font-family: var(--display);
  font-weight: 400;
  font-size: 21px;
  color: #3a2208;
  margin-bottom: 2px;
}
.cards span {
  font-size: 16px;
  color: var(--muted);
  line-height: 1.4;
  display: block;
}

/* ===== السابق / التالي ===== */
.prevnext {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 44px;
  padding-top: 18px;
  border-top: 1px solid var(--parchment-line);
}
.prevnext a {
  display: block;
  padding: 10px 14px;
  border: 1px solid var(--parchment-line);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  background: #fbf3dd;
}
.prevnext a:hover {
  border-color: var(--gold-deep);
}
.prevnext small {
  display: block;
  font-size: 14px;
  color: var(--muted);
}
.prevnext b {
  font-size: 18px;
  color: var(--lapis);
}
.prevnext .next {
  text-align: end;
  grid-column: 2;
}

.foot {
  padding: 26px 16px 34px;
  font-size: 15px;
  color: var(--on-dark-muted);
  max-width: 920px;
}
.foot a {
  color: var(--on-dark);
}

/* ===== شاشات أكبر ===== */
@media (max-width: 520px) {
  .brand small {
    display: none;
  }
  .topbar-in {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 12px 10px;
    gap: 8px 10px;
  }
  .search {
    order: 5;
    flex: 1 1 calc(100% - 110px);
    max-width: none;
    margin: 0;
  }
  .lang {
    order: 6;
    height: 40px;
    font-size: 15px;
  }
  .play {
    margin-inline-start: auto;
    height: 38px;
    padding: 0 13px;
    font-size: 15px;
  }
  :root {
    --top-h: 108px;
  }
  body {
    font-size: 17px;
  }
  .band {
    padding-bottom: 46px;
  }
  .lede {
    font-size: 17px;
    line-height: 1.5;
  }
  .sheet h2 {
    font-size: 25px;
  }
  .sheet h3 {
    font-size: 20px;
  }
  .figure {
    width: 76px;
  }
  .figure img {
    width: 76px;
    height: 76px;
  }
  .prevnext {
    grid-template-columns: 1fr;
  }
  .prevnext .next {
    grid-column: 1;
  }
}
@media (min-width: 700px) {
  .band {
    padding: 34px 32px 62px;
  }
  .sheet {
    margin: -38px 24px 0;
    padding: 34px 40px 40px;
    border-radius: 8px 8px 0 0;
  }
  .foot {
    padding-inline-start: 32px;
  }
}
@media (min-width: 1040px) {
  .menu-btn,
  .nav-close,
  .scrim {
    display: none !important;
  }
  .layout {
    grid-template-columns: 260px minmax(0, 1fr);
  }
  .sidenav {
    position: sticky;
    top: var(--top-h);
    height: calc(100vh - var(--top-h));
    width: auto;
    transform: none;
    transition: none;
    background: transparent;
    border-inline-end: 1px solid var(--ink-line);
    z-index: 1;
  }
  .band {
    padding-inline-start: 44px;
  }
  .sheet {
    margin-left: 32px;
    margin-right: 32px;
  }
  .foot {
    padding-inline-start: 44px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .sidenav {
    transition: none;
  }
  html {
    scroll-behavior: auto;
  }
}
@media print {
  .topbar,
  .sidenav,
  .prevnext,
  .scrim,
  .foot {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
  .sheet {
    box-shadow: none;
    margin: 0;
  }
}

/* ===== القاموس ===== */
.gloss {
  margin: 0 0 8px;
}
.gloss dt {
  margin-top: 14px;
  font-size: 19px;
  color: #3a2208;
}
.gloss dd {
  margin: 2px 0 0;
}

/* شاشات عريضة: الورقة أعرض عشان الجداول الكبيرة، والنص فاضل على 72 حرف */
@media (min-width: 1280px) {
  .sheet,
  .band,
  .foot {
    max-width: 1080px;
  }
  .sheet {
    margin-inline-end: 20px;
    padding-left: 36px;
    padding-right: 36px;
  }
}
