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

html {
  font-size: 62.5%; /* 1rem = 10px */
}

body {
  background-color: var(--gray-light);
  color: var(--text-color);
  font-family: var(--font-base);
  font-size: 1.3rem;
  line-height: var(--line-height-base);
  padding: var(--gap-lg) var(--gap-md);
}

/* =============================
    INTERACTIONS
============================= */
button,
a {
  touch-action: manipulation;
}

button {
  user-select: none;
}

/* =============================
    VARIABLES
============================= */
:root {
  /* Colors */
  --primary: #174ea6;
  --primary-dark: #143e8c;
  --secondary: #d3d3d3;
  --secondary-dark: #bfbfbf;
  --success: #2ecc71;
  --error: #e74c3c;
  --warning: #f39c12;
  --info: #3498db;
  --gray-light: #f7f7f7;
  --gray: #ccc;
  --text-color: #333;
  --text-light: #444;
  --text-muted: #555;

  /* Typography */
  --font-base: Arial, sans-serif;
  --line-height-base: 1.5;

  --gap-xs: 0.4rem;
  --gap-sm: 0.8rem;
  --gap-md: 1.2rem;
  --gap-lg: 2.4rem;

  --radius-xs: 0.4rem;
  --radius-sm: 0.8rem;
  --radius-md: 1.2rem;
  --radius-lg: 2.4rem;

  --w-sm: 40rem;
  --w-md: 50rem;
}

/* =============================
    TYPOGRAPHY
============================= */
h1 {
  color: var(--primary);
  text-align: center;
}

p {
  margin-bottom: 1em;
}

input[disabled] + label {
  color: var(--gray);
}

select,
input,
textarea {
  background-color: var(--gray-light);
  border: 0.1rem solid var(--gray);
  border-radius: calc(var(--radius-md) * 1.5);
  box-sizing: border-box;
  color: var(--text-color);
  font-size: 1.4rem;
  padding: var(--gap-sm) var(--gap-md);
}

input,
textarea {
  /* TODO */
}

select {
  height: 3.2rem;
  padding: 0.6rem 2.4rem;
}

textarea {
  resize: none;
}

/* =============================
    ANIMATIONS 
============================= */
@keyframes pulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
  100% {
    opacity: 1;
  }
}

/* =============================
    CARD
============================= */
#card {
  background-color: var(--gray-light);
  border: 0.1rem solid var(--gray);
  border-radius: var(--radius-lg);
  margin: var(--gap-md) auto;
  max-width: var(--w-sm);
  min-height: 15rem;
  padding: calc(var(--gap-lg) * 1.5) var(--gap-lg) var(--gap-lg) var(--gap-lg);
  position: relative;
  text-align: center;
}

.progress-container {
  left: 50%;
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  width: calc(100% - 2 * var(--gap-lg));
}

.progress-list {
  column-gap: 0.8rem;
  display: flex;
  min-height: 1.8rem;
}

.progress-container > span {
  color: var(--primary);
  font-size: 1.2rem;
}

.progress-item {
  align-items: center;
  display: inline-flex;
  flex: 1 1 auto;
}

.progress-item > progress {
  flex: 1 1 auto;
  width: auto;
}

.progress-item > span {
  flex-shrink: 0;
  font-size: 1.2rem;
  margin-top: -0.2rem;
}

.practice-container {
  align-items: center;
  background-color: var(--gray-light);
  display: flex;
  font-size: 1.2rem;
  gap: var(--gap-xs);
  left: calc(1.25 * var(--gap-md));
  padding: 0 0.2rem;
  position: absolute;
  top: calc(1.25 * var(--gap-md));
}

#practice-mode + label {
  user-select: none;
}

#card-badge {
  font-size: 1.6rem;
  position: absolute;
  right: calc(1.25 * var(--gap-md));
  top: calc(1.25 * var(--gap-md));
}

#word {
  align-items: center;
  column-gap: var(--gap-sm);
  display: inline-flex;
}

#word > span {
  font-size: 2.4rem;
}
#word.learned > span {
  color: var(--success);
}

#phonetic {
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: var(--gap-sm);
}

#meaning {
  color: var(--text-light);
  font-size: 1.6rem;
}

/* =============================
    BUTTONS
============================= */
button[disabled] {
  opacity: 0.5;
  pointer-events: none;
}

.btn-primary,
.btn-secondary {
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-size: 1.4rem;
  padding: var(--gap-sm) var(--gap-lg);
  transition: background-color 0.2s ease;
}

.btn-primary {
  background-color: var(--primary);
  color: #fff;
}

.btn-secondary {
  background-color: var(--secondary);
  color: var(--text-color);
}

.btn-text {
  color: var(--text-color);
}

.btn-icon {
  background-color: transparent;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  flex-shrink: 0;
  font-size: 2.4rem;
  height: 3.6rem;
  justify-content: center;
  padding: 0 0 0.4rem 0;
  width: 3.6rem;
}

.quiz-words {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-xs);
}

.quiz-words button {
  background-color: var(--gray);
  color: var(--text-color);
  text-align: left;
}
.quiz-words button.correct {
  background-color: var(--success);
  color: #fff;
}
.quiz-words button.incorrect {
  background-color: var(--error);
  color: #fff;
  pointer-events: none;
}

