/* ==========================================================================
   Navneord: en eller et? — game-specific styles.
   Tokens, reset and base typography come from assets/css/design-system.css,
   loaded before this file.
   ========================================================================== */

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px 48px;
}

/* ── FLAGS layer ── */
#flagLayer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.flag-item {
  position: absolute;
  opacity: 0;
  animation: flagFadeIn 0.7s cubic-bezier(0.34,1.4,0.64,1) forwards;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.12));
}

@keyframes flagFadeIn {
  from { opacity: 0; transform: scale(0.3) rotate(-15deg); }
  to   { opacity: 0.2; transform: scale(1) rotate(0deg); }
}

.flag-item.vanish {
  animation: flagFadeOut 0.6s ease forwards;
}

@keyframes flagFadeOut {
  from { opacity: 0.2; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.3) rotate(12deg); }
}

/* ── Layout shell ── */
.layout {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 22px;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  max-width: 1240px;
}

.quiz-col {
  flex: 0 0 460px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Header ── */
header {
  text-align: center;
  margin-bottom: 22px;
  padding-top: 4px;
  position: relative;
  z-index: 1;
  width: 100%;
}

header h1 {
  font-size: clamp(16px, 3vw, 22px);
  letter-spacing: -0.2px;
  opacity: 0.85;
}

/* ── Stats bar ── */
.stats-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  align-items: center;
  justify-content: center;
  width: 100%;
}

/* Precision – compact */
.precision-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  max-width: 180px;
}

.precision-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.precision-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1;
}

.precision-meter {
  width: 100%;
  height: 5px;
  background: #E8E4DC;
  border-radius: 99px;
  overflow: hidden;
}

.precision-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--en-color), var(--et-color));
  border-radius: 99px;
  transition: width 0.5s ease;
  width: 0%;
}

.precision-val {
  font-size: 22px;
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* Streak block – the hero stat */
.streak-block {
  background: linear-gradient(135deg, #FFF8E4, #FFEDB5);
  border: 1.5px solid #E8CC7A;
  border-radius: 14px;
  padding: 10px 20px 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: transform 0.2s, box-shadow 0.3s;
  position: relative;
  overflow: hidden;
  flex: 1;
}

.streak-block::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,220,60,0), rgba(255,220,60,0.22));
  opacity: 0;
  transition: opacity 0.4s;
  border-radius: inherit;
  pointer-events: none;
}

.streak-block.glow::after { opacity: 1; }
.streak-block.glow {
  box-shadow: 0 0 24px rgba(212,168,67,0.55);
  transform: scale(1.03);
  border-color: #D4A843;
}

.streak-emoji-big {
  font-size: 26px;
  line-height: 1;
  min-width: 30px;
  text-align: center;
  transition: transform 0.2s;
}

.streak-block.glow .streak-emoji-big {
  animation: flameDance 0.6s ease infinite alternate;
}

@keyframes flameDance {
  from { transform: scale(1) rotate(-3deg); }
  to   { transform: scale(1.15) rotate(3deg); }
}

.streak-text-col {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.streak-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #9A7200;
  line-height: 1;
}

.streak-val {
  font-size: 38px;
  font-weight: 800;
  color: #6A4C00;
  line-height: 1;
  font-family: 'DM Serif Display', serif;
  font-variant-numeric: tabular-nums;
}

.streak-val.pop {
  animation: streakPop 0.32s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes streakPop {
  0%   { transform: scale(1); }
  55%  { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* ── Card ── */
.card-wrap {
  width: 100%;
  max-width: 460px;
  margin-bottom: 14px;
}

.card {
  position: relative;
  background: var(--surface);
  border-radius: 22px;
  padding: 42px 32px 34px;
  text-align: center;
  box-shadow: 0 4px 32px rgba(26,35,64,0.09), 0 1px 4px rgba(26,35,64,0.04);
  border: 1px solid var(--border);
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.3s, border-color 0.3s;
}

.card.correct-glow {
  box-shadow: 0 4px 32px rgba(58,138,90,0.28), 0 1px 4px rgba(26,35,64,0.04);
  border-color: #A8D9BA;
}

.card.wrong-glow {
  box-shadow: 0 4px 32px rgba(194,59,59,0.22), 0 1px 4px rgba(26,35,64,0.04);
  border-color: #F0B3B3;
}

.card.bump { animation: bump 0.22s ease; }
@keyframes bump {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.045); }
  100% { transform: scale(1); }
}

.card.shake { animation: shake 0.38s ease; }
@keyframes shake {
  0%   { transform: translateX(0); }
  18%  { transform: translateX(-9px); }
  38%  { transform: translateX(9px); }
  58%  { transform: translateX(-5px); }
  78%  { transform: translateX(5px); }
  100% { transform: translateX(0); }
}

.cat-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  background: #F3F0EA;
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 3px 10px;
  margin-bottom: 10px;
}

