/* buoyancy.html specific styles */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Microsoft YaHei', sans-serif;
}

body {
    background: white;
    color: black;
    min-height: 100vh;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.container {
    width: 100%;
    max-width: 1200px;
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    padding: 20px;
    margin: 20px 0;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid #999;
}

h1 {
    color: black;
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: normal;
}

h2 {
    color: black;
    font-size: 1.8rem;
    margin: 20px 0 10px;
}

p {
    color: black;
    line-height: 1.6;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.main-content {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.left-panel {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.animation-container {
    background: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    height: 520px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.tank {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 28px;
    height: 360px;
    width: 72%;
    min-width: 280px;
    max-width: calc(100% - 60px);
    border-left: 12px solid rgba(164, 218, 255, 0.88);
    border-right: 12px solid rgba(164, 218, 255, 0.88);
    border-bottom: 14px solid rgba(164, 218, 255, 0.92);
    border-top: none;
    border-radius: 0 0 28px 28px;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(5px);
    box-shadow: inset 0 0 25px rgba(0, 70, 140, 0.18);
}

.tank::after {
    content: "";
    position: absolute;
    top: 6px;
    left: 12px;
    right: 12px;
    height: 5px;
    border-radius: 8px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0));
    opacity: 0.6;
    pointer-events: none;
}

.tank-inner {
    position: absolute;
    left: 6px;
    right: 6px;
    top: 0;
    bottom: 10px;
    border-radius: 0 0 18px 18px;
    overflow: visible;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(220, 236, 255, 0.05));
}

.water {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(180deg, rgba(0, 120, 255, 0.7), rgba(0, 140, 255, 0.5));
    transition: height 0.4s ease, background 0.4s ease;
    border-radius: 0 0 18px 18px;
    box-shadow: inset 0 6px 12px rgba(255, 255, 255, 0.25);
}

.overflow-droplet {
    position: absolute;
    top: 4px;
    width: 28px;
    height: 40px;
    background: url('../4mechanics/images/water.svg') center / contain no-repeat;
    opacity: 0;
    pointer-events: none;
    transform-origin: top center;
    --x-translate: 0px;
    --delay: 0s;
    --drop-duration: 1.8s;
}

.overflow-droplet.show {
    animation: droplet-fall var(--drop-duration) ease-out forwards;
    animation-delay: var(--delay);
}

.overflow-droplet[data-direction="out-left-far"] {
    left: -8px;
    --x-translate: -90px;
    --delay: 0s;
}

.overflow-droplet[data-direction="out-left"] {
    left: 4px;
    --x-translate: -70px;
    --delay: 0.05s;
}

.overflow-droplet[data-direction="out-mid-left"] {
    left: 20px;
    --x-translate: -50px;
    --delay: 0.1s;
}

.overflow-droplet[data-direction="out-center-left"] {
    left: 50%;
    margin-left: -24px;
    --x-translate: -25px;
    --delay: 0.14s;
}

.overflow-droplet[data-direction="out-center"] {
    left: 50%;
    margin-left: -14px;
    --x-translate: -5px;
    --delay: 0.18s;
}

.overflow-droplet[data-direction="out-center-right"] {
    left: 50%;
    margin-left: -2px;
    --x-translate: 15px;
    --delay: 0.22s;
}

.overflow-droplet[data-direction="out-mid-right"] {
    right: 24px;
    --x-translate: 35px;
    --delay: 0.26s;
}

.overflow-droplet[data-direction="out-right"] {
    right: 6px;
    --x-translate: 55px;
    --delay: 0.3s;
}

.overflow-droplet[data-direction="out-right-far"] {
    right: -12px;
    --x-translate: 85px;
    --delay: 0.08s;
}

.overflow-droplet[data-direction="out-mid-right-far"] {
    right: 42px;
    --x-translate: 45px;
    --delay: 0.12s;
}

@keyframes droplet-fall {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    70% {
        opacity: 1;
        transform: translate(calc(var(--x-translate) * 0.65), 95px) scale(0.95);
    }
    100% {
        opacity: 0;
        transform: translate(var(--x-translate), 135px) scale(0.85);
    }
}

.support-arrow {
    bottom: 50%;
    height: 0;
    background-color: #00FF7F;
    display: none;
    transition: height 0.3s ease;
    z-index: 0;
}

.support-arrow .arrow-head {
    top: -12px;
    border-bottom: 12px solid #00FF7F;
}

.support-arrow .arrow-label {
    top: 0;
    --base-translate: -50%;
}

.object {
    position: absolute;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: grab;
    user-select: none;
    z-index: 20;
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    transition: bottom 0.3s cubic-bezier(0.34, 1.0, 0.64, 1.0), transform 0.2s, left 0.5s ease;
    border: 2px solid transparent;
    filter: none;
    overflow: visible;
    --duck-scale: 1;
    --duck-offset-y: 2%;
}

.object.cube {
    background: linear-gradient(45deg, #FF5722, #FF9800);
    border-color: #E65100;
}

.object.duck {
    background: none;
    border: none;
}

.object.duck::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 100%;
    height: 100%;
    transform: translate(-50%, var(--duck-offset-y)) scale(var(--duck-scale, 1));
    transform-origin: center bottom;
    background-image: url('../4mechanics/images/duck.svg');
    background-repeat: no-repeat;
    background-position: center bottom;
    background-size: contain;
    pointer-events: none;
    z-index: -2;
}

.object.ice {
    background-image: url('../4mechanics/images/ice.svg');
    border: none;
    background-size: 115% 115%;
    background-position: center;
}

.object.dragging {
    cursor: grabbing;
    transform: scale(1.05);
    transition: transform 0.2s, bottom 0.3s ease;
}

.object.cube.dragging {
    box-shadow: 0 0 18px rgba(255, 87, 34, 0.6);
}

.object.duck.dragging {
    box-shadow: none;
    filter: drop-shadow(0 0 14px rgba(255, 235, 59, 0.9));
}

.object.ice.dragging {
    box-shadow: none;
    filter: drop-shadow(0 0 16px rgba(173, 216, 230, 0.85));
}

.center-of-mass {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(186, 104, 200, 0.8);
    box-shadow: 0 0 6px rgba(128, 222, 234, 0.4);
    pointer-events: none;
    z-index: 5;
    transform: translate(-50%, -50%);
}

.force-arrow {
    position: absolute;
    left: 50%;
    width: 3px;
    transform: translateX(-1.5px);
    z-index: -1;
    display: flex;
    justify-content: center;
}

.buoyancy-arrow {
    bottom: var(--com-percent, 50%);
    height: 0;
    background-color: #00BFFF;
    transition: height 0.3s ease;
}

.gravity-arrow {
    top: calc(100% - var(--com-percent, 50%));
    height: 0;
    background-color: #DC3545;
    transition: height 0.3s ease;
}

.pressure-arrow {
    display: none;
    z-index: 0;
}

.pressure-down-arrow {
    bottom: 50%;
    background-color: #00BFFF;
    transition: height 0.3s ease;
}

.pressure-down-arrow .arrow-head {
    top: -12px;
    border-bottom: 12px solid #00BFFF;
}

.pressure-up-arrow {
    top: 50%;
    background-color: #00BFFF;
    transition: height 0.3s ease;
}

.pressure-up-arrow .arrow-head {
    bottom: -12px;
    border-top: 12px solid #00BFFF;
}

.arrow-head {
    position: absolute;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
}

.buoyancy-arrow .arrow-head {
    top: -12px;
    border-bottom: 12px solid #00BFFF;
}

.gravity-arrow .arrow-head {
    bottom: -12px;
    border-top: 12px solid #DC3545;
}

.arrow-label {
    position: absolute;
    left: 15px;
    font-size: 1rem;
    font-weight: bold;
    color: black;
    padding: 0 3px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 3px;
    white-space: nowrap;
    --base-translate: 0%;
    --label-offset: 0px;
    --label-offset-x: 0px;
    transform: translateX(var(--label-offset-x)) translateY(var(--base-translate)) translateY(var(--label-offset));
}

.buoyancy-arrow .arrow-label {
    top: 0;
    --base-translate: -50%;
}

.gravity-arrow .arrow-label {
    bottom: 0;
    --base-translate: 50%;
}

.pressure-down-arrow .arrow-label {
    top: 0;
    --base-translate: -50%;
}

.pressure-up-arrow .arrow-label {
    bottom: 0;
    --base-translate: 50%;
}

.water-line {
    position: absolute;
    left: 0;
    width: 100%;
    border-top: 2px dashed white;
    z-index: 10;
    pointer-events: none;
    transition: bottom 0.3s ease-out;
    display: none;
}

.info-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.status-display {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}

.status-box {
    background: #f0f8ff;
    color: black;
    padding: 15px;
    border-radius: 8px;
    min-width: 250px;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    flex: 1;
}

.status-title {
    font-size: 1rem;
    margin-bottom: 8px;
}

.status-value {
    font-size: 1.4rem;
    font-weight: bold;
}

.floating {
    color: #4CAF50;
}

.suspended {
    color: #2575fc;
}

.sinking {
    color: #F44336;
}

.supported {
    color: #6D4C41;
}

.formula-box {
    background: #f0f8ff;
    color: black;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.formula-title {
    font-size: 1rem;
    margin-bottom: 8px;
}

.formula-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 8px;
    position: relative;
}

.formula-header .formula-title {
    margin-bottom: 0;
}

.formula-content {
    font-size: 1.4rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.value-content {
    font-size: 1.2rem;
    font-weight: bold;
    color: black;
    margin-bottom: 5px;
}

.formula-explanation {
    font-size: 0.9rem;
    opacity: 0.9;
}

.controls {
    flex: 1;
    min-width: 300px;
    background-color: #f8f9fa;
    padding: 16px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#tankControlsDesktopAnchor {
    margin-bottom: 14px;
}

#tankControlsDesktopAnchor:empty {
    display: none;
}

@media (max-width: 991px) {
    #tankControlsDesktopAnchor {
        display: none !important;
    }
}

.primary-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 18px;
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.primary-button {
    padding: 10px 22px;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #ffffff;
    background-color: #4CAF50;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.primary-button.secondary {
    background-color: #2196F3;
}

.primary-button:hover:not(:disabled) {
    background-color: #43a047;
}

.primary-button.secondary:hover:not(:disabled) {
    background-color: #1a86dc;
}

.primary-button:disabled,
.primary-button.disabled {
    background-color: #cccccc;
    color: #f5f5f5;
    cursor: not-allowed;
}

.preset-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
    position: relative;
}

