/**
 * Memory & Storage Explorer - styles
 * @package com_memorystorage
 */

.ms-app {
    max-width: 960px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #1d2939;
    padding: 1rem 0 2.5rem;
}

.ms-loading { text-align: center; color: #667085; padding: 2rem 0; }

/* Header / progress dots */
.ms-header { display: flex; justify-content: center; margin-bottom: 1.25rem; }
.ms-dots { display: flex; gap: 0.5rem; }
.ms-dot {
    width: 14px; height: 14px; border-radius: 50%;
    background: #e4e7ec; border: 2px solid #d0d5dd;
}
.ms-dot--done { background: #12b76a; border-color: #12b76a; }
.ms-dot--current { border-color: #2970ff; box-shadow: 0 0 0 3px rgba(41,112,255,.2); }

.ms-title { text-align: center; margin: 0 0 0.5rem; font-size: 1.5rem; }

.ms-intro-wrap {
    display: flex; align-items: center; justify-content: center; gap: 0.75rem;
    max-width: 720px; margin: 0 auto 1rem;
}
.ms-helper-avatar {
    width: 56px; height: 56px; object-fit: contain; flex-shrink: 0;
    border-radius: 50%; background: #f9fafb; border: 2px solid #e4e7ec; padding: 2px;
}
.ms-intro {
    text-align: center; margin: 0;
    color: #475467; line-height: 1.5;
}

/* Companion bar */
.ms-companion-bar {
    display: flex; align-items: center; gap: 0.6rem; justify-content: center;
    max-width: 480px; margin: 0 auto 1.25rem; padding: 0.5rem 0.9rem;
    background: #f9fafb; border: 1px solid #e4e7ec; border-radius: 999px;
}
.ms-companion-avatar {
    width: 40px; height: 40px; object-fit: contain; border-radius: 50%;
    background: #fff; border: 2px solid #d0d5dd;
}
.ms-companion-info { display: flex; flex-direction: column; line-height: 1.25; margin-right: auto; }
.ms-companion-name { font-weight: 700; font-size: 0.9rem; color: #1d2939; }
.ms-companion-tokens { font-size: 0.8rem; color: #667085; }
.ms-companion-change {
    padding: 0.35rem 0.75rem; border-radius: 999px; border: 2px solid #d0d5dd;
    background: #fff; font-weight: 600; font-size: 0.8rem; cursor: pointer;
}
.ms-companion-change:hover { filter: brightness(0.97); }

/* Character picker */
.ms-picker { text-align: center; padding: 0.5rem 0 1.5rem; }
.ms-picker-intro { color: #475467; margin-bottom: 1.25rem; }
.ms-picker-cards { display: flex; gap: 1.5rem; justify-content: center; flex-wrap: wrap; }
.ms-picker-card {
    display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
    padding: 1.25rem 1.75rem; border-radius: 16px; border: 2px solid #d0d5dd;
    background: #fff; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.ms-picker-card:hover { border-color: #2970ff; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(16, 24, 40, 0.12); }
.ms-picker-card:focus-visible { outline: 3px solid #2970ff; outline-offset: 2px; }
.ms-picker-avatar { width: 140px; height: 140px; object-fit: contain; }
.ms-picker-name { font-weight: 700; font-size: 1.05rem; color: #1d2939; }

.ms-status {
    min-height: 1.5em; text-align: center; font-weight: 600; margin-bottom: 0.75rem;
}
.ms-status--correct { color: #067647; }
.ms-status--incorrect { color: #b42318; }

/* Play area */
.ms-play { display: flex; flex-direction: column; gap: 1.25rem; }

.ms-pool {
    display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center;
    padding: 1rem; background: #f9fafb; border: 1px dashed #d0d5dd; border-radius: 12px;
    min-height: 3.5rem;
}

.ms-zones { display: flex; flex-wrap: wrap; gap: 0.85rem; justify-content: center; }

/* Chips (draggable items) */
.ms-chip {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.55rem 0.9rem; background: #fff; border: 2px solid #2970ff;
    border-radius: 999px; color: #1849a9; font-weight: 600; font-size: 0.95rem;
    cursor: grab; touch-action: none; user-select: none;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
    transition: transform .12s ease, box-shadow .12s ease;
}
.ms-chip:hover { box-shadow: 0 2px 8px rgba(16, 24, 40, 0.12); }
.ms-chip:focus-visible { outline: 3px solid #2970ff; outline-offset: 2px; }
.ms-chip--selected { background: #eff4ff; box-shadow: 0 0 0 3px rgba(41,112,255,.35); }
.ms-chip--dragging { opacity: 0.35; }
.ms-chip--ghost { position: fixed; z-index: 9999; cursor: grabbing; pointer-events: none; }
.ms-chip--locked {
    cursor: default; border-color: #12b76a; color: #067647; background: #ecfdf3;
    width: 100%; justify-content: center;
}
.ms-chip--shake { animation: ms-shake .4s ease; }

@keyframes ms-shake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-8px); }
    40%, 60% { transform: translateX(8px); }
}

/* Drop zones */
.ms-dropzone {
    background: #fff; border: 2px solid #d0d5dd; border-radius: 12px;
    padding: 0.75rem; min-width: 150px; text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
    cursor: pointer;
}
.ms-dropzone:focus-visible { outline: 3px solid #2970ff; outline-offset: 2px; }
.ms-dropzone--over { border-color: #2970ff; background: #eff4ff; }
.ms-dropzone--correct { border-color: #12b76a; background: #ecfdf3; }
.ms-dropzone--incorrect { border-color: #f04438; background: #fef3f2; }

.ms-zone-position {
    font-size: 0.75rem; font-weight: 700; color: #fff; background: #667085;
    border-radius: 999px; width: 22px; height: 22px; display: inline-flex;
    align-items: center; justify-content: center;
}
.ms-zone-label { font-size: 0.85rem; color: #475467; line-height: 1.35; }
.ms-zone-slot { min-height: 2.4rem; width: 100%; display: flex; align-items: center; justify-content: center; }

/* Layout: two bins side by side */
.ms-play--bins .ms-zones { }
.ms-play--bins .ms-dropzone {
    flex: 1 1 260px; min-height: 140px; padding: 1rem; justify-content: flex-start;
}
.ms-play--bins .ms-zone-slot { flex-wrap: wrap; gap: 0.4rem; }
.ms-play--bins .ms-chip--locked { width: auto; }
.ms-play--bins .ms-zone-label { font-size: 1rem; font-weight: 700; color: #1d2939; }

/* Layout: matching definitions */
.ms-play--match .ms-zones { flex-direction: column; align-items: stretch; }
.ms-play--match .ms-dropzone {
    flex-direction: row; text-align: left; justify-content: space-between; min-width: 0;
}
.ms-play--match .ms-zone-label { flex: 1; }
.ms-play--match .ms-zone-slot { width: 180px; min-height: 2.4rem; }

/* Layout: ordered sequence */
.ms-play--order .ms-zones,
.ms-play--order-long .ms-zones {
    display: grid; gap: 0.75rem;
}
.ms-play--order .ms-zones { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.ms-play--order-long .ms-zones { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.ms-play--order .ms-dropzone,
.ms-play--order-long .ms-dropzone { min-width: 0; }

/* Layout: single backup target */
.ms-play--single .ms-zones { justify-content: center; }
.ms-play--single .ms-dropzone { min-width: 260px; min-height: 120px; }

/* Level complete panel */
.ms-complete {
    text-align: center; padding: 2rem 1rem; background: #f9fafb; border-radius: 16px;
    margin-top: 1rem;
}
.ms-complete h3 { margin-top: 0; }
.ms-complete-stats { color: #667085; margin-bottom: 1rem; }
.ms-complete-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }

.ms-btn {
    padding: 0.6rem 1.3rem; border-radius: 8px; border: 2px solid #d0d5dd;
    background: #fff; font-weight: 600; cursor: pointer; font-size: 0.95rem;
}
.ms-btn--primary { background: #2970ff; border-color: #2970ff; color: #fff; }
.ms-btn:hover { filter: brightness(0.97); }

/* Celebration overlay */
.ms-celebration {
    position: fixed; inset: 0; z-index: 10000;
    display: flex; align-items: center; justify-content: center;
    pointer-events: none;
    animation: ms-celebration-in .2s ease;
}
.ms-celebration--out { animation: ms-celebration-out .25s ease forwards; }

@keyframes ms-celebration-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes ms-celebration-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

.ms-celebration-card {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
    padding: 1.25rem 1.75rem; border-radius: 20px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 12px 32px rgba(16, 24, 40, 0.25);
    animation: ms-celebration-pop .35s cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes ms-celebration-pop {
    from { transform: scale(0.6); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.ms-celebration-avatar { width: 150px; height: 150px; object-fit: contain; }
.ms-celebration--big .ms-celebration-avatar { width: 200px; height: 200px; }

.ms-celebration--correct .ms-celebration-card { border: 3px solid #12b76a; }
.ms-celebration--incorrect .ms-celebration-card { border: 3px solid #f04438; }

.ms-celebration-token {
    font-weight: 800; font-size: 1.1rem; color: #067647;
    background: #ecfdf3; border-radius: 999px; padding: 0.35rem 1rem;
}
.ms-celebration-retry {
    font-weight: 700; font-size: 1rem; color: #b42318;
    background: #fef3f2; border-radius: 999px; padding: 0.35rem 1rem;
}

/* Confetti */
.ms-confetti {
    position: absolute; inset: -20% -10% auto -10%; height: 140%;
    overflow: visible; pointer-events: none;
}
.ms-confetti-piece {
    position: absolute; top: -10px; width: 8px; height: 14px;
    animation-name: ms-confetti-fall; animation-timing-function: ease-in;
    animation-fill-mode: forwards; border-radius: 2px;
}
@keyframes ms-confetti-fall {
    from { transform: translateY(0) rotate(0deg); opacity: 1; }
    to { transform: translateY(160px) rotate(340deg); opacity: 0; }
}

@media (max-width: 640px) {
    .ms-picker-avatar { width: 100px; height: 100px; }
    .ms-celebration-avatar { width: 110px; height: 110px; }
    .ms-celebration--big .ms-celebration-avatar { width: 150px; height: 150px; }

    .ms-play--order .ms-zones,
    .ms-play--order-long .ms-zones { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ms-play--match .ms-dropzone { flex-direction: column; align-items: stretch; }
    .ms-play--match .ms-zone-slot { width: 100%; }
}
