/* acid-base-titration — الأنماط الخاصّة بالمعايرة فقط.
   tokens واللغة البصريّة المشتركة في ../../../shared/lesson-core.css.
   Primitives المتصادمة مع lesson-core تُعاد تسميتها إلى .titration-* . */


/* ——— وظيفيّ محلّيّ (ألوان الحمض/القاعدة/التعادل) ——— */
:root {
  --acid: #ff5e6c;
  --base: #8c5cff;
  --neutral: #39d98a;
  --warm: #f5a623;
}


/* ——— topbar (شعار + meta) ——— */
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo {
  width: 26px; height: 26px; border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--acid) 0%, var(--neutral) 50%, var(--base) 100%);
  box-shadow: 0 0 12px rgba(140, 92, 255, 0.3);
}
.brand .t1 { font-weight: 700; font-size: var(--fs-base); display: block; }
.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); display: block;
}
.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(--cyan); }


/* ——— preset list (التجربة) ——— */
.preset-list {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}
.pbtn {
  background: var(--panel-2); border: 1px solid var(--line-bright);
  color: var(--ink);
  padding: var(--sp-4); border-radius: var(--r-md);
  cursor: pointer;
  display: flex; flex-direction: column; gap: 3px;
  font-family: inherit; text-align: start;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.pbtn:hover { border-color: var(--cyan); background: #172140; }
.pbtn.active {
  border-color: var(--warm);
  background: rgba(245, 166, 35, 0.08);
  box-shadow: inset 0 0 0 1px var(--warm);
}
.pbtn .p-ar { font-weight: 600; font-size: var(--fs-small); }
.pbtn .p-en {
  font-family: var(--font-en); font-size: var(--fs-label-en);
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--ink-soft);
}
.pbtn .p-ph {
  font-family: var(--font-mono); font-size: var(--fs-tiny);
  color: var(--cyan); margin-top: 2px;
}


/* ——— ctl (سلايدر + label + قيمة) ——— */
.ctl { display: flex; flex-direction: column; gap: var(--sp-2); }
.ctl .row {
  display: flex; align-items: center; justify-content: space-between;
}
.ctl label { font-size: var(--fs-small); font-weight: 500; }
.ctl .v {
  font-family: var(--font-mono); font-size: var(--fs-xs);
  color: var(--cyan); background: var(--bg);
  border: 1px solid var(--line-bright);
  padding: 2px var(--sp-3); border-radius: var(--r-sm);
}
input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px;
  background: var(--line-bright); border-radius: 2px;
  outline: none; margin: var(--sp-3) 0 0;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--cyan); border: 2px solid #fff;
  cursor: pointer; box-shadow: 0 0 8px rgba(74, 184, 255, 0.6);
}
input[type=range]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--cyan); border: 2px solid #fff;
  cursor: pointer;
}
.scale {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: var(--fs-label-en);
  color: var(--ink-dim); margin-top: 2px;
}


/* ——— أزرار (مُعادة التسمية لتفادي التصادم مع lesson-core .btn) ——— */
.titration-btn-row {
  display: grid; grid-template-columns: 2fr 1fr 1fr;
  gap: var(--sp-2);
}
.titration-btn {
  background: var(--cyan); border: 1px solid var(--cyan);
  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);
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}
.titration-btn:hover { background: #7fcfff; }
.titration-btn.secondary {
  background: transparent; color: var(--ink);
  border-color: var(--line-bright);
}
.titration-btn.secondary:hover { background: var(--panel-2); }
.titration-btn.danger {
  background: var(--acid); border-color: var(--acid); color: #fff;
}
.titration-btn.running {
  background: var(--warm); border-color: var(--warm);
}
.titration-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;
}


/* ——— titration side-note (مُعادة التسمية تفادياً للتصادم) ——— */
.titration-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);
}
.titration-side-note b { color: var(--ink); font-weight: 600; }


/* ——— ana-type selector (حمض / قاعدة) ——— */
.ana-type-row {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: var(--sp-1);
}


/* ============================================================
   STAGE — burette / beaker / pH strip
   ============================================================ */

.titration-lab {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px;
  max-width: 100%; max-height: 100%;
}

