/* ==================== node-card animation ==================== */

.node-card {
    transition: transform var(--transition), box-shadow var(--transition);
}

.node-card.animate-in {
    animation: fadeInUp 0.4s ease forwards;
    opacity: 0;
}

.node-card:nth-child(1).animate-in { animation-delay: 0.05s; }
.node-card:nth-child(2).animate-in { animation-delay: 0.1s; }
.node-card:nth-child(3).animate-in { animation-delay: 0.15s; }
.node-card:nth-child(4).animate-in { animation-delay: 0.2s; }
.node-card:nth-child(5).animate-in { animation-delay: 0.25s; }
.node-card:nth-child(6).animate-in { animation-delay: 0.3s; }
.node-card:nth-child(7).animate-in { animation-delay: 0.35s; }
.node-card:nth-child(8).animate-in { animation-delay: 0.4s; }
.node-card:nth-child(9).animate-in { animation-delay: 0.45s; }
.node-card:nth-child(10).animate-in { animation-delay: 0.5s; }

.node-card:hover .status-dot,
.node-card:hover .node-status-dot {
    transform: scale(1.2);
}

.node-card:hover .metric-value {
    transform: translateX(4px);
}

.node-card:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
}

/* ==================== Custom background overrides ==================== */

body.has-custom-background .node-card {
    background: rgba(var(--bg-card-rgb), var(--custom-card-alpha, 0.75));
    border-color: rgba(var(--border-color-rgb), 0.4);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06),
                0 1px 4px rgba(0, 0, 0, 0.04);
}

body.has-custom-background .node-card:hover {
    background: rgba(var(--bg-card-rgb), 0.88);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1),
                0 4px 8px rgba(0, 0, 0, 0.06);
    border-color: rgba(var(--accent-rgb), 0.5);
}

body.has-custom-background .node-card::after {
    background: linear-gradient(135deg, transparent 40%, rgba(255, 255, 255, 0.06) 100%);
}

body.has-custom-background .table-card {
    background: rgba(var(--bg-card-rgb), var(--custom-card-alpha, 0.7));
    border-color: rgba(var(--border-color-rgb), 0.4);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

body.has-custom-background .table-card:hover {
    background: rgba(var(--bg-card-rgb), 0.85);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    border-color: rgba(var(--accent-rgb), 0.5);
}

body.has-custom-background .node-card-header {
    border-bottom-color: rgba(var(--border-color-rgb), 0.35);
}

body.has-custom-background .node-card-footer {
    border-top-color: rgba(var(--border-color-rgb), 0.35);
}

body.has-custom-background .node-api-tag {
    background: rgba(var(--bg-card-rgb), 0.55);
}

body.has-custom-background .node-api-tag.tag-green,
body.has-custom-background .node-api-tag.tag-success {
    background: rgba(76, 175, 125, 0.15);
}

body.has-custom-background .node-api-tag.tag-red,
body.has-custom-background .node-api-tag.tag-danger {
    background: rgba(231, 76, 94, 0.15);
}

body.has-custom-background .node-api-tag.tag-blue,
body.has-custom-background .node-api-tag.tag-info {
    background: rgba(92, 156, 237, 0.15);
}

body.has-custom-background .node-api-tag.tag-yellow,
body.has-custom-background .node-api-tag.tag-warning,
body.has-custom-background .node-api-tag.tag-orange {
    background: rgba(245, 166, 35, 0.15);
}

body.has-custom-background .node-api-tag.tag-purple,
body.has-custom-background .node-api-tag.tag-pink {
    background: rgba(232, 102, 138, 0.15);
}

body.has-custom-background .node-api-tag.tag-cyan {
    background: rgba(8, 145, 178, 0.15);
}

body.has-custom-background .node-api-tag.tag-gray {
    background: rgba(var(--border-color-rgb), 0.25);
}

body.has-custom-background .node-expiry.level-normal {
    background: rgba(var(--bg-card-rgb), 0.5);
}

body.has-custom-background .node-ping.level-normal {
    background: rgba(76, 175, 125, 0.12);
}

body.has-custom-background .node-ping.level-warning {
    background: rgba(245, 166, 35, 0.12);
}

body.has-custom-background .node-ping.level-danger {
    background: rgba(231, 76, 94, 0.12);
}

body.has-custom-background .table-card-metric-bar {
    background: rgba(var(--border-color-rgb), 0.25);
}

body.has-custom-background .table-card-status {
    box-shadow: 0 0 8px rgba(76, 175, 125, 0.6);
}

body.has-custom-background .table-card-status.offline {
    box-shadow: 0 0 8px rgba(231, 76, 94, 0.6);
}

body.has-custom-background .node-card-flag-placeholder {
    background: rgba(var(--bg-card-rgb), 0.5);
}

body.has-custom-background .table-flag-placeholder {
    background: rgba(var(--bg-card-rgb), 0.5);
}

/* ==================== Responsive ==================== */

@media (max-width: 768px) {
    .nodes-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .node-card {
        padding: 16px;
        border-radius: 14px;
    }

    .node-card:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }

    .node-card::before {
        height: 2px;
    }

    .node-card-header {
        gap: 12px;
        margin-bottom: 14px;
        padding-bottom: 10px;
    }

    .node-card-flag {
        width: 28px;
        height: 20px;
    }

    .node-card-name {
        font-size: 0.95rem;
    }

    .node-name-text {
        -webkit-line-clamp: 2;
    }

    .node-status-dot {
        width: 8px;
        height: 8px;
    }

    .node-card-metrics {
        gap: 12px;
    }

    .metric-label {
        font-size: 0.7rem;
    }

    .metric-value {
        font-size: 0.82rem;
    }

    .metric-bar {
        height: 6px;
    }

    .node-card-footer {
        margin-top: 14px;
        padding-top: 10px;
        gap: 6px 10px;
        font-size: 0.7rem;
    }

    .node-expiry {
        font-size: 0.65rem;
        padding: 2px 6px;
    }

    .node-ping {
        font-size: 0.68rem;
        padding: 2px 6px;
    }

    .network-dir {
        font-size: 0.65rem;
    }

    .nodes-table-container {
        overflow: visible;
    }

    .table-cards {
        grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
        gap: 10px;
    }

    .table-card {
        padding: 10px 14px;
        gap: 8px;
        min-height: 110px;
    }

    .table-card-header {
        gap: 6px;
    }

    .table-card-flag-wrap {
        min-width: 16px;
    }

    .table-card-flag {
        width: 16px;
        height: 11px;
    }

    .table-card-name {
        font-size: 0.72rem;
    }

    .table-card-info {
        gap: 4px;
        margin-top: 1px;
    }

    .table-card-price,
    .table-card-expiry {
        font-size: 0.58rem;
    }

    .table-card-metrics {
        grid-template-columns: repeat(6, 1fr);
        gap: 8px;
    }

    .table-card-metric-label {
        font-size: 0.6rem;
    }

    .table-card-metric-value {
        font-size: 0.7rem;
    }

    .table-card-metric-bar {
        height: 3px;
    }
}

