html {
    scroll-behavior: smooth;
}

* {
    box-sizing: border-box;
}

:root {
    --bg-color: #000000;
    --text-color: #ffffff;
    --sub-text: #888888;
    --border-main: #ffffff;
    --border-muted: #222222;
    --key-active: #333333;
    --lamp-active: #ffffff;
    --lamp-inactive: #555555;
    --plug-inactive: #555555;
    --plug-hover: #777777;
    --accent-color: #ffffff;
    --plug-connected: #00ff00;
    --plug-selected: #0088ff;
    --plug-highlight: #ff3333;
}

.light-theme {
    --bg-color: #ffffff;
    --text-color: #000000;
    --sub-text: #888888;
    --border-main: #000000;
    --border-muted: #eeeeee;
    --key-active: #eeeeee;
    --lamp-active: #000000;
    --lamp-inactive: #bbbbbb;
    --plug-inactive: #bbbbbb;
    --plug-hover: #999999;
    --accent-color: #000000;
    --plug-connected: #006600;
    --plug-selected: #004488;
    --plug-highlight: #aa0000;
}

body {
    font-family: 'Courier Prime', 'Courier New', Courier, monospace;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    min-height: 100vh;
}

.top-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 15px;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1s;
}

.control-btn {
    background: var(--bg-color);
    border: 1px solid var(--text-color);
    border-radius: 50%;
    color: var(--text-color);
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Courier Prime', monospace;
}

.theme-toggle {
    font-size: 24px;
    padding-bottom: 2px;
    /* Optical adjustment for the sun/moon char */
}

#langBtn {
    font-size: 14px;
    font-weight: 700;
}

.control-btn:hover {
    transform: scale(1.1);
    background: rgba(128, 128, 128, 0.1);
}

/* 1. Welcome Section */
.welcome-section {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    text-align: center;
    overflow: hidden;
    background-color: var(--bg-color);
}

.hero-title {
    font-size: min(120px, 15vw);
    letter-spacing: min(40px, 5vw);
    text-indent: min(40px, 5vw);
    margin: 0;
    font-weight: 700;
    opacity: 0;
    font-family: 'Courier Prime', monospace;
}

.title-visible {
    opacity: 1;
    transition: opacity 1s ease-in;
}

.subtitle-container {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 20px;
    flex-wrap: wrap;
}

.hero-subtitle {
    font-size: 1.5rem;
    letter-spacing: 0.5rem;
    text-indent: 0.5rem;
    color: var(--sub-text);
    min-height: 1.5rem;
    font-weight: 300;
    text-transform: uppercase;
    margin: 0;
}

.scroll-arrow {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 60px;
    border: 1px solid var(--text-color);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-decoration: none;
    color: var(--text-color);
    font-size: 24px;
    transition: all 0.3s, opacity 1s;
    animation: bounce 2s infinite;
    opacity: 0;
    pointer-events: none;
}

.scroll-arrow span {
    line-height: 1;
    display: inline-block;
    transform: translateY(11px);
}

.controls-visible {
    opacity: 1 !important;
    pointer-events: all !important;
}

.scroll-arrow:hover {
    border-color: var(--border-main);
    background: rgba(255, 255, 255, 0.05);
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

    40% {
        transform: translateX(-50%) translateY(-10px);
    }

    60% {
        transform: translateX(-50%) translateY(-5px);
    }
}

/* Parallax Spacer Section */
.parallax-section {
    height: 60vh;
    background-image: url('assets/enigma.jpg');
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    border-top: 1px solid var(--border-muted);
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.parallax-section-2 {
    height: 60vh;
    background-image: url('assets/2.png');
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    border-top: 1px solid var(--border-muted);
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.home-btn {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 60px;
    height: 60px;
    background: var(--bg-color);
    border: 1px solid var(--text-color);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-decoration: none;
    color: var(--text-color);
    font-size: 24px;
    transition: all 0.3s, opacity 0.5s;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
}

.home-btn span {
    line-height: 1;
    display: inline-block;
    transform: translateY(-2px);
}

.home-btn.visible {
    opacity: 1;
    pointer-events: all;
}

.home-btn:hover {
    border-color: var(--border-main);
    background: rgba(255, 255, 255, 0.05);
    transform: scale(1.1);
}

/* 2. History Section */
.history-section {
    min-height: 100vh;
    padding: 120px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-color);
    border-top: 1px solid var(--border-muted);
    border-bottom: 1px solid var(--border-muted);
    position: relative;
}

.history-content {
    max-width: 800px;
    width: 100%;
}

.history-content h2 {
    font-size: 24px;
    letter-spacing: 12px;
    color: var(--sub-text);
    margin-bottom: 60px;
    text-align: center;
    text-transform: uppercase;
    font-weight: 300;
}

.history-text {
    line-height: 1.8;
    color: var(--text-color);
    font-size: 16px;
    text-align: justify;
}

.history-text p {
    margin-bottom: 30px;
}

/* Project Section */
.project-section {
    min-height: 100vh;
    padding: 120px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-color);
    border-top: 1px solid var(--border-muted);
    position: relative;
}

