/* =========================================================
   Hexadecimal: A Compact View of Binary
   Secondary Computer Science 1.1.3
   ========================================================= */

.hex-table-scroll {
    width: 100%;
    overflow-x: auto;
    margin: 1.25rem 0;
}

.hex-table-scroll .study-table {
    min-width: 760px;
    margin-top: 0;
    margin-bottom: 0;
}

.hex-reference-table th,
.hex-reference-table td,
.hex-place-table th,
.hex-place-table td {
    text-align: center;
    white-space: nowrap;
}

.hex-reference-table td:nth-child(2),
.hex-reference-table td:nth-child(5) {
    color: #5b5fa8;
    font-size: 1.05rem;
    font-weight: 900;
}

.hex-reference-table td:nth-child(3),
.hex-reference-table td:nth-child(6) {
    font-family: "Courier New", monospace;
    font-weight: 900;
    letter-spacing: 0.08em;
}

.hex-conversion-display {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.65rem;

    margin: 1rem 0;
}

.hex-conversion-display span {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 90px;
    padding: 0.7rem 1rem;

    border: 2px solid #cbd5e1;
    border-radius: 16px;

    background: #f8fafc;
    color: #0f172a;

    font-family: "Courier New", monospace;
    font-size: 1.35rem;
    font-weight: 900;
    letter-spacing: 0.12em;
}

.hex-conversion-display .hex-padded-group {
    border-color: #5b5fa8;
    background: #eef2ff;
    color: #34387f;
}

.hex-calculation {
    width: fit-content;
    max-width: 100%;

    margin: 1rem auto;
    padding: 0.85rem 1.25rem;

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

    background: #f8fafc;
    color: #0f172a;

    font-family: "Courier New", monospace;
    font-size: 1.2rem;
    font-weight: 900;
    text-align: center;

    overflow-wrap: anywhere;
}

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

.hex-converter-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.13),
            transparent 30%
        ),
        radial-gradient(
            circle at bottom left,
            rgba(230, 0, 79, 0.05),
            transparent 28%
        ),
        white;

    color: #0f172a;

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

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

    margin-bottom: 1.25rem;
}

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

