/* public/truss_sim.css */

/* 1. 시뮬레이션 레이어 */
#simulation-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 20; pointer-events: none;
}

/* 2. 부재(Beam) 기본 스타일 */
.sim-beam {
    fill: #ffffff;
    stroke: #000000;
    stroke-width: 3px;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.2));
}

/* 영부재 (Zero Force) */
.sim-beam.zero {
    fill: #e0e0e0;
    stroke: #999;
    stroke-dasharray: 5, 5;
    opacity: 0.6;
}

/* 3. 화살표(Arrow) 공통 스타일 */
.sim-arrow-head {
    stroke-width: 3px;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}


/* 인장 (Tension) - 빨강 */
.sim-arrow-head.tension {
    stroke: #ff3b30;
    filter: drop-shadow(0 0 2px #ff3b30);
}

/* 압축 (Compression) - 파랑 */
.sim-arrow-head.compression {
    stroke: #007aff;
    filter: drop-shadow(0 0 2px #007aff);
}

/* 4. 텍스트 스타일 */
.sim-text-bg {
    fill: rgba(255, 255, 255, 0.85);
    rx: 4px;
}
.sim-text {
    font-size: 16px;
    font-weight: 800;
    text-anchor: middle;
    dominant-baseline: central;
}


/* 2. 결과 텍스트 (힘의 크기) */
.sim-force-text {
    font-size: 14px;
    font-weight: 900;
    text-anchor: middle;
    dominant-baseline: central;
    filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.8));
    opacity: 0;
    animation: fade-in-text 0.5s forwards 0.5s; /* 0.5초 뒤 등장 */
}

/* 3. 화살표 애니메이션 정의 */
@keyframes arrow-flow-tension {
    0% { transform: translate(0, 0); opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { transform: translate(var(--tx), var(--ty)); opacity: 0; }
}

@keyframes arrow-flow-compression {
    0% { transform: translate(var(--tx), var(--ty)); opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { transform: translate(0, 0); opacity: 0; }
}

/* 화살표 공통 스타일 */
.sim-arrow {
    opacity: 0; /* 시작 전 숨김 */
}

.sim-arrow.tension {
    fill: #ff3b30; /* 빨강 */
    animation: arrow-flow-tension 1.5s infinite ease-out;
}

.sim-arrow.compression {
    fill: #007aff; /* 파랑 */
    animation: arrow-flow-compression 1.5s infinite ease-out;
}

@keyframes fade-in-text {
    to { opacity: 1; }
}

/* 점선 흐르는 애니메이션 */
@keyframes dash-flow {
    to {
        stroke-dashoffset: -30;
    }
}

.flow-anim {
    animation: dash-flow 1s linear infinite;
}

/* 트러스 패턴 애니메이션 */
@keyframes flow-pattern {
    from { transform: translateX(0); }
    to { transform: translateX(40px); }
}

@keyframes flow-pattern-reverse {
    from { transform: translateX(0); }
    to { transform: translateX(-40px); }
}

/* 인장 (바깥쪽으로 흐름) */
.anim-tension {
    /* SVG 패턴은 transform 속성을 애니메이션 해야 함 */
    /* 하지만 SVG 내부 rect는 CSS transform이 잘 안 먹힐 수 있음 */
    /* 대안: Javascript로 애니메이션 하거나, 아래처럼 시도 */
}

/* public/truss_sim.css 하단에 추가 */

/* 6. 자유물체도(FBD) 툴팁 박스 (Apple Style) */
#fbd-tooltip {
    position: fixed;
    width: 320px; /* 조금 더 넓게 */
    height: 320px;
    
    /* Glassmorphism 배경 */
    background: rgba(30, 30, 30, 0.75);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    
    /* 얇고 은은한 테두리 */
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px; /* 둥근 모서리 */
    
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    pointer-events: none;
    z-index: 9999;
    display: none;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    transition: opacity 0.2s ease;
}

/* 헤더 (제목) */
#fbd-tooltip h4 {
    margin: 0;
    padding: 12px 0;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 15px;
    text-align: center;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    letter-spacing: -0.5px;
}

/* SVG 캔버스 */
#fbd-svg {
    width: 100%;
    height: calc(100% - 45px);
    background: transparent; /* 배경 투명 (블러 효과 살림) */
}

.fbd-label-text {
    font-size: 13px;
    font-weight: 700;
    font-family: "SF Pro Text", -apple-system, sans-serif;
    text-anchor: middle;
    dominant-baseline: central;
}

/* 텍스트 라벨 (배지 스타일) */
.fbd-label-bg {
    fill: rgba(255, 255, 255, 0.95);
    rx: 6px; /* 둥근 사각형 */
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* public/truss_sim.css - HUD 추가 */

/* 6. HUD 컨테이너 (툴팁) */
#truss-hud {
    position: absolute;
    pointer-events: none; /* 마우스 통과 (깜빡임 방지) */
    z-index: 1000;
    
    background: rgba(28, 28, 30, 0.85); /* 진한 반투명 검정 */
    backdrop-filter: blur(12px); /* 애플 스타일 블러 */
    -webkit-backdrop-filter: blur(12px);
    
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-width: 150px;
    opacity: 0;
    transform: scale(0.95) translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#truss-hud.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* HUD 제목 */
.hud-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #f5f5f7;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    width: 100%;
    text-align: center;
    padding-bottom: 4px;
}

/* HUD 내부 SVG 캔버스 */
.hud-svg {
    overflow: visible;
}

/* HUD 텍스트 */
.hud-text {
    font-size: 12px;
    font-weight: 500;
    fill: #fff;
    text-anchor: start;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.8));
}

.hud-value {
    font-weight: 700;
}


/* public/truss_sim.css - HUD 추가 */

/* 6. HUD 컨테이너 (툴팁) */
#truss-hud {
    position: absolute;
    pointer-events: none; /* 마우스 통과 (깜빡임 방지) */
    z-index: 1000;
    
    background: rgba(28, 28, 30, 0.85); /* 진한 반투명 검정 */
    backdrop-filter: blur(12px); /* 애플 스타일 블러 */
    -webkit-backdrop-filter: blur(12px);
    
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-width: 150px;
    opacity: 0;
    transform: scale(0.95) translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#truss-hud.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* HUD 제목 */
.hud-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #f5f5f7;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    width: 100%;
    text-align: center;
    padding-bottom: 4px;
}

/* HUD 내부 SVG 캔버스 */
.hud-svg {
    overflow: visible;
}

/* HUD 텍스트 */
.hud-text {
    font-size: 12px;
    font-weight: 500;
    fill: #fff;
    text-anchor: start;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.8));
}

.hud-value {
    font-weight: 700;
}

/* 🚨 중요: SVG 패턴 애니메이션은 CSS만으로 완벽하지 않을 수 있습니다. 
   가장 확실한 방법은 위 JS 코드 내의 <pattern> 정의 안에 
   <animateTransform> 태그를 넣는 것입니다. 
   
   제가 위 JS 코드의 defs 부분을 수정해서 애니메이션을 내장하겠습니다.
   따라서 이 CSS는 굳이 추가하지 않으셔도 됩니다! (JS가 처리함)
*/