/* ===============================================
   TRANSFORMER ILUSTRADO CON GATITOS - CSS
   Estilo inspirado en Jay Alammar's Illustrated Transformer
   =============================================== */

/* Variables */
:root {
    --bg-dark: #0a0a0f;
    --bg-section: #12121a;
    --bg-card: #1a1a2e;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --accent-1: #00f5d4;
    --accent-2: #7b2cbf;
    --accent-3: #f72585;
    --accent-4: #4cc9f0;
    --accent-5: #fee440;
    --encoder-color: #4cc9f0;
    --decoder-color: #f72585;
    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-2: linear-gradient(135deg, #f72585 0%, #7209b7 100%);
    --gradient-3: linear-gradient(135deg, #00f5d4 0%, #00bbf9 100%);
    --gradient-neon: linear-gradient(90deg, #00f5d4, #7b2cbf, #f72585, #fee440, #00f5d4);
    --font-main: 'Space Grotesk', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --shadow-glow: 0 0 30px rgba(0, 245, 212, 0.3);
    --shadow-pink: 0 0 30px rgba(247, 37, 133, 0.3);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow-x: hidden;
    line-height: 1.6;
}

/* ===============================================
   PARTICLES BACKGROUND
   =============================================== */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--accent-1);
    border-radius: 50%;
    animation: float-particle 15s infinite;
    opacity: 0.3;
}

@keyframes float-particle {
    0%, 100% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% { opacity: 0.5; }
    90% { opacity: 0.5; }
    100% {
        transform: translateY(-100vh) rotate(720deg);
        opacity: 0;
    }
}

/* ===============================================
   FLOATING NAVIGATION
   =============================================== */
.floating-nav {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
    background: rgba(26, 26, 46, 0.9);
    padding: 15px 10px;
    border-radius: 30px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-dot {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    text-decoration: none;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: transparent;
}

.nav-dot:hover,
.nav-dot.active {
    background: var(--gradient-3);
    transform: scale(1.15);
    box-shadow: var(--shadow-glow);
}

/* ===============================================
   SECTIONS
   =============================================== */
.section {
    min-height: 100vh;
    padding: 80px 20px;
    position: relative;
    z-index: 1;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
}

.dark-section {
    background: var(--bg-section);
}

/* ===============================================
   HERO SECTION
   =============================================== */
.hero {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a0f 100%);
    overflow: hidden;
}

.hero-bg {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
}

.floating-cat {
    position: absolute;
    font-size: 4rem;
    animation: float-cat 8s ease-in-out infinite;
    opacity: 0.4;
}

.floating-cat.c1 { top: 10%; left: 10%; animation-delay: 0s; }
.floating-cat.c2 { top: 20%; right: 15%; animation-delay: 1.5s; }
.floating-cat.c3 { bottom: 30%; left: 20%; animation-delay: 3s; }
.floating-cat.c4 { bottom: 20%; right: 10%; animation-delay: 4.5s; }
.floating-cat.c5 { top: 50%; left: 5%; animation-delay: 6s; }

@keyframes float-cat {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-30px) rotate(5deg); }
}

/* Glitch Effect */
.glitch {
    font-size: clamp(3rem, 10vw, 7rem);
    font-weight: 700;
    text-transform: uppercase;
    position: relative;
    text-shadow: 0.05em 0 0 var(--accent-3), -0.05em -0.025em 0 var(--accent-4);
    animation: glitch 725ms infinite;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch::before {
    left: 2px;
    text-shadow: -2px 0 var(--accent-3);
    clip: rect(24px, 550px, 90px, 0);
    animation: glitch-anim 2s infinite linear alternate-reverse;
}

.glitch::after {
    left: -2px;
    text-shadow: -2px 0 var(--accent-4);
    clip: rect(85px, 550px, 140px, 0);
    animation: glitch-anim 2s infinite linear alternate-reverse;
    animation-delay: -1s;
}

@keyframes glitch {
    0% { text-shadow: 0.05em 0 0 var(--accent-3), -0.05em -0.025em 0 var(--accent-4); }
    14% { text-shadow: 0.05em 0 0 var(--accent-3), -0.05em -0.025em 0 var(--accent-4); }
    15% { text-shadow: -0.05em -0.025em 0 var(--accent-3), 0.025em 0.025em 0 var(--accent-4); }
    49% { text-shadow: -0.05em -0.025em 0 var(--accent-3), 0.025em 0.025em 0 var(--accent-4); }
    50% { text-shadow: 0.025em 0.05em 0 var(--accent-3), 0.05em 0 0 var(--accent-4); }
    99% { text-shadow: 0.025em 0.05em 0 var(--accent-3), 0.05em 0 0 var(--accent-4); }
    100% { text-shadow: -0.025em 0 0 var(--accent-3), -0.025em -0.025em 0 var(--accent-4); }
}

@keyframes glitch-anim {
    0% { clip: rect(31px, 9999px, 94px, 0); }
    20% { clip: rect(12px, 9999px, 47px, 0); }
    40% { clip: rect(48px, 9999px, 73px, 0); }
    60% { clip: rect(72px, 9999px, 34px, 0); }
    80% { clip: rect(18px, 9999px, 52px, 0); }
    100% { clip: rect(85px, 9999px, 42px, 0); }
}

.subtitle {
    font-size: 1.8rem;
    color: var(--text-secondary);
    margin: 15px 0 30px;
}

.intro-text {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 40px;
}

.intro-text a {
    color: var(--accent-1);
    text-decoration: none;
}

.intro-text a:hover {
    text-decoration: underline;
}

/* Hero Cards */
.hero-cards {
    display: flex;
    gap: 25px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 30px 0;
}

.hero-card {
    background: var(--bg-card);
    padding: 25px 35px;
    border-radius: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.big-emoji {
    font-size: 3rem;
}

.pulse-border {
    animation: pulse-border 2s infinite;
}

.pulse-border.delay-1 { animation-delay: 0.5s; }
.pulse-border.delay-2 { animation-delay: 1s; }

@keyframes pulse-border {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 245, 212, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(0, 245, 212, 0); }
}

/* Scroll Indicator */
.scroll-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    margin-top: 40px;
}

