/* ==============================================================================
   منصة الأستاذ محمد الحلواني (القيصر)
   Imperial Emerald Castle Ambience & Security Engine v1.0
   1. Royal Castle Historic Green Cursor & Interactive Aura
   2. Tactile Touch Ripples for Mobile
   3. Sovereign Shield Anti-Inspection & Right-Click Blocker
   ============================================================================== */

/* ----------------------------------------------------------------------------
   1. ROYAL EMERALD & GOLD HISTORIC CASTLE CURSORS (SVG Data URIs)
   ---------------------------------------------------------------------------- */

/* Default Spearhead Castle Cursor: Ancient Green Blade, Gold Hilt, Sharp Tip */
:root {
  --castle-cursor-default: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='36' height='36' viewBox='0 0 36 36'><defs><linearGradient id='blade' x1='0%' y1='0%' x2='100%' y2='100%'><stop offset='0%' stop-color='%2334d399'/><stop offset='45%' stop-color='%2310b981'/><stop offset='85%' stop-color='%23059669'/><stop offset='100%' stop-color='%23022b1a'/></linearGradient><linearGradient id='gold' x1='0%' y1='0%' x2='100%' y2='100%'><stop offset='0%' stop-color='%23ffffff'/><stop offset='30%' stop-color='%23fff3b0'/><stop offset='60%' stop-color='%23ffd700'/><stop offset='100%' stop-color='%23996515'/></linearGradient><filter id='glow' x='-25%' y='-25%' width='150%' height='150%'><feDropShadow dx='0' dy='1.5' stdDeviation='1.5' flood-color='%23000000' flood-opacity='0.85'/><feDropShadow dx='0' dy='0' stdDeviation='2' flood-color='%2310b981' flood-opacity='0.6'/></filter></defs><g filter='url(%23glow)'><path d='M2 2 L13 26 L17 18 L25 21 L2 2 Z' fill='url(%23blade)' stroke='url(%23gold)' stroke-width='1.5' stroke-linejoin='round'/><polygon points='2,2 9,14 14,14' fill='%236ee7b7' opacity='0.75'/><path d='M17 18 L27 28 L23 32 L13 22 Z' fill='url(%23gold)' stroke='%23451a03' stroke-width='0.8'/><circle cx='20' cy='25' r='1.8' fill='%2310b981' stroke='%23fff' stroke-width='0.6'/><circle cx='2' cy='2' r='2' fill='%23ffffff'/></g></svg>") 2 2, auto;

  --castle-cursor-pointer: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='38' height='38' viewBox='0 0 38 38'><defs><linearGradient id='pBlade' x1='0%' y1='0%' x2='100%' y2='100%'><stop offset='0%' stop-color='%2334d399'/><stop offset='35%' stop-color='%2310b981'/><stop offset='75%' stop-color='%23047857'/><stop offset='100%' stop-color='%23022c1b'/></linearGradient><linearGradient id='pGold' x1='0%' y1='0%' x2='100%' y2='100%'><stop offset='0%' stop-color='%23ffffff'/><stop offset='30%' stop-color='%23fff5c0'/><stop offset='65%' stop-color='%23ffd700'/><stop offset='100%' stop-color='%238c6d32'/></linearGradient><filter id='pGlow' x='-25%' y='-25%' width='150%' height='150%'><feDropShadow dx='0' dy='1.5' stdDeviation='1.5' flood-color='%23000000' flood-opacity='0.9'/><feDropShadow dx='0' dy='0' stdDeviation='2.8' flood-color='%23ffd700' flood-opacity='0.75'/></filter></defs><g filter='url(%23pGlow)'><!-- Armored Wrist Cuff --><path d='M16 24 L27 34 L23 37 L13 27 Z' fill='url(%23pGold)' stroke='%233b1e08' stroke-width='0.8'/><circle cx='19.5' cy='30.5' r='1.8' fill='%2310b981' stroke='%23fff' stroke-width='0.6'/><!-- Palm and Folded Fingers Guard --><path d='M10 16 C10 12.5 14.5 12.5 15.5 15 C16.5 12 21 12 22 14 C23 13 26 14 25.5 17.5 L24 23 C23 26 17 27 13 25 L10 20 Z' fill='url(%23pBlade)' stroke='url(%23pGold)' stroke-width='1.4' stroke-linejoin='round'/><!-- Thumb fold --><path d='M6 15 C6 13 9.5 14 11.5 16.5 L12.5 19.5 C11.5 21.5 8 20.5 7 18 Z' fill='url(%23pBlade)' stroke='url(%23pGold)' stroke-width='1.3'/><!-- Extended Pointing Index Finger --><path d='M6 2 C6.8 1.4 8.5 2 9 3.2 L12.5 14 C12.5 16 10 17 8.5 15.5 L5.5 5 C5.2 3.5 5.5 2.2 6 2 Z' fill='url(%23pBlade)' stroke='url(%23pGold)' stroke-width='1.5' stroke-linejoin='round'/><!-- Armored Knuckle Segments --><line x1='6.8' y1='6.5' x2='9.8' y2='7.5' stroke='url(%23pGold)' stroke-width='1.1' stroke-linecap='round'/><line x1='7.8' y1='10.8' x2='11.2' y2='11.8' stroke='url(%23pGold)' stroke-width='1.1' stroke-linecap='round'/><!-- Diamond Jewel Glint on Index Fingertip --><circle cx='6.5' cy='2.8' r='1.6' fill='%23ffffff'/><circle cx='6.5' cy='2.8' r='2.8' fill='none' stroke='%23ffd700' stroke-width='0.6' opacity='0.8'/></g></svg>") 6 2, pointer;
}

