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

:root {
    /* FVD Color Scheme */
    --primary: #a71c20;
    --primary-dark: #8b1418;
    --primary-light: #c42a2e;
    --accent-red: #a71c20;
    --accent-red-light: #c42a2e;
    --accent-green: #49a636;
    --accent-green-light: #5cb848;
    --public: #49a636;
    --public-light: #e8f5e4;
    --private: #a71c20;
    --private-light: #fce8e8;
    --success: #49a636;
    --success-light: #e8f5e4;
    --bg: rgb(243, 244, 246);
    --card-bg: #ffffff;
    --text: #454545;
    --text-dark: #2d2d2d;
    --text-light: #6b7280;
    --border: #ccc6c6;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
}

body {
    font-family:
        "Segoe UI",
        system-ui,
        -apple-system,
        sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
    padding-top: 1rem;
}

.header-logo {
    display: block;
    margin: 0 auto 1.5rem auto;
    max-width: 200px;
    height: auto;
}

header h1 {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 1.25rem;
    color: var(--text-light);
    font-weight: 300;
}

/* Language Switcher */
.language-switcher {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    gap: 0.5rem;
}

.lang-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.6;
}

.lang-btn:hover {
    opacity: 1;
    border-color: var(--primary);
}

.lang-btn.active {
    opacity: 1;
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.lang-btn svg {
    display: block;
    border-radius: 2px;
}

/* Intro Section */
.intro {
    background: var(--primary);
    color: white;
    padding: 2rem;
    border-radius: 4px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 2rem;
}

.intro h2 {
    margin-bottom: 1rem;
    color: white;
    font-weight: 700;
}

.intro p {
    color: rgba(255, 255, 255, 0.9);
}

.intro .public {
    color: #7de068;
    font-weight: 600;
}

.intro .private {
    color: #ff9999;
    font-weight: 600;
}

.public {
    color: var(--public);
    font-weight: 600;
}

.private {
    color: var(--private);
    font-weight: 600;
}

/* Step Sections */
.step {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 4px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    border-top: 4px solid var(--primary);
}

.step h2 {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    color: var(--text-dark);
    font-weight: 700;
}

.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    background: var(--primary);
    color: white;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 700;
}

.explanation {
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

/* Math Box */
.math-box {
    background: #f9f9f9;
    padding: 1.5rem;
    border-radius: 4px;
    margin-top: 1rem;
    border: 1px solid var(--border);
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-dark);
}

.prime-inputs {
    display: flex;
    gap: 2rem;
}

.prime-inputs select {
    padding: 0.5rem 1rem;
    font-size: 1.25rem;
    border: 2px solid var(--border);
    border-radius: 4px;
    background: white;
    cursor: pointer;
    color: var(--text-dark);
}

