/* ============================================
   Student Project Showcase
   Page-scoped styles (sp- prefix). Reuses the
   design tokens from styles.css.
   ============================================ */

.sp-hidden {
    display: none !important;
}

.sp-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- buttons ---------- */
.sp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 14px 26px;
    border-radius: var(--radius-full);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    transition: transform var(--transition-fast), box-shadow var(--transition-normal),
        background var(--transition-normal), color var(--transition-normal), border-color var(--transition-normal);
}

.sp-btn-primary {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: var(--shadow-primary);
}

.sp-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 34px -12px rgba(255, 75, 75, 0.55);
    color: #fff;
}

/* ---------- hero ---------- */
.sp-hero {
    position: relative;
    overflow: hidden;
    padding: 150px 0 84px;
    background: linear-gradient(135deg, #ffffff 0%, #f0f4ff 55%, #fff5f5 100%);
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.sp-hero-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    pointer-events: none;
}

.sp-glow-one {
    width: 520px;
    height: 520px;
    top: -240px;
    right: -120px;
    background: radial-gradient(circle, rgba(255, 75, 75, 0.42), transparent 70%);
}

.sp-glow-two {
    width: 460px;
    height: 460px;
    bottom: -240px;
    left: -140px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.28), transparent 70%);
}

.sp-hero-inner {
    position: relative;
    z-index: 2;
    max-width: 900px;
    text-align: center;
}

.sp-hero-title {
    font-size: clamp(2.1rem, 5.2vw, 3.5rem);
    font-weight: 800;
    line-height: 1.08;
    letter-spacing: -0.03em;
    color: var(--text-dark);
    margin: 18px 0 20px;
}

.sp-hero-title .highlight {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.sp-hero-sub {
    font-size: 1.08rem;
    color: var(--text-medium);
    line-height: 1.7;
    max-width: 68ch;
    margin: 0 auto;
}

.sp-hero-sub strong {
    color: var(--text-dark);
}

.sp-hero-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin: 40px auto 0;
    max-width: 520px;
}

.sp-stat {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(15, 23, 42, 0.07);
    border-radius: var(--radius-lg);
    padding: 20px 18px;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(8px);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.sp-stat:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.sp-stat-num {
    display: block;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 800;
    color: var(--primary);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.sp-stat-label {
    display: block;
    margin-top: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-light);
}

.sp-hero-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px;
    margin-top: 36px;
}

/* ---------- section + toolbar ---------- */
.sp-section {
    padding: 76px 0 96px;
    background: var(--bg-white);
}

.sp-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 22px;
    margin-bottom: 40px;
}

.sp-toolbar-text h2 {
    font-size: clamp(1.6rem, 3vw, 2.1rem);
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 6px;
}

.sp-count {
    color: var(--text-light);
    font-size: 0.98rem;
    margin: 0;
}

.sp-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.sp-search {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-light);
    border: 1px solid rgba(15, 23, 42, 0.09);
    border-radius: var(--radius-full);
    padding: 12px 18px;
    min-width: 280px;
    color: var(--text-light);
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.sp-search:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(255, 75, 75, 0.12);
    background: #fff;
}

.sp-search input {
    border: none;
    outline: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.98rem;
    color: var(--text-dark);
    width: 100%;
}

.sp-select select {
    appearance: none;
    -webkit-appearance: none;
    font-family: inherit;
    font-size: 0.98rem;
    font-weight: 500;
    color: var(--text-dark);
    background: var(--bg-light) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 16px center;
    border: 1px solid rgba(15, 23, 42, 0.09);
    border-radius: var(--radius-full);
    padding: 13px 44px 13px 20px;
    cursor: pointer;
    transition: border-color var(--transition-normal);
}

.sp-select select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ---------- grid + cards ---------- */
.sp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 28px;
}

.sp-grid:empty {
    display: none;
}

.sp-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #eef2f7;
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal),
        border-color var(--transition-normal);
}

.sp-card:hover,
.sp-card:focus-within {
    transform: translateY(-6px);
    box-shadow: var(--shadow-xl);
    border-color: #ffd9d9;
}

.sp-thumb {
    position: relative;
    aspect-ratio: 16 / 10;
    background: var(--bg-blue-tint);
    overflow: hidden;
}

.sp-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.sp-card:hover .sp-thumb img {
    transform: scale(1.05);
}

.sp-thumb-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #fff0f0, #f0f4ff);
    font-size: 2.4rem;
}

.sp-chip {
    position: absolute;
    top: 14px;
    left: 14px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #fff;
    background: rgba(15, 23, 42, 0.72);
    border-radius: var(--radius-full);
    padding: 6px 12px;
    backdrop-filter: blur(6px);
}

.sp-chip-gallery {
    left: auto;
    right: 14px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text-dark);
}

.sp-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 24px 24px 26px;
    flex: 1;
}

.sp-title {
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.32;
    color: var(--text-dark);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sp-desc {
    color: var(--text-medium);
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sp-builder {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid #f1f5f9;
}

.sp-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid #fff;
    box-shadow: var(--shadow-sm);
    background: var(--bg-blue-tint);
}

.sp-avatar-fallback {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
    background: var(--primary-gradient);
}

.sp-builder-text {
    min-width: 0;
}

.sp-builder-name {
    display: block;
    font-weight: 600;
    font-size: 0.96rem;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sp-builder-ref {
    display: block;
    font-size: 0.8rem;
    color: var(--text-light);
}

.sp-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.sp-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--text-light);
}

