/* Palmistry — biometric / dactyloscopy scan UI */

/* Modal chrome (shared "wnw" shell used by palmistry_chart.js) */
.wnw-overlay {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
        max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    box-sizing: border-box;
    background: rgba(8, 12, 22, 0.62);
    backdrop-filter: blur(2px);
}

.wnw-overlay[hidden] {
    display: none !important;
}

.wnw-dialog {
    display: flex;
    flex-direction: column;
    width: min(1100px, 100%);
    max-height: 92vh;
    overflow: hidden;
    border-radius: 14px;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
}

.wnw-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    flex-shrink: 0;
}

.wnw-title {
    min-width: 0;
}

.wnw-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.wnw-actions button,
.wnw-close {
    appearance: none;
    border: 1px solid #d5dbe6;
    background: #fff;
    color: #1f2937;
    font: 600 12px/1.2 "IBM Plex Mono", "Consolas", "Courier New", monospace;
    letter-spacing: 0.04em;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
}

.wnw-actions button:hover,
.wnw-close:hover {
    border-color: #b8c2d1;
    background: #f8fafc;
}

.wnw-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.palm-dialog {
    width: 100%;
    max-width: none;
    max-height: 92vh;
    background: #fff;
    border: 1px solid #e4e8f0;
    font-family: "IBM Plex Mono", "Consolas", "Courier New", monospace;
}

.palm-dialog--wide {
    width: 100%;
    max-width: none;
}

.palm-toolbar {
    background: #fafbfc;
    border-bottom: 1px solid #eceff3;
    align-items: flex-start;
}

.palm-toolbar__meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.palm-dialog .wnw-title {
    color: #1f2937;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.palm-toolbar__sub {
    font-size: 11px;
    letter-spacing: 0.06em;
    color: #64748b;
}

.palm-body {
    padding: 12px 12px 16px;
    background: #f8fafc;
    overflow: auto;
}

.palm-build-sheet {
    max-width: 420px;
    margin: 28px auto 18px;
    padding: 22px 22px 20px;
    background: #fff;
    border: 1px solid #e4e8f0;
    border-radius: 14px;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
}

.palm-build-sheet__title {
    font-size: 16px;
    font-weight: 700;
    color: #111;
    margin-bottom: 6px;
}

.palm-build-sheet__hint {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 18px;
}

.palm-build-bar {
    height: 10px;
    border-radius: 99px;
    background: #eceef1;
    overflow: hidden;
}

