/* =========================================================
   Two States, Many Patterns Widget
   Secondary Computer Science 1.1.1
   ========================================================= */

.binary-process-flow {
    display: grid;
    grid-template-columns:
        minmax(135px, 1fr) auto
        minmax(135px, 1fr) auto
        minmax(135px, 1fr) auto
        minmax(135px, 1fr) auto
        minmax(135px, 1fr);
    align-items: stretch;
    gap: 0.65rem;

    margin: 1.6rem 0;
}

.binary-process-step {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;

    padding: 1rem;
    border-radius: 18px;

    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #334155;
}

.binary-process-step strong {
    color: #0f172a;
}

.binary-process-step p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.binary-process-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 30px;
    height: 30px;
    border-radius: 999px;

    background: #5b5fa8;
    color: white;

    font-weight: 900;
}

.binary-process-arrow {
    display: flex;
    align-items: center;
    justify-content: center;

    color: #5b5fa8;
    font-size: 1.5rem;
    font-weight: 900;
}

/* =========================================================
   Main widget shell
   ========================================================= */

.binary-pattern-widget {
    margin: 1.5rem 0;
    padding: 1.35rem;

    border: 1px solid #dbe3ef;
    border-radius: 24px;

    background:
        radial-gradient(
            circle at top right,
            rgba(91, 95, 168, 0.11),
            transparent 30%
        ),
        white;

    color: #0f172a;

    box-shadow: 0 16px 42px rgba(15, 23, 42, 0.08);
}

.binary-pattern-widget-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;

    margin-bottom: 1.25rem;
}

.binary-pattern-widget-header h3 {
    margin: 0.2rem 0 0;
}

.binary-pattern-eyebrow {
    margin: 0;

    color: #5b5fa8;
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.binary-pattern-count-card {
    min-width: 150px;

    display: flex;
    flex-direction: column;
    align-items: center;

    padding: 0.85rem 1rem;
    border-radius: 18px;

    background: #f8fafc;
    border: 1px solid #cbd5e1;
}

.binary-pattern-count-card span {
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.binary-pattern-count-card strong {
    margin: 0.15rem 0;

    color: #5b5fa8;
    font-size: 2rem;
    line-height: 1;
}

.binary-pattern-count-card small {
    color: #475569;
    font-weight: 800;
}

/* =========================================================
   Bit-count controls
   ========================================================= */

.binary-pattern-fieldset {
    margin: 0 0 1.25rem;
    padding: 1rem;

    border: 1px solid #e2e8f0;
    border-radius: 18px;

    background: rgba(248, 250, 252, 0.8);
}

.binary-pattern-fieldset legend {
    padding: 0 0.4rem;

    color: #334155;
    font-weight: 900;
}

.binary-pattern-bit-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.binary-pattern-bit-option {
    border: 1px solid #cbd5e1;
    border-radius: 999px;

    padding: 0.55rem 0.9rem;

    background: white;
    color: #334155;

    font-weight: 800;
    cursor: pointer;

    transition: all 0.2s ease;
}

.binary-pattern-bit-option:hover {
    border-color: #5b5fa8;
    color: #34387f;
    transform: translateY(-1px);
}

.binary-pattern-bit-option.active {
    background: #5b5fa8;
    border-color: #5b5fa8;
    color: white;

    box-shadow: 0 8px 18px rgba(91, 95, 168, 0.22);
}

/* =========================================================
   Workspace
   ========================================================= */

.binary-pattern-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(250px, 0.75fr);
    gap: 1rem;
}

.binary-pattern-switch-panel,
.binary-pattern-explanation-panel {
    padding: 1rem;
    border-radius: 20px;

    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.binary-pattern-switch-panel h4,
.binary-pattern-explanation-panel h4 {
    margin-top: 0;
}

.binary-pattern-switches {
    display: flex;
    justify-content: center;
    align-items: stretch;
    flex-wrap: wrap;
    gap: 0.75rem;

    margin: 1rem 0;
}

.binary-pattern-switch {
    width: 92px;
    min-height: 132px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 0.55rem;

    padding: 0.75rem;
    border: 2px solid #cbd5e1;
    border-radius: 20px;

    background: white;
    color: #334155;

    cursor: pointer;
    transition: all 0.22s ease;
}

.binary-pattern-switch:hover {
    transform: translateY(-3px);
    border-color: #5b5fa8;
}

.binary-pattern-switch.state-one {
    border-color: #5b5fa8;

    background:
        linear-gradient(
            145deg,
            rgba(91, 95, 168, 0.16),
            rgba(230, 0, 79, 0.06)
        );

    box-shadow: 0 10px 24px rgba(91, 95, 168, 0.14);
}

.binary-pattern-switch-label {
    color: #64748b;
    font-size: 0.76rem;
    font-weight: 900;
    text-transform: uppercase;
}

.binary-pattern-switch-value {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 52px;
    height: 52px;
    border-radius: 999px;

    background: #e2e8f0;
    color: #334155;

    font-size: 1.65rem;
    font-weight: 900;
}

.binary-pattern-switch.state-one .binary-pattern-switch-value {
    background: #5b5fa8;
    color: white;
}

.binary-pattern-switch-state {
    font-size: 0.8rem;
    font-weight: 800;
}

.binary-pattern-current-card {
    display: flex;
    flex-direction: column;
    align-items: center;

    padding: 0.9rem;
    border-radius: 18px;

    background: white;
    border: 1px solid #cbd5e1;
}

.binary-pattern-current-card span {
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 900;
    text-transform: uppercase;
}

.binary-pattern-current-card strong {
    margin: 0.25rem 0;

    color: #0f172a;
    font-family: "Courier New", monospace;
    font-size: clamp(2rem, 6vw, 3.2rem);
    letter-spacing: 0.18em;
}

.binary-pattern-current-card small {
    color: #475569;
    text-align: center;
}

.binary-pattern-process-list {
    margin-bottom: 0;
    padding-left: 1.4rem;
}

.binary-pattern-process-list li {
    margin-bottom: 0.8rem;
}

/* =========================================================
   Actions and animation
   ========================================================= */

.binary-pattern-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;

    margin: 1rem 0;
}

.binary-pattern-actions button:disabled {
    opacity: 0.45;
    cursor: default;
    transform: none;
}

.binary-pattern-sequence-card {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;

    padding: 0.85rem 1rem;
    border-radius: 16px;

    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e3a8a;
}

.binary-pattern-sequence-card span {
    font-size: 0.75rem;
    font-weight: 900;
    text-transform: uppercase;
}

/* =========================================================
   Pattern gallery
   ========================================================= */

.binary-pattern-gallery-section {
    margin-top: 1.2rem;
    padding-top: 1.2rem;

    border-top: 1px solid #e2e8f0;
}

.binary-pattern-gallery-section h4 {
    margin-bottom: 0.25rem;
}

.binary-pattern-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;

    margin-top: 0.8rem;
}

