/* ------------------ GLOBAL STYLE ------------------ */
html { scroll-behavior: smooth; }

body {
    margin: 0;
    background: #0d0f19;
    font-family: 'IBM Plex Mono', monospace, sans-serif;
    color: #e8f0ff;
}

/* Background glow animation */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 20% 30%, rgba(0,240,255,0.08), transparent),
                radial-gradient(circle at 80% 70%, rgba(255,0,230,0.07), transparent);
    animation: floatBg 14s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes floatBg {
    0% { transform: translate(0, 0); }
    100% { transform: translate(20px, -20px); }
}

/* ------------------ NAVBAR ------------------ */
nav {
    position: fixed;
    top: 0;
    width: 93%;
    height: 60px;
    padding: 0 25px;
    background: rgba(13, 15, 25, 0.85);
    display: flex;
    align-items: center;
    justify-content: space-between;
    backdrop-filter: blur(8px);
    border-bottom: 1px solid #1f2637;
    z-index: 30;
}

.nav-left { display: flex; align-items: center; }

.nav-logo {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #00d4ff;
    box-shadow: 0 0 10px #00d4ff;
}

.nav-right { display: flex; gap: 32px; }

.nav-right a {
    color: #cfe2ff;
    text-decoration: none;
    font-size: 15px;
    letter-spacing: 0.6px;
    transition: 0.3s;
}

.nav-right a:hover {
    color: #00d4ff; 
    text-shadow: 0 0 6px #00d4ff;
}

/* GitHub corner */
.github-corner {
    position: fixed;
    top: 0;
    right: 0;
    width: 90px; height: 90px;
    background: #042842;
    clip-path: polygon(100% 0, 0 0, 100% 100%);
    z-index: 40;
}

