/*
 * polygon-angles — triangle / quadrilateral angle-sum widget.
 *
 *   explore   — draggable vertices; the polygon morphs and angles
 *               recompute live, sum readout always confirms the rule.
 *   challenge — known angles labelled; missing one shows an input box;
 *               Check validates the typed answer against the rule.
 *   display   — pinned anchor labels for IWB modelling.
 */

.maths-activity .pol-mode-chip {
    display: inline-block;
    margin-top: 0.4rem;
    padding: 0.3rem 0.75rem;
    background: var(--maths-surface-alt);
    color: var(--maths-primary-dark);
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.9rem;
}

.maths-activity .pol-stage {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(220px, 280px);
    gap: 1rem;
    align-items: start;
}

.maths-activity .pol-svg {
    width: 100%;
    height: auto;
    max-height: 460px;
    background: var(--maths-surface);
    border: 1px solid var(--maths-border);
    border-radius: 10px;
    touch-action: none;
    user-select: none;
}

/* Readout panel */
.maths-activity .pol-readout {
    background: var(--maths-surface);
    border: 1px solid var(--maths-border);
    border-radius: 10px;
    padding: 1rem 1.1rem;
}

.maths-activity .pol-readout-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--maths-ink-muted);
    margin-bottom: 0.55rem;
}

.maths-activity .pol-list {
    list-style: none;
    padding: 0;
    margin: 0 0 0.7rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.maths-activity .pol-list li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.35rem 0.55rem;
    background: var(--maths-surface-alt);
    border-radius: 6px;
    border-left: 4px solid var(--maths-primary);
    font-weight: 700;
    color: var(--maths-ink);
}

.maths-activity .pol-list li.is-missing {
    border-left-color: var(--maths-accent);
    background: #FFF2EA;
}

.maths-activity .pol-list li .pol-vertex {
    font-weight: 600;
    color: var(--maths-ink-muted);
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
}

.maths-activity .pol-list li .pol-deg {
    font-variant-numeric: tabular-nums;
    color: var(--maths-primary-dark);
}

.maths-activity .pol-list li.is-missing .pol-deg {
    color: var(--maths-accent);
}

.maths-activity .pol-sum {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.55rem 0.75rem;
    background: var(--maths-surface-alt);
    border-radius: 6px;
    border: 1px solid var(--maths-border);
    margin-bottom: 0.55rem;
}

.maths-activity .pol-sum-label {
    font-weight: 700;
    color: var(--maths-ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.85rem;
}

.maths-activity .pol-sum-value {
    font-weight: 800;
    font-size: 1.4rem;
    color: var(--maths-success);
    font-variant-numeric: tabular-nums;
}

.maths-activity .pol-hint {
    font-size: 0.9rem;
    color: var(--maths-ink-muted);
    line-height: 1.4;
}

/* Target panel inner styling */
.maths-activity .pol-target-label {
    font-weight: 800;
    color: var(--maths-primary-dark);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.85rem;
}

.maths-activity .pol-target-label i {
    margin-right: 0.35rem;
    color: var(--maths-accent);
}

.maths-activity .pol-target-prompt {
    font-weight: 700;
    color: var(--maths-ink);
    font-size: 1.05rem;
    flex: 1 1 auto;
}

/* SVG element classes used by the JS renderer */
.pol-polygon-fill {
    fill: rgba(31, 111, 178, 0.08);
    stroke: var(--maths-primary, #1F6FB2);
    stroke-width: 2.5;
    stroke-linejoin: round;
}

.pol-vertex-label {
    font: 700 16px Nunito, sans-serif;
    fill: var(--maths-ink, #1F2933);
    text-anchor: middle;
    dominant-baseline: middle;
}

.pol-angle-arc {
    fill: none;
    stroke: var(--maths-primary, #1F6FB2);
    stroke-width: 2;
}

.pol-angle-arc.is-missing {
    stroke: var(--maths-accent, #E86A33);
    stroke-dasharray: 4 3;
}

.pol-angle-label {
    font: 700 14px Nunito, sans-serif;
    fill: var(--maths-primary-dark, #154A78);
    text-anchor: middle;
    dominant-baseline: middle;
}

.pol-angle-label.is-missing {
    fill: var(--maths-accent, #E86A33);
    font-weight: 800;
}

.pol-answer-leader {
    stroke: var(--maths-accent, #E86A33);
    stroke-width: 1.5;
    stroke-dasharray: 4 3;
    fill: none;
}

.pol-vertex-handle {
    fill: #fff;
    stroke: var(--maths-accent, #E86A33);
    stroke-width: 2.5;
    cursor: grab;
}

.pol-vertex-handle:hover {
    fill: #fff8e1;
}

.pol-vertex-handle:active {
    cursor: grabbing;
}

/* The challenge mode missing-angle input — sits inline at the missing
 * vertex via SVG foreignObject. Sized to fit inside narrow angle
 * wedges (e.g. a ~60° triangle apex). */
.pol-answer-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1px;
    width: 100%;
    height: 100%;
    background: #fff;
    border: 2px solid var(--maths-accent, #E86A33);
    border-radius: 6px;
    padding: 0 2px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.10);
    box-sizing: border-box;
    overflow: hidden;
}

.pol-answer-input {
    font: 800 16px Nunito, sans-serif;
    width: 48px;
    min-width: 0;
    text-align: right;
    color: var(--maths-accent, #E86A33);
    border: none;
    outline: none;
    background: transparent;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    -moz-appearance: textfield;
}

.pol-answer-input::-webkit-outer-spin-button,
.pol-answer-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.pol-answer-input::placeholder {
    color: var(--maths-accent, #E86A33);
    opacity: 0.5;
}

.pol-answer-suffix {
    font: 800 16px Nunito, sans-serif;
    color: var(--maths-accent, #E86A33);
    line-height: 1;
}

@media (max-width: 760px) {
    .maths-activity .pol-stage {
        grid-template-columns: 1fr;
    }
}

/* Display mode strips drag handles and the challenge target panel.
 * Angle labels stay visible. */
.maths-activity[data-display-mode="true"] .pol-vertex-handle,
.maths-activity[data-display-mode="true"] .pol-target-panel,
.maths-activity[data-display-mode="true"] .pol-answer-wrap {
    display: none !important;
}
