/* Outer shell for the island */
.study-shell {
    max-width: 1024px;
    margin: 0 auto 2rem;
    padding: 0 1.5rem;
}

/* Top bar */
.study-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 1rem 0 0.75rem;
}

.study-back {
    text-decoration: none;
    color: var(--fc-text-main);
    padding: 8px 10px;
    border-radius: var(--fc-radius-md);
    border: 1px solid var(--border);
    background: white;
}

.study-back:hover,
.study-back:focus-visible {
    background: var(--fc-bg-panel-soft);
    outline: none;
}

.study-topbar-title {
    font-weight: 600;
    color: var(--fc-text-main);
}

.study-topbar-right {
    width: 44px; /* keeps title centered-ish */
}

/* Empty/error wrapper used by Empty.svelte */
.study-empty {
    margin-top: 0.75rem;
    padding: 1rem;
    border-radius: var(--fc-radius-lg);
    border: 1px solid var(--border);
    background: var(--fc-bg-panel-soft);
}

.study-empty-actions {
    margin-top: 0.75rem;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Loading skeleton (Empty kind="loading") */
.study-skeleton {
    margin-top: 0.75rem;
    padding: 1rem;
    border-radius: var(--fc-radius-lg);
    border: 1px solid var(--border);
    background: var(--fc-bg-panel-soft);
    display: grid;
    gap: 0.75rem;
}

.skel {
    position: relative;
    overflow: hidden;
    border-radius: var(--fc-radius-md);
    background: rgba(255, 255, 255, 0.10);
}

.skel::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.16), transparent);
    animation: fc-shimmer 1.15s infinite;
}

@keyframes fc-shimmer { 100% { transform: translateX(100%); } }

.skel-line { height: 14px; }
.skel-box { height: 220px; border-radius: var(--fc-radius-lg); }

.w-40 { width: 40%; }
.w-55 { width: 55%; }
.w-70 { width: 70%; }
.w-80 { width: 80%; }

@media (prefers-reduced-motion: reduce) {
    .skel::after { animation: none !important; }
}

/* No-cards-due state */
#no-cards {
    margin: 1.5rem 0;
    padding: 1.5rem;
    background: var(--primary-bg);
    border-radius: var(--fc-radius-lg);
    border: 1px solid var(--primary-light);
    font-size: 0.9375rem;
    color: var(--fc-text-muted);
    text-align: center;
}

/* Study section wrapper */
.study {
    margin-top: 1.5rem;
}

/* Header row (title + due note) */
.study-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.study-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--fc-text-main);
}

.study-header-left {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.study-note {
    margin: 0;
    font-size: 0.875rem;
    color: var(--fc-text-muted);
}

/* Session metadata (remaining count) */
.study-meta {
    margin-bottom: 0.75rem;
}

#session-remaining {
    font-size: 0.875rem;
    color: var(--fc-text-muted);
    background: var(--fc-bg-panel-soft);
    padding: 0.5rem 1rem;
    border-radius: var(--fc-radius-md);
    display: inline-block;
}

/* Card stage: DOM card + future WebGL overlay */
.card-stage {
    position: relative;
}

.card-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;

    /* Always mounted; hidden by default */
    opacity: 0;
    pointer-events: none;

    border: 1px solid var(--border);
    border-radius: var(--fc-radius-lg);
    background: white;
    box-shadow: var(--fc-shadow-md);
    overflow: hidden;
    transition: opacity 120ms linear;
}

.card-overlay canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.card-overlay .gl-wrap {
    width: 100%;
    height: 100%;
}

.card-stage.gl-active .card-overlay {
    opacity: 1;
}

/* When GL is active, keep DOM card in flow but non-interactive + invisible */
.card-stage.gl-active .fc-card {
    opacity: 0;
    pointer-events: none;
}

.card-stack {
    position: relative;
}

/* Study card (fc- classes kept to match classic DOM) */
.fc-card {
    border-radius: var(--fc-radius-lg);
    border: 1px solid var(--border);
    padding: 2rem;
    background: white;
    box-shadow: var(--fc-shadow-md);
    min-height: 160px;
    display: grid;
    align-items: center;
    justify-items: center;
    position: relative;
    overflow: hidden;
}

.fc-face {
    font-size: 1.75rem;
    text-align: center;
    line-height: 1.35;
    padding: 0.5rem;
    word-break: break-word;
    color: var(--fc-text-main);
}

.fc-back {
    display: none;
    color: var(--primary);
}

/* Reveal behaviour */
.fc-card.revealed .fc-front {
    opacity: 0.4;
}

.fc-card.revealed .fc-back {
    display: block;
}

/* Controls row under the card */
.study-controls {
    margin-top: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

/* Grade bar layout */
.button-group {
    display: inline-flex;
    border-radius: var(--fc-radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
    background: white;
}

.button-group .button {
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--border);
}

.button-group .button:last-child {
    border-right: none;
}

/* Utility for show/hide toggles */
.fc-hidden {
    display: none !important;
}

/* Small-screen tweaks */
@media (max-width: 768px) {
    .study-shell {
        padding: 0 1rem;
    }
}

.study-deck-chooser {
    margin-bottom: 1rem;
    font-size: 0.9375rem;
}

.study-deck-chooser label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--fc-text-muted);
    font-weight: 500;
}

.study-deck-chooser select {
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    border-radius: var(--fc-radius-md);
    border: 1px solid var(--border-strong);
    background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E") no-repeat right 0.5rem center;
    color: var(--fc-text-main);
    font-size: 0.875rem;
    appearance: none;
}

/* Progress bar */
.study-progress {
    margin: 0.5rem 0 0.75rem;
    height: 8px;
    border-radius: 9999px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.04);
}

.study-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--primary);
    opacity: 0.35;
    transition: width 160ms linear;
}

@media (prefers-reduced-motion: reduce) {
    .study-progress-bar { transition: none; }
}
