/* الألوان */
:root {
  --red: #a01c2e;
  --red-dark: #6e0f1d;
  --red-light: #c23347;
  --flag-black: #111;
  --green: #147744;

  --page-bg: #cfcabb;
  --page-bg-2: #c8c3b3;
  --white: #fff;
  --text: #333;
  --title: #222;
  --muted: #666;
  --gold: #7d5a1e;
  --border: #b5b0a2;
  --border-soft: #dcd8cc;

  --bar-top: #f7f6f1;
  --bar-bottom: #dedacd;
  --head-top: #fdfcf8;
  --head-bottom: #e6e0cf;
  --side-bg: #f2efe6;
  --row-alt: #f8f6f0;
}

[data-theme="dark"] {
  --page-bg: #1b1b1b;
  --page-bg-2: #171717;
  --white: #262626;
  --text: #d6d6d6;
  --title: #f0f0f0;
  --muted: #a5a5a5;
  --gold: #d6b26a;
  --border: #4a4a4a;
  --border-soft: #383838;

  --bar-top: #444;
  --bar-bottom: #2e2e2e;
  --head-top: #383838;
  --head-bottom: #242424;
  --side-bg: #2d2d2d;
  --row-alt: #2f2f2f;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { background: var(--page-bg); }

body {
  margin: 0;
  padding: 12px 0 20px;
  color: var(--text);
  font-family: Tahoma, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.75;
  background-color: var(--page-bg);
  background-image: repeating-linear-gradient(45deg, var(--page-bg-2) 0 1px, transparent 1px 4px);
}

img { display: block; max-width: 100%; height: auto; }
a { color: var(--red); text-decoration: none; }

.page {
  width: 970px;
  max-width: 100%;
  margin: 0 auto;
  background: var(--white);
  border: 1px solid #8f8a7c;
  box-shadow: 0 0 6px rgba(0, 0, 0, .35);
}

.flagline { display: grid; grid-template-rows: 4px 3px 4px; }
.flagline span:nth-child(1) { background: #ce1126; }
.flagline span:nth-child(2) { background: #fff; }
.flagline span:nth-child(3) { background: var(--flag-black); }

/* الترويسة */
.masthead {
  position: relative;
  background: linear-gradient(to bottom, var(--head-top), var(--head-bottom));
  border-bottom: 1px solid var(--border);
}
.masthead__inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
}
.crest { width: 92px; flex: none; }
.masthead__names { flex: 1; }
.masthead__title {
  margin: 0;
  font-family: "Traditional Arabic", "Simplified Arabic", "Times New Roman", serif;
  font-size: 34px;
  font-weight: bold;
  line-height: 1.25;
  color: var(--red);
}
[data-theme="dark"] .masthead__title { color: #e4606f; }
.masthead__sub {
  margin: 0;
  font-size: 13px;
  font-weight: bold;
  color: var(--gold);
}
.masthead__chant {
  width: 130px;
  margin-top: 16px;
  padding: 5px 10px;
  color: var(--gold);
  font-family: "Traditional Arabic", "Simplified Arabic", "Times New Roman", serif;
  font-size: 19px;
  font-weight: bold;
  line-height: 1.2;
  border-right: 1px solid var(--border);
}
.masthead__chant p { margin: 0; text-align: center; }
.masthead__chant-sides { display: flex; justify-content: space-between; }

.theme-toggle {
  position: absolute;
  top: 4px;
  left: 8px;
  padding: 0;
  font: inherit;
  font-size: 11px;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--red); text-decoration: underline; }

/* القائمة */
.nav {
  background: linear-gradient(to bottom, var(--red-light) 0, var(--red) 48%, var(--red-dark) 52%, #861527 100%);
  border-top: 1px solid var(--red-dark);
  border-bottom: 3px solid #3d0810;
}
.nav ul {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
}
.nav li { border-left: 1px solid #5c0d19; border-right: 1px solid #c04658; }
.nav li:first-child { border-right: 0; }
.nav a {
  display: block;
  padding: 7px 24px;
  color: #fff;
  font-size: 13px;
  font-weight: bold;
}
.nav a:hover { background: #55101b; text-decoration: underline; }
.nav a.is-active { background: #55101b; }
.nav__toggle { display: none; }

/* الأعمدة */
main { padding: 10px; }

.cols {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 10px;
}
.cols__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.side {
  width: 262px;
  flex: none;
  padding: 7px;
  background: var(--side-bg);
  border: 1px solid var(--border);
}

/* المربعات */
.box { border: 1px solid var(--border); background: var(--white); }
.about { flex: 1; }
.box__body { padding: 10px 12px; }
.box__body p { margin: 0 0 8px; text-align: justify; }
.box__body p:last-child { margin-bottom: 0; }

.sechead {
  margin: 0;
  padding: 3px 10px;
  font-size: 14px;
  font-weight: bold;
  line-height: 1.7;
  color: var(--red);
  background: linear-gradient(to bottom, var(--bar-top), var(--bar-bottom));
  border-bottom: 1px solid var(--border);
}
[data-theme="dark"] .sechead { color: #eb8894; }
.sechead::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 7px;
  background: var(--red);
  border: 1px solid var(--red-dark);
}

.intro__actions { margin-top: 2px; text-align: left; }
.btn {
  display: inline-block;
  padding: 2px 16px;
  font-size: 12px;
  font-weight: bold;
  border-radius: 3px;
}
.btn--red {
  color: #fff;
  background: linear-gradient(to bottom, var(--red-light), var(--red-dark));
  border: 1px solid #55101b;
}
.btn--red:hover { background: var(--red-dark); text-decoration: underline; }

.about .lead { font-weight: bold; color: var(--title); }

/* العلم */
.flagcard__flag {
  display: grid;
  grid-template-rows: 1fr 1fr 1fr;
  width: 180px;
  max-width: 100%;
  margin: 2px auto 0;
  aspect-ratio: 3 / 2;
  border: 1px solid #777;
}
.flagcard__flag .r { background: #ce1126; }
.flagcard__flag .k { background: var(--flag-black); }
.flagcard__flag .w {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18%;
  background: #fff;
}
.flagcard__flag svg {
  width: 13%;
  aspect-ratio: 100 / 95;
  fill: var(--green);
}
.flagcard__meta {
  display: table;
  width: 100%;
  margin: 7px 0 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-collapse: collapse;
}
.flagcard__meta > div { display: table-row; }
.flagcard__meta > div:nth-child(even) { background: var(--row-alt); }
.flagcard__meta dt,
.flagcard__meta dd {
  display: table-cell;
  padding: 2px 7px;
  font-size: 12px;
  border-bottom: 1px solid var(--border-soft);
}
.flagcard__meta dt { width: 40%; font-weight: bold; color: var(--muted); border-left: 1px solid var(--border-soft); }
.flagcard__meta dd { margin: 0; color: var(--title); white-space: nowrap; }
.flagcard__meta > div:last-child dt,
.flagcard__meta > div:last-child dd { border-bottom: 0; }

/* أرقام */
.facts {
  margin: 7px 0 0;
  padding: 0;
  list-style: none;
  background: var(--white);
  border: 1px solid var(--border);
}
.facts li {
  padding: 6px 8px;
  border-bottom: 1px dotted var(--border);
}
.facts li:last-child { border-bottom: 0; }
.facts strong {
  display: block;
  font-size: 15px;
  line-height: 1.4;
  color: var(--red);
}
[data-theme="dark"] .facts strong { color: #eb8894; }
.facts span { font-size: 11px; color: var(--muted); }

/* السيادة */
.files {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.file {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 11px;
  align-items: start;
  padding: 11px;
  border-bottom: 1px solid var(--border-soft);
}
.file:nth-child(odd) { border-left: 1px solid var(--border-soft); }
.file:nth-last-child(-n+2) { border-bottom: 0; }

.frame {
  margin: 0;
  padding: 3px;
  background: var(--white);
  border: 1px solid #aaa;
}
.frame img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
}
.frame--emblem { background: #fff; }
.frame--emblem img { object-fit: contain; padding: 10%; }
.frame.is-empty {
  aspect-ratio: 4 / 5;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--side-bg);
  color: var(--muted);
  font-size: 10px;
  direction: ltr;
}
.file__dates {
  display: block;
  font-size: 11px;
  color: var(--muted);
}
.file h3 {
  margin: 0 0 4px;
  padding-bottom: 2px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--red);
  border-bottom: 1px dotted var(--border);
}
[data-theme="dark"] .file h3 { color: #eb8894; }
.file p { margin: 0; text-align: justify; font-size: 12px; }

/* التذييل */
.footer {
  background: linear-gradient(to bottom, var(--bar-top), var(--bar-bottom));
  border-top: 1px solid var(--border);
}
.footer__inner {
  padding: 8px 10px;
  text-align: center;
}
.footer img { width: 36px; margin: 0 auto 2px; }
.footer p {
  margin: 0;
  font-size: 12px;
  font-weight: bold;
  color: var(--title);
}
.footer small { font-size: 11px; color: var(--muted); }

.theme-toggle:focus-visible,
.nav a:focus-visible,
.nav__toggle:focus-visible,
.btn:focus-visible { outline: 1px dotted currentColor; outline-offset: 1px; }

/* الشاشات الصغيرة */
@media (max-width: 760px) {
  body { padding: 0; font-size: 14px; }
  .page { border: 0; box-shadow: none; }
  .masthead__inner { padding: 24px 10px 10px; gap: 10px; }
  .crest { width: 62px; }
  .masthead__title { font-size: 25px; }
  .masthead__chant { width: 82px; margin-top: 0; padding: 2px 6px; font-size: 15px; }
  .nav__toggle {
    display: block;
    width: 100%;
    padding: 7px;
    font: inherit;
    font-weight: bold;
    color: #fff;
    background: none;
    border: 0;
    cursor: pointer;
  }
  .nav ul { display: none; flex-direction: column; }
  .nav.is-open ul { display: flex; }
  .nav li { border: 0; border-top: 1px solid #5c0d19; }
  .cols { flex-direction: column; }
  .side { width: 100%; }
  .files { grid-template-columns: 1fr; }
  .file,
  .file:nth-child(odd) { border-left: 0; }
  .file:nth-last-child(2) { border-bottom: 1px solid var(--border-soft); }
}
