/* =============================================
   PRESCREEN — ID Card
   ============================================= */

#prescreen {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background-image: url('/images/lightmode.jpg');
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    overflow: hidden;
}

/* =============================================
   CARD MASK — genie collapses to center
   ============================================= */

.id-card-mask {
    position: relative;
    width: 600px;
    height: 330px;
    /* transform-origin center so genie collapses to screen center */
    transform-origin: center center;
    transition: transform 0.55s cubic-bezier(0.7, -0.01, 0.4, 1),
                opacity 0.4s ease;
}

.id-card-mask.genie-out {
    transform: scale(0.05);
    opacity: 0;
}

/* =============================================
   CARD REVEAL CIRCLE
   ============================================= */

.id-card-reveal-circle {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    transform: scale(0);
    transition: transform 0.55s cubic-bezier(0.34, 1.2, 0.64, 1),
                border-radius 0.55s cubic-bezier(0.34, 1.2, 0.64, 1);
    /* Default card color — overridden by JS via --card-bg */
    background: var(--card-bg, #3b6fd4);
    overflow: hidden;
}

.id-card-reveal-circle.expanded {
    transform: scale(1);
    border-radius: 18px;
}

/* =============================================
   THE ID CARD
   ============================================= */

.id-card {
    position: absolute;
    inset: 0;
    background: var(--card-bg, #3b6fd4);
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow:
        0 8px 40px rgba(0,0,0,0.25),
        0 0 0 1px rgba(0,0,0,0.08),
        inset 0 1px 0 rgba(255,255,255,0.18);
    font-family: 'SFRegular', sans-serif;
    transition: background 0.35s ease;
}

/* Subtle diagonal grain overlay */
.id-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        -45deg,
        rgba(255,255,255,0.03) 0px,
        rgba(255,255,255,0.03) 1px,
        transparent 1px,
        transparent 8px
    );
    border-radius: inherit;
    pointer-events: none;
    z-index: 0;
}

/* ─── Card Header ─── */
.id-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 18px 11px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    background: rgba(0,0,0,0.12);
    position: relative;
    z-index: 1;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.38s ease, transform 0.38s ease;
}
.id-card-header.loaded { opacity: 1; transform: translateY(0); }

.card-logo-img {
    height: 22px;
    width: auto;
    display: block;
    filter: brightness(0) invert(1);
    opacity: 0.8;
}

.id-card.light-card .card-logo-img {
    filter: brightness(0) invert(1);
    opacity: 0.8;
}

.card-label {
    font-family: 'SFMedium', sans-serif;
    font-size: 9.5px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.6);
}

/* ─── Card Body ─── */
.id-card-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

/* LEFT: Square Photo */
.id-card-photo-col {
    width: 190px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: 14px 12px 14px 16px;
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 0.38s ease 0.09s, transform 0.38s ease 0.09s;
}
.id-card-photo-col.loaded { opacity: 1; transform: translateX(0); }

.photo-frame {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: rgba(0,0,0,0.06);
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.06);
}
.photo-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }

.photo-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: rgba(255,255,255,0.4);
}
.photo-placeholder svg { opacity: 0.7; }
.photo-placeholder span {
    font-size: 9px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-family: 'SFMedium', sans-serif;
}

/* RIGHT: Fields */
.id-card-fields-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 14px 18px 14px 10px;
    gap: 12px;
    opacity: 0;
    transform: translateX(8px);
    transition: opacity 0.38s ease 0.17s, transform 0.38s ease 0.17s;
}
.id-card-fields-col.loaded { opacity: 1; transform: translateX(0); }

.id-field { display: flex; flex-direction: column; gap: 3px; }

.id-field-label {
    font-family: 'SFMedium', sans-serif;
    font-size: 8px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.5);
}

.id-field-name-row { display: flex; align-items: center; gap: 7px; }

.id-name-input {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 1.5px solid rgba(255,255,255,0.3);
    font-family: 'SFMedium', sans-serif;
    font-size: 15px;
    color: #fff;
    padding: 2px 0;
    outline: none;
    transition: border-color 0.2s ease;
    min-width: 0;
}
.id-name-input::placeholder { color: rgba(255,255,255,0.3); font-size: 13px; }
.id-name-input:focus { border-bottom-color: rgba(255,255,255,0.7); }

