body {
    margin: 0;
    background: #0f172a;
    color: white;
}

h1, h2, h3 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
}

body, p {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
}

header {
    padding: 30px;
    text-align: center;
}

footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    padding: 12px 32px;
    border-top: 1px solid #1e293b;
    background: #0f172a;
    color: #64748b;
    font-size: 14px;
    z-index: 10;
}

footer a {
    color: #64748b;
    text-decoration: none;
}

footer a:hover {
    color: white;
}

h1 {
    margin: 0;
    font-size: 40px;
}

/* Controls bar */

#controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 40px 20px;
    flex-wrap: wrap;
}

.search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 8px 14px;
    flex: 1;
    min-width: 200px;
    max-width: 360px;
    transition: border-color 0.2s;
}

.search-wrap:focus-within {
    border-color: #2563eb;
}

.search-wrap svg {
    color: #64748b;
    flex-shrink: 0;
}

.search-wrap input {
    background: none;
    border: none;
    outline: none;
    color: white;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    width: 100%;
}

.search-wrap input::placeholder {
    color: #64748b;
}

.sort-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.sort-wrap label {
    font-size: 13px;
    color: #94a3b8;
    white-space: nowrap;
}

.sort-wrap select {
    background: #1e293b;
    border: 1px solid #334155;
    color: white;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.sort-wrap select:focus {
    border-color: #2563eb;
}

/* Projects grid */

#projects {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    padding: 0 40px 80px;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    color: #64748b;
    padding: 60px 0;
    font-size: 16px;
}

/* Cards */

.card {
    background: #1e293b;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0;
    transform: translateY(12px);
    transition: transform 0.25s, box-shadow 0.25s, opacity 0.3s ease, border-color 0.2s;
    border: 1px solid transparent;
}

.card-visible {
    opacity: 1;
    transform: translateY(0);
}

.card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
    border-color: #334155;
}

.card img {
    width: 100%;
    height: 160px;
    object-fit: cover;
}

.card-body {
    padding: 15px;
}

.card-title {
    font-size: 20px;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    margin-bottom: 8px;
}

.card-footer {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 10px;
    text-align: right;
}

/* Tags */

#tags {
    display: flex;
    gap: 0;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    padding: 0 40px 20px;
}

.project-count {
    font-size: 12px;
    color: #64748b;
    margin-right: 12px;
    font-family: 'DM Sans', sans-serif;
}

.tags {
    margin-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tag {
    background: #334155;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 12px;
    margin-right: 5px;
    margin-bottom: 5px;
    transition: background 0.15s;
}

.tag:not(.selected) {
    cursor: pointer;
}

.tag:not(.selected):hover {
    background: #3f5068;
}

.selected {
    background: #2563eb;
}

/* Modal */

#modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    padding: 20px;
    box-sizing: border-box;
}

#modal.modal-open {
    opacity: 1;
}

#modal-content {
    width: 100%;
    max-width: 900px;
    background: #1e293b;
    border-radius: 14px;
    padding: 24px;
    border: 1px solid #334155;
    transform: translateY(16px);
    transition: transform 0.2s ease;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#modal.modal-open #modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 22px;
}

.modal-body {
    display: flex;
    gap: 24px;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}

.modal-body img {
    width: 380px;
    height: 220px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    align-self: flex-start;
}

.modal-right {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#modal-desc {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
    line-height: 1.7;
    color: #cbd5e1;
    font-size: 14px;
}

/* Custom scrollbar for readme */
#modal-desc::-webkit-scrollbar {
    width: 5px;
}

#modal-desc::-webkit-scrollbar-track {
    background: #0f172a;
    border-radius: 4px;
}

#modal-desc::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

#modal-desc::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

#modal-desc h1, #modal-desc h2, #modal-desc h3 {
    color: white;
    margin-top: 0;
}

#modal-desc p:first-child {
    margin-top: 0;
}

#modal-desc code {
    background: #0f172a;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

#modal-desc pre {
    background: #0f172a;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
}

.modal-launch {
    display: block;
    margin-top: 16px;
    flex-shrink: 0;
    text-decoration: none;
}

.modal-launch button {
    width: 100%;
    padding: 10px;
}

button {
    padding: 8px 16px;
    background: #2563eb;
    border: none;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s;
}

button:hover {
    background: #1d4ed8;
}

.close-btn {
    background: #334155;
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 16px;
    flex-shrink: 0;
}

.close-btn:hover {
    background: #475569;
}



/* ── Responsive ─────────────────────────────────────────────────────────── */

/* Tablet: 2-column grid */
@media (max-width: 900px) {
    #projects {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
        padding: 0 20px 32px;
    }

    #controls {
        padding: 0 20px 16px;
    }

    #tags {
        padding: 0 20px 16px;
    }

    .search-wrap {
        max-width: none;
    }
}

/* Mobile: full single-column layout */
@media (max-width: 600px) {
    header {
        padding: 20px 16px 16px;
    }

    h1 {
        font-size: 28px;
    }

    header p {
        font-size: 14px;
        margin: 6px 0 0;
    }

    #controls {
        padding: 0 12px 12px;
        gap: 8px;
    }

    .search-wrap {
        min-width: 0;
        max-width: none;
        flex: 1 1 100%;
    }

    .sort-wrap {
        margin-left: 0;
        flex: 1 1 100%;
        justify-content: space-between;
    }

    .sort-wrap select {
        flex: 1;
    }

    #tags {
        padding: 0 12px 12px;
        justify-content: flex-start;
        gap: 6px;
        flex-wrap: wrap;
    }

    .tag {
        padding: 6px 12px;
        font-size: 13px;
        border-radius: 20px;
        margin: 0;
        white-space: nowrap;
    }

    .project-count {
        width: 100%;
        margin-right: 0;
        margin-bottom: 4px;
    }

    #projects {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 0 12px 32px;
    }

    .card:hover {
        transform: none;
        box-shadow: none;
        border-color: transparent;
    }

    .card:active {
        transform: scale(0.98);
        opacity: 0.85;
    }

    .card img {
        height: 180px;
    }

    .card-body {
        padding: 12px;
    }

    .card-title {
        font-size: 17px;
    }

    /* Modal: bottom sheet on mobile */
    #modal {
        align-items: flex-end;
        padding: 0;
    }

    #modal-content {
        border-radius: 18px 18px 0 0;
        padding: 16px;
        padding-bottom: 60px;
        max-height: 92vh;
        transform: translateY(100%);
        overflow-y: auto;
    }

    #modal.modal-open #modal-content {
        transform: translateY(0);
    }

    #modal-content::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: #475569;
        border-radius: 2px;
        margin: 0 auto 16px;
    }

    .modal-header {
        margin-bottom: 12px;
    }

    .modal-header h2 {
        font-size: 18px;
    }

    .modal-body {
        flex-direction: column;
        gap: 14px;
        overflow: visible;
    }

    .modal-body img {
        width: 100%;
        height: 180px;
        align-self: stretch;
    }

    .modal-right {
        overflow: visible;
        min-height: unset;
    }

    #modal-desc {
        overflow-y: auto;
        max-height: 40vh;
        padding-right: 4px;
    }

    .modal-launch {
        margin-top: 12px;
        margin-bottom: 8px;
    }

    .modal-launch button {
        padding: 14px;
        font-size: 16px;
        border-radius: 10px;
    }

    .close-btn {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
}