:root {
    --primary: #6e45e2;
    --secondary: #88d3ce;
    --dark: #1a1a2e;
    --light: #f8f9fa;
    --card-border: rgba(255, 255, 255, 0.1);
    --container-pad: clamp(14px, 3vw, 24px);
    --section-space: clamp(20px, 4vw, 50px);
    --text-base: clamp(0.95rem, 0.25vw + 0.9rem, 1rem);
    --title-space: clamp(32px, 4vw, 56px);
    --page-bg: #1a1a2e;
    --page-text: #f8f9fa;
    --text-muted: rgba(248, 249, 250, 0.76);
    --surface: rgba(255, 255, 255, 0.04);
    --surface-2: rgba(255, 255, 255, 0.08);
    --border-soft: rgba(255, 255, 255, 0.12);
    --theme-toggle-bg: rgba(255, 255, 255, 0.06);
    --theme-toggle-border: rgba(255, 255, 255, 0.16);
}

html[data-theme='light'] {
    color-scheme: light;
    --page-bg: #f6f8fc;
    --page-text: #0f172a;
    --text-muted: rgba(15, 23, 42, 0.72);
    --surface: #ffffff;
    --surface-2: rgba(15, 23, 42, 0.04);
    --border-soft: rgba(15, 23, 42, 0.12);
    --theme-toggle-bg: rgba(15, 23, 42, 0.05);
    --theme-toggle-border: rgba(15, 23, 42, 0.14);
}

#home, #about, #skills, #tools, #projects, #assignments, #contact {
    scroll-margin-top: 72px;
}

html {
    scroll-behavior: smooth;
}

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

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--page-bg);
    color: var(--page-text);
    font-size: var(--text-base);
    line-height: 1.6;
}

/* ── Plexus Background ── */
#plexus-bg {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    pointer-events: none;
    display: block;
    filter: saturate(1.08) contrast(1.04);
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(85% 60% at 50% 15%, rgba(10, 20, 45, 0.20), transparent 72%),
        linear-gradient(180deg, rgba(4, 8, 20, 0.22), rgba(4, 8, 20, 0.42));
}

@media (prefers-reduced-motion: reduce) {
    #plexus-bg {
        opacity: 0.65;
    }
}

html[data-theme='light'] #plexus-bg,
html[data-theme='light'] body::before {
    display: none;
}

.assignments-section {
    padding: var(--section-space) 0;
    position: relative;
}

.assignments-section .container {
    display: block;
}

.assign-wrapper {
    width: 90%;
    margin: 0 auto;
    max-width: 80rem;
}

.assign-cols {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2rem;
    padding: 1rem 0;
}

.assign-col {
    width: calc(25% - 2rem);
    cursor: pointer;
}

.flip-container {
    transform-style: preserve-3d;
    perspective: 1000px;
    position: relative;
    min-height: 280px;
}

.flip-front,
.flip-back {
    background-size: cover;
    background-position: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    transition: transform 0.7s cubic-bezier(0.4, 0.2, 0.2, 1);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    text-align: center;
    min-height: 280px;
    color: #fff;
    font-size: 1.5rem;
    border: 1px solid rgba(110, 69, 226, 0.2);
}

.flip-front {
    transform: rotateY(0deg);
    transform-style: preserve-3d;
    background-image: url('../assets/img/assigment/animated_fancy.gif');
    background-color: rgba(26, 26, 46, 0.9);
}

.flip-front::after {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    content: '';
    display: block;
    opacity: 0.55;
    background-color: #0a0a1a;
    backface-visibility: hidden;
    border-radius: 12px;
}

.flip-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotateY(180deg);
    transform-style: preserve-3d;
    
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    background-color: rgba(26, 26, 46, 0.95);
}

.assign-col:nth-child(1) .flip-back {
    background-image: url("../assets/img/assigment/case-1.png");
}

.assign-col:nth-child(2) .flip-back {
    background-image: url("../assets/img/assigment/case-2.gif");
}

.assign-col:nth-child(3) .flip-back {
    background-image: url("../assets/img/assigment/case-3.gif");
}

.assign-col:nth-child(4) .flip-back {
    background-image: url("../assets/img/assigment/case-4.gif");
}

.assign-col:nth-child(5) .flip-back {
    background-image: url("../assets/img/assigment/case-5.png");
}

.assign-col:nth-child(6) .flip-back {
    background-image: url("../assets/img/assigment/case-6.png");
}

.assign-col:nth-child(7) .flip-back {
    background-image: url("../assets/img/assigment/case-7.gif");
}

.assign-col:nth-child(8) .flip-back {
    background-image: url("../assets/img/assigment/case-8.gif");
}