.word-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.word-display {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(34px, 7.5vw, 52px);
  color: var(--navy);
  line-height: 1.1;
  margin-bottom: 5px;
  transition: color 0.25s, font-size 0.15s;
}

.word-display.len-long {
  font-size: clamp(26px, 6vw, 40px);
}

.word-display.len-vlong {
  font-size: clamp(20px, 5vw, 31px);
}

.word-display .article {
  display: inline;
}

.word-display .article.en-art { color: var(--en-color); }
.word-display .article.et-art { color: var(--et-color); }

.english-hint {
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}

/* Definite form (wrong answer) */
.word-display .definite-form {
  color: var(--wrong);
}

.result-badge {
  display: none;
  margin-top: 16px;
  padding: 8px 17px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 700;
}

.result-badge.correct {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #E6F4EC;
  color: var(--correct);
  border: 1.5px solid #A8D9BA;
}

.result-badge.wrong {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #FCE8E8;
  color: var(--wrong);
  border: 1.5px solid #F0B3B3;
}

/* ── Buttons ── */
.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
  width: 100%;
  max-width: 460px;
  margin-bottom: 11px;
}

.btn-gender {
  border: none;
  border-radius: 16px;
  padding: 19px 14px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  transition: transform 0.1s, box-shadow 0.12s, opacity 0.15s;
}

.btn-gender:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: 0 8px 22px rgba(0,0,0,0.2);
}

.btn-gender:active:not(:disabled) { transform: translateY(0); }
.btn-gender:disabled { opacity: 0.45; cursor: default; }

.btn-en {
  background: var(--en-color);
  color: white;
  box-shadow: 0 3px 14px rgba(199,92,63,0.32);
}

.btn-et {
  background: var(--et-color);
  color: white;
  box-shadow: 0 3px 14px rgba(46,125,140,0.32);
}

.btn-gender .big-label {
  display: block;
  font-size: 22px;
  font-family: 'DM Serif Display', serif;
  font-weight: 400;
  margin-bottom: 2px;
}

.btn-gender .sub-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  opacity: 0.85;
}

.btn-gender .key-hint {
  display: block;
  font-size: 10px;
  opacity: 0.55;
  margin-top: 3px;
  letter-spacing: 0.5px;
}

.btn-en.revealed-correct, .btn-et.revealed-correct {
  outline: 3px solid var(--correct);
  outline-offset: 2px;
}

.btn-en.revealed-wrong, .btn-et.revealed-wrong { opacity: 0.28 !important; }

/* ── Tip box ── */
.tip-box {
  width: 100%;
  max-width: 460px;
  background: #FFFBF0;
  border: 1.5px solid #F0D98A;
  border-radius: 14px;
  padding: 11px 15px;
  font-size: 13px;
  color: #5A4800;
  display: none;
  line-height: 1.6;
  margin-bottom: 2px;
}

.tip-header {
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #9A7800;
  margin-bottom: 4px;
}

.tip-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #9A7800;
  font-size: 13px;
}

.spinner {
  width: 13px; height: 13px;
  border: 2px solid #E8CC7A;
  border-top-color: #9A7800;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* ── Sidebars (shared) ── */
.sidebar {
  flex: 0 0 200px;
  min-width: 0;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-header {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
  padding: 0 2px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.sidebar-count {
  background: var(--navy);
  color: white;
  border-radius: 99px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  min-width: 22px;
  text-align: center;
  transition: transform 0.2s;
}

.sidebar-count.pop {
  animation: sidePop 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes sidePop {
  0%   { transform: scale(1); }
  55%  { transform: scale(1.5); }
  100% { transform: scale(1); }
}

.sidebar-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow-y: auto;
  flex: 1;
  padding: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-list::-webkit-scrollbar { width: 4px; }
.sidebar-list::-webkit-scrollbar-track { background: transparent; }
.sidebar-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.sidebar-empty {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 20px 6px;
  font-style: italic;
  line-height: 1.5;
}

.mastered-word {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 5px 7px;
  border-radius: 8px;
  cursor: default;
  position: relative;
  transition: background 0.15s;
  animation: wordSlideIn 0.38s cubic-bezier(0.34,1.2,0.64,1) forwards;
  opacity: 0;
}

@keyframes wordSlideIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

.mastered-word:hover { background: #F5F1EB; }

.mastered-word:hover .word-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.mastered-art {
  font-size: 10px;
  font-weight: 800;
  min-width: 16px;
  flex-shrink: 0;
  letter-spacing: 0.2px;
}

.mastered-art.en { color: var(--en-color); }
.mastered-art.et { color: var(--et-color); }

.mastered-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--navy);
  font-family: 'DM Serif Display', serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.word-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 5px);
  transform: translateX(-50%) translateY(5px);
  background: var(--navy);
  color: white;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 10;
  font-style: italic;
  font-family: 'Inter', sans-serif;
}

.word-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--navy);
}

