/* ═══════════════════════════════════════════════════════════════
   Chem Lab Pro — Design System
   وضعان متمايزان: فاتح (معمل أبيض) ≠ داكن (ليل بنفسجي)
   ═══════════════════════════════════════════════════════════════ */

/* ───────────── LIGHT: أبيض نقي + بنفسجي حبر ───────────── */
:root,
html[data-theme="light"],
html[data-theme="light"] body.chem-lab,
html[data-theme="light"] body.chemistry-pro,
body.chem-lab,
body.chemistry-pro {
  color-scheme: light;

  --chem-ink: #140822;
  --chem-ink-2: #2B1248;
  --chem-violet: #5B2C8A;
  --chem-violet-mid: #6E3A9E;
  --chem-violet-soft: #8B5BB5;
  --chem-mist: #F8F6FC;
  --chem-white: #FFFFFF;
  --chem-line: rgba(20, 8, 34, 0.12);
  --chem-line-strong: rgba(91, 44, 138, 0.32);
  --chem-glow: rgba(91, 44, 138, 0.18);

  --brand-950: #140822;
  --brand-900: #2B1248;
  --brand-800: #3D1A63;
  --brand-700: #5B2C8A;
  --brand-600: #6E3A9E;
  --brand-500: #8B5BB5;
  --brand-100: rgba(91, 44, 138, 0.10);
  --brand-50: rgba(91, 44, 138, 0.05);
  --brand-weak: rgba(91, 44, 138, 0.12);
  --brand-soft: rgba(91, 44, 138, 0.08);
  --brand-border: var(--chem-line-strong);
  --brand-glow: var(--chem-glow);

  --accent: #5B2C8A;
  --accent-soft: rgba(91, 44, 138, 0.12);
  --accent-light: #EDE4F7;

  --page-bg: #F4F0FA;
  --page-bg-alt: #EBE4F5;
  --card-bg: #FFFFFF;
  --card: #FFFFFF;
  --card-bg-strong: #FFFFFF;
  --card-soft: #F3ECF9;

  --surface-soft: rgba(91, 44, 138, 0.06);
  --surface-strong: rgba(91, 44, 138, 0.12);
  --surface-highlight: rgba(91, 44, 138, 0.10);

  /* نصوص فاتح: داكنة جداً لوضوح 100% */
  --text: #1C1228;
  --text-strong: #0E0618;
  --muted: #3A2A4E;
  --muted-strong: #241533;

  --border: rgba(20, 8, 34, 0.12);
  --border-strong: rgba(91, 44, 138, 0.35);
  --shadow: 0 10px 32px rgba(20, 8, 34, 0.08);
  --shadow-soft: 0 4px 14px rgba(20, 8, 34, 0.05);
  --shadow-strong: 0 22px 48px rgba(20, 8, 34, 0.12);

  --primary: #5B2C8A;
  --primary-strong: #2B1248;
  --primary-weak: rgba(91, 44, 138, 0.12);

  --field-bg: #FFFFFF;
  --field-text: #1C1228;
  --field-border: rgba(20, 8, 34, 0.18);
  --field-placeholder: #6B5A7D;

  --btn-solid-bg: linear-gradient(135deg, #5B2C8A 0%, #2B1248 100%);
  --btn-solid-text: #FFFFFF;
  --btn-success-bg: linear-gradient(135deg, #5B2C8A, #7B3FA8);
  --btn-success-text: #FFFFFF;
  --btn-ghost-bg: #FFFFFF;
  --btn-ghost-text: #2B1248;
  --btn-ghost-border: rgba(91, 44, 138, 0.35);

  --success: #1F7A52;
  --success-soft-bg: rgba(31, 122, 82, 0.10);
  --success-soft-border: rgba(31, 122, 82, 0.28);
  --danger: #C0392B;
  --danger-soft-bg: rgba(192, 57, 43, 0.10);
  --danger-soft-border: rgba(192, 57, 43, 0.28);
  --warning: #A7672A;
  --warning-soft-bg: rgba(167, 103, 42, 0.10);
  --warning-soft-border: rgba(167, 103, 42, 0.28);

  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 26px;

  --sw-bg: #D9C6EC;
  --sw-knob: #FFFFFF;

  --hdr-bg: #FFFFFF;
  --hdr-text: #140822;
  --hdr-border: rgba(20, 8, 34, 0.10);
  --hdr-muted: #4E3D63;
  --hdr-strip-bg: #F0EAF8;
  --hdr-strip-text: #5B2C8A;

  --hero-bg: linear-gradient(165deg, #FFFFFF 0%, #F3ECF9 45%, #E8DFF4 100%);
  --hero-text: #140822;
  --hero-muted: #3D2E52;
  --hero-accent: #5B2C8A;
  --hero-glow: rgba(91, 44, 138, 0.14);

  --section-bg: #FFFFFF;
  --section-alt-bg: #F4F0FA;
  --footer-bg: #140822;
  --footer-text: #F5F0FA;
  --footer-muted: #C9B8DC;

  --grid-line: rgba(91, 44, 138, 0.08);
  --page-glow-1: rgba(91, 44, 138, 0.08);
  --page-glow-2: rgba(139, 91, 181, 0.06);

  --font-display: 'Tajawal', 'Cairo', system-ui, sans-serif;
  --font-body: 'Tajawal', 'Cairo', system-ui, sans-serif;
  --font-science: 'Space Grotesk', 'Tajawal', system-ui, sans-serif;

  --insight: #5B2C8A;
  --brand: #5B2C8A;
}

/* ───────────── DARK: ليل بنفسجي ≠ الفاتح ───────────── */
html[data-theme="dark"],
html[data-theme="dark"] body.chem-lab,
html[data-theme="dark"] body.chemistry-pro {
  color-scheme: dark;

  --chem-ink: #F7F2FC;
  --chem-ink-2: #E9D8F8;
  --chem-violet: #C084FC;
  --chem-violet-mid: #A855F7;
  --chem-violet-soft: #D8B4FE;
  --chem-mist: #1A1028;
  --chem-white: #221536;
  --chem-line: rgba(232, 213, 248, 0.14);
  --chem-line-strong: rgba(192, 132, 252, 0.45);
  --chem-glow: rgba(168, 85, 247, 0.35);

  --brand-950: #F7F2FC;
  --brand-900: #E9D8F8;
  --brand-800: #D8B4FE;
  --brand-700: #C084FC;
  --brand-600: #A855F7;
  --brand-500: #9333EA;
  --brand-100: rgba(192, 132, 252, 0.16);
  --brand-50: rgba(192, 132, 252, 0.08);
  --brand-weak: rgba(192, 132, 252, 0.18);
  --brand-soft: rgba(192, 132, 252, 0.12);
  --brand-border: var(--chem-line-strong);
  --brand-glow: var(--chem-glow);

  --accent: #C084FC;
  --accent-soft: rgba(192, 132, 252, 0.18);
  --accent-light: #2A1840;

  --page-bg: #0B0614;
  --page-bg-alt: #12081F;
  --card-bg: #1A1028;
  --card: #1A1028;
  --card-bg-strong: #241538;
  --card-soft: #161022;

  --surface-soft: rgba(192, 132, 252, 0.08);
  --surface-strong: rgba(192, 132, 252, 0.16);
  --surface-highlight: rgba(192, 132, 252, 0.14);

  /* نصوص داكن: فاتحة جداً لوضوح 100% */
  --text: #F7F2FC;
  --text-strong: #FFFFFF;
  --muted: #CDBFE0;
  --muted-strong: #E8DCF5;

  --border: rgba(232, 213, 248, 0.14);
  --border-strong: rgba(192, 132, 252, 0.42);
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 6px 18px rgba(0, 0, 0, 0.30);
  --shadow-strong: 0 28px 60px rgba(0, 0, 0, 0.55);

  --primary: #C084FC;
  --primary-strong: #E9D8F8;
  --primary-weak: rgba(192, 132, 252, 0.18);

  --field-bg: #140C22;
  --field-text: #F7F2FC;
  --field-border: rgba(232, 213, 248, 0.22);
  --field-placeholder: #A996C0;

  --btn-solid-bg: linear-gradient(135deg, #A855F7 0%, #7C3AED 100%);
  --btn-solid-text: #FFFFFF;
  --btn-success-bg: linear-gradient(135deg, #A855F7, #C084FC);
  --btn-success-text: #FFFFFF;
  --btn-ghost-bg: transparent;
  --btn-ghost-text: #F7F2FC;
  --btn-ghost-border: rgba(232, 213, 248, 0.35);

  --success: #4ADE80;
  --success-soft-bg: rgba(74, 222, 128, 0.12);
  --success-soft-border: rgba(74, 222, 128, 0.32);
  --danger: #FB7185;
  --danger-soft-bg: rgba(251, 113, 133, 0.12);
  --danger-soft-border: rgba(251, 113, 133, 0.32);
  --warning: #FBBF24;
  --warning-soft-bg: rgba(251, 191, 36, 0.12);
  --warning-soft-border: rgba(251, 191, 36, 0.32);

  --sw-bg: #3B2460;
  --sw-knob: #F7F2FC;

  --hdr-bg: #12081F;
  --hdr-text: #FFFFFF;
  --hdr-border: rgba(232, 213, 248, 0.12);
  --hdr-muted: #CDBFE0;
  --hdr-strip-bg: #1A0B2E;
  --hdr-strip-text: #D8B4FE;

  --hero-bg: linear-gradient(155deg, #0B0614 0%, #1A0B2E 40%, #3B1764 100%);
  --hero-text: #FFFFFF;
  --hero-muted: #E0D4F0;
  --hero-accent: #E9D8F8;
  --hero-glow: rgba(168, 85, 247, 0.40);

  --section-bg: #12081F;
  --section-alt-bg: #0B0614;
  --footer-bg: #06030C;
  --footer-text: #F7F2FC;
  --footer-muted: #CDBFE0;

  --grid-line: rgba(192, 132, 252, 0.10);
  --page-glow-1: rgba(168, 85, 247, 0.18);
  --page-glow-2: rgba(192, 132, 252, 0.10);

  --insight: #C084FC;
  --brand: #C084FC;
}

/* شعار واحد فقط: فاتح أو داكن حسب الثيم */
.platform-logo__img--light { display: block !important; }
.platform-logo__img--dark { display: none !important; }
html[data-theme="dark"] .platform-logo__img--light { display: none !important; }
html[data-theme="dark"] .platform-logo__img--dark { display: block !important; }
.platform-logo__img--single { display: block !important; }

body.chem-lab,
body.chemistry-pro {
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  transition: background-color .25s ease, color .2s ease;
}

body.chem-lab .container,
body.chemistry-pro .container {
  width: min(1120px, calc(100% - 32px));
  margin-inline: auto;
}

/* Global text clarity */
body.chem-lab,
body.chemistry-pro,
body.chem-lab p,
body.chemistry-pro p,
body.chem-lab li,
body.chemistry-pro li,
body.chem-lab label,
body.chemistry-pro label,
body.chem-lab td,
body.chemistry-pro td,
body.chem-lab th,
body.chemistry-pro th,
body.chem-lab span,
body.chemistry-pro span {
  color: inherit;
}

body.chem-lab h1,
body.chemistry-pro h1,
body.chem-lab h2,
body.chemistry-pro h2,
body.chem-lab h3,
body.chemistry-pro h3,
body.chem-lab h4,
body.chemistry-pro h4 {
  color: var(--text-strong);
}

body.chem-lab .muted,
body.chemistry-pro .muted,
body.chem-lab .hint,
body.chemistry-pro .hint {
  color: var(--muted) !important;
}

body.chem-lab a:not(.chem-btn):not(.btn-submit):not(.acc-btn):not(.acc-btnx):not(.acc-nav__item):not(.chem-grade):not(.acc-journey__step),
body.chemistry-pro a:not(.chem-btn):not(.btn-submit):not(.acc-btn):not(.acc-btnx):not(.acc-nav__item):not(.chem-grade):not(.acc-journey__step) {
  color: var(--primary);
}

/* Buttons */
.chem-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.98rem;
  text-decoration: none;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease, color .2s ease;
  font-family: var(--font-body);
}
.chem-btn:hover { transform: translateY(-2px); }
.chem-btn--solid {
  background: var(--btn-solid-bg);
  color: var(--btn-solid-text) !important;
  box-shadow: 0 10px 28px var(--chem-glow);
}
.chem-btn--outline {
  background: transparent;
  color: var(--hero-text) !important;
  border-color: color-mix(in srgb, var(--hero-text) 45%, transparent);
}
.chem-btn--outline:hover {
  background: color-mix(in srgb, var(--hero-text) 10%, transparent);
  border-color: var(--hero-text);
}
.chem-btn--ghost {
  background: var(--btn-ghost-bg);
  color: var(--btn-ghost-text) !important;
  border-color: var(--btn-ghost-border);
}
.chem-btn--ghost:hover {
  border-color: var(--primary);
  color: var(--primary) !important;
}
.chem-btn--lg { padding: 14px 28px; font-size: 1.05rem; }

/* Section heads */
.chem-section__head { text-align: center; margin-bottom: 36px; }
.chem-section__kicker {
  font-family: var(--font-science);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 700;
  margin: 0 0 8px;
}
.chem-section__title {
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 3vw, 2.1rem);
  font-weight: 800;
  color: var(--text-strong);
  margin: 0 0 10px;
  line-height: 1.35;
}
.chem-section__sub {
  margin: 0 auto;
  max-width: 520px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.7;
  font-weight: 500;
}
.chem-section__rule {
  display: block;
  width: 56px;
  height: 3px;
  margin: 18px auto 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--chem-violet-soft));
}

.chem-ui-ico {
  width: 1.15em;
  height: 1.15em;
  display: inline-block;
  vertical-align: -0.15em;
}

.chem-hdr .theme-switch,
.chem-hdr .math-theme-switch {
  --sw-bg: var(--sw-bg);
}

.student-perf-lite .chem-hero__orbits,
.student-perf-lite .chem-bg__floats,
.android-native-app .chem-hero__orbits,
.android-native-app .chem-bg__floats {
  display: none !important;
}
.student-perf-lite .chem-hero,
.android-native-app .chem-hero {
  animation: none !important;
}

/* Form controls — always readable */
body.chem-lab input,
body.chemistry-pro input,
body.chem-lab select,
body.chemistry-pro select,
body.chem-lab textarea,
body.chemistry-pro textarea,
body.chem-lab .input,
body.chemistry-pro .input {
  background: var(--field-bg) !important;
  color: var(--field-text) !important;
  border-color: var(--field-border) !important;
}
body.chem-lab input::placeholder,
body.chemistry-pro input::placeholder,
body.chem-lab textarea::placeholder,
body.chemistry-pro textarea::placeholder {
  color: var(--field-placeholder) !important;
  opacity: 1;
}
body.chem-lab option,
body.chemistry-pro option {
  background: var(--field-bg);
  color: var(--field-text);
}
