
/* animation.css - Themed for style.css */

/* 1. Class & Object Animation */

.class-object-animation {
    background: linear-gradient(135deg, #FFFFFF, #F8FAFC);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 10px;
    margin: 15px 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.class-object-animation .animation-container {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 40px;
    margin-bottom: 40px;
}

.class-object-animation .class-template {
    background: linear-gradient(135deg, #E1F5FE, #B3E5FC);
    border: 2px solid var(--primary-color);
    border-radius: 16px;
    padding: 15px;
    text-align: center;
    min-width: 320px;
    transition: all 0.6s ease;
    animation: classPulse 3s ease-in-out infinite;
    box-shadow: 0 4px 20px rgba(208, 101, 25, 0.15);
    position: relative;
    overflow: hidden;
}

.class-object-animation .class-template::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.8s ease;
}

.class-object-animation .class-template:hover::before {
    left: 100%;
}

@keyframes classPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 20px rgba(208, 101, 25, 0.15);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 6px 25px rgba(208, 101, 25, 0.2);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.class-object-animation {
    animation: fadeInUp 0.8s ease-out;
}

.class-object-animation .attribute,
.class-object-animation .method {
    animation: fadeInUp 0.6s ease-out;
    animation-fill-mode: both;
}

.class-object-animation .attribute:nth-child(1) { animation-delay: 0.1s; }
.class-object-animation .attribute:nth-child(2) { animation-delay: 0.2s; }
.class-object-animation .attribute:nth-child(3) { animation-delay: 0.3s; }
.class-object-animation .method:nth-child(4) { animation-delay: 0.4s; }
.class-object-animation .method:nth-child(5) { animation-delay: 0.5s; }

.class-object-animation .class-title {
    color: var(--accent-color);
    font-size: 1.6em;
    font-weight: 800;
    margin-bottom: 20px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.class-object-animation .class-properties {
    color: var(--text-color);
    font-size: 1.1em;
    line-height: 1.8;
    text-align: left;
    font-family: 'Roboto Mono', monospace;
}

.class-object-animation .instantiation-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.5) translateY(20px);
    transition: all 1s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.class-object-animation .instantiation-arrow.active {
    opacity: 1;
    transform: scale(1) translateY(0);
    animation: arrowPulse 1.5s ease-in-out infinite;
}

@keyframes arrowPulse {
    0%, 100% {
        transform: scale(1) translateY(0);
        box-shadow: 0 4px 15px rgba(208, 101, 25, 0.2);
    }
    50% {
        transform: scale(1.05) translateY(0);
        box-shadow: 0 6px 20px rgba(208, 101, 25, 0.3);
    }
}

.class-object-animation .instantiation-arrow.active {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.class-object-animation .arrow-line {
    width: 80px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    border-radius: 3px;
    position: relative;
    margin: 15px 0;
    box-shadow: 0 2px 8px rgba(208, 101, 25, 0.3);
    background-size: 200% 100%;
    animation: shimmer 2s infinite linear;
}

.class-object-animation .arrow-line::after {
    content: '→';
    position: absolute;
    right: -20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2em;
    color: var(--primary-color);
}

.class-object-animation .arrow-text {
    color: var(--accent-color);
    font-size: 0.9em;
    font-weight: bold;
}

.class-object-animation .object-instances {
    display: flex;
    flex-direction: column;
    gap: 25px;
    min-width: 280px;
}

.class-object-animation .object-instance {
    background: linear-gradient(135deg, #FFF8E1, #FFECB3);
    border: 2px solid var(--accent-color);
    border-radius: 16px;
    padding: 30px;
    margin: 15px;
    text-align: center;
    opacity: 0;
    transform: translateX(40px) scale(0.95);
    transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    min-width: 280px;
    box-shadow: 0 4px 20px rgba(138, 74, 18, 0.15);
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.class-object-animation .object-instance::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.6s ease;
}

.class-object-animation .object-instance:hover::before {
    left: 100%;
}

.class-object-animation .object-instance:hover {
    transform: translateX(0) scale(1.02);
    box-shadow: 0 8px 32px rgba(138, 74, 18, 0.25);
}

.class-object-animation .object-instance.active {
    opacity: 1;
    transform: translateX(0) scale(1);
    box-shadow: 0 8px 32px rgba(138, 74, 18, 0.25);
    animation: objectBounce 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes objectBounce {
    0% {
        transform: translateX(40px) scale(0.95);
        opacity: 0;
    }
    60% {
        transform: translateX(-5px) scale(1.05);
        opacity: 1;
    }
    100% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

.class-object-animation .object-instance:nth-child(2).active {
    transition-delay: 0.3s;
}
.class-object-animation .object-instance:nth-child(3).active {
    transition-delay: 0.6s;
}

.class-object-animation .object-title {
    color: var(--accent-color);
    font-size: 1.3em;
    font-weight: 700;
    margin-bottom: 15px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.class-object-animation .object-values {
    color: var(--text-color);
    font-size: 1em;
    line-height: 1.7;
    text-align: left;
    font-family: 'Roboto Mono', monospace;
}

.class-object-animation .animation-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 25px;
    position: relative;
}

.class-object-animation .animation-progress {
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(208, 101, 25, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.class-object-animation .animation-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 2px;
}

.memory-model-animation .animation-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-top: 25px;
}

/* Use styles from style.css for buttons */
.animation-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(208, 101, 25, 0.3);
    position: relative;
    overflow: hidden;
}

.animation-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.animation-btn:hover::before {
    left: 100%;
}

.animation-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(208, 101, 25, 0.4);
}

.animation-btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 10px rgba(208, 101, 25, 0.3);
}

.animation-btn:active::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    animation: ripple 0.6s ease-out;
}

@keyframes ripple {
    to {
        transform: translate(-50%, -50%) scale(20);
        opacity: 0;
    }
}


/* 2. Memory Model Animation */

.memory-model-animation {
    background: linear-gradient(135deg, #FFFFFF, #F8FAFC);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 40px;
    margin: 40px 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.memory-model-animation .memory-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    margin-bottom: 40px;
}

.memory-model-animation .memory-section {
    background: var(--bg-color);
    border-radius: 16px;
    padding: 30px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.memory-model-animation .memory-section h4 {
    color: var(--heading-color);
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.2em;
}

.memory-model-animation .memory-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.memory-model-animation .memory-area {
    background: #FFFFFF;
    border-radius: 8px;
    padding: 15px;
    min-height: 200px;
    flex: 1;
    position: relative;
}

.memory-model-animation .stack-area {
    border: 2px solid var(--warning-text-color);
    background-color: var(--warning-bg-color);
}

.memory-model-animation .heap-area {
    border: 2px solid var(--primary-color);
    background-color: #FFF3E0; /* Light orange */
}

.memory-model-animation .memory-label {
    color: var(--text-color);
    font-weight: bold;
    text-align: center;
    margin-bottom: 15px;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.memory-model-animation .variable-container,
.memory-model-animation .object-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.memory-model-animation .variable-box {
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s ease;
}

.memory-model-animation .variable-box.active {
    opacity: 1;
    transform: translateY(0);
}

.memory-model-animation .primitive-var.active {
    border-color: var(--warning-text-color);
    box-shadow: 0 0 15px rgba(185, 28, 28, 0.3);
}

.memory-model-animation .reference-var.active {
    border-color: var(--accent-color);
    box-shadow: 0 0 15px rgba(138, 74, 18, 0.3);
}

.memory-model-animation .var-name {
    color: #6B7280; /* Gray from style.css */
    font-size: 0.85em;
    margin-bottom: 5px;
    font-family: 'Roboto Mono', monospace;
}

.memory-model-animation .var-value {
    color: var(--text-color);
    font-weight: bold;
    font-family: 'Roboto Mono', monospace;
}

.memory-model-animation .reference-arrow {
    color: var(--accent-color) !important;
    position: relative;
}

.memory-model-animation .reference-arrow::after {
    content: '→';
    position: absolute;
    right: -50px;
    top: 0;
    color: var(--accent-color);
    font-size: 1.2em;
    opacity: 0;
    animation: arrowBlink 1s infinite alternate;
}

.memory-model-animation .reference-var.active .reference-arrow::after {
    opacity: 1;
}

@keyframes arrowBlink {
    0% { opacity: 0.3; }
    100% { opacity: 1; }
}

.memory-model-animation .object-box {
    background: #FFFFFF;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    padding: 15px;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.8s ease;
}

.memory-model-animation .object-box.active {
    opacity: 1;
    transform: scale(1);
    animation: objectPulse 2s infinite alternate;
}

@keyframes objectPulse {
    0% { box-shadow: 0 0 15px rgba(208, 101, 25, 0.3); }
    100% { box-shadow: 0 0 25px rgba(208, 101, 25, 0.6); }
}

.memory-model-animation .object-address {
    color: var(--primary-color);
    font-size: 0.8em;
    font-weight: bold;
    text-align: center;
    margin-bottom: 10px;
    font-family: 'Roboto Mono', monospace;
}

.memory-model-animation .object-content {
    border-top: 1px solid var(--border-color);
    padding-top: 10px;
}

.memory-model-animation .object-field {
    color: var(--text-color);
    font-size: 0.85em;
    margin-bottom: 5px;
    font-family: 'Roboto Mono', monospace;
}

.memory-model-animation .code-snippet {
    background-color: var(--code-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
    border-left: 4px solid var(--primary-color);
}

.memory-model-animation .code-snippet code {
    background-color: transparent;
    color: var(--code-text-color);
    font-family: 'Roboto Mono', monospace;
    font-size: 0.9em;
    line-height: 1.4;
}

.memory-model-animation .animation-steps {
    display: flex;
    flex-wrap: wrap; /* 允许元素换行 */
    gap: 15px;       /* 子元素之间的间距 */
    margin-top: 20px; /* 上边距 */
    justify-content: space-between; /* 左右对齐，元素之间有间隔 */
}

.memory-model-animation .step-indicator {
    background: var(--code-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    color: #6B7280;
    font-size: 0.9em;
    opacity: 0.7;
    transition: all 0.3s ease;
}

.memory-model-animation .step-indicator.active {
    opacity: 1;
    border-color: var(--primary-color);
    background: #FFF3E0;
    color: var(--accent-color);
    font-weight: bold;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(208, 101, 25, 0.2);
}

/* Responsive Design */
@media (max-width: 768px) {
    .class-object-animation .animation-container {
        flex-direction: column;
        align-items: center;
        gap: 30px;
    }
    
    .class-object-animation .instantiation-arrow {
        transform: rotate(90deg) scale(0.5);
    }
    
    .class-object-animation .instantiation-arrow.active {
        transform: rotate(90deg) scale(1);
    }
    
    .class-object-animation .class-template,
    .class-object-animation .object-instances {
        min-width: 250px;
    }

    .memory-model-animation .memory-comparison {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    .memory-model-animation .memory-layout {
        flex-direction: column;
        gap: 15px;
    }
    
    .memory-model-animation .animation-steps {
        grid-template-columns: 1fr;
    }
}

/* Access Control Animation Demo */
.access-control-animation {
    background: linear-gradient(135deg, #F8F9FA, #E9ECEF);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.package-structure {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
    justify-content: space-around;
}

.package-folder {
    background: #FFFFFF;
    border: 2px solid #6C757D;
    border-radius: 12px;
    padding: 15px;
    min-width: 350px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.folder-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
    padding: 10px;
    background: linear-gradient(135deg, #E3F2FD, #BBDEFB);
    border-radius: 8px;
    font-weight: bold;
    color: #1976D2;
}

.folder-icon {
    font-size: 1.2em;
}

.folder-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.java-file {
    background: #F8F9FA;
    border: 1px solid #DEE2E6;
    border-radius: 8px;
    padding: 12px;
    transition: all 0.3s ease;
}

.java-file:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.file-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-weight: bold;
    color: #495057;
}

.file-icon {
    font-size: 1.1em;
}

.extends-label {
    background: #E8F5E8;
    color: #2E7D32;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    margin-left: auto;
}

.class-members {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.member {
    padding: 8px 12px;
    border-radius: 6px;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.9em;
    transition: all 0.3s ease;
}

.member.public {
    background: #E8F5E8;
    border-left: 4px solid #4CAF50;
}

.member.protected {
    background: #FFF3E0;
    border-left: 4px solid #FF9800;
}

.member.default {
    background: #E3F2FD;
    border-left: 4px solid #2196F3;
}

.member.private {
    background: #FFEBEE;
    border-left: 4px solid #F44336;
}

.access-modifier {
    font-weight: bold;
    margin-right: 8px;
}

.access-attempts {
    min-height: 120px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.access-attempt {
    padding: 6px 10px;
    border-radius: 4px;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.85em;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transform: translateX(-20px);
    transition: all 0.4s ease;
}

.access-attempt.show {
    opacity: 1;
    transform: translateX(0);
}

.access-attempt.success {
    background: #E8F5E8;
    border-left: 3px solid #4CAF50;
    color: #2E7D32;
}

.access-attempt.failure {
    background: #FFEBEE;
    border-left: 3px solid #F44336;
    color: #C62828;
}

.access-icon {
    font-size: 1.1em;
}

.animation-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 25px 0;
    flex-wrap: wrap;
}

.control-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
    min-width: 140px;
}

.control-btn:hover {
    background-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(208, 101, 25, 0.3);
}

.access-legend {
    background: #F8F9FA;
    border: 1px solid #DEE2E6;
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
}

.access-legend h4 {
    margin: 0 0 12px 0;
    color: var(--text-color);
}

.legend-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9em;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
}

.legend-color.public { background: #4CAF50; }
.legend-color.protected { background: #FF9800; }
.legend-color.default { background: #2196F3; }
.legend-color.private { background: #F44336; }

.test-results {
    background: #FFFFFF;
    border: 1px solid #DEE2E6;
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
}

.test-results h4 {
    margin: 0 0 12px 0;
    color: var(--text-color);
}

.results-content {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.9em;
    line-height: 1.6;
    color: #495057;
}

@media (max-width: 768px) {
    .package-structure {
        flex-direction: column;
        gap: 20px;
    }
    
    .package-folder {
        min-width: auto;
    }
    
    .animation-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .control-btn {
        width: 100%;
        max-width: 200px;
    }
    
    .legend-items {
        grid-template-columns: 1fr;
    }
}