.randomize-btn {
    background: none;
    border: 1.5px solid rgba(255,255,255,0.25);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.5);
    padding: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
                border-color 0.2s, background 0.2s, color 0.2s;
}
.randomize-btn:hover {
    border-color: rgba(255,255,255,0.7);
    background: rgba(255,255,255,0.1);
    color: #fff;
}
/* spinning handled by SVG child animation — see bottom of file */

.id-date-value {
    font-family: 'SFMedium', sans-serif;
    font-size: 14px;
    color: rgba(255,255,255,0.85);
    border-bottom: 1.5px solid rgba(255,255,255,0.15);
    padding: 2px 0;
    user-select: none;
}

/* ─── Signature ─── */
.signature-wrapper {
    position: relative;
    border-radius: 6px 6px 0 0;
    background: transparent;
    overflow: hidden;
}

.signature-canvas {
    display: block;
    width: 100%;
    height: 56px;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    cursor: crosshair;
    position: relative;
    z-index: 2;
}

.signature-underline {
    height: 1.5px;
    background: rgba(255,255,255,0.2);
}

.signature-clear-btn {
    position: absolute;
    top: 4px;
    right: 5px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.3);
    font-size: 9px;
    cursor: pointer;
    font-family: 'SFMedium', sans-serif;
    letter-spacing: 0.5px;
    padding: 2px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    transition: color 0.2s, background 0.2s;
    z-index: 3;
}
.signature-clear-btn:hover {
    color: rgba(255,255,255,0.8);
    background: rgba(255,255,255,0.08);
}

.sig-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'SFItalic', serif;
    font-size: 12px;
    color: rgba(255,255,255,0.3);
    pointer-events: none;
    transition: opacity 0.2s ease;
    user-select: none;
    z-index: 1;
}
.sig-placeholder.hidden { opacity: 0; }

/* ─── Color Palette ─── */
.id-card-footer {
    padding: 10px 18px;
    border-top: 1px solid rgba(255,255,255,0.12);
    background: rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 1;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.38s ease 0.25s, transform 0.38s ease 0.25s;
    gap: 12px;
}
.id-card-footer.loaded { opacity: 1; transform: translateY(0); }

.color-palette {
    display: flex;
    gap: 7px;
    align-items: center;
}

.color-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.25);
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1),
                border-color 0.2s;
    flex-shrink: 0;
}
.color-swatch:hover { transform: scale(1.2); border-color: rgba(255,255,255,0.7); }
.color-swatch.active {
    border-color: #fff;
    transform: scale(1.25);
    box-shadow: 0 0 0 2px rgba(255,255,255,0.3);
}

.enter-btn {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border: 1.5px solid rgba(255,255,255,0.35);
    border-radius: 8px;
    padding: 7px 20px;
    font-family: 'SFMedium', sans-serif;
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s, border-color 0.2s;
    white-space: nowrap;
}
.enter-btn:hover { background: rgba(255,255,255,0.3); border-color: rgba(255,255,255,0.6); }
.enter-btn:active { transform: scale(0.97); }

/* =============================================
   DESKTOP WIDGET
   ============================================= */

#desktop-id-card {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 10000;
    width: 220px;
    border-radius: 14px;
    box-shadow:
        0 2px 8px rgba(0,0,0,0.08),
        0 0 0 1px rgba(0,0,0,0.05);
    overflow: hidden;
    /* Match system UI initial hidden state */
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 1s ease, transform 1s ease;
    pointer-events: auto;
    cursor: default;
    user-select: none;
    font-family: 'SFRegular', sans-serif;
    background: var(--card-bg, #D9EDF8);
}

