/* =====================================================
   D-Dact Spellingplatform — Stylesheet
   Huisstijl: Poppins, #dd5c65 (koraalrood), #37a1af (teal)
   ===================================================== */

/* ── Reset & Base ─────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Poppins', sans-serif;
  font-weight: 400;
  background-color: #f2efef;
  color: #2d2d2d;
  min-height: 100vh;
  line-height: 1.6;
}

/* ── CSS Variables ────────────────────────────────── */
:root {
  --coral:     #dd5c65;
  --coral-dark:#c44d55;
  --teal:      #37a1af;
  --teal-dark: #2d8a97;
  --yellow:    #f9b100;
  --bg:        #f2efef;
  --white:     #ffffff;
  --text:      #2d2d2d;
  --text-light:#666666;
  --border:    #ddd;
  --shadow:    0 2px 12px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.12);
  --radius:    12px;
  --radius-sm: 8px;
}

/* ── Views ────────────────────────────────────────── */
.view {
  display: none;
  min-height: 100vh;
}

.view.active {
  display: block;
}

/* ── Site Header ──────────────────────────────────── */
.site-header {
  background: var(--coral);
  color: var(--white);
  padding: 1.25rem 2rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header-inner {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.logo {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--white);
}

.logo span {
  color: var(--yellow);
}

.header-subtitle {
  font-size: 0.9rem;
  font-weight: 300;
  opacity: 0.9;
  letter-spacing: 1px;
  text-transform: uppercase;
  flex: 1;
}

.btn-library-nav {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.4);
  color: var(--white);
  border-radius: 20px;
  padding: 0.4rem 1rem;
  font-family: 'Poppins', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}

.btn-library-nav:hover {
  background: rgba(255,255,255,0.35);
}

/* ── Setup View ───────────────────────────────────── */
.setup-main {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.setup-section {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1.25rem;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--coral);
  color: var(--white);
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* Groep knoppen */
.group-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

@media (max-width: 500px) {
  .group-buttons {
    grid-template-columns: repeat(2, 1fr);
  }
}

.group-btn {
  padding: 1.1rem 0.5rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  font-family: 'Poppins', sans-serif;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: center;
}

.group-btn:hover {
  border-color: var(--coral);
  color: var(--coral);
  background: #fff5f5;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(221,92,101,0.15);
}

.group-btn.selected {
  border-color: var(--coral);
  background: var(--coral);
  color: var(--white);
  box-shadow: 0 4px 12px rgba(221,92,101,0.3);
}

/* Categorieën grid */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.category-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--bg);
}

.category-checkbox:hover {
  border-color: var(--teal);
  background: #f0fafb;
}

.category-checkbox.checked {
  border-color: var(--teal);
  background: #e8f7f9;
}

.category-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
  margin-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
}

.category-checkbox span {
  font-size: 0.88rem;
  font-weight: 400;
  line-height: 1.4;
  color: var(--text);
}

.select-all-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
}

.btn-link {
  background: none;
  border: none;
  color: var(--teal);
  font-family: 'Poppins', sans-serif;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.btn-link:hover {
  color: var(--teal-dark);
}

.divider {
  color: var(--text-light);
  font-size: 0.8rem;
}

/* Instellingen */
.settings-grid {
  display: grid;
  gap: 1.5rem;
}

.setting-block {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.setting-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.range-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.range-input {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--coral);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(221,92,101,0.4);
}

.range-input::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--coral);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(221,92,101,0.4);
}

.range-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--coral);
  min-width: 2.5rem;
  text-align: center;
}

.timer-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.6rem;
}

.timer-option {
  display: flex;
  align-items: center;
  gap: 0;
  cursor: pointer;
}

.timer-option input[type="radio"] {
  display: none;
}

.timer-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 400;
  background: var(--bg);
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
}

.timer-option input[type="radio"]:checked + .timer-label {
  border-color: var(--coral);
  background: #fff5f5;
  color: var(--coral);
  font-weight: 500;
}

.timer-icon {
  font-size: 1rem;
}

/* Genereer knop */
.generate-row {
  display: flex;
  justify-content: center;
  padding: 0.5rem 0 1rem;
}

/* ── Knoppen ──────────────────────────────────────── */
.btn-primary {
  background: var(--coral);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem 2rem;
  font-family: 'Poppins', sans-serif;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: 0 3px 10px rgba(221,92,101,0.3);
}