.binary-pattern-gallery-button {
    padding: 0.48rem 0.7rem;

    border: 1px solid #cbd5e1;
    border-radius: 10px;

    background: #f8fafc;
    color: #334155;

    font-family: "Courier New", monospace;
    font-size: 0.92rem;
    font-weight: 900;

    cursor: pointer;
    transition: all 0.18s ease;
}

.binary-pattern-gallery-button:hover {
    background: #eef2ff;
    border-color: #5b5fa8;
    color: #34387f;
}

.binary-pattern-gallery-button.current {
    background: #5b5fa8;
    border-color: #5b5fa8;
    color: white;

    box-shadow: 0 6px 15px rgba(91, 95, 168, 0.2);
}

/* =========================================================
   Challenge
   ========================================================= */

.binary-pattern-challenge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;

    margin-top: 1.25rem;
    padding: 1rem 1.1rem;
    border-radius: 20px;

    background: #faf5ff;
    border: 1px solid #e9d5ff;
    color: #581c87;
}

.binary-pattern-challenge h4 {
    margin: 0.15rem 0 0.45rem;
}

.binary-pattern-target {
    display: inline-block;

    padding: 0.45rem 0.8rem;
    border-radius: 12px;

    background: white;
    border: 1px solid #d8b4fe;

    color: #581c87;
    font-family: "Courier New", monospace;
    font-size: 1.8rem;
    letter-spacing: 0.14em;
}

.binary-pattern-challenge-message {
    margin-bottom: 0;
    font-weight: 800;
}

.binary-pattern-challenge-message.success {
    color: #166534;
}

.binary-pattern-challenge-message.try-again {
    color: #9a3412;
}

/* =========================================================
   Responsive layout
   ========================================================= */

@media (max-width: 1050px) {
    .binary-process-flow {
        grid-template-columns: 1fr;
    }

    .binary-process-arrow {
        transform: rotate(90deg);
        min-height: 24px;
    }
}

@media (max-width: 760px) {
    .binary-pattern-widget-header {
        flex-direction: column;
    }

    .binary-pattern-count-card {
        width: 100%;
        box-sizing: border-box;
    }

    .binary-pattern-workspace {
        grid-template-columns: 1fr;
    }

    .binary-pattern-challenge {
        align-items: flex-start;
        flex-direction: column;
    }

    .binary-pattern-switch {
        width: 78px;
        min-height: 120px;
    }
}