/**
 * Profile cards (M-026): the Badge tab of the profile (site/profile/tabs/badge, inside .profile-tabs) and the page
 * of a card's link (site/profile-card/show). Built on account.css (panels, switch rows, fields) and media-kit.css
 * (tabs, chips, buttons, skeleton, module colors through .is-{module}).
 * Behavior: public/js/site/profile/badge.js.
 */

/* ================== PROFILE TABS ================== */
.profile-tabs {
    padding-top: 20px;
}

/* ================== TAB LAYOUT ================== */
.profile-card {
    container-type: inline-size;
}

.profile-card-head {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 26px;
}

.profile-card-head .account-panel-text {
    margin: 0;
}

.profile-card-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.profile-card-list .kit-chip {
    height: 34px;
    padding: 0 14px;
    font-size: 13px;
}

.profile-card-list .kit-chip.is-off {
    border-style: dashed;
    color: var(--text-2);
}

/* One column: the preview stays in view while the form scrolls under it, and the codes come after the save
   button. A wide tab puts the preview and the codes in a sticky column next to the form. */
.profile-card-body {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.profile-card-side {
    display: contents;
}

.profile-card-form {
    order: 1;
}

.profile-card-unsaved,
.profile-card-share {
    order: 2;
}

@container (min-width: 1000px) {
    .profile-card-body {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 600px);
        align-items: start;
        gap: 32px;
    }

    .profile-card-side {
        position: sticky;
        top: calc(var(--sticky-top, 58px) + 20px);
        display: flex;
        flex-direction: column;
        grid-row: 1;
        grid-column: 2;
        gap: 16px;
        min-width: 0;
    }

    .profile-card-form {
        grid-row: 1;
        grid-column: 1;
    }
}

/* ================== FORM ================== */
.profile-card-form {
    display: flex;
    flex-direction: column;
    gap: 22px;
    min-width: 0;
}

.profile-card-step {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.profile-card-step + .profile-card-step,
.profile-card-step + .profile-card-actions {
    padding-top: 22px;
    border-top: 1px solid var(--line);
}

.profile-card-step[hidden] {
    display: none;
}

.profile-card-step-title {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 0 0 14px;
    padding: 0;
    font-size: 12px;
    font-weight: 600;
    line-height: 16px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-2);
}

.profile-card-count {
    letter-spacing: 0;
    text-transform: none;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
}

.profile-card-step .account-help {
    margin-top: 0;
}

/* Format: two cards with a drawing of each shape */
.profile-card-formats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    max-width: 520px;
}

.profile-card-format {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0;
    padding: 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.profile-card-format:hover {
    border-color: var(--text-2);
}

.profile-card-format:has(input:checked) {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.profile-card-format:has(input:focus-visible) {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.profile-card-format-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.profile-card-format-shape {
    position: relative;
    display: block;
    aspect-ratio: 600 / 315;
    border-radius: 8px;
    background: var(--surface-0);
    box-shadow: inset 0 0 0 1px var(--line-strong);
}

.profile-card-format-shape.is-strip {
    aspect-ratio: 600 / 150;
    margin-block: auto;
}

.profile-card-format-dot {
    position: absolute;
    top: 13%;
    left: 6%;
    width: 15%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: color-mix(in srgb, var(--accent) 75%, transparent);
}

.is-strip .profile-card-format-dot {
    top: 18%;
    width: auto;
    height: 64%;
}

/* Three bars in the module colors stand for the numbers */
.profile-card-format-lines {
    position: absolute;
    right: 6%;
    bottom: 16%;
    left: 6%;
    height: 22%;
    border-radius: 3px;
    background: linear-gradient(90deg,
        var(--module-anime) 0 24%, transparent 24% 36%,
        var(--module-game) 36% 60%, transparent 60% 72%,
        var(--module-movie) 72% 96%, transparent 96%);
    opacity: 0.85;
}

.is-strip .profile-card-format-lines {
    bottom: 22%;
    left: 26%;
    height: 26%;
}

.profile-card-format-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.profile-card-format-name {
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
    color: var(--text-1);
}

.profile-card-format-hint {
    font-size: 12.5px;
    line-height: 18px;
    color: var(--text-2);
}

/* Numbers: one group of chips per module, selected in the module's color */
.profile-card-group {
    margin-top: 16px;
}

.profile-card-group.is-all,
.profile-card-order-item.is-all {
    --module: var(--accent);
}

.profile-card-group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 600;
    line-height: 18px;
    color: var(--text-1);
}

.profile-card-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.profile-card-chip {
    height: 34px;
    padding: 0 14px;
    font-size: 13px;
}

.profile-card-chip[aria-pressed="true"] {
    border-color: var(--module);
    background: color-mix(in srgb, var(--module) 14%, transparent);
}

.profile-card-order-box {
    margin-top: 20px;
    padding: 14px;
    border-radius: var(--radius);
    background: var(--surface-2);
}

.profile-card-order {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.profile-card-order-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 4px 4px 2px;
    border-radius: 8px;
    background: var(--surface-1);
    box-shadow: inset 0 0 0 1px var(--line);
}

.profile-card-order-item.is-dragging {
    opacity: 0.5;
}

.profile-card-order-handle {
    display: grid;
    flex: none;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--text-2);
    cursor: grab;
}

.profile-card-order-handle:hover {
    color: var(--text-1);
}

.profile-card-order-handle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.profile-card-order-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-1);
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Accent: one swatch per color */
.profile-card-subtitle {
    margin: 18px 0 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1);
}

