/* ===========================
   LASERLAB EXPORT — Download Modal v2
   Art-First glass modal with circular preview
   =========================== */

/* ── Overlay / Backdrop ── */

#download-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

#download-modal.dlm-visible {
    opacity: 1;
    visibility: visible;
}

.dlm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 18, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* ── Main Card ── */

.dlm-card {
    position: relative;
    width: 440px;
    max-width: 92vw;
    max-height: 92vh;
    overflow-y: auto;
    background: linear-gradient(168deg,
        rgba(15, 23, 42, 0.97) 0%,
        rgba(20, 28, 50, 0.97) 40%,
        rgba(15, 23, 42, 0.97) 100%);
    border: 1px solid rgba(96, 165, 250, 0.18);
    border-radius: 20px;
    box-shadow:
        0 0 0 1px rgba(96, 165, 250, 0.06),
        0 25px 70px rgba(0, 0, 0, 0.55),
        0 0 120px rgba(96, 165, 250, 0.04);
    transform: translateY(18px) scale(0.96);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
                opacity 0.4s ease;
}

#download-modal.dlm-visible .dlm-card {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Scrollbar styling for overflow */
.dlm-card::-webkit-scrollbar { width: 4px; }
.dlm-card::-webkit-scrollbar-thumb {
    background: rgba(96, 165, 250, 0.2);
    border-radius: 2px;
}

/* ── Close Button ── */

.dlm-close {
    position: absolute;
    top: 16px;
    right: 18px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 8px;
    color: #64748b;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 2;
    line-height: 1;
}

.dlm-close:hover {
    color: #e2e8f0;
    background: rgba(30, 41, 59, 0.9);
    border-color: rgba(148, 163, 184, 0.25);
}

/* ── Header ── */

.dlm-header {
    padding: 32px 32px 0;
    text-align: center;
}

.dlm-title {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #94a3b8;
    margin: 0 0 4px;
}

.dlm-title span {
    color: #e2e8f0;
}

/* ── Filename Input (minimalist — bottom border only) ── */

.dlm-filename-wrap {
    padding: 10px 60px 0;
    text-align: center;
}

.dlm-filename-label {
    display: block;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #475569;
    margin-bottom: 4px;
}

.dlm-filename-input {
    width: 100%;
    padding: 6px 0;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    color: #e2e8f0;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    text-align: center;
    outline: none;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.dlm-filename-input::placeholder {
    color: #475569;
}

.dlm-filename-input:focus {
    border-bottom-color: rgba(96, 165, 250, 0.5);
}

/* ── Circular Preview ── */

.dlm-preview-area {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 0 24px;
}

.dlm-preview-ring {
    position: relative;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    padding: 3px;
    background: conic-gradient(
        from 0deg,
        rgba(96, 165, 250, 0.6),
        rgba(139, 92, 246, 0.4),
        rgba(245, 158, 11, 0.5),
        rgba(139, 92, 246, 0.4),
        rgba(96, 165, 250, 0.6)
    );
    box-shadow:
        0 0 30px rgba(96, 165, 250, 0.12),
        0 0 60px rgba(139, 92, 246, 0.06);
    animation: dlmRingSpin 12s linear infinite;
}

@keyframes dlmRingSpin {
    from { background: conic-gradient(from 0deg, rgba(96,165,250,0.6), rgba(139,92,246,0.4), rgba(245,158,11,0.5), rgba(139,92,246,0.4), rgba(96,165,250,0.6)); }
    to   { background: conic-gradient(from 360deg, rgba(96,165,250,0.6), rgba(139,92,246,0.4), rgba(245,158,11,0.5), rgba(139,92,246,0.4), rgba(96,165,250,0.6)); }
}

/* Smooth rotation via a pseudo-element overlay trick for the conic gradient */
.dlm-preview-ring::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    padding: 3px;
    background: inherit;
    animation: dlmGlowPulse 4s ease-in-out infinite;
    opacity: 0.5;
    filter: blur(12px);
    z-index: 0;
}

@keyframes dlmGlowPulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50%      { opacity: 0.6; transform: scale(1.04); }
}

.dlm-preview-inner {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(10, 15, 30, 1);
    z-index: 1;
}

.dlm-preview-canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ── Format Cards ── */

.dlm-formats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 0 24px;
}

.dlm-format-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 18px 14px 16px;
    border-radius: 14px;
    border: 1px solid;
    background: rgba(15, 23, 42, 0.6);
    cursor: pointer;
    transition: all 0.25s ease;
    overflow: hidden;
}

/* Subtle gradient overlay for depth */
.dlm-format-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 14px;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.dlm-format-card:hover::before {
    opacity: 1;
}

/* — PNG Card (Blue / Indigo) — */
.dlm-format-card.dlm-png {
    border-color: rgba(96, 165, 250, 0.25);
}

