/* =========================================================
   DEEP LEARNING HERO VISUAL
========================================================= */

.hero-visual {

    position: relative;

    width: 100%;
    min-height: 520px;

    display: flex;

    align-items: center;
    justify-content: center;

    /*
     * 只负责页面级别的溢出保护。
     * 不负责裁剪卡片内部内容。
     */
    overflow: hidden;

    box-sizing: border-box;
}


/* =========================================================
   CARD
========================================================= */

.deep-learning-card {

    position: relative;

    width: min(820px, 100%);
    max-width: 820px;
    min-width: 0;

    padding: 22px;

    border-radius: 24px;

    background:
        linear-gradient(
            145deg,
            rgba(255, 255, 255, 0.98),
            rgba(247, 250, 255, 0.98)
        );

    border:
        1px solid rgba(25, 55, 95, 0.10);

    overflow: visible;

    box-sizing: border-box;
}


/* =========================================================
   HEADER
========================================================= */

.dl-header {

    position: relative;

    z-index: 1;

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 12px;

    margin-bottom: 18px;

    min-width: 0;
}


.dl-title {

    display: flex;

    align-items: center;

    gap: 9px;

    min-width: 0;

    color: #172235;

    font-size: 11px;

    font-weight: 800;

    letter-spacing: .16em;
}


.dl-dot {

    width: 7px;
    height: 7px;

    flex: 0 0 auto;

    border-radius: 50%;

    background: #3b82f6;

    box-shadow:
        0 0 0 4px rgba(59,130,246,.10),
        0 0 12px rgba(59,130,246,.45);

    animation:
        dlPulse 1.8s ease-in-out infinite;
}


.dl-training-status {

    display: flex;

    align-items: center;

    gap: 7px;

    flex: 0 0 auto;

    padding: 6px 10px;

    border-radius: 999px;

    background:
        rgba(34,197,94,.07);

    border:
        1px solid rgba(34,197,94,.14);

    color: #27934e;

    font-size: 9px;

    font-weight: 800;

    letter-spacing: .12em;
}


.status-pulse {

    width: 5px;
    height: 5px;

    flex: 0 0 auto;

    border-radius: 50%;

    background: #31b867;

    animation:
        dlPulse 1.2s ease-in-out infinite;
}


/* =========================================================
   MAIN
========================================================= */

.dl-main {

    position: relative;

    z-index: 1;

    display: grid;

    /*
     * 这里是这次最重要的修改。
     *
     * 不再使用：
     *
     * minmax(280px, .92fr)
     * minmax(360px, 1.18fr)
     *
     * 因为它们会强制撑宽。
     *
     * minmax(0, ...)
     * 才能真正允许两个 panel 缩小。
     */
    grid-template-columns:
        minmax(0, .92fr)
        minmax(0, 1.18fr);

    gap: 14px;

    width: 100%;

    min-width: 0;

    box-sizing: border-box;
}


/* =========================================================
   PANELS
========================================================= */

.dl-data-panel,
.dl-network-panel {

    position: relative;

    /*
     * 允许 grid item 真正缩小。
     */
    width: 100%;

    min-width: 0;

    max-width: 100%;

    box-sizing: border-box;

    border-radius: 16px;

    background:
        rgba(255,255,255,.72);

    border:
        1px solid rgba(35,65,105,.08);

    /*
     * 绝对不要 hidden。
     *
     * 内部 SVG / 网络节点不能在这里被裁。
     */
    overflow: visible;
}


/* =========================================================
   PANEL LABEL
========================================================= */

.panel-label {

    width: 100%;

    height: 42px;

    padding: 0 13px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 8px;

    box-sizing: border-box;

    border-bottom:
        1px solid rgba(35,65,105,.07);
}


.panel-label span {

    min-width: 0;

    font-size: 9px;

    font-weight: 800;

    letter-spacing: .13em;

    color: #314158;
}


.panel-label small {

    min-width: 0;

    overflow: hidden;

    white-space: nowrap;

    text-overflow: ellipsis;

    font-size: 7px;

    letter-spacing: .08em;

    color: #98a5b8;
}


/* =========================================================
   CLASSIFICATION CHART
========================================================= */

.classification-chart {

    position: relative;

    width: calc(100% - 20px);

    height: 260px;

    margin: 10px;

    /*
     * DATA 图表自己的内容可以在图表区域内裁。
     *
     * 这不会裁 DATA panel。
     */
    overflow: hidden;

    border-radius: 11px;

    background:
        linear-gradient(
            rgba(70,100,140,.055) 1px,
            transparent 1px
        ),
        linear-gradient(
            90deg,
            rgba(70,100,140,.055) 1px,
            transparent 1px
        );

    background-size:
        25px 25px;

    border:
        1px solid rgba(50,80,120,.06);

    box-sizing: border-box;
}


.chart-grid {

    position: absolute;

    inset: 0;

    opacity: .4;
}


/* =========================================================
   DECISION REGION
========================================================= */

