/* ============================================================
   MiniLink — public profile page

   Every colour on this page is derived from three values the admin
   picks (or a preset fills in): --background-color, --text-color and
   --theme-color. No per-preset CSS, no gradients, no glow. Hierarchy
   comes from size, weight and tone, not from decoration.
   ============================================================ */

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

body.public-body {
    --bg: var(--background-color, #f3f1ec);
    --fg: var(--text-color, #171717);
    --accent: var(--theme-color, #171717);
    --accent-fg: var(--accent-contrast, #ffffff);

    --muted: color-mix(in srgb, var(--fg) 64%, var(--bg));
    --subtle: color-mix(in srgb, var(--fg) 46%, var(--bg));
    --surface: color-mix(in srgb, var(--fg) 5%, var(--bg));
    --surface-hover: color-mix(in srgb, var(--fg) 9%, var(--bg));
    --line: color-mix(in srgb, var(--fg) 11%, var(--bg));
    --line-strong: color-mix(in srgb, var(--fg) 22%, var(--bg));

    --radius: 14px;
    --radius-sm: 10px;
    --ease: cubic-bezier(0.2, 0, 0, 1);

    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--fg);
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body.public-body ::selection {
    background: var(--accent);
    color: var(--accent-fg);
}

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

:focus-visible {
    outline: 2px solid var(--fg);
    outline-offset: 3px;
}

/* ------------------------------------------------------------
   Page column
   ------------------------------------------------------------ */

.page {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: clamp(48px, 11vh, 96px) 20px 32px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    animation: page-in 0.5s var(--ease) both;
}

@keyframes page-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
}

/* ------------------------------------------------------------
   Profile header
   ------------------------------------------------------------ */

.profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 36px;
}

.avatar {
    width: 88px;
    height: 88px;
    margin-bottom: 20px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--accent);
    color: var(--accent-fg);
}

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

.avatar-initial {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1;
}

.profile-name {
    margin: 0;
    font-size: clamp(1.5rem, 5.5vw, 1.875rem);
    font-weight: 650;
    letter-spacing: -0.025em;
    line-height: 1.15;
    text-wrap: balance;
}

.profile-bio {
    margin: 10px 0 0;
    max-width: 38ch;
    color: var(--muted);
    font-size: 0.9375rem;
    line-height: 1.55;
    text-wrap: pretty;
}

/* Avatar frames ------------------------------------------------ */

.avatar-frame-rounded-square .avatar {
    border-radius: 28%;
}

.avatar-frame-hexagon .avatar {
    border-radius: 0;
    clip-path: polygon(25% 3%, 75% 3%, 100% 50%, 75% 97%, 25% 97%, 0% 50%);
}

/* "gradient-ring" key kept for stored settings; renders as a plain ring */
.avatar-frame-gradient-ring .avatar {
    overflow: visible;
    box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent);
}

.avatar-frame-gradient-ring .avatar img,
.avatar-frame-gradient-ring .avatar-initial {
    border-radius: 50%;
}

.avatar-frame-gradient-ring .avatar img {
    background: var(--bg);
}

/* ------------------------------------------------------------
   Social icons
   ------------------------------------------------------------ */

.socials {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px;
    margin-top: 18px;
}

.socials a {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    color: var(--muted);
    transition: color 0.15s var(--ease), background-color 0.15s var(--ease);
}

.socials a:hover {
    color: var(--fg);
    background: var(--surface-hover);
}

.socials-inline {
    margin-top: 6px;
    margin-bottom: -4px;
}

.socials-inline a {
    width: 36px;
    height: 36px;
}

.socials-inline .platform-badge i {
    font-size: 16px;
}

/* bottom-bar: sticks to the viewport bottom until the page ends */
.socials-bar {
    position: sticky;
    bottom: 16px;
    z-index: 5;
    align-self: center;
    max-width: 100%;
    margin-top: 28px;
    padding: 4px;
    gap: 0;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.45);
}

.socials-bar::-webkit-scrollbar {
    display: none;
}

.socials-bar a {
    flex-shrink: 0;
}

/* Platform glyphs: monochrome, take the colour of their container */
.platform-badge {
    display: inline-grid;
    place-items: center;
    color: inherit;
    line-height: 1;
}

.platform-badge i {
    font-size: 18px;
    line-height: 1;
}

/* ------------------------------------------------------------
   Links
   ------------------------------------------------------------ */

.link-group + .link-group {
    margin-top: 28px;
}

.group-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 10px;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0;
    color: var(--muted);
}

.group-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
}

.group-count {
    order: 2;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--subtle);
}

.links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.link {
    position: relative;
    width: 100%;
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px 12px 12px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--fg);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition:
        background-color 0.15s var(--ease),
        border-color 0.15s var(--ease),
        transform 0.15s var(--ease);
}

.link:hover {
    background: var(--surface-hover);
}

.link:active {
    transform: scale(0.99);
}

.link-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, currentColor 8%, transparent);
}

