﻿:root { 
    --nav-height: 60px; 
    --drawer-width: 360px;
    --primary: #4183d0; 
    --primary-color: #4183d0; 
    --primary-rgb: 0, 122, 255;
    --primary-background: #fff;
    --secondary-color: #1cb0f6;
    --error-color: #d23a3a;
    --text-color: #4b4b4b;
    --border-color: #888;
    --light-border-color: #E5E5E5;
    --base-font-size: 1rem; 
}
        
body {
   margin: 0;
   height: 100vh;
   padding: 10px;
   font-family: 'Segoe UI', system-ui, sans-serif;
   overflow: hidden;
   display: flex;
   flex-direction: column;
   align-items: center;
   background-color: #eef2f5;
}

#app-container {   
    flex: 1;
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    height: 100vh; 
    height: 100svh;
    min-width: 20vw;
    padding-bottom: 15vh;
    padding-top: 5px;
    -webkit-overflow-scrolling: touch;
    transition: all 0.3s ease-out;
    opacity: 1;
    /* transform: translateY(0); */
}

#app-container.hidden-anim {
    opacity: 0;
    transform: translateY(20px);
}

#app-container > * {
    height: auto !important;
}

.top-nav {
    display: flex;
    flex-direction: column;
    height: auto;
    padding: 10px;
    width: 100%;
    align-items: center;
    background: var(--primary-background);
    border-bottom: 1px solid var(--border-color);
}

.nav-content-wrapper {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.nav-row {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 10px;
}

#title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
    min-width: 0;    
    font-weight: bold;
    padding: 0 10px;
}

@media (max-width: 360px) {
    #title { font-size: 0.9em; }
}

@media (max-width: 600px) {
    #app-container {
        min-width: 80vw;
        margin: 0 auto; 
        max-width: 100vw;
    }
}

.completion-screen {
    text-align: center;
}

/* errors-panel  */
.progress-container {
    width: 100%;
    max-width: 100%;
    height: 16px;
    box-sizing: border-box;
    background: var(--border-color);
    border-radius: 10px;
    margin: 20px 0;
    overflow: hidden;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

.flashcards-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.flashcard-wrapper {
    position: relative;
    user-select: none;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 10px;
    box-sizing: border-box;
}

.flashcard-header {
    display: flex;
    margin-top: 10px;
    margin-bottom: 10px;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    background: var(--primary-background);
    width: 100%;
    box-sizing: border-box;
}

#card-counter {
  white-space: nowrap;
  font-weight: bold;
  margin: 5px;
  text-align: center;
  flex: 0 0 auto; 
  padding: 0 10px;
  font-size: 1.2rem;
  color: var(--border-color);
}

.mode-toggle, .speed-controls {
    flex: 1;
    display: flex;
}

.mode-toggle-wrapper {
    flex: 1;
    display: flex;
    justify-content: flex-start;
}

.mode-toggle {
  cursor: pointer;
  border: 3px solid var(--border-color);
  color: var(--border-color);
  border-radius: 5px;
  margin: 5px;
  font-size: 1.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;}

.speed-controls {
    justify-content: flex-end;
    align-items: center;
    gap: 5px;
}

.card-controls {
    display: flex;
    justify-content: center;
}

.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: var(--primary-background);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    box-shadow: none;
    border: 3px solid var(--border-color);
    color: var(--border-color);
    cursor: pointer;
    font-size: 2rem;
    user-select: none;
}

.nav-btn.prev { left: 0px; top: 165px; }
.nav-btn.next { right: 0px; top: 165px; }

.action-btn {
    cursor: pointer;
    margin: 0px 10px 10px 0px;
    padding: 15px 25px;
    border-radius: 30px;
    border: solid 3px;
    font-weight: bold;
    min-width: 38%;
}

.action-btn.easy { border-color: var(--primary); color: var(--primary); }
.action-btn.hard { border-color: var(--error-color); color: var(--error-color); }

.row-btn {
  margin-top: 10px;
}