.decision-region {

    position: absolute;

    inset: 0;

    background:
        linear-gradient(
            135deg,
            rgba(59,130,246,.08),
            transparent 45%
        );

    clip-path:
        polygon(
            0 0,
            48% 0,
            36% 100%,
            0 100%
        );

    transition:
        clip-path 1s ease;
}


/* =========================================================
   DECISION LINE
========================================================= */

.decision-line {

    position: absolute;

    width: 130%;

    height: 2px;

    left: -15%;

    top: 50%;

    transform:
        rotate(-18deg);

    transform-origin: center;

    background:
        linear-gradient(
            90deg,
            transparent,
            #4c8df7 15%,
            #4c8df7 85%,
            transparent
        );

    box-shadow:
        0 0 10px rgba(76,141,247,.25);

    transition:
        top .8s ease,
        transform .8s ease;
}


/* =========================================================
   DATA POINTS
========================================================= */

.data-points {

    position: absolute;

    inset: 0;
}


.data-point {

    position: absolute;

    width: 9px;
    height: 9px;

    border-radius: 50%;

    transform:
        translate(-50%, -50%)
        scale(.8);

    animation:
        pointAppear .5s ease forwards;

    transition:
        transform .35s ease,
        opacity .35s ease;
}


.data-point.class-a {

    background: #3b82f6;

    box-shadow:
        0 0 0 3px rgba(59,130,246,.10),
        0 0 10px rgba(59,130,246,.22);
}


.data-point.class-b {

    background: #f97368;

    box-shadow:
        0 0 0 3px rgba(249,115,104,.10),
        0 0 10px rgba(249,115,104,.20);
}


.data-point.active {

    transform:
        translate(-50%, -50%)
        scale(1.35);

    box-shadow:
        0 0 0 5px rgba(59,130,246,.10),
        0 0 16px rgba(59,130,246,.42);
}


/* =========================================================
   NETWORK PANEL
========================================================= */

.network-stage {

    position: relative;

    width: 100%;

    min-width: 0;

    max-width: 100%;

    height: 260px;

    box-sizing: border-box;

    /*
     * 这里绝对不裁。
     */
    overflow: visible;
}


/* =========================================================
   NETWORK SVG
========================================================= */

.network-svg {

    position: absolute;

    left: 0;

    top: 5px;

    /*
     * 关键：
     * SVG 永远只使用 MODEL 的实际宽度。
     */
    width: 100%;

    height: 230px;

    max-width: 100%;

    display: block;

    overflow: visible;

    vertical-align: top;

    box-sizing: border-box;
}


/* =========================================================
   CONNECTIONS
========================================================= */

.network-link {

    stroke:
        rgba(85,110,145,.17);

    stroke-width: 1;

    transition:
        stroke .25s ease,
        stroke-width .25s ease,
        opacity .25s ease;
}


.network-link.active {

    stroke:
        rgba(59,130,246,.75);

    stroke-width: 1.8;

    filter:
        drop-shadow(
            0 0 3px
            rgba(59,130,246,.25)
        );
}


.network-link.backward {

    stroke:
        rgba(249,115,104,.72);

    stroke-width: 1.8;
}


/* =========================================================
   NEURONS
========================================================= */

.network-neuron {

    fill: #ffffff;

    stroke: #aab8ca;

    stroke-width: 1.4;

    transition:
        fill .25s ease,
        stroke .25s ease,
        transform .25s ease;
}


.network-neuron.active {

    fill: #eaf2ff;

    stroke: #4389f7;

    filter:
        drop-shadow(
            0 0 6px
            rgba(59,130,246,.38)
        );
}


.network-neuron.output {

    stroke: #6b8fc2;

    stroke-width: 1.8;
}


.network-neuron.correct {

    fill: #effcf4;

    stroke: #36a967;
}


.network-neuron.error {

    fill: #fff3f1;

    stroke: #ef7b6d;
}


/* =========================================================
   FLOW PARTICLES
========================================================= */

.flow-particle {

    fill: #4b8ff8;

    filter:
        drop-shadow(
            0 0 5px
            rgba(59,130,246,.55)
        );
}


.flow-particle.backward {

    fill: #f47b6d;

    filter:
        drop-shadow(
            0 0 5px
            rgba(244,123,109,.45)
        );
}


/* =========================================================
   LAYER LABELS
========================================================= */

.layer-labels {

    position: absolute;

    left: 12px;

    right: 12px;

    bottom: 5px;

    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    text-align: center;

    color: #99a6b7;

    font-size: 7px;

    font-weight: 800;

    letter-spacing: .12em;

    pointer-events: none;
}


/* =========================================================
   TRAINING PANEL
========================================================= */

.dl-training-panel {

    position: relative;

    z-index: 1;

    width: 100%;

    margin-top: 12px;

    padding: 13px 14px;

    display: flex;

    align-items: center;

    gap: 20px;

    border-radius: 15px;

    background:
        rgba(246,249,253,.85);

    border:
        1px solid rgba(35,65,105,.07);

    box-sizing: border-box;
}


.training-main {

    flex: 1 1 auto;

    min-width: 0;
}


.training-title {

    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 10px;

    margin-bottom: 8px;
}


