/* atom-builder — الأنماط الخاصّة بالذرّة فقط.
   tokens واللغة البصريّة المشتركة في ../../../shared/lesson-core.css. */


/* ——— topbar (شعار + meta) ——— */
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo {
  width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff 0, var(--electron) 40%, #0d2c47 100%);
  box-shadow: 0 0 12px rgba(74, 184, 255, 0.4);
}
.brand .t1 { font-weight: 700; font-size: var(--fs-base); }
.brand .t2 {
  font-family: var(--font-en);
  font-weight: 500; font-size: var(--fs-tiny);
  letter-spacing: 0.25em; text-transform: uppercase;
  color: var(--ink-soft); margin-inline-end: var(--sp-3);
}
.meta {
  display: flex; gap: var(--sp-7);
  font-family: var(--font-mono);
  font-size: var(--fs-xs); color: var(--ink-soft);
}
.meta b { color: var(--ink); font-weight: 500; }
.meta .live { color: var(--electron); }


/* ——— particle controls ——— */
.part-ctl {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: var(--sp-4);
  display: grid; grid-template-columns: auto 1fr auto auto;
  gap: var(--sp-4); align-items: center;
}
.part-ctl .pdot {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-family: var(--font-mono);
  font-weight: 700; font-size: var(--fs-small);
}
.part-ctl .pdot.p { background: var(--proton); }
.part-ctl .pdot.n { background: var(--neutron); }
.part-ctl .pdot.e { background: var(--electron); }
.part-ctl .lbl { display: flex; flex-direction: column; gap: 2px; }
.part-ctl .lbl .a { font-size: var(--fs-small); font-weight: 600; }
.part-ctl .lbl .e {
  font-family: var(--font-en); font-size: var(--fs-label-en);
  letter-spacing: 0.12em; color: var(--ink-soft);
  text-transform: uppercase;
}
.part-ctl .count {
  font-family: var(--font-mono); font-size: var(--fs-base);
  font-weight: 600; width: 28px; text-align: center;
  color: var(--accent);
}
.part-ctl .pm { display: flex; gap: var(--sp-1); }
.pm-btn {
  width: 26px; height: 26px;
  border: 1px solid var(--line-bright); background: var(--bg);
  color: var(--ink); border-radius: var(--r-sm);
  cursor: pointer; font-weight: 600;
  font-family: var(--font-mono);
}
.pm-btn:hover { background: var(--line); }
.pm-btn:active { transform: translateY(1px); }


