*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-1: #0b1020;
    --bg-2: #1b1f4a;
    --accent: #7c8cff;
    --accent-2: #4fd1c5;
    --success: #34d399;
    --text: #f2f4ff;
    --muted: rgba(242, 244, 255, 0.6);
    --glass: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.18);
}

html,
body {
    height: 100%;
}

body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    font-family: "Poppins", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 15% 20%, rgba(124, 140, 255, 0.45), transparent 40%),
        radial-gradient(circle at 85% 80%, rgba(79, 209, 197, 0.35), transparent 40%),
        linear-gradient(135deg, var(--bg-1), var(--bg-2));
    overflow: hidden;
}

/* ---------- Card ---------- */

.card {
    position: relative;
    width: 100%;
    max-width: 380px;
    padding: 24px;
    border-radius: 24px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
    isolation: isolate;
}

/* glowing gradient border */
.card__border {
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: conic-gradient(
        from var(--angle, 0deg),
        transparent 0%,
        var(--accent) 15%,
        transparent 30%,
        var(--accent-2) 60%,
        transparent 80%
    );
    -webkit-mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask:
        linear-gradient(#000 0 0) content-box exclude,
        linear-gradient(#000 0 0);
    opacity: 0.7;
    pointer-events: none;
    animation: spin-border 6s linear infinite;
    z-index: -1;
}

@property --angle {
    syntax: "<angle>";
    initial-value: 0deg;
    inherits: false;
}

@keyframes spin-border {
    to {
        --angle: 360deg;
    }
}

/* ---------- Close button ---------- */

.close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.25s, color 0.25s, transform 0.25s;
}

.close:hover {
    background: rgba(255, 255, 255, 0.18);
    color: var(--text);
    transform: rotate(90deg);
}

.close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---------- Top: folder + text ---------- */

.top {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 24px;
    padding-right: 30px;
}

.folder {
    position: relative;
    flex: none;
    width: 72px;
    height: 58px;
    filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.35));
}

.folder-back {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    color: #5a67e8;
}

.folder-front {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 82%;
    color: var(--accent);
    transform-origin: bottom;
    transition: transform 0.4s ease;
}

.card:hover .folder-front {
    transform: perspective(200px) rotateX(-18deg);
}

.label {
    position: absolute;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    padding: 1px 8px;
    border-radius: 6px;
    background: rgba(11, 16, 32, 0.35);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 1px;
    color: #fff;
}

.content h2 {
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
}

.content span {
    display: inline-block;
    margin-top: 4px;
    font-size: 13px;
    font-weight: 400;
    color: var(--muted);
}

/* ---------- Upload box ---------- */

.upload-box {
    padding: 16px 18px 18px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.upload-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status p {
    font-size: 14px;
    font-weight: 500;
}

#percent {
    font-size: 26px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.5px;
}

/* ---------- Loader ---------- */

.loader {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent-2);
    animation: spin 0.9s linear infinite;
    display: grid;
    place-items: center;
}

.loader.done {
    border-color: var(--success);
    background: var(--success);
    color: #06281c;
    font-size: 11px;
    animation: pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

@keyframes pop {
    0% {
        transform: scale(0.4);
    }
    100% {
        transform: scale(1);
    }
}

/* ---------- Progress ---------- */

.progress {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

.bar {
    position: relative;
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    box-shadow: 0 0 14px rgba(124, 140, 255, 0.6);
    overflow: hidden;
}

/* moving shine */
.bar::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.55),
        transparent
    );
    transform: translateX(-100%);
    animation: shine 1.4s linear infinite;
}

@keyframes shine {
    to {
        transform: translateX(100%);
    }
}

/* ---------- Mobile / a11y ---------- */

@media (max-width: 420px) {
    .card {
        padding: 20px;
    }

    .content h2 {
        font-size: 15px;
    }

    #percent {
        font-size: 22px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .card__border,
    .bar::after {
        animation: none;
    }
}

/* ---------- Download button ---------- */

.download {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 48px;
    margin-top: 16px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 8px 22px rgba(124, 140, 255, 0.35);
    transition:
        transform 0.2s,
        box-shadow 0.25s,
        opacity 0.3s,
        background 0.4s;
}

.download:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(124, 140, 255, 0.5);
}

.download:active:not(:disabled) {
    transform: scale(0.97);
}

.download:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

.download:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

/* заполнение внутри кнопки */
.download::before {
    content: "";
    position: absolute;
    inset: 0;
    width: 0;
    background: rgba(255, 255, 255, 0.28);
    pointer-events: none;
}

.download__icon,
.download__text {
    position: relative;
    z-index: 1;
}

.download__icon {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    overflow: hidden;
    font-size: 15px;
}

/* --- загрузка --- */

.download.loading {
    pointer-events: none;
}

.download.loading::before {
    width: calc(var(--p, 0) * 1%);
    transition: width 0.15s linear;
}

.download.loading .download__icon i {
    animation: arrow-drop 0.8s ease-in infinite;
}

@keyframes arrow-drop {
    0% {
        transform: translateY(-140%);
        opacity: 0;
    }
    40% {
        opacity: 1;
    }
    100% {
        transform: translateY(140%);
        opacity: 0;
    }
}

/* --- готово --- */

.download.done {
    pointer-events: none;
    background: linear-gradient(90deg, #22c55e, var(--success));
    box-shadow: 0 8px 22px rgba(52, 211, 153, 0.45);
}

.download.done .download__icon i {
    animation: pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (prefers-reduced-motion: reduce) {
    .download.loading .download__icon i {
        animation: none;
    }
}

/* ---------- Ошибка ---------- */

.progress.error .bar {
    background: linear-gradient(90deg, #ef4444, #f97316);
    box-shadow: 0 0 14px rgba(239, 68, 68, 0.6);
}

.loader.error {
    border-color: #ef4444;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    animation: pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
