/*
    Works page redesign — scoped to .main-workspage only.
    Concept: browsing a filesystem of real repos — a booting terminal,
    then a grid of "repo cards" keyed to each project's actual GitHub language.
*/
.main-workspage {
    --mono: 'JetBrains Mono', monospace;
    --panel: #16171b;
    --panel-border: rgba(255, 255, 255, 0.08);
}

/* Terminal hero */
.terminal-hero {
    padding-top: 70px;
}
.terminal-window {
    max-width: 620px;
    margin: 0 auto 40px auto;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.6);
}
.terminal-titlebar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--panel-border);
}
.terminal-titlebar .dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    display: block;
}
.terminal-titlebar .dot-red { background: #ff5f56; }
.terminal-titlebar .dot-yellow { background: #ffbd2e; }
.terminal-titlebar .dot-green { background: #27c93f; }
.terminal-title {
    margin-left: 6px;
    font-family: var(--mono);
    font-size: 12px;
    color: #74798a;
}
.terminal-body {
    padding: 20px 22px 26px 22px;
    font-family: var(--mono);
    font-size: 14px;
    line-height: 1.9;
}
.terminal-line .prompt {
    color: var(--primary_color);
    margin-right: 8px;
}
.terminal-line .typed {
    color: #f2f2f2;
}
.terminal-line .typed.is-typing::after {
    content: '\258C';
    margin-left: 2px;
    color: var(--primary_color);
    animation: term-blink 1s steps(2) infinite;
}
.terminal-output {
    color: #5fe0a5;
    opacity: 0;
    transform: translateY(2px);
    transition: opacity .3s ease, transform .3s ease;
}
.terminal-output.is-visible {
    opacity: 1;
    transform: translateY(0);
}
.terminal-output::before {
    content: '>';
    margin-right: 8px;
    color: #4a4f5c;
}
@keyframes term-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.terminal-hero .section-heading {
    font-size: 48px;
    margin-top: 0;
}

/* Segmented filter control */
.works-filter {
    position: relative;
    display: flex;
    width: fit-content;
    max-width: 100%;
    margin: 34px auto 50px;
    padding: 5px;
    border-radius: 999px;
    background: #f4f5f7;
    border: 1px solid rgba(16, 18, 27, 0.06);
    box-shadow:
        0 1px 2px rgba(16, 18, 27, 0.05),
        0 18px 44px -18px rgba(16, 18, 27, 0.4);
    isolation: isolate;
}
.works-filter__btn {
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
    border: 0;
    background: transparent;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
    color: #454a58;
    padding: 11px 28px;
    border-radius: 999px;
    white-space: nowrap;
    transition: color 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
}
.works-filter__btn:hover:not(.is-active) {
    color: #10121b;
}
.works-filter__btn:focus-visible {
    outline: 2px solid var(--primary_color);
    outline-offset: 3px;
}
.works-filter__btn.is-active {
    color: #fff;
}
.works-filter__indicator {
    position: absolute;
    top: 5px;
    left: 0;
    width: 0;
    height: calc(100% - 10px);
    border-radius: 999px;
    background: linear-gradient(135deg, #6f8bff 0%, #5b78f6 45%, #3b5bdb 100%);
    box-shadow:
        0 6px 16px -6px rgba(91, 120, 246, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
    transform: translateX(0);
    transition:
        transform 0.55s cubic-bezier(0.4, 0, 0.2, 1),
        width 0.55s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, width;
    z-index: 0;
}

/* Repo grid */
.repo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
}
.repo-card {
    position: relative;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    padding: 18px;
    transform: perspective(900px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) translateY(0);
    transition: transform .25s ease, border-color .3s ease, box-shadow .3s ease, opacity .5s cubic-bezier(.4, 0, .2, 1);
}
.repo-card:hover {
    border-color: rgba(91, 120, 246, 0.5);
    box-shadow: 0 24px 48px -24px rgba(91, 120, 246, 0.45);
    transform: perspective(900px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) translateY(-6px);
}
/* Filter transition — fade + slight slide/scale when switching filters */
.repo-card.is-fading {
    opacity: 0 !important;
    transform: perspective(900px) translateY(10px) scale(.96);
    pointer-events: none;
}
.repo-card.is-hidden {
    display: none !important;
}
.repo-card.is-entering {
    animation: repo-card-in .6s cubic-bezier(.22, .61, .36, 1) both;
    animation-delay: calc(var(--i, 0) * 45ms);
}
@keyframes repo-card-in {
    from {
        opacity: 0;
        transform: perspective(900px) translateY(16px) scale(.97);
    }
    to {
        opacity: 1;
        transform: perspective(900px) translateY(0) scale(1);
    }
}
.repo-card-link {
    position: absolute;
    inset: 0;
    z-index: 5;
    border-radius: inherit;
}
.repo-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    font-family: var(--mono);
    font-size: 12px;
    color: #8a8f98;
}
.lang-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--lang-color);
    box-shadow: 0 0 8px var(--lang-color);
}
.repo-path {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: -.2px;
}
.repo-card-arrow {
    font-size: 16px;
    color: #5f6570;
    transition: transform .3s ease, color .3s ease;
}
.repo-card:hover .repo-card-arrow {
    color: #fff;
    transform: translate(3px, -3px);
}
.repo-card-media {
    position: relative;
    aspect-ratio: 16 / 10;
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 16px;
    background: #000;
}
.repo-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(85%) contrast(1.05);
    transition: filter .5s ease, transform .5s ease;
    display: block;
}
.repo-card-media::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 0%, rgba(91, 120, 246, .25) 50%, transparent 100%);
    transform: translateY(-100%);
    transition: transform .6s ease;
}
.repo-card:hover .repo-card-media::after {
    transform: translateY(100%);
}
.repo-card:hover .repo-card-media img {
    filter: grayscale(0%) contrast(1);
    transform: scale(1.04);
}
.repo-card-body h3 {
    font-size: 19px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 6px;
}
.repo-card-body p {
    font-size: 13px;
    line-height: 1.6;
    color: #9f9f9f;
    margin-bottom: 14px;
}
.repo-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.tag {
    font-family: var(--mono);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #c7cad1;
    border: 1px solid var(--panel-border);
    padding: 4px 10px;
    border-radius: 999px;
}

/* Logo-style media — show the full mark instead of a cropped photo */
.repo-card--logo .repo-card-media {
    background: #fff;
}
.repo-card--logo .repo-card-media img {
    object-fit: contain;
    padding: 14px;
}

@media (max-width: 920px) {
    .repo-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 767px) {
    .terminal-hero .section-heading {
        font-size: 34px;
    }
}
@media (max-width: 585px) {
    .repo-grid {
        grid-template-columns: 1fr;
    }
    .terminal-body {
        font-size: 12.5px;
        padding: 16px;
    }
}

/* Mobile: clean full-width segmented control, no text overflow */
@media (max-width: 560px) {
    .works-filter {
        width: 100%;
        margin: 26px 0 38px;
    }
    .works-filter__btn {
        flex: 1 1 0;
        min-width: 0;
        padding: 11px 6px;
        font-size: 12px;
        letter-spacing: 0;
        text-align: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .repo-card,
    .repo-card-media img,
    .repo-card-media::after,
    .repo-card-arrow,
    .works-filter__btn,
    .works-filter__indicator,
    .terminal-line .typed.is-typing::after {
        transition: none !important;
        animation: none !important;
    }
}