.preset-selector label {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #005792;
}

.preset-selector select {
    min-width: 140px;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #cccccc;
    font-size: 0.95rem;
    color: #333333;
    background-color: #ffffff;
}

.preset-selector select:focus {
    outline: none;
    border-color: #2196F3;
}

.melt-control {
    margin-bottom: 18px;
    padding: 14px 16px 12px;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 14px;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 123, 255, 0.18);
}

.melt-control label {
    font-size: 0.95rem;
    color: #005792;
    font-weight: 600;
}

.melt-control-inner {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 10px;
}

.melt-control-inner input[type="range"] {
    flex: 1;
}

.melt-control-inner span {
    min-width: 48px;
    text-align: right;
    font-weight: 600;
    color: #ff7043;
    font-size: 1rem;
}

.controls-section {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    margin-top: 20px;
}

.control-group {
    margin-bottom: 20px;
    padding: 10px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.controls-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.controls-row .control-group {
    flex: 1;
    margin-bottom: 0;
}

.control-group.full-width {
    flex: 1 0 100%;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: black;
}

input[type="range"] {
    width: 100%;
}

input[type="range"]:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.value-display {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.value-display.ice-stack {
    flex-direction: column;
}

.value-box {
    background: #f0f8ff;
    color: black;
    padding: 12px 15px;
    border-radius: 8px;
    min-width: 180px;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    flex: 1;
}

.value-display.ice-stack .value-box {
    width: 100%;
}

.value-title {
    color: black;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.value {
    font-size: 1.3rem;
    font-weight: bold;
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    
    .animation-container, .controls {
        width: 100%;
    }
    
    .status-display {
        flex-direction: column;
    }
}
