/*
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: 18px 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-hint {
    margin: 0;
    max-width: 28ch;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 400;
    line-height: 1.65;
    color: var(--rg-muted);
}

.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 {
    background-color: #e8d9b8;
    background-image: url("../assets/images/bg_curtain.webp");
    background-size: cover;
    background-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.14);
    backdrop-filter: blur(28px) saturate(1.35);
    -webkit-backdrop-filter: blur(28px) saturate(1.35);
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 28px;
    box-shadow: 0 12px 32px rgba(81, 88, 17, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

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 .register-card form {
    margin-top: 18px;
    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),
                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 {
    left: calc(100% - 16px);
    transform: translate(-100%, -50%);
    font-size: 0.72rem;
    font-weight: 600;
}

body.profile-body .register-field input {
    height: 52px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    background: #f4eddf;
    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-start: 8rem;
    padding-inline-end: 16px;
}

body.profile-body .register-field input[dir="ltr"]:focus,
body.profile-body .register-field input[dir="ltr"]:not(:placeholder-shown) {
    text-align: left;
    padding-inline-start: 16px;
    padding-inline-end: 8rem;
}

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

body.profile-body .register-field input[readonly] {
    background: #f4eddf;
    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-password-btn {
    width: 100%;
    height: 52px;
    border: 0;
    border-radius: 999px;
    background: #E7D6B5;
    color: #515811;
    font: inherit;
    font-size: 0.98rem;
    font-weight: 600;
    cursor: pointer;
}

body.profile-body .profile-password-btn:hover {
    filter: brightness(0.97);
}

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: #f4eddf;
    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); }
}

.birth-trigger {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 52px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #515811;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
}

#birth-field.is-filled .birth-trigger,
#birth-field:focus-within .birth-trigger {
    text-align: start;
    padding-inline-end: 16px;
    padding-inline-start: 8rem;
}

#birth-field.is-filled > span,
#birth-field:focus-within > span {
    left: calc(100% - 16px);
    transform: translate(-100%, -50%);
    font-size: 0.72rem;
    font-weight: 600;
}

.jalali-cal {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 8;
    padding: 10px;
    border-radius: 16px;
    background: rgba(244, 237, 223, 0.96);
    box-shadow: 0 10px 28px rgba(81, 88, 17, 0.16);
    text-align: center;
}

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

.jalali-cal-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.jalali-cal-bar select {
    flex: 1;
    height: 34px;
    border: 0;
    border-radius: 999px;
    background: #fff;
    color: #515811;
    font: inherit;
    font-size: 0.82rem;
    padding: 0 8px;
}

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

.jalali-week span {
    font-size: 0.7rem;
    color: #a18447;
    padding: 4px 0;
}

.jalali-grid button {
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #515811;
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
}

.jalali-grid button:hover { background: rgba(81, 88, 17, 0.08); }
.jalali-grid button.is-selected { background: #515811; color: #fff; }

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

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