@media (max-width: 480px) {
    .node-card {
        padding: 12px;
    }

    .table-cards {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .table-card {
        padding: 10px 12px;
        gap: 6px;
        min-height: 100px;
    }

    .table-card-header {
        gap: 5px;
    }

    .table-card-flag-wrap {
        min-width: 15px;
    }

    .table-card-flag {
        width: 15px;
        height: 10px;
    }

    .table-card-name {
        font-size: 0.7rem;
    }

    .table-card-info {
        gap: 3px;
        margin-top: 1px;
    }

    .table-card-price,
    .table-card-expiry {
        font-size: 0.55rem;
    }

    .table-card-metrics {
        grid-template-columns: repeat(6, 1fr);
        gap: 6px;
    }

    .table-card-metric-label {
        font-size: 0.55rem;
    }

    .table-card-metric-value {
        font-size: 0.65rem;
    }

    .os-icon {
        width: 10px;
        height: 10px;
    }

    .table-card-metric-bar {
        height: 2px;
    }

    .node-card-metrics {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    .node-card-name {
        font-size: 0.85rem;
    }

    .node-name-text {
        -webkit-line-clamp: 2;
    }

    .node-api-tag {
        font-size: 0.6rem;
        padding: 1px 4px;
    }

    .metric-label {
        font-size: 0.65rem;
    }

    .metric-value {
        font-size: 0.75rem;
    }

    .node-card-footer {
        font-size: 0.65rem;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .nodes-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }

    .table-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .table-card {
        padding: 10px 14px;
        gap: 6px;
        min-height: 110px;
    }

    .table-card-name {
        font-size: 0.72rem;
    }

    .table-card-price,
    .table-card-expiry {
        font-size: 0.62rem;
    }

    .table-card-metrics {
        gap: 8px;
    }

    .table-card-metric-label {
        font-size: 0.62rem;
    }

    .table-card-metric-value {
        font-size: 0.72rem;
    }
}

/* ==================== Hover: none (touch) ==================== */

@media (hover: none) {
    .node-card:hover {
        transform: none;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04), 
                    0 1px 2px rgba(0, 0, 0, 0.06);
        border-color: var(--border-color);
    }

    .node-card:hover::before {
        opacity: 0;
    }

    .node-card:active {
        transform: scale(0.98);
        border-color: var(--accent);
    }

    .node-card:active::before {
        opacity: 1;
    }

    .node-card:hover .node-card-flag,
    .node-card:hover .node-api-tag,
    .node-card:hover .node-expiry,
    .node-card:hover .node-ping {
        transform: none;
    }

    .node-card:active .node-card-flag {
        transform: scale(1.02);
    }

    .node-card:hover {
        transform: none;
        box-shadow: var(--shadow-card);
    }

    .node-card::before {
        display: none;
    }

    .metric-value {
        transform: none !important;
    }
}