.prime-inputs select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Buttons */
.btn {
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn.primary {
    background: var(--primary);
    color: white;
}

.btn.primary:hover {
    background: var(--primary-light);
    box-shadow: var(--shadow);
}

/* Calculation Steps */
.calculation-steps {
    margin-top: 1.5rem;
}

.step-calc {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    border-left: 4px solid var(--primary);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
}

.step-calc h4 {
    color: var(--primary);
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
}

.step-calc.highlight {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.step-calc.highlight h4 {
    color: rgba(255, 255, 255, 0.9);
}

.formula {
    font-family: "Cambria Math", "Times New Roman", serif;
    font-size: 1.25rem;
    margin: 0.5rem 0;
}

.formula.big {
    font-size: 1.75rem;
    text-align: center;
    padding: 0.5rem;
}

.formula.result {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--success);
}

.step-calc.highlight .formula {
    color: white;
}

.step-calc.highlight .formula.result {
    color: #7de068;
}

.note {
    font-size: 0.85rem;
    color: var(--text-light);
    font-style: italic;
}

/* Wikipedia Links */
.wiki-link {
    display: block;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

.wiki-link:hover {
    color: var(--primary-light);
    text-decoration: underline;
}

.step-calc.highlight .wiki-link {
    color: rgba(255, 255, 255, 0.8);
    border-top-color: rgba(255, 255, 255, 0.2);
}

.step-calc.highlight .wiki-link:hover {
    color: white;
}

/* Keys Display */
.keys-display {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 2rem;
}

.key-card {
    padding: 1.5rem;
    border-radius: 4px;
    text-align: center;
    box-shadow: var(--shadow);
}

.key-card.public-key {
    background: linear-gradient(135deg, var(--public-light), #d4edda);
    border: 2px solid var(--public);
}

.key-card.private-key {
    background: linear-gradient(135deg, var(--private-light), #f5c6c6);
    border: 2px solid var(--private);
}

.key-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.key-card h3 {
    margin-bottom: 0.5rem;
    color: var(--text-dark);
    font-weight: 700;
}

.key-value {
    font-family: "Courier New", monospace;
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

.public-key .key-value {
    color: #2d6a1e;
}

.private-key .key-value {
    color: #8b1418;
}

.key-label {
    font-size: 0.9rem;
    color: var(--text-light);
}

.key-desc {
    font-size: 0.85rem;
    margin-top: 0.5rem;
    font-style: italic;
}

/* Scenario */
.scenario {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    padding: 2rem;
    background: linear-gradient(135deg, #e8e8e8, #d4d4d4);
    border-radius: 4px;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.person {
    text-align: center;
}

.avatar {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.name {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-dark);
}

.role {
    font-size: 0.85rem;
    color: var(--text-light);
}

.arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.arrow-line {
    width: 100px;
    height: 4px;
    background: var(--primary);
    position: relative;
}

.arrow-line::after {
    content: "";
    position: absolute;
    right: -8px;
    top: -6px;
    border: 8px solid transparent;
    border-left-color: var(--primary);
}

.arrow-label {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}

/* Message Input */
.message-input {
    padding: 0.75rem 1rem;
    font-size: 1.5rem;
    width: 120px;
    border: 2px solid var(--border);
    border-radius: 4px;
    text-align: center;
}

.message-input:focus {
    outline: none;
    border-color: var(--primary);
}

.message-var {
    margin-left: 1rem;
    font-family: "Courier New", monospace;
    font-size: 1.25rem;
    color: var(--text-dark);
}

/* Transform Visual */
.transform-visual {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1.5rem;
    background: white;
    border-radius: 4px;
    margin-top: 1.5rem;
    border: 1px solid var(--border);
}

.original-msg,
.encrypted-msg {
    padding: 1rem 1.5rem;
    border-radius: 4px;
    text-align: center;
    min-width: 120px;
}

.original-msg {
    background: #e8e8e8;
    border: 2px solid var(--primary);
}

.encrypted-msg {
    background: var(--private-light);
    border: 2px solid var(--private);
}

.original-msg.success {
    background: var(--success-light);
    border-color: var(--success);
}

.transform-visual .label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.transform-visual .value {
    font-size: 2rem;
    font-weight: 700;
    font-family: "Courier New", monospace;
    color: var(--text-dark);
}

.transform-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 1.5rem;
    color: var(--primary);
}

.key-used {
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
}

/* Received Cipher */
.received-cipher {
    text-align: center;
    padding: 1rem;
    background: var(--private-light);
    border-radius: 4px;
    margin-bottom: 1rem;
    border: 1px solid var(--private);
}

.cipher-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--private);
    font-family: "Courier New", monospace;
}

/* Success Message */
.success-message {
    text-align: center;
    color: var(--success);
    font-weight: 700;
    font-size: 1.25rem;
    margin-top: 1rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* Flow Diagram */
.flow-diagram {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.flow-step {
    display: flex;
    justify-content: center;
}

.flow-box {
    background: white;
    padding: 1.5rem;
    border-radius: 4px;
    box-shadow: var(--shadow);
    min-width: 300px;
    text-align: center;
    border: 1px solid var(--border);
}

.flow-box h4 {
    margin-bottom: 1rem;
    color: var(--primary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.9rem;
}

.key-pair {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.flow-key {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 4px;
    font-family: "Courier New", monospace;
}

.flow-key.public {
    background: var(--public-light);
    border: 1px solid var(--public);
}

.flow-key.private {
    background: var(--private-light);
    border: 1px solid var(--private);
}

.flow-connector {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0;
}

.connector-line {
    width: 4px;
    height: 40px;
    background: var(--primary);
}

.connector-line.encrypted-line {
    background: var(--accent-red);
}

.connector-label {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

.flow-person {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.flow-action {
    font-size: 0.9rem;
}

.flow-formula {
    font-family: "Courier New", monospace;
    background: #f9f9f9;
    padding: 0.5rem;
    border-radius: 4px;
    margin-top: 0.5rem;
    border: 1px solid var(--border);
}

.alice-encrypt {
    border: 2px solid var(--public);
}

.bob-decrypt {
    border: 2px solid var(--private);
}

/* Why it Works */
.why-works {
    margin-top: 2rem;
    background: var(--primary);
    color: white;
    padding: 2rem;
    border-radius: 4px;
}

.why-works h3 {
    color: white;
    margin-bottom: 1rem;
    font-weight: 700;
}

.why-works p {
    color: rgba(255, 255, 255, 0.9);
}

.why-works .formula {
    color: white;
}

.math-explanation {
    line-height: 2;
}

.security-note {
    margin-top: 1.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-left: 4px solid var(--accent-red);
    border-radius: 4px;
}

.security-note h4 {
    color: #ff9999;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.security-note p {
    color: rgba(255, 255, 255, 0.85);
}

/* Playground */
.playground-container {
    background: #f9f9f9;
    padding: 2rem;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.playground-input {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.playground-input label {
    font-weight: 500;
    color: var(--text-dark);
}

#playground-slider {
    flex: 1;
    min-width: 200px;
    height: 8px;
    -webkit-appearance: none;
    background: var(--border);
    border-radius: 4px;
    outline: none;
}

#playground-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    background: var(--primary);
    border-radius: 4px;
    cursor: pointer;
}

#playground-msg {
    width: 80px;
    padding: 0.5rem;
    font-size: 1.25rem;
    text-align: center;
    border: 2px solid var(--border);
    border-radius: 4px;
}

#playground-msg:focus {
    outline: none;
    border-color: var(--primary);
}

.playground-results {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.result-box {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 4px;
    text-align: center;
    min-width: 100px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.result-box.encrypted {
    background: var(--private-light);
    border-color: var(--private);
}

.result-box.success {
    background: var(--success-light);
    border-color: var(--success);
}

.result-label {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-family: "Courier New", monospace;
    color: var(--text-dark);
}

.result-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-light);
}

.result-arrow span:first-child {
    font-size: 1.25rem;
}

.playground-details {
    background: white;
    padding: 1rem;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.detail-row {
    display: flex;
    gap: 1rem;
    margin: 0.5rem 0;
    font-family: "Courier New", monospace;
    font-size: 0.9rem;
}

.detail-label {
    font-weight: 600;
    min-width: 100px;
    color: var(--text-dark);
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
    font-size: 0.9rem;
}

footer p {
    margin: 0.25rem 0;
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .keys-display {
        grid-template-columns: 1fr;
    }

    .scenario {
        flex-direction: column;
    }

    .arrow {
        transform: rotate(90deg);
    }

    .transform-visual {
        flex-direction: column;
    }

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

    .playground-results {
        flex-direction: column;
    }

    .result-arrow {
        transform: rotate(90deg);
    }
}
