/* ============================================================
   atom_drawer_chem.css — Styles for the Atom Drawer exercise
   ============================================================
   Load AFTER style.css and exercises.css (it reuses .check-step-btn
   and the problem-picker styles from exercises.css).
   Rules that touch headings/lists/paragraphs are scoped under
   .notes-content so they beat style.css's typography rules without
   needing !important.
   ============================================================ */

.notes-content [hidden] { display: none !important; }

/* ── Header: question + picker ── */
.ad-top-header {
    display: flex;
    align-items: stretch;
    gap: 16px;
    margin-bottom: 14px;
}

.ad-prompt-box {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    background: var(--bg-card);
    border: 2px solid var(--accent-blue);
    border-radius: 12px;
    padding: 14px 22px;
    box-shadow: var(--shadow-soft);
}

.ad-prompt-text {
    font-size: clamp(1.15rem, 1rem + 1vw, 1.6rem);
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-heading);
}

.ad-prompt-hint {
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--text-secondary);
}

/* ── Workspace ── */
.ad-workspace {
    display: grid;
    /* Gave the table (first column) more width so it doesn't get squished */
    grid-template-columns: minmax(380px, 1.3fr) minmax(0, 1.5fr) minmax(320px, 1fr);
    gap: 24px;
    align-items: start;
}

/* ── Mini Periodic Table ── */
.ad-pt-area {
    background: var(--bg-card);
    border: 2px solid var(--border-main);
    border-radius: 16px;
    padding: 14px;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ad-pt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-blue);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
    padding: 0 4px;
}

.ad-pt-link {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-decoration: none;
    text-transform: none;
    transition: color 0.15s;
}
.ad-pt-link:hover {
    color: var(--accent-blue);
    text-decoration: underline;
}

.ad-pt-grid {
    display: grid;
    grid-template-columns: repeat(19, minmax(0, 1fr));
    gap: 3px; /* Increased from 1px to give the cells breathing room */
    width: 100%;
}

.ad-pt-num {
    font-size: clamp(0.4rem, 0.7vw, 0.6rem);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
}

.ad-pt-cell {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.45rem, 0.9vw, 0.7rem); /* Scaled up text */
    background: var(--bg-header);
    color: var(--text-primary);
    border: 1px solid rgba(255,255,255,0.04);
    border-left-width: 2px; /* Thinner category border */
    border-radius: 2px;
    transition: transform 0.15s, outline 0.15s;
    user-select: none;
}

.ad-pt-cell .ad-pt-num { font-size: 0.65em; opacity: 0.7; line-height: 1; margin-top: 2px; }
.ad-pt-cell .ad-pt-sym { font-weight: 700; line-height: 1; margin-bottom: 2px; }

