/* Balance Scale Tool - CSS */
/* Uses design system variables from tools_design_system.css */

/* Override the min-height from base template to prevent gap */
.tool-page-wrapper:has(.bs-container) {
    min-height: 0 !important;
}

.tool-content-area:has(.bs-container) {
    min-height: 0 !important;
}

.bs-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: var(--t-space-4) var(--t-space-3);
    padding-top: 15vh;
    background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
    -webkit-user-select: none;
    user-select: none;
    overflow: hidden;
}

/* Fullscreen mode - fill entire viewport */
:fullscreen .bs-container,
:-webkit-full-screen .bs-container,
:-moz-full-screen .bs-container {
    justify-content: center;
    padding-top: 0;
}

/* Also target the tool content area in fullscreen */
:fullscreen .tool-content-area,
:-webkit-full-screen .tool-content-area,
:-moz-full-screen .tool-content-area {
    display: flex;
    flex-direction: column;
}

/* Scale Container */
.bs-scale-wrapper {
    position: relative;
    width: 100%;
    max-width: 900px;
    height: 450px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}

/* The beam that tilts */
.bs-beam-container {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    transform-origin: center bottom;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bs-beam {
    width: 650px;
    height: 22px;
    background: linear-gradient(180deg, #9ca3af 0%, #6b7280 100%);
    border-radius: 4px;
    position: relative;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Drop zones on beam - 2 columns layout */
.bs-drop-zone {
    position: absolute;
    bottom: 100%;
    width: 140px;
    min-height: 280px;
    display: flex;
    flex-wrap: wrap-reverse;
    flex-direction: row;
    align-content: flex-start;
    justify-content: center;
    gap: 2px;
    padding-bottom: 5px;
    transition: background-color 0.2s ease;
}

.bs-drop-zone.bs-left {
    left: 5px;
}

.bs-drop-zone.bs-right {
    right: 5px;
}

.bs-drop-zone.bs-drag-over {
    background: rgba(59, 130, 246, 0.1);
    border-radius: var(--t-radius-lg);
}

/* Fulcrum (triangle base) */
.bs-fulcrum {
    width: 0;
    height: 0;
    border-left: 70px solid transparent;
    border-right: 70px solid transparent;
    border-bottom: 100px solid #6b7280;
    position: relative;
    z-index: 1;
}

.bs-fulcrum::before {
    content: '';
    position: absolute;
    bottom: -100px;
    left: -70px;
    width: 140px;
    height: 12px;
    background: #4b5563;
    border-radius: 0 0 4px 4px;
}

/* Block Palette */
.bs-palette {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--t-space-2);
    margin-top: var(--t-space-4);
    padding: var(--t-space-4);
    background: white;
    border-radius: var(--t-radius-xl);
    box-shadow: var(--t-shadow-md);
    max-width: 900px;
}

/* Individual blocks */
.bs-block {
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    color: #1f2937;
    border-radius: var(--t-radius-lg);
    cursor: grab;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.1),
        inset 0 2px 0 rgba(255, 255, 255, 0.3),
        inset 0 -2px 0 rgba(0, 0, 0, 0.1);
    border: 3px solid rgba(0, 0, 0, 0.2);
}

.bs-block:hover {
    transform: scale(1.05);
    box-shadow:
        0 6px 12px rgba(0, 0, 0, 0.15),
        inset 0 2px 0 rgba(255, 255, 255, 0.3),
        inset 0 -2px 0 rgba(0, 0, 0, 0.1);
}

.bs-block:active,
.bs-block.bs-dragging {
    cursor: grabbing;
    transform: scale(1.1);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

.bs-block.bs-on-scale {
    width: 65px;
    height: 65px;
    font-size: 28px;
    margin-bottom: 2px;
}

/* Blocks are always available - can be used multiple times */

/* Block colors */
.bs-block[data-value="1"] { background: #c4c4c4; }
.bs-block[data-value="2"] { background: #22c55e; }
.bs-block[data-value="3"] { background: #06b6d4; }
.bs-block[data-value="4"] { background: #3b82f6; }
.bs-block[data-value="5"] { background: #ec4899; }
.bs-block[data-value="6"] { background: #f59e0b; }
.bs-block[data-value="7"] { background: #f97316; }
.bs-block[data-value="8"] { background: #ef4444; }
.bs-block[data-value="9"] { background: #a855f7; }
.bs-block[data-value="10"] { background: #6366f1; color: white; }

/* Control buttons */
.bs-controls {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 900px;
    margin-top: var(--t-space-3);
    gap: var(--t-space-3);
}

.bs-controls-left,
.bs-controls-right {
    display: flex;
    gap: var(--t-space-2);
}

.bs-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--t-space-2);
    padding: var(--t-space-3) var(--t-space-5);
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    background: white;
    border: 2px solid #1f2937;
    border-radius: var(--t-radius-2xl);
    cursor: pointer;
    transition: all var(--t-transition-fast);
}

.bs-btn:hover {
    background: #f3f4f6;
    transform: translateY(-2px);
    box-shadow: var(--t-shadow-md);
}

.bs-btn:active {
    transform: translateY(0);
}

.bs-btn-icon {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: var(--t-radius-xl);
}

.bs-btn-icon svg {
    width: 24px;
    height: 24px;
}

/* Weight display */
.bs-weight-display {
    position: absolute;
    bottom: -30px;
    font-size: 18px;
    font-weight: 700;
    color: #4b5563;
    background: white;
    padding: 4px 12px;
    border-radius: var(--t-radius-lg);
    box-shadow: var(--t-shadow-sm);
}

.bs-drop-zone.bs-left .bs-weight-display {
    left: 50%;
    transform: translateX(-50%);
}

.bs-drop-zone.bs-right .bs-weight-display {
    right: 50%;
    transform: translateX(50%);
}

/* Dragging ghost */
.bs-drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 10000;
    opacity: 0.9;
}

/* Responsive */
@media (max-width: 768px) {
    .bs-container {
        padding: var(--t-space-2);
        padding-top: var(--t-space-2);
    }

    .bs-scale-wrapper {
        height: 300px;
    }

    .bs-beam {
        width: 350px;
    }

    .bs-drop-zone {
        width: 100px;
        min-height: 150px;
    }

    .bs-drop-zone.bs-left {
        left: 5px;
    }

    .bs-drop-zone.bs-right {
        right: 5px;
    }

    .bs-fulcrum {
        border-left-width: 45px;
        border-right-width: 45px;
        border-bottom-width: 60px;
    }

    .bs-fulcrum::before {
        bottom: -60px;
        left: -45px;
        width: 90px;
    }

    .bs-block {
        width: 50px;
        height: 50px;
        font-size: 22px;
    }

    .bs-block.bs-on-scale {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }

    .bs-palette {
        padding: var(--t-space-3);
        gap: var(--t-space-1);
    }

    .bs-btn {
        padding: var(--t-space-2) var(--t-space-4);
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .bs-beam {
        width: 280px;
    }

    .bs-block {
        width: 42px;
        height: 42px;
        font-size: 18px;
    }

    .bs-block.bs-on-scale {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }

    .bs-drop-zone {
        width: 80px;
    }

    .bs-controls {
        flex-direction: column;
        align-items: center;
    }
}

/* RTL Support */
[dir="rtl"] .bs-drop-zone.bs-left {
    left: auto;
    right: 5px;
}

[dir="rtl"] .bs-drop-zone.bs-right {
    right: auto;
    left: 5px;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .bs-beam-container,
    .bs-block,
    .bs-btn {
        transition: none;
    }
}

/* Focus states */
.bs-block:focus,
.bs-btn:focus {
    outline: 3px solid var(--t-primary);
    outline-offset: 2px;
}