/* ==============================================================================
   UNIVERSAL OVERRIDE: THE SYSTEM DEFAULT MOUSE MUST NEVER APPEAR ANYWHERE
   ============================================================================== */
html,
body,
*,
*::before,
*::after {
  cursor: var(--castle-cursor-default) !important;
}

/* All interactive clickable elements and ALL their nested descendants */
a,
button,
select,
summary,
label,
[role="button"],
[role="tab"],
[role="menuitem"],
[role="link"],
[onclick],
.clickable,
.btn,
.tab-btn,
.action-btn,
.lesson-card,
.quiz-card,
.game-card,
.m-role-tab,
.d-role-tab,
.m-step-badge,
.d-step-badge,
.m-eye-btn,
.d-eye-btn,
.m-title-hitbox,
.d-title-hitbox,
.d-glass-card,
.cursor-pointer,
input[type="button"],
input[type="submit"],
input[type="reset"],
input[type="checkbox"],
input[type="radio"],
/* And EVERY child inside clickable elements */
a *,
button *,
select *,
summary *,
label *,
[role="button"] *,
[role="tab"] *,
[role="menuitem"] *,
[role="link"] *,
[onclick] *,
.clickable *,
.btn *,
.tab-btn *,
.action-btn *,
.lesson-card *,
.quiz-card *,
.game-card *,
.m-role-tab *,
.d-role-tab *,
.m-step-badge *,
.d-step-badge *,
.m-eye-btn *,
.d-eye-btn *,
.m-title-hitbox *,
.d-title-hitbox *,
.d-glass-card *,
.cursor-pointer * {
  cursor: var(--castle-cursor-pointer) !important;
}

/* Text inputs and editable fields */
input[type="text"],
input[type="tel"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="search"],
input[type="url"],
textarea,
[contenteditable="true"] {
  cursor: text !important;
}

/* Disabled elements */
[disabled],
[disabled] *,
.disabled,
.disabled * {
  cursor: not-allowed !important;
}

/* ----------------------------------------------------------------------------
   2. ROYAL CURSOR AURA: IMPERIAL ASTROLABE GLASS HALO & STARDUST
   ---------------------------------------------------------------------------- */
