/* Thank-you certificate (spec §7.4/7.5). The page is a 1123×794 board (A4 landscape at 96 px/in);
   certificates.js places every piece at the same board pixels it uses for the PNG canvas.
   The paper stays light in dark mode: it is a printed keepsake. */

#print-root { display: none; }

/* Fixed art colours for printed paper (certificate previews and «قائمة الأوائل»).
   Paper is paper: these never change with the design or with dark mode. */
.cert-thumb, .winners-sheet {
    --w-paper: #FFFFFF;
    --w-paper-warm: #FFFDF8;
    --w-text: #1E293B;
    --w-ink: #3B0764;
    --w-tint: #F3E8FF;
    --w-muted: #475569;
    --w-faint: #94A3B8;
    --w-foot: #64748B;
    --w-line: #CBD5E1;
    --w-row: #F8FAFC;
    --w-gold: #B8892B;
}

/* The theme's palette arrives as inline custom properties on each page (certificates.js paletteVars);
   the values below are the default «💜 بنفسجي ملكي». */
.cert-page {
    --cert-primary: #7e22ce;
    --cert-deep: #581c87;
    --cert-soft: #d8b4fe;
    --cert-accent: #db2777;
    --cert-accent-deep: #be185d;
    --cert-highlight: #0f766e;
    --cert-hl-bg: #f0fdfa;
    --cert-hl-line: #5eead4;
    --cert-gold: #b8892b;
    --cert-gold-light: #e9c46a;
    --cert-paper: #ffffff;
    --cert-paper-1: #ffffff;
    --cert-paper-2: #fffaf0;
    --cert-paper-3: #fbf0dc;
    --cert-ink: #334155;
    --cert-ink-soft: #64748b;
    --cert-math: #7e22ce;
    --cert-seal-1: #f7dd8c;
    --cert-seal-2: #d4a63c;
    --cert-seal-3: #a87a22;
    position: relative;
    width: 1123px;
    height: 794px;
    overflow: hidden;
    direction: rtl;
    font-family: 'Tajawal', sans-serif;
    color: var(--cert-ink);
    background: radial-gradient(ellipse at center, var(--cert-paper-1) 0%, var(--cert-paper-2) 70%, var(--cert-paper-3) 100%);
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    line-height: 1.2;
    text-align: center;
}
.cert-page * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.cert-frame { position: absolute; inset: 0; width: 100%; height: 100%; }
.cert-math, .cert-stars { position: absolute; inset: 0; pointer-events: none; }
.cert-math span { position: absolute; font-weight: 900; color: var(--cert-math); opacity: .08; line-height: 1; }
.cert-stars span { position: absolute; transform: translate(-50%, -50%); font-weight: 700; line-height: 1; }
.cert-page > p, .cert-page > h2, .cert-logo, .cert-seal {
    position: absolute; margin: 0; transform: translate(-50%, -50%); white-space: nowrap;
}
.cert-logo {
    width: 242px; padding: 7px 10px; line-height: 0; /* the see-through logo straight on the paper */
}
.cert-logo img { width: 222px; height: auto; display: block; }
.cert-title { font-size: 76px; font-weight: 900; color: var(--cert-deep); letter-spacing: 0; line-height: 1; }
.cert-rank { font-size: 30px; font-weight: 800; color: var(--cert-accent-deep); display: flex; align-items: center; gap: 8px; }
.cert-medal { font-size: 38px; line-height: 1; }
.cert-name { font-weight: 900; color: var(--cert-deep); line-height: 1.1; }
.cert-class { font-size: 22px; font-weight: 700; color: var(--cert-ink-soft); }
.cert-text {
    position: absolute; right: 50%; display: flex; align-items: center; justify-content: center;
    font-weight: 500; line-height: 1.75; color: var(--cert-ink);
}
.cert-text p { margin: 0; white-space: normal; text-wrap: balance; }
.cert-time {
    font-size: 21px; font-weight: 800; color: var(--cert-highlight);
    background: var(--cert-hl-bg); border: 1.5px solid var(--cert-hl-line); border-radius: 999px; padding: 6px 17px;
}
.cert-date { font-size: 19px; font-weight: 700; color: var(--cert-ink); transform: translate(0, -50%) !important; right: calc(1123px - 1000px); left: auto !important; }
.cert-date b { color: var(--cert-primary); font-weight: 800; }
.cert-seal {
    width: 88px; height: 88px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at 36% 34%, var(--cert-seal-1) 0%, var(--cert-seal-2) 60%, var(--cert-seal-3) 100%);
    box-shadow: 0 0 0 4px rgba(184, 137, 43, .18);
}
.cert-seal::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; border: 1.5px dashed rgba(255, 255, 255, .85); }
.cert-seal span { color: #fff; font-size: 36px; font-weight: 900; line-height: 1; }
.cert-sign-label { font-size: 17px; font-weight: 700; color: var(--cert-ink-soft); }
.cert-sign-name { font-family: 'Aref Ruqaa', serif; font-weight: 700; font-size: 38px; color: var(--cert-deep); line-height: 1.3; }
/* «🖨️ كلاسيكي للطباعة»: white paper and outlines only, so the printer spends little ink */
.cert-page--flat { background: #fff; }
.cert-page--flat .cert-seal { background: #fff; border: 2.5px solid var(--cert-deep); box-shadow: none; }
.cert-page--flat .cert-seal::after { border-color: var(--cert-gold); }
.cert-page--flat .cert-seal span { color: var(--cert-deep); }

/* ---- the four designed certificates (cert-designs.js): an ornament SVG + positioned text pieces.
   Every size, colour and position comes inline from the same numbers the PNG uses. ---- */
.cert-page--design { background: var(--cert-paper-2); }
.cert-page .cert-decor { position: absolute; inset: 0; width: 100%; height: 100%; }
.cert-page .cd-line { display: flex; align-items: center; gap: .28em; }
/* the site sets a font on every element (app.css `*`); the line's own font (Aref Ruqaa for titles) must reach its text */
.cert-page .cd-line > .cd-txt { font-family: inherit; }
.cert-page .cd-emoji { font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; font-weight: 400; line-height: 1; }
/* gradient text (the watercolour name, the gold-foil title); the padding keeps calligraphic swashes inside the paint */
.cert-page .cd-grad {
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;
    padding: .14em .22em; margin: -.14em -.22em;
}
.cert-page .cd-para { position: absolute; display: flex; align-items: center; justify-content: center; font-weight: 500; }
.cert-page .cd-para p { margin: 0; white-space: normal; text-wrap: balance; }
.cert-page .cd-pills { display: flex; gap: .6em; }
.cert-page .cd-pill {
    display: inline-flex; align-items: center; gap: .4em; padding: .3em .85em; border: 1.5px solid; border-radius: 999px;
    font-weight: 800; line-height: 1.3;
}
.cert-page > p.cd-label { transform: translate(0, -50%); left: auto; font-weight: 700; }
.cert-page .cd-label b { font-weight: 800; }
.cert-page .cd-logo img { height: auto; }

/* ---- theme chips: a tiny certificate in the theme's colours ---- */
.cert-theme-chips.choice-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 8.5rem), 1fr)); gap: 8px; }
.cert-theme-chips .cc-chip { flex-wrap: wrap; justify-content: center; gap: 4px 8px; padding: 8px; text-align: center; border-radius: var(--r-card); } /* a tile, never a pill (tall chips turned into ovals) */
.cert-theme-chips .cc-text { flex-basis: 100%; align-items: center; }
.cert-theme-chips .cc-icon { font-size: 20px; }
.cert-swatch {
    position: relative; flex: 0 0 auto; width: 46px; height: 33px; border-radius: 4px; overflow: hidden;
    background: radial-gradient(ellipse at center, var(--cert-paper-1), var(--cert-paper-2) 70%, var(--cert-paper-3));
    border: 3px solid var(--cert-primary); box-shadow: inset 0 0 0 1.5px var(--cert-gold), 0 1px 3px rgb(15 23 42 / .25);
}
.cert-swatch::before { /* the title */
    content: ""; position: absolute; top: 6px; left: 50%; width: 20px; height: 4px; margin-left: -10px; border-radius: 2px; background: var(--cert-deep);
}
.cert-swatch::after { /* the text lines and the seal */
    content: ""; position: absolute; top: 14px; left: 50%; width: 26px; height: 2px; margin-left: -13px; background: var(--cert-ink-soft);
    box-shadow: 0 4px 0 var(--cert-ink-soft), 0 9px 0 -0.5px var(--cert-seal-2);
}
.cert-swatch--flat { background: #fff; }
.cert-swatch--flat::after { box-shadow: 0 4px 0 var(--cert-ink-soft), 0 9px 0 -0.5px var(--cert-deep); }
/* live: the chip holds a real copy of the certificate, scaled down (certificates.js chipPreviews) */
.cert-swatch--live { width: 128px; height: 91px; border: 0; border-radius: 6px; background: #fff; }
.cert-swatch--live::before, .cert-swatch--live::after { content: none; }
.cert-mini { position: absolute; inset: 0; }
.cert-mini > .cert-page { position: absolute; top: 0; right: 0; transform-origin: top right; transform: scale(.114); pointer-events: none; }
.cert-theme-chips:has(.cert-swatch--live).choice-chips { grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr)); }
/* a phone: two per row, never one long column (the award window and «طباعة الشهادات» both) */
@media (max-width: 479.98px) {
    .cert-theme-chips.choice-chips, .cert-theme-chips:has(.cert-swatch--live).choice-chips { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cert-theme-chips .cc-chip { padding: 6px 4px; min-width: 0; }
    .cert-theme-chips .cert-swatch--live { width: 100%; max-width: 128px; height: auto; aspect-ratio: 1123 / 794; }
}
.cert-theme-hint { margin-top: 6px; }
.cert-thumb-item { display: flex; flex-direction: column; gap: 8px; }

/* ---- previews ---- */
.cert-thumbs { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.cert-thumb {
    position: relative; width: 100%; aspect-ratio: 1123 / 794; overflow: hidden; border-radius: 10px;
    box-shadow: var(--pop-shadow, 0 6px 18px -8px rgba(0, 0, 0, .35)), 0 0 0 1px var(--border);
    background: var(--w-paper-warm); /* the paper itself */
}
.cert-thumb > .cert-page { position: absolute; top: 0; right: 0; transform-origin: top right; transform: scale(var(--s, .2)); }
.cert-thumb--big { max-width: 760px; margin-inline: auto; }

/* ---- «قائمة الأوائل» (prints portrait, always on white paper) ---- */
.winners-sheet { direction: rtl; font-family: 'Tajawal', sans-serif; color: var(--w-text); background: var(--w-paper); }
.winners-head { text-align: center; border-bottom: 3px double var(--w-ink); padding-bottom: 10px; margin-bottom: 14px; }
.winners-head img { width: 200px; height: auto; display: block; margin: 0 auto 8px; }
.winners-head h2 { font-size: 34px; font-weight: 900; color: var(--w-ink); margin: 0; }
.winners-head p { margin: 4px 0 0; font-weight: 700; color: var(--w-muted); }
.winners-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.winners-table th, .winners-table td { border: 1px solid var(--w-line); padding: 7px 9px; text-align: right; vertical-align: middle; }
.winners-table thead th { background: var(--w-tint); color: var(--w-ink); font-weight: 900; }
.winners-table tbody th { background: var(--w-row); font-weight: 800; width: 34%; }
.winners-name { font-weight: 800; }
.winners-rank { white-space: nowrap; }
.winners-empty { color: var(--w-faint); font-weight: 700; }
.winners-foot { margin-top: 28px; width: 240px; text-align: center; margin-inline-start: auto; margin-inline-end: 0; float: left; }
.winners-foot p { margin: 0; font-weight: 700; color: var(--w-foot); }
.winners-foot span { display: block; border-top: 1.6px solid var(--w-gold); margin: 30px 0 4px; }
.winners-foot .cert-sign-name { font-size: 30px; color: var(--w-ink); }

/* ---- the student's «شهاداتي» list ---- */
.my-cert {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px; border-radius: var(--r-card, 16px);
    background: var(--reward-tint); border: 1px solid color-mix(in srgb, var(--reward) 45%, transparent);
}
.my-cert-medal { font-size: 34px; line-height: 1; }
.my-cert-info { flex: 1 1 10rem; min-width: 0; }
.my-cert-actions { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
.my-cert-actions .ap-btn { flex: 1 1 8rem; }
.cert-chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 10px; border-radius: var(--r-pill, 999px);
    background: var(--reward-tint); border: 1px solid color-mix(in srgb, var(--reward) 45%, transparent); color: var(--on-reward);
    font-size: 14px; font-weight: 700; white-space: nowrap;
}
.cert-chip button {
    min-height: 32px; min-width: 44px; padding: 0 10px; border-radius: var(--r-pill, 999px);
    background: var(--error-tint); color: var(--error); font-weight: 700; font-size: 14px;
}
.cert-print-btns { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); }
.cert-btn-off:disabled { opacity: .5; cursor: not-allowed; }
.cert-new-card { background-image: radial-gradient(circle at 50% 0%, var(--tint), transparent 60%); }

/* ---- «تقرير للمديرة» PDF: the same look as the Excel file (portrait A4, white paper) ---- */
.rpx { --rp: #5B2A86; --rpx-ink: #2E1A47; --rpx-muted: #6B6B7B; --rpx-line: #D9CDE6; --rpx-soft: #F1E9F8; --rpx-zebra: #FAF7FD;
    --rpx-good: #1E7B4F; --rpx-good-bg: #E7F5EE; --rpx-bad: #B42318; --rpx-bad-bg: #FDECEC; --rpx-gold: #9A6B00; --rpx-gold-bg: #FFF6DB;
    color: var(--rpx-ink); font-size: 14px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.rpx-head { text-align: center; margin: 0 0 10px; }
.rpx-head img { width: 180px; height: auto; display: block; margin: 0 auto 8px; }
.rpx-band { margin: 0; padding: 7px 16px; border-radius: 12px; background: var(--rp); color: #fff; font-size: 23px; font-weight: 900; }
.rpx-period { margin: 4px 0 0; color: var(--rpx-muted); font-weight: 700; }
.rpx-info { display: grid; grid-template-columns: 1fr 1fr; margin: 0 0 6px; border: 1px solid var(--rpx-line); border-radius: 12px; overflow: hidden; }
.rpx-info div { display: grid; grid-template-columns: 8.5em 1fr; border-bottom: 1px solid var(--rpx-line); }
.rpx-info div:nth-child(odd):not(.rpx-wide) { border-inline-end: 1px solid var(--rpx-line); }
.rpx-info .rpx-wide { grid-column: 1 / -1; border-bottom: 0; }
.rpx-info dt { padding: 5px 10px; background: var(--rpx-soft); font-weight: 900; }
.rpx-info dd { margin: 0; padding: 5px 10px; font-weight: 700; }
.rpx-h { display: flex; align-items: baseline; gap: 10px; margin: 12px 0 6px; padding-bottom: 3px; border-bottom: 2px solid var(--rp); color: var(--rp); font-size: 17px; font-weight: 900; break-after: avoid-page; }
.rpx-h small { color: var(--rpx-muted); font-size: 13px; font-weight: 700; }
.rpx-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.rpx-tile { border: 1px solid var(--rpx-line); border-radius: 12px; overflow: hidden; text-align: center; }
.rpx-tile b { display: block; padding: 6px 4px 3px; font-size: 26px; font-weight: 900; color: var(--rp); line-height: 1.1; }
.rpx-tile span { display: block; padding: 3px 4px; background: var(--rpx-soft); color: var(--rpx-muted); font-size: 12.5px; font-weight: 700; }
.rpx-flag { margin: 8px 0 0; padding: 5px 12px; border-radius: 10px; text-align: center; font-weight: 900; }
.rpx-flag.is-low { background: var(--rpx-bad-bg); color: var(--rpx-bad); }
.rpx-flag.is-good { background: var(--rpx-good-bg); color: var(--rpx-good); }
.rpx-tbl { width: 100%; border-collapse: separate; border-spacing: 0; border: 1px solid var(--rpx-line); border-radius: 12px; overflow: hidden; font-size: 13.5px; }
.rpx-tbl th { background: var(--rp); color: #fff; font-weight: 900; padding: 5px 10px; text-align: center; }
.rpx-tbl td { padding: 4px 10px; border-top: 1px solid var(--rpx-line); text-align: center; white-space: nowrap; }
.rpx-tbl tbody tr:nth-child(even) td { background: var(--rpx-zebra); }
.rpx-tbl tr { break-inside: avoid; }
.rpx-tbl .rpx-name { text-align: right; font-weight: 700; white-space: normal; }
.rpx-tbl .rpx-n { width: 2.5em; color: var(--rpx-muted); }
.rpx-tbl .rpx-why { text-align: right; color: var(--rpx-bad); white-space: normal; }
.rpx-pct { display: inline-flex; align-items: center; gap: 8px; justify-content: center; }
.rpx-pct b { min-width: 2.8em; font-weight: 700; }
.rpx-pct i { display: block; width: 64px; height: 7px; border-radius: 99px; background: var(--rpx-soft); overflow: hidden; }
.rpx-pct s { display: block; height: 100%; border-radius: 99px; background: var(--rp); }
.rpx-pct.is-good b { color: var(--rpx-good); }
.rpx-pct.is-good s { background: var(--rpx-good); }
.rpx-pct.is-low b { color: var(--rpx-bad); }
.rpx-pct.is-low s { background: var(--rpx-bad); }
.rpx-top { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.rpx-top li { display: grid; justify-items: center; gap: 1px; padding: 6px; border-radius: 12px; border: 1px solid #F0D98A; background: var(--rpx-gold-bg); text-align: center; }
.rpx-top .rpx-medal { font-size: 22px; line-height: 1; }
.rpx-top small { color: var(--rpx-gold); font-weight: 900; }
.rpx-top b { font-size: 15px; }
.rpx-top em { font-style: normal; color: var(--rpx-muted); font-size: 12.5px; font-weight: 700; }
.rpx-sign { display: flex; justify-content: space-between; gap: 24px; margin-top: 18px; break-inside: avoid; }
.rpx-sign div { display: flex; align-items: flex-end; gap: 10px; }
.rpx-sign span { font-weight: 900; }
.rpx-sign b { color: var(--rp); font-size: 17px; }
.rpx-sign i { display: block; width: 170px; border-bottom: 1.5px solid var(--rpx-ink); height: 22px; }
.report-sheet .rps-break { break-before: page; page-break-before: always; height: 0; }
.report-sheet::after { content: ""; display: block; clear: both; }

/* «ملف الإنجاز والشواهد» (teacher-portfolio.js): a cover, then one A4 page per section */
.pfx-cover { text-align: center; padding-top: 8px; }
.pfx-logo { width: 210px; height: auto; display: block; margin: 0 auto 4px; }
.pfx-school { margin: 0; color: var(--rpx-muted); font-weight: 900; font-size: 15px; }
.pfx-emblem { width: 92px; height: 92px; margin: 22px auto 14px; border-radius: 26px; display: grid; place-items: center; background: var(--rpx-soft); border: 2px solid var(--rpx-line); color: var(--rp); font-size: 54px; }
.pfx-title { font-size: 30px; padding: 10px 16px; }
.pfx-who { display: grid; gap: 2px; margin: 14px 0 2px; }
.pfx-who b { font-size: 22px; color: var(--rp); }
.pfx-who span { font-weight: 700; color: var(--rpx-muted); }
.pfx-cover .rpx-tiles { margin-top: 18px; }
.pfx-cover .rpx-tile b { font-size: 24px; padding: 10px 4px 6px; }
.pfx-cover .rpx-h { margin-top: 22px; text-align: right; }
.pfx-toc { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; text-align: right; }
.pfx-toc li { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--rpx-line); border-radius: 12px; }
.pfx-toc em, .pfx-sec em { font-style: normal; display: inline-grid; place-items: center; width: 1.7em; height: 1.7em; border-radius: 50%; background: var(--rp); color: #fff; font-weight: 900; flex: none; }
.pfx-toc i { color: var(--rp); font-size: 19px; }
.pfx-toc b { font-weight: 900; }
.pfx-toc small { margin-inline-start: auto; white-space: nowrap; color: var(--rpx-muted); font-weight: 700; font-size: 12px; }
.pfx-date { margin: 22px 0 0; color: var(--rpx-muted); font-weight: 700; }
.pfx-top { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 6px; margin-bottom: 14px; border-bottom: 1px solid var(--rpx-line); color: var(--rpx-muted); font-size: 12.5px; font-weight: 700; }
.pfx-sec { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; padding-bottom: 6px; border-bottom: 3px solid var(--rp); color: var(--rp); font-size: 24px; font-weight: 900; }
.pfx-sec i { font-size: 26px; }
.pfx-desc { margin: 0 0 12px; line-height: 1.7; font-weight: 700; color: var(--rpx-ink); }
.rpx-tiles.pfx-tiles-3 { grid-template-columns: repeat(3, 1fr); }
.pfx-tbl .pfx-d { width: 7.5em; color: var(--rpx-muted); font-weight: 700; }
.pfx-tbl .rpx-name { font-weight: 600; }
.pfx-tbl .pfx-blank td { height: 30px; }
.pfx-more { margin: 6px 0 0; color: var(--rpx-muted); font-size: 12.5px; font-weight: 700; }
.pfx-sign { margin-top: 28px; }
.rpx-tiles.pfx-tiles-1 { grid-template-columns: minmax(0, 220px); }
.pfx-own { display: inline-block; margin-inline-start: 8px; padding: 0 8px; border-radius: 99px; background: var(--rpx-soft); color: var(--rp); font-size: 11px; font-weight: 700; vertical-align: 1px; }
