/*
File: profile.css
Purpose: Photo picker on the signed-in profile page.
*/

.profile-photo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 4px 0 6px;
}

.profile-photo-btn {
    width: 118px;
    height: 118px;
    padding: 0;
    border: 2px solid #515811;
    border-radius: 50%;
    background: transparent;
    color: transparent;
    cursor: pointer;
    overflow: hidden;
}

.profile-photo-btn:hover {
    background: #eceef1;
}

.profile-photo-btn:focus-visible {
    outline: 2px solid var(--rg-ink);
    outline-offset: 3px;
}

.profile-photo-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.profile-photo-preview.is-image svg {
    display: none;
}

.profile-photo-clear {
    height: 34px;
    padding: 0 12px 1px;
    border: 1px solid var(--rg-line);
    border-radius: var(--rg-pill);
    background: #fff;
    color: var(--rg-ink);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.profile-photo-clear:hover {
    background: var(--rg-paper);
}

.profile-photo-clear[hidden] {
    display: none;
}

#phone[readonly] {
    background: var(--rg-paper);
    color: var(--rg-muted);
}

#profile-admin-link[hidden] {
    display: none;
}

#profile-admin-link {
    background: #fff;
    color: var(--rg-submit);
    border: 1px solid var(--rg-line);
}

.avatar-crop-root {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.avatar-crop-root[hidden] { display: none; }

.avatar-crop-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(27, 36, 46, 0.42);
}

.avatar-crop-dialog {
    position: relative;
    width: min(24rem, 100%);
    background: #fff;
    border-radius: var(--rg-radius);
    box-shadow: var(--rg-shadow);
    padding: 20px 20px 16px;
}

.avatar-crop-dialog h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
}

.avatar-crop-lead {
    margin: 8px 0 0;
    font-size: 0.88rem;
    font-weight: 400;
    line-height: 1.7;
    color: var(--rg-muted);
}

.avatar-crop-stage {
    position: relative;
    width: 320px;
    height: 320px;
    max-width: 100%;
    aspect-ratio: 1;
    margin: 16px auto 0;
    overflow: hidden;
    background: #1b242e;
    border-radius: 12px;
    touch-action: none;
    cursor: grab;
}

.avatar-crop-stage:active { cursor: grabbing; }

.avatar-crop-stage img {
    position: absolute;
    top: 0;
    left: 0;
    max-width: none;
    transform-origin: 0 0;
    pointer-events: none;
    user-select: none;
}

.avatar-crop-mask {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 75%;
    height: 75%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    box-shadow: 0 0 0 999px rgba(15, 18, 22, 0.55);
    border: 2px solid #ffffff;
    pointer-events: none;
}

.avatar-crop-banner-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--rg-muted);
}

.avatar-crop-banner-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    background: #e8eaee;
    border: 1px solid var(--rg-line);
}

.avatar-crop-banner-circle img {
    position: absolute;
    top: 0;
    left: 0;
    max-width: none;
    transform-origin: 0 0;
}

.avatar-crop-zoom {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 14px;
    font-size: 0.82rem;
    font-weight: 600;
}

.avatar-crop-zoom input {
    width: 100%;
}

.avatar-crop-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.avatar-crop-actions .register-submit {
    width: auto;
    min-width: 8rem;
}

@media (max-width: 767px) {
    .avatar-crop-stage {
        width: min(320px, calc(100vw - 72px));
        height: auto;
    }
    body.profile-body {
        overflow: auto;
        height: auto;
        max-height: none;
    }
    body.profile-body .register-workspace {
        align-items: flex-start;
        min-height: var(--vvh, 100dvh);
        padding: calc(env(safe-area-inset-top, 0px) + 68px + 16px) 12px max(24px, env(safe-area-inset-bottom, 0px));
        overflow: visible;
    }
    body.profile-body .register-card {
        max-height: none;
        overflow: visible;
    }
}

body.profile-body {
    background-color: #e8d9b8;
    background-image: var(--curtain-image);
    background-size: cover;
    background-position: var(--curtain-position, center center);
    background-repeat: no-repeat;
    overflow: auto;
}

body.profile-body .register-workspace {
    min-height: var(--vvh, 100dvh);
    padding: calc(75px + var(--banner-gap) + 24px) 20px 32px;
    align-items: center;
}

