/* Algebra Seesaw App - CSS Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family:
        "Comic Sans MS", "Chalkboard SE", "Arial Rounded MT Bold", sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    padding: 20px;
    text-align: center;
}

header {
    background: linear-gradient(to right, #ff6b6b, #ffa502);
    color: white;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

header h1 {
    font-size: 2.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
}

header p {
    font-size: 1.2rem;
    font-weight: bold;
}

main {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* ── Top Bar: Equation + Difficulty ──────────────────────────────────────── */
.top-bar {
    display: flex;
    align-items: center;
    gap: 14px;
}

.equation-display {
    flex: 1;
    background: linear-gradient(to right, #4facfe 0%, #00f2fe 100%);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: background 0.4s ease;
}

/* Difficulty colour themes */
.equation-display.difficulty-easy {
    background: linear-gradient(to right, #43e97b, #38f9d7);
}

.equation-display.difficulty-medium {
    background: linear-gradient(to right, #4facfe, #00f2fe);
}

.equation-display.difficulty-hard {
    background: linear-gradient(to right, #f7576a, #ff9a44);
}

.equation-display.difficulty-very-hard {
    background: linear-gradient(to right, #72278e, #c026d3);
}

#current-equation {
    font-size: 2rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.difficulty-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.difficulty-wrapper label {
    font-weight: bold;
    font-size: 0.9rem;
    color: #555;
}

#difficulty-select {
    padding: 10px 14px;
    border: 2px solid #764ba2;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    background-color: white;
    color: #333;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

#difficulty-select:focus {
    border-color: #ff6b6b;
}

/* ── Seesaw ──────────────────────────────────────────────────────────────── */
.seesaw-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 20px 0;
}

.seesaw {
    position: relative;
    width: 300px;
    height: 80px;
    margin: 20px 0;
}

.seesaw-fulcrum {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background-color: #8b4513;
    border-radius: 50%;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.seesaw-arm {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 8px;
    background-color: #8b4513;
    transform-origin: center;
    transition: transform 0.5s ease;
    z-index: 5;
}

.left-side,
.right-side {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.left-side {
    left: 0;
    background: linear-gradient(to right, #ff6b6b, #ff8e8e);
    color: white;
    width: 120px;
    height: 50px;
}

.right-side {
    right: 0;
    background: linear-gradient(to left, #4facfe, #87cefa);
    color: white;
    width: 120px;
    height: 50px;
}

.weight {
    font-size: 1.1rem;
    text-align: center;
    padding: 5px;
    word-break: break-word;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Fractions & Structure Rendering ─────────────────────────────────────── */
.expr-chunk {
    display: inline-flex;
    align-items: center;
}

.fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    margin: 0 5px;
}

.numerator {
    padding: 0 8px;
    margin-bottom: 2px;
}

.fraction-line {
    width: 100%;
    height: 2px;
    background-color: currentColor;
    margin: 2px 0;
}

.denominator {
    padding: 0 8px;
    margin-top: 2px;
}

.paren-expr {
    display: inline-flex;
    align-items: center;
}

.paren-expr::before {
    content: "(";
}

.paren-expr::after {
    content: ")";
}

.balance-indicator {
    font-size: 1.5rem;
    font-weight: bold;
    margin-top: 10px;
    padding: 10px;
    border-radius: 10px;
    background-color: #90ee90;
    color: #228b22;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s, color 0.3s;
}

.balance-indicator.unbalanced {
    background-color: #ff6347;
    color: white;
}

.balance-indicator.success {
    background-color: #00b09b;
    color: white;
}

.balance-indicator.error {
    background-color: #ff4757;
    color: white;
    animation: pulse 0.5s ease-in-out infinite;
}

/* ── Input Section ───────────────────────────────────────────────────────── */
.input-section {
    background: linear-gradient(to right, #ff9a9e, #fad0c4);
    padding: 10px;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.operation-controls {
    margin-bottom: 15px;
}

.operation-controls h3 {
    font-size: 1.3rem;
    color: #333;
    margin-bottom: 10px;
}

.input-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.side-label {
    font-weight: bold;
    color: #333;
    min-width: 90px;
    text-align: right;
    font-size: 1rem;
}

/* ── Operator Buttons ────────────────────────────────────────────────────── */
.op-buttons {
    display: flex;
    gap: 6px;
}

.op-btn {
    width: 44px;
    height: 44px;
    border: 2px solid #999;
    border-radius: 10px;
    background: white;
    color: #555;
    font-size: 1.3rem;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}

.op-btn:hover {
    border-color: #764ba2;
    background: #f0eaff;
    color: #764ba2;
}

.op-btn.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-color: #5a4a99;
    color: white;
    transform: scale(1.05);
    box-shadow: 0 3px 8px rgba(102, 126, 234, 0.5);
}

/* ── Number Input ────────────────────────────────────────────────────────── */
#left-value,
#right-value {
    width: 90px;
    padding: 10px;
    border: 2px solid #aaa;
    border-radius: 8px;
    font-size: 1.1rem;
    font-family: inherit;
    text-align: center;
    background-color: white;
    transition: border-color 0.2s;
}

#left-value:focus,
#right-value:focus {
    border-color: #764ba2;
    outline: none;
}

/* ── Action Buttons ──────────────────────────────────────────────────────── */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 10px;
}

#go-button {
    background: linear-gradient(to right, #00b09b, #96c93d);
    color: white;
    border: none;
    padding: 14px 36px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    font-family: inherit;
}

#go-button:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3);
}

#go-button:active {
    transform: scale(0.97);
}

#reset-button {
    background: linear-gradient(to right, #f7ba2a, #ea5455);
    color: white;
    border: none;
    padding: 14px 28px;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    font-family: inherit;
}

#reset-button:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3);
}

#reset-button:active {
    transform: scale(0.97);
}

/* ── Feedback Section ────────────────────────────────────────────────────── */
.feedback-section {
    background: linear-gradient(to right, #a1c4fd, #c2e9fb);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 15px;
    font-size: 1.2rem;
    font-weight: bold;
}

.stats p {
    padding: 10px;
    border-radius: 10px;
    background-color: rgba(255, 255, 255, 0.7);
}

.message {
    font-size: 1.3rem;
    font-weight: bold;
    min-height: 40px;
    padding: 10px;
    border-radius: 10px;
    margin-top: 10px;
}

.message.success {
    background-color: #90ee90;
    color: #228b22;
}

.message.error {
    background-color: #ff6347;
    color: white;
}

.message.info {
    background-color: #add8e6;
    color: #00008b;
}

footer {
    margin-top: 20px;
    padding: 15px;
    background: linear-gradient(to right, #667eea, #764ba2);
    color: white;
    border-radius: 15px;
    font-weight: bold;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* ── Animations ──────────────────────────────────────────────────────────── */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.balance-indicator.solved {
    background-color: #2ed573 !important;
    color: white;
    font-weight: bold;
    animation: celebrate 0.5s ease-in-out infinite;
}

@keyframes celebrate {

    0%,
    100% {
        transform: rotate(0deg) scale(1);
    }

    25% {
        transform: rotate(-5deg) scale(1.1);
    }

    50% {
        transform: rotate(5deg) scale(1.1);
    }

    75% {
        transform: rotate(-3deg) scale(1.05);
    }
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 2rem;
    }

    .top-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .difficulty-wrapper {
        flex-direction: row;
        justify-content: center;
    }

    #current-equation {
        font-size: 1.5rem;
    }

    .seesaw {
        width: 250px;
    }

    .input-row {
        flex-direction: column;
        align-items: center;
    }

    .side-label {
        text-align: center;
    }

    .stats {
        flex-direction: column;
        gap: 10px;
    }
}