* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background: #080808;
    color: #ffffff;
    line-height: 1.6;
}

/* Navigation */

.navbar {
    width: 100%;
    padding: 20px 7%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #222;
    position: sticky;
    top: 0;
    background: rgba(8, 8, 8, 0.95);
    z-index: 1000;
}

.logo {
    font-size: 20px;
    font-weight: bold;
}

.logo span {
    color: #ff3b30;
}

.navbar nav {
    display: flex;
    gap: 30px;
}

.navbar nav a {
    color: #cccccc;
    text-decoration: none;
    transition: 0.3s;
}

.navbar nav a:hover {
    color: #ff3b30;
}


/* Hero */

.hero {
    min-height: 90vh;
    padding: 100px 7%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 60px;
}

.hero-content {
    max-width: 700px;
}

.tag {
    color: #ff3b30;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 2px;
    margin-bottom: 20px;
}

.hero h1 {
    font-size: clamp(45px, 6vw, 80px);
    line-height: 1.05;
    margin-bottom: 30px;
}

.hero h1 span {
    color: #ff3b30;
}

.description {
    color: #aaaaaa;
    font-size: 18px;
    max-width: 620px;
    margin-bottom: 35px;
}

.hero-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.btn {
    display: inline-block;
    padding: 14px 25px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: bold;
    transition: 0.3s;
}

.btn.primary {
    background: #ff3b30;
    color: white;
}

.btn.primary:hover {
    background: #ff554b;
    transform: translateY(-2px);
}

.btn.secondary {
    border: 1px solid #444;
    color: white;
}

.btn.secondary:hover {
    border-color: #ff3b30;
    color: #ff3b30;
}


/* Chip Visual */

.hero-visual {
    display: flex;
    justify-content: center;
    align-items: center;
}

.chip {
    width: 280px;
    height: 280px;
    border: 2px solid #333;
    border-radius: 20px;
    background: #101010;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    box-shadow: 0 0 50px rgba(255, 59, 48, 0.12);
}

.chip-title {
    color: #777;
    font-size: 12px;
    letter-spacing: 2px;
    margin-bottom: 30px;
}

.chip-center {
    font-size: 55px;
    font-weight: bold;
    color: #ff3b30;
}

.chip-label {
    margin-top: 10px;
    color: #888;
    letter-spacing: 3px;
}