body.profile-body .register-card {
    position: relative;
    width: min(26rem, 100%);
    padding: 28px 26px 24px;
    text-align: center;
    background: rgba(232, 217, 185, 0.18);
    backdrop-filter: blur(28px) saturate(1.4);
    -webkit-backdrop-filter: blur(28px) saturate(1.4);
    border: 1px solid rgba(255, 255, 255, 0.38);
    border-radius: 28px;
    box-shadow: 0 12px 32px rgba(81, 88, 17, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

body.profile-body #top-banner .banner-seg,
body.profile-body #top-banner .top-nav {
    display: none !important;
}

body.profile-body #profile-main {
    view-transition-name: account-card;
}

body.profile-body .register-card-wide {
    width: min(28rem, 100%);
}

body.profile-body .register-kicker {
    font-size: 1.05rem;
    font-weight: 500;
    color: #a18447;
}

body.profile-body .register-card h1 {
    margin-top: 2px;
    font-size: 1.7rem;
    font-weight: 700;
    color: #515811;
}

body.profile-body .register-lead {
    margin: 8px auto 0;
    color: #a18447;
}

body.profile-body .password-intro-phone {
    margin: 16px 0 0;
    color: #515811;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

body.profile-body .password-steps {
    counter-reset: step;
    margin: 18px 0 8px;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: start;
}

body.profile-body .password-steps li {
    position: relative;
    padding: 10px 14px 10px 14px;
    padding-inline-start: 2.6rem;
    border-radius: 14px;
    background: rgba(244, 237, 223, 0.72);
    color: #515811;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.6;
}

body.profile-body .password-steps li::before {
    content: counter(step);
    counter-increment: step;
    position: absolute;
    inset-inline-start: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    background: #515811;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.profile-body #profile-password-send {
    margin-top: 10px;
}

body.profile-body .register-card form {
    margin-top: 8px;
    gap: 12px;
}

body.profile-body .register-pair { gap: 12px; }

body.profile-body .register-field {
    position: relative;
    display: block;
    font-weight: 400;
}

body.profile-body .register-field > span {
    position: absolute;
    top: 26px;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #a18447;
    font-size: 0.95rem;
    font-weight: 500;
    pointer-events: none;
    white-space: nowrap;
    transition: top 0.28s cubic-bezier(0.22, 1, 0.36, 1),
                left 0.28s cubic-bezier(0.22, 1, 0.36, 1),
                right 0.28s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
                font-size 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

body.profile-body .register-field input:focus + span,
body.profile-body .register-field input:not(:placeholder-shown) + span,
body.profile-body .register-field input.is-filled + span {
    top: 7px;
    left: auto;
    right: 16px;
    transform: none;
    font-size: 0.68rem;
    font-weight: 600;
}

body.profile-body .register-field input {
    height: 52px;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    background: #fff;
    color: #515811;
    text-align: center;
    font-weight: 500;
    transition: padding 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

body.profile-body .register-field input:focus,
body.profile-body .register-field input:not(:placeholder-shown),
body.profile-body .register-field input.is-filled {
    text-align: start;
    padding-inline: 16px;
}

body.profile-body .register-field:has(> span) input:focus,
body.profile-body .register-field:has(> span) input:not(:placeholder-shown),
body.profile-body .register-field:has(> span) input.is-filled {
    padding-top: 18px;
    padding-bottom: 8px;
}

body.profile-body .register-field input[dir="ltr"]:focus,
body.profile-body .register-field input[dir="ltr"]:not(:placeholder-shown),
body.profile-body .register-field input[dir="ltr"].is-filled {
    text-align: left;
}

body.profile-body .register-field input::placeholder { color: transparent; }

body.profile-body .register-field input[readonly] {
    background: #fff;
    color: #515811;
    opacity: 0.85;
}

body.profile-body .register-submit {
    width: 100%;
    height: 52px;
    background: #515811;
    color: #ffffff;
}

body.profile-body .register-submit:hover:not(:disabled) {
    background: #3f460d;
    filter: none;
}

body.profile-body .profile-photo-btn {
    width: 118px;
    height: 118px;
    border: 2px solid #515811;
    background: transparent;
}

body.profile-body .profile-photo-btn:hover {
    background: rgba(244, 237, 223, 0.28);
}

body.profile-body .profile-photo-btn:has(.is-image) {
    border-color: transparent;
}

body.profile-body .profile-photo-clear {
    height: auto;
    padding: 0;
    border: 0;
    background: transparent;
    color: #a18447;
    font-size: 0.82rem;
    font-weight: 500;
}

body.profile-body .profile-photo-clear:hover {
    background: transparent;
    text-decoration: underline;
}

body.profile-body .auth-back-fab {
    position: absolute;
    top: 16px;
    inset-inline-start: 16px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: #a18447;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

body.profile-body .auth-back {
    border: 0;
    padding: 0;
    background: none;
    color: #a18447;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
}

body.profile-body .register-hint { color: #a18447; text-align: center; }

body.profile-body .otp-sending {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    min-height: 8.5rem;
    color: #515811;
    font-size: 0.95rem;
    font-weight: 600;
}
body.profile-body .otp-sending[hidden] { display: none; }
body.profile-body .otp-sending p { margin: 0; }
body.profile-body .otp-spinner {
    width: 38px;
    height: 38px;
    border: 3px solid rgba(81, 88, 17, 0.18);
    border-top-color: #515811;
    border-radius: 50%;
    animation: otp-spin 0.75s linear infinite;
}
@keyframes otp-spin {
    to { transform: rotate(360deg); }
}

body.profile-body #profile-admin-link {
    background: #fff;
    color: #515811;
    border: 0;
}

body.profile-body .register-field.is-picking {
    z-index: 50;
}

body.profile-body #birth_date {
    cursor: pointer;
    opacity: 1;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23a18447' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='4.5' width='18' height='16.5' rx='2'/><path d='M8 2.5v4'/><path d='M16 2.5v4'/><path d='M3 10h18'/></svg>");
    background-repeat: no-repeat;
    background-position: 16px 50%;
    background-size: 18px;
}

body.profile-body #birth_date:focus,
body.profile-body #birth_date:not(:placeholder-shown),
body.profile-body #birth_date.is-filled {
    padding-inline-start: 40px;
}

.shamsi-cal {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    z-index: 40;
    display: block;
    width: max(100%, 17.5rem);
    padding: 12px;
    border-radius: 18px;
    background: #fff;
    border: 1px solid rgba(81, 88, 17, 0.16);
    box-shadow: 0 14px 28px rgba(81, 88, 17, 0.16);
    text-align: center;
}

.shamsi-cal[hidden] { display: none; }

.shamsi-cal.is-above {
    top: auto;
    bottom: calc(100% + 8px);
}

.shamsi-cal-head {
    display: flex;
    align-items: center;
    gap: 6px;
}

.shamsi-cal-head select {
    flex: 1 1 0;
    min-width: 0;
    height: 34px;
    border: 0;
    border-radius: 999px;
    background: #efe6d4;
    color: #515811;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
}

.shamsi-cal-shift {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: #efe6d4;
    color: #515811;
    font: inherit;
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
}

.shamsi-cal-shift:hover,
.shamsi-cal-head select:hover,
.shamsi-cal-day:hover:not(.is-selected) {
    background: #e7d6b5;
}

.shamsi-cal-week,
.shamsi-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.shamsi-cal-week {
    margin-top: 10px;
    color: #a18447;
    font-size: 0.72rem;
    font-weight: 600;
}

.shamsi-cal-week span {
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shamsi-cal-grid {
    margin-top: 2px;
}

.shamsi-cal-empty {
    height: 34px;
}

.shamsi-cal-day {
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #515811;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
}

.shamsi-cal-day.is-today {
    box-shadow: inset 0 0 0 1.5px #a18447;
}

.shamsi-cal-day.is-selected {
    background: #515811;
    color: #fff;
    box-shadow: none;
}

.shamsi-cal-day:focus-visible,
.shamsi-cal-shift:focus-visible,
.shamsi-cal-head select:focus-visible,
.shamsi-cal-clear:focus-visible {
    outline: 2px solid #515811;
    outline-offset: 2px;
}

.shamsi-cal-clear {
    width: 100%;
    margin-top: 8px;
    height: 32px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #a18447;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
}

.shamsi-cal-clear:hover {
    text-decoration: underline;
}

@media (max-width: 767px) {
    body.profile-body .register-workspace {
        padding: calc(64px + 28px) 14px 20px;
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
}

/* Reserve only keyboard overlap, and let short visible viewports scroll naturally. */
@media (max-width:767px), (pointer:coarse) {
    body.profile-body .register-workspace {
        padding-bottom:calc(max(20px, env(safe-area-inset-bottom, 0px)) + var(--profile-keyboard-inset, 0px));
    }
    html.profile-keyboard-open body.profile-body .register-workspace { align-items:flex-start; }
    body.profile-body .register-card input,
    body.profile-body .register-card textarea,
    body.profile-body .register-card select { scroll-margin-block:100px 24px; }
}

@media (max-width:767px) {
    body.profile-body .register-card { backdrop-filter:blur(8px) saturate(1.1); -webkit-backdrop-filter:blur(8px) saturate(1.1); }
    body.profile-body .register-field>span,body.profile-body .register-field input { transition:none; }
}