.scroll-indicator svg {
    width: 30px;
    height: 30px;
    stroke: var(--accent-1);
    stroke-width: 2;
    fill: none;
}

.bounce {
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-15px); }
    60% { transform: translateY(-8px); }
}

/* ===============================================
   SECTION TITLES
   =============================================== */
.section-title {
    font-size: clamp(1.8rem, 5vw, 3rem);
    text-align: center;
    margin-bottom: 40px;
}

.emoji-bg {
    font-size: 1.2em;
    margin-right: 15px;
    animation: wiggle 2s infinite;
}

@keyframes wiggle {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

.section-intro {
    text-align: center;
    font-size: 1.2rem;
    color: var(--text-secondary);
    max-width: 800px;
    margin: 0 auto 40px;
    line-height: 1.8;
}

/* ===============================================
   DIAGRAM CONTAINERS & SVG
   =============================================== */
.diagram-container {
    margin: 40px 0;
    overflow-x: auto;
}

.diagram-container h3 {
    text-align: center;
    margin-bottom: 25px;
    font-size: 1.4rem;
}

/* SVG Base Styles */
svg {
    display: block;
    margin: 0 auto;
}

.blackbox-svg,
.encoder-decoder-svg,
.embeddings-svg,
.party-svg,
.waves-svg,
.full-diagram {
    width: 100%;
    max-width: 900px;
    height: auto;
}

/* SVG Text Styles */
.diagram-text {
    font-family: var(--font-main);
    font-size: 16px;
    fill: var(--text-primary);
    text-anchor: middle;
}

.diagram-subtext {
    font-family: var(--font-main);
    font-size: 12px;
    fill: var(--text-secondary);
    text-anchor: middle;
}

/* Input/Output Boxes */
.input-box {
    fill: rgba(76, 201, 240, 0.2);
    stroke: var(--encoder-color);
    stroke-width: 2;
}

.output-box {
    fill: rgba(247, 37, 133, 0.2);
    stroke: var(--decoder-color);
    stroke-width: 2;
}

.transformer-box {
    fill: var(--bg-card);
    stroke: var(--accent-1);
    stroke-width: 3;
    filter: drop-shadow(0 0 20px rgba(0, 245, 212, 0.3));
}

.transformer-label {
    font-size: 32px;
    text-anchor: middle;
}

.transformer-text {
    font-family: var(--font-main);
    font-size: 18px;
    font-weight: 700;
    fill: var(--accent-1);
    text-anchor: middle;
}

.transformer-subtext {
    font-family: var(--font-main);
    font-size: 12px;
    fill: var(--text-secondary);
    text-anchor: middle;
}

/* Arrows */
.arrow-line {
    stroke: var(--accent-1);
    stroke-width: 3;
    stroke-linecap: round;
}

.arrow-head {
    fill: var(--accent-1);
}

/* ===============================================
   EXPLANATION BOXES
   =============================================== */
.explanation-box {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 30px;
    margin: 30px 0;
    display: flex;
    gap: 25px;
    align-items: flex-start;
}

.explanation-box.cat-box {
    border-left: 4px solid var(--accent-1);
}

.cat-icon {
    font-size: 3rem;
    flex-shrink: 0;
}

.explanation-content h3 {
    margin-bottom: 15px;
    color: var(--accent-1);
}

.explanation-content p {
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.8;
}

.highlight-text {
    background: rgba(0, 245, 212, 0.1);
    padding: 15px 20px;
    border-radius: 10px;
    color: var(--text-primary) !important;
    margin-top: 15px;
}

/* ===============================================
   ENCODER-DECODER SECTION
   =============================================== */
.encoder-decoder-svg .stack-title {
    font-family: var(--font-main);
    font-size: 20px;
    font-weight: 700;
    text-anchor: middle;
}

.encoder-decoder-svg .stack-subtitle {
    font-family: var(--font-main);
    font-size: 12px;
    fill: var(--text-secondary);
    text-anchor: middle;
}

.encoder-rect {
    fill: rgba(76, 201, 240, 0.15);
    stroke: var(--encoder-color);
    stroke-width: 2;
    rx: 10;
}

.decoder-rect {
    fill: rgba(247, 37, 133, 0.15);
    stroke: var(--decoder-color);
    stroke-width: 2;
    rx: 10;
}

.encoder-block,
.decoder-block {
    animation: blockFadeIn 0.5s ease-out forwards;
    animation-delay: calc(var(--delay, 0) * 0.1s);
    opacity: 0;
}

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

.block-text {
    font-family: var(--font-main);
    font-size: 14px;
    fill: var(--text-primary);
    text-anchor: middle;
}

.curved-arrow {
    stroke: var(--accent-1);
    stroke-width: 3;
    stroke-dasharray: 5 5;
    animation: dashMove 1s linear infinite;
}

@keyframes dashMove {
    to { stroke-dashoffset: -10; }
}

.connection-label {
    font-family: var(--font-main);
    font-size: 14px;
    fill: var(--accent-1);
    text-anchor: middle;
}

.input-label,
.output-label {
    font-family: var(--font-main);
    font-size: 16px;
    fill: var(--text-primary);
    text-anchor: middle;
}

/* Two Columns Layout */
.two-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin: 40px 0;
}