.training-title span {

    color: #34445b;

    font-size: 8px;

    font-weight: 800;

    letter-spacing: .12em;
}


.training-title small {

    color: #7890ad;

    font-size: 7px;

    letter-spacing: .08em;

    white-space: nowrap;
}


.training-progress {

    width: 100%;

    height: 4px;

    overflow: hidden;

    border-radius: 999px;

    background:
        rgba(70,100,140,.08);
}


.training-progress-bar {

    width: 5%;

    height: 100%;

    border-radius: inherit;

    background:
        linear-gradient(
            90deg,
            #4c8df7,
            #67a3ff
        );

    box-shadow:
        0 0 8px rgba(59,130,246,.25);

    transition:
        width .5s ease;
}


/* =========================================================
   STATS
========================================================= */

.training-stats {

    display: flex;

    gap: 18px;

    flex: 0 0 auto;
}


.training-stat {

    display: flex;

    flex-direction: column;

    gap: 3px;

    min-width: 48px;
}


.stat-label {

    color: #9aa7b7;

    font-size: 7px;

    font-weight: 700;

    letter-spacing: .1em;
}


.training-stat strong {

    color: #25354b;

    font-size: 13px;

    font-weight: 800;

    font-variant-numeric: tabular-nums;
}


/* =========================================================
   EQUATION
========================================================= */

.dl-equation {

    position: relative;

    z-index: 1;

    width: 100%;

    margin-top: 12px;

    padding: 11px 14px;

    display: flex;

    align-items: center;

    justify-content: center;

    gap: 11px;

    border-radius: 13px;

    background:
        linear-gradient(
            90deg,
            rgba(59,130,246,.045),
            rgba(255,255,255,.75),
            rgba(59,130,246,.045)
        );

    border:
        1px solid rgba(59,130,246,.07);

    color: #55677f;

    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;

    font-size: 9px;

    box-sizing: border-box;
}


.dl-equation i {

    color: #9cabc0;

    font-style: normal;
}


/* =========================================================
   FOOTER
========================================================= */

.dl-footer {

    position: relative;

    z-index: 1;

    display: flex;

    align-items: center;

    justify-content: center;

    width: 100%;

    min-width: 0;

    margin-top: 13px;

    color: #8f9cad;

    font-size: 11px;

    font-weight: 600;

    line-height: 1.6;

    letter-spacing: .04em;

    text-align: center;

}



/* =========================================================
   ANIMATIONS
========================================================= */

@keyframes dlPulse {

    0%,
    100% {

        opacity: .55;

        transform:
            scale(.9);
    }

    50% {

        opacity: 1;

        transform:
            scale(1.15);
    }
}


@keyframes pointAppear {

    from {

        opacity: 0;

        transform:
            translate(-50%, -50%)
            scale(.2);
    }

    to {

        opacity: 1;

        transform:
            translate(-50%, -50%)
            scale(.8);
    }
}


/* =========================================================
   TABLET
========================================================= */

@media (max-width: 860px) {

    .deep-learning-card {

        width:
            calc(100% - 24px);

        max-width:
            calc(100% - 24px);
    }


    .dl-main {

        /*
         * 继续允许两个区域自由收缩
         */
        grid-template-columns:
            minmax(0, .92fr)
            minmax(0, 1.08fr);

        gap: 12px;
    }
}


/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 760px) {

    .hero-visual {

        min-height: auto;

        padding:
            20px 0;
    }


    .deep-learning-card {

        width:
            calc(100% - 20px);

        max-width:
            calc(100% - 20px);

        padding: 16px;

        border-radius: 18px;
    }


    .dl-main {

        /*
         * 手机直接上下排列。
         */
        grid-template-columns: 1fr;

        gap: 12px;
    }


    .classification-chart,
    .network-stage {

        height: 220px;
    }


    .network-svg {

        height: 200px;
    }


    .dl-training-panel {

        flex-direction: column;

        align-items: stretch;

        gap: 14px;
    }


    .training-stats {

        justify-content: space-between;

        width: 100%;
    }


    .dl-equation {

        gap: 6px;

        font-size: 7px;

        flex-wrap: wrap;
    }


    .dl-footer {

        flex-wrap: wrap;
    }


    .backprop-label {

        width: 100%;

        margin-left: 0;

        margin-top: 3px;
    }
}


/* =========================================================
   SMALL MOBILE
========================================================= */

@media (max-width: 480px) {

    .deep-learning-card {

        width:
            calc(100% - 12px);

        max-width:
            calc(100% - 12px);

        padding: 13px;

        border-radius: 16px;
    }


    .dl-header {

        margin-bottom: 12px;
    }


    .dl-title {

        font-size: 9px;
    }


    .dl-training-status {

        padding: 5px 8px;

        font-size: 8px;
    }


    .panel-label {

        padding:
            0 10px;
    }


    .panel-label small {

        display: none;
    }


    .classification-chart {

        width:
            calc(100% - 16px);

        margin: 8px;
    }


    .training-stats {

        gap: 10px;
    }


    .training-stat {

        min-width: 42px;
    }


    .training-stat strong {

        font-size: 12px;
    }
}