/* Burette */
.burette-col {
  display: flex; flex-direction: column; align-items: center;
  gap: 0; position: relative;
  z-index: 2;
}
.burette-label {
  font-family: var(--font-en); font-size: var(--fs-label-en);
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: var(--sp-2);
}
.burette-label b {
  color: var(--base); font-weight: 600;
  display: block; font-family: var(--font-ar);
  font-size: var(--fs-xs); letter-spacing: 0;
}
.burette {
  width: 34px; height: 180px;
  border: 2px solid var(--line-bright); border-top: none;
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  background: rgba(14, 22, 38, 0.6);
  position: relative;
  box-shadow: inset 0 0 20px rgba(140, 92, 255, 0.1);
}
.burette::before {
  content: ""; position: absolute; top: -14px; left: 50%;
  transform: translateX(-50%);
  width: 54px; height: 14px;
  background: var(--panel-2);
  border: 2px solid var(--line-bright);
  border-radius: 3px 3px 0 0;
}
.burette-fill {
  position: absolute; left: 2px; right: 2px; bottom: 0;
  background: linear-gradient(180deg, rgba(140, 92, 255, 0.4) 0%, rgba(140, 92, 255, 0.8) 100%);
  border-radius: 0 0 2px 2px;
  transition: height 0.2s;
}
.burette-marks {
  position: absolute; left: 100%; top: 0; bottom: 0;
  margin-left: 4px; width: 40px;
  font-family: var(--font-mono); font-size: 8px;
  color: var(--ink-dim);
}
.burette-marks span {
  position: absolute; left: 0;
  transform: translateY(-50%);
  white-space: nowrap;
}
.burette-marks span::before {
  content: ""; position: absolute; right: 100%;
  margin-right: 2px; top: 50%;
  width: 6px; height: 1px;
  background: var(--line-bright);
}
.burette-tip {
  width: 4px; height: 16px;
  background: var(--line-bright);
  margin-top: -1px;
}
.drop {
  position: absolute; left: 50%; top: 260px;
  transform: translateX(-50%);
  width: 8px; height: 10px;
  border-radius: 0 0 50% 50% / 60%;
  background: var(--base);
  opacity: 0; pointer-events: none;
}
.stopcock {
  width: 22px; height: 10px;
  background: var(--acid);
  border: 1.5px solid var(--line);
  border-radius: 2px;
  margin-top: -2px; position: relative; z-index: 2;
}

/* Beaker */
.beaker-col {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; position: relative;
}
.beaker-wrap {
  position: relative; width: 260px; height: 300px;
  display: flex; align-items: flex-end; justify-content: center;
}
.beaker {
  position: relative; width: 240px; height: 260px;
  border: 2.5px solid var(--line-bright); border-top: none;
  border-radius: 0 0 14px 14px;
  background: rgba(14, 22, 38, 0.4);
  overflow: hidden; backdrop-filter: blur(2px);
  box-shadow: inset 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 40px rgba(74, 184, 255, 0.08);
}
.beaker::before {
  content: ""; position: absolute; top: -2px; left: -6px;
  width: 12px; height: 16px;
  border: 2.5px solid var(--line-bright); border-right: none;
  border-radius: 8px 0 0 0; background: transparent;
}
.beaker::after {
  content: ""; position: absolute; top: -2px; right: -6px;
  width: 12px; height: 16px;
  border: 2.5px solid var(--line-bright); border-left: none;
  border-radius: 0 8px 0 0; background: transparent;
}
.liquid {
  position: absolute; left: 0; right: 0; bottom: 0; height: 60%;
  transition: height 0.4s, background 0.3s;
  background: linear-gradient(180deg, rgba(57, 217, 138, 0.4) 0%, rgba(57, 217, 138, 0.7) 100%);
  overflow: hidden;
}
.liquid::before {
  content: ""; position: absolute; top: -4px; left: -10%; right: -10%;
  height: 10px; background: inherit;
  border-radius: 50%; filter: blur(2px); opacity: 0.7;
}
.liquid .wave {
  position: absolute; top: -2px; left: -25%; right: -25%;
  height: 6px; background: rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  animation: titration-wave 3s ease-in-out infinite;
}
@keyframes titration-wave { 50% { transform: translateY(-2px); } }
.beaker-marks {
  position: absolute; right: 10px; top: 20px; bottom: 20px;
  width: 20px;
  display: flex; flex-direction: column; justify-content: space-between;
  font-family: var(--font-mono); font-size: 8px;
  color: var(--ink-dim);
}
.beaker-marks span {
  position: relative; padding-right: 8px; text-align: right;
}
.beaker-marks span::before {
  content: ""; position: absolute; right: 0; top: 50%;
  width: 4px; height: 1px; background: var(--line-bright);
}
.beaker-label {
  font-family: var(--font-en); font-size: var(--fs-label-en);
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink-soft); text-align: center;
}
.beaker-label b {
  color: var(--acid); font-weight: 600; display: block;
  font-family: var(--font-ar); font-size: var(--fs-xs);
  letter-spacing: 0;
}

/* pH strip */
.ph-strip {
  position: absolute; right: -80px; top: 0; bottom: 0; width: 60px;
  display: flex; flex-direction: column; justify-content: space-between;
  align-items: center; pointer-events: none;
}
.ph-strip .scale-bar {
  position: absolute; top: 0; bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 12px; border-radius: 6px;
  background: linear-gradient(180deg, #8c5cff 0%, #4ab8ff 25%, #39d98a 50%, #f5a623 75%, #ff5e6c 100%);
  border: 1.5px solid var(--line);
}
.ph-strip::before {
  content: "pH · قراءة";
  position: absolute; top: -18px; left: 50%; transform: translateX(-50%);
  font-family: var(--font-en); font-size: 8px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-dim); white-space: nowrap;
}
.ph-strip .marker {
  position: absolute; left: 50%; transform: translate(-50%, -50%);
  width: 0; height: 0;
  background: transparent; border: 0;
  transition: top 0.3s;
}
.ph-strip .marker::before {
  content: "◂";
  position: absolute; left: calc(50% + 9px); top: 50%;
  transform: translateY(-50%);
  font-size: 14px; line-height: 1; color: var(--ink);
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
}
.ph-strip .marker::after {
  content: attr(data-ph); position: absolute;
  left: calc(50% + 22px); top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono); font-size: var(--fs-tiny);
  font-weight: 500; color: var(--ink-soft);
  white-space: nowrap;
}
.ph-strip .tick {
  position: absolute; left: calc(50% + 8px);
  font-family: var(--font-mono); font-size: 8px;
  color: var(--ink-dim);
  transform: translateY(-50%);
}

