/*
 * rlhf-preference-game.css
 * Styles for the RLHF Human Preference Alignment Game
 * 
 * PEDAGOGICAL NOTE: Visual design emphasizes the comparison between
 * responses and the gradual adaptation of the model to human preferences.
 */

/* ============================================
   MAIN CONTAINER
   ============================================ */

.rlhf-game {
    background: var(--demo-surface);
    border: 1px solid var(--demo-border);
    border-radius: var(--demo-radius-lg);
    padding: var(--demo-spacing-lg);
    font-family: var(--demo-font);
}

/* ============================================
   GAME HEADER
   ============================================ */

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--demo-spacing-lg);
    padding-bottom: var(--demo-spacing);
    border-bottom: 1px solid var(--demo-border);
    flex-wrap: wrap;
    gap: var(--demo-spacing);
}

.round-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: linear-gradient(135deg, var(--demo-accent) 0%, var(--demo-primary) 100%);
    padding: 0.75rem 1.5rem;
    border-radius: calc(var(--demo-radius) * 1.5);
    border: 2px solid var(--demo-accent);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: pulseRound 2s ease-in-out infinite;
}

@keyframes pulseRound {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    50% {
        transform: scale(1.02);
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    }
}

.round-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.round-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.preference-profile-summary {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.profile-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.5rem;
    background: var(--demo-surface-alt);
    border-radius: var(--demo-radius-xs);
    font-size: 0.75rem;
    border: 1px solid var(--demo-border);
    animation: badge-appear 0.3s ease-out;
}

@keyframes badge-appear {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================
   MAIN LAYOUT
   ============================================ */

.game-main-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: var(--demo-spacing-lg);
    margin-bottom: var(--demo-spacing-lg);
}