.ar-text { direction: rtl; font-size: calc(var(--base-font-size) * 2); color: #222; margin-bottom: 10px; }
.ru-text { font-size: 1.8rem; color: #2196F3; }
.tr-text { color: #666; font-style: italic; margin-top: 5px; }

#card-anchor { transition: all 0.2s ease; }

.flashcard.flipped {
    transform: rotateY(180deg);
}

.flashcard {
    transition: transform 0.6s ease;
    transform-style: preserve-3d;
    position: relative;
    width: 300px;
    height: 200px;
    margin-bottom: 10px;
}

.card-front, .card-back {
    position: absolute; /* Обязательно для наложения друг на друга */
    top: 0; 
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden; /* КРИТИЧЕСКИ ВАЖНО: скрывает изнанку */
    -webkit-backface-visibility: hidden;
    display: flex;
    overflow: hidden;
    padding: 10px;
    box-sizing: border-box;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white; /* Фон, чтобы не просвечивало */
    border: 1px solid var(--border-color);
    border-radius: 15px;
}

.card-back {
    transform: rotateY(180deg); /* Поворачиваем изнанку на 180 градусов */
}

.matching-container {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
    max-width: 600px; width: 100%; min-height: 300px;
}

#progress-bar-fill {
    height: 100%;
    width: 0%;
    background: #4caf50;
    transition: width 0.3s ease;
}

.audio-main-btn {
  border-radius: 5px;
  margin: 10px;
}

@keyframes shake {
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

.win-screen {
    display: none; position: fixed; top: 50%; left: 50%;
    transform: translate(-50%, -50%); background: white;
    padding: 40px; border-radius: 20px; box-shadow: 0 10px 50px rgba(0,0,0,0.3);
    text-align: center; width: 80%; max-width: 350px;
}

.card {
    flex: 1 1 45%; 
    min-width: 140px; 
    max-width: 300px;
    padding: 20px;
    text-align: center;
    font-size: calc(var(--base-font-size) * 1.5);
    padding: 15px 10px;
    border: 1px solid var(--border-color);
    border-radius: 15px;
    cursor: pointer; text-align: center;
    background: white;
    display: flex; align-items: center;
    justify-content: center;
    user-select: none;
    transition: 0.1s;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card.selected { background-color: #ddf4ff; border-color: #84d8ff; color: var(--secondary-color); }
.card.correct { opacity: 0.15; pointer-events: none; transform: scale(0.9); border-color: transparent; }
.card.wrong { background-color: #ffdfe0; border-color: var(--error-color); animation: shake 0.3s; }
.wrong { border-color: var(--error-color); animation: shake 0.3s; }

.arabic { direction: rtl; font-size: calc(var(--base-font-size) * 2); }

.errors-panel {
    color:#afafaf;
    padding-left: 8px;
    background: #f9f9f9;
    font-weight:bold;
    border: 1px solid var(--border-color);
    margin-bottom: 10px;
    margin-top: 10px;
    border-radius: 5px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.hint-panel {
    margin: 20px 0;
    min-height: 3em;
    background: #f9f9f9;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    font-style: italic;
    color: #888;
}

#dictToggleBtn { color: var(--primary-color); font-weight: bold; }

#accuracyStat {
  font-size: 3rem;
  color: var(--primary-color);
  font-weight: bold;
  margin-bottom: 15px;
}

#nextGameBtn {padding:15px 40px; }

.actionBtn {
  background:var(--primary-color);
  color:white;
  border:none;
  margin-bottom: 20px;
  border-radius: 15px;
  cursor: pointer;
  font-weight: bold;
  font-size: larger;
  padding: 15px 15px;
}

.sent-words {
    background: var(--primary-background);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 15px 30px;
    margin-bottom: 20px;
    font-size: 1.8rem;
    min-height: 80px;	
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.sent-word {
    display: inline-block;
    user-select: none;
    background: var(--primary-background);
    border: 2px solid var(--light-border-color);
    border-bottom: 4px solid var(--light-border-color);
    border-radius: 12px;
    max-height: 2.5rem;
    padding: 5px;
    margin: 5px;
    cursor: pointer;
}

.sent-word-used {
    background: var(--light-border-color);
    color: var(--light-border-color);
    cursor: default;
}

.question-card {
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 15px 20px;
    margin-bottom: 20px;
    text-align: center;
    font-size: calc(var(--base-font-size) * 1.5);
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* 2x2 для планшетов */
    gap: 15px;
}

@media (max-width: 500px) {
    .options-grid {
       grid-template-columns: 1fr;
       justify-items: center;
    }
    .quiz-card {
       min-width: 80vw;
    }
}

#dictionaryList {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.dictionaryCard {
  display: block;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 15px;
  cursor: pointer;
}

.dictionaryTransl {
  font-size: 1.1em; 
  color: #333; 
  margin-top: 4px;
}

.transcription {
    color: #666;
    font-style: italic;
}

.transcription.hidden {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

.nav-controls {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.nav-arrow {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 0.85rem;
}

.exercise-path {
    list-style: none;
    padding-bottom: 20px;
    display: flex;
    flex-direction: column;
    padding-inline-start: 0px;
    align-items: center;
}

.exercise-node {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px;
    width: 80%;
    border-bottom: 2px dashed #ccc; /* delimiter */
    cursor: pointer;
    transition: 0.3s;
}

.exercise-node:hover {
    background: #f0f0f0;
    transform: scale(1.02);
}

.node-icon {
    width: 35px;
    height: 35px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.exercise-node.current {
    background: #fff;
    border: 2px solid var(--primary);
    transform: scale(1.1);
    /*box-shadow: 0 4px 10px var(--primary);*/
}

.exercise-node.current .node-icon {
    background: var(--primary);
    animation: pulse 2s infinite;
}

@keyframes pulse {
0%   { box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.7); }
70%  { box-shadow: 0 0 0 10px rgba(var(--primary-rgb), 0); }
100% { box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0); }
}


.drawer {
    display: flex;
    flex-direction: column;
    position: fixed; 
    left: calc(-1 * var(--drawer-width));
    top: 0; 
    width: var(--drawer-width); 
    height: 100%;
    background: white; 
    z-index: 1001; 
    transition: left 0.3s ease;
    padding: 10px;
    box-shadow: 5px 0 15px rgba(0,0,0,0.2);
    box-sizing: border-box;
}

.drawer-header {
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
}

.drawer-title {
    position: relative;
    padding: 15px;
}

.title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

#currentTopicName {
    margin: 0;
    font-size: 1.1rem;
    padding-right: 10px;
    padding-top: 7px;
    padding-left: 20px;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
}

.topic-stats {
    /* display: flex; */
    gap: 15px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(var(--primary-rgb), 0.1);
    font-size: 0.85rem;
    color: #666;
}

.stat-value {
    font-weight: bold;
    color: var(--primary);
    margin-left: 4px;
}

.title-actions {
    display: flex;
    gap: 5px;
    z-index: 10;
}

.icon-btn {
    background: none;
    border: 1px solid transparent;
    font-size: 1.2rem;
    cursor: pointer;
    color: #666;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--primary);
}

.drawer-title {
    position: relative;
    display: flex;
    overflow: hidden;
    flex-direction: column;
    padding: 0 10px 10px 10px;
}

.drawer-title::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    /* Corner triangle */
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 35px 35px 0 0; /* size */
    border-color: var(--primary) transparent transparent transparent;
    
    display: flex;
    justify-content: center;
    align-items: center;
    
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.drawer-title::after {
    content: "✓";
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 12px;
    color: white;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
}

.drawer-title.is-passed::before,
.drawer-title.is-passed::after {
    opacity: 1;
}

.drawer-title.is-passed {
    background: rgba(var(--primary-rgb), 0.05);
}

#topic-settings {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 0;
    margin-bottom: 5px;
    font-size: 0.8rem;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
}

#topic-settings.hidden {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

.pass-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    color: #555;
}

#topicPassedCheckbox {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    outline: none;
}

#topicPassedCheckbox:hover {
    border-color: var(--primary);
    background-color: rgba(var(--primary-rgb), 0.03);
}

#topicPassedCheckbox:checked {
    border-color: var(--primary);
    background-color: var(--primary);
}

#topicPassedCheckbox::after {
    content: "✓";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: 14px;
    color: white;
    font-weight: bold;
    transition: transform 0.2s ease-out;
}