/* ——— jump grid (عناصر مفضّلة) ——— */
.jump-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-2);
}
.jumpbtn {
  background: var(--panel-2); border: 1px solid var(--line-bright);
  color: var(--ink); padding: var(--sp-3) var(--sp-1);
  border-radius: var(--r-md); cursor: pointer;
  font-family: var(--font-mono); font-size: var(--fs-xs);
  font-weight: 600;
  display: flex; flex-direction: column; gap: 2px;
  align-items: center;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.jumpbtn:hover { border-color: var(--accent); background: #172140; }
.jumpbtn.active {
  border-color: var(--accent); background: rgba(245, 166, 35, 0.1);
  color: var(--accent);
}
.jumpbtn .sym { font-size: var(--fs-base); font-weight: 700; }
.jumpbtn .name {
  font-family: var(--font-ar);
  font-size: var(--fs-label-en); color: var(--ink-soft);
}


/* ——— أزرار الذرّة (تعادل / إعادة) ——— */
.atom-btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.atom-btn {
  background: var(--electron); border: 1px solid var(--electron);
  color: var(--bg); padding: var(--sp-4);
  border-radius: var(--r-md); cursor: pointer;
  font-weight: 600; font-family: inherit; font-size: var(--fs-small);
}
.atom-btn:hover { background: #7fcfff; }
.atom-btn.secondary {
  background: transparent; color: var(--ink);
  border-color: var(--line-bright);
}
.atom-btn.secondary:hover { background: var(--panel-2); }
.atom-btn .en {
  font-family: var(--font-en); font-size: var(--fs-label-en);
  letter-spacing: 0.15em; display: block; opacity: 0.8;
  font-weight: 500;
}


/* ——— side-note ذرّة-خاصّ (بخلفيّة) ——— */
.side-note {
  font-size: var(--fs-xs); line-height: 1.6;
  color: var(--ink-soft); background: var(--panel-2);
  border: 1px dashed var(--line-bright); border-radius: var(--r-md);
  padding: var(--sp-4) var(--sp-5);
}
.side-note b { color: var(--ink); font-weight: 600; }


/* ——— stage canvas + overlays ——— */
.lesson-stage canvas {
  display: block; position: absolute; inset: 0;
  width: 100%; height: 100%;
}

/* خصوصيّة atom-builder: هوك في أعلى اليمين physical
   (يستبدل مكان legend القديم). لوحات الدرس الأخرى
   تُبقي default lesson-core (inset-inline-end). */
.lesson-stage .lesson-hook {
  inset-inline-end: auto;
  right: var(--sp-6); left: auto;
}
.atom-title-card {
  position: absolute; top: var(--sp-6); left: var(--sp-6);
  z-index: 5; background: var(--panel);
  border: 1px solid var(--line-bright); border-radius: var(--r-md);
  padding: var(--sp-5) var(--sp-6);
  display: flex; align-items: center; gap: 14px;
}
.atom-title-card .sym {
  font-family: var(--font-en); font-size: 42px;
  font-weight: 700; line-height: 1;
  color: var(--accent); letter-spacing: -0.02em;
}
.atom-title-card .lab { display: flex; flex-direction: column; }
.atom-title-card .lab .ar { font-size: var(--fs-base); font-weight: 600; }
.atom-title-card .lab .en {
  font-family: var(--font-en); font-size: var(--fs-tiny);
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--ink-soft);
}
.atom-title-card .zlab {
  display: flex; flex-direction: column;
  margin-right: auto; gap: var(--sp-1);
  padding-right: var(--sp-5);
  border-right: 1px solid var(--line);
  font-family: var(--font-mono); font-size: var(--fs-tiny);
  color: var(--ink-soft);
}
.atom-title-card .zlab b { color: var(--ink); font-weight: 600; font-size: var(--fs-small); }

.view-toggle {
  position: absolute; bottom: var(--sp-6); left: var(--sp-6);
  display: flex; background: var(--panel);
  border: 1px solid var(--line-bright); border-radius: var(--r-md);
  overflow: hidden; font-family: var(--font-en);
  font-size: var(--fs-tiny); letter-spacing: 0.15em;
  text-transform: uppercase; z-index: 5;
}
.view-toggle button {
  background: transparent; border: 0; color: var(--ink-soft);
  padding: var(--sp-3) 14px; cursor: pointer; font: inherit;
  letter-spacing: inherit; border-left: 1px solid var(--line-bright);
}
.view-toggle button:first-child { border-left: 0; }
.view-toggle button.active { background: var(--electron); color: var(--bg); font-weight: 600; }

.key-fact {
  position: absolute; bottom: var(--sp-6); right: var(--sp-6);
  max-width: 360px; background: var(--panel);
  border: 1px solid var(--line-bright); border-radius: var(--r-md);
  padding: var(--sp-5) 14px; z-index: 5;
  border-left: 3px solid var(--accent);
}
.key-fact .tag {
  font-family: var(--font-en); font-size: var(--fs-label-en);
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--accent); font-weight: 600; margin-bottom: var(--sp-1);
}
.key-fact .ar { font-size: var(--fs-small); line-height: 1.6; }
.key-fact .en {
  font-family: var(--font-en); font-size: var(--fs-tiny);
  line-height: 1.5; color: var(--ink-soft);
  margin-top: var(--sp-1); direction: ltr; text-align: left;
}

/* legend chips — أسفل بطاقة العنوان (يسار physical) */
.atom-legend {
  position: absolute; top: 90px; left: var(--sp-6);
  z-index: 5; display: flex; flex-direction: column;
  gap: var(--sp-2);
  font-family: var(--font-en); font-size: var(--fs-tiny);
  letter-spacing: 0.1em; text-transform: uppercase;
}
.atom-legend .chip {
  display: inline-flex; align-items: center; gap: var(--sp-3);
  background: var(--panel); border: 1px solid var(--line-bright);
  padding: 5px var(--sp-4); border-radius: var(--r-pill);
  color: var(--ink-soft);
}
.atom-legend .chip b { color: var(--ink); }
.atom-legend .sw { width: 10px; height: 10px; border-radius: 50%; }


/* ——— HUD ذرّة-خاصّ ——— */
.hud-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.hud-cell {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: var(--sp-4) var(--sp-5);
  display: flex; flex-direction: column; gap: 2px;
  position: relative; overflow: hidden;
}
.hud-cell::before {
  content: ""; position: absolute; top: 0; inset-inline-start: 0;
  width: 3px; height: 100%; background: var(--electron);
}
.hud-cell.p::before { background: var(--proton); }
.hud-cell.n::before { background: var(--neutron); }
.hud-cell.e::before { background: var(--electron); }
.hud-cell.w::before { background: var(--accent); }
.hud-cell.v::before { background: var(--violet); }
.hud-cell.g::before { background: var(--green); }
.hud-cell .k {
  font-family: var(--font-en); font-size: var(--fs-label-en);
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--ink-soft);
}
.hud-cell .k .ar {
  display: block; font-family: var(--font-ar);
  font-size: var(--fs-tiny); letter-spacing: 0;
  color: var(--ink); font-weight: 500; margin-bottom: 2px;
}
.hud-cell .v {
  font-family: var(--font-mono); font-size: 18px;
  font-weight: 600; line-height: 1.1; margin-top: var(--sp-1);
}
.hud-cell .v small {
  font-size: var(--fs-tiny); font-weight: 400;
  color: var(--ink-soft); margin-inline-start: var(--sp-1);
}