.chip-lines {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.chip-lines div {
    position: absolute;
    width: 25px;
    height: 2px;
    background: #444;
    left: -25px;
}

.chip-lines div:nth-child(1) {
    top: 25%;
}

.chip-lines div:nth-child(2) {
    top: 40%;
}

.chip-lines div:nth-child(3) {
    top: 60%;
}

.chip-lines div:nth-child(4) {
    top: 75%;
}


/* Simulator */

.simulator-section {
    padding: 100px 7%;
    border-top: 1px solid #222;
}

.section-heading {
    max-width: 700px;
    margin-bottom: 50px;
}

.section-heading h2 {
    font-size: 42px;
    margin-bottom: 15px;
}

.section-heading p:not(.tag) {
    color: #999;
}


/* Module Cards */

.module-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.module-card {
    background: #101010;
    border: 1px solid #252525;
    padding: 30px;
    border-radius: 12px;
    transition: 0.3s;
}

.module-card:hover {
    transform: translateY(-5px);
    border-color: #ff3b30;
}

.module-card.featured {
    border-color: #ff3b30;
}

.module-number {
    color: #ff3b30;
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 25px;
}

.module-card h3 {
    font-size: 24px;
    margin-bottom: 12px;
}

.module-card p {
    color: #999;
    margin-bottom: 25px;
}

.module-card button {
    background: transparent;
    border: 1px solid #444;
    color: white;
    padding: 10px 18px;
    border-radius: 5px;
    cursor: pointer;
    transition: 0.3s;
}

.module-card button:hover {
    background: #ff3b30;
    border-color: #ff3b30;
}


/* About */

.about-section {
    padding: 100px 7%;
    border-top: 1px solid #222;
}

.about-section .section-heading {
    max-width: 800px;
}


/* Footer */

footer {
    padding: 30px 7%;
    border-top: 1px solid #222;
    display: flex;
    justify-content: space-between;
    color: #777;
    font-size: 14px;
}


/* Responsive */

@media (max-width: 900px) {

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

    .hero-content {
        max-width: 800px;
    }

    .description {
        margin-left: auto;
        margin-right: auto;
    }

    .hero-buttons {
        justify-content: center;
    }

    .module-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .navbar {
        padding: 18px 5%;
    }
}


@media (max-width: 600px) {

    .navbar nav {
        display: none;
    }

    .hero {
        padding: 80px 5%;
    }

    .hero h1 {
        font-size: 45px;
    }

    .module-grid {
        grid-template-columns: 1fr;
    }

    .section-heading h2 {
        font-size: 34px;
    }

    footer {
        flex-direction: column;
        gap: 10px;
    }
}
/* ================================
   LOGIC GATE SIMULATOR
================================ */

.gate-panel {
    max-width: 900px;
    margin: 40px auto 0;
    padding: 40px;
    background: #101010;
    border: 1px solid #252525;
    border-radius: 15px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.input-group,
.gate-selector {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.input-group label,
.gate-selector label {
    color: #999;
    font-size: 14px;
    font-weight: bold;
}

.input-group button {
    width: 100%;
    padding: 20px;
    font-size: 30px;
    font-weight: bold;
    background: #080808;
    color: #ff3b30;
    border: 1px solid #444;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.3s;
}

.input-group button:hover {
    border-color: #ff3b30;
    transform: translateY(-2px);
}

.gate-selector {
    grid-column: 1 / -1;
}

.gate-selector select {
    padding: 15px;
    background: #080808;
    color: white;
    border: 1px solid #444;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
}

.gate-selector select:focus {
    outline: none;
    border-color: #ff3b30;
}

.output-box {
    grid-column: 1 / -1;
    text-align: center;
    padding: 30px;
    border: 1px solid #ff3b30;
    border-radius: 10px;
    background: #0b0b0b;
}

.output-label {
    color: #999;
    font-size: 13px;
    letter-spacing: 2px;
    margin-bottom: 10px;
}

#gateOutput {
    font-size: 60px;
    font-weight: bold;
    color: #ff3b30;
}


/* Mobile */

@media (max-width: 600px) {

    .gate-panel {
        grid-template-columns: 1fr;
        padding: 25px;
    }

    .gate-selector {
        grid-column: auto;
    }

    .output-box {
        grid-column: auto;
    }
}
/* ================================
   ALU INPUTS
================================ */

.alu-panel input {
    width: 100%;
    padding: 18px;
    background: #080808;
    color: #ff3b30;
    border: 1px solid #444;
    border-radius: 8px;
    font-size: 24px;
    font-family: monospace;
    font-weight: bold;
    text-align: center;
    letter-spacing: 4px;
}

.alu-panel input:focus {
    outline: none;
    border-color: #ff3b30;
}

.simulate-button,
.reset-button {
    padding: 14px 22px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    transition: 0.3s;
}

.simulate-button {
    background: #ff3b30;
    color: white;
    border: 1px solid #ff3b30;
}

.simulate-button:hover {
    transform: translateY(-2px);
}

.reset-button {
    background: transparent;
    color: white;
    border: 1px solid #444;
}

.reset-button:hover {
    border-color: #ff3b30;
    color: #ff3b30;
}

#aluMessage {
    grid-column: 1 / -1;
    text-align: center;
    color: #999;
    font-size: 14px;
}
/* ========================================
   STATE / TRUTH TABLE
======================================== */

#clockTableContainer,
#counterTableContainer,
#truthTableContainer {
    width: 100%;
    overflow-x: auto;
    margin-top: 20px;
}

.truth-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px;
    background: #080808;
    border: 1px solid #333;
}

.truth-table th {
    padding: 15px 18px;
    color: #ff3b30;
    background: #151515;
    border: 1px solid #333;
    text-align: center;
    font-size: 14px;
    letter-spacing: 1px;
}

.truth-table td {
    padding: 14px 18px;
    color: #ffffff;
    border: 1px solid #292929;
    text-align: center;
    font-family: monospace;
    font-size: 16px;
}

.truth-table tr:hover td {
    background: #151515;
}

#clockTableContainer .truth-table {
    min-width: 600px;
}/* ========================================
   STRONG TABLE FIX
======================================== */

#clockTableContainer {
    grid-column: 1 / -1;
    width: 100%;
    margin-top: 25px;
    overflow-x: auto;
}

#clockTableContainer table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

#clockTableContainer th {
    padding: 16px;
    background: #151515;
    color: #ff3b30;
    border: 1px solid #444;
    text-align: center;
    font-weight: bold;
}

#clockTableContainer td {
    padding: 16px;
    background: #080808;
    color: white;
    border: 1px solid #333;
    text-align: center;
    font-family: monospace;
    font-size: 17px;
}

#clockTableContainer tr:hover td {
    background: #151515;
}

/* ========================================
   JK STATE DIAGRAM
======================================== */

#stateDiagramContainer {
    grid-column: 1 / -1;
    width: 100%;
    margin-top: 30px;
    padding-top: 10px;
}

.state-title {
    color: #ffffff;
    font-size: 20px;
    margin-bottom: 25px;
}

