/* ═══════════════════════════════════════════════
   COMMUNITY GALLERY — Card grid + filters
   ═══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg-page: hsl(40, 30%, 97%);
    --bg-white: hsl(0, 0%, 100%);
    --bg-warm: hsl(35, 40%, 95%);
    --bg-soft: hsl(30, 20%, 93%);
    --bg-card: hsl(0, 0%, 100%);
    --border: hsl(30, 15%, 88%);
    --border-hover: hsl(30, 20%, 78%);
    --text-0: hsl(220, 20%, 16%);
    --text-1: hsl(220, 10%, 38%);
    --text-2: hsl(220, 8%, 55%);
    --text-3: hsl(220, 6%, 68%);
    --accent: hsl(245, 58%, 56%);
    --accent-light: hsl(245, 58%, 64%);
    --accent-bg: hsl(245, 60%, 96%);
    --accent-border: hsl(245, 50%, 88%);
    --coral: hsl(12, 80%, 62%);
    --coral-bg: hsl(12, 80%, 96%);
    --amber: hsl(38, 92%, 55%);
    --teal: hsl(170, 50%, 45%);
    --teal-bg: hsl(170, 50%, 95%);
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-pill: 100px;
    --transition: 200ms ease;
    --shadow-sm: 0 1px 3px hsla(220, 20%, 16%, 0.06);
    --shadow-md: 0 4px 16px hsla(220, 20%, 16%, 0.08);
    --shadow-lg: 0 8px 32px hsla(220, 20%, 16%, 0.1);
    --shadow-btn: 0 2px 8px hsla(245, 58%, 56%, 0.2);
}

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

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    scroll-behavior: smooth;
}

body {
    font-family: var(--sans);
    background: var(--bg-page);
    color: var(--text-0);
    min-height: 100vh;
    overflow-x: hidden;
}

.gallery-app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.gallery-app>#shared-footer {
    margin-top: auto;
}

/* ─── Intro ─── */

.gal-main {
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 40px 32px 60px;
}

.gal-intro {
    text-align: center;
    margin-bottom: 36px;
}

.section-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    margin-bottom: 8px;
}

.section-title {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 12px;
    color: var(--text-0);
}

.section-subtitle {
    font-size: 1rem;
    color: var(--text-2);
    max-width: 480px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ─── Filters ─── */

.gal-filters {
    margin-bottom: 28px;
}

.gal-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.filter-chip {
    padding: 7px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--bg-white);
    font-family: var(--sans);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-1);
    cursor: pointer;
    transition: all 200ms ease;
    white-space: nowrap;
}

.filter-chip:hover {
    background: var(--accent-bg);
    border-color: var(--accent-border);
    color: var(--accent);
}

.filter-chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    font-weight: 600;
}

.gal-filter-controls {
    display: flex;
    gap: 12px;
}

.gal-search-input {
    flex: 1;
    max-width: 360px;
    padding: 9px 14px;
    font-size: 0.82rem;
}

.gal-sort-select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-0);
    font-family: var(--sans);
    font-size: 0.82rem;
    padding: 9px 32px 9px 14px;
    cursor: pointer;
    transition: border-color var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239598a0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.gal-sort-select:focus {
    outline: none;
    border-color: var(--accent);
}

/* ─── Card Grid ─── */

.gal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.gal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 300ms ease;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.gal-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-hover);
}

.gal-card-header {
    padding: 20px 20px 0;
}

.gal-card-domain {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    margin-bottom: 10px;
}

.domain-api {
    background: var(--accent-bg);
    color: var(--accent);
}

.domain-webapp {
    background: var(--teal-bg);
    color: var(--teal);
}

.domain-cli {
    background: hsl(38, 80%, 95%);
    color: hsl(38, 70%, 40%);
}

.domain-game {
    background: var(--coral-bg);
    color: var(--coral);
}

.domain-mobile {
    background: hsl(280, 40%, 94%);
    color: hsl(280, 40%, 50%);
}

.domain-dashboard {
    background: hsl(200, 40%, 94%);
    color: hsl(200, 50%, 40%);
}

.domain-ai {
    background: hsl(260, 50%, 94%);
    color: hsl(260, 50%, 50%);
}

.domain-devtools {
    background: hsl(30, 30%, 94%);
    color: hsl(30, 30%, 40%);
}

.domain-other {
    background: var(--bg-soft);
    color: var(--text-2);
}

.gal-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-0);
    margin-bottom: 6px;
    line-height: 1.3;
}

