/**
 * Settings Panel Styles
 */

/* ── Modal Specific Sizing ────────────────────────────────── */

.modal--settings {
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
}

@media (max-width: 600px) {
  .modal--settings {
    width: 95%;
    max-height: 90vh;
  }
}

/* ── Tabs ─────────────────────────────────────────────────── */

.modal__tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 0 20px;
  overflow-x: auto;
}

.modal__tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--fg-dim);
  padding: 12px 20px;
  min-height: 44px;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.modal__tab:hover {
  color: var(--fg);
  background: var(--border);
}

.modal__tab--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Settings Body ────────────────────────────────────────── */

.modal__body--settings {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(85vh - 140px); /* Account for header + tabs */
}

@media (max-width: 600px) {
  .modal__body--settings {
    padding: 16px;
    max-height: calc(90vh - 140px);
  }
}

/* ── Settings Panel ───────────────────────────────────────── */

.settings-panel {
  display: block;
}

.settings-panel--hidden {
  display: none;
}

/* ── Settings Section ─────────────────────────────────────── */

.settings-section {
  margin-bottom: 32px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ── Settings Control ─────────────────────────────────────── */

.settings-control {
  margin-bottom: 20px;
}

.settings-control:last-child {
  margin-bottom: 0;
}

.settings-control--featured {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}

/* ── Labels ───────────────────────────────────────────────── */

.settings-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg);
  margin-bottom: 8px;
}

.settings-help {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--fg-dim);
  margin-top: 2px;
}

/* ── WPM Display (Featured) ───────────────────────────────── */

.wpm-display {
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  margin: 16px 0;
  font-variant-numeric: tabular-nums;
}

/* ── Sliders ──────────────────────────────────────────────── */

.settings-slider-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-slider {
  flex: 1;
  width: 100%;  /* Ensure full width when not in flex container */
  height: 6px;
  border-radius: 3px;
  background: var(--surface);
  -webkit-appearance: none;
  appearance: none;
}

.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: all 0.2s;
}

.settings-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.settings-slider:hover::-webkit-slider-thumb {
  transform: scale(1.15);
  box-shadow: 0 0 0 4px rgba(107, 138, 253, 0.2);
}

.settings-slider:hover::-moz-range-thumb {
  transform: scale(1.15);
  box-shadow: 0 0 0 4px rgba(107, 138, 253, 0.2);
}

.settings-slider:active::-webkit-slider-thumb {
  transform: scale(1.25);
  box-shadow: 0 0 0 6px rgba(107, 138, 253, 0.3);
}

.settings-slider:active::-moz-range-thumb {
  transform: scale(1.25);
  box-shadow: 0 0 0 6px rgba(107, 138, 253, 0.3);
}

/* Large WPM slider */
.settings-slider--large {
  height: 8px;
}

.settings-slider--large::-webkit-slider-thumb {
  width: 24px;
  height: 24px;
}

.settings-slider--large::-moz-range-thumb {
  width: 24px;
  height: 24px;
}

/* ── Slider Value Display ─────────────────────────────────── */

.settings-value {
  min-width: 50px;
  text-align: right;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

/* ── Range Labels ─────────────────────────────────────────── */

.settings-range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--fg-dim);
  margin-top: 4px;
}

/* ── Radio Buttons ────────────────────────────────────────── */

.settings-radio-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.settings-radio {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  min-height: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.875rem;
  color: var(--fg);
}

.settings-radio:hover {
  background: rgba(107, 138, 253, 0.1);
  border-color: var(--accent);
}

.settings-radio input[type="radio"] {
  margin: 0;
  cursor: pointer;
}

.settings-radio input[type="radio"]:checked + span {
  color: var(--accent);
  font-weight: 600;
}

/* ── Checkboxes ───────────────────────────────────────────── */

.settings-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--fg);
  padding: 8px 0;
  min-height: 44px;
}

.settings-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  margin: 0;
}

.settings-checkbox:hover {
  color: var(--accent);
}

/* ── Buttons ──────────────────────────────────────────────── */

.settings-button {
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.settings-button--secondary {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
}

.settings-button--secondary:hover {
  background: rgba(107, 138, 253, 0.1);
  border-color: var(--accent);
  color: var(--accent);
}

.settings-button--secondary:active {
  transform: scale(0.98);
}

/* ── Reset Links ──────────────────────────────────────────── */

.settings-reset-link {
  font-size: 0.75rem;
  color: var(--fg-dim);
  text-decoration: none;
  margin-left: 8px;
  transition: color 0.2s;
  cursor: pointer;
}

.settings-reset-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* For section titles */
.settings-section__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* For inline labels */
.settings-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
}

.settings-label .settings-reset-link {
  order: 2;  /* Position reset link after main label text */
}

.settings-label .settings-help {
  order: 3;  /* Keep help text at end */
  flex-basis: 100%;  /* Force help to new line */
}

/* ── Font Preview ─────────────────────────────────────────── */

.font-preview-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 0;
  margin-bottom: 20px;
  overflow: hidden;
}

.font-preview-caption {
  position: absolute;
  top: 6px;
  left: 12px;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.font-preview {
  font-size: var(--reader-font-size);
  font-weight: 650;
  letter-spacing: 0.5px;
  line-height: 1.2;
  color: var(--fg);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  /* Fade out at both edges when text is wider than the container */
  mask-image: linear-gradient(
    to right,
    transparent 0%,
    black 12%,
    black 88%,
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0%,
    black 12%,
    black 88%,
    transparent 100%
  );
}

/* ── Row Layout (label + button side by side) ─────────────── */

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ── Font Size Controls ───────────────────────────────────── */

.settings-font-size-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-font-size-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 14px;
  color: var(--fg);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 44px;
  min-height: 44px;
  text-align: center;
}

.settings-font-size-btn:hover {
  border-color: var(--accent);
  background: rgba(107, 138, 253, 0.1);
}

.settings-font-size-btn:active {
  transform: scale(0.95);
}

.settings-font-size-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fg);
  min-width: 44px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ── Select ───────────────────────────────────────────────── */

.settings-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 32px 8px 12px;
  color: var(--fg);
  font-size: 0.875rem;
  cursor: pointer;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='%23888' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.settings-select:focus {
  border-color: var(--accent);
}

.settings-select option {
  background: var(--surface);
  color: var(--fg);
}

/* ── Mobile Optimizations ─────────────────────────────────── */

@media (max-width: 600px) {
  .settings-section {
    margin-bottom: 24px;
  }

  .settings-control {
    margin-bottom: 16px;
  }

  .wpm-display {
    font-size: 2.5rem;
  }

  .settings-radio-group {
    gap: 8px;
  }

  .settings-radio {
    padding: 8px 12px;
    font-size: 0.8125rem;
  }
}

/* ── Scrollbar Styling ────────────────────────────────────── */

.modal__body--settings::-webkit-scrollbar {
  width: 8px;
}

.modal__body--settings::-webkit-scrollbar-track {
  background: var(--surface);
}

.modal__body--settings::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.modal__body--settings::-webkit-scrollbar-thumb:hover {
  background: var(--fg-dim);
}
