/* =====================================
   Tahouri Edu Platform
   Matching Engine UI
   Version 1.4

   Owns only Matching Screen presentation.
   ===================================== */

.matchingScreen {
    width: min(920px, 100%);
    margin: 0 auto;
    padding: 24px 18px 40px;
    text-align: center;
}

.matchingScreen h1 {
    margin: 0 0 10px;
    font-size: clamp(24px, 3vw, 32px);
    line-height: 1.4;
    font-weight: 800;
}

.matchingInstruction {
    margin: 0 auto 22px;
    max-width: 720px;
    color: var(--ui-muted, #667085);
    line-height: 1.9;
}

.matchingBoard {
    width: min(760px, 100%);
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
    direction: ltr;
    align-items: center;
    position: relative;
}

.matchingConnections {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
    z-index: 1;
}

.matchingPairConnection {
    pointer-events: none;
}

.matchingPreviewConnection {
    pointer-events: none;
}

.matchingColumn {
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--ui-border, #dbe4ef);
    border-radius: var(--ui-radius-card, 20px);
    background: var(--ui-surface, #ffffff);
    box-shadow: var(--ui-shadow-card, 0 7px 20px rgba(31, 41, 55, .06));
    direction: rtl;
    position: relative;
    z-index: 2;
}

.matchingColumnTitle {
    margin-bottom: 12px;
    font-size: 16px;
    font-weight: 800;
    color: var(--ui-text, #172033);
}

.matchingItems {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.matchingItem {
    width: 100%;
    min-height: 58px;
    padding: 12px 14px;
    border: 1px solid var(--ui-border, #dbe4ef);
    border-radius: 14px;
    background: var(--ui-surface-soft, #f8fbff);
    color: var(--ui-text-body, #1f2937);
    font: inherit;
    font-weight: 700;
    line-height: 1.6;
    text-align: center;
    cursor: pointer;
    touch-action: none;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background-color .16s ease;
    position: relative;
    z-index: 3;
}

.matchingItem:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--ui-shadow-card-hover, 0 11px 26px rgba(31, 41, 55, .09));
}

.matchingItem.connectionTarget {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .16);
    transform: translateY(-1px);
}

.matchingItem.selected {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px var(--ui-focus, rgba(37, 99, 235, .20));
}

.matchingItem.matched {
    cursor: default;
    opacity: .72;
}

.matchingItem:disabled {
    cursor: default;
}

.matchingItemImageWrap {
    display: block;
    width: 100%;
}

.matchingItemImage {
    display: block;
    width: 100%;
    max-height: 120px;
    object-fit: contain;
    margin: 0 auto;
}

.matchingStatus {
    margin: 18px auto 0;
    color: var(--ui-muted, #667085);
    font-size: 14px;
    font-weight: 700;
}

.matchingMessage {
    position: fixed;
    top: 12%;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100vw - 32px);
    box-sizing: border-box;
    margin: 0;
    padding: 8px 14px;
    border-radius: 14px;
    font-weight: 800;
    line-height: 1.7;
    text-align: center;
    z-index: 10000;
    pointer-events: auto;
    cursor: pointer;
    opacity: 1;
    transition: opacity .22s ease;
    box-shadow: 0 10px 30px rgba(31, 41, 55, .16);
}

.matchingMessage.success {
    background: rgba(236, 253, 243, .72);
    color: #166534;
}

.matchingMessage.error {
    background: rgba(254, 242, 242, .72);
    color: #b91c1c;
}

.matchingMessage.is-hiding {
    opacity: 0;
}

@media (max-width: 560px) {
    .matchingScreen {
        padding: 18px 10px 28px;
    }

    .matchingBoard {
        gap: 10px;
    }

    .matchingColumn {
        padding: 10px;
        border-radius: 16px;
    }

    .matchingColumnTitle {
        margin-bottom: 9px;
        font-size: 14px;
    }

    .matchingItems {
        gap: 8px;
    }

    .matchingItem {
        min-height: 52px;
        padding: 10px 8px;
        border-radius: 12px;
        font-size: 14px;
    }
}


@media (prefers-reduced-motion: reduce) {
    .matchingMessage { transition: none; }
}


/* Compact layout for the ten-pair detective game: fit the full activity
   in the viewport on phones and desktop without an inner scroll area. */
.matchingActivity-detective {
    box-sizing: border-box;
    max-height: 100dvh;
    overflow: hidden;
    padding: 8px 12px 10px;
}
.matchingActivity-detective h1 {
    margin: 0 0 4px;
    font-size: clamp(19px, 2.5vw, 26px);
    line-height: 1.25;
}
.matchingActivity-detective .matchingInstruction {
    margin: 0 auto 7px;
    line-height: 1.35;
    font-size: 13px;
}
.matchingActivity-detective .matchingBoard {
    gap: 8px;
    align-items: center;
}
.matchingActivity-detective .matchingColumn {
    padding: 7px;
    border-radius: 12px;
}
.matchingActivity-detective .matchingColumnTitle {
    margin-bottom: 5px;
    font-size: 12px;
}
.matchingActivity-detective .matchingItems {
    gap: 4px;
}
.matchingActivity-detective .matchingItem {
    box-sizing: border-box;
    min-height: 32px;
    padding: 4px 5px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.2;
}
.matchingActivity-detective .matchingStatus {
    margin: 6px auto 0;
    font-size: 11px;
    line-height: 1.3;
}
@media (max-width: 560px) {
    .matchingActivity-detective {
        padding: 6px 6px 8px;
    }
    .matchingActivity-detective .matchingBoard {
        gap: 5px;
    }
    .matchingActivity-detective .matchingColumn {
        padding: 5px;
        border-radius: 10px;
    }
    .matchingActivity-detective .matchingItems {
        gap: 3px;
    }
    .matchingActivity-detective .matchingItem {
        min-height: 30px;
        padding: 3px 2px;
        font-size: 12px;
        line-height: 1.15;
    }
}
@media (max-height: 700px) {
    .matchingActivity-detective {
        padding-top: 3px;
        padding-bottom: 4px;
    }
    .matchingActivity-detective .matchingInstruction {
        margin-bottom: 4px;
        font-size: 12px;
    }
    .matchingActivity-detective .matchingColumn {
        padding: 4px;
    }
    .matchingActivity-detective .matchingItems {
        gap: 2px;
    }
    .matchingActivity-detective .matchingItem {
        min-height: 27px;
        padding-top: 2px;
        padding-bottom: 2px;
        font-size: 11px;
    }
}