#topicPassedCheckbox:checked::after {
    transform: translate(-50%, -50%) scale(1);
}

.drawer-title.is-passed .pass-toggle {
    color: var(--primary);
}

.btn-reset {
    background: none;
    border: none;
    color: var(--error-color);
    cursor: pointer;
    font-size: 0.75rem;
    padding: 2px 5px;
    opacity: 0.8;
}

.btn-reset:hover {
    opacity: 1;
    text-decoration: underline;
}

.nav-controls {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 10px;
}

.nav-arrow {
    flex: 1;
    padding: 8px;
}

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

.drawer-content::-webkit-scrollbar {
    width: 6px;
}

.drawer-content::-webkit-scrollbar-thumb {
    background-color: #ddd;
    border-radius: 10px;
}

.drawer.open { left: 0; }

#overlay {
    position: fixed; 
    top: 0; left: 0; 
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); 
    display: none;
    z-index: 999;
}

#overlay.active { display: block; }

.drawer h3 {
  font-size: 14px;
  color: #888;
  text-transform:
  uppercase;
  margin-top: 20px;
}

.setting-group { margin: 20px 0; padding: 0 5px; }
.setting-item { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 15px;
    padding: 10px 5px;
}

/* state switch */
.segmented-control {
    display: flex;
    position: relative;
    background: #f0f0f0;
    border-radius: 10px;
    padding: 2px;
    margin-top: 8px;
}