.project-content {
    max-width: 1000px;
    width: 100%;
}

.project-content h2 {
    font-size: 24px;
    letter-spacing: 12px;
    color: var(--sub-text);
    margin-bottom: 80px;
    text-align: center;
    text-transform: uppercase;
    font-weight: 300;
}

.project-grid {
    display: flex;
    flex-direction: column;
    gap: 100px;
}

.project-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
    text-align: center;
}

.project-item p {
    line-height: 1.8;
    color: var(--text-color);
    font-size: 18px;
    max-width: 700px;
}

.project-img {
    width: 100%;
    max-width: 800px;
    height: auto;
    border: 1px solid var(--border-muted);
    filter: grayscale(0.5);
    transition: all 0.5s ease;
}

.project-img:hover {
    filter: grayscale(0);
    border-color: var(--border-main);
    transform: scale(1.02);
}

/* 3. Simulator Section */
.simulator-section {
    min-height: 100vh;
    padding: 120px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--bg-color);
}

.app-header {
    width: 100%;
    max-width: 1000px;
    text-align: center;
    margin-bottom: 80px;
}

.app-header h2 {
    font-size: 24px;
    letter-spacing: 12px;
    color: var(--sub-text);
    margin: 0;
    text-transform: uppercase;
    font-weight: 300;
}

.header-line {
    width: 100px;
    height: 1px;
    background: var(--border-muted);
    margin: 20px auto 0;
}

.content {
    width: 100%;
    max-width: 1000px;
    display: flex;
    flex-direction: column;
    gap: 60px;
}

/* 1. Rotors Section */
.rotor-setup {
    display: flex;
    justify-content: center;
    gap: 60px;
    flex-wrap: wrap;
}

.rotor-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.rotor-column select {
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--border-main);
    padding: 5px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    outline: none;
}

.control-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 15px;
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.label {
    font-size: 9px;
    text-transform: uppercase;
    color: var(--sub-text);
}

.control-group button {
    background: transparent;
    color: var(--text-color);
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 5px;
    opacity: 0;
    transition: opacity 0.2s;
}

.control-group:hover button {
    opacity: 1;
}

.digit {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    border: 1px solid var(--border-main);
    color: var(--text-color);
}

.digit.small {
    width: 25px;
    height: 25px;
    font-size: 14px;
    color: var(--sub-text);
    border: 1px solid var(--border-muted);
    border-radius: 50%;
}

/* 2. Lampboard Section */
.lampboard {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.row {
    display: flex;
    justify-content: center;
    gap: 25px;
}

.lamp {
    width: 45px;
    height: 45px;
    border: 1px solid var(--lamp-inactive);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--lamp-inactive);
    font-weight: bold;
    font-size: 18px;
    transition: all 0.1s;
}

.lamp.active {
    border-color: var(--lamp-active);
    color: var(--lamp-active);
    box-shadow: 0 0 10px var(--lamp-active);
}

