/* ==========================================================================
   MODUL 03: THE MUTATION LAB - I'LAL & IDGHAM PHONOSURGERY (PRESERVED)
   ========================================================================== */
:root {
    --bg-matte-black: #0B0C10;
    --bg-chamber: #161B24;
    --bg-glass-panel: rgba(22, 27, 36, 0.86);
    --fusion-violet-bright: #C39BD3;
    --fusion-violet-glow: rgba(155, 89, 182, 0.55);
    --border-crimson: rgba(255, 0, 127, 0.38);
    --border-violet: rgba(155, 89, 182, 0.42);

    --fs-ar-atom: clamp(1.85rem, 1.55rem + 1.2vw, 2.65rem);
    --fs-ar-word: clamp(1.65rem, 1.4rem + 1vw, 2.35rem);
    --fs-ar-rule: clamp(1.25rem, 1.1rem + 0.6vw, 1.65rem);
    --sp-xs: clamp(0.4rem, 0.35rem + 0.25vw, 0.65rem);
    --sp-sm: clamp(0.7rem, 0.55rem + 0.45vw, 1.05rem);
    --sp-md: clamp(1rem, 0.85rem + 0.75vw, 1.5rem);
    --sp-lg: clamp(1.4rem, 1.1rem + 1.1vw, 2.15rem);
    --ease-lab: 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

.lab-header {
    width: 100%;
    background: rgba(11, 12, 16, 0.86);
    border-bottom: 1px solid var(--border-cyan);
    padding: var(--sp-sm) var(--sp-lg);
}

.header-bar {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    flex-wrap: wrap;
}

.back-portal-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.42rem 0.92rem;
    border-radius: var(--radius-pill);
    background: var(--bg-chamber);
    border: 1px solid var(--border-cyan);
    color: var(--neon-cyan);
    font-size: var(--fs-xs);
    font-weight: 700;
    transition: all var(--ease-lab);
}

.back-portal-btn:hover {
    background: var(--neon-cyan);
    color: var(--bg-matte-black);
    box-shadow: 0 0 18px var(--neon-cyan-glow);
}

.lab-title-cluster { display: flex; flex-direction: column; }

.lab-main-title {
    font-size: var(--fs-md);
    font-weight: 800;
    letter-spacing: -0.01em;
    background: linear-gradient(90deg, #FFFFFF, var(--neon-cyan), var(--volcanic-crimson));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.lab-subtitle {
    font-family: var(--font-mono);
    font-size: var(--fs-2xs);
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.batch-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.42rem 0.95rem;
    border-radius: var(--radius-pill);
    font-size: var(--fs-xs);
    font-weight: 800;
    background: linear-gradient(135deg, var(--volcanic-crimson), var(--fusion-violet));
    color: #FFFFFF;
    box-shadow: 0 0 18px var(--volcanic-crimson-dim);
    transition: transform var(--ease-lab), box-shadow var(--ease-lab);
}

.batch-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 24px var(--volcanic-crimson-glow);
}

.reset-all-btn {
    padding: 0.42rem 0.85rem;
    border-radius: var(--radius-pill);
    font-size: var(--fs-xs);
    font-weight: 700;
    background: var(--bg-chamber);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: var(--text-secondary);
}

.reset-all-btn:hover { border-color: var(--neon-cyan); color: var(--neon-cyan); }

/* Workspace */
.lab-workspace {
    position: relative;
    z-index: 1;
    width: 100%;
    padding: var(--sp-md) var(--sp-lg) var(--sp-lg);
    display: flex;
    flex-direction: column;
    gap: var(--sp-md);
}

.telemetry-legend-strip {
    width: 100%;
    background: var(--bg-glass-panel);
    border: 1px solid var(--border-cyan);
    border-radius: var(--radius-md);
    padding: 0.65rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--sp-sm);
}

.legend-items-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: var(--fs-xs);
}

