/* =========================================
   STUDY PAGE (study.html)
   Builds on styles-clean.css tokens and buttons.
========================================= */

.study-body {
    min-height: 100vh;

    background:
        linear-gradient(180deg, #1d4f9a 0%, var(--navy-soft) 340px, var(--navy) 100%)
        fixed;
}

.study-header {
    position: sticky;
    top: 0;
    z-index: 20;

    display: flex;
    align-items: center;
    gap: 12px;

    max-width: 760px;
    min-height: 64px;

    margin: 0 auto;
    padding: 0 16px;

    color: var(--white);
}

.study-home-link {
    display: grid;
    place-items: center;

    width: 38px;
    height: 38px;

    border-radius: 50%;

    background: rgba(255, 255, 255, 0.14);

    color: var(--white);

    font-size: 26px;
    line-height: 1;
    text-decoration: none;
}

.study-main {
    max-width: 760px;

    margin: 0 auto;
    padding: 4px 16px 48px;
}

.study-card {
    margin-bottom: 16px;

    padding: 18px;

    border-radius: var(--radius);

    background: var(--white);

    box-shadow: var(--shadow);
}

.study-center {
    text-align: center;
}

.study-big-emoji {
    display: block;

    margin-bottom: 6px;

    font-size: 44px;
}

.study-card h1,
.study-card h2 {
    margin: 0 0 6px;

    color: var(--navy);
}

.study-title {
    margin: 0 0 4px;

    color: var(--navy);

    font-size: 22px;
    font-weight: 900;
}

#studySetView .study-title,
#studySetView .study-set-head .study-note {
    color: var(--white);
}

#studySetView .study-set-head .study-note {
    opacity: 0.75;
}

.study-note {
    margin: 0 0 14px;

    color: var(--gray);

    font-size: 14px;
    line-height: 1.45;
}

.study-label {
    display: block;

    margin: 12px 0 6px;

    color: var(--navy);

    font-size: 13px;
    font-weight: 800;
}

.study-input {
    width: 100%;

    padding: 11px 12px;

    border: 1px solid #d7dde6;
    border-radius: 10px;

    background: var(--white);

    color: var(--black);

    outline: none;
}

.study-input:focus {
    border-color: var(--orange);

    box-shadow: 0 0 0 3px rgba(255, 138, 36, 0.12);
}

textarea.study-input {
    resize: vertical;
}

.study-drop {
    position: relative;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;

    margin-top: 14px;
    padding: 18px;

    border: 2px dashed #c9d2df;
    border-radius: var(--radius);

    background: var(--off-white);

    color: var(--navy);

    text-align: center;

    cursor: pointer;
}

.study-drop:hover {
    border-color: var(--orange);
}

.study-drop input {
    position: absolute;
    inset: 0;

    opacity: 0;

    cursor: pointer;
}

.study-drop-icon {
    font-size: 26px;
}

.study-drop small {
    color: var(--gray);
}

.study-file-list {
    margin: 8px 0 0;
    padding: 0;

    list-style: none;
}

.study-file-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;

    margin-top: 6px;
    padding: 8px 10px;

    border-radius: 10px;

    background: var(--off-white);

    font-size: 14px;
}

.study-file-list li span {
    min-width: 0;

    overflow: hidden;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.study-file-list button {
    flex-shrink: 0;

    border: 0;

    background: none;

    color: var(--gray);

    font-size: 20px;
}

.study-wide-button {
    display: block;

    width: 100%;

    margin-top: 14px;

    text-align: center;
    text-decoration: none;
}

.study-fine-print {
    margin: 10px 0 0;

    color: var(--gray);

    font-size: 12px;
    text-align: center;
}

.study-section > h2 {
    margin: 8px 0 10px;

    color: var(--white);

    font-size: 17px;
}

.study-section .study-note {
    color: rgba(255, 255, 255, 0.7);
}

.study-set-list {
    display: grid;
    gap: 10px;
}

.study-set-item {
    display: flex;
    align-items: center;
    gap: 12px;

    width: 100%;

    padding: 14px;

    border: 0;
    border-radius: var(--radius);

    background: var(--white);

    color: var(--navy);

    text-align: left;
}

.study-set-emoji {
    font-size: 26px;
}

.study-set-text {
    flex: 1;

    min-width: 0;
}

.study-set-text strong,
.study-set-text small {
    display: block;

    overflow: hidden;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.study-set-text small {
    color: var(--gray);
}

.study-set-arrow {
    color: var(--gray);

    font-size: 22px;
}

/* ---------- One set ---------- */

.study-link-button {
    padding: 6px 0;

    border: 0;

    background: none;

    color: var(--white);

    font-size: 14px;
    font-weight: 700;
}

.study-set-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;

    margin: 8px 0 12px;
}

.study-set-actions {
    display: flex;
    gap: 6px;
}

.study-icon-button {
    display: grid;
    place-items: center;

    width: 38px;
    height: 38px;

    border: 0;
    border-radius: 50%;

    background: rgba(255, 255, 255, 0.14);

    font-size: 15px;
}

.study-spinner {
    width: 40px;
    height: 40px;

    margin: 6px auto 12px;

    border: 4px solid var(--light-gray);
    border-top-color: var(--orange);
    border-radius: 50%;

    animation: study-spin 0.9s linear infinite;
}

@keyframes study-spin {
    to {
        transform: rotate(360deg);
    }
}

.study-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;

    margin-bottom: 14px;
    padding: 4px;

    border-radius: 14px;

    background: rgba(255, 255, 255, 0.12);
}