.palm-build-bar > i {
    display: block;
    height: 100%;
    width: 0%;
    border-radius: 99px;
    background: linear-gradient(90deg, #7ec8a3, #4ea87e);
    transition: width 0.28s ease;
}

.palm-build-sheet__pct {
    margin-top: 10px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: #475569;
    font-family: "IBM Plex Mono", "Consolas", "Courier New", monospace;
}

.palm-body-inner {
    min-height: 0;
}

.palm-gallery {
    display: grid;
    gap: 14px;
    width: 100%;
    align-items: start;
    justify-items: center;
}

.palm-gallery--single {
    grid-template-columns: 1fr;
}

.palm-gallery--pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.palm-gallery--many {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.palm-card {
    display: block;
    width: 100%;
    background: #fff;
    border: 1px solid #e4e8f0;
    opacity: 0;
    transform: translateY(8px);
}

.palm-card--reveal {
    animation: palmCardIn 0.55s ease forwards;
}

@keyframes palmCardIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.palm-card__frame {
    position: relative;
    background:
        linear-gradient(#c5d0dc, #c5d0dc) 0 0 / 12px 1px no-repeat,
        linear-gradient(#c5d0dc, #c5d0dc) 0 0 / 1px 12px no-repeat,
        linear-gradient(#c5d0dc, #c5d0dc) 100% 0 / 12px 1px no-repeat,
        linear-gradient(#c5d0dc, #c5d0dc) 100% 0 / 1px 12px no-repeat,
        linear-gradient(#c5d0dc, #c5d0dc) 0 100% / 12px 1px no-repeat,
        linear-gradient(#c5d0dc, #c5d0dc) 0 100% / 1px 12px no-repeat,
        linear-gradient(#c5d0dc, #c5d0dc) 100% 100% / 12px 1px no-repeat,
        linear-gradient(#c5d0dc, #c5d0dc) 100% 100% / 1px 12px no-repeat,
        #f4f6f8;
    padding: 8px;
}

.palm-card__badge {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 2;
    padding: 3px 7px;
    font-size: 9px;
    letter-spacing: 0.14em;
    color: #3a4a5a;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(80, 110, 140, 0.25);
    pointer-events: none;
}

.palm-analysis__subject {
    max-width: 58%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
    text-transform: none;
    letter-spacing: 0.02em;
    font-size: 11px;
}

.palm-stage {
    position: relative;
    width: 100%;
    background: #fff;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.palm-stage__fit {
    position: relative;
    display: inline-block;
    max-width: 100%;
    line-height: 0;
}

.palm-card__img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 68vh;
    margin: 0 auto;
    vertical-align: top;
    filter: contrast(1.05);
}

.palm-gallery--pair .palm-card__img,
.palm-gallery--many .palm-card__img {
    max-height: min(52vh, 520px);
}

.palm-scanline {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    top: -4%;
    background: linear-gradient(90deg, transparent, rgba(80, 160, 220, 0.55), transparent);
    box-shadow: 0 0 12px rgba(80, 160, 220, 0.35);
    pointer-events: none;
    opacity: 0;
}

.palm-card--reveal .palm-scanline {
    animation: palmScan 1.4s ease-in-out 0.15s 1;
}

@keyframes palmScan {
    0% { top: -2%; opacity: 0; }
    12% { opacity: 1; }
    88% { opacity: 0.7; }
    100% { top: 102%; opacity: 0; }
}

.palm-lines-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
    opacity: 0;
}

.palm-lines-svg .palm-scan-crease {
    /* Keep crease ink readable after the photo is scaled down in the gallery */
    vector-effect: non-scaling-stroke;
}

.palm-card--reveal .palm-lines-svg {
    animation: palmLinesIn 0.7s ease 0.55s forwards;
}

@keyframes palmLinesIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.palm-analysis {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 16px 14px;
    background: #f8fafc;
    color: #475569;
    font-size: 11px;
    letter-spacing: 0.08em;
}

.palm-analysis__head {
    font-size: 12px;
    font-weight: 600;
    color: #1f2937;
    letter-spacing: 0.16em;
}

.palm-analysis__row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
    border-bottom: 1px solid #e8ecf2;
}

.palm-analysis__row span {
    color: #64748b;
}

.palm-analysis__row strong {
    color: #1f2937;
    font-weight: 600;
}

.palm-analysis__row--conf strong {
    color: #7ec8a3;
}

.palm-analysis__lines {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.palm-analysis__lines li {
    display: grid;
    grid-template-columns: 8px 1fr auto;
    align-items: center;
    gap: 10px;
}

.palm-analysis__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.palm-analysis__name {
    color: #334155;
    text-transform: uppercase;
    font-size: 10px;
}

.palm-analysis__status {
    font-size: 10px;
    letter-spacing: 0.1em;
}

.palm-analysis__lines li.is-detected .palm-analysis__status {
    color: #7ec8a3;
}

.palm-analysis__lines li.is-missing .palm-analysis__status {
    color: #6d7f92;
}

.palm-analysis__lines li.is-missing .palm-analysis__dot {
    opacity: 0.35;
}

.palm-analysis__foot {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid rgba(160, 185, 210, 0.12);
    color: #7ec8a3;
    font-size: 10px;
    letter-spacing: 0.14em;
    opacity: 0;
}

.palm-card--reveal .palm-analysis__foot {
    animation: palmLinesIn 0.4s ease 1.1s forwards;
}

.natal-viz-btn--palmistry {
    background: linear-gradient(180deg, #f08a3a 0%, #e87830 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(232, 120, 48, 0.35);
}

/* --- Staged scan (admin animateScan) --- */

.palm-scan-view {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
    max-width: none;
    margin: 0;
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid #e4e8f0;
}

.palm-scan-stage {
    position: relative;
    background: #fff;
    min-height: 280px;
}

.palm-scan-stage__img {
    display: block;
    width: 100%;
    height: auto;
    vertical-align: top;
}

.palm-scan-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.palm-scan-outline,
.palm-lines-svg .palm-scan-outline {
    filter: drop-shadow(0 0 1px rgba(40, 120, 80, 0.35));
}

.palm-scan-caption {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 14px;
    max-width: calc(100% - 24px);
    padding: 6px 14px;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #1a1d23;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 999px;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.12);
    pointer-events: none;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.palm-scan-sheet {
    background: #fff;
    color: #1a1a1a;
    border-radius: 18px 18px 0 0;
    margin-top: -12px;
    position: relative;
    z-index: 2;
    padding: 18px 20px 22px;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.25);
}

.palm-scan-sheet__title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    color: #111;
}

.palm-scan-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.palm-scan-step {
    display: grid;
    grid-template-columns: 28px 1fr 28px;
    gap: 10px;
    align-items: center;
}

.palm-scan-step__ico {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: #f0f1f3;
    position: relative;
}

.palm-scan-step__ico::after {
    content: "";
    position: absolute;
    inset: 7px;
    border: 2px solid #c5c8ce;
    border-radius: 4px;
}

.palm-scan-step.is-active .palm-scan-step__ico::after {
    border-color: #f08a3a;
    border-top-color: transparent;
    border-radius: 50%;
    animation: palmScanSpin 0.8s linear infinite;
}

.palm-scan-step.is-done .palm-scan-step__ico {
    background: #e8f7ee;
}

.palm-scan-step.is-done .palm-scan-step__ico::after {
    content: "";
    inset: 8px 7px 9px 8px;
    border: none;
    border-left: 2.5px solid #2db86a;
    border-bottom: 2.5px solid #2db86a;
    border-radius: 0;
    transform: rotate(-45deg);
    animation: none;
}

.palm-scan-step__label {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
}

.palm-scan-step__bar {
    height: 6px;
    border-radius: 99px;
    background: #eceef1;
    overflow: hidden;
}

.palm-scan-step__bar > i {
    display: block;
    height: 100%;
    width: 0%;
    border-radius: 99px;
    background: linear-gradient(90deg, #f0a04b, #e87830);
    transition: width 0.25s ease;
}

.palm-scan-step__status {
    width: 22px;
    height: 22px;
}

@keyframes palmScanSpin {
    to { transform: rotate(360deg); }
}

@media (max-width: 720px) {
    .palm-dialog,
    .palm-dialog--wide {
        width: 100%;
        max-width: none;
    }

    .palm-gallery--pair,
    .palm-gallery--many {
        grid-template-columns: 1fr;
    }

    .palm-card__img,
    .palm-gallery--pair .palm-card__img,
    .palm-gallery--many .palm-card__img {
        max-width: 100%;
        max-height: 58vh;
    }
}

/* Inline mount on /result (free palmistry viz) */
.palm-result-inline {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.palm-result-inline__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px 14px;
}
.palm-result-inline__title {
    font-weight: 800;
    font-size: 1.05rem;
    color: #2b2358;
}
.palm-result-inline__sub {
    flex: 1 1 auto;
    font-size: 0.9rem;
    color: #6b6288;
}
.palm-result-inline__dl {
    appearance: none;
    border: 1px solid rgba(124, 92, 252, 0.35);
    background: #fff;
    color: #5b21b6;
    font: 700 13px/1.2 inherit;
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
}
.palm-result-inline__body .palm-gallery {
    margin: 0;
}
body.result-page.result-reading .rr-viz:not([hidden]) {
    display: block;
    min-height: 200px;
}