.legend-chip { display: inline-flex; align-items: center; gap: 0.45rem; font-weight: 600; color: var(--text-secondary); }
.dot-indicator { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-cyan { background: var(--neon-cyan); box-shadow: 0 0 8px var(--neon-cyan); }
.dot-crimson { background: var(--volcanic-crimson); box-shadow: 0 0 8px var(--volcanic-crimson); }
.dot-violet { background: var(--fusion-violet); box-shadow: 0 0 8px var(--fusion-violet); }
.dot-gold { background: var(--amber-gold); box-shadow: 0 0 8px var(--amber-gold); }

.lab-bench-split {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--sp-lg);
    align-items: start;
}

.chambers-grid {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--sp-md);
}

.mutation-chamber-card {
    background: var(--bg-glass-panel);
    border: 1.5px solid rgba(102, 252, 241, 0.2);
    border-radius: var(--radius-lg);
    padding: var(--sp-md);
    display: flex;
    flex-direction: column;
    gap: var(--sp-sm);
    position: relative;
    transition: all var(--ease-lab);
    box-shadow: 0 16px 36px -12px rgba(0, 0, 0, 0.85);
    cursor: pointer;
}

.mutation-chamber-card:hover { border-color: rgba(102, 252, 241, 0.48); }

.mutation-chamber-card.selected-chamber {
    border-color: var(--neon-cyan);
    box-shadow: 0 18px 42px -12px rgba(0, 0, 0, 0.92), 0 0 24px var(--neon-cyan-dim);
}

.mutation-chamber-card.chamber-idgham.selected-chamber {
    border-color: var(--fusion-violet);
    box-shadow: 0 18px 42px -12px rgba(0, 0, 0, 0.92), 0 0 26px var(--fusion-violet-dim);
}

.chamber-top-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-xs);
    flex-wrap: wrap;
}

.chamber-badge-code {
    font-family: var(--font-mono);
    font-size: var(--fs-2xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.18rem 0.6rem;
    border-radius: var(--radius-pill);
    background: var(--volcanic-crimson-dim);
    border: 1px solid var(--border-crimson);
    color: var(--volcanic-crimson);
    font-weight: 700;
}

.chamber-idgham .chamber-badge-code {
    background: var(--fusion-violet-dim);
    border-color: var(--border-violet);
    color: var(--fusion-violet-bright);
}

.chamber-state-pill {
    font-family: var(--font-mono);
    font-size: var(--fs-2xs);
    padding: 0.18rem 0.65rem;
    border-radius: var(--radius-pill);
    background: rgba(11, 12, 16, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-secondary);
}

.chamber-state-pill.mutated-pill {
    background: var(--neon-cyan-dim);
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
    font-weight: 700;
}

.chamber-title-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.chamber-title { font-size: var(--fs-md); font-weight: 800; color: var(--text-primary); }
.chamber-arabic-subtitle { font-family: var(--font-arabic); font-size: 1.2rem; color: var(--amber-gold); font-weight: 700; }

.specimen-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.38rem;
    padding: 0.25rem 0;
}

