/* Account pages: sign-in, registration, password reset, account deletion,
   the profile and the profile picture. Everything here sits on app.css. */

/* ---------- a form with a piece turning beside it ---------- */

.account {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 40px;
}
.account__main {
    display: flex;
    flex-direction: column;
    gap: 26px;
    width: min(100%, 480px);
}
.account__head {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
}
.account__head h1 {
    font-size: clamp(38px, 5vw, 58px);
}
.account__head .lede {
    font-size: 17px;
    color: var(--muted);
}
.account__head .back-link {
    margin-bottom: 8px;
}
.account__head .lede b {
    font-weight: 500;
    color: var(--title);
    overflow-wrap: anywhere;
}
.eyebrow--check {
    color: var(--check);
}

@media (min-width: 960px) {
    .account {
        grid-template-columns: minmax(0, 480px) minmax(0, 1fr);
        justify-items: stretch;
        align-items: center;
        gap: clamp(40px, 7vw, 110px);
        min-height: calc(100svh - var(--nav-height) - 160px);
    }
}

/* The stage: a canvas for the 3D piece, with a flat piece behind it for
   browsers that cannot draw one. Hidden on narrow screens. */
.stage {
    display: none;
    margin: 0;
}
.stage__frame {
    position: relative;
    width: min(100%, 440px);
    aspect-ratio: 4 / 5;
    margin-inline: auto;
}
.stage__frame::before,
.stage__frame::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 54%;
    aspect-ratio: 1;
    border-radius: 50%;
    pointer-events: none;
}
/* A pool of light under the piece. */
.stage__frame::before {
    width: 96%;
    transform: translate(-50%, -50%);
    background: radial-gradient(closest-side, color-mix(in srgb, var(--gold) 30%, transparent), transparent);
}
/* A dashed orbit that turns slowly round it. */
.stage__frame::after {
    width: 88%;
    border: 1px dashed var(--line-strong);
    transform: translate(-50%, -50%);
    animation: stage-orbit 80s linear infinite;
}
@keyframes stage-orbit {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}
.stage canvas {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.9s var(--ease-out);
}
.stage.is-live canvas {
    opacity: 1;
}
.stage__flat {
    display: none;
    position: absolute;
    left: 50%;
    top: 52%;
    z-index: 1;
    width: 56%;
    translate: -50% -50%;
    filter: drop-shadow(0 26px 22px color-mix(in srgb, var(--ink-0) 70%, transparent));
    animation: stage-float 5s ease-in-out infinite alternate;
}
.stage--fallen .stage__flat {
    rotate: -84deg;
    animation: none;
}
@keyframes stage-float {
    to {
        transform: translateY(-12px);
    }
}
.stage.is-flat canvas,
.no-js .stage canvas {
    display: none;
}
.stage.is-flat .stage__flat,
.no-js .stage__flat {
    display: block;
}
.stage__caption {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    text-align: center;
    color: var(--muted);
}
.stage__caption b {
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gold);
}
@media (min-width: 960px) {
    .stage {
        display: block;
        position: sticky;
        top: calc(var(--nav-height) + 28px);
        align-self: start;
    }
}

/* ---------- the form card ---------- */

.auth-card {
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: clamp(22px, 3.2vw, 34px);
    box-shadow: var(--shadow);
}
/* A gold hairline along the top edge. */
.auth-card::before {
    content: '';
    position: absolute;
    inset: -1px 28px auto;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.auth-card .messages {
    margin: 0;
}
/* toast.js hides the confirmations it turns into toasts; when nothing is
   left to read, the list should not leave a gap. */
.messages:not(:has(.notice:not([style*='display: none']))) {
    display: none;
}
.notice .errorlist {
    font-size: inherit;
    color: inherit;
}
.auth-card__text {
    color: var(--text);
}
.auth-card__foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    font-size: 14.5px;
    color: var(--muted);
}
.auth-card__foot .text-link {
    font-weight: 500;
}
.auth-card form.inline-form {
    display: inline;
}
/* On the narrowest phones the longest label on a card, "Delete my account
   permanently", is wider than its button. Slightly smaller letters and less
   padding at the sides keep it whole. */