.study-tab {
    min-height: 42px;

    border: 0;
    border-radius: 10px;

    background: transparent;

    color: var(--white);

    font-weight: 800;
}

.study-tab.active {
    background: var(--white);

    color: var(--navy);
}

.study-progress-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;

    margin-bottom: 10px;

    color: rgba(255, 255, 255, 0.8);

    font-size: 14px;
    font-weight: 700;
}

.study-known {
    color: var(--yellow);
}

/* Flip card */
.study-flashcard {
    display: block;

    width: 100%;
    height: min(56vh, 360px);

    padding: 0;

    border: 0;

    background: none;

    perspective: 1200px;

    cursor: pointer;
}

.study-flashcard-inner {
    position: relative;

    display: block;

    width: 100%;
    height: 100%;

    transition: transform 0.45s ease;
    transform-style: preserve-3d;
}

.study-flashcard.is-flipped .study-flashcard-inner {
    transform: rotateY(180deg);
}

.study-face {
    position: absolute;
    inset: 0;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;

    padding: 24px;

    overflow-y: auto;

    border-radius: 20px;

    background: var(--white);

    box-shadow: var(--shadow-heavy);

    color: var(--navy);

    font-size: clamp(18px, 4.5vw, 24px);
    font-weight: 800;
    line-height: 1.35;
    text-align: center;

    backface-visibility: hidden;
}

.study-face small {
    color: var(--gray);

    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.study-back {
    transform: rotateY(180deg);

    background: #fff9e0;

    font-size: clamp(16px, 4vw, 20px);
    font-weight: 650;
}

.study-hint {
    margin: 10px 0;

    color: rgba(255, 255, 255, 0.6);

    font-size: 13px;
    text-align: center;
}

.study-card-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.study-card-tools {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 16px;

    margin-top: 12px;
}

#studyCardsDone,
#studyQuizDone {
    margin-top: 4px;
}

#studyCardsDone .study-card-buttons,
#studyQuizDone .study-card-buttons {
    margin-top: 14px;
}

/* Quiz */
.study-progress-bar {
    height: 8px;

    margin-bottom: 14px;

    overflow: hidden;

    border-radius: 999px;

    background: rgba(255, 255, 255, 0.15);
}

.study-progress-bar div {
    width: 0;
    height: 100%;

    border-radius: 999px;

    background: linear-gradient(90deg, var(--orange), var(--yellow));

    transition: width 0.3s ease;
}

.study-question {
    margin-bottom: 14px !important;

    font-size: 19px;
    line-height: 1.35;
}

.study-choices {
    display: grid;
    gap: 8px;
}

.study-choice {
    display: flex;
    align-items: center;
    gap: 12px;

    width: 100%;
    min-height: 52px;

    padding: 10px 12px;

    border: 2px solid var(--light-gray);
    border-radius: 12px;

    background: var(--white);

    color: var(--black);

    font-size: 15px;
    text-align: left;

    transition: border-color 0.15s;
}

.study-choice:hover:not(:disabled) {
    border-color: var(--orange);
}

.study-choice:disabled {
    cursor: default;
}

.study-choice-letter {
    flex-shrink: 0;

    display: grid;
    place-items: center;

    width: 28px;
    height: 28px;

    border-radius: 50%;

    background: var(--off-white);

    color: var(--navy);

    font-size: 13px;
    font-weight: 900;
}

.study-choice.is-correct {
    border-color: var(--green);

    background: rgba(34, 160, 107, 0.1);
}

.study-choice.is-correct .study-choice-letter {
    background: var(--green);

    color: var(--white);
}

.study-choice.is-wrong {
    border-color: var(--red);

    background: rgba(232, 69, 69, 0.08);
}

.study-choice.is-wrong .study-choice-letter {
    background: var(--red);

    color: var(--white);
}

.study-explanation {
    margin: 14px 0 0;
    padding: 12px;

    border-radius: 10px;

    background: var(--off-white);

    color: var(--dark-gray);

    font-size: 14px;
    line-height: 1.45;
}

@media (prefers-reduced-motion: reduce) {
    .study-flashcard-inner,
    .study-spinner {
        transition: none;
        animation: none;
    }
}