.gal-card-desc {
    font-size: 0.78rem;
    color: var(--text-2);
    line-height: 1.5;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gal-card-preview {
    margin: 0 20px;
    padding: 12px 14px;
    background: hsl(225, 18%, 12%);
    border-radius: 8px;
    font-family: var(--mono);
    font-size: 0.68rem;
    line-height: 1.6;
    color: hsl(220, 8%, 60%);
    max-height: 120px;
    overflow: hidden;
    position: relative;
}

.gal-card-preview::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(transparent, hsl(225, 18%, 12%));
}

.gal-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    margin-top: auto;
    border-top: 1px solid var(--border);
}

.gal-card-author {
    font-size: 0.72rem;
    color: var(--text-3);
}

.gal-card-vote {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--bg-white);
    font-family: var(--sans);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-1);
    cursor: pointer;
    transition: all 200ms ease;
}

.gal-card-vote:hover {
    border-color: var(--coral);
    color: var(--coral);
    background: var(--coral-bg);
}

.gal-card-vote.voted {
    border-color: var(--coral);
    background: var(--coral-bg);
    color: var(--coral);
}

.gal-card-vote .vote-icon {
    transition: transform 200ms ease;
}

.gal-card-vote:hover .vote-icon {
    transform: scale(1.2);
}

/* ─── Empty / Load More ─── */

.gal-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-3);
}

.gal-empty .empty-icon {
    font-size: 2.4rem;
    margin-bottom: 12px;
}

.gal-empty p {
    font-size: 0.92rem;
    margin-bottom: 4px;
}

.gal-load-more {
    text-align: center;
    padding: 32px;
}

/* ─── Gallery Modal (scoped to avoid conflict with project modal) ─── */

#modal-overlay {
    position: fixed;
    inset: 0;
    background: hsla(220, 20%, 10%, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
    backdrop-filter: blur(4px);
    pointer-events: none;
}

#modal-overlay.active {
    display: flex;
    pointer-events: auto;
}

#modal-overlay .modal-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    max-width: 680px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 300ms ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

#modal-overlay .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 24px 24px 0;
}

#modal-overlay .modal-header h2 {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-0);
    line-height: 1.3;
    flex: 1;
    padding-right: 16px;
}

#modal-overlay .modal-close {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-white);
    font-size: 1.2rem;
    color: var(--text-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 200ms;
    flex-shrink: 0;
    position: static;
}

#modal-overlay .modal-close:hover {
    background: var(--bg-warm);
    color: var(--text-0);
}

#modal-overlay .modal-meta {
    padding: 12px 24px;
    font-size: 0.75rem;
    color: var(--text-2);
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

#modal-overlay .modal-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

#modal-overlay .modal-body {
    padding: 0 24px 24px;
}

#modal-overlay .modal-body .modal-section {
    margin-bottom: 16px;
}

#modal-overlay .modal-body .modal-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    margin-bottom: 8px;
}

#modal-overlay .modal-body .modal-code {
    background: hsl(225, 18%, 12%);
    border-radius: 8px;
    padding: 16px;
    font-family: var(--mono);
    font-size: 0.74rem;
    line-height: 1.7;
    color: hsl(220, 8%, 68%);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
}

#modal-overlay .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* ─── Buttons / Inputs (shared) ─── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 22px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-family: var(--sans);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: var(--shadow-btn);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-light);
    transform: translateY(-1px);
}

.btn-ghost {
    background: var(--bg-white);
    border-color: var(--border);
    color: var(--text-0);
}

.btn-ghost:hover:not(:disabled) {
    border-color: var(--border-hover);
    background: var(--bg-warm);
}

.input {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-0);
    font-family: var(--sans);
    font-size: 0.88rem;
    padding: 11px 14px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px hsla(245, 58%, 56%, 0.08);
}

.input::placeholder {
    color: var(--text-3);
}

/* ─── Toast ─── */

.toast {
    position: fixed;
    bottom: 32px;
    right: 24px;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-0);
    background: var(--bg-white);
    border: 1px solid var(--border);
    opacity: 0;
    transform: translateY(10px);
    transition: all 250ms ease;
    pointer-events: none;
    z-index: 300;
    box-shadow: var(--shadow-lg);
}

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

.toast.error {
    border-color: hsl(0, 60%, 85%);
    background: hsl(0, 50%, 95%);
    color: hsl(0, 50%, 35%);
}

/* ─── Animations ─── */

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─── Scrollbar ─── */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-soft);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-3);
}

/* ─── Responsive ─── */

@media (max-width: 800px) {
    .gal-main {
        padding: 24px 16px 40px;
    }

    .gal-grid {
        grid-template-columns: 1fr;
    }

    .gal-filter-controls {
        flex-direction: column;
    }

    .gal-search-input {
        max-width: 100%;
    }

    .section-title {
        font-size: 1.6rem;
    }

    .modal-card {
        max-height: 90vh;
    }
}