.specimen-tab {
    padding: 0.24rem 0.65rem;
    border-radius: var(--radius-sm);
    background: rgba(11, 12, 16, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: var(--fs-2xs);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.specimen-tab:hover,
.specimen-tab.active {
    background: rgba(102, 252, 241, 0.14);
    border-color: var(--neon-cyan);
    color: var(--text-primary);
}

.specimen-tab .sp-ar {
    font-family: var(--font-arabic);
    font-size: 1rem;
    color: var(--amber-gold);
    font-weight: 700;
}

/* Containment Stage & Kinetic Atoms */
.containment-stage {
    width: 100%;
    min-height: 158px;
    background: radial-gradient(circle at 50% 50%, rgba(30, 37, 50, 0.9), #090B0E 90%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    padding: var(--sp-md) var(--sp-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    position: relative;
    overflow: hidden;
}

.atoms-track-rtl {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    justify-content: center;
    gap: clamp(0.5rem, 2vw, 1.15rem);
    position: relative;
    z-index: 2;
}

.atom-node-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    position: relative;
    transition: all 520ms cubic-bezier(0.22, 1, 0.36, 1);
}

.atom-orb {
    width: clamp(64px, 7.5vw, 80px);
    height: clamp(64px, 7.5vw, 80px);
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #242E3D, #0B0C10 85%);
    border: 2px solid var(--neon-cyan);
    box-shadow: 0 0 18px var(--neon-cyan-dim), inset 0 0 12px rgba(102, 252, 241, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 480ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.atom-orb.volatile-illah {
    border-color: var(--volcanic-crimson);
    background: radial-gradient(circle at 30% 30%, #3D142B, #0B0C10 85%);
    box-shadow: 0 0 24px var(--volcanic-crimson-dim), inset 0 0 15px rgba(255, 0, 127, 0.28);
    animation: volatileTremor 2.4s ease-in-out infinite;
}

.atom-orb.stabilized-madd {
    border-color: var(--amber-gold);
    background: radial-gradient(circle at 30% 30%, #3A3014, #0B0C10 85%);
    box-shadow: 0 0 26px var(--amber-gold-glow), inset 0 0 15px rgba(212, 175, 55, 0.28);
    animation: none;
}

.atom-orb.idgham-twin {
    border-color: var(--fusion-violet);
    background: radial-gradient(circle at 30% 30%, #2D1B38, #0B0C10 85%);
    box-shadow: 0 0 22px var(--fusion-violet-dim), inset 0 0 14px rgba(155, 89, 182, 0.3);
}

.atom-orb.idgham-fused-core {
    border: 2.5px solid #E056FD;
    background: radial-gradient(circle at 30% 30%, #4A1C64, #0B0C10 85%);
    box-shadow: 0 0 32px var(--fusion-violet-glow), 0 0 12px var(--neon-cyan);
    transform: scale(1.08);
}

.atom-glyph { font-family: var(--font-arabic); font-size: var(--fs-ar-atom); font-weight: 700; color: var(--neon-cyan); line-height: 1; }
.atom-orb.volatile-illah .atom-glyph { color: var(--volcanic-crimson); text-shadow: 0 0 12px var(--volcanic-crimson-glow); }
.atom-orb.stabilized-madd .atom-glyph { color: var(--amber-gold); text-shadow: 0 0 14px var(--amber-gold-glow); }
.atom-orb.idgham-twin .atom-glyph,
.atom-orb.idgham-fused-core .atom-glyph { color: var(--fusion-violet-bright); text-shadow: 0 0 14px var(--fusion-violet-glow); }

.atom-harakat-badge {
    position: absolute;
    top: -10px;
    right: -6px;
    background: #0B0C10;
    border: 1.5px solid var(--amber-gold);
    color: var(--amber-gold);
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 800;
    padding: 0.1rem 0.42rem;
    border-radius: var(--radius-pill);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.9);
    z-index: 5;
    white-space: nowrap;
}

.atom-harakat-badge.shaddah-crown {
    background: linear-gradient(135deg, var(--fusion-violet), var(--volcanic-crimson));
    border-color: #FFFFFF;
    color: #FFFFFF;
    box-shadow: 0 0 16px var(--fusion-violet-glow);
}

.atom-pos-caption { font-family: var(--font-mono); font-size: 0.64rem; color: var(--text-muted); }

/* Kinetic Animations */
.qalb-melting .atom-orb.volatile-illah { animation: qalbThermalMelt 760ms cubic-bezier(0.4, 0, 0.2, 1) forwards; }

@keyframes qalbThermalMelt {
    0% { transform: scale(1); filter: blur(0px); }
    45% { transform: scale(1.22, 0.68) rotate(8deg); background: var(--volcanic-crimson); box-shadow: 0 0 40px var(--volcanic-crimson); filter: blur(2px); }
    75% { transform: scale(0.85, 1.18) rotate(-4deg); background: var(--amber-gold); }
    100% { transform: scale(1); filter: blur(0px); }
}

.iskan-sliding-vowel { animation: slideVowelToPrecedingRight 680ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }

@keyframes slideVowelToPrecedingRight {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(38px, -18px) scale(1.35); background: var(--neon-cyan); color: #0B0C10; box-shadow: 0 0 22px var(--neon-cyan); }
    100% { transform: translate(76px, 0) scale(1); }
}

.sukun-crash-warning {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--volcanic-crimson);
    background: var(--volcanic-crimson-dim);
    border: 1px solid var(--border-crimson);
    padding: 0.2rem 0.65rem;
    border-radius: var(--radius-pill);
}

.sukun-crash-warning.resolved {
    color: var(--neon-cyan);
    background: var(--neon-cyan-dim);
    border-color: var(--neon-cyan);
}

.atom-node-wrapper.hadzf-dissolved {
    opacity: 0;
    transform: scale(0.1) translateY(-28px) rotate(24deg);
    filter: blur(8px);
    max-width: 0;
    margin: 0 -0.5rem;
    pointer-events: none;
}

.atom-node-wrapper.idgham-absorbed {
    opacity: 0;
    transform: translateX(52px) scale(0.2);
    max-width: 0;
    margin: 0 -0.5rem;
    pointer-events: none;
}

@keyframes volatileTremor {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-4px); }
}

.chamber-equation-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(11, 12, 16, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.85rem;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.eq-formula-ar { font-family: var(--font-arabic); font-size: var(--fs-ar-word); font-weight: 700; color: var(--text-primary); }
.chamber-controls-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding-top: 0.25rem; }

.mutate-trigger-btn {
    flex: 1;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-pill);
    font-size: var(--fs-xs);
    font-weight: 800;
    background: linear-gradient(90deg, var(--volcanic-crimson), #D4145A);
    color: #FFFFFF;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    box-shadow: 0 0 16px var(--volcanic-crimson-dim);
}

.mutate-trigger-btn:hover { transform: translateY(-2px); box-shadow: 0 0 24px var(--volcanic-crimson-glow); }

.mutate-trigger-btn.violet-btn {
    background: linear-gradient(90deg, var(--fusion-violet), #8E44AD);
    box-shadow: 0 0 16px var(--fusion-violet-dim);
}

.mutate-trigger-btn.violet-btn:hover { box-shadow: 0 0 24px var(--fusion-violet-glow); }

.chamber-reset-btn {
    padding: 0.55rem 0.9rem;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.14);
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-secondary);
}

.chamber-reset-btn:hover { border-color: var(--neon-cyan); color: var(--neon-cyan); }

/* Kaidah Rule Dossier */
.kaidah-dossier-panel {
    background: var(--bg-glass-panel);
    border: 1.5px solid var(--border-gold);
    border-radius: var(--radius-lg);
    padding: var(--sp-lg);
    display: flex;
    flex-direction: column;
    gap: var(--sp-md);
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.9), 0 0 28px var(--amber-gold-dim);
    position: sticky;
    top: 82px;
}

.dossier-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding-bottom: var(--sp-xs);
    border-bottom: 1px solid rgba(212, 175, 55, 0.25);
}

.dossier-kicker {
    font-family: var(--font-mono);
    font-size: var(--fs-2xs);
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--amber-gold);
    font-weight: 700;
}

