/* Face-search UI shared by findInRace.html and race.html (#104, #111) */

/* --- #104: capped selfie preview, crop modal, submit nudge --- */
#video-container,
.preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 1rem;
}

#video-container[style*="display:none"],
#video-container[style*="display: none"],
.preview-container[style*="display:none"],
.preview-container[style*="display: none"] {
    display: none !important;
}

#video,
.preview-image {
    display: block;
    width: 100%;
    max-width: 320px;
    max-height: 40vh;
    object-fit: cover;
    border-radius: 0.75rem;
    background: #000;
}

#video {
    transform: scaleX(-1); /* mirror the live view like a normal selfie camera */
}

.upload-chosen {
    display: none;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.upload-chosen img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 0.5rem;
}

.upload-chosen .upload-chosen-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.upload-chosen button,
.crop-actions button {
    border: none;
    border-radius: 9999px;
    padding: 0.5rem 1.1rem;
    font-weight: 600;
    cursor: pointer;
    color: #fff;
    background: #6b7280;
}

.crop-actions .crop-confirm {
    background: #ff6b35;
}

.crop-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.75);
}

.crop-modal.open {
    display: flex;
}

.crop-dialog {
    width: 100%;
    max-width: 560px;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 0.75rem;
    background: #141414;
    color: #ededed;
}

.crop-dialog p {
    margin: 0;
    font-size: 0.95rem;
}

.crop-stage {
    flex: 1 1 auto;
    min-height: 0;
    height: 55vh;
    background: #000;
}

.crop-stage img {
    display: block;
    max-width: 100%;
}

.crop-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.submit-button.needs-click {
    animation: submit-nudge 1.4s ease-in-out infinite;
}

@keyframes submit-nudge {
    0%, 100% { box-shadow: 0 6px 18px rgba(255, 107, 53, 0.34); }
    50% { box-shadow: 0 0 0 8px rgba(255, 107, 53, 0.35), 0 6px 18px rgba(255, 107, 53, 0.34); }
}

.submit-hint {
    display: none;
    margin: 0 0 0.5rem;
    text-align: center;
    font-weight: 700;
    color: #ff6b35;
}

.submit-hint.show {
    display: block;
}

@media (prefers-reduced-motion: reduce) {
    .submit-button.needs-click {
        animation: none;
        outline: 3px solid rgba(255, 107, 53, 0.6);
    }
}

/* --- #111: shared styles for the face-search fields, used by the Find My Photos page and the race-page overlay --- */
.camera-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    border-radius: 9999px;
    padding: 0.7rem 1.4rem;
    font-weight: 700;
    color: #fff;
    background: #3b82f6;
    cursor: pointer;
}

.camera-button:disabled {
    opacity: 0.6;
    cursor: default;
}

/* Overlay (race page). Self-contained so it doesn't depend on form-pages.css, which has page-level rules. */
.face-search-overlay {
    position: fixed;
    inset: 0;
    z-index: 1900;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.75);
}

.face-search-overlay.open {
    display: flex;
}

body.face-search-open {
    overflow: hidden;
}

.face-search-dialog {
    position: relative;
    width: 100%;
    max-width: 560px;
    margin: auto;
    padding: 1.25rem;
    border-radius: 0.75rem;
    background: #141414;
    color: #ededed;
    border: 1px solid #2f2f2f;
}

.face-search-dialog .form-section {
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

.face-search-dialog h2,
.face-search-dialog h3 {
    color: #ededed;
}

.face-search-dialog h2 {
    font-size: 1.25rem;
    margin: 0 0 0.25rem;
}

.face-search-dialog .upload-instructions p,
.face-search-dialog .helper-text {
    color: #cfcfcf;
    font-size: 0.9rem;
    margin: 0 0 0.5rem;
}

.face-search-dialog .upload-input {
    width: 100%;
    padding: 0.7rem;
    border-radius: 0.6rem;
    border: 2px dashed #3a3a3a;
    background: #101010;
    color: #f3f3f3;
}

.face-search-dialog .info-tip {
    margin-top: 1rem;
    padding: 0.8rem 1rem;
    border-radius: 0.6rem;
    background: #1a1a1a;
    border-left: 4px solid #ff6b35;
}

.face-search-dialog .info-tip p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.45;
    color: #f3f3f3;
}

.face-search-close {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    border: none;
    background: transparent;
    color: #ededed;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.face-search-bib-note {
    margin: 1rem 0 0;
    font-size: 0.9rem;
    color: #cfcfcf;
}

.face-search-dialog .submit-button-section {
    margin: 1rem 0 0;
}

.face-search-dialog .submit-button {
    background: #ff6b35;
    color: #fff;
    border: none;
    border-radius: 9999px;
    padding: 0.8rem 2rem;
    font-weight: 700;
    cursor: pointer;
}

.face-search-dialog .submit-hint {
    margin-top: 0.75rem;
}

/* My Photos: the saved-face panel that starts an all-races search (#135) */
.face-panel { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin: 0 0 1.5rem; padding: 1rem 1.25rem;
    background: rgba(255, 107, 53, 0.12); border-radius: 0.75rem; }
.face-panel-thumb { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 3px solid #FF6B35; }
.face-panel-icon { font-size: 3rem; color: #FF6B35; width: 72px; text-align: center; }
.face-panel-text { flex: 1; min-width: 240px; color: inherit; }
.face-panel-text small { display: block; opacity: 0.8; margin-top: 0.15rem; }
.face-panel-text a { color: #fff; font-weight: 600; text-decoration: underline; }
.face-panel-text a:hover { color: #FF6B35; }
.face-find-hint { font-size: 0.85rem; opacity: 0.8; margin: 0.25rem 0 0.75rem; }
.face-panel-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
.face-panel-link { background: none; border: 0; padding: 0; color: #2563EB; text-decoration: underline; cursor: pointer; font-size: 0.9rem; }

/* My Photos while comparing a different photo of me with the saved face (#135) */
.face-compare-who { display: flex; gap: 0.9rem; align-items: center; }
.face-compare-who img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; border: 2px solid #FF6B35; flex-shrink: 0; }
.photo-group-title { font-size: 1.15rem; font-weight: 700; margin: 1.75rem 0 0.75rem; padding-bottom: 0.4rem; border-bottom: 1px solid rgba(255, 255, 255, 0.15); }
.photo-group-title span { font-weight: 400; opacity: 0.6; margin-left: 0.4rem; font-size: 0.95rem; }