.assign-col:nth-child(9) .flip-back {
    background-image: url("../assets/img/assigment/case-9.gif");
}

.assign-col:nth-child(10) .flip-back {
    background-image: url("../assets/img/assigment/case-10.gif");
}

.assign-col:nth-child(11) .flip-back {
    background-image: url("../assets/img/assigment/case-11.gif");
}

.assign-col:nth-child(12) .flip-back {
    background-image: url("../assets/img/assigment/case-12.gif");
}

.assign-col:nth-child(13) .flip-back {
    background-image: url("../assets/img/assigment/case-13.gif");
}

.assign-col:nth-child(14) .flip-back {
    background-image: url("../assets/img/assigment/case-14.gif");
}

.flip-back::after {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    content: '';
    display: block;
    opacity: 0.45;
    background-color: #0a0a1a;
    backface-visibility: hidden;
    border-radius: 12px;
}

.assign-col:hover .flip-front,
.assign-col.hover .flip-front {
    transform: rotateY(-180deg);
    transform-style: preserve-3d;
}

.assign-col:hover .flip-back,
.assign-col.hover .flip-back {
    transform: rotateY(0deg);
    transform-style: preserve-3d;
}

.flip-inner {
    transform: translateY(-50%) translateZ(60px) scale(0.94);
    top: 50%;
    position: absolute;
    left: 0;
    width: 100%;
    padding: 2rem;
    box-sizing: border-box;
    perspective: inherit;
    z-index: 2;

}

.flip-front .flip-inner p {
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 1rem;
    position: relative;
    color: #e2e8f0;
}

.flip-front .flip-inner p::after {
    content: '';
    width: 3rem;
    height: 2px;
    position: absolute;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    display: block;
    left: 0;
    right: 0;
    margin: 0 auto;
    bottom: -0.6rem;
}

.flip-front .flip-inner span {
    color: #4ade80;
    font-size: 0.95rem;
    font-weight: 400;
    margin-top: 0.5rem;
    display: block;
}

.flip-back .flip-inner p {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    letter-spacing: 0.5px;
    margin-bottom: 0.9rem;
}

.back-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.assign-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 86px;
    padding: 8px 14px;
    border-radius: 999px;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.view-btn {
    background: #ffffff;
    color: #121326;
}

.code-btn {
    background: rgba(18, 19, 38, 0.9);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.55);
}

.assign-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
}

.assign-btn:active {
    transform: translateY(0);
    opacity: 0.9;
}

/* ── Responsive ── */
@media (max-width: 64rem) {
    .assign-col {
        width: calc(33.333% - 2rem);
    }
}

@media (max-width: 48rem) {
    .assign-col {
        width: calc(50% - 2rem);
    }
}

@media (max-width: 32rem) {
    .assign-col {
        width: 100%;
        margin: 0 0 1.5rem 0;
    }
}

.theme-toggle-floating {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1100;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--theme-toggle-border);
    background: var(--theme-toggle-bg);
    color: var(--page-text);
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.theme-toggle-floating:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.12);
}

.theme-toggle-text {
    font-size: 0.85rem;
    font-weight: 600;
}

html[data-theme='light'] .assignments-section {
    background: rgba(15, 23, 42, 0.03);
}

html[data-theme='light'] .flip-front{
    background-color: rgba(240, 242, 255, 0.95);
    border-color: var(--border-soft);
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.1);
    background-image: url('../assets/img/assigment/animated_second.gif');
}

html[data-theme='light'] .flip-back {
    color: var(--page-text);
    border-color: var(--border-soft);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.1);
}

html[data-theme='light'] .flip-front {
    background-color: rgba(255, 255, 255, 0.94);
}

html[data-theme='light'] .flip-front::after,
html[data-theme='light'] .flip-back::after {
    background-color: rgba(255, 255, 255, 0.18);
}

html[data-theme='light'] .flip-back {
    background-color: rgba(255, 255, 255, 0.92);
}

html[data-theme='light'] .flip-front .flip-inner p {
    color: rgb(255, 210, 28);
}

html[data-theme='light'] .flip-front .flip-inner span {
    color: rgb(239, 7, 7);
}

html[data-theme='light'] .flip-back .flip-inner p {
    color: rgb(0, 0, 0);
}

html[data-theme='light'] .view-btn {
    background: var(--page-text);
    color: var(--page-bg);
}

html[data-theme='light'] .code-btn {
    background: var(--surface-2);
    color: var(--page-text);
    border-color: var(--border-soft);
}

@media (max-width: 32rem) {
    .theme-toggle-floating {
        top: 12px;
        right: 12px;
        padding: 8px 12px;
    }
}