.segmented-control input { display: none; }

.segmented-control label {
    flex: 1;
    text-align: center;
    padding: 8px 0;
    font-size: 14px;
    cursor: pointer;
    z-index: 1;
    transition: color 0.3s;
}

.segmented-control input:checked + label { color: #fff; font-weight: bold; }

/* tri-state slider */
.selection-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 33.33%;
    height: calc(100% - 4px);
    background: var(--primary);
    border-radius: 8px;
    transition: transform 0.3s ease;
    z-index: 0;
}

/* switching logic */
#diff-easy:checked ~ .selection-slider { transform: translateX(0%); }
#diff-medium:checked ~ .selection-slider { transform: translateX(100%); }
#diff-hard:checked ~ .selection-slider { transform: translateX(200%); }

/* Toggle */
.switch { position: relative; width: 50px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc; transition: .4s; border-radius: 34px;
}
.slider:before {
    position: absolute; content: ""; height: 18px; width: 18px; left: 4px; bottom: 4px;
    background-color: white; transition: .4s; border-radius: 50%;
}
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(24px); }

.reset-btn {
    width: 100%;
    padding: 12px;
    background: #fff0f0;
    color: #ff4b4b;
    border: 1px solid #ffcccc;
    border-radius: 10px;
    font-weight: bold;
    cursor: pointer;
}

.drawer-footer {
    margin-top: auto;
    padding: 20px;
    border-top: 1px solid #eee;
}

.github-link {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #666;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

.github-link:hover {
    color: var(--primary);
}

@keyframes burst {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); color: #4caf50; }
    100% { transform: scale(1); opacity: 0.8; }
}

.success-sparkle {
    position: absolute;
    top: -25px; /* Сдвигаем вверх за границу кнопки */
    left: 50%;
    transform: translateX(-50%) scale(2); /* Увеличиваем вдвое */
    font-size: 24px; /* Делаем сам символ крупнее */
    pointer-events: none;
    animation: fadeUp 0.5s ease-out forwards;
}

@keyframes fadeUp {
    0% { opacity: 1; transform: translateX(-50%) translateY(0) scale(2); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-20px) scale(2.5); }
}

.correct-animation {
    animation: burst 0.4s ease-out;
    border-color: var(--primary) !important;
}

.search-container {
    display: flex;
    align-items: center;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 5px 10px;
    background: white;
    width: 90vw;
    max-width: 600px;
    margin: 10px auto;
}

.search-container:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 4px rgba(88, 204, 2, 0.3);
}

#dictSearch {
    flex: 1;
    border: none;
    outline: none;
    padding: 8px;
    font-size: 16px;
}

#clearSearch {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--primary-color);
    padding: 0 5px;
}

.toolbarBtn {
    border-width: 1px;
    min-height: 1.8rem;
    border-radius: 3px;
    font-size: larger;
}