.btn-primary:hover {
  background: var(--coral-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(221,92,101,0.4);
}

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

.btn-primary.btn-large {
  font-size: 1.1rem;
  padding: 0.9rem 2.5rem;
  border-radius: 14px;
}

.btn-secondary {
  background: var(--white);
  color: var(--teal);
  border: 2px solid var(--teal);
  border-radius: var(--radius);
  padding: 0.7rem 1.5rem;
  font-family: 'Poppins', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn-secondary:hover {
  background: var(--teal);
  color: var(--white);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(55,161,175,0.3);
}

.btn-back {
  background: none;
  border: none;
  color: var(--text-light);
  font-family: 'Poppins', sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.4rem 0;
  transition: color 0.15s;
}

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

/* ── Woordenlijst View ────────────────────────────── */
.wordlist-main {
  max-width: 700px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem;
}

.wordlist-header {
  margin-bottom: 1.5rem;
}

.wordlist-title {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0.75rem 0 0.25rem;
}

.wordlist-subtitle {
  font-size: 0.9rem;
  color: var(--text-light);
  font-weight: 300;
}

.wordlist-container {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.word-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.word-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  transition: background 0.12s;
}

.word-item:hover {
  background: #f0fafb;
  border-color: var(--teal);
}

.word-number {
  font-size: 0.78rem;
  color: var(--text-light);
  min-width: 1.5rem;
  text-align: right;
  font-weight: 300;
}

.word-text-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: 'Poppins', sans-serif;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  outline: none;
  padding: 0;
}

.word-text-input:focus {
  color: var(--coral);
}

.word-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #ccc;
  font-size: 1rem;
  line-height: 1;
  padding: 0.2rem;
  border-radius: 4px;
  transition: all 0.12s;
  flex-shrink: 0;
}

.word-delete-btn:hover {
  color: var(--coral);
  background: #fff0f0;
}

.add-word-row {
  display: flex;
  gap: 0.75rem;
}

.add-word-input {
  flex: 1;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  font-family: 'Poppins', sans-serif;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

.add-word-input:focus {
  border-color: var(--teal);
}

.wordlist-actions {
  display: flex;
  justify-content: flex-end;
}

/* ── Oefening View ────────────────────────────────── */
.practice-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.btn-back-practice {
  background: none;
  border: none;
  color: var(--text-light);
  font-family: 'Poppins', sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.3rem 0;
  white-space: nowrap;
  transition: color 0.15s;
}

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

.progress-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: center;
}

.progress-text {
  font-size: 0.82rem;
  color: var(--text-light);
  font-weight: 300;
}

.progress-bar-track {
  width: 100%;
  max-width: 300px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--coral);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.group-badge {
  background: var(--teal);
  color: var(--white);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  white-space: nowrap;
}

.practice-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 70px);
  padding: 2rem 1.5rem;
  text-align: center;
}

/* Fase-puntjes */
.phase-dots {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2.5rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.2s;
}

.dot.active {
  background: var(--coral);
}

.dot.done {
  background: var(--teal);
}

/* Woord weergave — font-size wordt dynamisch gezet door calcWordFontSize() */
.word-display {
  font-weight: 700;
  color: var(--coral);
  letter-spacing: -2px;
  line-height: 1.05;
  text-align: center;
  word-break: break-word;
  max-width: 92vw;
  min-height: 8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2rem;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.word-display.hidden {
  opacity: 0;
  transform: scale(0.95);
}

.word-display.visible {
  opacity: 1;
  transform: scale(1);
}

/* Timer — volledig losgekoppeld, eigen rij onder het woord */
.timer-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  width: 100%;
  max-width: 320px;
}

.timer-bar-track {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.timer-bar-fill {
  height: 100%;
  background: var(--coral);
  border-radius: 4px;
  width: 100%;
  transition: width 1s linear;
}

.timer-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--coral);
  line-height: 1;
  min-width: 2.5rem;
  text-align: center;
}

/* Instructie tekst */
.instruction-text {
  font-size: 1rem;
  color: var(--text-light);
  font-weight: 300;
  margin-bottom: 1.5rem;
  min-height: 1.6rem;
}

/* Actieknop oefening */
.btn-practice-action {
  background: var(--coral);
  color: var(--white);
  border: none;
  border-radius: 50px;
  padding: 1rem 2.5rem;
  font-family: 'Poppins', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: 0 4px 16px rgba(221,92,101,0.35);
  letter-spacing: 0.3px;
}