.profile-card-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.profile-card-swatch {
    position: relative;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    margin: 0;
    border-radius: 50%;
    background: var(--module);
    box-shadow: 0 0 0 2px var(--surface-1), 0 0 0 3px var(--line-strong);
    cursor: pointer;
}

.profile-card-swatch.is-amber {
    --module: var(--accent);
}

.profile-card-swatch:has(input:checked) {
    box-shadow: 0 0 0 2px var(--surface-1), 0 0 0 4px var(--text-1);
}

.profile-card-swatch:has(input:checked)::after {
    content: "\f00c";
    font-family: "Font Awesome 6 Free";
    font-size: 12px;
    font-weight: 900;
    color: var(--surface-0);
}

.profile-card-swatch:has(input:focus-visible) {
    outline: 2px solid var(--accent);
    outline-offset: 5px;
}

.profile-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* ================== PREVIEW ================== */
/* The stage spans the column, so the form scrolling under the sticky preview never shows beside it */
.profile-card-stage {
    position: sticky;
    top: calc(var(--sticky-top, 58px) + 8px);
    z-index: 3;
    background: var(--surface-1);
    box-shadow: 0 -8px 0 var(--surface-1), 0 10px 0 var(--surface-1);
}

.profile-card-preview {
    position: relative;
    width: 100%;
    max-width: 600px;
    aspect-ratio: 600 / 315;
}

@container (min-width: 1000px) {
    .profile-card-stage {
        position: static;
        box-shadow: none;
    }
}

/* What gets focus or is scrolled to stops below the sticky preview (its height follows the tab width) */
.profile-card-form :is(input, button, select, label, li) {
    scroll-margin-top: calc(var(--sticky-top, 58px) + min(52.5cqw, 315px) + 32px);
}

@container (min-width: 1000px) {
    .profile-card-form :is(input, button, select, label, li) {
        scroll-margin-top: calc(var(--sticky-top, 58px) + 24px);
    }
}

/* Short screens need the room for the form */
@media (max-height: 700px) {
    .profile-card-stage {
        position: static;
        box-shadow: none;
    }

    .profile-card-form :is(input, button, select, label, li) {
        scroll-margin-top: calc(var(--sticky-top, 58px) + 24px);
    }
}

.profile-card-preview.is-strip {
    aspect-ratio: 600 / 150;
}

.profile-card-preview-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.profile-card-preview-skeleton {
    position: absolute;
    inset: 0;
    border-radius: 18px;
}

.profile-card-preview-message {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    margin: 0;
    padding: 20px;
    border: 1px dashed var(--line-strong);
    border-radius: 18px;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
    color: var(--text-2);
}

.profile-card-preview-image[hidden],
.profile-card-preview-skeleton[hidden],
.profile-card-preview-message[hidden],
.profile-card-share[hidden],
.profile-card-unsaved[hidden] {
    display: none;
}

.profile-card-unsaved {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0;
}

.profile-card-unsaved i {
    margin-top: 3px;
    color: var(--accent);
}

/* ================== SHARE ================== */
.profile-card-share {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
    border-radius: var(--radius);
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--line);
}

.profile-card-share-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
}

.profile-card-share-head .profile-card-step-title {
    margin: 0;
}

.profile-card-code-label {
    display: block;
    margin: 0 0 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-2);
}

.profile-card-code-row {
    display: flex;
    gap: 8px;
}

.account-panel .profile-card-code-row .form-control {
    min-height: 36px;
    padding: 6px 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
}

.profile-card-code-row .kit-button {
    flex: none;
}

.profile-card-share-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.profile-card-share .account-help {
    margin: 0;
}

/* ================== PAGE OF THE LINK ================== */
.profile-card-page-body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 24px;
    padding-top: 40px;
    padding-bottom: 80px;
}

.profile-card-page-image {
    display: block;
    width: 100%;
    max-width: 600px;
    height: auto;
}

.profile-card-page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.profile-card-page-join {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 18px 28px;
    width: 100%;
    max-width: 760px;
    padding: 24px 26px;
    border-radius: var(--radius);
    background: var(--surface-1);
    box-shadow: inset 0 0 0 1px var(--line);
}

.profile-card-page-join-title {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-1);
}

.profile-card-page-text {
    margin: 0;
    font-size: 14px;
    line-height: 20px;
    color: var(--text-2);
}

@media (max-width: 575.98px) {
    .profile-card-code-row {
        flex-direction: column;
    }

    .profile-card-code-row .kit-button {
        align-self: flex-start;
    }
}
