/* ============================================================
   APEX TECHNICAL SOLUTIONS — LIVE PORTFOLIO SHOWCASE
   File: apex-portfolio.css
   Self-contained. Uses only the existing brand palette:
   #0056D6 (primary blue), #00A3FF (light blue), #333 (dark gray).
   Loads AFTER style.css. Every selector is scoped under
   #portfolio / .apx- prefixes so nothing else on the site is touched.
   ============================================================ */

/* ---------- Toolbar: search + filters ---------- */
#portfolio .apx-toolbar {
    max-width: 900px;
    margin: 0 auto 35px;
}

#portfolio .apx-search {
    position: relative;
    max-width: 520px;
    margin: 0 auto 25px;
}
#portfolio .apx-search i {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-blue, #0056D6);
    pointer-events: none;
}
#portfolio .apx-search input {
    width: 100%;
    padding: 14px 18px 14px 48px;
    font-size: 1.05em;
    font-family: 'Open Sans', sans-serif;
    color: var(--dark-gray, #333);
    background: #f4f4f4;
    border: 2px solid transparent;
    border-radius: 30px;
    outline: none;
    transition: border-color 0.3s ease, background 0.3s ease;
}
#portfolio .apx-search input:focus {
    border-color: var(--primary-blue, #0056D6);
    background: #fff;
}
#portfolio .apx-search input::placeholder {
    color: #888;
}

#portfolio .apx-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}
#portfolio .apx-filter-btn {
    padding: 10px 22px;
    font-size: 0.95em;
    font-weight: 600;
    font-family: 'Open Sans', sans-serif;
    color: var(--primary-blue, #0056D6);
    background: transparent;
    border: 2px solid var(--primary-blue, #0056D6);
    border-radius: 30px;
    cursor: pointer;
    transition: background 0.3s ease, color 0.3s ease, transform 0.3s ease;
}
#portfolio .apx-filter-btn:hover {
    transform: translateY(-2px);
}
#portfolio .apx-filter-btn.active,
#portfolio .apx-filter-btn:hover {
    background: var(--primary-blue, #0056D6);
    color: #fff;
}
#portfolio .apx-filter-btn:focus-visible {
    outline: 3px solid var(--light-blue, #00A3FF);
    outline-offset: 2px;
}

/* ---------- Grid ---------- */
#portfolio .apx-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 35px;
    margin-top: 10px;
}

#portfolio .apx-empty {
    text-align: center;
    color: var(--dark-gray, #333);
    font-size: 1.15em;
    padding: 60px 20px;
    display: none;
}
#portfolio .apx-empty i {
    display: block;
    font-size: 2.2em;
    color: var(--light-blue, #00A3FF);
    margin-bottom: 12px;
}

/* ---------- Card ---------- */
.apx-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}
.apx-card:hover,
.apx-card:focus-within {
    transform: translateY(-10px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}
.apx-card:focus-visible {
    outline: 3px solid var(--light-blue, #00A3FF);
    outline-offset: 3px;
}

/* Preview area — fixed 16:10 ratio so the grid never jumps while
   screenshots stream in. */
.apx-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    background: #f4f4f4;
    overflow: hidden;
}
.apx-thumb img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.5s ease;
}
.apx-thumb img.apx-loaded {
    opacity: 1;
}
.apx-card:hover .apx-thumb img.apx-loaded {
    transform: scale(1.04);
}

/* Spinner shown while the screenshot service renders */
.apx-thumb .apx-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--primary-blue, #0056D6);
    font-size: 0.85em;
    font-weight: 600;
}
.apx-thumb .apx-spinner i {
    font-size: 1.8em;
    animation: apx-spin 1.2s linear infinite;
}
@keyframes apx-spin {
    to { transform: rotate(360deg); }
}

/* Branded fallback when no preview can be generated */
.apx-thumb .apx-fallback {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary-blue, #0056D6), var(--light-blue, #00A3FF));
    color: #fff;
}
.apx-thumb .apx-fallback img.apx-fallback-logo {
    position: static;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    opacity: 1;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}
.apx-thumb .apx-fallback .apx-fb-title {
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    font-size: 1.15em;
}
.apx-thumb .apx-fallback .apx-fb-domain {
    font-size: 0.85em;
    opacity: 0.9;
}
.apx-thumb.apx-thumb-failed .apx-fallback { display: flex; }
.apx-thumb.apx-thumb-failed .apx-spinner,
.apx-thumb.apx-thumb-failed > img.apx-shot { display: none; }
.apx-thumb.apx-thumb-done .apx-spinner { display: none; }

/* Hover hint over preview */
.apx-thumb .apx-view-hint {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(0, 86, 214, 0.65);
    color: #fff;
    font-weight: 700;
    font-family: 'Roboto', sans-serif;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
}
.apx-card:hover .apx-view-hint,
.apx-card:focus-visible .apx-view-hint {
    opacity: 1;
}