#castleCursorAura {
  position: fixed;
  top: 0;
  left: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  pointer-events: none !important;
  z-index: 999999;
  transform: translate(-50%, -50%);
  display: none;
  opacity: 0.5;
  transition: width 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              height 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.28s ease,
              transform 0.15s ease;
  will-change: transform, width, height, opacity;
}

@media (hover: hover) and (pointer: fine) and (min-width: 901px) {
  #castleCursorAura {
    display: block;
  }
}

@media (max-width: 900px), (hover: none), (pointer: coarse) {
  #castleCursorAura {
    display: none !important;
    pointer-events: none !important;
  }
}

/* 2.1 Ancient Astrolabe Celestial Orbit */
#castleCursorAura .aura-orbit {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(212, 175, 55, 0.4);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.18), inset 0 0 6px rgba(212, 175, 55, 0.12);
  animation: astrolabeSpin 24s linear infinite;
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 4 Delicate Royal Gold Compass Nodes */
#castleCursorAura .aura-node {
  position: absolute;
  width: 2.5px;
  height: 2.5px;
  border-radius: 50%;
  background: #ffd700;
  box-shadow: 0 0 5px #ffd700, 0 0 8px #10b981;
  transition: all 0.28s ease;
}
#castleCursorAura .node-n { top: -1.25px; left: calc(50% - 1.25px); }
#castleCursorAura .node-s { bottom: -1.25px; left: calc(50% - 1.25px); }
#castleCursorAura .node-e { right: -1.25px; top: calc(50% - 1.25px); }
#castleCursorAura .node-w { left: -1.25px; top: calc(50% - 1.25px); }

/* 2.2 Soft Ambient Emerald Mist Core */
#castleCursorAura .aura-core {
  position: absolute;
  inset: 2.5px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.16) 0%, rgba(5, 150, 105, 0.06) 55%, transparent 80%);
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Hovering State: Elegant, Luminous Gold Astrolabe Frame */
#castleCursorAura.is-hovering {
  width: 48px;
  height: 48px;
  opacity: 0.95;
}

#castleCursorAura.is-hovering .aura-orbit {
  border: 1.5px solid rgba(255, 215, 0, 0.8);
  box-shadow: 0 0 18px rgba(255, 215, 0, 0.45), 0 0 30px rgba(16, 185, 129, 0.3), inset 0 0 10px rgba(255, 215, 0, 0.2);
  animation-duration: 8s;
}

#castleCursorAura.is-hovering .aura-node {
  width: 3.5px;
  height: 3.5px;
  background: #ffffff;
  box-shadow: 0 0 8px #ffffff, 0 0 14px #ffd700;
}
#castleCursorAura.is-hovering .node-n { top: -1.75px; left: calc(50% - 1.75px); }
#castleCursorAura.is-hovering .node-s { bottom: -1.75px; left: calc(50% - 1.75px); }
#castleCursorAura.is-hovering .node-e { right: -1.75px; top: calc(50% - 1.75px); }
#castleCursorAura.is-hovering .node-w { left: -1.75px; top: calc(50% - 1.75px); }

#castleCursorAura.is-hovering .aura-core {
  inset: 3px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.25) 0%, rgba(212, 175, 55, 0.1) 60%, transparent 85%);
}

/* Clicking State: Snappy Seal Touch Pulse */
#castleCursorAura.is-clicking {
  width: 20px;
  height: 20px;
  opacity: 1;
}

#castleCursorAura.is-clicking .aura-orbit {
  border-color: #ffd700;
  border-width: 2px;
  box-shadow: 0 0 20px #ffd700, 0 0 35px #10b981;
}

#castleCursorAura.is-clicking .aura-core {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0%, rgba(255, 215, 0, 0.4) 60%, transparent 100%);
}

/* Faded calm state when reading */
#castleCursorAura.is-calm {
  opacity: 0.2;
}