@media (max-width: 350px) {
    .auth-card .button--danger.button--block {
        padding-inline: 12px;
        font-size: 14.5px;
    }
}

/* Help text under a field, and the list Django prints for password rules. */
.helptext ul {
    margin: 0;
    padding-left: 18px;
}
.helptext[data-state='ok'] {
    color: var(--good);
}
.helptext[data-state='taken'] {
    color: var(--check);
}
.helptext:empty {
    display: none;
}

/* A field with its errors underneath, when the field itself has to stay
   just a label and an input. */
.field-set {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

/* Show and hide a password. auth.js adds .pw-toggle on the sign-in and
   register pages; the other pages use the .field__reveal button. */
.pw-input-wrapper {
    position: relative;
}
.field .pw-input-wrapper input,
.field.field--password input {
    padding-right: 50px;
}
.pw-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: none;
    color: var(--muted);
    transform: translateY(-50%);
    transition: color 0.2s, background 0.2s;
}
.pw-toggle:hover,
.field__reveal:hover {
    background: var(--gold-wash);
    color: var(--gold);
}
.pw-toggle svg,
.field__reveal svg {
    width: 18px;
    height: 18px;
    pointer-events: none;
}
.field__reveal {
    transition: color 0.2s, background 0.2s;
}
.field__reveal .icon-hide,
.field__reveal[aria-pressed='true'] .icon-show {
    display: none;
}
.field__reveal[aria-pressed='true'] .icon-hide {
    display: block;
}

/* The checklist auth.js builds under the new password. */
.password-strength-meter {
    height: 4px;
    border-radius: 999px;
    background: var(--ink-3);
    overflow: hidden;
}
.strength-bar-fill {
    width: 0;
    height: 100%;
    border-radius: inherit;
    transition: width 0.4s var(--ease-out), background 0.4s;
}
/* auth.js sets data-strength as the rules are met. */
.strength-bar-fill[data-strength='weak'] {
    background: var(--check);
}
.strength-bar-fill[data-strength='fair'] {
    background: var(--gold);
}
.strength-bar-fill[data-strength='strong'] {
    background: var(--good);
}
.password-checklist {
    display: grid;
    gap: 5px;
    margin: 4px 0 0;
    padding: 0;
    list-style: none;
    font-size: 13px;
    color: var(--muted);
}
.password-checklist li {
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.25s;
}
.password-checklist .check-icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 15px;
    height: 15px;
    border: 1.5px solid var(--line-strong);
    border-radius: 50%;
    transition: background 0.25s, border-color 0.25s, transform 0.35s var(--ease-spring);
}
.password-checklist li.met {
    color: var(--good);
}
.password-checklist li.met .check-icon {
    border-color: var(--good);
    background: var(--good);
    transform: scale(1.12);
}
.password-checklist li.met .check-icon::after {
    content: '';
    width: 7px;
    height: 4px;
    margin-top: -2px;
    border-left: 1.5px solid var(--ink-1);
    border-bottom: 1.5px solid var(--ink-1);
    transform: rotate(-45deg);
}
.password-checklist.all-met {
    display: none;
}
.paste-block-msg {
    padding: 7px 10px;
    border-left: 2px solid var(--check);
    border-radius: 6px;
    background: var(--check-wash);
    font-size: 13px;
    color: var(--title);
}

/* A submit button while its form is on the way. */
.button.is-loading {
    color: transparent;
    pointer-events: none;
}
.button.is-loading::before {
    content: '';
    position: absolute;
    inset: 0;
    width: 20px;
    height: 20px;
    margin: auto;
    border: 2px solid var(--button-fg);
    border-right-color: transparent;
    border-radius: 50%;
    animation: account-spin 0.7s linear infinite;
}
@keyframes account-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---------- the code from the email ---------- */

