@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap');

:root {
    --bg-color: #0b021d;
    --card-bg: rgba(255, 255, 255, 0.05);
    --accent-color: #00f5ff;
    --accent-secondary: #ff00c8;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(0, 245, 255, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(255, 0, 200, 0.05) 0%, transparent 40%);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header & Hero */
header {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: relative;
}

.hero-title {
    font-size: 5rem;
    font-weight: 800;
    background: linear-gradient(45deg, var(--accent-color), var(--accent-secondary));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 20px;
    animation: titleFade 1.5s ease-out;
}

.hero-subtitle {
    font-size: 1.5rem;
    color: var(--text-secondary);
    max-width: 600px;
    animation: subFade 2s ease-out;
}

.scroll-indicator {
    position: absolute;
    bottom: 30px;
    animation: bounce 2s infinite;
}

/* Sections */
section {
    padding: 100px 0;
}

.section-title {
    font-size: 2.5rem;
    margin-bottom: 40px;
    position: relative;
    display: inline-block;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 60px;
    height: 4px;
    background: var(--accent-color);
    border-radius: 2px;
}

/* Cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 50px;
}

.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    padding: 40px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}

.glass-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 40px rgba(0, 245, 255, 0.1);
    border-color: rgba(0, 245, 255, 0.3);
}

.card-icon {
    font-size: 3rem;
    margin-bottom: 20px;
    display: block;
}

/* Knot Visualizers */
.knot-display {
    width: 100%;
    height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 15px;
    margin: 20px 0;
}

.knot-svg {
    width: 200px;
    height: 200px;
    stroke: var(--accent-color);
    stroke-width: 2.5;
    stroke-linecap: round;
    fill: none;
    filter: drop-shadow(0 0 4px var(--accent-color));
}

/* Reidemeister Section */
.move-container {
    display: flex;
    align-items: center;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 20px;
}

.move-box {
    text-align: center;
    flex: 1;
    min-width: 250px;
}

/* Animations */
@keyframes titleFade {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

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

@keyframes subFade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-10px);
    }

    60% {
        transform: translateY(-5px);
    }
}

.draw-animation {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: draw 5s linear infinite;
}

@keyframes draw {
    to {
        stroke-dashoffset: 0;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .hero-title {
        font-size: 3rem;
    }

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

/* Knot Lab Styles */
.lab-container {
    margin-top: 50px;
}

.knot-table {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.lab-item {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.lab-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-color);
}

.lab-item.selected {
    border-color: var(--accent-secondary);
    box-shadow: 0 0 15px rgba(255, 0, 200, 0.3);
    background: rgba(255, 0, 200, 0.05);
}

.lab-item .knot-svg {
    width: 140px;
    height: 140px;
    stroke-width: 2.5;
}

.animation-stage {
    min-height: 500px;
    background: radial-gradient(circle at center, rgba(0, 245, 255, 0.05) 0%, rgba(0, 0, 0, 0.6) 100%);
    border-radius: 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    border: 2px solid var(--glass-border);
    margin-top: 40px;
    box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.animation-stage::before {
    content: 'AREA DI TRASFORMAZIONE (TRANSFORMATION AREA)';
    position: absolute;
    top: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 2px;
}

#main-animator {
    width: 380px;
    height: 380px;
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 0 10px currentColor);
}

#animating-path {
    stroke: var(--accent-color);
    stroke-width: 3;
    stroke-linecap: round;
    fill: none;
}

.status-box {
    background: rgba(0, 20, 40, 0.9);
    border-left: 5px solid var(--accent-color);
    padding: 20px 30px;
    border-radius: 12px;
    margin-top: 25px;
    width: 90%;
    max-width: 650px;
    font-weight: 500;
    display: none;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

/* ---- 2D / 3D toggle ---- */
.view-toggle-row {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-top: 28px;
    flex-wrap: wrap;
}

.toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(0, 245, 255, 0.35);
    border-radius: 30px;
    color: var(--accent-color);
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    padding: 10px 22px;
    cursor: pointer;
    transition: background 0.25s ease, box-shadow 0.25s ease, color 0.25s ease;
    user-select: none;
    letter-spacing: 0.04em;
}

.toggle-btn .btn-icon {
    font-size: 1.1em;
    line-height: 1;
}

.toggle-btn:hover {
    background: rgba(0, 245, 255, 0.12);
    box-shadow: 0 0 14px rgba(0, 245, 255, 0.3);
}

.toggle-btn.active {
    background: linear-gradient(45deg, var(--accent-color), var(--accent-secondary));
    color: #fff;
    border-color: transparent;
    box-shadow: 0 0 22px rgba(0, 245, 255, 0.5);
}

.view-hint {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* ---- 3D Canvas ---- */
#knot-canvas-3d {
    display: none;
    /* shown only in 3D mode */
    width: 380px;
    height: 380px;
    border-radius: 8px;
    cursor: grab;
}

#knot-canvas-3d.dragging {
    cursor: grabbing;
}

/* In 3D mode hide the SVG, show the canvas */
.mode-3d #main-animator {
    display: none;
}

.mode-3d #knot-canvas-3d {
    display: block;
}


.lab-instructions {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-style: italic;
}

.help-button {
    background: linear-gradient(45deg, var(--accent-color), var(--accent-secondary));
    border: none;
    border-radius: 30px;
    color: white;
    padding: 12px 25px;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 30px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 245, 255, 0.3);
}

.help-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 245, 255, 0.5);
}

.help-button:active {
    transform: scale(0.98);
}

.blink-hint {
    animation: blinkHint 1.5s ease-in-out 3;
}

@keyframes blinkHint {

    0%,
    100% {
        border-color: var(--glass-border);
        box-shadow: none;
    }

    50% {
        border-color: white;
        box-shadow: 0 0 20px white;
        background: rgba(255, 255, 255, 0.1);
    }
}

/* =============================================
   APPLICAZIONI
   ============================================= */
#applicazioni {
    padding: 100px 0;
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 28px;
    margin-top: 50px;
}

.app-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    padding: 36px 32px 28px;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    position: relative;
    overflow: hidden;
}

.app-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-color), var(--accent-secondary));
    border-radius: 20px 20px 0 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.app-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 16px 40px rgba(0, 245, 255, 0.12);
    border-color: rgba(0, 245, 255, 0.25);
}

.app-card:hover::before {
    opacity: 1;
}

.app-icon {
    font-size: 2.8rem;
    margin-bottom: 18px;
    line-height: 1;
}

.app-card h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 14px;
}

.app-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 20px;
}

.app-tag {
    display: inline-block;
    background: rgba(0, 245, 255, 0.08);
    border: 1px solid rgba(0, 245, 255, 0.25);
    color: var(--accent-color);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    padding: 5px 14px;
    border-radius: 20px;
}