@media (max-width: 768px) {
    .two-columns {
        grid-template-columns: 1fr;
    }
}

.column-card {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 20px;
}

.column-card.encoder-card {
    border-top: 4px solid var(--encoder-color);
}

.column-card.decoder-card {
    border-top: 4px solid var(--decoder-color);
}

.column-card h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.card-subtitle {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.column-card ul {
    list-style: none;
    margin: 20px 0;
}

.column-card li {
    padding: 8px 0;
    font-size: 1.1rem;
}

.analogy {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 10px;
    margin-top: 20px;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* Key Insight Box */
.key-insight {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    background: linear-gradient(135deg, rgba(0, 245, 212, 0.1), rgba(123, 44, 191, 0.1));
    padding: 25px;
    border-radius: 15px;
    margin-top: 40px;
    border: 1px solid rgba(0, 245, 212, 0.3);
}

.insight-icon {
    font-size: 2.5rem;
    animation: bounce 2s infinite;
}

.insight-content strong {
    display: block;
    margin-bottom: 10px;
    font-size: 1.2rem;
}

/* ===============================================
   EMBEDDINGS SECTION
   =============================================== */
.embeddings-svg .word-box {
    fill: var(--bg-card);
    stroke: var(--accent-4);
    stroke-width: 2;
}

.embeddings-svg .word-box.cat-word {
    stroke: var(--accent-1);
    stroke-width: 3;
}

.word-text {
    font-family: var(--font-main);
    font-size: 18px;
    fill: var(--text-primary);
    text-anchor: middle;
}

.embed-arrow {
    stroke: var(--accent-1);
    stroke-width: 2;
    stroke-dasharray: 4 4;
}

.vector-box {
    fill: rgba(123, 44, 191, 0.2);
    stroke: var(--accent-2);
    stroke-width: 2;
}

.vector-box.cat-vector {
    stroke: var(--accent-1);
    fill: rgba(0, 245, 212, 0.1);
}

.vector-label {
    font-family: var(--font-mono);
    font-size: 12px;
    fill: var(--text-secondary);
    text-anchor: middle;
}

.vector-num {
    font-family: var(--font-mono);
    font-size: 14px;
    fill: var(--accent-1);
    text-anchor: middle;
}

.vector-dots {
    font-family: var(--font-mono);
    font-size: 16px;
    fill: var(--text-secondary);
    text-anchor: middle;
}

.embedding-group {
    animation: embedFadeIn 0.6s ease-out forwards;
    animation-delay: calc(var(--delay, 0) * 0.3s);
    opacity: 0;
}

@keyframes embedFadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.explanation-rect {
    fill: var(--bg-card);
    stroke: var(--accent-5);
    stroke-width: 2;
}

.explanation-title {
    font-family: var(--font-main);
    font-size: 16px;
    font-weight: 700;
    fill: var(--accent-5);
    text-anchor: middle;
}

/* Similarity Demo */
.similarity-demo {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 20px;
    margin-top: 40px;
}

.similarity-demo h3 {
    text-align: center;
    margin-bottom: 25px;
}

.similarity-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 500px;
    margin: 0 auto;
}

.similarity-pair {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pair-words {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    font-size: 1.2rem;
}

.similarity-arrow {
    font-size: 1.5rem;
}

.similarity-bar {
    height: 12px;
    border-radius: 6px;
    background: var(--bg-dark);
    overflow: hidden;
    position: relative;
}

.similarity-bar::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    border-radius: 6px;
    animation: barGrow 1s ease-out forwards;
}

.similarity-bar.high::after {
    width: 95%;
    background: var(--accent-1);
}

.similarity-bar.medium::after {
    width: 65%;
    background: var(--accent-5);
}

.similarity-bar.low::after {
    width: 12%;
    background: var(--accent-3);
}

@keyframes barGrow {
    from { width: 0; }
}

.similarity-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
}

