/* css/components/gaps.css */
/* Gap/answer element styles for modal-type exercises */

.gap-container {
  display: inline-block;
  margin: 0 4px;
  vertical-align: middle;
}

.gap-box {
  display: inline-flex;
  align-items: center;
  min-width: 90px;
  padding: 8px 14px;
  background: linear-gradient(135deg, #f0f4ff, #e6ecfe);
  border: 2px solid var(--primary-light);
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1rem;
}

@media (hover: hover) and (pointer: fine) {
  .gap-box:hover:not(.checked) {
    background: linear-gradient(135deg, #e0e7ff, #d1dbfa);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.2);
  }
}

.gap-box.answered {
  background: var(--primary);
  border-color: var(--primary-dark);
}

.gap-box.answered .gap-number,
.gap-box.answered .gap-text {
  color: white;
}

.gap-box.correct {
  background: var(--correct);
  border-color: #059669;
}

.gap-box.correct .gap-number,
.gap-box.correct .gap-text {
  color: white;
}

.gap-box.incorrect {
  background: var(--incorrect);
  border-color: #b91c1c;
  position: relative;
}

.gap-box.incorrect .gap-number,
.gap-box.incorrect .gap-text {
  color: white;
}

.gap-box.incorrect::after {
  content: attr(data-correct);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary-dark);
  color: white;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  white-space: nowrap;
  margin-bottom: 8px;
  display: none;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.gap-box.incorrect:hover::after {
  display: block;
}

.gap-box.checked {
  cursor: not-allowed;
}

.gap-answer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.gap-number {
  font-weight: 700;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.3);
  padding: 2px 6px;
  border-radius: 12px;
  color: var(--primary);
  flex-shrink: 0;
}

.gap-box.answered .gap-number,
.gap-box.correct .gap-number,
.gap-box.incorrect .gap-number {
  color: rgba(255, 255, 255, 0.9);
}

.gap-text {
  font-weight: 600;
  color: var(--primary);
  font-size: 1rem;
}

.gap-box.answered .gap-text,
.gap-box.correct .gap-text,
.gap-box.incorrect .gap-text {
  color: white;
}

.gap-dots {
  color: var(--text-light);
  letter-spacing: 2px;
}

.gap-input {
  width: 100px;
  padding: 4px 10px;
  border: 2px solid #cbd5e1;
  border-radius: 30px;
  font-family: 'Nunito', sans-serif;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  font-size: 1rem;
  transition: all 0.2s;
  background: white;
  vertical-align: middle;
  height: auto;
}

.gap-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.gap-input.correct {
  border-color: var(--correct);
  background-color: #d1fae5;
  color: #065f46;
}

.gap-input.incorrect {
  border-color: var(--incorrect);
  background-color: #fee2e2;
  color: #991b1b;
}

.gap-input:disabled {
  opacity: 0.8;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  .gap-container {
    max-width: 100%;
    margin: 3px 2px;
  }

  .gap-box {
    min-width: 0;
    max-width: 100%;
    padding: 7px 10px;
  }

  .gap-answer {
    min-width: 0;
  }

  .gap-text {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .gap-input {
    width: auto;
    min-width: 5ch;
    max-width: min(22ch, calc(100vw - 64px));
    padding: 6px 8px;
  }

  @supports (field-sizing: content) {
    .gap-input {
      field-sizing: content;
    }
  }

  .gap-box.incorrect::after {
    max-width: calc(100vw - 32px);
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

.gap-error {
  color: var(--incorrect);
  font-size: 0.9rem;
  font-style: italic;
  padding: 2px 8px;
  background: #fee2e2;
  border-radius: 8px;
}

.gap-number-outside {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-dark);
  margin-right: 4px;
  flex-shrink: 0;
}

.gap-box.gap-box-small {
  min-width: 36px;
  padding: 5px 10px;
  font-size: 0.95rem;
  justify-content: center;
  text-align: center;
}

.gap-box.gap-box-small .gap-text {
  font-size: 0.95rem;
}

.gap-box.gap-box-small .gap-dots {
  font-size: 0.9rem;
  letter-spacing: 1px;
}