/* Hidden over text inputs and editable zones for zero distraction */
#castleCursorAura.is-hidden,
body:has(input[type="text"]:hover) #castleCursorAura,
body:has(input[type="tel"]:hover) #castleCursorAura,
body:has(input[type="password"]:hover) #castleCursorAura,
body:has(input[type="email"]:hover) #castleCursorAura,
body:has(input[type="number"]:hover) #castleCursorAura,
body:has(input[type="search"]:hover) #castleCursorAura,
body:has(input[type="url"]:hover) #castleCursorAura,
body:has(textarea:hover) #castleCursorAura,
body:has([contenteditable="true"]:hover) #castleCursorAura {
  opacity: 0 !important;
  transform: translate(-50%, -50%) scale(0.5) !important;
}

@keyframes astrolabeSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ----------------------------------------------------------------------------
   2.3 SUBTLE ROYAL STARDUST SPARKS (WHISPER LIGHT TRAIL)
   ---------------------------------------------------------------------------- */
.castle-stardust {
  position: fixed;
  pointer-events: none !important;
  z-index: 999998;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: stardustFade 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes stardustFade {
  0% {
    opacity: 0.65;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) translate(var(--dx, 0px), var(--dy, 0px)) scale(0.2);
  }
}

/* ----------------------------------------------------------------------------
   3. TACTILE TOUCH RIPPLE FOR MOBILE & CLICKS
   ---------------------------------------------------------------------------- */
.castle-touch-ripple {
  position: fixed;
  border-radius: 50%;
  pointer-events: none !important;
  z-index: 999998;
  transform: translate(-50%, -50%) scale(0.2);
  background: radial-gradient(circle, rgba(255, 215, 0, 0.65) 0%, rgba(16, 185, 129, 0.45) 45%, transparent 75%);
  border: 2px solid rgba(255, 215, 0, 0.85);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.8), 0 0 30px rgba(255, 215, 0, 0.6);
  animation: castleRippleBloom 0.65s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes castleRippleBloom {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.2);
  }
  60% {
    opacity: 0.85;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.45);
  }
}

/* ----------------------------------------------------------------------------
   4. SOVEREIGN SHIELD: FRIENDLY STUDENT SUPPORT TOAST (STEALTH RIGHT-CLICK LOCK)
   ---------------------------------------------------------------------------- */
#castleShieldNotice {
  position: fixed;
  top: 20px;
  left: 50%;
  z-index: 1000000;
  pointer-events: none;
  display: none !important;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: linear-gradient(135deg, rgba(3, 30, 20, 0.96) 0%, rgba(1, 16, 11, 0.98) 100%);
  border: 1.8px solid #d4af37;
  border-radius: 40px;
  color: #fff8dc;
  font-family: 'Cairo', 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 800;
  direction: rtl;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.88), 0 0 24px rgba(212, 175, 55, 0.45), inset 0 1px 2px rgba(255, 255, 255, 0.35);
  transform: translate(-50%, -120%) scale(0.92);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  letter-spacing: -0.2px;
  max-width: 90vw;
  text-align: center;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}

@media (max-width: 680px) {
  #castleShieldNotice {
    white-space: normal;
    width: 92vw;
    font-size: 13px;
    padding: 10px 18px;
    border-radius: 24px;
    line-height: 1.5;
  }
}

#castleShieldNotice.is-active {
  display: flex !important;
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  animation: castleNoticeFloat 0.42s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#castleShieldNotice .shield-icon {
  width: 22px;
  height: 22px;
  fill: #ffd700;
  filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.75));
  flex-shrink: 0;
}

@keyframes castleNoticeFloat {
  0% {
    transform: translate(-50%, -60%) scale(0.86);
    opacity: 0;
  }
  65% {
    transform: translate(-50%, -106%) scale(1.02);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -100%) scale(1);
    opacity: 1;
  }
}

/* ----------------------------------------------------------------------------
   5. ANTI-INSPECTION SELECTION PROTECTION
   ---------------------------------------------------------------------------- */
body {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Ensure users CAN select & edit text inside legitimate inputs */
input, textarea, [contenteditable="true"] {
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  -ms-user-select: text !important;
  user-select: text !important;
}

img {
  -webkit-user-drag: none;
  user-drag: none;
}