/* ===============================================
   SELF-ATTENTION SECTION
   =============================================== */
.example-sentence {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 20px;
    margin-bottom: 40px;
}

.example-sentence h3 {
    text-align: center;
    margin-bottom: 25px;
}

.sentence-display {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
}

.sentence-display .word {
    background: var(--bg-dark);
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 1.1rem;
}

.sentence-display .highlight-word {
    background: rgba(0, 245, 212, 0.3);
    border: 2px solid var(--accent-1);
}

.sentence-display .attention-source {
    background: rgba(247, 37, 133, 0.3);
    border: 2px solid var(--accent-3);
    font-weight: 700;
}

.attention-lines svg {
    width: 100%;
    max-width: 800px;
    height: 60px;
}

.attention-line {
    stroke: var(--accent-1);
    stroke-width: 3;
    fill: none;
    opacity: 0;
    animation: lineAppear 1s ease-out 0.5s forwards;
}

@keyframes lineAppear {
    to { opacity: 1; }
}

.attention-source-dot {
    fill: var(--accent-3);
}

.attention-target-dot {
    fill: var(--accent-1);
}

.attention-explanation {
    text-align: center;
    color: var(--text-secondary);
    margin-top: 20px;
    font-size: 1.1rem;
}

/* Attention Steps */
.attention-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-top: 30px;
}

.attention-step {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 15px;
    position: relative;
}

.step-number {
    width: 40px;
    height: 40px;
    background: var(--gradient-2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    margin-bottom: 15px;
}

.step-content h4 {
    margin-bottom: 15px;
    color: var(--accent-1);
}

/* QKV Mini Display */
.qkv-mini {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 15px;
}

.qkv-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-dark);
    padding: 10px 15px;
    border-radius: 8px;
}

.qkv-icon {
    font-size: 1.3rem;
}

.qkv-label {
    font-weight: 600;
    min-width: 60px;
}

.qkv-question {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Softmax Demo */
.softmax-demo {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 15px;
}

.softmax-bar {
    background: var(--bg-dark);
    border-radius: 5px;
    padding: 8px 12px;
    position: relative;
    overflow: hidden;
}

.softmax-bar::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: var(--percent);
    background: var(--gradient-3);
    opacity: 0.3;
    border-radius: 5px;
}

.softmax-bar span {
    position: relative;
    z-index: 1;
    font-size: 0.9rem;
}

.result-text {
    color: var(--accent-1);
    font-weight: 600;
    margin-top: 10px;
}

/* ===============================================
   QKV DETAILED SECTION
   =============================================== */
.party-analogy {
    margin: 40px 0;
}

.party-scene {
    overflow-x: auto;
}

.party-svg {
    min-width: 700px;
}

.cat-circle {
    transition: all 0.3s ease;
}

.cat-circle.query-circle {
    fill: rgba(247, 37, 133, 0.2);
    stroke: var(--accent-3);
    stroke-width: 3;
}

.cat-circle.key-circle {
    fill: rgba(76, 201, 240, 0.2);
    stroke: var(--accent-4);
    stroke-width: 2;
}

.cat-circle.key-circle.match {
    fill: rgba(0, 245, 212, 0.3);
    stroke: var(--accent-1);
    stroke-width: 3;
    filter: drop-shadow(0 0 15px rgba(0, 245, 212, 0.5));
}

.cat-emoji {
    font-size: 24px;
    text-anchor: middle;
}

.cat-emoji.small {
    font-size: 18px;
}

.cat-name {
    font-family: var(--font-main);
    font-size: 14px;
    fill: var(--text-primary);
    text-anchor: middle;
}

.cat-name.small {
    font-size: 12px;
}

.cat-thought {
    font-family: var(--font-main);
    font-size: 12px;
    text-anchor: middle;
}

