/* ui/Settings — the gear and its panel. Contract: ./Settings.spec.md
   Tokens only (ui/Theme C8): no colour literals live here. */

/* The layer itself is inert: only the gear and the panel take a pointer, so a
   match underneath keeps taking aim, movement and fire while it is open. */
.qc-settings {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  font-family: var(--qc-font-ui);
}

.qc-settings__gear {
  pointer-events: auto;
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: calc(env(safe-area-inset-right, 0px) + 14px);
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  color: var(--qc-text-dim);
  background: color-mix(in oklab, var(--qc-space-1) 78%, transparent);
  border: 1px solid var(--qc-line-strong);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  transition: color var(--qc-dur-fast) var(--qc-ease-out), border-color var(--qc-dur-fast) var(--qc-ease-out);
}

.qc-settings__gear:hover,
.qc-settings__gear[aria-expanded="true"] {
  color: var(--qc-text);
  border-color: var(--qc-accent-2);
}

.qc-settings__cog {
  width: 20px;
  height: 20px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58a.49.49 0 0 0 .12-.61l-1.92-3.32a.49.49 0 0 0-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54A.48.48 0 0 0 13.9 2h-3.84a.48.48 0 0 0-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96a.49.49 0 0 0-.59.22L2.71 8.47a.49.49 0 0 0 .12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58a.49.49 0 0 0-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32a.49.49 0 0 0-.12-.61zM12 15.6A3.6 3.6 0 1 1 15.6 12 3.6 3.6 0 0 1 12 15.6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58a.49.49 0 0 0 .12-.61l-1.92-3.32a.49.49 0 0 0-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54A.48.48 0 0 0 13.9 2h-3.84a.48.48 0 0 0-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96a.49.49 0 0 0-.59.22L2.71 8.47a.49.49 0 0 0 .12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58a.49.49 0 0 0-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32a.49.49 0 0 0-.12-.61zM12 15.6A3.6 3.6 0 1 1 15.6 12 3.6 3.6 0 0 1 12 15.6'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Over the arena every corner belongs to ui/Hud — announcer log, kill feed,
   minimap, vitals, special, tray — so the gear takes the one gap the HUD keeps
   empty in every layout: the top strip just right of the match clock. It is
   also above every thumb zone, which a control over a touch match has to be. */
.qc-settings[data-screen="arena"] .qc-settings__gear {
  right: auto;
  left: calc(50% + 92px);
}

/* ------------------------------------------------------------- the panel --- */

.qc-settings__panel {
  pointer-events: auto;
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 68px);
  right: calc(env(safe-area-inset-right, 0px) + 14px);
  display: flex;
  flex-direction: column;
  width: min(340px, calc(100vw - 28px));
  max-height: calc(100vh - 96px);
  color: var(--qc-text);
  background: color-mix(in oklab, var(--qc-space-1) 94%, transparent);
  border: 1px solid var(--qc-line-strong);
  border-radius: var(--qc-radius);
  box-shadow: 0 24px 60px -24px var(--qc-space-0);
  backdrop-filter: blur(16px);
  animation: qc-settings-in var(--qc-dur) var(--qc-ease-out) both;
}

/* Under its gear, but never off the right edge on a narrow screen. */
.qc-settings[data-screen="arena"] .qc-settings__panel {
  right: auto;
  left: clamp(14px, calc(50% + 92px), calc(100vw - 354px));
}

@keyframes qc-settings-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.qc-settings__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 12px 18px;
  border-bottom: 1px solid var(--qc-line);
}

.qc-settings__title {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.26em;
  text-indent: 0.26em;
  text-transform: uppercase;
  color: var(--qc-text);
}

.qc-settings__close {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  color: var(--qc-text-faint);
  border-radius: 999px;
  transition: color var(--qc-dur-fast) var(--qc-ease-out);
}

.qc-settings__close:hover {
  color: var(--qc-text);
}

.qc-settings__cross {
  position: relative;
  width: 14px;
  height: 14px;
}

.qc-settings__cross::before,
.qc-settings__cross::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 0;
  width: 14px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}

.qc-settings__cross::before { transform: rotate(45deg); }
.qc-settings__cross::after { transform: rotate(-45deg); }

/* The body scrolls, so every control stays reachable on a short viewport. */
.qc-settings__body {
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 16px 18px 20px;
}

.qc-settings__section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qc-settings__section + .qc-settings__section {
  padding-top: 16px;
  border-top: 1px solid var(--qc-line);
}

.qc-settings__legend {
  margin: 0;
}

/* --------------------------------------------------------------- mixer ---- */

.qc-settings__row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 10px;
  min-height: 34px;
}

.qc-settings__row-label {
  font-size: 12px;
  color: var(--qc-text-dim);
}

.qc-settings__row-value {
  font: 600 11px/1 var(--qc-font-mono);
  color: var(--qc-text-faint);
  text-align: right;
}

.qc-settings__slider {
  width: 100%;
  height: 24px;
  margin: 0;
  accent-color: var(--qc-accent-2);
  cursor: pointer;
}

.qc-settings__check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
}

.qc-settings__checkbox {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--qc-accent-2);
  cursor: pointer;
}

.qc-settings__check-label {
  flex: 1;
  font-size: 12px;
  color: var(--qc-text-dim);
  cursor: pointer;
}

/* ----------------------------------------------------------- call sign ---- */

.qc-settings__field {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  font: 500 14px/1 var(--qc-font-ui);
  color: var(--qc-text);
  background: color-mix(in oklab, var(--qc-space-0) 70%, transparent);
  border: 1px solid var(--qc-line-strong);
  border-radius: var(--qc-radius-sm);
}

.qc-settings__field::placeholder {
  color: var(--qc-text-faint);
}

.qc-settings__field:focus-visible {
  border-color: var(--qc-accent-2);
}

.qc-settings__note {
  margin: 0;
  font-size: 11px;
  color: var(--qc-text-faint);
}

/* ------------------------------------------------------------- effects ---- */

.qc-settings__fieldset {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
}

.qc-settings__option {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--qc-line);
  border-radius: var(--qc-radius-sm);
  cursor: pointer;
  transition: border-color var(--qc-dur-fast) var(--qc-ease-out), background var(--qc-dur-fast) var(--qc-ease-out);
}

.qc-settings__option:hover {
  border-color: var(--qc-line-strong);
}

.qc-settings__option:has(:focus-visible) {
  outline: 2px solid var(--qc-accent-2);
  outline-offset: 2px;
}

.qc-settings__option[data-selected="true"] {
  background: color-mix(in oklab, var(--qc-accent) 12%, transparent);
  border-color: color-mix(in oklab, var(--qc-accent-2) 70%, transparent);
}

.qc-settings__option-mark {
  width: 14px;
  height: 14px;
  margin-top: 2px;
  border: 1px solid var(--qc-line-strong);
  border-radius: 999px;
}

.qc-settings__option[data-selected="true"] .qc-settings__option-mark {
  background: radial-gradient(circle, var(--qc-accent-2) 0 45%, transparent 46%);
  border-color: var(--qc-accent-2);
}

.qc-settings__option-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.qc-settings__option-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--qc-text);
}

.qc-settings__option-detail {
  font-size: 11px;
  line-height: 1.35;
  color: var(--qc-text-faint);
}

/* A landscape phone has almost no height for a panel: take back the margins. */
@media (max-height: 560px) {
  .qc-settings__panel {
    top: calc(env(safe-area-inset-top, 0px) + 60px);
    max-height: calc(100vh - 72px);
  }
}