.field .otp-input {
    min-height: 72px;
    padding-inline: 12px;
    font-family: var(--font-mono);
    font-size: clamp(26px, 7.4vw, 34px);
    font-weight: 700;
    letter-spacing: 0.4em;
    text-align: center;
    text-indent: 0.4em;
    color: var(--gold);
    caret-color: var(--gold);
}
.field .otp-input::placeholder {
    color: color-mix(in srgb, var(--muted) 38%, transparent);
}
.resend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
}
.link-button {
    padding: 0;
    border: 0;
    border-bottom: 1px solid transparent;
    background: none;
    font-weight: 600;
    color: var(--gold);
    transition: border-color 0.2s;
}
.link-button:hover {
    border-color: currentColor;
}
.link-button[hidden] {
    display: none;
}
.resend__wait {
    color: var(--text);
}
.resend__wait:empty {
    display: none;
}
.resend__wait b {
    font-family: var(--font-mono);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--gold);
}
/* A small ring that empties while the wait runs down. */
.resend__wait::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    vertical-align: -3px;
    border-radius: 50%;
    background: conic-gradient(var(--gold) calc(var(--left, 1) * 360deg), var(--ink-3) 0);
    -webkit-mask: radial-gradient(circle, transparent 5px, var(--ink-0) 5.5px);
    mask: radial-gradient(circle, transparent 5px, var(--ink-0) 5.5px);
}

/* ---------- pages that only say something ---------- */

.done-mark {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--good-wash);
    color: var(--good);
}
.done-mark svg {
    width: 26px;
    height: 26px;
}
.done-mark--gold {
    background: var(--gold-wash);
    color: var(--gold);
}
[data-reveal].is-in .done-mark {
    animation: done-pop 0.7s var(--ease-spring) 0.35s both;
}
@keyframes done-pop {
    from {
        opacity: 0;
        transform: scale(0.4) rotate(-20deg);
    }
}
.loss-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 15px;
}
.loss-list li {
    display: flex;
    align-items: baseline;
    gap: 10px;
}
.loss-list li::before {
    content: '×';
    font-family: var(--font-mono);
    color: var(--check);
}

/* ---------- profile ---------- */