.query-thought {
    fill: var(--accent-3);
}

.key-thought {
    fill: var(--accent-1);
}

.att-arrow {
    stroke-width: 2;
    stroke-linecap: round;
}

.att-arrow.strong {
    stroke: var(--accent-1);
    stroke-width: 4;
}

.att-arrow.medium {
    stroke: var(--accent-5);
    stroke-width: 2;
}

.att-arrow.weak {
    stroke: var(--text-secondary);
    stroke-width: 1;
    stroke-dasharray: 4 4;
}

.match-label {
    font-family: var(--font-main);
    font-size: 12px;
    fill: var(--accent-1);
    text-anchor: middle;
}

.score-label {
    font-family: var(--font-mono);
    font-size: 11px;
    fill: var(--text-secondary);
}

.result-box {
    fill: var(--bg-card);
    stroke: var(--accent-1);
    stroke-width: 2;
    rx: 20;
}

.result-title {
    font-family: var(--font-main);
    font-size: 18px;
    font-weight: 700;
    fill: var(--accent-1);
    text-anchor: middle;
}

.result-formula {
    font-family: var(--font-mono);
    font-size: 14px;
    fill: var(--text-primary);
    text-anchor: middle;
}

.result-conclusion {
    font-family: var(--font-main);
    font-size: 14px;
    fill: var(--accent-1);
    text-anchor: middle;
}

/* QKV Cards */
.qkv-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin: 40px 0;
}

.qkv-card {
    background: var(--bg-card);
    border-radius: 20px;
    overflow: hidden;
}

.qkv-header {
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.qkv-card.query-card .qkv-header {
    background: linear-gradient(135deg, rgba(247, 37, 133, 0.3), rgba(123, 44, 191, 0.3));
}

.qkv-card.key-card .qkv-header {
    background: linear-gradient(135deg, rgba(76, 201, 240, 0.3), rgba(0, 187, 249, 0.3));
}

.qkv-card.value-card .qkv-header {
    background: linear-gradient(135deg, rgba(0, 245, 212, 0.3), rgba(123, 44, 191, 0.3));
}

.qkv-big-icon {
    font-size: 2.5rem;
}

.qkv-header h3 {
    font-size: 1.3rem;
}

.qkv-body {
    padding: 25px;
}

.qkv-definition {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 20px;
}

.qkv-example {
    background: var(--bg-dark);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.qkv-example strong {
    color: var(--accent-1);
}

.qkv-math {
    font-family: var(--font-mono);
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
}

.qkv-math code {
    color: var(--accent-1);
}

/* Formula Section */
.formula-section {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    margin-top: 40px;
}

.formula-section h3 {
    margin-bottom: 30px;
    font-size: 1.5rem;
}

.big-formula {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    background: var(--bg-dark);
    padding: 30px;
    border-radius: 15px;
    display: inline-block;
    margin-bottom: 30px;
}

.formula-text {
    color: var(--text-primary);
}

.fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    margin: 0 8px;
}

.numerator {
    border-bottom: 2px solid var(--accent-1);
    padding-bottom: 5px;
    color: var(--accent-1);
}

.denominator {
    padding-top: 5px;
    color: var(--accent-4);
}

.formula-explanation {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
}

.formula-step {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-dark);
    padding: 12px 20px;
    border-radius: 10px;
}

.step-emoji {
    font-size: 1.3rem;
}

/* ===============================================
   MULTI-HEAD ATTENTION SECTION
   =============================================== */
.multihead-visual {
    text-align: center;
    margin: 40px 0;
}

.input-word-mh {
    margin-bottom: 30px;
}

.word-label {
    background: var(--bg-card);
    padding: 15px 30px;
    border-radius: 10px;
    font-size: 1.2rem;
    display: inline-block;
}

.heads-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin: 30px 0;
}

.head-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    animation: headAppear 0.5s ease-out forwards;
    animation-delay: calc(var(--hue, 0) * 2ms);
    opacity: 0;
}

@keyframes headAppear {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

.head-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, hsl(var(--hue), 70%, 40%), hsl(var(--hue), 70%, 60%));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 0 25px hsla(var(--hue), 70%, 50%, 0.5);
    animation: headPulse 2s infinite;
    animation-delay: calc(var(--hue, 0) * 5ms);
}

@keyframes headPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.head-emoji {
    font-size: 1.8rem;
}

