/* MoonlightWeb — Apps view */

.apps-view {
    width: 100%;
}

.apps-header {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}
.apps-host-info {
    flex: 1;
    min-width: 0;
}
.apps-host-name {
    font-weight: 600;
    font-size: var(--fs-lg);
    color: var(--text-1);
}
.apps-host-addr {
    font-size: var(--fs-xs);
    color: var(--text-2);
    font-family: var(--font-mono);
}
.apps-spacer {
    width: 100px;
} /* balance the back button */

.apps-loading,
.apps-error,
.apps-empty {
    text-align: center;
    padding: var(--space-8) var(--space-5);
    color: var(--text-2);
    background-color: var(--surface-2);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-1);
}

/* ── App grid ──────────────────────────────────────────────────────────── */
.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--space-6);
}

.app-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-4);
    text-align: center;
    cursor: pointer;
    transition:
        border-color 0.2s,
        transform 0.15s,
        box-shadow 0.2s;
}
/* Desktop: fixed-width cards in a wrapping row, so the host box width is
   driven by its content (side-by-side host boxes in hosts.css). */
@media (min-width: 601px) {
    .apps-grid {
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-5);
    }
    .app-card {
        width: 156px;
        padding-left: var(--space-5);
        padding-right: var(--space-5);
    }
}
.app-card:hover {
    box-shadow: var(--edge-accent), var(--glass-highlight);
    filter: var(--glow-accent);
    transform: translateY(-3px);
}
/* Press feedback (tap on mobile / click) — quick scale-down for tactile cue. */
.app-card:active {
    transform: translateY(-1px) scale(0.96);
    transition: transform 0.06s ease;
}

.app-card-image {
    width: 100%;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border-radius: var(--radius-sm);
    background-color: var(--surface-3);
    margin-bottom: 2px;
}
.app-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.app-card-image .app-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 2rem;
    opacity: 0.7;
}

.app-card-name {
    font-weight: 500;
    font-size: var(--fs-sm);
    line-height: 1.3;
    word-break: break-word;
}

/* ── Launching state ────────────────────────────────────────────────────── */
/* Keep a yellow edge for the whole launch, even after the pointer leaves
   (mouseleave/focusout) — otherwise the contour falls back to the cyan edge. */
.app-card--launching,
.app-card--launching:hover {
    cursor: progress;
    position: relative;
    box-shadow: var(--edge-accent), var(--glass-highlight);
    background:
        linear-gradient(rgba(252, 238, 10, 0.16), rgba(252, 238, 10, 0.16)), var(--surface-glass);
}
/* Status label: mono accent yellow, gently blinking to read as "loading". */
.app-card--launching .app-card-name {
    color: var(--accent-1);
    font-family: var(--font-mono);
    letter-spacing: 0.04em;
    animation: app-launch-blink 1.6s ease-in-out infinite;
}
@keyframes app-launch-blink {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.35;
    }
}

/* Rotating gradient ring around the card — clockwise, slow, "loader" cue.
   A conic gradient drawn into a border-thickness ring via mask compositing,
   notched to follow the CP2077 bevelled corners. */
@property --app-spin {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}
.app-card--launching::before {
    content: '';
    position: absolute;
    inset: 0;
    padding: 2px; /* ring thickness */
    border-radius: inherit;
    clip-path: var(--notch-lg);
    background: conic-gradient(
        from var(--app-spin),
        transparent 0deg,
        transparent 230deg,
        rgba(252, 238, 10, 0.55) 320deg,
        transparent 360deg
    );
    /* Keep only the padding ring (exclude the inner content box). */
    -webkit-mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    animation: app-spin-ring 3.2s linear infinite;
}
@keyframes app-spin-ring {
    to {
        --app-spin: 360deg;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-card--launching .app-card-name {
        animation: none;
    }
    .app-card--launching::before {
        animation: none;
    }
}

@media (max-width: 600px) {
    .apps-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: var(--space-3);
    }
    .app-card {
        gap: var(--space-2);
        padding: var(--space-3) var(--space-2);
    }
    .app-card-name {
        font-size: var(--fs-xs);
    }
    .apps-header {
        flex-wrap: wrap;
        gap: var(--space-3);
    }
    .apps-spacer {
        display: none;
    }
}