.classical-rule-box {
    background: rgba(11, 12, 16, 0.88);
    border: 1px solid var(--border-gold);
    border-right: 4px solid var(--amber-gold);
    border-radius: var(--radius-md);
    padding: var(--sp-md);
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.classical-arabic-kaidah { font-family: var(--font-arabic); font-size: var(--fs-ar-rule); color: var(--amber-gold); font-weight: 700; }
.kaidah-translation { font-size: var(--fs-xs); color: var(--text-primary); font-style: italic; }

.surgical-protocol-steps { display: flex; flex-direction: column; gap: 0.5rem; }

.protocol-step-row {
    background: rgba(18, 23, 31, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.75rem;
    display: grid;
    grid-template-columns: 26px 1fr;
    gap: 0.6rem;
    align-items: start;
}

.step-num-circle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--neon-cyan-dim);
    border: 1px solid var(--neon-cyan);
    color: var(--neon-cyan);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

.step-content-col { display: flex; flex-direction: column; gap: 0.12rem; }
.step-label { font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase; color: var(--electric-mint); font-weight: 700; }
.step-desc { font-size: var(--fs-xs); color: var(--text-secondary); }

.telemetry-log-box {
    background: #08090C;
    border: 1px solid rgba(102, 252, 241, 0.18);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.8rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--neon-cyan);
    max-height: 125px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

@media screen and (min-width: 768px) {
    .chambers-grid { grid-template-columns: repeat(2, 1fr); }
}

@media screen and (min-width: 1240px) {
    .lab-bench-split { grid-template-columns: 1.45fr 1fr; }
}
