/* ==========================================================================
   Aurora R34 · قوالب واجهة الزوار للموقع العام
   damascene (الأصلي، لا يتغيّر) · cosmos المرصد الكوني · lab مختبر العلوم · holo المستقبل الهولوغرافي · chalk السبورة
   كل قالب يعيد تعريف رموز public-site.css ويضيف شخصيته فوقها؛ الحركة في public-site-scifi.js.
   ========================================================================== */
@font-face { font-family: "Jasmine Chalk"; src: url("../fonts/snapshot-native/Amiri.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Jasmine Chalk"; src: url("../fonts/snapshot-native/Amiri-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

/* ---------- طبقة المشهد المشتركة ---------- */
.ps-scene, .ps-hud { display: none; }
html:not([data-template="damascene"]) .ps-scene { display: block; position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
html:not([data-template="damascene"]) :is(.ps-particles, .ps-trail, .ps-glow, .ps-magic-btn) { display: none !important; }
html:not([data-template="damascene"]) .ps-hero-title { text-shadow: none; }
html:not([data-template="damascene"]) .ps-hero-title em { background-size: 220% 100%; animation: tpl-shimmer 6s linear infinite; }
@keyframes tpl-shimmer { to { background-position: -220% 0; } }

/* أثر المؤشر السحري (لوحة رسم ثابتة فوق الصفحة، لا تلتقط النقرات) */
.ps-magic-layer { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 60; pointer-events: none; }

/* إطار HUD */
html:is([data-template="cosmos"], [data-template="holo"], [data-template="lab"]) .ps-hud { display: block; position: absolute; inset: 104px 18px 18px; z-index: 0; pointer-events: none; }
.ps-hud-c { position: absolute; width: 26px; height: 26px; border: 0 solid var(--tpl-hud, rgba(255, 255, 255, .5)); }
.ps-hud-tl { top: 0; left: 0; border-top-width: 2px; border-left-width: 2px; }
.ps-hud-tr { top: 0; right: 0; border-top-width: 2px; border-right-width: 2px; }
.ps-hud-bl { bottom: 0; left: 0; border-bottom-width: 2px; border-left-width: 2px; }
.ps-hud-br { bottom: 0; right: 0; border-bottom-width: 2px; border-right-width: 2px; }
.ps-hud-read { position: absolute; bottom: 8px; left: 36px; color: var(--tpl-hud, rgba(255, 255, 255, .6)); font: 600 .72rem/1 var(--font); letter-spacing: .04em; direction: ltr; white-space: nowrap; opacity: .85; }
.ps-hud-scan { position: absolute; inset-inline: 0; top: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--tpl-hud, #fff), transparent); opacity: 0; }
html[data-template="holo"] .ps-hud-scan { opacity: .5; animation: tpl-scan 5.5s linear infinite; }
@keyframes tpl-scan { to { transform: translateY(calc(100svh - 160px)); } }

/* ============ المرصد الكوني ============ */
html[data-template="cosmos"] {
    --navy-950: #03040d; --navy: #070a1f; --navy-2: #10153a; --navy-3: #1b2160;
    --teal: #6ee7f9; --teal-2: #a78bfa; --mint: #141a40; --gold: #ffcf6e; --gold-2: #ffe7a8; --terra: #f472b6;
    --bg: #05071a; --bg-alt: #0a0d2a; --paper: #0e1233; --ink: #e9ecff; --muted: #a2a9d6; --line: #232a63;
    --shadow: 0 14px 40px rgba(0, 0, 0, .5); --shadow-lg: 0 34px 90px rgba(0, 0, 0, .65); --tpl-hud: rgba(167, 139, 250, .65);
    color-scheme: dark;
}
html[data-template="cosmos"] body { background: radial-gradient(1200px 700px at 85% -10%, #1a1557 0%, transparent 60%), #05071a; }
html[data-template="cosmos"] .ps-hero-bg { background: radial-gradient(70% 60% at 78% 20%, #2a1d6e 0%, transparent 62%), radial-gradient(60% 55% at 15% 85%, #0c3f63 0%, transparent 64%), linear-gradient(180deg, #03040d, #070a24 70%, #05071a); }
html[data-template="cosmos"] .ps-hero-title em { background-image: linear-gradient(100deg, #6ee7f9, #a78bfa 35%, #ffcf6e 65%, #6ee7f9); }
html[data-template="cosmos"] :is(.ps-arch, .ps-arch-line) { border-radius: 50%; aspect-ratio: 1; inset: auto 0 0; }
html[data-template="cosmos"] .ps-arch { box-shadow: 0 0 0 8px rgba(167, 139, 250, .14), 0 0 90px rgba(110, 231, 249, .35), 0 40px 100px rgba(0, 0, 0, .6); }
html[data-template="cosmos"] .ps-arch-line { border-color: rgba(110, 231, 249, .55); border-style: dashed; transform: scale(1.08); animation: tpl-spin 60s linear infinite; }
html[data-template="cosmos"] .ps-arch-wrap { aspect-ratio: 1; }
html[data-template="cosmos"] .ps-coin { box-shadow: 0 0 0 6px rgba(110, 231, 249, .35), 0 0 50px rgba(110, 231, 249, .5); }
html[data-template="cosmos"] .ps-sec-alt { background-color: var(--bg-alt); background-image: radial-gradient(1px 1px at 20% 30%, rgba(255, 255, 255, .5), transparent), radial-gradient(1px 1px at 70% 80%, rgba(255, 255, 255, .4), transparent), radial-gradient(1.5px 1.5px at 40% 60%, rgba(167, 139, 250, .6), transparent); background-size: 220px 220px, 300px 300px, 260px 260px; }
html[data-template="cosmos"] .ps-header.is-stuck .ps-nav { background: rgba(7, 10, 31, .82); color: var(--ink); border-color: var(--line); }
@keyframes tpl-spin { to { rotate: 360deg; } }

/* ============ مختبر العلوم ============ */
html[data-template="lab"] {
    --navy-950: #061a2c; --navy: #0a2540; --navy-2: #0f3355; --navy-3: #164670;
    --teal: #0aa5a0; --teal-2: #22d3c5; --mint: #e3f6f5; --gold: #f59e0b; --gold-2: #fcd34d; --terra: #ef4444;
    --bg: #f5f9fc; --bg-alt: #eaf2f7; --paper: #ffffff; --ink: #0b2233; --muted: #557086; --line: #d6e4ee; --tpl-hud: rgba(125, 211, 252, .7);
}
html[data-template="lab"][data-theme="dark"] { --bg: #061a2c; --bg-alt: #0a2540; --paper: #0d2c4a; --ink: #e2f1fb; --muted: #9bb8cf; --line: #1b4366; --mint: #0d3b45; color-scheme: dark; }
html[data-template="lab"] .ps-hero-bg {
    background:
        linear-gradient(rgba(125, 211, 252, .09) 1px, transparent 1px) 0 0 / 28px 28px,
        linear-gradient(90deg, rgba(125, 211, 252, .09) 1px, transparent 1px) 0 0 / 28px 28px,
        linear-gradient(rgba(125, 211, 252, .16) 1px, transparent 1px) 0 0 / 140px 140px,
        linear-gradient(90deg, rgba(125, 211, 252, .16) 1px, transparent 1px) 0 0 / 140px 140px,
        radial-gradient(70% 70% at 75% 25%, #12507e, transparent 70%), #08233d;
}
html[data-template="lab"] .ps-hero-title em { background-image: linear-gradient(100deg, #22d3c5, #7dd3fc 40%, #fcd34d 70%, #22d3c5); }
html[data-template="lab"] :is(.ps-arch, .ps-arch-line) { border-radius: 36px; }
html[data-template="lab"] .ps-arch-line { border-color: #7dd3fc; border-style: dashed; }
html[data-template="lab"] .ps-arch { box-shadow: 0 0 0 1px rgba(125, 211, 252, .5), 0 0 0 10px rgba(125, 211, 252, .08), 0 40px 90px rgba(0, 0, 0, .45); }
html[data-template="lab"] .ps-sec-alt { background-image: linear-gradient(rgba(10, 165, 160, .06) 1px, transparent 1px), linear-gradient(90deg, rgba(10, 165, 160, .06) 1px, transparent 1px); background-size: 24px 24px; }
html[data-template="lab"] .ps-header.is-stuck .ps-nav { background: rgba(245, 249, 252, .9); }
html[data-template="lab"][data-theme="dark"] .ps-header.is-stuck .ps-nav { background: rgba(6, 26, 44, .88); }

/* ============ المستقبل الهولوغرافي ============ */
html[data-template="holo"] {
    --navy-950: #010409; --navy: #020a12; --navy-2: #06141f; --navy-3: #0a2232;
    --teal: #00f0ff; --teal-2: #5dfdcb; --mint: #062027; --gold: #ff3df2; --gold-2: #ff9bf8; --terra: #ffb800;
    --bg: #02060c; --bg-alt: #041019; --paper: #061620; --ink: #dffcff; --muted: #7fb4c0; --line: rgba(0, 240, 255, .2);
    --shadow: 0 0 0 1px rgba(0, 240, 255, .12), 0 18px 40px rgba(0, 0, 0, .6); --tpl-hud: rgba(0, 240, 255, .75);
    color-scheme: dark;
}
html[data-template="holo"] body { background: #02060c; }
html[data-template="holo"] body::after { content: ""; position: fixed; inset: 0; z-index: 59; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(0, 240, 255, .035) 0 1px, transparent 1px 3px); }
html[data-template="holo"] .ps-hero-bg { background: radial-gradient(60% 40% at 50% 100%, rgba(255, 61, 242, .28), transparent 70%), linear-gradient(180deg, #010409 0%, #04101c 60%, #0b0420 100%); }
html[data-template="holo"] .ps-hero-title em { background-image: linear-gradient(100deg, #00f0ff, #5dfdcb 30%, #ff3df2 60%, #00f0ff); filter: drop-shadow(0 0 18px rgba(0, 240, 255, .45)); }
html[data-template="holo"] .ps-hero-title { animation: tpl-glitch 7s steps(1) infinite; }
@keyframes tpl-glitch { 0%, 96%, 100% { transform: none; filter: none; } 97% { transform: translateX(3px); filter: drop-shadow(-3px 0 #ff3df2) drop-shadow(3px 0 #00f0ff); } 98% { transform: translateX(-2px) skewX(-4deg); } 99% { transform: none; filter: drop-shadow(2px 0 #00f0ff); } }
html[data-template="holo"] :is(.ps-arch, .ps-arch-line) { border-radius: 0; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); aspect-ratio: 1.15; inset: auto 0 0; }
html[data-template="holo"] .ps-arch-wrap { aspect-ratio: 1.15; }
html[data-template="holo"] .ps-arch-line { background: linear-gradient(135deg, #00f0ff, #ff3df2); border: 0; transform: scale(1.04); opacity: .9; }
html[data-template="holo"] .ps-arch { box-shadow: none; }
html[data-template="holo"] .ps-arch img { filter: saturate(1.2) hue-rotate(-10deg); }
html[data-template="holo"] :is(.ps-btn-gold) { background: transparent; color: #00f0ff; border-color: #00f0ff; box-shadow: 0 0 18px rgba(0, 240, 255, .45), inset 0 0 14px rgba(0, 240, 255, .25); }
html[data-template="holo"] .ps-btn-gold:hover { background: #00f0ff; color: #02060c; box-shadow: 0 0 34px rgba(0, 240, 255, .8); }
html[data-template="holo"] :is(.ps-portal, .ps-ribbon-item) { border-color: rgba(0, 240, 255, .25) !important; box-shadow: inset 0 0 30px rgba(0, 240, 255, .05); }
html[data-template="holo"] .ps-header.is-stuck .ps-nav { background: rgba(2, 10, 18, .85); color: var(--ink); border-color: rgba(0, 240, 255, .3); box-shadow: 0 0 24px rgba(0, 240, 255, .15); }
html[data-template="holo"] .ps-coin { box-shadow: 0 0 0 3px #00f0ff, 0 0 40px rgba(0, 240, 255, .7); }

/* ============ السبورة والطباشير ============ */
html[data-template="chalk"] {
    --navy-950: #14261d; --navy: #1b3427; --navy-2: #22412f; --navy-3: #2c5340;
    --teal: #1f7a5c; --teal-2: #3aa17e; --mint: #e7f3ec; --gold: #e0b232; --gold-2: #f6d36b; --terra: #d9534f;
    --bg: #fbfaf4; --bg-alt: #f3f0e3; --paper: #fffef9; --ink: #1d2a3f; --muted: #5d6879; --line: #e3dfcd;
}
html[data-template="chalk"][data-theme="dark"] { --bg: #16281f; --bg-alt: #1b3126; --paper: #203a2d; --ink: #f2efe2; --muted: #b9c4b9; --line: #335443; --mint: #24402f; color-scheme: dark; }
html[data-template="chalk"] .ps-hero-bg {
    background:
        radial-gradient(140% 90% at 50% 50%, transparent 55%, rgba(0, 0, 0, .45) 100%),
        radial-gradient(2px 2px at 20% 30%, rgba(255, 255, 255, .06), transparent), radial-gradient(2px 2px at 80% 60%, rgba(255, 255, 255, .05), transparent),
        linear-gradient(170deg, #2a4a39 0%, #1d3a2b 50%, #17301f 100%);
}
html[data-template="chalk"] .ps-hero { border-bottom: 18px solid #6b4a2b; box-shadow: inset 0 -4px 0 #8a6340; }
html[data-template="chalk"] .ps-hero-title { font-family: "Jasmine Chalk", var(--font); font-weight: 700; color: #f4f1e6; }
html[data-template="chalk"] .ps-hero-title em { background-image: linear-gradient(100deg, #f6d36b, #ffe9a8 50%, #f6d36b); }
html[data-template="chalk"] :is(.ps-arch, .ps-arch-line) { border-radius: 6px; }
html[data-template="chalk"] .ps-arch-wrap { rotate: -3deg; }
html[data-template="chalk"] .ps-arch { box-shadow: 0 0 0 12px #fffef9, 0 0 0 13px #e3dfcd, 0 30px 60px rgba(0, 0, 0, .45); }
html[data-template="chalk"] .ps-arch-line { border: 0; background: rgba(246, 211, 107, .85); inset: -18px 38% auto; height: 34px; transform: rotate(2deg); border-radius: 2px; opacity: .9; z-index: 2; }
html[data-template="chalk"] .ps-sec:not(.ps-sec-navy) { background-image: linear-gradient(transparent 31px, rgba(80, 120, 200, .12) 32px); background-size: 100% 32px; }
html[data-template="chalk"] .ps-head h2 { font-family: "Jasmine Chalk", var(--font); }
html[data-template="chalk"] .ps-header.is-stuck .ps-nav { background: rgba(251, 250, 244, .92); }
html[data-template="chalk"][data-theme="dark"] .ps-header.is-stuck .ps-nav { background: rgba(22, 40, 31, .9); }

/* ---------- معرض القوالب ---------- */
.ps-tpl { position: fixed; inset-block-end: 20px; inset-inline-start: 20px; z-index: 70; font-family: var(--font); }
.ps-tpl-fab {
    display: inline-flex; align-items: center; gap: 8px; height: 50px; padding-inline: 14px 18px; border: 0; border-radius: 999px; cursor: pointer;
    color: #fff; font: 800 .92rem var(--font); background: linear-gradient(135deg, var(--navy-2), var(--navy-3));
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .18) inset, 0 14px 30px rgba(0, 0, 0, .35); transition: transform .3s cubic-bezier(.34, 1.56, .64, 1);
}
.ps-tpl-fab:hover { transform: translateY(-3px) scale(1.03); }
.ps-tpl-fab svg { width: 26px; height: 26px; fill: none; stroke: var(--gold-2); stroke-width: 1.3; animation: tpl-spin 14s linear infinite; }
.ps-tpl-fab svg circle { fill: var(--gold-2); stroke: none; }
.ps-tpl-panel {
    position: absolute; inset-block-end: 62px; inset-inline-start: 0; width: min(380px, calc(100vw - 32px)); padding: 14px;
    border-radius: 24px; background: rgba(10, 16, 34, .86); color: #fff; -webkit-backdrop-filter: blur(20px) saturate(1.4); backdrop-filter: blur(20px) saturate(1.4);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .12) inset, 0 30px 70px rgba(0, 0, 0, .55); transform-origin: bottom left;
    animation: tpl-pop .38s cubic-bezier(.16, 1, .3, 1) both;
}
[dir="rtl"] .ps-tpl-panel { transform-origin: bottom right; }
.ps-tpl-panel[hidden] { display: none; }
@keyframes tpl-pop { from { opacity: 0; transform: translateY(14px) scale(.92); } }
.ps-tpl-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 10px; }
.ps-tpl-head strong { font-size: 1.05rem; }
.ps-tpl-x { width: 32px; height: 32px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .1); color: #fff; font-size: 1.2rem; cursor: pointer; }
.ps-tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ps-tpl-card {
    position: relative; display: grid; gap: 2px; padding: 8px; border: 1px solid rgba(255, 255, 255, .1); border-radius: 16px; cursor: pointer;
    background: rgba(255, 255, 255, .04); color: #fff; text-align: start; font-family: var(--font); transition: transform .25s, border-color .25s, background .25s;
}
.ps-tpl-card:first-child { grid-column: 1 / -1; grid-template-columns: 96px 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 10px; }
.ps-tpl-card:first-child .ps-tpl-sw { grid-row: 1 / 3; height: 52px; margin: 0; }
.ps-tpl-card:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, .3); }
.ps-tpl-card[aria-checked="true"] { border-color: var(--gold-2); background: rgba(255, 207, 110, .1); box-shadow: 0 0 0 1px var(--gold-2) inset; }
.ps-tpl-card b { font-size: .86rem; }
.ps-tpl-card small { color: rgba(255, 255, 255, .62); font-size: .72rem; line-height: 1.4; }
.ps-tpl-sw { display: block; height: 64px; margin-bottom: 6px; border-radius: 11px; background-size: cover; }
.ps-sw-damascene { background: radial-gradient(circle at 70% 40%, #d9a441 0 10%, transparent 11%), linear-gradient(160deg, #0b1f33, #0c3a52); }
.ps-sw-cosmos { background: radial-gradient(circle at 30% 60%, #ffcf6e 0 7%, transparent 8%), radial-gradient(ellipse at 30% 60%, transparent 14%, rgba(110, 231, 249, .7) 15%, transparent 17%), radial-gradient(80% 80% at 80% 20%, #2a1d6e, transparent), #03040d; }
.ps-sw-lab { background: radial-gradient(circle at 35% 50%, #22d3c5 0 8%, transparent 9%), radial-gradient(circle at 62% 38%, #fcd34d 0 6%, transparent 7%), linear-gradient(rgba(125, 211, 252, .2) 1px, transparent 1px) 0 0 / 10px 10px, linear-gradient(90deg, rgba(125, 211, 252, .2) 1px, transparent 1px) 0 0 / 10px 10px, #08233d; }
.ps-sw-holo { background: linear-gradient(transparent 55%, rgba(0, 240, 255, .5) 56%, transparent 58%, transparent 72%, rgba(0, 240, 255, .4) 73%, transparent 75%), radial-gradient(50% 40% at 50% 60%, #ff3df2, transparent 70%), #02060c; }
.ps-sw-chalk { background: linear-gradient(100deg, transparent 20%, rgba(244, 241, 230, .7) 21% 23%, transparent 24% 60%, rgba(246, 211, 107, .7) 61% 62%, transparent 63%), linear-gradient(170deg, #2a4a39, #17301f); }
.ps-tpl-note { margin: 10px 4px 2px; color: rgba(255, 255, 255, .6); font-size: .74rem; line-height: 1.6; }

/* انتقال البوابة بين القوالب */
::view-transition-old(root) { animation: none; }
::view-transition-new(root) { animation: none; }

@media (max-width: 640px) {
    .ps-tpl { inset-block-end: 14px; inset-inline-start: 12px; }
    .ps-tpl-fab span { display: none; }
    .ps-tpl-fab { width: 50px; padding: 0; justify-content: center; }
    html:not([data-template="damascene"]) .ps-hud { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    html:not([data-template="damascene"]) .ps-hero-title, html:not([data-template="damascene"]) .ps-hero-title em, .ps-tpl-fab svg, .ps-hud-scan, html[data-template="cosmos"] .ps-arch-line { animation: none !important; }
}
@media print { .ps-scene, .ps-hud, .ps-tpl, .ps-magic-layer { display: none !important; } }
