/* ==========================================================================
   MSHA Flashcards — WordPress Plugin Styles
   Scoped under #msha-flashcards-app to avoid theme conflicts
   Compatible with PressBook Premium 3.1.7
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---- Reset within container ---- */
#msha-flashcards-app {
    --fc-bg: #0f1117;
    --fc-surface: #181b25;
    --fc-surface-hover: #1e2230;
    --fc-border: #2a2e3d;
    --fc-text: #e2e4ec;
    --fc-text-muted: #8b8fa3;
    --fc-accent: #60a5fa;
    --fc-accent-dim: rgba(96,165,250,0.12);
    --fc-success: #4ade80;
    --fc-success-dim: rgba(74,222,128,0.12);
    --fc-warn: #f0a050;
    --fc-warn-dim: rgba(240,160,80,0.15);
    --fc-danger: #f87171;
    --fc-danger-dim: rgba(248,113,113,0.12);
    --fc-purple: #a78bfa;
    --fc-purple-dim: rgba(167,139,250,0.12);
    --fc-radius: 12px;
    --fc-radius-sm: 8px;
    --fc-font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --fc-mono: 'JetBrains Mono', 'Courier New', monospace;

    font-family: var(--fc-font);
    background: var(--fc-bg);
    color: var(--fc-text);
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    line-height: 1.6;
    box-sizing: border-box;
    max-width: 900px;
    margin: 24px auto;
    -webkit-tap-highlight-color: transparent;
}

#msha-flashcards-app *,
#msha-flashcards-app *::before,
#msha-flashcards-app *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ---- Header ---- */
.msha-fc-header {
    padding: 24px 28px 16px;
    border-bottom: 1px solid var(--fc-border);
}

.msha-fc-title {
    font-family: var(--fc-font);
    font-size: 22px;
    font-weight: 700;
    color: var(--fc-text);
    margin: 0 0 4px 0;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.msha-fc-subtitle {
    font-family: var(--fc-mono);
    font-size: 12px;
    color: var(--fc-text-muted);
    margin: 0;
}

/* ---- Deck Tabs ---- */
.msha-fc-tabs {
    display: flex;
    gap: 6px;
    padding: 16px 28px 0;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.msha-fc-tabs::-webkit-scrollbar {
    display: none;
}

.msha-fc-tab {
    font-family: var(--fc-mono);
    font-size: 11px;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: var(--fc-radius-sm);
    border: 1px solid var(--fc-border);
    background: transparent;
    color: var(--fc-text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    line-height: 1.4;
    min-height: 44px;
    display: flex;
    align-items: center;
    -webkit-appearance: none;
    appearance: none;
}

.msha-fc-tab:hover {
    background: var(--fc-surface-hover);
    color: var(--fc-text);
}

.msha-fc-tab.active {
    background: var(--fc-accent-dim);
    color: var(--fc-accent);
    border-color: rgba(96,165,250,0.3);
}

/* ---- Stats Bar ---- */
.msha-fc-stats {
    display: flex;
    gap: 16px;
    padding: 14px 28px;
    font-family: var(--fc-mono);
    font-size: 11px;
    color: var(--fc-text-muted);
    border-bottom: 1px solid var(--fc-border);
    flex-wrap: wrap;
}

.msha-fc-stat-value {
    font-weight: 700;
    margin-right: 4px;
}

.msha-fc-stat-value.accent { color: var(--fc-accent); }
.msha-fc-stat-value.success { color: var(--fc-success); }
.msha-fc-stat-value.warn { color: var(--fc-warn); }

/* ---- Progress Bar ---- */
.msha-fc-progress-track {
    margin: 0 28px;
    height: 3px;
    background: var(--fc-surface-hover);
    border-radius: 2px;
    overflow: hidden;
}
.msha-fc-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--fc-success), var(--fc-warn));
    border-radius: 2px;
    transition: width 0.4s ease;
}

/* ---- Filters ---- */
.msha-fc-filters {
    display: flex;
    gap: 8px;
    padding: 12px 28px;
    flex-wrap: wrap;
    align-items: center;
}

.msha-fc-filter-label {
    font-family: var(--fc-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fc-text-muted);
    margin-right: 4px;
}