.dlm-format-card.dlm-png:hover {
    border-color: rgba(96, 165, 250, 0.5);
    background: rgba(96, 165, 250, 0.06);
    box-shadow: 0 4px 24px rgba(96, 165, 250, 0.1);
}

.dlm-format-card.dlm-png::before {
    background: radial-gradient(ellipse at 50% 0%, rgba(96, 165, 250, 0.08) 0%, transparent 70%);
}

/* — JPEG Card (Gold / Amber) — */
.dlm-format-card.dlm-jpeg {
    border-color: rgba(245, 158, 11, 0.25);
}

.dlm-format-card.dlm-jpeg:hover {
    border-color: rgba(245, 158, 11, 0.5);
    background: rgba(245, 158, 11, 0.06);
    box-shadow: 0 4px 24px rgba(245, 158, 11, 0.1);
}

.dlm-format-card.dlm-jpeg::before {
    background: radial-gradient(ellipse at 50% 0%, rgba(245, 158, 11, 0.08) 0%, transparent 70%);
}

/* Badge (LOSSLESS / PHOTO) */
.dlm-badge-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.dlm-badge {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.dlm-badge-png {
    border: 2px solid rgba(96, 165, 250, 0.5);
    color: #60a5fa;
}

.dlm-badge-jpeg {
    border: 2px solid rgba(245, 158, 11, 0.5);
    color: #f59e0b;
}

.dlm-badge-micro {
    font-size: 7px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    line-height: 1;
    opacity: 0.8;
}

.dlm-badge-label {
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    margin-top: 1px;
}

/* Checkmark for active/selected state (optional — wired in JS) */
.dlm-badge-check {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    color: #0f172a;
    display: none;
}

.dlm-badge-check.dlm-png-check {
    background: #60a5fa;
}

.dlm-badge-check.dlm-jpeg-check {
    background: #f59e0b;
}

/* Format label */
.dlm-format-name {
    font-size: 20px;
    font-weight: 800;
    color: #e2e8f0;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.dlm-format-desc {
    font-size: 11px;
    color: #64748b;
    text-align: center;
    line-height: 1.4;
    margin-bottom: 14px;
    min-height: 32px;
}

/* Download button inside each card */
.dlm-download-btn {
    width: 100%;
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid;
    background: transparent;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.dlm-download-btn.dlm-btn-png {
    color: #60a5fa;
    border-color: rgba(96, 165, 250, 0.4);
}

.dlm-download-btn.dlm-btn-png:hover {
    background: rgba(96, 165, 250, 0.12);
    border-color: rgba(96, 165, 250, 0.7);
    box-shadow: 0 0 16px rgba(96, 165, 250, 0.15);
}

.dlm-download-btn.dlm-btn-jpeg {
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.4);
}

.dlm-download-btn.dlm-btn-jpeg:hover {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.7);
    box-shadow: 0 0 16px rgba(245, 158, 11, 0.15);
}

/* ── Technical Footer ── */

.dlm-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 18px 24px 22px;
    margin-top: 8px;
}

.dlm-footer-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(30, 41, 59, 0.5);
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.08);
}

.dlm-footer-icon {
    color: #475569;
    flex-shrink: 0;
}

.dlm-footer-value {
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    letter-spacing: 0.3px;
}

.dlm-footer-divider {
    width: 1px;
    height: 20px;
    background: rgba(148, 163, 184, 0.12);
    margin: 0 4px;
}

/* ── Processing Overlay (reuses existing structure) ── */

.dlm-processing {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    background: rgba(10, 15, 30, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 20px;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.dlm-processing.active {
    opacity: 1;
    visibility: visible;
}

/* Spinner ring */
.dlm-spinner-ring {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid rgba(96, 165, 250, 0.15);
    border-top-color: #60a5fa;
    animation: dlmSpin 1s linear infinite;
}

@keyframes dlmSpin {
    to { transform: rotate(360deg); }
}

.dlm-processing-text {
    font-size: 14px;
    font-weight: 700;
    color: #e2e8f0;
}

.dlm-processing-sub {
    font-size: 12px;
    color: #64748b;
}

/* ── Responsive ── */

@media (max-width: 480px) {
    .dlm-card {
        max-width: 96vw;
        border-radius: 16px;
    }

    .dlm-header { padding: 24px 20px 0; }
    .dlm-filename-wrap { padding: 8px 24px 0; }
    .dlm-formats { padding: 0 16px; gap: 8px; }
    .dlm-footer { padding: 14px 16px 18px; }

    .dlm-preview-ring {
        width: 160px;
        height: 160px;
    }

    .dlm-format-name { font-size: 17px; }
    .dlm-format-desc { font-size: 10px; }
}