/* ——— shell viz ——— */
.shell-viz {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: var(--sp-5);
}
.shell-viz h4 { margin: 0 0 var(--sp-4); font-size: var(--fs-xs); font-weight: 600; }
.shell-viz h4 small {
  font-family: var(--font-en); font-weight: 500;
  font-size: var(--fs-label-en); letter-spacing: 0.15em;
  text-transform: uppercase; color: var(--ink-soft);
  display: block; margin-top: 2px;
}
.shell-row {
  display: grid; grid-template-columns: 44px 1fr 56px;
  gap: var(--sp-3); align-items: center;
  padding: 3px 0; font-family: var(--font-mono);
  font-size: var(--fs-xs);
}
.shell-row .name { color: var(--ink-soft); }
.shell-row .dots { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; }
.shell-row .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--line); border: 1px solid var(--line-bright);
}
.shell-row .dot.filled {
  background: var(--electron); border-color: #fff;
  box-shadow: 0 0 4px rgba(74, 184, 255, 0.6);
}
.shell-row .val { font-size: var(--fs-tiny); color: var(--accent); text-align: left; }


/* ——— equations block ——— */
.eq-block {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: var(--sp-5);
  font-family: var(--font-mono); font-size: var(--fs-xs);
}
.eq-block h4 {
  margin: 0 0 var(--sp-3);
  font-family: var(--font-ar); font-size: var(--fs-xs); font-weight: 600;
}
.eq-block h4 small {
  font-family: var(--font-en); font-weight: 500;
  font-size: var(--fs-label-en); letter-spacing: 0.15em;
  text-transform: uppercase; color: var(--ink-soft);
  display: block; margin-top: 2px;
}
.eq-row {
  display: flex; justify-content: space-between;
  padding: var(--sp-1) 0; border-bottom: 1px dashed rgba(138, 151, 176, 0.15);
}
.eq-row:last-child { border: 0; }
.eq-row .lhs { color: var(--ink); }
.eq-row .rhs { color: var(--electron); }