/* Card body */
.apx-body {
    padding: 22px 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}
.apx-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.apx-cat {
    font-size: 0.78em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--light-blue, #00A3FF);
}
.apx-domain {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75em;
    font-weight: 600;
    color: var(--dark-gray, #333);
    background: #f4f4f4;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 4px 12px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.apx-domain i {
    color: var(--primary-blue, #0056D6);
    font-size: 0.9em;
}
.apx-body h3 {
    /* Override style.css global h3 centering/size inside cards */
    text-align: left;
    font-size: 1.25em;
    margin: 0;
    color: var(--primary-blue, #0056D6);
}
.apx-body h3::after {
    display: none;
}
.apx-body p {
    color: var(--dark-gray, #333);
    font-size: 0.95em;
    line-height: 1.55;
    margin: 0;
    flex: 1;
}
.apx-actions {
    display: flex;
    gap: 10px;
    margin-top: 6px;
    flex-wrap: wrap;
}
.apx-visit-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border-radius: 30px;
    background: var(--primary-blue, #0056D6);
    color: #fff;
    font-weight: 700;
    font-size: 0.9em;
    text-decoration: none;
    border: 2px solid var(--primary-blue, #0056D6);
    transition: background 0.3s ease, transform 0.3s ease;
}
.apx-visit-btn:hover {
    background: var(--light-blue, #00A3FF);
    border-color: var(--light-blue, #00A3FF);
    transform: translateY(-2px);
}
.apx-details-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border-radius: 30px;
    background: transparent;
    color: var(--primary-blue, #0056D6);
    font-weight: 700;
    font-size: 0.9em;
    border: 2px solid var(--primary-blue, #0056D6);
    cursor: pointer;
    transition: background 0.3s ease, color 0.3s ease;
}
.apx-details-btn:hover {
    background: var(--primary-blue, #0056D6);
    color: #fff;
}

/* ---------- Modal ---------- */
.apx-modal {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.75);
}
.apx-modal.open {
    display: flex;
    animation: apx-fade 0.25s ease;
}
@keyframes apx-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}
.apx-modal-box {
    background: #fff;
    border-radius: 20px;
    max-width: 860px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: apx-rise 0.3s ease;
}
@keyframes apx-rise {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.apx-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: rgba(51, 51, 51, 0.75);
    color: #fff;
    font-size: 1.2em;
    cursor: pointer;
    z-index: 2;
    transition: background 0.3s ease, transform 0.3s ease;
}
.apx-modal-close:hover {
    background: var(--primary-blue, #0056D6);
    transform: rotate(90deg);
}
.apx-modal-preview {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #f4f4f4;
    border-radius: 20px 20px 0 0;
    overflow: hidden;
}
.apx-modal-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
}
.apx-modal-preview .apx-fallback {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, var(--primary-blue, #0056D6), var(--light-blue, #00A3FF));
    color: #fff;
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    font-size: 1.3em;
}
.apx-modal-preview.apx-thumb-failed .apx-fallback { display: flex; }
.apx-modal-preview.apx-thumb-failed img { display: none; }
.apx-modal-body {
    padding: 30px 34px 34px;
}
.apx-modal-body .apx-meta {
    margin-bottom: 12px;
}
.apx-modal-body h3 {
    text-align: left;
    font-size: 1.7em;
    margin: 0 0 14px;
    color: var(--primary-blue, #0056D6);
}
.apx-modal-body h3::after { display: none; }
.apx-modal-body p {
    color: var(--dark-gray, #333);
    line-height: 1.7;
    margin: 0 0 20px;
}
.apx-tech-title {
    font-size: 0.8em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--dark-gray, #333);
    margin-bottom: 10px;
}
.apx-tech-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    padding: 0;
    margin: 0 0 24px;
}
.apx-tech-list li {
    padding: 6px 14px;
    border-radius: 20px;
    background: #f4f4f4;
    border: 1px solid #e5e7eb;
    color: var(--dark-gray, #333);
    font-size: 0.82em;
    font-weight: 600;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .apx-card,
    .apx-thumb img,
    .apx-filter-btn,
    .apx-visit-btn,
    .apx-modal.open,
    .apx-modal-box {
        transition: none;
        animation: none;
    }
    .apx-thumb .apx-spinner i {
        animation: none;
    }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    #portfolio .apx-grid {
        grid-template-columns: 1fr;
        gap: 25px;
    }
    .apx-modal-body {
        padding: 24px 20px 26px;
    }
}
@media (max-width: 480px) {
    #portfolio .apx-filter-btn {
        padding: 8px 16px;
        font-size: 0.85em;
    }
    .apx-actions {
        flex-direction: column;
    }
    .apx-visit-btn,
    .apx-details-btn {
        justify-content: center;
        width: 100%;
    }
}