.link-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.link-title {
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-desc {
    font-size: 0.8125rem;
    line-height: 1.4;
    color: var(--muted);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.link-desc:empty {
    display: none;
}

.link-arrow {
    flex-shrink: 0;
    font-size: 15px;
    color: var(--subtle);
    transition: transform 0.2s var(--ease), color 0.15s var(--ease);
}

.link:hover .link-arrow {
    color: var(--fg);
    transform: translate(2px, -2px);
}

/* IBAN copy row */
.link-copy .link-desc {
    font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    word-break: break-all;
}

.link-copy .icon-copied {
    display: none;
}

.link-copy.is-copied .icon-copy {
    display: none;
}

.link-copy.is-copied .icon-copied {
    display: inline-block;
    color: var(--fg);
}

.link-copy:hover .link-arrow {
    transform: none;
}

.copy-status {
    position: absolute;
    right: 44px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted);
    opacity: 0;
    transition: opacity 0.15s var(--ease);
    pointer-events: none;
}

.link-copy.is-copied .copy-status {
    opacity: 1;
}

/* Button styles ----------------------------------------------- */

/* soft (default): tinted surface, no border — rules above */

/* glass → outline: transparent with a hairline */
.button-style-glass .link {
    background: transparent;
    border-color: var(--line-strong);
}

.button-style-glass .link:hover {
    background: var(--surface);
    border-color: color-mix(in srgb, var(--fg) 40%, var(--bg));
}

/* solid → accent fill */
.button-style-solid .link {
    background: var(--accent);
    color: var(--accent-fg);
}

.button-style-solid .link:hover {
    background: color-mix(in srgb, var(--accent) 88%, var(--accent-fg));
}

.button-style-solid .link-desc,
.button-style-solid .link-arrow,
.button-style-solid .copy-status {
    color: color-mix(in srgb, var(--accent-fg) 72%, var(--accent));
}

.button-style-solid .link:hover .link-arrow,
.button-style-solid .link-copy.is-copied .icon-copied {
    color: var(--accent-fg);
}

.button-style-solid .link:focus-visible {
    outline-color: var(--accent);
}

/* ------------------------------------------------------------
   Layouts
   ------------------------------------------------------------ */

/* compact: dense rows, no descriptions */
.layout-compact .profile {
    margin-bottom: 28px;
}

.layout-compact .links {
    gap: 6px;
}

.layout-compact .link {
    min-height: 48px;
    padding: 8px 14px 8px 8px;
    gap: 12px;
    border-radius: 12px;
}

.layout-compact .link-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

.layout-compact .link-icon .platform-badge i {
    font-size: 15px;
}

.layout-compact .link-desc {
    display: none;
}

.layout-compact .link-copy .link-desc {
    display: block;
}

/* grid: two-up tiles */
.layout-grid .links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.layout-grid .link {
    min-height: 120px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 14px;
}

.layout-grid .link-text {
    width: 100%;
}

.layout-grid .link-title {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.layout-grid .link-arrow {
    position: absolute;
    top: 16px;
    right: 14px;
}

.layout-grid .copy-status {
    top: 16px;
    right: 36px;
}

@media (max-width: 360px) {
    .layout-grid .links {
        grid-template-columns: 1fr;
    }
}

/* hero: left-aligned, editorial header */
.layout-hero .page {
    max-width: 560px;
}

.layout-hero .profile {
    align-items: flex-start;
    text-align: left;
    margin-bottom: 44px;
}

.layout-hero .avatar {
    width: 72px;
    height: 72px;
    margin-bottom: 28px;
}

.layout-hero .avatar-initial {
    font-size: 1.625rem;
}

.layout-hero .profile-name {
    font-size: clamp(2.25rem, 10vw, 3.25rem);
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1.02;
}

.layout-hero .profile-bio {
    margin-top: 14px;
    font-size: 1.0625rem;
    max-width: 34ch;
}

.layout-hero .socials {
    justify-content: flex-start;
    margin-left: -10px;
}

.layout-hero .socials-bar {
    margin-left: 0;
}

.layout-hero .link {
    min-height: 72px;
}

/* ------------------------------------------------------------
   States
   ------------------------------------------------------------ */

.empty-state,
.setup-box {
    padding: 20px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    color: var(--muted);
    font-size: 0.9375rem;
    text-align: center;
}

.empty-state strong {
    display: block;
    color: var(--fg);
    font-weight: 600;
    margin-bottom: 2px;
}

.setup-box {
    text-align: left;
}

.setup-box h2 {
    margin: 0 0 8px;
    font-size: 1.125rem;
    color: var(--fg);
}

.setup-box p {
    margin: 0 0 8px;
}

.setup-box code {
    padding: 1px 6px;
    border-radius: 6px;
    background: var(--surface-hover);
    color: var(--fg);
    font-size: 0.8125rem;
}

.setup-box a {
    color: var(--fg);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ------------------------------------------------------------
   Footer credit
   ------------------------------------------------------------ */

.site-credit {
    margin-top: auto;
    padding-top: 56px;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--subtle);
}

.site-credit a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 8px;
    transition: color 0.15s var(--ease);
}

.site-credit a:hover {
    color: var(--fg);
}

.site-credit strong {
    font-weight: 600;
    color: var(--muted);
}

.site-credit a:hover strong {
    color: var(--fg);
}

/* ------------------------------------------------------------
   Fallbacks & motion
   ------------------------------------------------------------ */

@supports not (background: color-mix(in srgb, white 50%, black)) {
    body.public-body {
        --muted: var(--fg);
        --subtle: var(--fg);
        --surface: rgba(127, 127, 127, 0.1);
        --surface-hover: rgba(127, 127, 127, 0.16);
        --line: rgba(127, 127, 127, 0.22);
        --line-strong: rgba(127, 127, 127, 0.38);
    }

    .link-icon {
        background: rgba(127, 127, 127, 0.14);
    }
}

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

    .link,
    .link-arrow,
    .socials a {
        transition: none;
    }

    .link:hover .link-arrow,
    .link:active {
        transform: none;
    }
}
