/* Stacked language display */
.stacked-language {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
    gap: 0.15rem;
}

.stacked-primary {
    font-size: 1em;
    color: inherit;
}

.stacked-secondary {
    font-size: 0.75em;
    color: rgba(107, 114, 128, 0.75);
    margin-top: -0.1em;  /* Slightly reduce space between lines */
}

/* Optional: Add a subtle transition on hover */
.stacked-language:hover .stacked-secondary {
    color: rgba(107, 114, 128, 0.9);
}

/* Table cell adjustments */
td .stacked-language,
th .stacked-language {
    display: inline-flex;
    margin: -0.25rem 0;  /* Compensate for extra height in table cells */
}

/* Compact mode for smaller spaces */
.compact .stacked-language {
    gap: 0.1rem;
}

.compact .stacked-secondary {
    font-size: 0.7em;
}

/* Core dual-language behavior */
.dual-language {
    position: relative;
    display: inline-block;
    cursor: pointer; /* Interactive styling */
}

/* Primary language styles */
.primary-language {
    opacity: 1; /* Fully visible by default */
    visibility: visible; /* Ensure the element takes part in layout */
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out; /* Smooth fading */
}

/* Secondary language styles */
.secondary-language {
    opacity: 0; /* Fully hidden by default */
    visibility: hidden;
    position: absolute; /* Overlay the secondary language on top of the primary */
    top: 0;
    left: 0;
    white-space: nowrap; /* Keeps the secondary text aligned with the primary */
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out; /* Smooth transition */
}

/* Hover behavior for desktop */
.dual-language:hover .primary-language {
    opacity: 0; /* Fade out primary language */
    visibility: hidden; /* Hide visually */
}

.dual-language:hover .secondary-language {
    opacity: 1; /* Fade in secondary language */
    visibility: visible; /* Make it visible */
}

/* Mobile-friendly behavior (tap or focus) */
.dual-language:active .primary-language,
.dual-language:focus .primary-language {
    opacity: 0;
    visibility: hidden;
}

.dual-language:active .secondary-language,
.dual-language:focus .secondary-language {
    opacity: 1;
    visibility: visible;
}