@media (max-width: 950px) {
    .game-main-layout {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   NETWORK PANEL (Left Side)
   ============================================ */

.network-panel,
.preference-panel {
    background: var(--demo-surface-alt);
    border: 1px solid var(--demo-border);
    border-radius: var(--demo-radius);
    padding: var(--demo-spacing);
}

.panel-title,
.section-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--demo-spacing);
    color: var(--demo-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-icon {
    font-size: 1.1rem;
}

/* Network Container */
.network-container {
    background: var(--demo-bg);
    border: 1px solid var(--demo-border);
    border-radius: var(--demo-radius-sm);
    padding: var(--demo-spacing);
    min-height: 240px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* SVG Network Styles */
.rlhf-network-svg {
    width: 100%;
    height: 220px;
    display: block;
}

.rlhf-connection {
    transition: stroke 0.4s ease, stroke-width 0.4s ease, stroke-opacity 0.4s ease;
}

.rlhf-connection.highlighted {
    stroke-width: 4px !important;
    stroke-opacity: 1 !important;
    filter: drop-shadow(0 0 4px currentColor);
    animation: connection-pulse 0.6s ease-out;
}

.rlhf-node {
    transition: fill 0.4s ease, stroke 0.2s ease;
}

.rlhf-node.highlighted {
    stroke: #ffd700 !important;
    stroke-width: 4px !important;
    filter: drop-shadow(0 0 8px #ffd700);
    animation: node-pulse 0.6s ease-out;
}

.rlhf-node-value {
    font-family: var(--demo-font-mono, monospace);
    pointer-events: none;
    transition: fill 0.3s ease;
    font-size: 8px;
}

.rlhf-layer-label {
    font-family: var(--demo-font);
    font-weight: 500;
    font-size: 9px;
}

@keyframes node-pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
    }

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

@keyframes connection-pulse {
    0% {
        stroke-opacity: 0.3;
    }

    50% {
        stroke-opacity: 1;
    }

    100% {
        stroke-opacity: 0.7;
    }
}

/* Mini network for comparison */
.mini-network-svg {
    width: 100%;
    height: 80px;
    display: block;
}

/* Legend */
.network-legend {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: var(--demo-spacing);
    flex-wrap: wrap;
    padding: 0.5rem;
    background: var(--demo-surface-alt);
    border-radius: var(--demo-radius-xs);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    color: var(--demo-neutral);
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid var(--demo-border);
}

.legend-negative {
    background: linear-gradient(135deg, #424242, #212121);
}

.legend-zero {
    background: linear-gradient(135deg, #f5f5f5, #e0e0e0);
}

.legend-positive {
    background: linear-gradient(135deg, #f44336, #d32f2f);
}

/* ============================================
   CRITERIA PANEL
   ============================================ */

.criteria-panel {
    margin-top: var(--demo-spacing);
    padding-top: var(--demo-spacing);
    border-top: 1px solid var(--demo-border);
}

.criteria-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: var(--demo-spacing-sm);
    color: var(--demo-text);
}

.criteria-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.criterion-item {
    display: grid;
    grid-template-columns: 24px 1fr 60px 30px;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem;
    background: var(--demo-bg);
    border-radius: var(--demo-radius-xs);
    transition: background 0.3s ease;
}

.criterion-item.highlighted {
    background: rgba(76, 175, 80, 0.1);
    animation: criterion-flash 0.5s ease-out;
}

@keyframes criterion-flash {
    0% {
        background: rgba(76, 175, 80, 0.3);
    }

    100% {
        background: rgba(76, 175, 80, 0.1);
    }
}

.criterion-icon {
    font-size: 1rem;
    text-align: center;
}

.criterion-name {
    font-size: 0.8rem;
    color: var(--demo-text);
}

.criterion-bar {
    height: 6px;
    background: var(--demo-surface-muted);
    border-radius: 3px;
    overflow: hidden;
}

.criterion-fill {
    height: 100%;
    background: var(--demo-gradient-accent);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.criterion-value {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--demo-accent);
    text-align: right;
}

/* Positive/negative indicator */
.criterion-value.positive {
    color: var(--demo-success, #4CAF50);
}

.criterion-value.negative {
    color: var(--demo-danger, #f44336);
}

/* ============================================
   PREFERENCE PANEL (Right Side)
   ============================================ */

.preference-panel {
    display: flex;
    flex-direction: column;
    gap: var(--demo-spacing);
}

/* Prompt Section */
.prompt-section {
    background: var(--demo-bg);
    border: 1px solid var(--demo-border);
    border-radius: var(--demo-radius);
    padding: var(--demo-spacing);
}

.prompt-display {
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--demo-text);
    padding: var(--demo-spacing);
    background: var(--demo-surface);
    border-radius: var(--demo-radius-sm);
    border-left: 4px solid var(--demo-accent);
}

/* Responses Section */
.responses-section {
    flex: 1;
}

.instruction-text {
    font-size: 0.9rem;
    color: var(--demo-neutral);
    margin-bottom: var(--demo-spacing);
}

.responses-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--demo-spacing);
}

@media (max-width: 700px) {
    .responses-container {
        grid-template-columns: 1fr;
    }
}

/* Response Cards */
.response-card {
    background: var(--demo-bg);
    border: 2px solid var(--demo-border);
    border-radius: var(--demo-radius);
    padding: var(--demo-spacing);
    display: flex;
    flex-direction: column;
    gap: var(--demo-spacing-sm);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.response-card:hover {
    border-color: var(--demo-accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.response-card.selected {
    border-color: var(--demo-success, #4CAF50);
    background: rgba(76, 175, 80, 0.05);
}

.response-card.not-selected {
    opacity: 0.5;
    pointer-events: none;
}

.response-card.disabled {
    pointer-events: none;
    cursor: default;
}

.response-label {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--demo-accent);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    border: 2px solid var(--demo-surface);
}

.response-content {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--demo-text);
    min-height: 100px;
    padding-top: 0.5rem;
}

.select-btn {
    margin-top: auto;
    padding: 0.6rem 1rem;
    background: var(--demo-accent);
    color: white;
    border: none;
    border-radius: var(--demo-radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s ease;
}

.select-btn:hover {
    background: var(--demo-accent-dark, #1976D2);
}

.response-card.selected .select-btn {
    background: var(--demo-success, #4CAF50);
}

.response-card.not-selected .select-btn {
    display: none;
}

/* ============================================
   FEEDBACK MODAL
   ============================================ */

.feedback-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.feedback-modal {
    background: var(--demo-surface);
    border-radius: var(--demo-radius-lg);
    padding: var(--demo-spacing-lg);
    max-width: 500px;
    width: 100%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.feedback-modal .feedback-icon {
    font-size: 4rem;
    margin-bottom: var(--demo-spacing);
    animation: bounceIn 0.5s ease;
    color: var(--demo-success, #4CAF50);
}

@keyframes bounceIn {
    0% {
        transform: scale(0);
    }

    50% {
        transform: scale(1.1);
    }

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

.feedback-modal .feedback-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--demo-success, #4CAF50);
    margin-bottom: var(--demo-spacing);
}

.feedback-modal .feedback-content {
    margin-bottom: var(--demo-spacing-lg);
    font-size: 1rem;
    line-height: 1.6;
}

.criteria-feedback {
    margin-bottom: var(--demo-spacing);
}

.criteria-feedback-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    font-size: 0.9rem;
}

.criteria-feedback-item .icon {
    font-size: 1rem;
}

.criteria-feedback-item .direction {
    font-weight: 600;
}

.criteria-feedback-item .direction.up {
    color: var(--demo-success, #4CAF50);
}

.criteria-feedback-item .direction.down {
    color: var(--demo-danger, #f44336);
}

/* Network adjustment animation */
.network-adjustment-indicator {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: var(--demo-spacing-sm);
    background: var(--demo-surface-alt);
    border-radius: var(--demo-radius-sm);
    margin-bottom: var(--demo-spacing);
}

.adjustment-animation {
    display: flex;
    gap: 4px;
}

.adjustment-animation .pulse {
    width: 8px;
    height: 8px;
    background: var(--demo-accent);
    border-radius: 50%;
    animation: pulse-animation 1s ease-in-out infinite;
}

.adjustment-animation .pulse:nth-child(2) {
    animation-delay: 0.2s;
}

.adjustment-animation .pulse:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes pulse-animation {

    0%,
    100% {
        opacity: 0.3;
        transform: scale(0.8);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

.adjustment-text {
    font-size: 0.85rem;
    color: var(--demo-neutral);
    margin: 0;
}

.next-btn {
    width: 100%;
}

/* ============================================
   GAME COMPLETION
   ============================================ */

.game-complete-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--demo-spacing);
}

.game-complete-modal {
    background: var(--demo-surface);
    border-radius: var(--demo-radius-lg);
    padding: var(--demo-spacing-lg);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modal-appear 0.3s ease-out;
}

@keyframes modal-appear {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.completion-title {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: var(--demo-spacing-lg);
    color: var(--demo-text);
}

/* State Comparison */
.comparison-section {
    margin-bottom: var(--demo-spacing-lg);
}

.comparison-section h4 {
    text-align: center;
    margin-bottom: var(--demo-spacing);
    color: var(--demo-text);
}

.state-comparison {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--demo-spacing);
    flex-wrap: wrap;
}

.state-box {
    background: var(--demo-surface-alt);
    border: 1px solid var(--demo-border);
    border-radius: var(--demo-radius);
    padding: var(--demo-spacing);
    min-width: 180px;
    text-align: center;
}

.state-box h5 {
    font-size: 0.85rem;
    margin-bottom: var(--demo-spacing-sm);
    color: var(--demo-neutral);
}

.state-arrow {
    font-size: 1.5rem;
}

.mini-network {
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Preference Profile */
.preference-profile {
    margin-bottom: var(--demo-spacing-lg);
}

.preference-profile h4 {
    text-align: center;
    margin-bottom: var(--demo-spacing);
    color: var(--demo-text);
}

.final-criteria-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--demo-spacing);
}

@media (max-width: 500px) {
    .final-criteria-list {
        grid-template-columns: 1fr;
    }
}

.final-criterion {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: var(--demo-spacing-sm);
    background: var(--demo-surface-alt);
    border-radius: var(--demo-radius-sm);
}

.final-criterion .icon {
    font-size: 1.2rem;
}

.final-criterion .name {
    flex: 1;
    font-size: 0.9rem;
}

.final-criterion .value {
    font-weight: 700;
    font-size: 1rem;
}

.final-criterion .value.positive {
    color: var(--demo-success, #4CAF50);
}

.final-criterion .value.negative {
    color: var(--demo-danger, #f44336);
}

/* Key Message */
.key-message {
    background: linear-gradient(135deg, rgba(66, 66, 66, 0.15), rgba(33, 33, 33, 0.08));
    border: 1px solid rgba(128, 128, 128, 0.3);
    border-radius: var(--demo-radius);
    padding: var(--demo-spacing);
    text-align: center;
    margin-bottom: var(--demo-spacing-lg);
}

.key-message p {
    margin: 0;
    color: var(--demo-text);
    line-height: 1.6;
}

.restart-btn {
    width: 100%;
}

/* ============================================
   GAME CONTROLS
   ============================================ */

.game-controls {
    display: flex;
    justify-content: center;
    gap: var(--demo-spacing);
    padding-top: var(--demo-spacing);
    border-top: 1px solid var(--demo-border);
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 600px) {
    .rlhf-game {
        padding: var(--demo-spacing);
    }

    .game-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .prompt-display {
        font-size: 0.95rem;
    }

    .response-content {
        font-size: 0.9rem;
        min-height: 80px;
    }
}