.sp-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.sp-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sp-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
    background: rgba(255, 75, 75, 0.08);
    border: none;
    border-radius: var(--radius-full);
    padding: 10px 16px;
    cursor: pointer;
    transition: background var(--transition-normal), transform var(--transition-fast);
}

.sp-link-btn:hover {
    background: rgba(255, 75, 75, 0.16);
    transform: translateY(-1px);
}

.sp-link-btn-muted {
    color: var(--text-medium);
    background: var(--bg-light);
}

.sp-link-btn-muted:hover {
    background: #e9eef5;
    color: var(--text-dark);
}

/* ---------- skeleton ---------- */
.sp-skeleton {
    pointer-events: none;
}

.sp-skeleton-thumb {
    aspect-ratio: 16 / 10;
    background: linear-gradient(90deg, #f1f5f9 25%, #e7edf5 37%, #f1f5f9 63%);
    background-size: 400% 100%;
    animation: sp-shimmer 1.4s ease-in-out infinite;
}

.sp-skeleton-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sp-skeleton-body span {
    height: 14px;
    border-radius: 8px;
    background: linear-gradient(90deg, #f1f5f9 25%, #e7edf5 37%, #f1f5f9 63%);
    background-size: 400% 100%;
    animation: sp-shimmer 1.4s ease-in-out infinite;
}

.sp-skeleton-body span.short {
    width: 45%;
}

@keyframes sp-shimmer {
    0% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0 50%;
    }
}

/* ---------- empty / error state ---------- */
.sp-state {
    text-align: center;
    padding: 64px 24px;
    border: 1px dashed rgba(15, 23, 42, 0.14);
    border-radius: var(--radius-xl);
    background: var(--bg-light);
}

.sp-state-icon {
    font-size: 2.4rem;
    margin-bottom: 12px;
}

.sp-state h3 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.sp-state p {
    color: var(--text-medium);
    max-width: 52ch;
    margin: 0 auto 22px;
}

/* ---------- modal ---------- */
.sp-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.sp-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.62);
    backdrop-filter: blur(6px);
    animation: sp-fade 0.22s ease;
}

.sp-modal-card {
    position: relative;
    z-index: 1;
    width: min(920px, 100%);
    max-height: min(88vh, 900px);
    overflow-y: auto;
    background: #fff;
    border-radius: var(--radius-xl);
    box-shadow: 0 40px 80px -20px rgba(2, 6, 23, 0.5);
    animation: sp-rise 0.26s ease;
}

.sp-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 3;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.72);
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(6px);
    transition: background var(--transition-normal), transform var(--transition-fast);
}

.sp-modal-close:hover {
    background: var(--primary);
    transform: rotate(90deg);
}

.sp-modal-hero {
    position: relative;
    width: 100%;
    height: clamp(220px, 30vw, 380px);
    background: var(--bg-blue-tint);
    overflow: hidden;
}

.sp-modal-hero img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sp-modal-content {
    padding: 32px 34px 38px;
}

.sp-modal-content h2 {
    font-size: clamp(1.4rem, 3vw, 1.9rem);
    font-weight: 800;
    line-height: 1.2;
    color: var(--text-dark);
    margin-bottom: 14px;
}

.sp-modal-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid #f1f5f9;
}

.sp-modal-note {
    margin-top: 0;
    color: var(--text-medium);
    font-size: 1rem;
    line-height: 1.75;
    white-space: pre-line;
}

.sp-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
    margin-top: 24px;
}

.sp-gallery button {
    padding: 0;
    border: 1px solid #eef2f7;
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    background: none;
    aspect-ratio: 16 / 10;
    transition: border-color var(--transition-normal), transform var(--transition-fast);
}

.sp-gallery button:hover,
.sp-gallery button.is-active {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.sp-gallery img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sp-modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 28px;
}

@keyframes sp-fade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes sp-rise {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.98);
    }

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

body.sp-modal-open {
    overflow: hidden;
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
    .sp-hero {
        padding: 132px 0 68px;
    }

    .sp-hero-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .sp-stat {
        padding: 16px 12px;
    }

    .sp-stat-label {
        font-size: 0.72rem;
        letter-spacing: 0.05em;
    }

}

@media (max-width: 640px) {
    .sp-hero {
        padding: 120px 0 56px;
    }

    .sp-hero-stats {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }

    .sp-section {
        padding: 56px 0 72px;
    }

    .sp-toolbar {
        align-items: stretch;
    }

    .sp-controls,
    .sp-search,
    .sp-select select {
        width: 100%;
    }

    .sp-search {
        min-width: 0;
    }

    .sp-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .sp-modal {
        padding: 0;
        align-items: flex-end;
    }

    .sp-modal-card {
        max-height: 92vh;
        border-radius: 20px 20px 0 0;
    }

    .sp-modal-content {
        padding: 26px 20px 32px;
    }

    .sp-hero-actions .sp-btn {
        width: 100%;
    }
}