.profile {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.profile > .back-link {
    margin-bottom: 6px;
}
.profile-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    gap: 28px;
    padding: clamp(22px, 4vw, 44px);
    background:
        radial-gradient(70% 140% at 100% 0%, var(--gold-wash), transparent 70%),
        var(--ink-1);
    overflow: hidden;
}
.profile-hero__who {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 22px clamp(18px, 3vw, 32px);
}
.profile-hero__name {
    display: flex;
    flex: 1 1 240px;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    min-width: 0;
}
.profile-hero__name h1 {
    max-width: 100%;
    font-size: clamp(32px, 4.6vw, 54px);
    overflow-wrap: anywhere;
}
.profile-hero__name .cluster {
    margin-top: 6px;
}
.profile-avatar {
    flex: none;
    width: clamp(88px, 12vw, 124px);
    height: clamp(88px, 12vw, 124px);
    font-size: clamp(36px, 5vw, 52px);
    box-shadow: 0 0 0 4px var(--ink-1), 0 0 0 6px var(--gold), 0 18px 40px -14px var(--gold);
    transition: transform 0.5s var(--ease-spring);
}
.profile-hero:hover .profile-avatar {
    transform: rotate(-4deg) scale(1.04);
}
.profile-rating {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.profile-rating__value {
    font-size: clamp(64px, 11vw, 124px);
    font-weight: 700;
    line-height: 0.86;
    letter-spacing: -0.05em;
    font-variant-numeric: tabular-nums;
    color: var(--gold);
}
.profile-hero .stage__frame {
    width: 210px;
}
@media (min-width: 720px) {
    .profile-hero {
        grid-template-columns: minmax(0, 1fr) auto;
    }
    .profile-rating {
        align-items: flex-end;
        text-align: right;
    }
}
/* The hero only has room for its piece on a wide screen. */
.profile-hero .stage {
    display: none;
}
@media (min-width: 1180px) {
    .profile-hero {
        grid-template-columns: minmax(0, 1fr) auto 210px;
    }
    .profile-hero .stage {
        display: block;
        position: static;
        align-self: center;
        margin-block: -22px;
    }
}

.profile-results {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.profile-results__head p {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}
.profile-stats {
    --gap: 14px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.profile-stats .stat {
    position: relative;
    background: var(--ink-2);
    transition: border-color 0.25s;
}
.profile-stats .stat:hover {
    border-color: color-mix(in srgb, var(--mark, var(--gold)) 60%, transparent);
}
.stat--win {
    --mark: var(--good);
}
.stat--loss {
    --mark: var(--check);
}
.stat--draw {
    --mark: var(--muted);
}
.profile-stats .stat__label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.profile-stats .stat__label::before {
    content: '';
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--mark);
}
/* Wins, losses and draws as one bar. Each part grows by its count. */
.results-bar {
    display: flex;
    gap: 4px;
    height: 12px;
}
.results-bar span {
    flex: 0 1 0;
    min-width: 0;
    border-radius: 999px;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.9s var(--ease-out);
    transition-delay: calc(0.25s + var(--n, 0) * 0.14s);
}
.results-bar .is-win {
    background: var(--good);
}
.results-bar .is-loss {
    --n: 1;
    background: var(--check);
}
.results-bar .is-draw {
    --n: 2;
    background: var(--muted);
}
.is-in .results-bar span,
.no-js .results-bar span {
    transform: none;
}

.profile-links {
    --min: 230px;
    --gap: 14px;
}
.profile-links > div {
    display: flex;
}
.profile-link {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 6px;
    min-height: 148px;
}
/* Lift and lean together; .panel--link:hover alone would drop the lean. */
.profile-link[data-tilt]:hover {
    transform: perspective(900px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) translateY(-4px);
}
.profile-link h3 {
    font-size: 19px;
}
.profile-link p {
    font-size: 14.5px;
    color: var(--muted);
}
.profile-link__icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    margin-bottom: 8px;
    border-radius: 12px;
    background: var(--gold-wash);
    color: var(--gold);
    transition: transform 0.5s var(--ease-spring);
}
.profile-link__icon svg {
    width: 20px;
    height: 20px;
}
.profile-link:hover .profile-link__icon {
    transform: translateY(-3px) rotate(-8deg) scale(1.08);
}
.profile-link__go {
    margin-top: auto;
    padding-top: 10px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--gold);
    transition: letter-spacing 0.3s var(--ease-out);
}
.profile-link:hover .profile-link__go {
    letter-spacing: 0.04em;
}
.profile-account {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px 24px;
}
.profile-account p {
    max-width: 52ch;
    font-size: 14.5px;
    color: var(--muted);
}
@media (max-width: 480px) {
    .profile-stats {
        --gap: 8px;
    }
    .profile-stats .stat {
        padding: 14px 12px;
    }
}
/* On the narrowest phones a label and its dot are wider than a third of the
   row, so the card and the label close up a little. */
@media (max-width: 350px) {
    .profile-stats .stat {
        padding-inline: 8px;
    }
    .profile-stats .stat__label {
        gap: 5px;
        letter-spacing: 0.04em;
    }
}
@media (prefers-reduced-motion: reduce) {
    .results-bar span {
        transform: none;
    }
}

/* ---------- profile picture ---------- */