/* ——— scrollbars ——— */
.lesson-panel::-webkit-scrollbar { width: 6px; }
.lesson-panel::-webkit-scrollbar-thumb { background: var(--line-bright); border-radius: 3px; }


/* ——— طبقات الشرح — محتوى مُفصَّل ——— */
.lesson-layers__panel ul,
.lesson-layers__panel ol { margin: var(--sp-2) 0 0; padding-inline-start: var(--sp-6); }
.lesson-layers__panel li { margin-bottom: var(--sp-2); }
.lesson-layers__panel p + p { margin-top: var(--sp-3); }
.lesson-layers__panel b { color: var(--accent); font-weight: 600; }
.lesson-layers__panel .year {
  font-family: var(--font-mono); color: var(--accent);
  font-size: var(--fs-xs); margin-inline-end: var(--sp-2);
}


/* ============================================================
   JUMP BUTTON (الفتح) + Periodic Table Modal
   ============================================================ */
.pt-open-btn {
  background: linear-gradient(135deg, #4ab8ff 0%, #8c5cff 100%);
  border: 0; color: #fff; padding: var(--sp-5);
  border-radius: var(--r-md); cursor: pointer;
  font-weight: 600; font-family: inherit; font-size: var(--fs-small);
  display: flex; flex-direction: column; gap: 2px;
  align-items: center;
  box-shadow: 0 0 16px rgba(74, 184, 255, 0.2);
}
.pt-open-btn:hover { filter: brightness(1.15); }
.pt-open-btn .en {
  font-family: var(--font-en); font-size: var(--fs-label-en);
  letter-spacing: 0.2em; opacity: 0.85; font-weight: 500;
}

.pt-modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 8, 15, 0.85); backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center;
  padding: 20px; animation: pt-fadein var(--dur-base);
}
.pt-modal.show { display: flex; }
@keyframes pt-fadein { from { opacity: 0; } to { opacity: 1; } }
.pt-shell {
  background: var(--panel); border: 1px solid var(--line-bright);
  border-radius: var(--r-lg); max-width: 1400px; width: 100%;
  max-height: 92vh; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.pt-header {
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
}
.pt-title { display: flex; align-items: center; gap: 12px; }
.pt-title .ar { font-size: 16px; font-weight: 700; }
.pt-title .en {
  font-family: var(--font-en); font-size: var(--fs-tiny);
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink-soft);
}
.pt-tabs {
  display: flex; gap: var(--sp-1);
  background: var(--bg); border: 1px solid var(--line-bright);
  border-radius: var(--r-md); padding: 3px;
}
.pt-tab {
  background: transparent; border: 0; color: var(--ink-soft);
  padding: var(--sp-2) 14px; border-radius: var(--r-sm);
  cursor: pointer; font-family: inherit;
  font-size: var(--fs-xs); font-weight: 500; letter-spacing: 0.05em;
}
.pt-tab.active { background: var(--electron); color: var(--bg); font-weight: 600; }
.pt-close {
  background: transparent; border: 1px solid var(--line-bright);
  color: var(--ink); width: 30px; height: 30px; border-radius: 50%;
  cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.pt-close:hover { background: var(--red); border-color: var(--red); }

.pt-body { flex: 1; overflow: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.pt-table {
  display: grid; grid-template-columns: repeat(18, 1fr);
  gap: 3px; direction: ltr;
}
.pt-cell {
  aspect-ratio: 1; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 3px;
  cursor: pointer; padding: 3px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative;
  transition: transform var(--dur-fast), box-shadow var(--dur-fast);
  color: #fff;
}
.pt-cell:hover { transform: scale(1.12); z-index: 5; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5), 0 0 0 2px #fff; }
.pt-cell .z { font-family: var(--font-mono); font-size: 8px; font-weight: 500; opacity: 0.8; line-height: 1; }
.pt-cell .sym { font-family: var(--font-en); font-size: 16px; font-weight: 700; line-height: 1; text-align: center; }
.pt-cell .mass { font-family: var(--font-mono); font-size: 7px; opacity: 0.7; text-align: center; line-height: 1; }
.pt-cell.active { box-shadow: 0 0 0 3px var(--accent), 0 0 20px rgba(245, 166, 35, 0.5); transform: scale(1.08); z-index: 4; }
.pt-spacer { visibility: hidden; }
.pt-break { grid-column: 1 / -1; height: 8px; }
.pt-break.small { height: 4px; }

/* category colors */
.cat-alkali      { background: #d64545; color: #fff; }
.cat-alkaline    { background: #e07b39; color: #fff; }
.cat-transition  { background: #c9912e; color: #fff; }
.cat-post        { background: #6a7f8a; color: #fff; }
.cat-metalloid   { background: #4a8c7a; color: #fff; }
.cat-nonmetal    { background: #4b8dce; color: #fff; }
.cat-halogen     { background: #6a5acd; color: #fff; }
.cat-noble       { background: #8c5cff; color: #fff; }
.cat-lanthanide  { background: #c85a8e; color: #fff; }
.cat-actinide    { background: #a04284; color: #fff; }
.cat-unknown     { background: #3a4a64; color: #d8e0ee; }

.pt-legend {
  display: flex; flex-wrap: wrap; gap: var(--sp-2);
  padding: var(--sp-4); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: var(--r-md);
}
.pt-legend .chip {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-4); border-radius: var(--r-pill);
  font-size: var(--fs-tiny); font-family: var(--font-ar); font-weight: 500;
}
.pt-legend .sw { width: 10px; height: 10px; border-radius: 2px; }

.pt-pages { display: flex; flex-direction: column; gap: 14px; }
.page-nav { display: flex; gap: var(--sp-2); justify-content: center; flex-wrap: wrap; }
.page-nav button {
  background: var(--panel-2); border: 1px solid var(--line-bright);
  color: var(--ink); padding: var(--sp-3) 14px;
  border-radius: var(--r-md); cursor: pointer;
  font-family: inherit; font-size: var(--fs-xs);
  font-weight: 500;
  display: flex; flex-direction: column; align-items: center;
  gap: 2px; min-width: 80px;
}
.page-nav button:hover { border-color: var(--accent); }
.page-nav button.active {
  background: var(--electron); border-color: var(--electron);
  color: var(--bg); font-weight: 600;
}
.page-nav button .sub {
  font-family: var(--font-mono); font-size: 9px;
  opacity: 0.8; font-weight: 400;
}
.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--sp-4); }
.elem-card {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: var(--sp-5);
  cursor: pointer;
  transition: border-color var(--dur-fast), transform var(--dur-fast);
  position: relative; overflow: hidden;
}
.elem-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.elem-card::before {
  content: ""; position: absolute; top: 0;
  inset-inline-start: 0; width: 4px; height: 100%;
}
.elem-card.c-alkali::before      { background: #d64545; }
.elem-card.c-alkaline::before    { background: #e07b39; }
.elem-card.c-transition::before  { background: #c9912e; }
.elem-card.c-post::before        { background: #6a7f8a; }
.elem-card.c-metalloid::before   { background: #4a8c7a; }
.elem-card.c-nonmetal::before    { background: #4b8dce; }
.elem-card.c-halogen::before     { background: #6a5acd; }
.elem-card.c-noble::before       { background: #8c5cff; }
.elem-card.c-lanthanide::before  { background: #c85a8e; }
.elem-card.c-actinide::before    { background: #a04284; }
.elem-card.c-unknown::before     { background: #3a4a64; }
.elem-card .row1 { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: var(--sp-2); }
.elem-card .z { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-soft); }
.elem-card .sym { font-family: var(--font-en); font-size: 24px; font-weight: 700; line-height: 1; }
.elem-card .name-ar { font-size: var(--fs-small); font-weight: 600; }
.elem-card .name-en { font-family: var(--font-en); font-size: var(--fs-tiny); color: var(--ink-soft); letter-spacing: 0.05em; }
.elem-card .mass { font-family: var(--font-mono); font-size: var(--fs-tiny); color: var(--accent); margin-top: var(--sp-1); }