/* =============================
    LAYOUT
============================= */
.global-action-buttons {
  align-items: center;
  column-gap: var(--gap-sm);
  display: flex;
  min-height: 2.4rem;
  position: fixed;
  right: var(--gap-xs);
  top: 0;
  z-index: 1;
}

.global-action-buttons button {
  background-color: var(--gray-light);
  border-radius: var(--radius-md);
  border-width: 0;
  cursor: pointer;
  font-size: 1.1rem;
  height: 2.4rem;
  line-height: 2.4rem;
  padding: 0 0.4rem;
  user-select: none;
}

.global-action-buttons .data-actions {
  background-color: var(--gray-light);
  position: absolute;
}

#stats {
  align-items: center;
  color: var(--text-color);
  color: var(--primary);
  display: flex;
  font-size: 1.4rem;
  font-weight: bold;
  gap: var(--gap-md);
  justify-content: center;
  min-height: 3.3rem;
  padding: 0 0 var(--gap-md) 0;
}

.actions {
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  margin: 0 auto;
  max-width: var(--w-sm);
  padding: var(--gap-sm) 0;
  position: sticky;
  top: calc(1.25 * var(--gap-md));
  z-index: 1;
}

.actions > button {
  box-shadow: 0 0 1.2rem 1.2rem #ffffffaa;
  min-width: 9.2rem;
}

.navbar {
  padding: var(--gap-md) 0;
}

.navbar ul {
  display: flex;
  gap: var(--gap-lg);
  justify-content: center;
  list-style: none;
}

.navbar a {
  color: var(--primary);
  text-decoration: none;
}

.navbar a.active {
  font-weight: bold;
}

/* =============================
    LESSON
============================= */
#card.lesson-card {
  max-width: var(--w-md);
  padding: var(--gap-lg);
}

.lesson-selection {
  margin: 0 auto;
  max-width: var(--w-md);
}

/* =============================
    FEEDBACK
============================= */
#card.feedback-card {
  max-width: var(--w-md);
}

#card.feedback-card h2 {
  color: var(--primary);
  margin-bottom: var(--gap-lg);
  text-align: center;
}

#card.feedback-card label {
  color: var(--text-light);
  display: block;
  font-weight: bold;
  margin: var(--gap-md) auto var(--gap-xs) auto;
}

#card.feedback-card input,
#card.feedback-card textarea {
  width: 100%;
}

#card.feedback-card button {
  font-size: 1.6rem;
  margin-top: var(--gap-sm);
  padding: var(--gap-sm);
  width: 100%;
}

/* =============================
    ACCESSIBILITY
============================= */
a:focus-visible,
button:focus-visible {
  outline: 0.2rem solid var(--primary);
  outline-offset: 0.2rem;
}

/* =============================
    FOOTER
============================= */
.footer {
  background-color: var(--gray-light);
  padding: var(--gap-xs) 0;
  text-align: center;
}

/* =============================
    MARKDOWN STYLES
============================= */
.marked table {
  border-collapse: collapse;
  width: 100%;
}

.marked th {
  background-color: var(--primary);
  color: #fff;
  padding: 0.6rem;
  text-align: center;
}

.marked td {
  border: 0.1rem solid var(--gray);
  padding: 0.6rem;
  text-align: center;
}

.marked td.type {
  color: var(--accent);
  font-weight: bold;
}

.marked td.hangul {
  color: var(--primary);
  font-size: 1.5rem;
  font-weight: bold;
}

.marked {
  overflow-x: auto;
}

.marked h1,
.marked h2,
.marked h3,
.marked h4,
.marked h5,
.marked h6 {
  color: var(--primary);
}

.marked h1 {
  font-size: 2.4rem;
  margin-bottom: 1rem;
}

.marked h2 {
  font-size: 2rem;
  margin-bottom: 0.8rem;
}

.marked h3 {
  font-size: 1.8rem;
  margin-bottom: 0.6rem;
}

.marked h4 {
  font-size: 1.6rem;
  margin-bottom: 0.4rem;
}

.marked h5,
.marked h6 {
  color: var(--primary);
}

.marked hr {
  border: 0;
  border-top: 0.1rem solid var(--gray);
  margin: 2rem 0;
}

/* =============================
    HOVER STYLES
============================= */
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover {
    background-color: var(--primary-dark);
  }

  .btn-secondary:hover {
    background-color: var(--secondary-dark);
  }

  .navbar a:hover {
    text-decoration: underline;
  }

  .marked tr:hover {
    background-color: var(--gray-light);
  }
}

/* =============================
    STT
============================= */
.stt-container {
  margin: 0 auto;
  max-width: var(--w-sm);
}
.sentence-pair {
  margin-bottom: 1em;
}
.original {
  font-weight: bold;
}
.translation {
  margin-left: 1em;
  color: #555;
}
.no-speech {
  color: red;
  font-style: italic;
  margin-top: 1em;
  font-weight: bold;
}
#start {
  display: inline-block;
  vertical-align: middle;
}
#model-loading-bar {
  width: 100%;
  height: 8px;
  background: #eee;
  margin-bottom: 1em;
}
#progress {
  width: 0;
  height: 100%;
  background: #0078d4;
}
#visualizer {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}
#countdown-timer {
  margin: 0;
}