.avatar-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
    padding: clamp(22px, 3.4vw, 36px);
    box-shadow: var(--shadow);
}
.avatar-card > .messages {
    grid-column: 1 / -1;
    margin: 0;
}
.avatar-preview-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}
.avatar-img,
.avatar-placeholder {
    width: clamp(140px, 30vw, 184px);
    height: clamp(140px, 30vw, 184px);
    border-radius: 50%;
    box-shadow: 0 0 0 5px var(--ink-1), 0 0 0 7px var(--gold), 0 24px 50px -18px var(--gold);
    transition: transform 0.5s var(--ease-spring);
}
.avatar-img {
    object-fit: cover;
}
.avatar-placeholder {
    display: grid;
    place-items: center;
    background: var(--ink-3);
    color: var(--muted);
    box-shadow: 0 0 0 5px var(--ink-1), 0 0 0 7px var(--line-strong);
}
.avatar-placeholder svg {
    width: 44%;
    height: 44%;
}
.avatar-preview-wrap:hover .avatar-img,
.avatar-preview-wrap:hover .avatar-placeholder {
    transform: scale(1.04) rotate(-3deg);
}
.avatar-forms {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}
.upload-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    opacity: 0;
    white-space: nowrap;
}
.file-label {
    display: block;
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--radius);
    background: var(--ink-2);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.3s var(--ease-out);
}
.file-label:hover {
    border-color: var(--gold);
    background: var(--gold-wash);
    transform: translateY(-2px);
}
.file-input:focus-visible + .file-label {
    outline: 2px solid var(--gold);
    outline-offset: 3px;
}
.file-label.has-file {
    border-style: solid;
    border-color: var(--gold);
    background: var(--gold-wash);
}
.file-label-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 30px 20px;
    text-align: center;
}
.upload-icon {
    width: 30px;
    height: 30px;
    color: var(--muted);
    transition: color 0.2s, transform 0.4s var(--ease-spring);
}
.file-label:hover .upload-icon,
.file-label.has-file .upload-icon {
    color: var(--gold);
    transform: translateY(-4px);
}
.file-label-text {
    font-weight: 500;
    color: var(--title);
    overflow-wrap: anywhere;
}
.file-label-hint {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted);
}
.preview-new-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--ink-2);
    font-size: 14.5px;
}
.preview-new-wrap[hidden] {
    display: none;
}
.preview-new-img {
    flex: none;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 0 2px var(--gold);
}
.btn-clear-file {
    flex: none;
    margin-left: auto;
    width: 34px;
    height: 34px;
}
.btn-clear-file svg {
    width: 14px;
    height: 14px;
}
@media (min-width: 720px) {
    .avatar-card {
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        gap: 28px clamp(28px, 5vw, 56px);
    }
}

/* The profile picture is the way to the upload page: a camera badge sits on
   its corner. */
.profile-avatar-link {
    position: relative;
    display: inline-block;
    flex: none;
    border-radius: 50%;
}
.profile-avatar__badge {
    position: absolute;
    right: 0;
    bottom: 0;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 3px solid var(--ink-1);
    border-radius: 50%;
    background: var(--gold);
    color: var(--on-gold);
    transition: transform 0.3s var(--ease-spring);
}
.profile-avatar__badge svg {
    width: 18px;
    height: 18px;
}
.profile-avatar-link:hover .profile-avatar__badge,
.profile-avatar-link:focus-visible .profile-avatar__badge {
    transform: scale(1.14) rotate(-8deg);
}

/* ---------- touch screens ---------- */

/* The buttons that sit inside a field, and the one that clears a chosen
   picture, get room for a finger. */
@media (hover: none) and (pointer: coarse) {
    .pw-toggle {
        right: 4px;
        width: 40px;
        height: 40px;
    }
    .field--password .field__reveal {
        right: 4px;
        bottom: 4px;
        width: 40px;
        height: 40px;
    }
    .btn-clear-file {
        width: 40px;
        height: 40px;
    }
    /* "Send a new code" is a line of text. It takes a tap a little way
       outside its letters, the way the back link does in app.css. */
    .link-button {
        position: relative;
    }
    .link-button::after {
        content: '';
        position: absolute;
        inset: -10px -8px;
    }
}

/* ---------- the low performance tier ----------
   data-perf="low" is set by perf.js; see the end of app.css. account.js
   leaves the 3D piece out, so the flat one is shown from the first paint,
   standing still. */

[data-perf='low'] .stage canvas {
    display: none;
}
[data-perf='low'] .stage__flat {
    display: block;
    animation: none;
}
[data-perf='low'] .stage__frame::after {
    animation: none;
}
/* The gold ring round a picture stays; the glow under it goes. */
[data-perf='low'] .profile-avatar {
    box-shadow: 0 0 0 4px var(--ink-1), 0 0 0 6px var(--gold);
}
[data-perf='low'] .avatar-img {
    box-shadow: 0 0 0 5px var(--ink-1), 0 0 0 7px var(--gold);
}