.github-corner .github-icon {
    position: absolute;
    top: 12px; right: 12px;
    width: 32px; height: 32px;
    border-radius: 50%;
    filter: drop-shadow(0 0 4px #00d4ff);
    transition: 0.25s;
    cursor: pointer;
}
.github-corner .github-icon:hover { filter: drop-shadow(0 0 12px #07cbf3); }

/* ------------------ LANDING ------------------ */
.landing {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding-top: 60px;
    text-align: center;
}

#title {
    font-size: 3.2rem;
    font-weight: 600;
    color: #00d4ff;
    text-shadow: 0 0 18px #00d4ff;
}

#title::after {
    content: '|';
    margin-left: 6px;
    color: #00d4ff;
    animation: blink 0.7s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

.hidden { opacity: 0; }
#subtitle { transition: opacity 1.2s ease; }

/* ------------------ SECTIONS ------------------ */
section {
    padding: 40px 40px;
    min-height: 100vh;
    scroll-margin-top: 80px;
}

/* ------------------ SVG SIGNALS ------------------ */
.signal-line {
    stroke: #8899aa;
    stroke-width: 2;
    stroke-linecap: round;
}

.signal-flow {
    stroke: #00d4ff;
    stroke-width: 3;
    fill: none;
    stroke-dasharray: 6;
    animation: flow 2.0s linear infinite;
}

@keyframes flow {
    from { stroke-dashoffset: 0; }
    to { stroke-dashoffset: -18; }
}

.signal-dot {
    fill: #00eaff;
    filter: drop-shadow(0 0 6px #00eaff);
}

.neuron-node {
    stroke: #00d4ff;
    stroke-width: 3;
    fill: #070d1f;
}

.hidden-neuron {
    fill: #091426;
    stroke: #00aaff;
    stroke-width: 3;
    filter: drop-shadow(0 0 8px rgba(0,170,255,0.5));
}

/* Neuron glow */
@keyframes neuronPulse {
    0% { filter: drop-shadow(0 0 4px #00d4ff); }
    50% { filter: drop-shadow(0 0 16px #00d4ff); }
    100% { filter: drop-shadow(0 0 4px #00d4ff); }
}
.active-neuron-glow { animation: neuronPulse 3s ease-in-out infinite; }

/* Activation & Step glowing */
@keyframes glowPulse {
    0% { filter: drop-shadow(0 0 2px rgba(120,200,255,0.4)); }
    50% { filter: drop-shadow(0 0 10px rgba(160,230,255,0.9)); }
    100% { filter: drop-shadow(0 0 2px rgba(120,200,255,0.4)); }
}

#activation-node,
#step-function rect,
#step-function path {
    animation: glowPulse 2.5s ease-in-out infinite;
}

/* ------------------ LAYOUT BOXES ------------------ */
.perceptron-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 40px;
    flex-wrap: wrap;
    margin: 40px auto;
    max-width: 1200px;
    width: 100%;
}

.perceptron-text {
    flex: 1 1 48%;
    min-width: 320px;
    line-height: 1.6;
    color: #c8d2e5;
}

.perceptron-visual {
    flex: 1 1 48%;
    min-width: 320px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.diagram-box {
    background: #0b1224;
    border: 1px solid #294a88;
    border-radius: 14px;
    padding: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    box-shadow: 0 0 30px rgba(80, 140, 255, 0.25);
    transition: 0.3s ease;
    width: 100%;
    max-width: 900px;
    margin: 30px auto;
    overflow-x: auto;
}
.diagram-box:hover { box-shadow: 0 0 35px rgba(120,180,255,0.45); }

.diagram-box svg, 
.perceptron-visual svg {
    max-width: 100%;
    height: auto;
    display: block;
    margin:0 auto;
}

/* EXAMPLE SECTION */
.example-container {
    background: #0b1224;
    border: 1px solid #1e3c72;
    padding: 20px 25px;
    border-radius: 12px;
    max-width: 900px;
    margin: 40px auto;
    color: #d9e4ff;
    line-height: 1.6;
}

.row {
    display: flex;
    justify-content: space-between;
    gap: 30px;
    margin-top: 12px;
}
.row p, .row ul, .row .formula { width: 48%; }

/* Math formatting */
.formula {
    background: #111d36;
    padding: 6px 10px;
    border-radius: 5px;
    display: inline-block;
}

.formula-large {
    font-size: 22px;
    color: #c7d9ff;
}

/* Collapsible Math Section */
.math-toggle,.math-toggle1 { text-align: center; margin-top: 40px; cursor: pointer; }
.math-toggle-text,.math-toggle-text1 { color: #7ab8ff; font-size: 18px; transition: 0.3s; }
.math-toggle-text:hover { color: #a8d4ff; }

.math-section,.math-section1 {
    display: none;
    margin-top: 20px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 20px 30px;
    width: 80%;
    margin-inline: auto;
    backdrop-filter: blur(4px);
}
.scene-box {
    background: #0b1224;
    border: 1px solid #294a88;
    padding: 25px 28px;
    border-radius: 14px;
    max-width: 850px;
    margin: 45px auto;
    line-height: 1.6;
    box-shadow: 0 0 25px rgba(80,140,255,0.25);
    transition: 0.3s ease;
}

.scene-box h3 {
    margin-top: 0;
    font-size: 24px;
    color: #8fcaff;
}

.scene-desc {
    margin-bottom: 25px;
    color: #d7e4ff;
}

.loss-panel {
    text-align: center;
}

.loss-value p {
    margin: 6px 0;
    font-size: 17px;
    color: #c8d9ff;
}

/* Loss Meter */
.loss-meter {
    width: 85%;
    height: 16px;
    margin: 16px auto;
    background: #162237;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #335a9a;
}

.loss-bar {
    width: 65%;
    height: 100%;
    background: linear-gradient(90deg, #ff3670, #ff9d42);
    animation: lossPulse 1.6s ease-in-out infinite;
    border-radius: 6px;
}

@keyframes lossPulse {
    0% { filter: drop-shadow(0 0 2px #ff6290); }
    50% { filter: drop-shadow(0 0 12px #ff6290); }
    100% { filter: drop-shadow(0 0 2px #ff6290); }
}

.loss-text {
    font-size: 14px;
    color: #8fa5cf;
    margin-top: 6px;
}

/* Soft red glow for wrong prediction */
.output-neuron-error {
    fill: #170d14;
    stroke: #00aaff;
    stroke-width: 3;
    filter: drop-shadow(0 0 10px rgba(255, 80, 120, 0.9));
    animation: errorPulse 2.2s ease-in-out infinite;
}

@keyframes errorPulse {
    0%   { filter: drop-shadow(0 0 3px rgba(255, 80, 120, 0.4)); }
    50%  { filter: drop-shadow(0 0 14px rgba(255, 80, 120, 1)); }
    100% { filter: drop-shadow(0 0 3px rgba(255, 80, 120, 0.4)); }
}

.y-hat-error {
    fill: #ff6f96;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 80, 120, 0.9);
    animation: yGlow 2.2s ease-in-out infinite;
}

@keyframes yGlow {
    0%   { opacity: 0.75; text-shadow: 0 0 4px rgba(255, 80, 120, 0.4)); }
    50%  { opacity: 1;    text-shadow: 0 0 16px rgba(255, 80, 120, 1)); }
    100% { opacity: 0.75; text-shadow: 0 0 4px rgba(255, 80, 120, 0.4)); }
}

/* Backward error wave */
.error-backflow {
    stroke: #ff6d8a;
    stroke-width: 3;
    fill: none;
    stroke-dasharray: 6;
    animation: reverseFlow 1.6s linear infinite;
    filter: drop-shadow(0 0 8px rgba(255, 80, 120, 0.8));
}

@keyframes reverseFlow {
    from { stroke-dashoffset: 0; }
    to { stroke-dashoffset: 20; }
}

.hidden-neuron.error-receive {
    animation: receivePulse 2.2s ease-in-out infinite;
}

@keyframes receivePulse {
    0%   { filter: drop-shadow(0 0 3px rgba(255,80,120,0.3)); }
    50%  { filter: drop-shadow(0 0 14px rgba(255,80,120,1)); }
    100% { filter: drop-shadow(0 0 3px rgba(255,80,120,0.3)); }
}

.pause-forward .signal-dot {
    opacity: 0 !important;
}

.learning-line {
    stroke-width: 4;
    fill: none;
    stroke-dasharray: 6;
    animation: learnPulse 2s ease-in-out infinite;
    filter: drop-shadow(0 0 10px rgba(255, 80, 120, 0.9));
}

@keyframes learnPulse {
    0% {
        stroke: #ff4d6d;
        filter: drop-shadow(0 0 12px rgba(255, 80, 120, 1));
    }
    50% {
        stroke: #00d4ff;
        filter: drop-shadow(0 0 14px rgba(0, 212, 255, 0.95));
    }
    100% {
        stroke: #ff4d6d;
        filter: drop-shadow(0 0 12px rgba(255, 80, 120, 1));
    }
}

.learning-note {
    margin-top: 10px;
    font-size: 14px;
    color: #9db3d9;
    opacity: 0.85;
    text-align: center;
}

/* Loss Bar */
.loss-meter {
  width: 250px;
  height: 12px;
  background: #2a334d;
  border-radius: 8px;
  margin: 14px auto 6px auto;
  overflow: hidden;
}

.loss-fill {
  width: 100%;
  height: 100%;
  background: #ff3b5f;
  transition: width 1.5s ease, background 1.5s ease;
}

.training-output {
  animation: learnPulse 3.5s infinite ease-in-out;
}

.loss-value {
  text-align: center;
  color: #bcd4ff;
  margin-top: 4px;
}
.train-controls {
  text-align: center;
  margin-top: 12px;
}

#train-toggle {
  background: #0d162b;
  border: 1px solid #00d4ff;
  color: #cfeaff;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  transition: 0.25s;
}

#train-toggle:hover {
  background: #001a33;
  box-shadow: 0 0 10px #00d4ff;
}
footer {
  text-align: center;
  color: #7ab8ff;
  padding: 30px 0;
  border-top: 1px solid #1e3c72;
  background: #0b1224;
  font-size: 14px;
}

/* ------------------ RESPONSIVENESS ------------------ */

/* Tablet view (≤1024px) */
@media (max-width: 1024px) {
    .perceptron-container {
        gap: 30px;
        flex-direction: column;
        text-align: center;
    }
    .perceptron-text, 
    .perceptron-visual {
        width: 90%;
    }
    .row {
        flex-direction: column;
        gap: 20px;
    }
    .row p, .row ul, .row .formula {
        width: 100%;
    }
}

/* Mobile view (≤768px) */
@media (max-width: 768px) {
    #title {
        font-size: 2.2rem;
    }

    section {
        padding: 25px 20px;
    }

    .perceptron-container {
        flex-direction: column;
        align-items: center;
        gap: 24px;
    }

    .perceptron-text, 
    .perceptron-visual {
        width: 100%;
        text-align: center;
    }

    .diagram-box {
        width: 100%;
        padding: 15px;
    }

    .example-container {
        padding: 18px;
        margin: 25px auto;
        width: 90%;
    }

    nav {
        flex-direction: column;
        height: auto;
        padding: 10px 20px;
        gap: 8px;
    }

    .nav-right {
        flex-wrap: wrap;
        justify-content: center;
        gap: 18px;
    }
}

/* Extra small (≤480px) */
@media (max-width: 480px) {
    #title { font-size: 1.8rem; }
    #subtitle { font-size: 0.95rem; }
    .perceptron-text { font-size: 14px; line-height: 1.5; }
    .diagram-box { padding: 12px; }
}
/* ------------------ TEXT RESPONSIVENESS FIX ------------------ */

html {
    font-size: 16px;
}

@media (max-width: 1024px) { html { font-size: 15px; } }
@media (max-width: 768px) { html { font-size: 14px; } }
@media (max-width: 480px) { html { font-size: 13px; } }

#title {
    font-size: clamp(1.8rem, 6vw, 3rem);
}

#subtitle {
    font-size: clamp(0.9rem, 3.5vw, 1.2rem);
}

p, li, .scene-desc, .perceptron-text {
    font-size: clamp(0.9rem, 2.8vw, 1rem);
    line-height: 1.7;
}

.scene-box h3 {
    font-size: clamp(1.1rem, 3.5vw, 1.5rem);
}

.math-section, .math-section1 {
    font-size: clamp(0.9rem, 2.5vw, 1rem);
}
@media (max-width: 600px) {
    .scene-box {
        padding: 18px;
        font-size: 0.95rem;
    }

    .math-toggle-text {
        font-size: 0.95rem;
    }

    .update-formula {
        font-size: 0.9rem;
    }
}
