/* ============================================================
   FlashDeckoo — Card & Study Layout
   ============================================================
   All card states (flip front/back, self-assess, feedback)
   render into the same 3-slot grid so nothing moves.
   Nav buttons always visible in footer.
   ============================================================ */

/* --- Prevent Pico overflow from breaking 3D transforms --- */
main, body > main, article, section { overflow: visible !important; }

/* === STABLE 3-SLOT LAYOUT === */
.study-layout {
    max-width: 700px;
    margin: 0 auto;
    display: grid;
    grid-template-rows: 340px 72px auto;
    gap: 0;
}

.study-card-slot {
    overflow: visible;
}

.study-action-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 72px;
    max-height: 72px;
}

.study-footer-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding-top: 0.25rem;
    width: 100%;
}

/* === HUD BAR === */
.hud-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1e1b4b;
    color: white;
    border-radius: 0.5rem;
    padding: 0.4rem 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    gap: 0.5rem;
}
.hud-left  { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.hud-right { display: flex; align-items: center; gap: 0.25rem; flex-shrink: 0; }
.hud-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.hud-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 2rem; height: 2rem; border-radius: 0.35rem;
    color: rgba(255,255,255,0.7); text-decoration: none; font-size: 1rem;
    transition: all 0.15s; cursor: pointer;
}
.hud-btn:hover       { background: rgba(255,255,255,0.15); color: white; }
.hud-btn.hud-active  { background: rgba(255,255,255,0.2); color: white; box-shadow: inset 0 -2px 0 white; }
.hud-sep             { width: 1px; height: 1.25rem; background: rgba(255,255,255,0.2); margin: 0 0.15rem; }

/* === FLIP CARD === */
.flashcard-container {
    perspective: 1200px;
    width: 100%; height: 100%;
    overflow: visible !important;
    transform-style: preserve-3d;
}
.flashcard {
    position: relative; width: 100%; height: 100%;
    cursor: pointer; transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.flashcard.flipped { transform: rotateY(180deg); }

.flashcard-face {
    position: absolute; inset: 0;
    backface-visibility: hidden; -webkit-backface-visibility: hidden;
    border-radius: 1rem; padding: 2rem;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    text-align: center; overflow: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}
.flashcard-front { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: white; font-size: 1.2rem; }
.flashcard-back  { background: white !important; color: #1f2937 !important; transform: rotateY(180deg); border: 2px solid #e5e7eb; font-size: 1.1rem; }

.flashcard-front .card-content, .flashcard-back .card-content { width: 100%; line-height: 1.7; word-wrap: break-word; }
.flashcard-front .card-content, .flashcard-front .card-content * { color: white !important; }
.flashcard-back  .card-content, .flashcard-back  .card-content * { color: #1f2937 !important; }

.flashcard-label { position: absolute; top: 0.75rem; left: 1rem; font-size: 0.75rem; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; }
.flip-hint       { position: absolute; bottom: 0.75rem; font-size: 0.8rem; opacity: 0.6; }
.card-type-badge { position: absolute; top: 0.75rem; right: 1rem; font-size: 0.7rem; background: rgba(255,255,255,0.2); padding: 0.2rem 0.5rem; border-radius: 0.5rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }

/* === ACTION SLOT CONTENTS === */

/* Self-assessment buttons */
.self-assess-buttons {
    display: flex; justify-content: center; gap: 1rem;
    visibility: hidden;          /* shown via JS on flip */
}
.self-assess-buttons[style*="visible"] { animation: fadeIn 0.25s ease; }

.btn-assess {
    padding: 0.65rem 2rem; border: none; border-radius: 0.5rem;
    font-size: 1rem; font-weight: 600; cursor: pointer;
    transition: all 0.15s; box-shadow: 0 3px 0 rgba(0,0,0,0.15); min-width: 140px;
}
.btn-assess:active     { box-shadow: none; transform: translateY(3px); }
.btn-assess-again      { background: #ef4444; color: white; }
.btn-assess-again:hover{ background: #dc2626; }
.btn-assess-got        { background: #22c55e; color: white; }
.btn-assess-got:hover  { background: #16a34a; }

/* Nav row (prev / next) */
.nav-row {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 1rem; width: 100%;
}
.btn-nav {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 5.5rem; text-align: center;
}
.btn-nav:first-child { justify-self: start; }
.btn-nav:last-child  { justify-self: end; }
.nav-done { color: var(--success); font-weight: 600; font-size: 0.95rem; }

/* Stacked feedback + nav */
.action-stack {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 0.25rem; width: 100%;
}

/* Inline feedback (compact, fits in action slot) */
.feedback-inline {
    padding: 0.3rem 1rem; border-radius: 2rem;
    font-size: 0.85rem; font-weight: 600; text-align: center;
}
.fb-correct   { background: #dcfce7; color: #166534; }
.fb-incorrect { background: #fef2f2; color: #991b1b; }

/* Progress */
.progress-bar  { background: var(--base-300); border-radius: 1rem; height: 0.4rem; width: 100%; max-width: 400px; overflow: hidden; }
.progress-fill { background: var(--primary); height: 100%; border-radius: 1rem; transition: width 0.3s ease; }
.card-progress { font-size: 0.85rem; color: #9ca3af; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Code blocks on cards */
.flashcard-front .card-content code {
    background: rgba(255,255,255,0.2);
    color: white !important;
    padding: 0.15rem 0.4rem;
    border-radius: 0.3rem;
    font-size: 0.9em;
}
.flashcard-front .card-content pre {
    background: rgba(255,255,255,0.15);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    overflow-x: auto;
    text-align: left;
    width: 100%;
}
.flashcard-front .card-content pre code {
    background: transparent;
    padding: 0;
}
.flashcard-back .card-content code {
    background: #f3f4f6;
    color: #d946ef !important;
    padding: 0.15rem 0.4rem;
    border-radius: 0.3rem;
    font-size: 0.9em;
}
.flashcard-back .card-content pre {
    background: #f3f4f6;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    overflow-x: auto;
    text-align: left;
    width: 100%;
}
.flashcard-back .card-content pre code {
    background: transparent;
    color: #1f2937 !important;
    padding: 0;
}

/* Cloze */
.cloze-blank  { display: inline-block; min-width: 4rem; padding: 0.1rem 0.5rem; border-bottom: 2px solid currentColor; font-weight: 600; text-align: center; letter-spacing: 0.1em; opacity: 0.7; }
.cloze-answer { background: rgba(34,197,94,0.15); padding: 0.15rem 0.5rem; border-radius: 0.35rem; color: #16a34a; font-weight: 600; border-bottom: 2px solid #22c55e; }

/* Study header (unused now, kept for reference) */
.study-header    { text-align: center; margin-bottom: 1rem; }
.study-header h2 { font-size: 1.3rem; color: #374151; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* === MOBILE === */
@media (max-width: 768px) {
    .study-layout { grid-template-rows: 280px 72px auto; }
    .flashcard-face { padding: 1.25rem; }
    .flashcard-front { font-size: 1.05rem; }
    .hud-title { max-width: 120px; font-size: 0.8rem; }
    .hud-bar { padding: 0.3rem 0.5rem; }
}

@media (max-width: 500px) {
    .study-layout { grid-template-rows: 320px 72px auto; }
    .self-assess-buttons { gap: 0.5rem; }
    .btn-assess { min-width: 110px; padding: 0.55rem 1.25rem; font-size: 0.9rem; }
}
