/* =============================================================
   تقرير أوسكار الشركة - نسخة الطباعة / PDF
   نفس لغة الموقع: مسطّح بلا ظلال، خطوط فاصلة رفيعة، أرقام ضخمة،
   والأحمر #BA1723 حبرًا لا زينة.
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap');

@font-face {
  font-family: 'Somar Sans';
  src: url('/fonts/SomarSans-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: block;
}
@font-face {
  font-family: 'Somar Sans';
  src: url('/fonts/SomarSans-Medium.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: block;
}
@font-face {
  font-family: 'Somar Sans';
  src: url('/fonts/SomarSans-SemiBold.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: block;
}
@font-face {
  font-family: 'Somar Sans';
  src: url('/fonts/SomarSans-Bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: block;
}

:root {
  --brand:      #ba1723;
  --brand-soft: #fdf1f2;
  --ink:        #141418;
  --muted:      #55555f;
  --faint:      #8a8a93;
  --rule:       #dedcd8;
  --rule-soft:  #e9e7e4;
  --paper:      #ffffff;
  --wash:       #f4f3f1;

  --font-ui:      'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  --font-display: 'Somar Sans', 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--wash);
  color: var(--ink);
  font-family: var(--font-ui);
  line-height: 1.7;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* شريط الأدوات على الشاشة فقط ------------------------------------------- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 18px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  font-size: 14px;
}
.toolbar b { font-family: var(--font-display); font-weight: 600; }
.toolbar .spacer { margin-inline-start: auto; }
.toolbar .hint { color: var(--faint); font-size: 12.5px; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border: 1.5px solid var(--brand);
  border-radius: 2px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn-ghost { background: none; color: var(--ink); border-color: var(--ink); }

/* الصفحات ---------------------------------------------------------------- */
.page {
  position: relative;
  width: var(--pw);
  height: var(--ph);
  margin: 18px auto;
  padding: var(--pad-y) var(--pad-x) var(--pad-b);
  background: var(--paper);
  overflow: hidden;           /* لا شيء يتجاوز حدود الصفحة أبدًا */
  page-break-after: always;
  break-after: page;
}
.page:last-child { page-break-after: auto; break-after: auto; }

/* صفحة تتدفّق على أكثر من ورقة (الجداول الطويلة) */
.page.flow { height: auto; min-height: var(--ph); overflow: visible; }

/*
 * مقاس الشرائح = مقاس عرض PowerPoint العريض (16:9): 13.333 × 7.5 بوصة.
 * وليس A4، كي يملأ الشاشة والبروجكتر بلا حواف سوداء.
 */
body.slides { --pw: 338.67mm; --ph: 190.5mm; --pad-x: 20mm; --pad-y: 15mm; --pad-b: 20mm; }
body.report { --pw: 210mm;    --ph: 297mm;   --pad-x: 16mm; --pad-y: 16mm; --pad-b: 18mm; }

/* شريط العلامة على حافة القراءة */
.page.light::after {
  content: '';
  position: absolute;
  inset-block: 0;
  inset-inline-end: 0;
  width: 8mm;
  background: var(--brand);
}
.page.dark { background: var(--brand); color: #fff; }

/* الغلاف ----------------------------------------------------------------- */
.cover { display: flex; flex-direction: column; justify-content: center; }
.cover-logo { width: 22mm; height: 22mm; border-radius: 2mm; margin-bottom: 10mm; }
.cover h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20mm;
  line-height: 1.3;
  margin: 0;
}
body.report .cover h1 { font-size: 16mm; }
.cover .sub { font-size: 7mm; margin-top: 5mm; color: #f6d6d9; font-weight: 500; }
.cover .rule { width: 34mm; height: 1.2mm; background: #f6d6d9; margin: 9mm 0; }
.cover .meta { font-size: 4mm; color: #efc0c4; }

/* صفحة فائز واحد --------------------------------------------------------- */
.award { display: flex; flex-direction: column; height: 100%; }
.award-top {
  display: flex;
  align-items: flex-start;
  gap: 6mm;
  padding-bottom: 5mm;
  border-bottom: 0.4mm solid var(--rule);
}
.award-idx {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11mm;
  line-height: 1;
  color: var(--brand);
  direction: ltr;
  unicode-bidi: isolate;
}
.award-emoji { font-size: 11mm; line-height: 1; }
.award-oscar {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 7mm;
  line-height: 1.45;
  color: var(--muted);
  flex: 1;
}
.award-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;             /* يسمح بالانكماش بدل الطفح */
}
.award-label {
  font-size: 4.2mm;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--faint);
  margin-bottom: 3mm;
}
.award-winner {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
  /* الحجم يُضبط بحسب طول الاسم في print.js */
}
.award-tie {
  margin-top: 5mm;
  font-size: 4.4mm;
  font-weight: 600;
  color: var(--brand);
}
.award-foot {
  display: flex;
  align-items: center;
  gap: 4mm;
  margin-top: 7mm;
  padding-top: 5mm;
  border-top: 0.3mm solid var(--rule-soft);
  font-size: 3.6mm;
  color: var(--faint);
}
.award-foot .num { direction: ltr; unicode-bidi: isolate; }
.award-foot img { width: 6mm; height: 6mm; border-radius: 1mm; }
.award-foot .spacer { margin-inline-start: auto; }

/* المركزان الثاني والثالث ------------------------------------------------- */
.runners {
  display: flex;
  gap: 12mm;
  flex-wrap: wrap;
  margin-top: 8mm;
  padding-top: 5mm;
  border-top: 0.3mm solid var(--rule-soft);
}
.runner { display: flex; align-items: baseline; gap: 3mm; min-width: 0; }
.runner-rank {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 4.6mm;
  color: var(--brand);
  direction: ltr;
  unicode-bidi: isolate;
  flex: none;
}
.runner-name {
  font-size: 4.4mm;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.5;
}
.runner-votes { font-size: 3.6mm; color: var(--faint); white-space: nowrap; }
.runners-none { margin-top: 8mm; font-size: 3.6mm; color: var(--faint); }

/* عناوين الأقسام --------------------------------------------------------- */
.section-head {
  margin: 0 0 7mm;
  padding-bottom: 3mm;
  border-bottom: 0.8mm solid var(--ink);
}
.section-head h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 9mm;
  margin: 0;
  line-height: 1.45;
}
.section-head p { margin: 1.5mm 0 0; font-size: 3.8mm; color: var(--faint); }

