/* ==========================================
   iCargo Alliance — Download section
   Standalone styles (no navbar / no footer)
   ========================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "neue-haas-unica", sans-serif;
}

:root {
    --dl-primary: #EE4036;
    --dl-primary-dark: #D6352B;
    --dl-white: #FFFFFF;
    --dl-dark: #1A1A1A;
    --dl-card-bg: rgba(255, 255, 255, 0.17);
    --dl-card-border: rgba(255, 255, 255, 0.46);
    --dl-muted: rgba(255, 255, 255, 0.82);
    --dl-btn-light: rgba(255, 241, 241, 1);
    --dl-transition: 0.25s ease;
}

body {
    background-color: #0B0D10;
    color: var(--dl-white);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Page shell ---------- */
.download-page {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 40px 6vw 80px;
    background-image: url('assets/background.png');
    background-size: cover;
    background-position: center;
}

.download-page::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background: linear-gradient(90deg,
        rgba(0, 0, 0, 0.72) 0%,
        rgba(0, 0, 0, 0.40) 55%,
        rgba(0, 0, 0, 0.15) 100%);
}

.download-back,
.download-content,
.download-cards {
    position: relative;
    z-index: 1;
}

/* ---------- Back link ---------- */
.download-back {
    position: relative;
    align-self: flex-start;
    color: var(--dl-white);
    text-decoration: none;
    font-size: 13px;
    opacity: 0.85;
    transition: opacity var(--dl-transition);
}

.download-back::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -3px;
    width: 0;
    height: 1px;
    background: var(--dl-primary);
    transition: width 0.3s ease;
}

.download-back:hover {
    opacity: 1;
}

.download-back:hover::after {
    width: 100%;
}

/* ---------- Content block ---------- */
.download-content {
    width: 100%;
    margin: clamp(40px, 12vh, 140px) 0 0;
}

.download-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 400;
    line-height: 1;
    letter-spacing: 0;
    margin-bottom: 14px;
}

.download-badge img {
    width: 17px;
    height: 19px;
}

.download-title {
    font-size: clamp(40px, 5vw, 68px);
    font-weight: 400;
    line-height: 1.05;
    letter-spacing: -0.02em;
}

.download-subtitle {
    margin-top: 12px;
    font-size: 16px;
    color: var(--dl-muted);
}

/* ---------- Login form ---------- */
.download-login-form {
    margin-top: 40px;
    width: 100%;
    max-width: 292px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.download-input {
    height: 48px;
    border: none;
    border-radius: 6px;
    padding: 0 16px;
    font-size: 14px;
    background: var(--dl-white);
    color: var(--dl-dark);
}

.download-input::placeholder {
    color: #8A8A8A;
}

.download-input:focus {
    outline: 2px solid var(--dl-primary);
    outline-offset: 1px;
}

.download-btn {
    cursor: pointer;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 700;
    transition: background var(--dl-transition);
}

.download-btn--primary {
    height: 48px;
    background: var(--dl-primary);
    color: var(--dl-white);
    transition: background var(--dl-transition), transform 0.25s ease,
        box-shadow 0.25s ease;
}

.download-btn--primary:hover,
.download-btn--primary:focus-visible {
    background: #F25C53;
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(238, 64, 54, 0.4);
}

.download-error {
    color: #FFB4AE;
    font-size: 13px;
}

/* ---------- Cards grid ---------- */
.download-cards {
    max-width: 1300px;
    margin: clamp(36px, 7vh, 72px) auto 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 36px;
}

.download-card {
    container-type: inline-size;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 28px 22px 26px;
    border-radius: 12px;
    background: var(--dl-card-bg);
    border: 1px solid var(--dl-card-border);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: transform 0.3s ease, border-color 0.3s ease,
        background-color 0.3s ease, box-shadow 0.3s ease;
}

.download-card:hover {
    transform: translateY(-6px);
    border-color: rgba(255, 255, 255, 0.85);
    background-color: rgba(255, 255, 255, 0.22);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

.download-card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.download-card-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 10px;
    background: var(--dl-primary);
    display: grid;
    place-items: center;
    transition: transform 0.3s ease;
}

.download-card:hover .download-card-icon {
    transform: scale(1.08) rotate(-6deg);
}

.download-card-icon img {
    width: 18px;
}

.download-card-title {
    font-size: 20px;
    font-weight: 500;
    font-style: normal;
    line-height: 1;
    letter-spacing: 0;
    white-space: nowrap;
}

/* Keep the card title on a single line by shrinking it as the card narrows */
@container (max-width: 277px) {
    .download-card-title {
        font-size: 18px;
    }
}

@container (max-width: 258px) {
    .download-card-title {
        font-size: 16px;
    }
}

@container (max-width: 240px) {
    .download-card-title {
        font-size: 14px;
    }
}

@container (max-width: 221px) {
    .download-card-title {
        font-size: 12px;
    }
}

@container (max-width: 203px) {
    .download-card-title {
        font-size: 10px;
    }
}

.download-card-text {
    font-size: 14px;
    font-weight: 350;
    line-height: 16px;
    letter-spacing: 0;
    text-align: center;
    color: var(--dl-muted);
    min-height: 42px;
}

.download-card-btn {
    position: relative;
    margin-top: 18px;
    height: 40px;
    padding: 0 22px;
    border: none;
    border-radius: 8px;
    background-color: var(--dl-btn-light);
    background-image: linear-gradient(var(--dl-primary), var(--dl-primary));
    background-repeat: no-repeat;
    background-position: left center;
    background-size: 0% 100%;
    color: var(--dl-dark);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-size 0.35s ease, color 0.2s ease,
        transform 0.25s ease, box-shadow 0.25s ease;
}

.download-card-btn:hover,
.download-card-btn:focus-visible {
    background-size: 100% 100%;
    color: var(--dl-white);
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(238, 64, 54, 0.35);
}

/* ---------- Versions modal ---------- */
.download-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    overflow: hidden;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.18s ease, visibility 0.18s ease;
}