/* 3. Keyboard Section */
.keyboard {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.keyboard button {
    width: 50px;
    height: 50px;
    border: 1px solid var(--border-main);
    border-radius: 50%;
    background: transparent;
    color: var(--text-color);
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s, color 0.1s;
    outline: none;
}

.keyboard button:active,
.keyboard button.pressed {
    background: var(--key-active);
}

/* 4. Plugboard Section */
.plugboard-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.section-title {
    text-align: center;
    font-size: 10px;
    color: var(--sub-text);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.plug-row {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.plug {
    width: 32px;
    height: 32px;
    border: 1px solid var(--plug-inactive);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--plug-inactive);
    cursor: pointer;
    transition: all 0.2s;
}

.plug:hover {
    border-color: var(--plug-hover);
    color: var(--plug-hover);
}

.plug-connected {
    border-color: var(--plug-connected);
    color: var(--plug-connected);
}

.light-theme .plug-connected {
    border-width: 2px;
}

.plug-selected {
    border-color: var(--plug-selected);
    color: var(--plug-selected);
}

.light-theme .plug-selected {
    border-width: 2px;
}

.plug-highlight-red {
    border-color: var(--plug-highlight) !important;
    color: var(--plug-highlight) !important;
}

.light-theme .plug-highlight-red {
    border-width: 2px !important;
}

/* 5. Output Log Section */
.message-container {
    border-top: 1px solid var(--border-muted);
    padding-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#messageTape {
    font-size: 18px;
    color: var(--text-color);
    letter-spacing: 2px;
}

.clear-btn {
    background: transparent;
    color: var(--sub-text);
    border: 1px solid var(--border-muted);
    padding: 5px 10px;
    font-size: 10px;
    cursor: pointer;
    font-family: inherit;
    text-transform: uppercase;
}

.clear-btn:hover {
    color: var(--text-color);
    border-color: var(--border-main);
}

/* Contacts Section */
.contacts-section {
    padding: 100px 20px;
    background-color: var(--bg-color);
    text-align: center;
    border-top: 1px solid var(--border-muted);
}

.contacts-content {
    max-width: 800px;
    margin: 0 auto;
}

.contacts-content h2 {
    font-size: min(32px, 8vw);
    letter-spacing: 10px;
    margin-bottom: 20px;
    font-weight: 700;
}

.contacts-content p {
    font-size: 16px;
    line-height: 1.6;
    color: var(--sub-text);
    margin-bottom: 60px;
}

.contacts-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 25px;
    margin-top: 40px;
}

.contacts-links a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 14px;
    letter-spacing: 3px;
    font-weight: 700;
    transition: opacity 0.3s;
}

.contacts-links a:hover {
    opacity: 0.5;
}

.contacts-links .separator {
    color: var(--border-muted);
    font-size: 14px;
}

/* 4. Footer */
.app-footer {
    padding: 40px 20px 40px;
    text-align: center;
    border-top: 1px solid var(--border-muted);
}

.app-footer p {
    font-size: 14px;
    letter-spacing: 2px;
    color: var(--sub-text);
    margin-bottom: 30px;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 30px;
}

.footer-links a {
    color: var(--sub-text);
    text-decoration: none;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--text-color);
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    .hero-title {
        letter-spacing: 15px;
        text-indent: 15px;
    }

    .subtitle-container {
        flex-direction: column;
        gap: 10px;
    }

    .hero-subtitle {
        font-size: 1.1rem;
        letter-spacing: 0.3rem;
        text-indent: 0.3rem;
        height: auto;
        line-height: 1.4;
        margin: 0;
    }

    .parallax-section,
    .parallax-section-2 {
        height: 40vh;
        background-attachment: scroll;
        background-position: center center;
    }

    .history-section,
    .simulator-section,
    .project-section {
        padding: 80px 15px;
    }

    .project-grid {
        gap: 60px;
    }

    .project-item p {
        font-size: 16px;
    }

    .project-content h2 {
        font-size: 18px;
        letter-spacing: 6px;
        margin-bottom: 40px;
    }

    .history-text {
        font-size: 14px;
        text-align: left;
    }

    .history-content h2,
    .app-header h2 {
        font-size: 14px;
        letter-spacing: 6px;
    }

    .digit {
        width: 35px;
        height: 35px;
        font-size: 20px;
    }

    .digit.small {
        width: 20px;
        height: 20px;
        font-size: 11px;
    }

    .row,
    .plug-row {
        gap: 5px;
    }

    .lamp,
    .keyboard button {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    .plug {
        width: 24px;
        height: 24px;
        font-size: 10px;
    }

    .control-group button {
        opacity: 1;
        font-size: 14px;
    }

    #messageTape {
        font-size: 14px;
    }
}

@media (max-width: 400px) {
    .rotor-setup {
        gap: 5px;
    }

    .control-row {
        gap: 5px;
    }

    .lamp,
    .keyboard button {
        width: 25px;
        height: 25px;
        font-size: 12px;
    }

    .plug {
        width: 20px;
        height: 20px;
        font-size: 9px;
    }
}