/**
 * Marky Mark — Graph
 * Graph collapse handle and zoom controls.
 */

/* --- Graph Collapse Handle (mobile only, hidden on desktop) --- */
#graph-handle {
    display: none;
}

/* ── Pythagoras live-equation overlay ──────────────────────────────────── */
/* Sits at the top of the visual stage, above the JSXGraph canvas.         */
.pyth-overlay {
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.97);
    border-bottom: 1px solid #e2e8f0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.9rem;
    line-height: 1.7;
    flex-shrink: 0;
}

[data-theme="dark"] .pyth-overlay {
    background: rgba(15, 23, 42, 0.97);
    border-bottom-color: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
}

.pyth-overlay .pyth-formula {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.pyth-overlay .pyth-values,
.pyth-overlay .pyth-result {
    font-size: 0.85rem;
    color: #475569;
}

[data-theme="dark"] .pyth-overlay .pyth-values,
[data-theme="dark"] .pyth-overlay .pyth-result {
    color: #94a3b8;
}

.pyth-overlay .pyth-check {
    color: #22c55e;
    font-weight: 700;
    margin-left: 6px;
}

/* Side colour tokens — must match geometry.js A_COLOR / B_COLOR / C_COLOR */
.pyth-overlay .pyth-a { color: #3b7cf4; font-weight: 700; }
.pyth-overlay .pyth-b { color: #2ecc71; font-weight: 700; }
.pyth-overlay .pyth-c { color: #e67e22; font-weight: 700; }

/* Equation panel — floating cards stacked top-left over the graph canvas */
.equation-panel {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.equation-card {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 11px 5px 9px;
    background: color-mix(in srgb, var(--eq-color, #3b7cf4) 10%, white);
    border: 1px solid color-mix(in srgb, var(--eq-color, #3b7cf4) 22%, transparent);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--eq-color, #3b7cf4);
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
    cursor: pointer;
    transition: box-shadow 0.15s, transform 0.12s, opacity 0.15s;
    animation: eq-card-fadein 0.4s ease forwards;
    user-select: none;
}

.equation-card:hover {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.13);
    transform: translateX(2px);
}

.equation-card.highlighted {
    box-shadow: 0 0 0 2px var(--eq-color, #3b7cf4), 0 2px 8px rgba(0, 0, 0, 0.10);
    transform: translateX(3px);
}

.equation-card.dimmed {
    opacity: 0.35;
}

.eq-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--eq-color, #3b7cf4);
    flex-shrink: 0;
}

@keyframes eq-card-fadein {
    from { opacity: 0; transform: translateX(-4px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Live equation overlay driven by slider card */
.eq-overlay-live {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(59, 124, 244, 0.25);
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(4px);
    pointer-events: none;
    animation: eq-card-fadein 0.3s ease forwards;
}

[data-theme="dark"] .eq-overlay-live {
    background: rgba(15, 23, 42, 0.88);
    border-color: rgba(59, 124, 244, 0.3);
    color: #e2e8f0;
}

/* --- Visual Panel Header (desktop card layout, hidden on mobile) --- */
.visual-panel-header {
    display: none;
}

@media (min-width: 769px) {
    .visual-panel-header {
        display: flex;
        align-items: center;
        padding: 0 16px;
        height: 44px;
        flex-shrink: 0;
        border-bottom: 1px solid var(--border-subtle);
    }

    .visual-panel-header .panel-title {
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.07em;
        text-transform: uppercase;
        color: var(--text-tertiary);
    }

    /* Close button in the graph panel header */
    .panel-close-btn {
        margin-left: auto;
        background: transparent;
        border: none;
        cursor: pointer;
        color: var(--text-tertiary);
        padding: 6px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        transition: color 0.15s, background 0.15s;
    }
    .panel-close-btn:hover {
        color: var(--text-secondary);
        background: var(--bg-hover);
    }
}

/* --- Graph Zoom Controls --- */
#graph-controls {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 150;
}

#graph-controls button {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-color);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    box-shadow: 0 2px 8px var(--shadow-sm);
    transition: transform 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
}

#graph-controls button:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    transform: scale(1.08);
    box-shadow: 0 4px 12px var(--shadow-md);
}

#graph-controls button:active {
    transform: scale(0.95);
    background: var(--bg-hover);
}

#zoom-in-btn,
#zoom-out-btn {
    font-size: 20px;
    font-weight: 300;
    line-height: 1;
    color: var(--text-primary);
}

/* Shift zoom controls below the 44px panel header on desktop */
@media (min-width: 769px) {
    #graph-controls {
        top: 56px;
    }
}

/* Dark mode graph + equation cards */
/* Note: In cartesian_graph mode, #jxgbox background is controlled by graph.js.
   In geometry mode, geometry.js sets the SVG root to transparent so the CSS
   graph paper grid above shows through. */

[data-theme="dark"] .equation-card {
    background: #0f172a;
    border-color: rgba(255, 255, 255, 0.18);
    color: var(--eq-color, #3b7cf4);
}

[data-theme="dark"] .eq-dot {
    background: var(--eq-color, #3b7cf4);
}

/* Gradient equation floating card — rendered inside JSXGraph as an HTML text element */
.gradient-eq-card {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    padding: 5px 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: #1e293b;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    line-height: 1;
}

[data-theme="dark"] .gradient-eq-card {
    background: rgba(15, 23, 42, 0.92);
    border-color: rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
}

/* Axis tick label colour in dark mode — targets JSXGraph's foreignObject HTML labels */
[data-theme="dark"] .jxgbox foreignObject {
    color: #64748b;
}

/* ── Geometry mode — graph paper grid, no zoom controls ── */

/* Hide zoom/reset buttons in geometry mode — they are meaningless without zoom */
body.is-geometry-mode #graph-controls {
    display: none;
}

/* Graph paper grid rendered as a CSS background on the JSXGraph container.
   The SVG inside #jxgbox is set to background:transparent by geometry.js so
   the grid shows through. Minor lines every 20 px; major lines every 100 px. */
body.is-geometry-mode #jxgbox {
    background-image:
        linear-gradient(rgba(100, 116, 139, 0.10) 1px, transparent 1px),
        linear-gradient(90deg, rgba(100, 116, 139, 0.10) 1px, transparent 1px),
        linear-gradient(rgba(100, 116, 139, 0.22) 1px, transparent 1px),
        linear-gradient(90deg, rgba(100, 116, 139, 0.22) 1px, transparent 1px);
    background-size: 20px 20px, 20px 20px, 100px 100px, 100px 100px;
}

[data-theme="dark"] body.is-geometry-mode #jxgbox {
    background-image:
        linear-gradient(rgba(148, 163, 184, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px),
        linear-gradient(rgba(148, 163, 184, 0.16) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.16) 1px, transparent 1px);
    background-size: 20px 20px, 20px 20px, 100px 100px, 100px 100px;
}

/* ── Side annotation pulse — geometry.js applies this class to JSXGraph SVG paths ── */
/* Pulses 4 times then stops. stroke-width and stroke-opacity are SVG paint properties */
/* that CSS animations can drive even when JSXGraph sets them inline.                  */
@keyframes jxg-side-pulse {
    0%,  100% { stroke-width: 3;   stroke-opacity: 1;    }
    50%        { stroke-width: 5.5; stroke-opacity: 0.55; }
}

.jxg-side-pulse {
    animation: jxg-side-pulse 1.1s ease-in-out 4;
}