.msha-fc-select {
    font-family: var(--fc-mono);
    font-size: 11px;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--fc-border);
    background: var(--fc-surface);
    color: var(--fc-text);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238b8fa3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
    min-height: 44px;
}

.msha-fc-select:focus {
    outline: none;
    border-color: var(--fc-accent);
}

.msha-fc-btn-shuffle {
    font-family: var(--fc-mono);
    font-size: 11px;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--fc-border);
    background: transparent;
    color: var(--fc-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: auto;
    min-height: 44px;
    -webkit-appearance: none;
    appearance: none;
}

.msha-fc-btn-shuffle:hover {
    background: var(--fc-surface-hover);
    color: var(--fc-text);
}

.msha-fc-btn-shuffle.active {
    background: var(--fc-purple-dim);
    color: var(--fc-purple);
    border-color: rgba(167,139,250,0.3);
}

/* ---- Card Area ---- */
.msha-fc-card-area {
    padding: 20px 28px;
}

.msha-fc-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--fc-text-muted);
    font-size: 14px;
}

/* ---- Card ---- */
.msha-fc-card {
    background: transparent;
    border: none;
    min-height: 280px;
    cursor: pointer;
    position: relative;
    perspective: 1200px;
    touch-action: pan-y;
}

.msha-fc-card-inner {
    position: relative;
    width: 100%;
    min-height: 280px;
    transition: transform 0.5s ease;
    transform-style: preserve-3d;
}

.msha-fc-card.flipped .msha-fc-card-inner {
    transform: rotateY(180deg);
}

.msha-fc-card-face {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    backface-visibility: hidden;
    border-radius: var(--fc-radius);
    padding: 28px;
    display: flex;
    flex-direction: column;
}

.msha-fc-card-face-front {
    background: linear-gradient(135deg, var(--fc-surface) 0%, var(--fc-surface-hover) 100%);
    border: 1px solid var(--fc-border);
}

