/* Overseerr-Inspired Link Page */
/* Custom design for austism's homelab */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* ElegantFin Color Palette */
    --primary: rgb(119, 91, 244);
    --primary-dark: rgb(79, 70, 229);
    --primary-light: rgb(117, 111, 226);

    --bg-primary: #111827;
    --bg-secondary: #1d2635;
    --bg-tertiary: rgb(55, 65, 81);
    --bg-card: rgb(31, 41, 55);

    --text-primary: rgb(209, 213, 219);
    --text-secondary: rgb(156, 163, 175);
    --text-tertiary: rgb(107, 114, 128);

    --border: hsl(214, 13%, 32%);
    --border-light: hsla(0, 0%, 100%, .2);
    --shadow: rgba(0, 0, 0, 0.4);

    --success: rgb(50, 167, 105);
    --highlight: rgb(37, 99, 235);
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    /* Better touch scrolling on mobile */
    -webkit-overflow-scrolling: touch;
    /* Prevent text size adjustment on orientation change */
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
    position: relative;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Animated Particles Background */
#particles-js {
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 0;
    pointer-events: auto;
}

/* Ensure content appears above particles */
.container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 48px;
    animation: fadeInDown 0.6s ease-out;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3),
                0 0 0 1px var(--border);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--primary), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.header:hover {
    border-color: var(--primary);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5),
                0 0 0 1px var(--primary),
                0 0 20px rgba(119, 91, 244, 0.3);
}

.header:hover::before {
    opacity: 0.05;
}

/* Logo */
.logo {
    max-width: 400px;
    height: auto;
    margin: 0 auto 20px;
    display: block;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

.header:hover .logo {
    transform: translateY(-4px);
}

.subtitle {
    font-size: 18px;
    color: var(--text-secondary);
    font-weight: 400;
    line-height: 1.4;
    margin: 0;
    position: relative;
    z-index: 1;
}

/* Links Grid */
.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

/* Link Cards */
.link-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 0;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    /* Better tap/click experience on mobile */
    -webkit-tap-highlight-color: rgba(119, 91, 244, 0.1);
    tap-highlight-color: rgba(119, 91, 244, 0.1);
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.link-card-header {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
}

.link-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--primary), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.link-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5),
                0 0 0 1px var(--primary),
                0 0 20px rgba(119, 91, 244, 0.3);
}

.link-card:hover::before {
    opacity: 0.05;
}

.link-card:active {
    transform: translateY(-2px);
}

/* Link Icon */
.link-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: 10px;
    flex-shrink: 0;
    transition: all 0.3s ease;
    overflow: hidden;
    padding: 8px;
}

.link-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.link-card:hover .link-icon {
    background: rgba(119, 91, 244, 0.2);
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(119, 91, 244, 0.4);
}

/* Link Content */
.link-content {
    flex: 1;
    min-width: 0;
}

.link-name {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.link-desc {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Expand Icon */
.expand-icon {
    font-size: 24px;
    color: var(--text-tertiary);
    transition: all 0.3s ease;
    transform: rotate(0deg);
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.link-card.expanded .expand-icon {
    transform: rotate(90deg);
    color: var(--primary);
}

/* Link Details (Hidden by default) */
.link-details {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0 0 0 72px;
    margin-top: 0;
}

.link-details p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.link-card.expanded .link-details {
    max-height: 200px;
    opacity: 1;
    margin-top: 16px;
    padding-bottom: 4px;
}

/* Footer */
.footer {
    text-align: center;
    padding: 40px 20px;
    margin-top: 60px;
    border-top: 1px solid var(--border);
    color: var(--text-tertiary);
    font-size: 14px;
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 6px;
    border: 2px solid var(--bg-secondary);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Selection */
::selection {
    background: var(--primary);
    color: white;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        /* Safe area padding for notched devices */
        padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    }

    .container {
        padding: 32px 20px;
        padding-bottom: max(32px, env(safe-area-inset-bottom));
    }

    .header {
        margin-bottom: 32px;
        padding: 24px;
    }

    .logo {
        max-width: 320px;
        margin-bottom: 16px;
    }

    .subtitle {
        font-size: 17px;
        line-height: 1.4;
    }

    .links-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .link-card {
        padding: 20px;
        min-height: 80px;
        border-radius: 14px;
        /* Larger touch target */
        gap: 18px;
    }

    .link-card:active {
        transform: translateY(-1px);
        /* Reduced transform for mobile tap feedback */
    }

    .link-icon {
        width: 56px;
        height: 56px;
        border-radius: 12px;
        flex-shrink: 0;
        padding: 10px;
    }

    .link-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .link-name {
        font-size: 17px;
        font-weight: 600;
        line-height: 1.3;
    }

    .link-desc {
        font-size: 14px;
        line-height: 1.4;
        color: var(--text-tertiary);
    }

    .expand-icon {
        font-size: 28px;
        width: 28px;
        height: 28px;
    }

    .link-details {
        padding: 0 0 0 74px;
    }

    .link-details p {
        font-size: 15px;
        line-height: 1.5;
    }

    .footer {
        padding: 32px 20px;
        margin-top: 48px;
        font-size: 15px;
    }

    /* Reduce animation intensity on mobile */
    .link-card:hover {
        transform: translateY(-2px);
    }

    .link-card:hover .link-icon {
        transform: scale(1.05);
    }
}

/* Extra small devices (phones in portrait) */
@media (max-width: 400px) {
    .container {
        padding: 24px 16px;
    }

    .header {
        padding: 20px;
    }

    .logo {
        max-width: 280px;
        margin-bottom: 12px;
    }

    .subtitle {
        font-size: 16px;
    }

    .link-card {
        padding: 18px;
        gap: 16px;
    }

    .link-icon {
        width: 52px;
        height: 52px;
        padding: 9px;
    }

    .link-name {
        font-size: 16px;
    }

    .link-desc {
        font-size: 13px;
    }

    .expand-icon {
        font-size: 24px;
        width: 24px;
        height: 24px;
    }

    .link-details {
        padding: 0 0 0 68px;
    }

    .link-details p {
        font-size: 14px;
    }
}

@media (min-width: 1400px) {
    .links-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }
}

/* Loading State Animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
        color: black;
    }

    .link-card {
        break-inside: avoid;
        border: 1px solid #ccc;
    }

    .footer {
        page-break-before: always;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus States */
.link-card:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.link-card:focus:not(:focus-visible) {
    outline: none;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .link-card {
        border-width: 2px;
    }
}