/* ── Ratio donut ── */
.ratio-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  display: none;
  align-items: center;
  gap: 12px;
}

.ratio-box.show { display: flex; }

.donut-wrap {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}

.donut {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: conic-gradient(var(--en-color) 0% 50%, var(--et-color) 50% 100%);
  transition: background 0.4s ease;
}

.donut-hole {
  position: absolute;
  top: 9px;
  left: 9px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface);
}

.ratio-legend {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--navy);
  font-weight: 600;
}

.ratio-legend .dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
}

.ratio-legend .dot.en { background: var(--en-color); }
.ratio-legend .dot.et { background: var(--et-color); }

/* ── Filters sidebar (left) ── */
.filters-col {
  flex: 0 0 200px;
  min-width: 0;
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.filter-section-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 7px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toggle-btn {
  --tc: var(--navy);
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 9px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--tc);
  text-align: left;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.1s ease;
}

.toggle-btn .toggle-sub {
  display: block;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  opacity: 0.6;
  margin-top: 1px;
}

.toggle-btn:hover:not(:disabled):not(.active) {
  border-color: var(--tc);
  background: color-mix(in srgb, var(--tc) 10%, white);
  transform: translateY(-1px);
}

.toggle-btn:active:not(:disabled) { transform: translateY(0); }

.toggle-btn.active {
  background: var(--tc);
  color: white;
  border-color: var(--tc);
  box-shadow: 0 3px 12px color-mix(in srgb, var(--tc) 45%, transparent);
}

.toggle-btn.active .toggle-sub { opacity: 0.8; }

.toggle-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  color: var(--muted);
}

.toggle-btn.bump { animation: bump 0.22s ease; }
.toggle-btn.shake { animation: shake 0.38s ease; }

/* ── Pool controls ── */
.pool-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pool-select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  background: var(--surface);
  cursor: pointer;
}

.pool-count {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  font-weight: 600;
}

.reset-btn {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--wrong);
  background: var(--surface);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.reset-btn:hover {
  background: #FCE8E8;
  transform: translateY(-1px);
}

.reset-btn:active { transform: translateY(0); }

/* ── Confetti ── */
#confettiWrap {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -10px;
  animation: fall linear forwards;
  border-radius: 2px;
}

@keyframes fall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ── Toast ── */
.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(-90px);
  background: var(--navy);
  color: white;
  padding: 10px 22px;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 600;
  z-index: 200;
  transition: transform 0.38s cubic-bezier(0.34,1.56,0.64,1);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.show { transform: translateX(-50%) translateY(0); }

/* ── Back-to-site link ── */
.back-link {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 10px;
  position: relative;
  z-index: 1;
}

.back-link:hover { color: var(--navy); }

/* Responsive */
@media (max-width: 1180px) {
  .layout { flex-direction: column; align-items: center; }
  .filters-col, .sidebar { position: static; max-height: none; width: 100%; max-width: 460px; }
  .filters-col { order: -1; flex-direction: row; flex-wrap: wrap; gap: 10px; }
  .filters-col .pool-box, .filters-col .filter-section-list { flex: 1 1 220px; }
  .filters-col .filter-section-list { flex-direction: row; flex-wrap: wrap; }
  .filters-col .filter-section-list .toggle-btn { flex: 1 1 calc(50% - 4px); }
  .sidebar { order: 2; }
  .sidebar-list { max-height: 150px; }
}

@media (max-width: 480px) {
  .toast { white-space: normal; text-align: center; }
}