.head-num {
    position: absolute;
    bottom: -5px;
    right: -5px;
    width: 24px;
    height: 24px;
    background: var(--bg-dark);
    border-radius: 50%;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.head-info {
    text-align: center;
}

.head-info strong {
    display: block;
    font-size: 0.9rem;
}

.head-info span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Concat Section */
.concat-section {
    margin-top: 30px;
}

.concat-arrow {
    font-size: 2rem;
    margin-bottom: 15px;
}

.concat-box {
    background: var(--gradient-3);
    color: #000;
    padding: 20px 40px;
    border-radius: 15px;
    display: inline-block;
}

.concat-box span {
    display: block;
}

.concat-size {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    margin-top: 5px;
}

/* Multi-Head Example */
.multihead-example {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 20px;
    margin-top: 40px;
}

.multihead-example h3 {
    text-align: center;
    margin-bottom: 25px;
}

.example-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.example-head {
    background: var(--bg-dark);
    padding: 20px;
    border-radius: 15px;
    text-align: center;
}

.head-label {
    background: linear-gradient(135deg, hsl(var(--hue), 70%, 40%), hsl(var(--hue), 70%, 60%));
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    display: inline-block;
    margin-bottom: 15px;
}

.attention-viz {
    margin: 15px 0;
}

.source-word {
    background: var(--accent-3);
    color: #000;
    padding: 8px 15px;
    border-radius: 8px;
    display: inline-block;
    margin-bottom: 10px;
    font-weight: 600;
}

.target-words {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.target {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
}

.target.high {
    background: var(--accent-1);
    color: #000;
    font-weight: 600;
}

.target.medium {
    background: rgba(0, 245, 212, 0.4);
}

.target.low {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
}

.example-head p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 10px;
}

/* ===============================================
   POSITIONAL ENCODING SECTION
   =============================================== */
.position-problem {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 20px;
    margin-bottom: 40px;
}

.position-problem h3 {
    text-align: center;
    margin-bottom: 25px;
}

.problem-examples {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

@media (max-width: 600px) {
    .problem-examples {
        grid-template-columns: 1fr;
    }
}

.problem-example {
    padding: 25px;
    border-radius: 15px;
    text-align: center;
}

.problem-example.wrong {
    background: rgba(247, 37, 133, 0.1);
    border: 2px solid var(--accent-3);
}

.problem-example.right {
    background: rgba(0, 245, 212, 0.1);
    border: 2px solid var(--accent-1);
}

.example-emoji {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 15px;
}

.word-bag,
.word-sequence {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 15px 0;
}

.word-bag span,
.word-sequence span {
    background: var(--bg-dark);
    padding: 10px 15px;
    border-radius: 8px;
}

.word-sequence span sup {
    color: var(--accent-1);
    font-weight: 700;
}

.problem-result {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 10px;
}

/* Position Solution */
.position-solution {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 20px;
    margin-bottom: 40px;
}

.position-solution h3 {
    text-align: center;
    margin-bottom: 25px;
}

.waves-container {
    margin: 25px 0;
    overflow-x: auto;
}

.waves-svg {
    min-width: 600px;
}

.sin-wave {
    fill: none;
    stroke: var(--accent-1);
    stroke-width: 3;
    stroke-linecap: round;
    animation: waveDraw 2s ease-out forwards;
}

.cos-wave {
    fill: none;
    stroke: var(--accent-3);
    stroke-width: 3;
    stroke-linecap: round;
    animation: waveDraw 2s ease-out 0.5s forwards;
    opacity: 0;
}

@keyframes waveDraw {
    from {
        stroke-dasharray: 1000;
        stroke-dashoffset: 1000;
        opacity: 0;
    }
    to {
        stroke-dashoffset: 0;
        opacity: 1;
    }
}

.marker-circle {
    fill: var(--accent-2);
}

.marker-text {
    fill: white;
    font-family: var(--font-main);
    font-size: 12px;
    font-weight: 700;
    text-anchor: middle;
}

.position-formula {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 600px;
    margin: 0 auto;
}

.formula-item {
    background: var(--bg-dark);
    padding: 15px 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.formula-label {
    color: var(--text-secondary);
    min-width: 140px;
}

.formula-item code {
    font-family: var(--font-mono);
    color: var(--accent-1);
    font-size: 0.95rem;
}

/* Position Visual */
.position-visual {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 20px;
    margin-bottom: 40px;
}

.position-visual h3 {
    text-align: center;
    margin-bottom: 25px;
}

.addition-demo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.add-item {
    background: var(--bg-dark);
    padding: 20px;
    border-radius: 15px;
    text-align: center;
}

.add-item.embedding-item {
    border: 2px solid var(--accent-4);
}

.add-item.position-item {
    border: 2px solid var(--accent-5);
}

.add-item.result-item {
    border: 2px solid var(--accent-1);
    background: rgba(0, 245, 212, 0.1);
}

.add-label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 0.9rem;
}

.vector-preview {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.add-operator {
    font-size: 2rem;
    color: var(--accent-1);
    font-weight: 700;
}

/* Cat Analogy */
.cat-analogy {
    display: flex;
    align-items: center;
    gap: 25px;
    background: linear-gradient(135deg, rgba(0, 245, 212, 0.1), rgba(123, 44, 191, 0.1));
    padding: 25px;
    border-radius: 15px;
    border: 1px solid rgba(0, 245, 212, 0.3);
}

.cat-icon-big {
    font-size: 4rem;
}

.analogy-text h4 {
    color: var(--accent-1);
    margin-bottom: 10px;
}

/* ===============================================
   DECODER SECTION
   =============================================== */
.decoder-flow {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.decoder-step-item {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 20px;
}

.step-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.step-icon {
    font-size: 2.5rem;
}

.step-header h3 {
    font-size: 1.4rem;
}

/* Mask Table */
.mask-visual {
    margin: 25px 0;
    overflow-x: auto;
}

.mask-table {
    margin: 0 auto;
    border-collapse: collapse;
}

.mask-table td {
    width: 70px;
    height: 45px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 1.2rem;
}

.mask-table .header {
    background: var(--bg-dark);
    font-weight: 600;
    color: var(--accent-4);
    font-size: 0.9rem;
}

.mask-table .visible {
    background: rgba(0, 245, 212, 0.2);
}

.mask-table .masked {
    background: rgba(247, 37, 133, 0.2);
}

.mask-explanation {
    text-align: center;
    color: var(--text-secondary);
    margin-top: 20px;
}

/* Cross Attention Visual */
.cross-attention-visual {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin: 25px 0;
    flex-wrap: wrap;
}

.cross-side {
    background: var(--bg-dark);
    padding: 20px;
    border-radius: 15px;
    text-align: center;
}

.side-label {
    display: block;
    margin-bottom: 15px;
    font-weight: 600;
    color: var(--text-secondary);
}

.cross-words {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.cross-word {
    padding: 10px 18px;
    border-radius: 8px;
    background: rgba(76, 201, 240, 0.2);
    transition: all 0.3s ease;
}

.cross-word.current {
    background: var(--accent-3);
    color: #000;
    font-weight: 600;
}

.cross-arrows svg {
    width: 100px;
    height: 100px;
}

.cross-arrow-line {
    stroke: var(--accent-1);
    stroke-width: 2;
    fill: none;
    opacity: 0.3;
}

.cross-arrow-line.strong {
    stroke-width: 4;
    opacity: 1;
}

.cross-arrow-line.medium {
    opacity: 0.6;
}

.cross-explanation {
    text-align: center;
    color: var(--text-secondary);
    margin-top: 20px;
}

/* Vocab Probabilities */
.vocab-probs {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 450px;
    margin: 25px auto;
}

.prob-item {
    display: flex;
    align-items: center;
    gap: 15px;
}

.prob-word {
    min-width: 80px;
    font-weight: 600;
    text-align: right;
}

.prob-item .prob-bar {
    flex: 1;
    height: 30px;
    background: var(--bg-dark);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.prob-item .prob-bar::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: calc(var(--prob) * 100%);
    background: var(--gradient-3);
    border-radius: 8px;
    animation: probGrow 1s ease-out forwards;
}

@keyframes probGrow {
    from { width: 0; }
}

.prob-value {
    min-width: 50px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

.selected-output {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 25px;
    font-size: 1.3rem;
}

.selected-output .arrow {
    color: var(--accent-1);
    animation: arrowPulse 1s infinite;
}

@keyframes arrowPulse {
    0%, 100% { opacity: 0.5; transform: translateX(0); }
    50% { opacity: 1; transform: translateX(5px); }
}

.output-word {
    background: var(--gradient-3);
    padding: 12px 25px;
    border-radius: 10px;
    font-weight: 600;
    color: #000;
}

.check {
    color: var(--accent-1);
    font-size: 1.8rem;
}

/* Generation Animation */
.generation-animation {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 20px;
    margin-top: 40px;
}

.generation-animation h3 {
    text-align: center;
    margin-bottom: 25px;
}

.gen-steps {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 600px;
    margin: 0 auto;
}

.gen-step {
    display: flex;
    align-items: center;
    gap: 15px;
    background: var(--bg-dark);
    padding: 15px 20px;
    border-radius: 10px;
    opacity: 0;
    animation: stepAppear 0.5s ease-out forwards;
    animation-delay: calc(var(--step, 1) * 0.3s);
}

.gen-step[data-step="1"] { --step: 1; }
.gen-step[data-step="2"] { --step: 2; }
.gen-step[data-step="3"] { --step: 3; }
.gen-step[data-step="4"] { --step: 4; }
.gen-step[data-step="5"] { --step: 5; }

@keyframes stepAppear {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

.gen-input {
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    flex: 1;
}

.gen-arrow {
    color: var(--accent-1);
    font-size: 1.5rem;
}

.gen-output {
    background: var(--accent-1);
    color: #000;
    padding: 5px 15px;
    border-radius: 5px;
    font-weight: 600;
}

/* ===============================================
   FINAL SECTION
   =============================================== */
.final-section {
    background: linear-gradient(180deg, var(--bg-section) 0%, #1a0a2e 100%);
}

.summary-visual {
    margin: 40px 0;
    overflow-x: auto;
}

.full-diagram {
    min-width: 800px;
}

.summary-box {
    rx: 10;
}

.summary-box.input { fill: rgba(76, 201, 240, 0.2); stroke: var(--encoder-color); stroke-width: 2; }
.summary-box.embed { fill: rgba(123, 44, 191, 0.2); stroke: var(--accent-2); stroke-width: 2; }
.summary-box.pos { fill: rgba(254, 228, 64, 0.2); stroke: var(--accent-5); stroke-width: 2; }
.summary-box.encoder { fill: rgba(76, 201, 240, 0.15); stroke: var(--encoder-color); stroke-width: 3; }
.summary-box.decoder { fill: rgba(247, 37, 133, 0.15); stroke: var(--decoder-color); stroke-width: 3; }
.summary-box.linear { fill: rgba(0, 245, 212, 0.2); stroke: var(--accent-1); stroke-width: 2; }
.summary-box.output { fill: rgba(247, 37, 133, 0.2); stroke: var(--decoder-color); stroke-width: 2; }

.summary-emoji {
    font-size: 20px;
    text-anchor: middle;
}

.summary-text {
    font-family: var(--font-main);
    font-size: 12px;
    font-weight: 600;
    fill: var(--text-primary);
    text-anchor: middle;
}

.summary-subtext {
    font-family: var(--font-main);
    font-size: 10px;
    fill: var(--text-secondary);
    text-anchor: middle;
}

.summary-label {
    font-family: var(--font-main);
    font-size: 11px;
    fill: var(--accent-1);
    text-anchor: middle;
}

.summary-arrow {
    stroke: var(--accent-1);
    stroke-width: 3;
    fill: none;
    marker-end: url(#arrowhead);
}

/* Key Takeaways */
.key-takeaways {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 20px;
    margin: 40px 0;
}

.key-takeaways h3 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.5rem;
}

.takeaway-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
}

.takeaway-item {
    background: var(--bg-dark);
    padding: 25px;
    border-radius: 15px;
    text-align: center;
    transition: transform 0.3s ease;
}

.takeaway-item:hover {
    transform: translateY(-5px);
}

.takeaway-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 15px;
}

.takeaway-item h4 {
    margin-bottom: 10px;
    color: var(--accent-1);
}

.takeaway-item p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Next Steps */
.next-steps {
    text-align: center;
    margin: 40px 0;
}

.next-steps h3 {
    margin-bottom: 25px;
    font-size: 1.5rem;
}

.next-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.next-btn {
    background: var(--bg-card);
    padding: 15px 30px;
    border-radius: 12px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.next-btn:hover {
    border-color: var(--accent-1);
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow);
}

/* Final Message */
.final-message {
    text-align: center;
    padding: 60px 30px;
    position: relative;
}

.final-message h2 {
    font-size: clamp(2rem, 5vw, 3rem);
    margin-bottom: 20px;
}

.rainbow-text {
    background: var(--gradient-neon);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: rainbow 3s linear infinite;
}

@keyframes rainbow {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

.final-message p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 15px;
}

.credits {
    margin-top: 30px;
    font-size: 0.95rem;
}

.credits a {
    color: var(--accent-1);
    text-decoration: none;
}

.credits a:hover {
    text-decoration: underline;
}

/* Confetti */
.confetti {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 20px;
    top: -20px;
    animation: confettiFall 3s linear infinite;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* ===============================================
   RESPONSIVE
   =============================================== */
@media (max-width: 768px) {
    .floating-nav {
        right: 10px;
        padding: 10px 5px;
    }

    .nav-dot {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

    .section {
        padding: 60px 15px;
    }

    .hero-cards {
        flex-direction: column;
        align-items: center;
    }

    .explanation-box {
        flex-direction: column;
        text-align: center;
    }

    .qkv-cards,
    .attention-steps {
        grid-template-columns: 1fr;
    }

    .addition-demo {
        flex-direction: column;
    }

    .add-operator {
        transform: rotate(90deg);
    }

    .cross-attention-visual {
        flex-direction: column;
    }

    .heads-container {
        gap: 15px;
    }

    .head-circle {
        width: 65px;
        height: 65px;
    }

    .head-emoji {
        font-size: 1.4rem;
    }
}

/* ===============================================
   ACCESSIBILITY - Reduced Motion
   =============================================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
