/* Amiri (document font) is self-hosted so the PDF export can embed it */
@font-face { font-family: "Amiri"; font-weight: 400; font-display: swap; src: url(../vendor/fonts/amiri-arabic-400.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Amiri"; font-weight: 700; font-display: swap; src: url(../vendor/fonts/amiri-arabic-700.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Amiri"; font-weight: 400; font-display: swap; src: url(../vendor/fonts/amiri-latin-400.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "Amiri"; font-weight: 700; font-display: swap; src: url(../vendor/fonts/amiri-latin-700.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122; }

:root {
  --ink: #14213d;
  --brand: #0f5c4d;
  --brand-2: #157a66;
  --gold: #c9962b;
  --bg: #f4f1ea;
  --card: #ffffff;
  --line: #e2ddd0;
  --muted: #6b6b6b;
  --pdf: #c0392b;
  --word: #2b579a;
  --wa: #1fa855;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Tajawal", system-ui, sans-serif; font-size: 16px; line-height: 1.6;
}
a { color: inherit; }
.muted { color: var(--muted); font-size: .92em; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.wrap.narrow { max-width: 640px; padding-top: 24px; padding-bottom: 40px; }
.link { color: var(--brand); text-decoration: none; font-weight: 700; }

/* ---------- header */
.top {
  position: sticky; top: 0; z-index: 20; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,.12);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand b { display: block; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { display: block; font-size: .68rem; letter-spacing: .12em; opacity: .75; direction: ltr; text-align: right; }
.logo { background: var(--gold); width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 20px; flex: none; }
.top nav { display: flex; align-items: center; gap: 10px; }
.count { background: var(--gold); color: #fff; font-weight: 800; padding: 4px 12px; border-radius: 999px; font-size: .85rem; white-space: nowrap; }
.top .btn.ghost { color: #fff; border-color: rgba(255,255,255,.4); background: transparent; }

/* ---------- buttons */
.btn {
  font: inherit; font-weight: 700; border: 1.5px solid transparent; border-radius: 10px; padding: 9px 16px;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  transition: transform .08s, filter .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn.sm { padding: 6px 12px; font-size: .9rem; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn.pdf { background: var(--pdf); color: #fff; }
.btn.word { background: var(--word); color: #fff; }
.btn.wa { background: var(--wa); color: #fff; }
.btn.sponsored { background: #fbf3e0; color: var(--ink); border-color: var(--gold); margin: 0 0 10px; }

/* ---------- hero */
.hero {
  background: linear-gradient(160deg, var(--brand) 0%, #0a4237 100%); color: #fff; text-align: center;
  padding: 36px 16px 44px;
}
.hero h1 { margin: 0 0 6px; font-size: clamp(1.4rem, 4vw, 2.2rem); font-weight: 800; }
.hero p { margin: 0 auto 20px; max-width: 640px; opacity: .85; }
.search { max-width: 620px; margin: 0 auto; position: relative; }
.search input {
  width: 100%; font: inherit; font-size: 1.05rem; padding: 14px 48px 14px 18px; border: 0; border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,.2); outline: none;
}
.search span { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); }

/* ---------- category chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 16px 0 8px; scrollbar-width: thin; }
.chips button {
  font: inherit; font-size: .92rem; white-space: nowrap; border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
}
.chips button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.listhead { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 12px; font-weight: 700; gap: 10px; flex-wrap: wrap; }

/* ---------- grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; padding-bottom: 32px; }
.card {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 14px 14px; text-decoration: none; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px;
  transition: box-shadow .15s, transform .15s, border-color .15s; min-height: 150px;
}
.card:hover { box-shadow: 0 10px 24px rgba(20,33,61,.1); transform: translateY(-2px); border-color: var(--brand-2); }
.card .ico { font-size: 30px; }
.card b { font-size: .95rem; line-height: 1.45; }
.card small { color: var(--muted); font-size: .78rem; direction: ltr; }
.card .lang { position: absolute; top: 8px; left: 8px; font-size: .68rem; font-weight: 800; background: #fbf3e0; color: var(--gold); padding: 1px 7px; border-radius: 6px; }
.card.new { border-style: dashed; border-color: var(--brand-2); background: #f7fbf9; }
.span-all { grid-column: 1 / -1; }

/* ---------- ads */
.ad { margin: 14px auto; text-align: center; overflow: hidden; }
.ad-ph {
  display: grid; place-items: center; border: 2px dashed #cfc7b4; border-radius: 12px; color: #a59c86;
  background: repeating-linear-gradient(45deg, #faf8f3, #faf8f3 10px, #f3efe5 10px, #f3efe5 20px); font-size: .85rem;
}
.ad-top.ad-ph, .ad-footer.ad-ph { height: 90px; max-width: 728px; }
.ad-infeed.ad-ph { height: 110px; margin: 0; }
.ad-sidebar.ad-ph { height: 600px; width: 100%; margin: 0; }
.ad-download.ad-ph { height: 250px; max-width: 300px; }

/* ---------- document page */
.crumbs { font-size: .85rem; color: var(--muted); padding: 14px 0 4px; }
.crumbs a { text-decoration: none; color: var(--brand); }
.doc-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.doc-head h1 { margin: 0; font-size: clamp(1.15rem, 3vw, 1.6rem); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.editor { display: grid; grid-template-columns: 320px minmax(0, 1fr) 300px; gap: 18px; align-items: start; padding-bottom: 32px; }
.form { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; }
.form h3 { margin: 0; }
.form label, label.req { display: block; margin: 12px 0 0; }
.form label span, label.req span { display: block; font-size: .85rem; font-weight: 700; margin-bottom: 4px; }
.form input, .form textarea, label.req input, label.req textarea {
  width: 100%; font: inherit; padding: 9px 11px; border: 1.5px solid var(--line); border-radius: 9px; background: #fdfcf9; outline: none;
}
.form input:focus, .form textarea:focus, label.req input:focus, label.req textarea:focus { border-color: var(--brand-2); background: #fff; }
.form-foot { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.wrap.narrow .btn { margin-top: 16px; }

.paper-col { min-width: 0; }
.toolbar {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap; background: #fff; border: 1px solid var(--line);
  border-radius: 12px 12px 0 0; padding: 6px 8px; position: sticky; top: 64px; z-index: 5;
}
.toolbar button { font: inherit; min-width: 34px; height: 32px; border: 0; background: transparent; border-radius: 7px; cursor: pointer; font-size: 1rem; padding: 0 8px; }
.toolbar button:hover { background: #eef3f1; }
.toolbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.toolbar .hint { margin-inline-start: auto; font-size: .8rem; color: var(--muted); }
.paper-scroll { background: #d9d4c7; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 12px 12px; padding: 20px; overflow: hidden; }

/* A4 sheet */
.paper {
  width: 210mm; min-height: 297mm; margin: 0 auto; background: #fff; padding: 22mm 20mm;
  box-shadow: 0 6px 24px rgba(0,0,0,.15); outline: none; color: #111;
  font-family: "Amiri", "Times New Roman", serif; font-size: 15.5pt; line-height: 1.75;
}
.paper[dir="ltr"] { font-family: "Times New Roman", Georgia, serif; font-size: 12.5pt; }
.paper p { margin: 0 0 6px; }
.paper .b-title { text-align: center; font-weight: 700; font-size: 1.3em; text-decoration: underline; text-underline-offset: 6px; margin: 6px 0 10px; }
.paper .b-center { text-align: center; font-weight: 700; }
.paper .b-end { text-align: end; }
.paper .b-start { text-align: start; margin: 0; }
.paper .b-just { text-align: justify; text-indent: 1.5em; }
.paper .b-empty { margin: 0; line-height: 1; }
.paper .b-cols { display: flex; justify-content: space-between; gap: 20px; margin-top: 18px; font-weight: 700; }
.paper .b-cols p { flex: 1; text-align: center; }
.paper .v { background: #fff7d6; border-radius: 3px; padding: 0 2px; transition: background .2s; }
.paper .v.empty { color: #b9ad8a; background: transparent; }
.paper .v.hl { background: #ffe58a; box-shadow: 0 0 0 2px #ffd34d; }
/* the clone used for PDF: no highlight */
.pdf-holder { position: fixed; left: -10000px; top: 0; }
.paper.for-pdf { box-shadow: none; margin: 0; }
.paper.for-pdf .v, .paper.for-pdf .v.empty { background: transparent; color: inherit; box-shadow: none; }

.side { position: sticky; top: 76px; }
.tabs-m { display: none; }

/* ---------- modal */
.modal { position: fixed; inset: 0; background: rgba(10,20,30,.55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal[hidden] { display: none; }
.modal .box { background: #fff; border-radius: 18px; padding: 24px; width: min(420px, 100%); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.modal h3 { margin: 8px 0 4px; }
.spin { width: 38px; height: 38px; border: 4px solid #e4efe9; border-top-color: var(--brand); border-radius: 50%; margin: 0 auto; animation: spin .8s linear infinite; }
.spin[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- footer */
.foot { text-align: center; padding: 22px 16px 34px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 10px; }
.foot p { margin: 4px 0; }
.foot a { color: var(--brand); }

/* ---------- responsive */
@media (max-width: 1180px) {
  .editor { grid-template-columns: 300px minmax(0, 1fr); }
  .side { grid-column: 1 / -1; position: static; }
  .ad-sidebar.ad-ph { height: 250px; max-width: 728px; margin: 0 auto; }
}
@media (max-width: 860px) {
  .top nav .btn { display: none; }
  .editor { grid-template-columns: 1fr; }
  .form { position: static; max-height: none; }
  .tabs-m { display: flex; gap: 6px; margin-bottom: 10px; position: sticky; top: 60px; z-index: 6; background: var(--bg); padding: 6px 0; }
  .tabs-m button { flex: 1; font: inherit; font-weight: 700; padding: 10px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; }
  .tabs-m button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
  .editor[data-show="form"] .paper-col { display: none; }
  .editor[data-show="paper"] .form { display: none; }
  .toolbar { top: 112px; }
  .toolbar .hint { display: none; }
  .paper-scroll { padding: 10px; }
  .doc-head .actions { width: 100%; }
  .doc-head .actions .btn { flex: 1 1 auto; justify-content: center; padding: 9px 10px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { min-height: 130px; padding: 16px 10px 12px; }
  .ad-top.ad-ph, .ad-footer.ad-ph { height: 70px; }
}

/* ---------- print: only the sheet */
@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  body * { visibility: hidden; }
  #paper, #paper * { visibility: visible; }
  #paper { position: absolute; left: 0; top: 0; box-shadow: none; margin: 0; zoom: 1 !important; }
  .paper .v, .paper .v.empty { background: transparent; color: inherit; box-shadow: none; }
}
