/* SG3D — أنماطُ المحرّك المشترك وصفحةِ المعاينة (٩ أكتوبر ٢٠٢٦).
   ملفٌّ ثابت خارج الحزم (لا يمرّ على rtlcss): الاتجاهُ بخاصية dir في العناصر، والخصائصُ منطقية (inline-start/end).
   لا خاصيةَ اتجاهٍ هنا، ولا إزاحةَ أفقية للإظهار والإخفاء. */

.sg3d-host { position: relative; min-block-size: 320px; isolation: isolate; }
.sg3d { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; }
.sg3d-canvas { display: block; inline-size: 100%; block-size: 100%; touch-action: none; outline: none; }
/* طبقاتٌ مرتّبة: CSS2DRenderer يعطي كل وسمٍ z-index بحسب بعده، فتُحبس الوسومُ في طبقتها تحت البطاقات والأدوات */
.sg3d-labels { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.sg3d-cards { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.sg3d-ui { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.sg3d-host.sg3d-on [data-sg3d-fallback] { display: none !important; }

.sg3d-labels > * { left: 0; top: 0; }
.sg3d-label {
    font: 600 12px/1.25 "Lama Text", "LamaSans", system-ui, sans-serif; color: #10153A;
    background: rgba(255, 255, 255, .92); border: 1px solid #E1ECF4; border-radius: 6px;
    padding: 2px 6px; white-space: nowrap; pointer-events: none; box-shadow: 0 1px 2px rgba(16, 21, 58, .12);
    margin-block-end: 4px;
}
.sg3d-label bdi { unicode-bidi: isolate; }
.sg3d[data-theme="night"] .sg3d-label { background: rgba(16, 21, 58, .88); color: #fff; border-color: rgba(255, 255, 255, .15); }

.sg3d-card {
    position: absolute; pointer-events: auto; inline-size: min(300px, calc(100% - 16px)); box-sizing: border-box;
    background: #fff; color: #10153A; border: 1px solid #E1ECF4; border-radius: 12px;
    box-shadow: 0 8px 24px rgba(16, 21, 58, .18); padding: 12px 14px 12px;
    font: 400 14px/1.6 "Lama Text", "LamaSans", system-ui, sans-serif;
}
.sg3d-card-x {
    float: inline-end; border: 0; background: #F4F6FA; color: #10153A; border-radius: 6px;
    font: inherit; font-size: 12px; padding: 2px 8px; cursor: pointer; margin-inline-start: 8px;
}
.sg3d-card-sheet {
    inset-inline: 0 !important; inset-block-end: 0; inset-block-start: auto !important; inline-size: 100%;
    border-radius: 14px 14px 0 0; max-block-size: 55%; overflow: auto;
}

.sg3d-north {
    position: absolute; inset-block-start: 10px; inset-inline-end: 10px; inline-size: 40px; block-size: 40px;
    border-radius: 50%; border: 1px solid #E1ECF4; background: rgba(255, 255, 255, .94); pointer-events: auto;
    cursor: pointer; display: grid; place-items: center; padding: 0; color: #10153A;
    font: 700 11px/1 "Lama Text", system-ui, sans-serif;
}
.sg3d-north i {
    position: absolute; inset: 4px; border-radius: 50%; pointer-events: none;
    background: conic-gradient(from -12deg, #C9A96A 0 24deg, transparent 24deg 360deg);
    -webkit-mask: radial-gradient(circle, transparent 52%, #000 53%); mask: radial-gradient(circle, transparent 52%, #000 53%);
}
.sg3d-north span { position: relative; }

.sg3d-note {
    position: absolute; z-index: 4; inset-block-start: 10px; inset-inline-start: 10px; margin: 0; max-inline-size: calc(100% - 70px);
    background: #FFF8E8; color: #10153A; border: 1px dashed #10153A; border-radius: 8px; padding: 4px 10px;
    font: 600 13px/1.5 "Lama Text", system-ui, sans-serif; pointer-events: none;
}
.sg3d-why { font: 400 13px/1.6 "Lama Text", system-ui, sans-serif; color: #5B6478; margin: .5rem 0 0; }
.sg3d-lost {
    position: absolute; inset: 0; z-index: 5; display: grid; place-content: center; gap: 8px; text-align: center;
    background: rgba(244, 241, 234, .94); color: #10153A; font: 600 14px/1.6 "Lama Text", system-ui, sans-serif;
}
.sg3d-btn {
    border: 1px solid #10153A; background: #10153A; color: #fff; border-radius: 8px; padding: 6px 14px;
    font: 600 14px/1.4 "Lama Text", system-ui, sans-serif; cursor: pointer;
}
.sg3d-ask { position: absolute; inset-block-start: 50%; inset-inline-start: 50%; margin: -18px 0 0 -60px; z-index: 2; }
/* تنبيهٌ عابر وسط المشهد (العجلةُ مرّرت الصفحة)، وسببُ «حركة أقل» حين يكون إعدادَ الجهاز */
.sg3d-toast {
    position: absolute; z-index: 4; inset-block-start: 50%; inset-inline: 0; margin: -20px auto 0; inline-size: fit-content;
    max-inline-size: calc(100% - 32px); box-sizing: border-box; text-align: center; pointer-events: none;
    background: rgba(16, 21, 58, .9); color: #fff; border-radius: 12px; padding: 8px 16px;
    font: 600 14px/1.6 "Lama Text", "LamaSans", system-ui, sans-serif;
}
.sg3d-rm-why { font: 400 12.5px/1.5 "Lama Text", "LamaSans", system-ui, sans-serif; color: #5B6478; }

/* سعود واقفاً في الزاوية: صورةٌ ثابتة بارتفاع 30% من المسرح */
.sg3d-saud {
    position: absolute; inset-block-end: 0; block-size: 30%; aspect-ratio: .6;
    pointer-events: none; min-block-size: 110px;
}
.sg3d-saud-start { inset-inline-start: 8px; }
.sg3d-saud-pose { position: absolute; inset-block-end: 0; inset-inline-start: 0; block-size: 100%; inline-size: 100%; object-fit: contain; object-position: bottom; }
.sg3d-saud-say {
    position: absolute; inset-block-end: 92%; inset-inline-start: 30%; margin: 0; inline-size: max-content; max-inline-size: 240px;
    background: #fff; color: #10153A; border: 1px solid #E1ECF4; border-radius: 12px; padding: 6px 10px;
    font: 600 13px/1.5 "Lama Text", system-ui, sans-serif; box-shadow: 0 4px 14px rgba(16, 21, 58, .16);
}

/* ═══ صفحة المعاينة /sg3d/preview ═══ */
.sg3dp { max-inline-size: 1240px; margin: 0 auto; padding: 16px; color: #10153A; font: 400 15px/1.7 "Lama Text", "LamaSans", system-ui, sans-serif; }
.sg3dp h1 { font-size: 22px; margin: 0 0 4px; }
.sg3dp h2 { font-size: 18px; margin: 0 0 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sg3dp-top { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; justify-content: space-between; border-block-end: 1px solid #E1ECF4; padding-block-end: 10px; margin-block-end: 14px; }
.sg3dp-top a { color: #0DA4DB; text-decoration: none; font-weight: 600; }
.sg3dp-est {
    display: inline-block; font: 700 12px/1.4 "Lama Text", system-ui, sans-serif; color: #10153A; background: #FFF8E8;
    border: 1px dashed #10153A; border-radius: 999px; padding: 1px 10px; white-space: nowrap;
}
.sg3dp-sec { background: #fff; border: 1px solid #E1ECF4; border-radius: 14px; padding: 14px; margin-block-end: 16px; }
.sg3dp-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-block-end: 10px; }
.sg3dp-bar .sep { inline-size: 1px; block-size: 22px; background: #E1ECF4; margin-inline: 4px; }
.sg3dp-b {
    border: 1px solid #D5DEEA; background: #F7F9FC; color: #10153A; border-radius: 8px; padding: 4px 10px;
    font: 600 13px/1.5 "Lama Text", system-ui, sans-serif; cursor: pointer; text-decoration: none;
}
.sg3dp-b[aria-pressed="true"], .sg3dp-b.on { background: #10153A; color: #fff; border-color: #10153A; }
.sg3dp-stage { block-size: min(62vh, 560px); border-radius: 12px; overflow: hidden; background: #F4F1EA; }
.sg3dp-stage.grey { filter: grayscale(1); }
.sg3dp-stats { font: 500 12px/1.6 ui-monospace, "SF Mono", Menlo, monospace; color: #5B6478; margin-block-start: 6px; }
.sg3dp-fb { block-size: 180px; border-radius: 12px; background: #F4F6FA; border: 1px dashed #9AA6BD; padding: 12px; }
.sg3dp table { border-collapse: collapse; inline-size: 100%; font-size: 14px; }
.sg3dp th, .sg3dp td { text-align: start; padding: 6px 8px; border-block-end: 1px solid #E1ECF4; vertical-align: top; }
.sg3dp-muted { color: #5B6478; font-size: 13px; }
@media (max-width: 600px) {
    .sg3dp { padding: 12px; }
    .sg3dp-stage { block-size: 70vh; }
}
.sg3d-label.sg3d-label-site { font-size: 14px; font-weight: 700; background: #10153A; color: #fff; border-color: #10153A; }
