/* =========================================================
   Character Codes and Multilingual Text
   Secondary Computer Science 1.2.1
   ========================================================= */

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

    margin: 1.5rem 0;
}

.character-code-flow-step {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;

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

    background: #f8fafc;
    color: #334155;
}

.character-code-flow-step strong {
    color: #0f172a;
}

.character-code-flow-step p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.character-code-flow-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;

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

    background: #5b5fa8;
    color: white;

    font-weight: 900;
}

.character-code-flow-arrow {
    display: flex;
    align-items: center;
    justify-content: center;

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

.character-message-display,
.character-binary-display {
    width: fit-content;
    max-width: 100%;

    margin: 1rem auto;
    padding: 0.8rem 1.2rem;

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

    background: #f8fafc;
    color: #0f172a;

    text-align: center;
    overflow-wrap: anywhere;
}

.character-message-display {
    font-size: 2rem;
}

.character-binary-display {
    font-family: "Courier New", monospace;
    font-size: 1.15rem;
    font-weight: 900;
}

.character-encoding-path {
    display: grid;
    grid-template-columns:
        minmax(150px, 1fr) auto
        minmax(150px, 1fr) auto
        minmax(150px, 1fr) auto
        minmax(150px, 1fr);
    align-items: stretch;
    gap: 0.65rem;

    margin: 1.5rem 0;
}

.character-encoding-path-card {
    padding: 1rem;

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

    background: #f8fafc;
    color: #334155;
}

.character-encoding-path-card strong {
    color: #0f172a;
}

.character-encoding-path-card p {
    margin-bottom: 0;
}

.character-encoding-path-arrow {
    display: flex;
    align-items: center;
    justify-content: center;

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

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

.character-code-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);
}

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

    margin-bottom: 1.25rem;
}

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

.character-widget-eyebrow {
    margin: 0;

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

.character-widget-summary-card {
    min-width: 190px;

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

    padding: 0.85rem 1rem;

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

    background: #f8fafc;
}

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

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

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

.character-widget-summary-card small {
    color: #334155;
    font-weight: 800;
    text-align: center;
}

/* =========================================================
   Mode selector
   ========================================================= */

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

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

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

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

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

.character-widget-mode-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.character-widget-mode-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;
}

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

.character-widget-mode-option.active {
    border-color: #5b5fa8;
    background: #5b5fa8;
    color: white;

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

.character-widget-mode-description {
    margin: 0.8rem 0 0;

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

/* =========================================================
   Text input
   ========================================================= */

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

    padding: 1rem;

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

    background: #f8fafc;
}

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

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

    padding: 0.8rem 0.9rem;

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

    background: white;
    color: #0f172a;

    font-size: 1rem;
    outline: none;
}

.character-widget-input-card textarea {
    resize: vertical;
    min-height: 88px;
}

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

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

.character-widget-preset-row,
.character-widget-input-actions,
.character-widget-actions,
.character-widget-challenge-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.character-widget-preset {
    padding: 0.45rem 0.72rem;

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

    background: white;
    color: #475569;

    font-size: 0.82rem;
    font-weight: 800;

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

.character-widget-preset:hover {
    border-color: #5b5fa8;
    color: #34387f;
    background: #eef2ff;
}

/* =========================================================
   Feedback and code stream
   ========================================================= */

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

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

    background: #eff6ff;
    color: #1e3a8a;

    font-weight: 800;
}

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

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

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

    padding: 0.9rem 1rem;

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

    background: #f8fafc;
}

.character-widget-stream-card span {
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
}

.character-widget-stream-card strong {
    max-width: 100%;

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

    overflow-wrap: anywhere;
}

/* =========================================================
   Character cards
   ========================================================= */

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

.character-widget-board-section h4 {
    margin-bottom: 0.75rem;
}

.character-widget-card-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 0.75rem;
}

.character-widget-card {
    min-height: 205px;

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

    padding: 0.85rem;

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

    background: white;
    color: #334155;

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

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

.character-widget-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);
}

.character-widget-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);
}

.character-widget-card.unsupported {
    border-color: #fed7aa;
    background: #fff7ed;
}

.character-widget-index-label {
    color: #64748b;
    font-size: 0.68rem;
    font-weight: 900;
    text-transform: uppercase;
}

.character-widget-visible-character {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 62px;
    height: 62px;
    padding: 0 0.3rem;

    border-radius: 18px;

    background: #5b5fa8;
    color: white;

    font-size: 1.75rem;
    font-weight: 900;

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

.character-widget-code-label {
    color: #34387f;
    font-family: "Courier New", monospace;
    font-size: 0.92rem;
    font-weight: 900;
    text-align: center;
}

.character-widget-card-detail {
    margin: 0;

    color: #475569;
    font-size: 0.77rem;
    font-weight: 800;
    line-height: 1.4;
    text-align: center;

    overflow-wrap: anywhere;
}

.character-widget-selected-card {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr);
    align-items: center;
    gap: 0.8rem;

    margin: 1rem 0;
    padding: 0.9rem 1rem;

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

    background: #f8fafc;
}

.character-widget-selected-card span {
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
}

.character-widget-selected-card strong {
    color: #5b5fa8;
    font-size: 1.8rem;
}

.character-widget-selected-card p {
    margin: 0;
    color: #334155;
}

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

.character-widget-challenge {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(250px, 0.75fr);
    gap: 1rem;

    margin-top: 1.2rem;
    padding: 1rem;

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

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

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

.character-widget-challenge-binary {
    padding: 0.75rem;

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

    background: white;

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

    overflow-wrap: anywhere;
}

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

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

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

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

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

.character-widget-input-actions button:disabled {
    opacity: 0.45;
    cursor: default;
    transform: none;
}

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

@media (max-width: 1050px) {
    .character-code-flow,
    .character-encoding-path {
        grid-template-columns: 1fr;
    }

    .character-code-flow-arrow,
    .character-encoding-path-arrow {
        transform: rotate(90deg);
        min-height: 24px;
    }
}

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

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

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

    .character-widget-selected-card {
        grid-template-columns: 1fr;
        text-align: center;
    }
}

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