.btn-practice-action:hover {
  background: var(--coral-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(221,92,101,0.45);
}

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

.btn-practice-action.secondary {
  background: var(--teal);
  box-shadow: 0 4px 16px rgba(55,161,175,0.35);
}

.btn-practice-action.secondary:hover {
  background: var(--teal-dark);
  box-shadow: 0 8px 24px rgba(55,161,175,0.45);
}

/* Keyboard hint */
.keyboard-hint {
  margin-top: 1rem;
  font-size: 0.75rem;
  color: #bbb;
}

/* Eindscherm */
.end-screen {
  position: fixed;
  inset: 0;
  background: rgba(242,239,239,0.97);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.end-content {
  text-align: center;
  padding: 2rem;
}

.end-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.end-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--coral);
  margin-bottom: 0.5rem;
}

.end-subtitle {
  font-size: 1rem;
  color: var(--text-light);
  font-weight: 300;
  margin-bottom: 2rem;
}

.end-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Animaties ────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.setup-section, .wordlist-container {
  animation: fadeIn 0.25s ease both;
}

@keyframes wordAppear {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

.word-display.appear {
  animation: wordAppear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ── Bibliotheek View ─────────────────────────────── */
.library-main {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 4rem;
}

.library-intro {
  margin-bottom: 1.75rem;
}

.library-title {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.library-desc {
  font-size: 0.9rem;
  color: var(--text-light);
  font-weight: 300;
  line-height: 1.6;
}

/* Groep-tabs */
.lib-group-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.lib-tab {
  padding: 0.55rem 1.25rem;
  border: 2px solid var(--border);
  border-radius: 20px;
  background: var(--white);
  font-family: 'Poppins', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.15s;
}

.lib-tab:hover {
  border-color: var(--coral);
  color: var(--coral);
}

.lib-tab.active {
  background: var(--coral);
  border-color: var(--coral);
  color: var(--white);
}

/* Categorieën accordion */
.lib-categories {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.lib-cat-block {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.lib-cat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
}

.lib-cat-header:hover {
  background: #fafafa;
}

.lib-cat-name {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 500;
}

.lib-cat-count {
  font-size: 0.78rem;
  color: var(--text-light);
  font-weight: 300;
}

.lib-modified-badge {
  font-size: 0.7rem;
  background: var(--teal);
  color: var(--white);
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-weight: 600;
}

.lib-cat-toggle {
  font-size: 0.8rem;
  color: var(--text-light);
  transition: transform 0.2s;
}

.lib-cat-block.open .lib-cat-toggle {
  transform: rotate(180deg);
}

.lib-cat-body {
  display: none;
  padding: 0 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
}

.lib-cat-block.open .lib-cat-body {
  display: block;
}

/* Woordenlijst in bibliotheek */
.lib-word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
  padding-top: 1rem;
}

.lib-word-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.25rem 0.7rem 0.25rem 0.85rem;
  font-size: 0.88rem;
  font-weight: 400;
  color: var(--text);
  transition: all 0.12s;
}

.lib-word-chip:hover {
  border-color: var(--coral);
  background: #fff5f5;
}

.lib-chip-delete {
  background: none;
  border: none;
  color: #ccc;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.1s;
}

.lib-chip-delete:hover {
  color: var(--coral);
}

/* Toevoegen & reset */
.lib-add-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.lib-add-input {
  flex: 1;
  min-width: 150px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.85rem;
  font-family: 'Poppins', sans-serif;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

.lib-add-input:focus {
  border-color: var(--teal);
}

.btn-lib-add {
  background: var(--teal);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  font-family: 'Poppins', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn-lib-add:hover {
  background: var(--teal-dark);
}

.btn-lib-reset {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-light);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.85rem;
  font-family: 'Poppins', sans-serif;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-lib-reset:hover {
  border-color: var(--coral);
  color: var(--coral);
}

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 600px) {
  .site-header {
    padding: 1rem;
  }

  .header-inner {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .setup-main, .wordlist-main, .library-main {
    padding: 1rem 1rem 4rem;
  }

  .setup-section {
    padding: 1.25rem;
  }

  .categories-grid {
    grid-template-columns: 1fr;
  }

  .timer-options {
    grid-template-columns: repeat(2, 1fr);
  }

  .practice-header {
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
  }

  .word-display {
    min-height: 5rem;
  }
}

@media (max-width: 400px) {
  .group-buttons {
    grid-template-columns: repeat(2, 1fr);
  }
}