/* Triggered by .visible class — same moment as system-ready */
#desktop-id-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px 7px;
    position: relative;
    z-index: 1;
}
.widget-logo-img {
    height: 14px;
    width: auto;
}
.widget-card-label {
    font-family: 'SFMedium', sans-serif;
    font-size: 7px;
    letter-spacing: 2px;
    text-transform: uppercase;
}
.widget-body {
    display: flex;
    padding: 10px 12px 12px 10px;
    align-items: flex-start;
    gap: 8px;
    position: relative;
}
.widget-photo {
    width: 52px;
    height: 52px;
    border-radius: 7px;
    border: 1px solid rgba(0,0,0,0.06);
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.widget-photo img { width: 100%; height: 100%; object-fit: cover; }

/* Fields area — position:relative so signature bg can sit behind */
.widget-fields {
    flex: 1;
    min-width: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

/* Signature watermark: absolute, fills the whole fields area */
.widget-sig-bg {
    position: absolute;
    inset: -4px -4px -4px -4px; /* bleed slightly to edges */
    z-index: 0;
    pointer-events: none;
}
.widget-sig-canvas {
    display: block;
    width: 100%;
    height: 100%;
    opacity: 0.55; /* subtle — behind the text */
}

/* Labels and values sit above the sig */
.widget-field-label {
    font-size: 6.5px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-family: 'SFMedium', sans-serif;
    position: relative;
    z-index: 1;
}
.widget-field-value {
    font-size: 13px;
    font-family: 'SFMedium', sans-serif;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    z-index: 1;
}
.widget-name,
.widget-date {
    font-family: 'Handwriting', cursive !important;
}

/* =============================================
   ADDITIONS & OVERRIDES
   ============================================= */

/* Handwriting font for name + date fields */
@font-face {
    font-family: 'Handwriting';
    src: url('/fonts/handwriting.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

.id-name-input,
.id-date-value,
.widget-name,
.widget-date {
    font-family: 'Handwriting', cursive !important;
}

/* Randomize button — circular arrows icon, rounder */
.randomize-btn {
    width: 24px;
    height: 24px;
}

.randomize-btn.spinning svg {
    animation: spin-once 0.5s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
}

@keyframes spin-once {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ─── Widget fields and sig handled above in the DESKTOP WIDGET block ─── */

/* ─── Light card mode (for pastel/light background colors) ─── */

.id-card.light-card {
    box-shadow:
        0 8px 40px rgba(0,0,0,0.12),
        0 0 0 1px rgba(0,0,0,0.06),
        inset 0 1px 0 rgba(255,255,255,0.6);
}

.id-card.light-card .id-card-header {
    border-bottom-color: rgba(0,0,0,0.08);
    background: rgba(255,255,255,0.35);
}

.id-card.light-card .card-logo-img {
    filter: brightness(0) invert(1);
    opacity: 0.8;
}

.id-card.light-card .card-label {
    color: rgba(0,0,0,0.35);
}

.id-card.light-card .id-field-label {
    color: rgba(0,0,0,0.4);
}

.id-card.light-card .id-name-input {
    color: #222;
    border-bottom-color: rgba(0,0,0,0.2);
}

.id-card.light-card .id-name-input::placeholder {
    color: rgba(0,0,0,0.25);
}

.id-card.light-card .id-name-input:focus {
    border-bottom-color: rgba(0,0,0,0.5);
}

.id-card.light-card .id-date-value {
    color: #444;
    border-bottom-color: rgba(0,0,0,0.1);
}

.id-card.light-card .photo-frame {
    background: rgba(0,0,0,0.08);
    border-color: rgba(0,0,0,0.1);
}

.id-card.light-card .photo-placeholder {
    color: rgba(0,0,0,0.3);
}

.id-card.light-card .sig-placeholder {
    color: rgba(0,0,0,0.25);
}

.id-card.light-card .signature-clear-btn {
    color: rgba(0,0,0,0.25);
}

.id-card.light-card .signature-clear-btn:hover {
    color: rgba(0,0,0,0.55);
    background: rgba(0,0,0,0.05);
}

.id-card.light-card .signature-underline {
    background: rgba(0,0,0,0.12);
}

.id-card.light-card .id-card-footer {
    border-top-color: rgba(0,0,0,0.07);
    background: rgba(255,255,255,0.25);
}

.id-card.light-card .enter-btn {
    background: rgba(0,0,0,0.12);
    color: #222;
    border-color: rgba(0,0,0,0.18);
}

.id-card.light-card .enter-btn:hover {
    background: rgba(0,0,0,0.2);
}

.id-card.light-card .randomize-btn {
    border-color: rgba(0,0,0,0.18);
    color: rgba(0,0,0,0.45);
}

.id-card.light-card .randomize-btn:hover {
    border-color: rgba(0,0,0,0.45);
    background: rgba(0,0,0,0.06);
    color: #222;
}

/* Signature ink — dark on light cards */
/* (handled in JS: makeSignaturePad uses white; on light cards switch to dark) */
