/* World Flags Explorer Styles - Dual Theme (Light & Dark) */

.flag-card {
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 1rem;
    overflow: hidden;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

html:not(.dark) .flag-card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.flag-card:hover {
    transform: translateY(-3px);
    border-color: rgba(56, 189, 248, 0.4);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
}

html:not(.dark) .flag-card:hover {
    border-color: rgba(13, 148, 136, 0.5);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.flag-card-img-wrap {
    position: relative;
    width: 100%;
    height: 120px;
    background: radial-gradient(circle at 50% 50%, rgba(30, 41, 59, 0.5) 0%, rgba(15, 23, 42, 0.8) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

html:not(.dark) .flag-card-img-wrap {
    background: radial-gradient(circle at 50% 50%, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.flag-card-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
    transition: transform 0.2s ease;
}

html:not(.dark) .flag-card-img {
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.18));
}

.flag-card:hover .flag-card-img {
    transform: scale(1.05);
}

/* List View Variant */
.flags-container.is-list-view {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.flags-container.is-list-view .flag-card {
    flex-direction: row;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
}

.flags-container.is-list-view .flag-card-img-wrap {
    width: 60px;
    height: 40px;
    padding: 0.25rem;
    background: transparent;
    border-bottom: none;
    flex-shrink: 0;
}

.flags-container.is-list-view .flag-card-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
}

/* Modal Details - Bulletproof Responsive Dialog */
.flag-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    visibility: hidden;
}

@media (min-width: 640px) {
    .flag-modal-overlay {
        padding: 1.5rem;
    }
}

html:not(.dark) .flag-modal-overlay {
    background: rgba(15, 23, 42, 0.55);
}

.flag-modal-overlay.is-active {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

.flag-modal-dialog {
    width: 100%;
    max-width: 820px;
    max-height: calc(100dvh - 1.5rem);
    height: auto;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 1.25rem;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.75);
    display: flex;
    flex-direction: column;
    margin: auto;
    animation: flagModalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 640px) {
    .flag-modal-dialog {
        max-height: min(92dvh, 700px);
    }
}

@keyframes flagModalIn {
    from {
        transform: scale(0.96);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

html:not(.dark) .flag-modal-dialog {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2);
}

.flag-modal-header {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 20;
    background: #0f172a;
}

html:not(.dark) .flag-modal-header {
    background: #ffffff;
}

.flag-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.flag-modal-footer {
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 20;
    background: #0f172a;
}

html:not(.dark) .flag-modal-footer {
    background: #ffffff;
}

.flag-preview-stage {
    position: relative;
    width: 100%;
    height: 130px;
    background: radial-gradient(circle at 50% 50%, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.95) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

@media (min-width: 768px) {
    .flag-preview-stage {
        height: 180px;
    }
}

html:not(.dark) .flag-preview-stage {
    background: radial-gradient(circle at 50% 50%, #f8fafc 0%, #e2e8f0 100%);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.flag-preview-stage.is-transparent-bg {
    background-image: 
        linear-gradient(45deg, rgba(255, 255, 255, 0.05) 25%, transparent 25%), 
        linear-gradient(-45deg, rgba(255, 255, 255, 0.05) 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.05) 75%), 
        linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.05) 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

html:not(.dark) .flag-preview-stage.is-transparent-bg {
    background-image: 
        linear-gradient(45deg, rgba(0, 0, 0, 0.04) 25%, transparent 25%), 
        linear-gradient(-45deg, rgba(0, 0, 0, 0.04) 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, rgba(0, 0, 0, 0.04) 75%), 
        linear-gradient(-45deg, transparent 75%, rgba(0, 0, 0, 0.04) 75%);
}

/* Styled radio cards for File Format */
.modal-format-card:has(input:checked) {
    border-color: #14b8a6;
    background: rgba(20, 184, 166, 0.12);
    box-shadow: 0 0 0 1px rgba(20, 184, 166, 0.4);
}

html:not(.dark) .modal-format-card:has(input:checked) {
    border-color: #0d9488;
    background: rgba(13, 148, 136, 0.08);
    box-shadow: 0 0 0 1px rgba(13, 148, 136, 0.3);
}

.filter-pill {
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(30, 41, 59, 0.5);
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

html:not(.dark) .filter-pill {
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: #f1f5f9;
    color: #475569;
}

.filter-pill:hover {
    background: rgba(51, 65, 85, 0.7);
    color: #f8fafc;
}

html:not(.dark) .filter-pill:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.filter-pill.is-active {
    background: rgba(13, 148, 136, 0.2);
    border-color: #14b8a6;
    color: #2dd4bf;
    font-weight: 600;
}

html:not(.dark) .filter-pill.is-active {
    background: rgba(13, 148, 136, 0.12);
    border-color: #0d9488;
    color: #0f766e;
    font-weight: 600;
}

.letter-jump-btn {
    width: 1.75rem;
    height: 1.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    font-size: 0.6875rem;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(30, 41, 59, 0.4);
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

html:not(.dark) .letter-jump-btn {
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: #f1f5f9;
    color: #475569;
}

.letter-jump-btn:hover {
    background: rgba(51, 65, 85, 0.7);
    color: #ffffff;
}

html:not(.dark) .letter-jump-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.letter-jump-btn.is-active {
    background: #14b8a6;
    border-color: #14b8a6;
    color: #ffffff;
}

html:not(.dark) .letter-jump-btn.is-active {
    background: #0d9488;
    border-color: #0d9488;
    color: #ffffff;
}

/* Color Chips in Modal */
.flag-color-chip {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

html:not(.dark) .flag-color-chip {
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.flag-color-chip:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.flag-color-chip:focus-visible {
    outline: 2px solid #14b8a6;
    outline-offset: 2px;
}

/* Card Quick Download & Compare Buttons */
.card-quick-btn {
    opacity: 0.85;
    transition: opacity 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.flag-card:hover .card-quick-btn {
    opacity: 1;
}

.card-quick-btn:hover {
    transform: scale(1.08);
}

/* Comparison Sticky Drawer */
.compare-sticky-bar {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    z-index: 40;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
    opacity: 0;
    pointer-events: none;
    max-width: calc(100vw - 2rem);
}

.compare-sticky-bar.is-visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* Accessibility & Focus Indicators */
.flag-card:focus-visible,
.filter-pill:focus-visible,
.letter-jump-btn:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid #14b8a6;
    outline-offset: 2px;
}

/* High contrast subtle borders for cards in light theme */
html:not(.dark) .flag-card {
    border: 1px solid rgba(0, 0, 0, 0.09);
}

/* Progress bar animation */
@keyframes progressStripes {
    from { background-position: 1rem 0; }
    to { background-position: 0 0; }
}

.progress-animated {
    background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
    background-size: 1rem 1rem;
    animation: progressStripes 1s linear infinite;
}