.download-modal-overlay.active {
    visibility: visible;
    opacity: 1;
}

.download-modal {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: min(440px, 92vw);
    max-height: 85vh;
    padding: 26px 22px 22px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--dl-white);
    color: var(--dl-dark);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    opacity: 0;
    transform: scale(0.94) translateY(8px);
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.download-modal-overlay.active .download-modal {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.download-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: #8A8A8A;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: color var(--dl-transition), transform 0.3s ease;
}

.download-modal-close:hover {
    color: var(--dl-primary);
    transform: rotate(90deg);
}

.download-modal-eyebrow {
    font-size: 12px;
    color: #9A9A9A;
}

.download-modal-title {
    margin-top: 4px;
    padding-bottom: 14px;
    border-bottom: 1px solid #EAEAEA;
    font-size: 19px;
    font-weight: 600;
}

.download-modal-list {
    list-style: none;
    flex: 1 1 auto;
    min-height: 0;
    max-height: 55vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.download-modal-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 6px 12px 0;
    border-bottom: 1px solid #EFEFEF;
}

.download-modal-item:last-child {
    border-bottom: none;
}

.download-modal-item-icon {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--dl-primary);
    display: grid;
    place-items: center;
}

.download-modal-item-icon img {
    width: 15px;
}

.download-modal-item-name {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 14px;
}

.download-modal-view {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: var(--dl-primary);
    font-size: 12px;
    text-decoration: none;
    white-space: nowrap;
    transition: color var(--dl-transition);
}

.download-modal-view-arrow {
    display: inline-block;
    transition: transform 0.25s ease;
}

.download-modal-view:hover {
    color: var(--dl-primary-dark);
}

.download-modal-view:hover .download-modal-view-arrow {
    transform: translateX(3px);
}

/* ---------- Keyboard focus ---------- */
.download-back:focus-visible,
.download-btn:focus-visible,
.download-card-btn:focus-visible,
.download-modal-close:focus-visible,
.download-modal-view:focus-visible,
.download-input:focus-visible {
    outline: 2px solid var(--dl-white);
    outline-offset: 2px;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .download-card,
    .download-card-icon,
    .download-card-btn,
    .download-btn,
    .download-modal-view,
    .download-modal-view-arrow,
    .download-modal-close,
    .download-back,
    .download-back::after,
    .download-modal-overlay,
    .download-modal {
        transition: none;
    }

    .download-modal {
        transform: none;
    }

    .download-card:hover,
    .download-card:hover .download-card-icon,
    .download-card-btn:hover,
    .download-card-btn:focus-visible,
    .download-btn--primary:hover,
    .download-btn--primary:focus-visible,
    .download-modal-close:hover,
    .download-modal-view:hover .download-modal-view-arrow {
        transform: none;
    }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .download-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .download-page {
        padding: 24px 6vw 56px;
    }

    .download-content {
        margin-top: 40px;
    }

    .download-cards {
        grid-template-columns: 1fr;
    }

    .download-card-text {
        min-height: 0;
    }
}

/* ---------- Publisher controls ---------- */
.download-modal-item-delete {
    order: -1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border: none;
    border-radius: 8px;
    background: rgba(238, 64, 54, 0.12);
    color: var(--dl-primary);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.download-modal-item-delete:hover {
    background: var(--dl-primary);
    color: var(--dl-white);
}

.download-modal-upload-bar {
    display: flex;
    justify-content: flex-end;
    padding-bottom: 12px;
}

.download-upload-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 16px;
    border: none;
    border-radius: 8px;
    background: var(--dl-primary);
    color: var(--dl-white);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.download-upload-trigger:hover {
    background: var(--dl-primary-dark);
    transform: translateY(-1px);
}

.download-card-replace {
    margin-top: 10px;
    height: 34px;
    padding: 0 18px;
    border: 1px dashed var(--dl-card-border);
    border-radius: 8px;
    background: transparent;
    color: var(--dl-white);
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.download-card-replace:hover {
    border-color: var(--dl-white);
    background: rgba(255, 255, 255, 0.08);
}

/* ---------- Confirm / upload modals ---------- */
.download-modal--confirm,
.download-modal--upload {
    max-width: min(420px, 92vw);
}

.download-confirm-text {
    margin: 12px 0 22px;
    font-size: 14px;
    line-height: 1.5;
    color: #555;
}

.download-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.download-btn-cancel,
.download-btn-danger {
    height: 40px;
    padding: 0 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.download-btn-cancel {
    background: #EFEFEF;
    color: var(--dl-dark);
}

.download-btn-cancel:hover {
    background: #E2E2E2;
}

.download-btn-danger {
    background: var(--dl-primary);
    color: var(--dl-white);
}

.download-btn-danger:hover {
    background: var(--dl-primary-dark);
}

.download-upload-input {
    display: block;
    width: 100%;
    margin: 16px 0;
    font-size: 14px;
}

.download-upload-status {
    margin-bottom: 14px;
    font-size: 13px;
    color: #555;
}

/* Only publishers see the extra controls. */
.download-modal-item-delete,
.download-modal-upload-bar,
.download-card-replace {
    display: none;
}

body[data-role="publisher"] .download-modal-item-delete {
    display: inline-flex;
}

body[data-role="publisher"] .download-modal-upload-bar {
    display: flex;
}

body[data-role="publisher"] .download-card-replace {
    display: inline-block;
}
