
/* The interactive page of a delivered project (interactive_page.py fills it): the real board assembling group by group,
   a card per part saying why it was chosen, and -- when the controller can be simulated -- the project's real program
   running live. Every control floats over the 3D in glass; phones turn the side panels into bottom sheets. Two looks:
   studio (dark, lets the lights glow) and lab (light). */
.app {
  --bg: #050f0b;
  --glass: rgba(8, 23, 17, 0.74); --glass-2: rgba(11, 30, 23, 0.94);
  --line: rgba(192, 160, 80, 0.22); --line-soft: rgba(252, 252, 248, 0.08);
  --fg: #fcfcf8; --muted: #a8baaf; --gold: #c0a050; --on-gold: #1a1405;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.38);
  --font: "IBM Plex Sans Arabic", "IBM Plex Sans", "Segoe UI", Tahoma, Arial, sans-serif;
  --mono: "IBM Plex Mono", Consolas, "Courier New", monospace;
  --gut: max(16px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  color-scheme: dark;
}
.app[data-look="lab"] {
  --bg: #edf2ee;
  --glass: rgba(255, 255, 255, 0.82); --glass-2: rgba(255, 255, 255, 0.96);
  --line: rgba(0, 68, 47, 0.16); --line-soft: rgba(0, 68, 47, 0.07);
  --fg: #0d2a20; --muted: #4c695c; --gold: #9a782c; --on-gold: #fffaf0;
  --shadow: 0 12px 32px rgba(0, 40, 28, 0.13);
  color-scheme: light;
}
.app [hidden], .app[hidden] { display: none !important; }
.app { font-family: var(--font); font-size: 15px; line-height: 1.55; --tl: 96px; position: relative; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg); }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.glass { background: var(--glass); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); backdrop-filter: blur(14px) saturate(1.15); -webkit-backdrop-filter: blur(14px) saturate(1.15); }
.app button { font-family: var(--font); color: inherit; }
.app button:focus-visible, .app input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.app svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.top { position: absolute; top: 14px; left: var(--gut); right: var(--gut); z-index: 6; display: flex; align-items: center; gap: 10px; pointer-events: none; }
.top > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 7px 14px 7px 10px; min-width: 0; margin-inline-end: auto; }
.brand img { width: 32px; height: 32px; flex: none; }
.brand .nm { min-width: 0; }
.brand b { display: block; font-size: 1rem; font-weight: 700; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.brand small { display: block; font-size: 0.74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions { display: flex; align-items: center; gap: 2px; padding: 4px; }
.icon { width: 36px; height: 36px; border-radius: 11px; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; font: 600 0.78rem var(--mono); }
.icon:hover { background: var(--line-soft); }
.tour { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; font-weight: 700; background: var(--gold); color: var(--on-gold); border: 0; border-radius: 11px; padding: 8px 14px; cursor: pointer; white-space: nowrap; }
.tour svg.i { width: 15px; height: 15px; }

.live { position: absolute; top: 80px; inset-inline-end: var(--gut); width: 296px; z-index: 5; padding: 12px 14px; display: grid; gap: 8px; max-height: calc(100% - var(--tl) - 120px); overflow: auto; box-sizing: border-box; }
.lhead { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0; padding: 0; cursor: pointer; text-align: start; }
.lhead h2 { margin: 0; font-size: 0.95rem; font-weight: 700; flex: 1; }
.beat { width: 8px; height: 8px; border-radius: 50%; background: #4be37a; box-shadow: 0 0 10px #4be37a; flex: none; }
.lhead .chev { transition: transform 0.2s; color: var(--muted); }
.live.closed .lbody { display: none; }
.live.closed .chev { transform: rotate(180deg); }
.lbody { display: grid; gap: 10px; }
.badge { margin: 0; font-size: 0.78rem; color: var(--muted); }
.inp { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; }
.inp label { font-size: 0.84rem; font-weight: 600; }
.inp output { font: 600 0.9rem var(--mono); direction: ltr; unicode-bidi: isolate; }
.inp input { grid-column: 1 / -1; width: 100%; accent-color: var(--gold); direction: ltr; margin: 0; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; font-size: 0.82rem; font-weight: 600; background: transparent; color: var(--muted); border: 0; padding: 7px 10px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--gold); color: var(--on-gold); }
.tgl p { margin: 0 0 4px; font-size: 0.82rem; font-weight: 600; }
.outs { display: grid; gap: 4px; }
.out { display: flex; align-items: center; gap: 8px; font-size: 0.84rem; color: var(--muted); }
.out i { width: 12px; height: 12px; border-radius: 50%; background: rgba(127, 140, 133, 0.25); border: 1px solid var(--line); flex: none; }
.out.on { color: var(--fg); }
.out.on i { background: var(--c); box-shadow: 0 0 10px var(--c); }
.app dl.kv { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 12px; font-size: 0.82rem; }
.app dl.kv dt { color: var(--muted); }
.app dl.kv dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; text-align: left; }
.app[dir="ltr"] dl.kv dd { text-align: right; }
.note { margin: 0; font-size: 0.78rem; color: var(--muted); }

.partsbtn { position: absolute; top: 80px; inset-inline-start: var(--gut); z-index: 5; display: flex; align-items: center; gap: 8px; padding: 9px 14px; cursor: pointer; font-size: 0.88rem; font-weight: 600; border-radius: 14px; }
.partsbtn .n { font: 600 0.76rem var(--mono); color: var(--gold); }
.drawer { position: absolute; top: 80px; bottom: calc(var(--tl) + 26px); inset-inline-start: var(--gut); width: 300px; z-index: 7; display: flex; flex-direction: column; padding: 12px; gap: 8px; box-sizing: border-box; }
.dhead { display: flex; align-items: center; gap: 8px; }
.dhead h2 { margin: 0; font-size: 0.95rem; font-weight: 700; flex: 1; }
.search { width: 100%; box-sizing: border-box; font: 500 0.86rem var(--font); color: var(--fg); background: var(--line-soft); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; }
.plist { overflow: auto; min-height: 0; display: grid; gap: 2px; align-content: start; }
.pgroup { font-size: 0.74rem; font-weight: 700; color: var(--gold); padding: 8px 6px 2px; }
.prow { display: flex; align-items: center; gap: 10px; width: 100%; text-align: start; background: transparent; border: 0; border-radius: 9px; padding: 5px 6px; cursor: pointer; font-size: 0.86rem; }
.prow:hover, .prow.sel { background: var(--line-soft); }
.prow .r { flex: none; font: 600 0.78rem var(--mono); color: var(--gold); min-width: 3.1em; }

.callout { position: absolute; z-index: 8; width: min(340px, calc(100% - 32px)); padding: 14px 16px 16px; display: grid; gap: 8px; background: var(--glass-2); box-sizing: border-box; }
.chead { display: flex; align-items: flex-start; gap: 10px; }
.chead .t { flex: 1; min-width: 0; }
.chead .ref { font: 600 0.78rem var(--mono); color: var(--gold); }
.chead h3 { margin: 0; font-size: 1.02rem; font-weight: 700; line-height: 1.35; }
.why { margin: 0; font-size: 0.9rem; line-height: 1.7; }
.why b { color: var(--gold); font-weight: 700; margin-inline-end: 4px; }
.why bdi { unicode-bidi: isolate; direction: ltr; white-space: nowrap; }
.facts { display: flex; flex-wrap: wrap; gap: 6px; }
.facts span { font: 500 0.74rem var(--mono); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; color: var(--muted); }
.facts span i { font: 500 0.74rem var(--font); font-style: normal; margin-inline-end: 5px; }
.gparts { display: flex; flex-wrap: wrap; gap: 6px; }
.gparts button { font: 600 0.76rem var(--mono); background: var(--line-soft); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; cursor: pointer; color: var(--gold); }

.hot { position: absolute; z-index: 4; transform: translate(-50%, -50%); width: 30px; height: 30px; border-radius: 50%; background: var(--gold); color: var(--on-gold); font: 700 0.8rem var(--mono); border: 2px solid rgba(255, 255, 255, 0.85); box-shadow: 0 0 0 6px rgba(192, 160, 80, 0.22); cursor: pointer; display: grid; place-items: center; padding: 0; }
.hot .lbl { position: absolute; top: 50%; inset-inline-start: 36px; transform: translateY(-50%); white-space: nowrap; background: var(--glass-2); color: var(--fg); border: 1px solid var(--line); padding: 2px 9px; border-radius: 8px; font: 600 0.78rem var(--font); opacity: 0; transition: opacity 0.15s; pointer-events: none; }
.hot:hover .lbl, .hot:focus-visible .lbl { opacity: 1; }

.timeline { position: absolute; bottom: 14px; left: var(--gut); right: var(--gut); max-width: 880px; margin-inline: auto; z-index: 6; padding: 10px 16px 12px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; align-items: center; }
.tnow { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.tnow .cnt { font: 600 0.74rem var(--mono); color: var(--gold); flex: none; direction: ltr; unicode-bidi: isolate; }
.tnow .ttl { font-weight: 700; flex: none; }
.tnow .dsc { color: var(--muted); font-size: 0.84rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbtns { display: flex; gap: 2px; }
.tbtns .icon.play { background: var(--gold); color: var(--on-gold); }
.track { position: relative; height: 34px; }
.rail { position: absolute; inset-inline: 0; top: 50%; height: 4px; margin-top: -2px; border-radius: 4px; background: var(--line); }
.fill { position: absolute; inset-inline-start: 0; top: 50%; height: 4px; margin-top: -2px; border-radius: 4px; background: var(--gold); width: 0; }
.tick { position: absolute; top: 50%; width: 12px; height: 12px; margin-top: -6px; margin-inline-start: -6px; border-radius: 50%; background: var(--bg); border: 2px solid var(--line); padding: 0; z-index: 1; }
.tick.done { background: var(--gold); border-color: var(--gold); }
.knob { position: absolute; top: 50%; width: 20px; height: 20px; margin-top: -10px; margin-inline-start: -10px; border-radius: 50%; background: var(--fg); box-shadow: 0 0 0 4px rgba(192, 160, 80, 0.45); pointer-events: none; z-index: 2; }
.track input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 3; }
.hint { position: absolute; bottom: calc(var(--tl) + 24px); left: 50%; transform: translateX(-50%); z-index: 3; font-size: 0.78rem; color: var(--muted); background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 4px 14px; white-space: nowrap; pointer-events: none; transition: opacity 0.4s; }
.tip { position: absolute; z-index: 9; pointer-events: none; background: var(--glass-2); border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px; font-size: 0.8rem; white-space: nowrap; transform: translate(-50%, calc(-100% - 12px)); }
.tip b { font-family: var(--mono); color: var(--gold); margin-inline-end: 6px; }
.loader { position: absolute; inset: 0; z-index: 20; display: grid; place-content: center; justify-items: center; gap: 14px; background: var(--bg); text-align: center; padding: 16px; }
.loader img { width: 150px; height: auto; }
.loader .bar { width: 220px; max-width: 70vw; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.loader .bar div { height: 100%; width: 0; background: var(--gold); transition: width 0.2s; }
.loader p { margin: 0; color: var(--muted); font-size: 0.9rem; }

/* build it yourself: the mode switch, the schematic beside the 3D (the 3D keeps the start side) */
.modes { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-inline-end: 4px; }
.modes button { font-size: 0.8rem; font-weight: 700; background: transparent; color: var(--muted); border: 0; padding: 7px 12px; cursor: pointer; white-space: nowrap; }
.modes button[aria-pressed="true"] { background: var(--gold); color: var(--on-gold); }
.modes .sm { display: none; }
.app.split #view { width: 58%; inset-inline-end: auto; }
.schem-pane { position: absolute; top: 80px; bottom: calc(var(--tl) + 26px); inset-inline-end: var(--gut); width: calc(42% - 2 * var(--gut)); z-index: 5; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; box-sizing: border-box; }
.schem-pane .shead { display: flex; align-items: center; gap: 8px; }
.schem-pane h2 { margin: 0; font-size: 0.95rem; font-weight: 700; flex: 1; }
.schem-pane #sch { flex: 1; min-height: 0; overflow: auto; display: grid; place-items: start center; }
.schem { width: 100%; max-width: 520px; height: auto; color: var(--fg); }
.schem path, .schem rect { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.schem .box { stroke: var(--line); fill: var(--line-soft); }
.schem .part { fill: var(--glass-2); }
.schem .led { stroke: var(--c); fill: none; }
.schem .ray { stroke-width: 1.2; }
.schem text { fill: var(--muted); font: 600 9px var(--mono); stroke: none; direction: ltr; unicode-bidi: isolate; }
.schem text.strong { fill: var(--fg); font-size: 10px; }
.schem text.pin { fill: var(--gold); }
.schem text.sm { font-size: 8px; }
.app[dir="rtl"] .schem .l-en, .app[dir="ltr"] .schem .l-ar { display: none; }
.schem text.l-ar { font-family: var(--font); font-size: 10px; }
.schem g[data-k] { cursor: pointer; transition: opacity 0.2s; }
.schem g.future { opacity: 0.22; }
.schem g.now path, .schem g.now rect, .schem g.hl path, .schem g.hl rect { stroke: var(--gold); }
.schem g.hl path, .schem g.hl rect { stroke-width: 2.6; }
.schem g.lit .led { fill: var(--c); filter: drop-shadow(0 0 4px var(--c)); }
.schem g.flow path { stroke: var(--c); stroke-dasharray: 5 5; animation: flow 0.7s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -10; } }
.schem-pane .live { position: static; width: auto; max-height: none; box-shadow: none; background: transparent; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 10px 0 0; backdrop-filter: none; -webkit-backdrop-filter: none; }
.app.split .hint { display: none; }
.app.split .partsbtn, .app.split .drawer { inset-inline-start: auto; inset-inline-end: calc(42% + var(--gut)); }
.stepbtn { justify-self: start; font-size: 0.8rem; font-weight: 700; background: var(--line-soft); border: 1px solid var(--line); color: var(--gold); border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.schembtn { display: none; align-items: center; gap: 8px; padding: 9px 14px; cursor: pointer; font-size: 0.88rem; font-weight: 600; border-radius: 14px; }

/* a public lesson (learn_section.py): its goals before the first step, «عندك فكرة؟» in the timeline at the last one */
.intro { position: absolute; z-index: 15; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(440px, calc(100% - 2 * var(--gut))); max-height: calc(100% - 150px); overflow: auto; padding: 20px 22px; display: grid; gap: 10px; background: var(--glass-2); box-sizing: border-box; }
.intro .lvl { justify-self: start; font-size: 0.74rem; font-weight: 700; color: var(--gold); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }
.intro h2 { margin: 0; font-size: 1.2rem; font-weight: 700; line-height: 1.35; padding-inline-end: 36px; }
.intro p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.intro h3 { margin: 4px 0 0; font-size: 0.86rem; font-weight: 700; color: var(--gold); }
.intro ul { margin: 0; padding-inline-start: 1.2em; display: grid; gap: 6px; font-size: 0.9rem; line-height: 1.6; }
.intro .go { font-size: 0.95rem; font-weight: 700; background: var(--gold); color: var(--on-gold); border: 0; border-radius: 12px; padding: 10px 16px; cursor: pointer; margin-top: 4px; }
.intro .x { position: absolute; top: 12px; inset-inline-end: 12px; }
.intro bdi { unicode-bidi: isolate; direction: ltr; }
.cta { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 10px; }
.cta .ct { flex: 1; min-width: 200px; font-size: 0.88rem; }
.cta .ct b { color: var(--gold); margin-inline-end: 6px; }
.cta a { font-size: 0.86rem; font-weight: 700; background: var(--gold); color: var(--on-gold); border-radius: 11px; padding: 8px 16px; text-decoration: none; white-space: nowrap; }
.app a.icon { color: inherit; text-decoration: none; }

@media (max-width: 760px) {
  .app.split #view { width: 100%; }
  .schem-pane { top: auto; bottom: calc(var(--tl) + 26px); inset-inline: var(--gut); width: auto; height: 46vh; }
  .schem-pane.closed { display: none; }
  .schembtn { display: flex; position: absolute; top: 74px; inset-inline-end: var(--gut); z-index: 5; }
  .app.split .partsbtn, .app.split .drawer { inset-inline-end: auto; inset-inline-start: var(--gut); }
  .app.split .tnow { flex-wrap: wrap; row-gap: 2px; }
  .app.split .tnow .dsc { display: block; white-space: normal; flex-basis: 100%; font-size: 0.8rem; line-height: 1.45; }
  .modes button { padding: 6px 9px; font-size: 0.74rem; }
  /* a phone's bar keeps what it needs: the light switch and full screen step aside, the modes take their short names */
  #look, #full { display: none; }
  .modes .lg { display: none; }
  .modes .sm { display: inline; }
  .brand small { display: none; }
  .brand b { max-width: 40vw; }
  .tour .txt { display: none; }
  .live { top: auto; bottom: calc(var(--tl) + 26px); inset-inline: var(--gut); width: auto; max-height: 44vh; }
  .live.closed { inset-inline-start: auto; }
  .partsbtn { top: 74px; }
  .drawer { top: auto; bottom: calc(var(--tl) + 26px); inset-inline-end: var(--gut); width: auto; height: 48vh; }
  .callout { left: var(--gut) !important; right: var(--gut) !important; top: auto !important; bottom: calc(var(--tl) + 26px) !important; width: auto; max-height: 44vh; overflow: auto; }
  .tnow .dsc { display: none; }
  .hint { display: none; }
}
@media (prefers-reduced-motion: reduce) { .lhead .chev, .hot .lbl, .hint { transition: none; } .schem g.flow path { animation: none; } }

/* ── تكييف الصفحة داخل قالب الموقع ── */
.plant-stage{background:#050f0b}
.plant-stage .app{height:calc(100vh - 150px);height:calc(100svh - var(--stage-off,150px));min-height:560px}
