/* RESET & BASE */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Segoe UI", sans-serif;
    background: linear-gradient(135deg, #f0f4f8, #d9e2ec);
    color: #102a43;
    min-height: 100vh;
}

header {
    background: #334e68;
    color: #fff;
    padding: 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}

header h1 {
    font-size: 1.5rem;
}

nav button {
    margin: 0.25rem;
    background: #486581;
    color: #fff;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
}

nav button[aria-pressed="true"] {
    background: #fff;
    color: #334e68;
}

main {
    padding: 2rem;
}

/* FLASHCARD */
.card {
    width: 90vw;
    max-width: 300px;
    aspect-ratio: 3/2;
    margin: 1rem auto;
    perspective: 1000px;
    cursor: pointer;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform .6s;
}

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

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    padding: 0.5rem;
    text-align: center;
}

.card-front {
    background: #fff;
}

.card-back {
    background: #edf2f4;
    transform: rotateY(180deg);
}

/* CONTROLS */
.controls,
.quiz-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.controls button,
.quiz-controls button,
#submit-quiz {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    background: #627d98;
    color: #fff;
    cursor: pointer;
    flex: 1 1 auto;
    min-width: 80px;
    text-align: center;
}

.controls button[aria-pressed="true"],
#toggle-random[aria-pressed="true"],
#toggle-repeat[aria-pressed="true"] {
    background: #ff6f61;
    /* HIGH‑CONTRAST “ON” STATE */
    color: #fff;
}

.controls button:hover,
.quiz-controls button:hover,
#submit-quiz:hover {
    background: #1f4967;
}

/* QUIZ INPUT & FEEDBACK */
#quiz-input {
    width: 90%;
    max-width: 300px;
    margin: 0.5rem auto;
    display: block;
    padding: 0.5rem;
    font-size: 1rem;
    border: 1px solid #bcccdc;
    border-radius: 4px;
}

#feedback,
#remaining,
#score {
    margin-top: 1rem;
    text-align: center;
    font-size: 1.1rem;
}

#score {
    font-weight: bold;
}

/* FOCUS STYLES FOR ACCESSIBILITY */
button:focus,
.card:focus,
#quiz-input:focus {
    outline: 2px dashed #627d98;
    outline-offset: 2px;
}

/* RESPONSIVE TYPOGRAPHY */
@media (max-width: 400px) {
    header h1 {
        font-size: 1.2rem;
    }

    .card-face {
        font-size: 1.5rem;
    }

    nav button,
    .controls button,
    .quiz-controls button,
    #submit-quiz {
        font-size: 0.9rem;
        padding: 0.4rem 0.8rem;
    }
}

#question-counter {
    margin-top: 1rem;
    text-align: center;
    font-size: 1.1rem;
}

.list-picker {
    text-align: center;
    margin: 1rem 0;
}

.list-picker select {
    padding: 0.5rem;
    font-size: 1rem;
}

#question-counter {
    margin-top: 1rem;
    text-align: center;
    font-size: 1.1rem;
}


/* FULL‐SCREEN LOADING OVERLAY */
#loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    /* center the text */
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: #334e68;
    z-index: 9999;
    /* sit on top of everything */
}

/* browse‐mode list picker */
.list-picker {
    text-align: center;
    margin: 1rem 0;
}

.list-picker select {
    padding: 0.5rem;
    font-size: 1rem;
}

/* table styling */
#browse-container {
    width: 100%;
    max-width: 800px;
    margin: 1rem auto;
    overflow-x: auto;
}

#browse-table {
    /* Optional: prevent stretching */
    width: max-content;
    border-collapse: collapse;
}

#browse-table th,
#browse-table td {
    border: 1px solid #ddd;
    padding: 0.5rem 0.75rem;
    text-align: left;
}

#browse-table th {
    background: #f4f4f4;
}

.play-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    margin-right: 0.5rem;
}

.play-btn:hover {
    color: #334e68;
}

/* always‑visible list picker */
.list-picker {
    text-align: center;
    margin: 1rem 0;
}

.list-picker label {
    font-weight: bold;
    margin-right: 0.5rem;
}

.list-picker select {
    padding: 0.5rem;
    font-size: 1rem;
}

/* browse‑mode table */
#browse-container {
    max-width: 800px;
    margin: 1rem auto;
    overflow-x: auto;
}

#browse-table {
    width: 100%;
    border-collapse: collapse;
}

#browse-table th,
#browse-table td {
    border: 1px solid #ddd;
    padding: 0.5rem 0.75rem;
    text-align: left;
}

#browse-table th {
    background: #f4f4f4;
}

.play-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    margin-right: 0.5rem;
}

.play-btn:hover {
    color: #334e68;
}

#attempt-log {
    display: flex;
    gap: 2rem;
    margin-top: 1rem;
    padding: 1rem;
    background: #f9f9f9;
    border-radius: 6px;
}

.log-col {
    flex: 1;
}

.log-col h4 {
    margin-bottom: 0.5rem;
    font-size: 1rem;
    border-bottom: 1px solid #ddd;
    padding-bottom: 0.25rem;
}

.log-col ul {
    list-style: disc inside;
    max-height: 150px;
    overflow-y: auto;
    margin: 0;
    padding-left: 1rem;
}

.log-col ul li {
    margin: 0.2rem 0;
    font-size: 0.9rem;
}

kbd {
    background: #eee;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 0 4px;
    font-size: 0.9em;
    font-family: monospace;
}