/* بطاقات الأرقام --------------------------------------------------------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 0.3mm solid var(--rule);
  margin-bottom: 8mm;
}
.tile { padding: 4mm; border-inline-start: 0.3mm solid var(--rule-soft); border-bottom: 0.3mm solid var(--rule-soft); }
.tile:nth-child(4n + 1) { border-inline-start: none; }
.tile-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 9mm;
  line-height: 1.15;
  color: var(--brand);
  direction: ltr;
  unicode-bidi: isolate;
  text-align: start;
}
.tile-label { font-size: 3.3mm; color: var(--muted); margin-top: 0.5mm; line-height: 1.4; }

/* جدول النتائج ----------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: 3.7mm; }
thead { display: table-header-group; }      /* يتكرّر رأس الجدول في كل صفحة */
th, td {
  text-align: start;
  padding: 2.4mm 2mm;
  border-bottom: 0.25mm solid var(--rule-soft);
  vertical-align: top;
}
th {
  font-size: 3.1mm;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--faint);
  border-bottom: 0.5mm solid var(--ink);
}
tr { break-inside: avoid; page-break-inside: avoid; }
td.num { direction: ltr; unicode-bidi: isolate; white-space: nowrap; color: var(--muted); }
td.win { font-weight: 600; }
.chip {
  display: inline-block;
  padding: 0.6mm 2mm;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
  font-size: 3.3mm;
}

/* قوائم السجلّات --------------------------------------------------------- */
.recs { display: grid; grid-template-columns: 1fr 1fr; gap: 6mm 8mm; }
/*
 * على الشريحة نثبّت عدد الأعمدة والصفوف بدل ترك الشبكة تلتفّ:
 * التفافها كان يرفع ارتفاع الصف فيطفح آخر سطر خارج الشريحة.
 */
body.slides .recs { gap: 8mm 12mm; align-content: start; }
body.slides .recs-4 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  height: 100%;
}
body.slides .recs-3 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
}
/* البطاقة لا تتمدّد خارج خانتها مهما طال محتواها */
body.slides .rec { min-height: 0; overflow: hidden; }
body.slides .rec-row { padding: 1.9mm 0; }
body.slides .rec h3 { font-size: 4.9mm; }
/* الصفحة التي تحمل الشبكة تُعطيها بقيّة الارتفاع */
body.slides .page.recs-page { display: flex; flex-direction: column; }
body.slides .recs-page .recs { flex: 1; min-height: 0; }
body.slides .tiles { grid-template-columns: repeat(4, 1fr); }
.rec { break-inside: avoid; page-break-inside: avoid; }
.rec h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 4.6mm;
  margin: 0 0 1mm;
  line-height: 1.35;
}
.rec .note { font-size: 3.2mm; color: var(--faint); margin: 0 0 2mm; line-height: 1.45; }
.rec-row {
  display: grid;
  grid-template-columns: 9mm 1fr;
  gap: 0 2.5mm;
  padding: 1.6mm 0;
  border-bottom: 0.25mm solid var(--rule-soft);
}
.rec-row:last-child { border-bottom: none; }
.rec-val {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 4mm;
  color: var(--brand);
  direction: ltr;
  unicode-bidi: isolate;
  text-align: start;
}
.rec-name { font-size: 3.8mm; font-weight: 500; line-height: 1.4; }
.rec-sub { grid-column: 2; font-size: 3.2mm; color: var(--faint); line-height: 1.4; }
.rec-empty { font-size: 3.4mm; color: var(--faint); }

/* ترقيم الصفحات ---------------------------------------------------------- */
.page-num {
  position: absolute;
  inset-block-end: calc(var(--pad-b) / 2.2);
  inset-inline-start: var(--pad-x);
  font-size: 3.2mm;
  color: var(--faint);
  direction: ltr;
  unicode-bidi: isolate;
}

.loading { padding: 60px 20px; text-align: center; color: var(--faint); }

/* ------------------------------------------------------------- الطباعة */
@media print {
  html, body { background: #fff; }
  .toolbar { display: none !important; }
  .page {
    margin: 0;
    box-shadow: none;
    /* المقاس يأتي من @page، فنترك الارتفاع يملأ الورقة تمامًا */
  }
}

@media screen {
  .page { box-shadow: 0 2px 14px rgba(20, 20, 24, 0.12); }
  body { padding-bottom: 40px; }
}
