/* ============================================
   Linktree public page
   Theme colours arrive as custom properties set per body.theme-* in the page.
   ============================================ */

@property --gradient-start
{
    syntax: '<color>';
    initial-value: #1a1a2e;
    inherits: true;
}

@property --gradient-end
{
    syntax: '<color>';
    initial-value: #16213e;
    inherits: true;
}

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

:root
{
    --radius: 12px;
    --ease: 0.2s ease;
    --text-on-dark: #fff;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

body
{
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding-block: 20px;
    overflow-x: hidden;
    color: var(--text-on-dark);
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    transition: --gradient-start 0.5s ease, --gradient-end 0.5s ease;
}

.visually-hidden
{
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.container
{
    width: 100%;
    animation: fade-in 0.6s ease-in;

    @media (prefers-reduced-motion: reduce)
    {
        animation: none;
    }
}

@keyframes fade-in
{
    from
    {
        opacity: 0;
        translate: 0 20px;
    }

    to
    {
        opacity: 1;
        translate: 0 0;
    }
}

:focus-visible
{
    outline: 2px solid currentColor;
    outline-offset: 3px;
}

/* ============================================
   Profile
   ============================================ */
.profile
{
    text-align: center;
    margin-block-end: 30px;
    padding-inline: 20px;
}

.profile-image
{
    display: block;
    width: 96px;
    height: 96px;
    margin: 0 auto 20px;
    border-radius: 50%;
    border: 4px solid rgb(255 255 255 / 0.3);
    background: rgb(255 255 255 / 0.1);
    object-fit: cover;
}

.profile-name
{
    font-size: 24px;
    font-weight: 700;
    margin-block-end: 8px;

    @media (width <= 480px)
    {
        font-size: 20px;
    }
}

.profile-bio
{
    font-size: 15px;
    line-height: 1.5;
    opacity: 0.9;
}

.social-icons
{
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-block-start: 20px;
    list-style: none;
}

.social-icon-link
{
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgb(255 255 255 / 0.2);
    color: inherit;
    font-size: 20px;
    text-decoration: none;
    transition: scale var(--ease), background var(--ease);

    &:hover
    {
        scale: 1.1;
        background: rgb(255 255 255 / 0.35);
    }

    body.dark &
    {
        background: rgb(255 255 255 / 0.1);

        &:hover
        {
            background: rgb(255 255 255 / 0.2);
        }
    }
}

/* ============================================
   Links
   ============================================ */
.links
{
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 680px;
    margin-inline: auto;
    padding-inline: 20px;
    list-style: none;
}

.links-empty
{
    text-align: center;
    opacity: 0.5;
    padding: 20px;
}

.link-item
{
    display: block;
    padding: 20px;
    border-radius: var(--radius);
    border-inline-start: 4px solid var(--accent, transparent);
    background: var(--link-bg, rgb(255 255 255 / 0.95));
    color: var(--theme-text, #333);
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    box-shadow: 0 4px 6px rgb(0 0 0 / 0.1);
    backdrop-filter: blur(10px);
    transition: translate 0.3s ease, box-shadow 0.3s ease, background 0.5s ease, color 0.5s ease;

    &:hover
    {
        translate: 0 -2px;
        box-shadow: 0 6px 12px rgb(0 0 0 / 0.15);
        background: var(--link-hover, #fff);
    }

    &.has-icon
    {
        display: flex;
        align-items: center;
        gap: 16px;
        text-align: start;
    }

    @media (width <= 480px)
    {
        padding: 16px;
        font-size: 15px;

        &.has-icon
        {
            gap: 12px;
        }
    }
}

.link-icon
{
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--accent, #667eea);
    color: #fff;
    font-size: 20px;
    transition: background 0.5s ease;

    body.dark .link-item:not([style]) &
    {
        background: rgb(255 255 255 / 0.2);
    }

    @media (width <= 480px)
    {
        width: 38px;
        height: 38px;
        font-size: 18px;
        border-radius: 8px;
    }
}

.link-text
{
    flex: 1;
    min-width: 0;
}

.link-title
{
    display: block;
    margin-block-end: 4px;
}

.link-description
{
    font-size: 13px;
    font-weight: 400;
    color: #666;

    body.dark &
    {
        color: rgb(255 255 255 / 0.7);
    }
}

/* ============================================
   Panel tabs and swiper
   ============================================ */
.panel-tabs
{
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-block-end: 24px;
    padding-inline: 20px;
}

.panel-tab
{
    padding: 8px 20px;
    border-radius: 20px;
    background: rgb(255 255 255 / 0.15);
    color: rgb(255 255 255 / 0.7);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background var(--ease), color var(--ease);

    &:hover
    {
        background: rgb(255 255 255 / 0.25);
        color: #fff;
    }

    &[aria-current]
    {
        background: rgb(255 255 255 / 0.9);
        color: #333;
    }

    body.dark &
    {
        background: rgb(255 255 255 / 0.08);
        color: rgb(255 255 255 / 0.5);

        &:hover
        {
            background: rgb(255 255 255 / 0.15);
            color: rgb(255 255 255 / 0.9);
        }

        &[aria-current]
        {
            background: rgb(255 255 255 / 0.2);
            color: #fff;
        }
    }
}

.swiper
{
    width: 100%;
    padding-block: 10px;
    overflow: visible;

    /* Swiper did not load: stack the panels, tabs become in-page anchors */
    &:not(.swiper-initialized)
    {
        .swiper-wrapper
        {
            display: flex;
            flex-direction: column;
            gap: 48px;
        }

        .swiper-slide
        {
            width: 100%;
            max-width: none;
        }
    }
}

.swiper-wrapper
{
    align-items: stretch;
}

.swiper-slide
{
    width: 85%;
    max-width: 720px;
    height: auto;
    transition: opacity 0.3s, transform 0.3s;

    .swiper-initialized &:not(.swiper-slide-active)
    {
        opacity: 0.35;
        pointer-events: none;
    }

    @media (width <= 480px)
    {
        width: 90%;
    }
}

/* ============================================
   Language switcher
   ============================================ */
.lang-switcher
{
    position: fixed;
    inset-block-start: 24px;
    inset-inline-start: 24px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;

    @media (width <= 480px)
    {
        inset-block-start: 16px;
        inset-inline-start: 16px;
    }
}

.lang-current,
.lang-link
{
    padding: 4px 10px;
    border-radius: 6px;
}

.lang-current
{
    font-weight: 700;
    background: rgb(255 255 255 / 0.25);

    body.dark &
    {
        background: rgb(255 255 255 / 0.15);
    }
}

.lang-link
{
    font-weight: 500;
    color: rgb(255 255 255 / 0.7);
    text-decoration: none;
    transition: background var(--ease), color var(--ease);

    &:hover
    {
        background: rgb(255 255 255 / 0.15);
        color: #fff;
    }

    body.dark &
    {
        color: rgb(255 255 255 / 0.5);

        &:hover
        {
            background: rgb(255 255 255 / 0.1);
            color: rgb(255 255 255 / 0.9);
        }
    }
}

/* ============================================
   Site info (popover)
   ============================================ */
.site-icon
{
    position: fixed;
    inset-block-start: 20px;
    inset-inline-end: 20px;
    z-index: 200;
    width: 44px;
    height: 44px;
    padding: 0;
    overflow: hidden;
    border-radius: 50%;
    border: 2px solid rgb(255 255 255 / 0.4);
    background: rgb(255 255 255 / 0.15);
    cursor: pointer;
    transition: scale var(--ease), border-color var(--ease);

    &:hover
    {
        scale: 1.08;
        border-color: rgb(255 255 255 / 0.7);
    }

    img
    {
        display: block;
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    @media (width <= 480px)
    {
        inset-block-start: 16px;
        inset-inline-end: 16px;
        width: 38px;
        height: 38px;
    }
}

.site-icon-letter
{
    display: grid;
    place-items: center;
    height: 100%;
    color: #fff;
    font-size: 18px;
    font-weight: 700;
}

.site-info
{
    /* Popover: top layer, placed under the site icon */
    position: fixed;
    inset: 72px 20px auto auto;
    min-width: 220px;
    max-width: 280px;
    padding: 24px;
    border: 0;
    border-radius: 16px;
    background: rgb(255 255 255 / 0.95);
    color: #2c3e50;
    backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgb(0 0 0 / 0.2);
    text-align: center;
    opacity: 0;
    translate: 0 -8px;
    scale: 0.95;
    transition: opacity var(--ease), translate var(--ease), scale var(--ease), display 0.2s allow-discrete, overlay 0.2s allow-discrete;

    &:popover-open
    {
        opacity: 1;
        translate: 0 0;
        scale: 1;

        @starting-style
        {
            opacity: 0;
            translate: 0 -8px;
            scale: 0.95;
        }
    }

    /* Browsers without the Popover API (see popover-fallback.js) */
    &:not(:is(:popover-open, .is-open))
    {
        display: none;
    }

    &.is-open
    {
        display: block;
        opacity: 1;
        translate: 0 0;
        scale: 1;
        z-index: 199;
    }

    body.dark &
    {
        background: rgb(30 30 50 / 0.9);
        color: #fff;
    }

    @media (width <= 480px)
    {
        inset: 62px 16px auto auto;
    }
}

.site-info-avatar
{
    display: block;
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    border-radius: 50%;
    border: 2px solid rgb(0 0 0 / 0.08);
    object-fit: cover;

    body.dark &
    {
        border-color: rgb(255 255 255 / 0.15);
    }
}

.site-info-name
{
    font-size: 16px;
    font-weight: 700;
    margin-block-end: 4px;
}

.site-info-bio
{
    font-size: 13px;
    line-height: 1.4;
    margin-block-end: 12px;
    opacity: 0.75;
}

.site-info-link
{
    display: inline-block;
    padding: 6px 16px;
    border-radius: 8px;
    background: rgb(52 152 219 / 0.1);
    color: #3498db;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background var(--ease);

    &:hover
    {
        background: rgb(52 152 219 / 0.2);
    }

    body.dark &
    {
        background: rgb(93 173 226 / 0.15);
        color: #5dade2;

        &:hover
        {
            background: rgb(93 173 226 / 0.25);
        }
    }
}
