/* =========================================================
   2.01 Evolution of Networking widgets
   ========================================================= */

/* ---------- Shared widget styling ---------- */

.network-evolution-widget,
.sharing-model-widget {
    margin: 1.5rem 0;
    padding: 1.25rem;
    border: 1px solid #e2e8f0;
    border-radius: 22px;
    background: #ffffff;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

/* ---------- Evolution timeline widget ---------- */

.evolution-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
}

.evolution-tab {
    appearance: none;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
    border-radius: 999px;
    padding: 0.55rem 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.evolution-tab:hover {
    border-color: #94a3b8;
    background: #f1f5f9;
}

.evolution-tab.active {
    background: #0f172a;
    color: white;
    border-color: #0f172a;
}

.evolution-panel {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(260px, 0.9fr);
    gap: 1.25rem;
    align-items: stretch;
}

.evolution-diagram {
    min-height: 310px;
    border-radius: 18px;
    border: 1px solid #e2e8f0;
    background:
        radial-gradient(circle at top right, rgba(191, 219, 254, 0.65), transparent 38%),
        linear-gradient(180deg, #f8fafc, #eef2ff);
    position: relative;
    overflow: hidden;
    padding: 1rem;
}

.evolution-explanation {
    border-radius: 18px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 1rem 1.1rem;
}

.evolution-era {
    margin: 0 0 0.35rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.8rem;
    font-weight: 700;
}

.evolution-explanation h3 {
    margin-top: 0;
    margin-bottom: 0.65rem;
}

.evolution-benefits {
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid #e2e8f0;
}

.evolution-benefits h4 {
    margin: 0 0 0.45rem;
    color: #334155;
}

.evolution-benefits ul {
    margin-bottom: 0;
}

/* diagram pieces */

.net-node,
.net-label,
.net-link,
.net-cloud,
.net-phone {
    position: absolute;
}

.net-node {
    width: 74px;
    min-height: 54px;
    padding: 0.45rem 0.35rem;
    border-radius: 16px;
    background: white;
    border: 1px solid #cbd5e1;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 700;
    color: #334155;
    z-index: 2;
}

.net-node.server {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.net-node.user {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.net-node.printer {
    background: #fdf4ff;
    border-color: #e9d5ff;
}

.net-node.branch {
    background: #fff7ed;
    border-color: #fed7aa;
}

.net-node.internet-node {
    background: #fefce8;
    border-color: #fde68a;
}

.net-label {
    font-size: 0.76rem;
    color: #475569;
    font-weight: 700;
    z-index: 2;
}

.net-link {
    height: 3px;
    background: linear-gradient(90deg, #94a3b8, #64748b);
    transform-origin: left center;
    border-radius: 999px;
    z-index: 1;
}

.net-link.dashed {
    background: repeating-linear-gradient(
        90deg,
        #94a3b8 0 10px,
        transparent 10px 16px
    );
}

.net-cloud {
    width: 120px;
    height: 68px;
    border-radius: 999px;
    background: #dbeafe;
    border: 1px solid #93c5fd;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #1d4ed8;
    z-index: 2;
}

.net-phone {
    width: 42px;
    height: 74px;
    border-radius: 12px;
    background: #0f172a;
    border: 3px solid #334155;
    z-index: 2;
}

.net-phone::before {
    content: "";
    position: absolute;
    inset: 7px 6px 11px;
    border-radius: 7px;
    background: #dbeafe;
}

.net-phone::after {
    content: "";
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 3px;
    border-radius: 999px;
    background: #cbd5e1;
}

.diagram-enter {
    animation: diagramFade 0.35s ease;
}

@keyframes diagramFade {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- Sharing model widget ---------- */

.sharing-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.sharing-mode-btn,
.sharing-start-btn {
    appearance: none;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    padding: 0.55rem 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sharing-mode-btn {
    background: #f8fafc;
    color: #334155;
}

.sharing-mode-btn:hover {
    background: #f1f5f9;
}

.sharing-mode-btn.active {
    background: #0f172a;
    color: white;
    border-color: #0f172a;
}

.sharing-start-btn {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}

.sharing-start-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
}

.sharing-model-explanation {
    margin-top: 0;
    color: #475569;
}

.sharing-stage {
    position: relative;
    min-height: 290px;
    border-radius: 18px;
    border: 1px solid #e2e8f0;
    background:
        radial-gradient(circle at top left, rgba(220, 252, 231, 0.75), transparent 38%),
        linear-gradient(180deg, #ffffff, #f8fafc);
    overflow: hidden;
    margin: 1rem 0;
}

.share-node {
    position: absolute;
    width: 92px;
    min-height: 64px;
    border-radius: 18px;
    padding: 0.55rem 0.45rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-weight: 700;
    border: 1px solid #cbd5e1;
    background: white;
    color: #334155;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    z-index: 2;
}

.share-node.server {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.share-node.peer {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.share-node.downloader {
    background: #fff7ed;
    border-color: #fed7aa;
}

.share-line {
    position: absolute;
    height: 3px;
    background: #94a3b8;
    transform-origin: left center;
    border-radius: 999px;
    z-index: 1;
}

.file-piece {
    position: absolute;
    width: 28px;
    height: 22px;
    border-radius: 8px;
    background: #2563eb;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    z-index: 3;
    opacity: 0;
}

.download-piece-to-client {
    animation: fileToClient 1.2s forwards ease-in-out;
}

.download-piece-from-peer-a {
    animation: fileFromPeerA 1.2s forwards ease-in-out;
}

.download-piece-from-peer-b {
    animation: fileFromPeerB 1.2s forwards ease-in-out;
}

.download-piece-from-peer-c {
    animation: fileFromPeerC 1.2s forwards ease-in-out;
}

@keyframes fileFromPeerA {
    from {
        left: 18%;
        top: 22%;
        opacity: 1;
    }
    to {
        left: 68%;
        top: 46%;
        opacity: 1;
    }
}

@keyframes fileFromPeerB {
    from {
        left: 18%;
        top: 68%;
        opacity: 1;
    }
    to {
        left: 68%;
        top: 46%;
        opacity: 1;
    }
}

@keyframes fileFromPeerC {
    from {
        left: 42%;
        top: 12%;
        opacity: 1;
    }
    to {
        left: 68%;
        top: 46%;
        opacity: 1;
    }
}

.sharing-summary-box {
    margin-top: 0.75rem;
    padding: 0.9rem 1rem;
    border-radius: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
    .evolution-panel {
        grid-template-columns: 1fr;
    }

    .evolution-diagram {
        min-height: 280px;
    }

    .sharing-stage {
        min-height: 330px;
    }
}
