/* ==========================================================================
   GazeTo — Settings screen redesign (AssistUK)
   Restyles the Settings screen onto the redesign foundation: eyebrow + big
   serif title, grouped .card blocks, prominent return bar. Presentation only.
   ========================================================================== */

/* Page scaffold */
.screen-settings { padding: 24px 24px 64px; }
.settings-page { display: block; }
.settings-head { margin-bottom: 28px; }

/* ── Shared card (used here; augments the redesign component set) ── */
.card {
  background: var(--c-bg-primary, #fff);
  border: 1px solid var(--c-border, rgba(0, 0, 0, 0.08));
  border-radius: 24px;
  box-shadow: var(--shadow-md, 0 4px 18px rgba(0, 0, 0, 0.06));
}

/* ── Settings cards ── */
.settings-card {
  padding: 26px 28px;
  margin-bottom: 22px;
}
.settings-card__title {
  margin: 0 0 18px;
  /* inherits .eyebrow styling (Oswald, uppercase, tracked) */
}
.settings-card__body {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Return-to-activity bar (one-shot, prominent) ── */
.settings-return-bar {
  margin: 0 0 28px;
  padding: 16px 20px;
  border-radius: 20px;
  background: var(--c-bg-primary, #fff);
  border: 1px solid var(--c-border, rgba(0, 0, 0, 0.08));
  box-shadow: var(--shadow-md, 0 4px 18px rgba(0, 0, 0, 0.06));
  display: flex;
  justify-content: center;
}
.settings-return-btn {
  width: 100%;
  max-width: 560px;
  min-height: 60px;
}

/* ── Rows ── */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.settings-row--column {
  flex-direction: column;
  align-items: stretch;
}
.settings-row--toggle {
  flex-wrap: nowrap;
}
.settings-label {
  font-family: var(--f-body, sans-serif);
  font-weight: 600;
  font-size: 1rem;
  color: var(--c-fg1, #1d1d1f);
}
.settings-row--column > .settings-label { margin-bottom: 2px; }

/* Profile header (avatar + spacing) */
.settings-profile-header { gap: 14px; justify-content: flex-start; }

/* Text input */
.settings-input {
  flex: 1 1 220px;
  min-width: 0;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1.5px solid var(--c-border-strong, rgba(0, 0, 0, 0.14));
  background: var(--c-bg-primary, #fff);
  color: var(--c-fg1, #1d1d1f);
  font-family: var(--f-body, sans-serif);
  font-size: 1rem;
}
.settings-input:focus {
  outline: none;
  border-color: var(--c-accent, #4b698c);
  box-shadow: 0 0 0 3px rgba(75, 105, 140, 0.15);
}

/* Profile action buttons grouped vertically on wide, wrap on narrow */
.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.settings-actions .btn { min-height: 48px; }

/* Button group (segmented options) */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.btn-group .btn {
  flex: 0 1 auto;
  min-height: 48px;
}

/* ── Selected / active option chips ──────────────────────────────────────
   FIX (button-contrast): the selected chip must read clearly. We use the
   accent fill with WHITE text and keep that contrast on :hover (hover only
   darkens the accent — it never lowers fg/bg contrast). The double-class
   selectors raise specificity so this reliably beats the legacy
   `.btn--outline.btn--active` rule (light bg + dark text) from activities.css
   on the redesigned Settings screen, giving one consistent readable look. */
.settings-page .btn-group .btn--active,
.settings-page .btn--outline.btn--active,
.btn-group .btn--outline.btn--active {
  background: var(--c-accent, #4b698c);
  border-color: var(--c-accent, #4b698c);
  color: #fff;
}
.settings-page .btn-group .btn--active:hover,
.settings-page .btn--outline.btn--active:hover,
.btn-group .btn--outline.btn--active:hover {
  background: var(--c-accent-2, #3a5a7c);
  border-color: var(--c-accent-2, #3a5a7c);
  color: #fff;
}
/* Unselected chip hover must not look "selected" or drop contrast. */
.settings-page .btn-group .btn--outline:not(.btn--active):hover {
  background: var(--c-bg-tertiary, #e3e6ec);
  border-color: var(--c-accent, #4b698c);
  color: var(--c-fg1, #1d1d1f);
}

/* Dark theme: the dark-mode accent is a LIGHT blue, so white text on it is
   weak. Use dark text on the light-blue fill for an AA+ selected chip. */
[data-theme="dark"] .settings-page .btn-group .btn--active,
[data-theme="dark"] .settings-page .btn--outline.btn--active {
  background: var(--c-accent, #7ea7d4);
  border-color: var(--c-accent, #7ea7d4);
  color: #0f1116;
}
[data-theme="dark"] .settings-page .btn-group .btn--active:hover,
[data-theme="dark"] .settings-page .btn--outline.btn--active:hover {
  background: var(--c-accent-2, #a3c0e0);
  border-color: var(--c-accent-2, #a3c0e0);
  color: #0f1116;
}

/* High-contrast theme: accent is yellow → selected chip must be BLACK text on
   yellow (white on yellow fails). Unselected chips stay white-on-black. */
[data-theme="contrast"] .settings-page .btn-group .btn--active,
[data-theme="contrast"] .settings-page .btn--outline.btn--active,
.high-contrast .settings-page .btn-group .btn--active,
.high-contrast .settings-page .btn--outline.btn--active {
  background: #ffd60a !important;
  border-color: #ffd60a !important;
  color: #000 !important;
}
[data-theme="contrast"] .settings-page .btn-group .btn--outline:not(.btn--active),
.high-contrast .settings-page .btn-group .btn--outline:not(.btn--active) {
  background: #000;
  border-color: #fff;
  color: #fff;
}
[data-theme="contrast"] .settings-page .btn-group .btn--outline:not(.btn--active):hover,
.high-contrast .settings-page .btn-group .btn--outline:not(.btn--active):hover {
  background: #1a1a1a;
  border-color: #ffd60a;
  color: #fff;
}

/* ── Cursor-style chips: keep any in-button colour PREVIEW visible ────────
   When a chip carries a small preview swatch tinted with the user's cursor
   colour, the swatch can vanish if its colour matches the (now navy) active
   chip background. Give every preview a contrasting white ring + halo so it
   stays visible against accent, dark and high-contrast backgrounds alike. */
.btn .cursor-preview,
.btn .style-preview,
.settings-page .btn-group .btn [data-preview] {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(0, 0, 0, 0.35);
  border-radius: 50%;
}
.btn--active .cursor-preview,
.btn--active .style-preview,
.settings-page .btn-group .btn--active [data-preview] {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(0, 0, 0, 0.45);
}

/* Webcam sub-settings */
.settings-subsection {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  border-radius: 16px;
  background: var(--c-bg-secondary, #f0f1f4);
  border: 1px solid var(--c-border, rgba(0, 0, 0, 0.08));
}

/* Sliders */
.settings-slider-row {
  display: flex;
  align-items: center;
  gap: 16px;
}
.settings-slider {
  flex: 1;
  min-width: 0;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 980px;
  background: var(--c-bg-tertiary, #e3e6ec);
  cursor: pointer;
}
.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--c-accent, #4b698c);
  border: 3px solid #fff;
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.05));
  cursor: pointer;
}
.settings-slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--c-accent, #4b698c);
  border: 3px solid #fff;
  cursor: pointer;
}
.settings-slider__value {
  min-width: 64px;
  text-align: right;
  font-family: var(--f-heading, sans-serif);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--c-fg2, #555e6e);
}

/* Dwell preview canvas */
.settings-dwell-preview {
  width: 100%;
  max-width: 280px;
  height: 100px;
  display: block;
  background: var(--c-bg-secondary, rgba(0, 0, 0, 0.04));
  border-radius: 14px;
}

/* Cursor style+colour preview canvas */
.settings-cursor-preview {
  width: 100%;
  max-width: 240px;
  height: 72px;
  display: block;
  border-radius: 8px;
}

/* Appearance chips: allow inline preview elements */
.settings-page .btn-group .btn.appearance-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
/* Theme "Aa" tile and all chip-preview spans */
.chip-preview {
  flex-shrink: 0;
  pointer-events: none;
}
/* Stufe dot rows: keep dots from being squished on small screens */
.chip-preview--stufe {
  display: inline-flex;
  gap: 2px;
  align-items: center;
}

/* Cursor colour swatches */
.color-swatch-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.color-swatch {
  width: 46px;
  height: 46px;
  min-height: 44px;
  border-radius: 50%;
  border: 3px solid transparent;
  box-shadow: 0 0 0 1px var(--c-border, rgba(0, 0, 0, 0.12));
  cursor: pointer;
  padding: 0;
}
.color-swatch--active {
  border-color: var(--c-accent, #4b698c);
  box-shadow: 0 0 0 1px var(--c-accent, #4b698c);
  transform: scale(1.08);
}

/* Toggles */
.toggle {
  position: relative;
  width: 60px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 980px;
  border: 0;
  background: var(--c-bg-tertiary, #e3e6ec);
  cursor: pointer;
  transition: background var(--transition-base, 0.2s) ease;
  padding: 0;
}
.toggle--on { background: var(--c-success, #1f8a5b); }
.toggle__knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.2));
  transition: transform var(--transition-base, 0.2s) ease;
}
.toggle--on .toggle__knob { transform: translateX(26px); }

/* Language search box */
.lang-search {
  flex: none !important;   /* prevent growth inside column-flex settings-card__body */
  max-width: 320px;
  margin-bottom: 4px;
}

/* Language flag grid */
.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
  padding: 4px 4px 4px 0;
  border: 1px solid var(--c-border, rgba(0,0,0,0.08));
  border-radius: 14px;
  padding: 12px;
}
.lang-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 12px 16px;
  border-radius: 16px;
  border: 1.5px solid var(--c-border-strong, rgba(0, 0, 0, 0.14));
  background: var(--c-bg-primary, #fff);
  color: var(--c-fg1, #1d1d1f);
  font-family: var(--f-body, sans-serif);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition-base, 0.2s) ease;
  text-align: left;
}
.lang-btn:hover { background: var(--c-bg-tertiary, #e3e6ec); }
.lang-btn.active {
  border-color: var(--c-accent, #4b698c);
  background: var(--color-primary-bg, #eef2f7);
  box-shadow: 0 0 0 2px var(--c-accent, #4b698c);
}
.lang-btn__flag { font-size: 1.6rem; line-height: 1; }
.lang-btn__name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Profile avatar (settings) */
.profile-avatar--small {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--f-heading, sans-serif);
  font-weight: 700;
  font-size: 1.4rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.15));
}

@media (max-width: 600px) {
  .screen-settings { padding: 16px 14px 56px; }
  .settings-card { padding: 20px 18px; }
  .settings-row--toggle { flex-wrap: nowrap; }
  .btn-group .btn { flex: 1 1 auto; }
}

/* ── Music Selector ── */
.settings-music-panel {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border, rgba(0,0,0,0.08));
}

.settings-music-tracks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 16px;
}

.settings-music-chip {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--color-border, rgba(0,0,0,0.15));
  background: var(--color-surface, #fff);
  color: var(--color-text, #222);
  font-size: 0.82rem;
  font-family: var(--f-body, sans-serif);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1.3;
  min-height: 34px;
}

.settings-music-chip:hover {
  border-color: var(--color-primary, #4b698c);
  background: rgba(75,105,140,0.07);
}

.settings-music-chip--active {
  background: var(--color-primary, #4b698c);
  border-color: var(--color-primary, #4b698c);
  color: #fff;
  font-weight: 600;
}