.hex-widget-eyebrow {
    margin: 0;

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

.hex-widget-summary-card {
    min-width: 210px;

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

    padding: 0.9rem 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 18px;

    background: #f8fafc;
}

.hex-widget-summary-card span {
    color: #64748b;
    font-size: 0.74rem;
    font-weight: 900;
    text-transform: uppercase;
}

.hex-widget-summary-card strong {
    margin: 0.15rem 0;

    color: #5b5fa8;
    font-family: "Courier New", monospace;
    font-size: 2rem;
    line-height: 1.1;
    letter-spacing: 0.08em;
}

.hex-widget-summary-card small {
    max-width: 100%;

    color: #334155;
    font-family: "Courier New", monospace;
    font-size: 0.9rem;
    font-weight: 900;
    text-align: center;
    overflow-wrap: anywhere;
}

/* =========================================================
   Width selector
   ========================================================= */

.hex-widget-fieldset {
    margin: 0 0 1.25rem;
    padding: 1rem;

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

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

.hex-widget-fieldset legend {
    padding: 0 0.4rem;

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

.hex-widget-width-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.hex-widget-width-option {
    padding: 0.55rem 0.9rem;

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

    background: white;
    color: #334155;

    font-weight: 800;
    cursor: pointer;

    transition: all 0.2s ease;
}

.hex-widget-width-option:hover {
    border-color: #5b5fa8;
    color: #34387f;
    transform: translateY(-1px);
}

.hex-widget-width-option.active {
    border-color: #5b5fa8;
    background: #5b5fa8;
    color: white;

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

.hex-widget-range-message {
    margin: 0.8rem 0 0;

    color: #475569;
    font-size: 0.9rem;
    font-weight: 700;
}

/* =========================================================
   Input cards
   ========================================================= */

.hex-widget-input-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.hex-widget-input-card {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;

    min-width: 0;
    padding: 1rem;

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

    background: #f8fafc;
}

.hex-widget-input-card h4 {
    margin: 0;
}

.hex-widget-input-card label,
.hex-widget-answer-area label {
    color: #475569;
    font-size: 0.84rem;
    font-weight: 800;
}

.hex-widget-input-card input,
.hex-widget-answer-area input {
    width: 100%;
    box-sizing: border-box;

    padding: 0.75rem 0.9rem;

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

    background: white;
    color: #0f172a;

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

    outline: none;
}

.hex-widget-input-card input:focus,
.hex-widget-answer-area input:focus {
    border-color: #5b5fa8;

    box-shadow: 0 0 0 4px rgba(91, 95, 168, 0.12);
}

/* =========================================================
   Feedback
   ========================================================= */

.hex-widget-feedback {
    margin: 1rem 0;
    padding: 0.8rem 1rem;

    border: 1px solid #bfdbfe;
    border-radius: 16px;

    background: #eff6ff;
    color: #1e3a8a;

    font-weight: 800;
}

.hex-widget-feedback.error {
    border-color: #fed7aa;
    background: #fff7ed;
    color: #9a3412;
}

.hex-widget-feedback.success {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}

/* =========================================================
   Nibble board
   ========================================================= */

.hex-widget-board-section {
    margin-top: 1.2rem;
}

.hex-widget-board-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;

    margin-bottom: 0.75rem;
}

.hex-widget-board-heading h4 {
    margin: 0;
}

.hex-widget-board-heading p {
    margin: 0.25rem 0 0;
    color: #64748b;
}

.hex-widget-nibble-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.8rem;
}

.hex-widget-nibble-card {
    position: relative;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;

    min-height: 185px;
    padding: 0.9rem;

    border: 2px solid #cbd5e1;
    border-radius: 20px;

    background: white;
    color: #334155;

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

.hex-widget-nibble-card:hover {
    transform: translateY(-3px);
    border-color: #5b5fa8;
}

.hex-widget-nibble-card.selected {
    border-color: #5b5fa8;

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

    box-shadow: 0 12px 28px rgba(91, 95, 168, 0.15);
}

.hex-widget-nibble-card.animation-focus {
    transform: translateY(-5px) scale(1.025);
    border-color: #e6004f;

    box-shadow:
        0 14px 30px rgba(230, 0, 79, 0.16),
        0 0 0 5px rgba(230, 0, 79, 0.08);
}

.hex-widget-position-label {
    color: #64748b;
    font-size: 0.7rem;
    font-weight: 900;
    text-transform: uppercase;
}

.hex-widget-binary-group {
    display: flex;
    gap: 0.25rem;
}

.hex-widget-bit {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 31px;
    height: 38px;

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

    background: #f8fafc;
    color: #334155;

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

.hex-widget-bit.one {
    border-color: rgba(91, 95, 168, 0.38);
    background: rgba(91, 95, 168, 0.12);
    color: #34387f;
}

.hex-widget-translation-arrow {
    color: #94a3b8;
    font-size: 1.2rem;
    font-weight: 900;
}

.hex-widget-digit {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 56px;
    height: 56px;

    border-radius: 999px;

    background: #5b5fa8;
    color: white;

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

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

.hex-widget-nibble-detail {
    margin: 0;

    color: #475569;
    font-size: 0.76rem;
    font-weight: 800;
    text-align: center;
}

/* =========================================================
   Equations and actions
   ========================================================= */

.hex-widget-equation-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;

    margin: 1rem 0;
}

.hex-widget-equation-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;

    min-width: 0;
    padding: 0.9rem;

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

    background: #f8fafc;
}

.hex-widget-equation-card span {
    color: #64748b;
    font-size: 0.7rem;
    font-weight: 900;
    text-transform: uppercase;
}

.hex-widget-equation-card strong {
    max-width: 100%;

    color: #0f172a;
    font-family: "Courier New", monospace;
    font-size: 0.94rem;
    text-align: center;

    overflow-wrap: anywhere;
}

.hex-widget-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;

    margin-bottom: 1.2rem;
}

.hex-widget-actions button:disabled,
.hex-widget-answer-area button:disabled,
.hex-widget-board-heading button:disabled {
    opacity: 0.45;
    cursor: default;
    transform: none;
}

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

.hex-widget-challenge {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(250px, 0.65fr);
    gap: 1rem;

    padding: 1rem;

    border: 1px solid #e9d5ff;
    border-radius: 20px;

    background: #faf5ff;
    color: #581c87;
}

.hex-widget-challenge h4 {
    margin: 0.15rem 0 0.45rem;
}

.hex-widget-challenge-types {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;

    margin-top: 0.8rem;
}

.hex-widget-challenge-type {
    padding: 0.55rem 0.8rem;

    border: 1px solid #d8b4fe;
    border-radius: 999px;

    background: white;
    color: #6b21a8;

    font-weight: 800;
    cursor: pointer;

    transition: all 0.2s ease;
}

.hex-widget-challenge-type:hover,
.hex-widget-challenge-type.active {
    border-color: #6b21a8;
    background: #6b21a8;
    color: white;
}

.hex-widget-answer-area {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.hex-widget-challenge-message {
    margin: 0;

    font-size: 0.9rem;
    font-weight: 800;
}

.hex-widget-challenge-message.success {
    color: #166534;
}

.hex-widget-challenge-message.error {
    color: #9a3412;
}

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

@media (max-width: 900px) {
    .hex-widget-input-grid,
    .hex-widget-equation-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .hex-widget-header,
    .hex-widget-board-heading {
        flex-direction: column;
    }

    .hex-widget-summary-card {
        width: 100%;
        box-sizing: border-box;
    }

    .hex-widget-challenge {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 420px) {
    .hex-widget-nibble-board {
        grid-template-columns: 1fr;
    }

    .hex-widget-bit {
        width: 28px;
    }
}