/* Title meter (overlay أعلى يسار الـstage — physical positioning) */
.title-meter {
  position: absolute; top: 16px; left: 16px; z-index: 5;
  background: var(--panel);
  border: 1px solid var(--line-bright);
  border-radius: var(--r-md);
  padding: var(--sp-4) 14px;
  display: flex; align-items: center; gap: 14px;
}
.title-meter .big-ph {
  font-family: var(--font-mono); font-size: 36px;
  font-weight: 700; line-height: 1;
  letter-spacing: -0.02em;
}
.title-meter .lab { display: flex; flex-direction: column; }
.title-meter .lab .k {
  font-family: var(--font-en); font-size: var(--fs-label-en);
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink-soft);
}
.title-meter .lab .cls { font-size: var(--fs-small); font-weight: 600; }

/* endpoint flash — تحت الـtopbar، أسفل الـhook */
.endpoint-flash {
  position: absolute; top: 140px; right: var(--sp-6);
  z-index: 6;
  background: var(--panel);
  border: 1px solid var(--neutral); border-radius: var(--r-md);
  padding: var(--sp-3) 14px;
  font-family: var(--font-en); font-size: var(--fs-tiny);
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--neutral); font-weight: 600;
  opacity: 0; transform: translateY(-8px);
  transition: opacity 0.3s, transform 0.3s;
  border-left: 3px solid var(--neutral);
}
.endpoint-flash.show {
  opacity: 1; transform: translateY(0);
  animation: titration-pulse 1.2s ease-in-out infinite;
}
@keyframes titration-pulse { 50% { box-shadow: 0 0 20px rgba(57, 217, 138, 0.4); } }

/* هوك الدرس — override محلّيّ لتثبيت اليمين physical في RTL
   (الدرس يحتوي overlays physical في أعلى اليسار، فنحفظ الاتّساق) */
.lesson-stage .lesson-hook {
  inset-inline-end: auto;
  right: var(--sp-6); left: auto;
  top: var(--sp-6);
  max-width: 360px;
}


/* ============================================================
   RIGHT PANEL — HUD + chart + pH row + equations
   ============================================================ */

/* HUD — مُعاد تسميته إلى .titration-hud-cell لتفادي تصادم lesson-core */
.hud-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}
.titration-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;
}
.titration-hud-cell::before {
  content: ""; position: absolute; top: 0; left: 0;
  width: 3px; height: 100%;
  background: var(--cyan);
}
.titration-hud-cell.acid::before { background: var(--acid); }
.titration-hud-cell.base::before { background: var(--base); }
.titration-hud-cell.neutral::before { background: var(--neutral); }
.titration-hud-cell.warm::before { background: var(--warm); }
.titration-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);
}
.titration-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;
}
.titration-hud-cell .v {
  font-family: var(--font-mono); font-size: 18px;
  font-weight: 600; letter-spacing: -0.01em;
  line-height: 1.1; margin-top: var(--sp-1);
}
.titration-hud-cell .v small {
  font-size: var(--fs-tiny); font-weight: 400;
  color: var(--ink-soft); margin-inline-start: var(--sp-1);
}

/* Titration chart */
.chart {
  background: var(--panel-2);
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--sp-5); position: relative;
}
.chart h4 {
  margin: 0 0 var(--sp-3);
  font-size: var(--fs-xs); font-weight: 600;
}
.chart 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;
}
.chart canvas { width: 100%; height: 160px; display: block; }

/* Equations block — خصوصيّ للدرس (lesson-core بلا eq-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(--cyan); }

/* pH color row */
.ph-row {
  display: grid; grid-template-columns: repeat(15, 1fr);
  gap: 0; margin-top: 2px;
  border: 1px solid var(--line-bright);
  border-radius: var(--r-sm); overflow: hidden;
  height: 22px;
  direction: ltr;
}
.ph-row span {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: var(--fs-label-en);
  font-weight: 600; color: #000;
  position: relative;
}
.ph-row span.current {
  box-shadow: inset 0 0 0 2px #fff, inset 0 0 0 4px var(--bg);
}
.ph-row-legend {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: var(--fs-label-en);
  color: var(--ink-dim); margin-top: var(--sp-1);
}


/* ——— 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(--cyan); font-weight: 600; }
.lesson-layers__panel .year {
  font-family: var(--font-mono); color: var(--cyan);
  font-size: var(--fs-xs); margin-inline-end: var(--sp-2);
}
.lesson-layers__panel .arrow {
  font-family: var(--font-mono); color: var(--neutral);
  margin: 0 var(--sp-2);
}