/* Category colors matching the main periodic table borders */
.ad-pt-cell.alkali { border-left-color: #e68a00; }
.ad-pt-cell.alkaline-earth { border-left-color: #f1c40f; }
.ad-pt-cell.transition-metal { border-left-color: #5b9cf6; }
.ad-pt-cell.post-transition { border-left-color: #1abc9c; }
.ad-pt-cell.metalloid { border-left-color: #2ecc71; }
.ad-pt-cell.nonmetal { border-left-color: #3498db; }
.ad-pt-cell.halogen { border-left-color: #3b82f6; }
.ad-pt-cell.noble-gas { border-left-color: #9b59b6; }
.ad-pt-cell.lanthanide { border-left-color: #e84393; }
.ad-pt-cell.actinide { border-left-color: #d63031; }

.ad-pt-cell.highlight {
    outline: 2px solid var(--accent-amber);
    outline-offset: 1px;
    transform: scale(1.2);
    z-index: 10;
    box-shadow: 0 0 10px var(--accent-amber);
    background: var(--bg-card);
}

/* ── Detail Panel ── */
.ad-detail-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    background: var(--bg-header);
    border: 2px solid var(--border-main);
    border-radius: 8px;
    margin-top: 4px;
}

.ad-detail-panel .detail-header {
    display: flex;
    align-items: center;
    gap: 14px;
}

.ad-detail-panel .detail-symbol-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    border-radius: 6px;
    border-left: 4px solid;
    background: var(--bg-card);
}

.ad-detail-panel .detail-symbol-num { font-size: 0.75rem; color: var(--text-secondary); line-height: 1; margin-bottom: 2px; }
.ad-detail-panel .detail-symbol-sym { font-size: 1.4rem; font-weight: 700; color: var(--text-primary); line-height: 1; }
.ad-detail-panel .detail-name { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); margin-bottom: 2px; }
.ad-detail-panel .detail-meta { font-size: 0.8rem; color: var(--text-secondary); }
.ad-detail-panel .detail-desc { font-size: 0.85rem; line-height: 1.4; color: var(--text-primary); margin: 0; }

/* Category Colors for the Symbol Box */
.ad-detail-panel .detail-symbol-box.alkali { border-left-color: #e68a00; }
.ad-detail-panel .detail-symbol-box.alkaline-earth { border-left-color: #f1c40f; }
.ad-detail-panel .detail-symbol-box.transition-metal { border-left-color: #5b9cf6; }
.ad-detail-panel .detail-symbol-box.post-transition { border-left-color: #1abc9c; }
.ad-detail-panel .detail-symbol-box.metalloid { border-left-color: #2ecc71; }
.ad-detail-panel .detail-symbol-box.nonmetal { border-left-color: #3498db; }
.ad-detail-panel .detail-symbol-box.halogen { border-left-color: #3b82f6; }
.ad-detail-panel .detail-symbol-box.noble-gas { border-left-color: #9b59b6; }
.ad-detail-panel .detail-symbol-box.lanthanide { border-left-color: #e84393; }
.ad-detail-panel .detail-symbol-box.actinide { border-left-color: #d63031; }

/* Left: canvas */
.ad-canvas-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.ad-canvas-wrapper {
    position: relative;
    width: 100%;
    max-width: 620px;
    margin: 0 auto;
    border-radius: 16px;
}

.ad-svg-container {
    width: 100%;
    aspect-ratio: 1 / 1;
    background:
        radial-gradient(circle at center, rgba(91, 156, 246, 0.08), transparent 68%),
        var(--bg-card);
    border: 2px solid var(--border-main);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

.ad-svg-container svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* When the configuration box is showing, reserve a strip at the bottom of the
   canvas so the drawing shrinks and sits above the box instead of under it */
.ad-canvas-wrapper:has(.ad-config-area:not([hidden])) .ad-svg-container {
    box-sizing: border-box;
    padding-bottom: 120px;
    background-origin: content-box; /* center the glow on the atom, not the whole box */
    background-repeat: no-repeat;   /* stop the glow tiling into the bottom strip */
}

/* Drawing elements */
.ad-shell {
    fill: none;
    stroke: rgba(160, 168, 188, 0.55);
    stroke-width: 2;
    pointer-events: none;
    transition: stroke 0.15s, stroke-width 0.15s;
}
.ad-shell.drop-target {
    stroke: var(--accent-green);
    stroke-width: 4;
}
.ad-shell-hit {
    fill: none;
    stroke: transparent;
    stroke-width: 24;
    pointer-events: stroke;
    cursor: copy;
}

.ad-electron-g { cursor: pointer; }
.ad-electron-hit { fill: transparent; }
.ad-electron {
    fill: none;
    stroke: #e53935; /* Red X */
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke 0.15s;
}
.ad-electron-g:hover .ad-electron { stroke: #ff7b78; } /* Lighter red on hover */
.ad-electron-g:hover .ad-electron { fill: #ff7b78; }   /* hints that clicking removes it */

.ad-nucleus { fill: var(--bg-header); stroke: var(--accent-blue); stroke-width: 2.5; }
.ad-nucleus-text {
    fill: var(--text-primary);
    font-family: monospace;
    font-size: 14px;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}
.ad-bracket { fill: none; stroke: var(--text-primary); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.ad-charge-text {
    fill: var(--accent-amber);
    font-family: sans-serif;
    font-size: 24px;
    font-weight: bold;
    pointer-events: none;
}

/* Footer under the canvas: toggle switches */
.ad-canvas-footer {
    display: flex;
    justify-content: flex-end;
    max-width: 620px;
    width: 100%;
    margin: 0 auto;
    padding-top: 4px;
}

.ad-toggle-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.ad-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}
.ad-checkbox-label input { width: 18px; height: 18px; accent-color: var(--accent-green); cursor: pointer; }

.ad-config-area {
    position: absolute;
    bottom: 8px; /* Brings it just inside the bottom border */
    left: 8px;
    right: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(30, 36, 48, 0.95);
    backdrop-filter: blur(6px);
    padding: 10px 12px;
    border: 2px solid var(--border-main);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    animation: fadeInFlowView 0.3s ease;
    z-index: 10;
}

.ad-config-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.ad-config-input {
    width: 100%;
    padding: 8px 12px;
    font-size: 1.05rem;
    font-family: monospace;
    background: var(--bg-header);
    color: var(--text-primary);
    border: 2px solid var(--border-main);
    border-radius: 6px;
    transition: border-color 0.2s;
}
.ad-config-input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

/* Top-of-canvas error popup */
.ad-canvas-alert {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    padding: 12px 16px;
    background: rgba(229, 57, 53, 0.95); /* Red error background */
    backdrop-filter: blur(4px);
    color: #fff;
    border-radius: 8px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.4;
    z-index: 20;
    animation: slideDownAlert 0.3s ease forwards;
}

@keyframes slideDownAlert {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ── Right: controls ── */
.ad-controls-area {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    background: var(--bg-card);
    border: 2px solid var(--border-main);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
    min-width: 0;
}

.ad-input-row { display: flex; gap: 14px; }

.ad-input-block,
.ad-ion-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.ad-ion-group { animation: fadeInFlowView 0.3s ease; }

.ad-input-label {
    display: block;
    width: 100%;
    padding: 5px 14px;
    font-size: 0.95rem;
    font-weight: 700;
    text-align: center;
    color: var(--accent-blue);
    background: var(--bg-header);
    border: 2px solid var(--accent-blue);
    border-radius: 20px;
}

.ad-controls-area input[type="number"] {
    width: 100%;
    height: 72px;
    padding: 8px;
    font-family: monospace;
    font-size: 1.7rem;
    text-align: center;
    color: var(--text-primary);
    background: var(--bg-header);
    border: 2px solid var(--border-main);
    border-radius: 12px;
    transition: border-color 0.2s;
    -moz-appearance: textfield;
    appearance: textfield;
}
.ad-controls-area input[type="number"]::-webkit-inner-spin-button,
.ad-controls-area input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ad-controls-area input[type="number"]:focus { outline: none; border-color: var(--accent-blue); }

/* Charge stepper */
.ad-stepper {
    display: flex;
    align-items: stretch;
    width: 100%;
    background: var(--bg-header);
    border: 2px solid var(--border-main);
    border-radius: 12px;
    overflow: hidden;
}
.ad-stepper button {
    flex: 0 0 64px;
    font: inherit;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    background: var(--bg-card);
    border: none;
    cursor: pointer;
    transition: background 0.15s;
}
.ad-stepper button:hover:not(:disabled) { background: #30364a; }
.ad-stepper button:disabled { opacity: 0.35; cursor: not-allowed; }
.ad-stepper output {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    font-family: monospace;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent-amber);
}

/* Number +/− steppers (protons / neutrons).
   The blocks fall back to full width when a side-by-side pair gets too narrow
   for the input, so the number is never squeezed to nothing. */
.ad-input-row { flex-wrap: wrap; }
.ad-input-block { flex: 1 1 150px; }

.ad-stepper button { touch-action: manipulation; }

.ad-stepper.ad-counter { width: 100%; }
.ad-stepper.ad-counter button {
    flex: 0 0 56px;
    font-size: 1.4rem;
}
.ad-stepper.ad-counter:focus-within { border-color: var(--accent-blue); }

.ad-stepper.ad-counter input[type="number"] {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    height: 56px;
    padding: 0;
    font-family: monospace;
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    color: var(--text-primary);
    background: transparent;
    border: none;
    border-radius: 0;
}

/* Buttons */
.ad-shell-row { display: flex; gap: 10px; }
.ad-shell-row .check-step-btn { flex: 1; font-size: 1rem; padding: 10px 8px; }

.ad-controls-area .ad-btn-secondary {
    color: var(--text-primary);
    background: var(--bg-header);
    border-color: var(--border-main);
}
.ad-controls-area .ad-btn-secondary:hover:not(:disabled) { background: #2a3144; border-color: var(--accent-blue); }
.ad-controls-area .ad-btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }

.ad-link-btn {
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-blue);
    background: none;
    border: none;
    padding: 4px 6px;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.ad-link-btn:hover { color: var(--accent-green); }
.ad-answer-btn { align-self: center; margin-top: -6px; }

/* Electron source */
.ad-electron-source-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 16px;
    background: var(--bg-header);
    border: 2px dashed var(--border-main);
    border-radius: 12px;
}

.ad-drag-source {
    width: 100%;
    height: 76px;
    font: inherit;
    font-size: 1.6rem;
    font-weight: bold;
    color: var(--accent-green);
    background: var(--bg-card);
    border: 2px solid var(--accent-green);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(61, 214, 140, 0.2);
    cursor: grab;
    touch-action: none;           /* only this button blocks scrolling, so dragging works on phones */
    user-select: none;
    -webkit-user-select: none;
    transition: transform 0.1s, box-shadow 0.1s;
}
.ad-drag-source:active,
.ad-drag-source.dragging { cursor: grabbing; transform: scale(0.97); }
.ad-drag-source:focus-visible { outline: 3px solid var(--accent-blue); outline-offset: 3px; }

.ad-drag-hint {
    min-height: 2.6em;
    font-size: 0.85rem;
    line-height: 1.4;
    text-align: center;
    color: var(--text-secondary);
}
.ad-drag-hint.warn { color: var(--accent-amber); font-weight: 600; }

/* Floating ghost electron while dragging */
.ad-ghost-electron {
    position: fixed;
    width: 18px;
    height: 18px;
    background: var(--accent-green);
    border-radius: 50%;
    pointer-events: none;
    z-index: 10000;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 12px var(--accent-green);
}

/* Check / Reset / New */
.ad-actions { display: flex; gap: 10px; }
.ad-actions .check-step-btn { flex: 1; font-size: 1.05rem; padding: 12px 8px; }

/* ── Feedback ── */
.ad-feedback {
    display: none;
    padding: 14px 16px;
    border-radius: 8px;
    font-size: 0.95rem;
    line-height: 1.5;
}
.ad-feedback.show { display: block; }
.ad-feedback.success { background: rgba(61, 214, 140, 0.1); border-left: 4px solid var(--accent-green); color: var(--accent-green); }
.ad-feedback.error   { background: rgba(229, 57, 53, 0.1);  border-left: 4px solid #e53935;             color: #ff7b78; }
.ad-feedback.info    { background: rgba(91, 156, 246, 0.1); border-left: 4px solid var(--accent-blue);  color: var(--text-primary); }

.notes-content .ad-feedback strong { color: inherit; }

.notes-content .ad-fb-list { list-style: none; margin: 10px 0 0; padding: 0; }
.notes-content .ad-fb-list li {
    display: flex;
    gap: 10px;
    margin: 0 0 8px;
    font-size: 0.95rem;
    line-height: 1.45;
    color: var(--text-primary);
}
.notes-content .ad-fb-list li:last-child { margin-bottom: 0; }
.ad-fb-icon { flex-shrink: 0; width: 1.2em; font-weight: 700; }
.ad-fb-list .ok .ad-fb-icon { color: var(--accent-green); }
.ad-fb-list .bad .ad-fb-icon { color: #ff7b78; }
.ad-fb-list .bad strong { color: #ff7b78; }
.ad-fb-msg { margin-top: 2px; color: var(--text-primary); }

.ad-feedback .ad-next-btn { display: block; margin-top: 12px; width: 100%; font-size: 1.05rem; padding: 10px; }

.ad-footnote {
    margin-top: 22px;
    font-size: 0.9rem;
    text-align: center;
    color: var(--text-secondary);
}

/* ── Phones / tablets ── */
@media (max-width: 900px) {
    .ad-workspace { grid-template-columns: minmax(0, 1fr); }
    .ad-top-header { flex-direction: column; }
}

@media (max-width: 600px) {
    .ad-prompt-box { padding: 12px 14px; }
    .notes-content .ad-steps { gap: 6px; }
    .notes-content .ad-steps li { font-size: 0.8rem; padding-right: 10px; }
    .ad-controls-area { padding: 14px; gap: 14px; }
    .ad-controls-area input[type="number"] { height: 60px; font-size: 1.5rem; }
    .ad-drag-source { height: 64px; }
    .ad-electron-source-wrapper { padding: 12px; }
    .ad-canvas-footer { justify-content: center; }
}