:root {
    --page-bg: <?= e($backgroundColor) ?>;
    --text: #172230;
    --muted: rgba(23, 34, 48, 0.68);
    --red: #d71920;
    --red-dark: #aa1117;
    --white: rgba(255, 255, 255, 0.94);
    --line: rgba(17, 34, 48, 0.09);
    --shadow: 0 18px 42px rgba(18, 38, 58, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--page-bg);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient( circle at 12% 5%, rgba(255, 255, 255, 0.78), transparent 28% ), radial-gradient( circle at 90% 12%, rgba(215, 25, 32, 0.10), transparent 27% ), var(--page-bg);
}

button,
input {
    font: inherit;
}

/* Contenitore principale */

.page-shell {
    width: min(700px, calc(100% - 28px));
    margin: 0 auto;
    padding: max(22px, env(safe-area-inset-top)) 0 max(42px, env(safe-area-inset-bottom));
}

/* Barra superiore */

.topbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.share-trigger {
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.84);
    color: var(--text);
    cursor: pointer;
    box-shadow: 0 12px 28px rgba(18, 38, 58, 0.10);
    backdrop-filter: blur(14px);
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}

    .share-trigger:hover {
        transform: translateY(-2px);
        box-shadow: 0 16px 34px rgba(18, 38, 58, 0.15);
    }

/* Immagine di copertina */

.cover {
    height: 180px;
    margin-bottom: -58px;
    overflow: hidden;
    border-radius: 28px;
    background: linear-gradient( 135deg, rgba(215, 25, 32, 0.14), rgba(255, 255, 255, 0.75) );
    box-shadow: var(--shadow);
}

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

/* Profilo */

.profile {
    position: relative;
    z-index: 2;
    padding: 18px 0 22px;
    text-align: center;
}

.avatar {
    width: 112px;
    height: 112px;
    margin: 0 auto 17px;
    overflow: hidden;
    border: 5px solid rgba(255, 255, 255, 0.93);
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 17px 38px rgba(18, 38, 58, 0.18);
}

    .avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

.avatar-placeholder {
    display: grid;
    width: 100%;
    height: 100%;
    place-items: center;
    color: var(--red);
    font-size: 2.25rem;
}

h1 {
    margin: 0 0 10px;
    font-size: clamp(1.65rem, 6vw, 2.35rem);
    line-height: 1.08;
    letter-spacing: -0.035em;
}

/* Bio */

.bio-card {
    width: 100%;
    margin: 22px 0 0;
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--white);
    color: var(--text);
    text-align: left;
    box-shadow: 0 12px 28px rgba(18, 38, 58, 0.09);
    backdrop-filter: blur(12px);
}

    .bio-card.rounded {
        border-radius: 15px;
    }

    .bio-card.soft {
        border-radius: 23px;
    }

    .bio-card.square {
        border-radius: 4px;
    }

    .bio-card.pill {
        border-radius: 32px;
    }

.bio-heading {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 11px 18px;
    border-bottom: 1px solid var(--line);
    background: rgba(241, 243, 245, 0.82);
    color: var(--red-dark);
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

    .bio-heading i {
        font-size: 0.9rem;
    }

.bio-content {
    margin: 0;
    padding: 17px 19px 19px;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.62;
    overflow-wrap: anywhere;
}

/* Elenco collegamenti */

.links {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.link-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 66px;
    padding: 12px 58px 12px 14px;
    border: 1px solid var(--line);
    background: var(--white);
    color: var(--text);
    text-decoration: none;
    font-weight: 850;
    box-shadow: 0 12px 28px rgba(18, 38, 58, 0.09);
    backdrop-filter: blur(12px);
    transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

    .link-card:hover {
        transform: translateY(-3px);
        border-color: rgba(215, 25, 32, 0.18);
        box-shadow: 0 19px 38px rgba(18, 38, 58, 0.14);
    }

    .link-card.rounded {
        border-radius: 15px;
    }

    .link-card.soft {
        border-radius: 23px;
    }

    .link-card.square {
        border-radius: 4px;
    }

    .link-card.pill {
        border-radius: 999px;
    }

.link-icon {
    display: grid;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    place-items: center;
    border-radius: 13px;
    background: #f1f3f5;
    color: var(--red);
    font-size: 1.08rem;
}

.link-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-arrow {
    position: absolute;
    right: 20px;
    opacity: 0.44;
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.link-card:hover .link-arrow {
    opacity: 0.85;
    transform: translateX(2px);
}

/* Stato vuoto */

.empty-state {
    padding: 24px;
    border: 1px dashed rgba(23, 34, 48, 0.25);
    border-radius: 18px;
    color: var(--muted);
    text-align: center;
    line-height: 1.55;
}

/* Branding e call to action finale */

.branding {
    margin-top: 32px;
    padding: 18px;
    color: rgba(23, 34, 48, 0.58);
    font-size: 0.8rem;
    font-weight: 750;
    line-height: 1.55;
    text-align: center;
}

    .branding a {
        color: inherit;
        text-decoration: none;
    }

    .branding strong {
        color: var(--red-dark);
    }

.create-link-page {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 10px 18px;
    border-radius: 999px;
    background: var(--red);
    color: #ffffff !important;
    font-weight: 700;
    text-decoration: none;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

    .create-link-page:hover {
        background: #b8141a;
        transform: translateY(-2px);
    }

/* Modale condivisione */

.share-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
}

    .share-modal.is-open {
        display: block;
    }

.share-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 18, 27, 0.60);
    backdrop-filter: blur(5px);
}

.share-sheet {
    position: absolute;
    left: 50%;
    bottom: max(16px, env(safe-area-inset-bottom));
    width: min(540px, calc(100% - 24px));
    padding: 20px;
    transform: translateX(-50%);
    border-radius: 26px;
    background: #ffffff;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.28);
}

.share-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

    .share-head strong {
        font-size: 1.08rem;
    }

.share-close {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: #f1f3f5;
    cursor: pointer;
    font-size: 1.25rem;
}

.share-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.share-option {
    display: flex;
    min-height: 88px;
    padding: 12px 7px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    border: 0;
    border-radius: 16px;
    background: #f6f7f9;
    color: var(--text);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 850;
    text-decoration: none;
}

    .share-option i {
        color: var(--red);
        font-size: 1.32rem;
    }

/* Campo copia link */

.copy-box {
    display: flex;
    gap: 9px;
    margin-top: 15px;
    padding: 8px;
    border: 1px solid #e1e5e9;
    border-radius: 15px;
    background: #fafbfc;
}

    .copy-box input {
        min-width: 0;
        flex: 1;
        padding: 0 8px;
        border: 0;
        outline: none;
        background: transparent;
        color: #5e6975;
    }

    .copy-box button {
        padding: 11px 14px;
        border: 0;
        border-radius: 11px;
        background: var(--red);
        color: #ffffff;
        cursor: pointer;
        font-weight: 850;
    }

/* Responsive */

@media (max-width: 560px) {
    .page-shell {
        width: min(calc(100% - 22px), 700px);
        padding-top: 16px;
    }

    .cover {
        height: 150px;
        border-radius: 23px;
    }

    .profile {
        padding-right: 12px;
        padding-left: 12px;
    }

    .share-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .copy-box {
        align-items: stretch;
        flex-direction: column;
    }

        .copy-box input {
            min-height: 42px;
        }
}