.state-diagram {
    position: relative;
    width: 100%;
    max-width: 750px;
    height: 330px;
    margin: 0 auto;
    background: #080808;
    border: 1px solid #252525;
    border-radius: 12px;
    overflow: hidden;
}

.state-node {
    position: absolute;
    top: 105px;
    z-index: 3;
}

.state-zero {
    left: 18%;
}

.state-one {
    right: 18%;
}

.state-circle {
    width: 105px;
    height: 105px;
    border: 3px solid #ff3b30;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #101010;
    color: #ffffff;
    font-size: 18px;
    font-weight: bold;
    box-shadow: 0 0 25px rgba(255, 59, 48, 0.12);
}

/* Arrows between Q=0 and Q=1 */

.state-arrow {
    position: absolute;
    left: 32%;
    width: 36%;
    height: 3px;
    background: #ff3b30;
    z-index: 1;
}

.state-arrow::after {
    content: "";
    position: absolute;
    right: -1px;
    top: -6px;
    border-left: 12px solid #ff3b30;
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
}

.arrow-top {
    top: 125px;
}

.arrow-bottom {
    top: 190px;
    transform: rotate(180deg);
}

.state-arrow span {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 10px;
    background: #080808;
    color: #ffffff;
    font-family: monospace;
    font-size: 13px;
    white-space: nowrap;
}

.arrow-top span {
    top: -28px;
}

.arrow-bottom span {
    top: 8px;
    transform: translateX(-50%) rotate(180deg);
}

/* Hold loops */

.state-loop {
    position: absolute;
    width: 145px;
    height: 75px;
    border: 2px solid #555;
    border-bottom: none;
    border-radius: 80px 80px 0 0;
    z-index: 1;
}

.loop-zero {
    left: 9%;
    top: 30px;
}

.loop-one {
    right: 9%;
    top: 30px;
}

.state-loop::after {
    content: "";
    position: absolute;
    bottom: -1px;
    width: 0;
    height: 0;
    border-top: 9px solid #555;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
}

.loop-zero::after {
    right: 0;
}

.loop-one::after {
    right: 0;
}

.state-loop span {
    position: absolute;
    top: -28px;
    left: 50%;
    transform: translateX(-50%);
    color: #aaaaaa;
    font-family: monospace;
    font-size: 12px;
    white-space: nowrap;
}

.diagram-note {
    max-width: 750px;
    margin: 18px auto 0;
    padding: 14px 18px;
    border-left: 3px solid #ff3b30;
    background: #101010;
    color: #aaaaaa;
    font-size: 14px;
}

/* Mobile state diagram */

@media (max-width: 600px) {

    .state-diagram {
        height: 390px;
    }

    .state-zero {
        left: 8%;
    }

    .state-one {
        right: 8%;
    }

    .state-circle {
        width: 85px;
        height: 85px;
        font-size: 15px;
    }

    .state-arrow {
        left: 25%;
        width: 50%;
    }

    .state-loop {
        width: 115px;
    }

    .state-loop span,
    .state-arrow span {
        font-size: 10px;
    }
}
/* ========================================
   4-BIT COUNTER STATE SEQUENCE
   ======================================== */

#counterDiagramContainer {
    margin-top: 35px;
    padding: 25px;
    border: 1px solid #333;
    border-radius: 12px;
    background: #0b0b0b;
    overflow-x: auto;
}

.counter-sequence {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    line-height: 2.5;
    font-family: monospace;
    font-size: 17px;
}

.counter-sequence span {
    white-space: nowrap;
}

.counter-sequence span:nth-child(odd) {
    padding: 8px 12px;
    border: 1px solid #ff3333;
    border-radius: 6px;
    background: #111111;
}

.counter-sequence span:nth-child(even) {
    color: #ff3333;
    font-size: 20px;
}

#counterDiagramContainer .diagram-note {
    margin-top: 20px;
    text-align: center;
}


/* Mobile */

@media (max-width: 600px) {

    #counterDiagramContainer {
        padding: 18px;
    }

    .counter-sequence {
        justify-content: flex-start;
        gap: 8px;
        font-size: 14px;
    }

    .counter-sequence span:nth-child(odd) {
        padding: 6px 9px;
    }

    .counter-sequence span:nth-child(even) {
        font-size: 17px;
    }
}
/* ========================================
   BACK TO MODULES BUTTON
   ======================================== */

.back-button {
    display: inline-block;
    margin-bottom: 25px;
    padding: 10px 18px;

    background: transparent;
    color: #ffffff;

    border: 1px solid #ff3333;
    border-radius: 6px;

    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;

    cursor: pointer;

    transition: 0.2s ease;
}

.back-button:hover {
    background: #ff3333;
    color: #ffffff;
}