.msha-fc-card-face-back {
    background: linear-gradient(135deg, #1e2233 0%, #252a3a 100%);
    border: 1px solid rgba(240,160,80,0.2);
    transform: rotateY(180deg);
}

.msha-fc-card-badges {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.msha-fc-badge {
    font-family: var(--fc-mono);
    font-size: 10px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.msha-fc-badge-module {
    background: var(--fc-accent-dim);
    color: var(--fc-accent);
}

.msha-fc-badge-type-concept,
.msha-fc-badge-type-definition {
    background: var(--fc-accent-dim);
    color: var(--fc-accent);
}

.msha-fc-badge-type-analysis,
.msha-fc-badge-type-comparison {
    background: var(--fc-purple-dim);
    color: var(--fc-purple);
}

.msha-fc-badge-type-application,
.msha-fc-badge-type-reflection {
    background: var(--fc-success-dim);
    color: var(--fc-success);
}

.msha-fc-badge-layer-core {
    background: var(--fc-warn-dim);
    color: var(--fc-warn);
}

.msha-fc-badge-layer-student_work {
    background: var(--fc-success-dim);
    color: var(--fc-success);
}

.msha-fc-badge-layer-applied {
    background: var(--fc-accent-dim);
    color: var(--fc-accent);
}

.msha-fc-card-question {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.5;
    color: var(--fc-text);
    flex: 1;
    display: flex;
    align-items: center;
}

.msha-fc-card-answer {
    font-size: 15px;
    line-height: 1.7;
    color: var(--fc-text);
    flex: 1;
}

.msha-fc-card-answer-label {
    font-family: var(--fc-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--fc-accent);
    margin-bottom: 12px;
    display: block;
}

.msha-fc-flip-hint {
    font-family: var(--fc-mono);
    font-size: 11px;
    color: var(--fc-text-muted);
    text-align: center;
    margin-top: 16px;
    opacity: 0.6;
}

.msha-fc-card-source {
    margin-top: 16px;
    font-size: 11px;
    color: var(--fc-text-muted);
    font-style: italic;
    border-top: 1px solid var(--fc-border);
    padding-top: 12px;
}

/* ---- Swipe indicators ---- */
.msha-fc-swipe-indicator {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 28px;
    color: rgba(255,255,255,0.15);
    pointer-events: none;
    transition: opacity 0.2s;
    opacity: 0;
    z-index: 10;
}
.msha-fc-swipe-indicator.left { left: 16px; }
.msha-fc-swipe-indicator.right { right: 16px; }
.msha-fc-swipe-indicator.show { opacity: 1; }

/* ---- Card flip animation ---- */
.msha-fc-card.flip-anim {
    animation: mshaFlipPulse 0.15s ease;
}
@keyframes mshaFlipPulse {
    0% { transform: scale(1); }
    50% { transform: scale(0.98); }
    100% { transform: scale(1); }
}

/* ---- Rating Buttons ---- */
.msha-fc-rating {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    flex-wrap: wrap;
}

.msha-fc-rate-btn {
    font-family: var(--fc-mono);
    font-size: 12px;
    font-weight: 500;
    padding: 12px 18px;
    border-radius: var(--fc-radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 44px;
    min-width: 60px;
    -webkit-appearance: none;
    appearance: none;
}

.msha-fc-rate-btn:active {
    transform: scale(0.96);
}

.msha-fc-rate-again {
    background: var(--fc-danger-dim);
    color: var(--fc-danger);
    border-color: rgba(248,113,113,0.2);
}

.msha-fc-rate-hard {
    background: var(--fc-warn-dim);
    color: var(--fc-warn);
    border-color: rgba(240,160,80,0.2);
}

.msha-fc-rate-good {
    background: var(--fc-accent-dim);
    color: var(--fc-accent);
    border-color: rgba(96,165,250,0.2);
}

.msha-fc-rate-easy {
    background: var(--fc-success-dim);
    color: var(--fc-success);
    border-color: rgba(74,222,128,0.2);
}

/* ---- Navigation ---- */
.msha-fc-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 12px 28px 24px;
}

.msha-fc-nav-btn {
    font-family: var(--fc-mono);
    font-size: 12px;
    padding: 10px 18px;
    border-radius: var(--fc-radius-sm);
    border: 1px solid var(--fc-border);
    background: var(--fc-surface);
    color: var(--fc-text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 44px;
    min-width: 44px;
    -webkit-appearance: none;
    appearance: none;
}

.msha-fc-nav-btn:active {
    background: rgba(255,255,255,0.05);
}

.msha-fc-nav-counter {
    font-family: var(--fc-mono);
    font-size: 12px;
    color: var(--fc-text-muted);
}

/* ---- Keyboard hints (desktop only) ---- */
.msha-fc-keys {
    text-align: center;
    padding: 8px 28px 20px;
    font-family: var(--fc-mono);
    font-size: 10px;
    color: var(--fc-text-muted);
    opacity: 0.4;
}

/* ---- Mobile hints (mobile only) ---- */
.msha-fc-keys-mobile {
    text-align: center;
    padding: 8px 28px 20px;
    font-family: var(--fc-mono);
    font-size: 10px;
    color: var(--fc-text-muted);
    opacity: 0.4;
    display: none;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
    #msha-flashcards-app {
        border-radius: 0;
        margin: 0;
    }

    .msha-fc-header {
        padding: 16px 16px 12px;
    }

    .msha-fc-title {
        font-size: 18px;
    }

    .msha-fc-tabs {
        padding: 12px 16px 0;
    }

    .msha-fc-stats {
        padding: 10px 16px;
        gap: 10px;
    }

    .msha-fc-progress-track {
        margin: 0 16px;
    }

    .msha-fc-filters {
        padding: 10px 16px;
    }

    .msha-fc-card-area {
        padding: 16px;
    }

    .msha-fc-card-face {
        padding: 20px;
    }

    .msha-fc-card-inner {
        min-height: 220px;
    }

    .msha-fc-card-question {
        font-size: 16px;
    }

    .msha-fc-card-answer {
        font-size: 14px;
    }

    .msha-fc-rating {
        padding: 10px 16px;
        gap: 6px;
    }

    .msha-fc-rate-btn {
        flex: 1;
        max-width: 100px;
        text-align: center;
    }

    .msha-fc-nav {
        padding: 10px 16px 20px;
    }

    .msha-fc-keys {
        display: none;
    }

    .msha-fc-keys-mobile {
        display: block;
    }
}
