/* Deck Tuner: live tuning controls + before/after comparison.
   The panel itself stays neutral (existing surface/border/text tokens). MTG
   mana colors appear ONLY as data markers on the color chart, swatches, and
   color alerts, never on buttons or generic status. */

:root {
  /* Semantic mana tokens, tuned to stay legible on the dark surface. Meaning
     is always paired with a text label, value, or hatch pattern. */
  --mana-white: #e9e4c9;
  --mana-blue: #5a9fe0;
  --mana-black: #9b93b0;
  --mana-red: #e0685a;
  --mana-green: #63b078;
  --mana-colorless: #9a9aa8;
  --mana-multi: #d9b24a;
}

.dc-tuner {
  margin-bottom: 18px;
  padding: 18px 20px 20px;
  border-radius: var(--radius-lg, 16px);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.1));
  background: var(--surface-panel, rgba(255, 255, 255, 0.03));
}

.dc-tuner-pattern-defs {
  position: absolute;
  width: 0;
  height: 0;
}

.dc-tuner-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.dc-tuner-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.dc-tuner-reset {
  padding: 6px 12px;
  border-radius: var(--radius-pill, 999px);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.1));
  background: transparent;
  color: var(--text-2, #8a879e);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.dc-tuner-reset:hover {
  color: var(--text-1, #f0eef8);
  border-color: var(--border-strong, rgba(255, 255, 255, 0.18));
  background: rgba(255, 255, 255, 0.04);
}

.dc-tuner-reset:focus-visible,
.dc-tuner-range:focus-visible,
.dc-tuner-apply:focus-visible,
.dc-tuner-undo:focus-visible,
.dc-tuner-seg-btn:focus-visible,
.dc-tuner-info:focus-visible,
.dc-tuner-currency-input:focus-visible,
.dc-tuner-compare-toggle:focus-visible {
  outline: 2px solid var(--accent, #c9a84c);
  outline-offset: 2px;
}

.dc-tuner-layout {
  display: grid;
  gap: 20px;
}

@media (min-width: 900px) {
  .dc-tuner-layout {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    align-items: start;
  }
}

/* ---- Controls ---- */
.dc-tuner-controls {
  display: grid;
  gap: 16px;
}

.dc-tuner-control {
  display: grid;
  gap: 7px;
}

.dc-tuner-control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.dc-tuner-control-label {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-1, #f0eef8);
}

.dc-tuner-control-value {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--accent-soft, #efd58b);
}

.dc-tuner-hint {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-2, #8a879e);
}

/* Range slider, styled from the design tokens. */
.dc-tuner-range {
  width: 100%;
  height: 26px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.dc-tuner-range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.dc-tuner-range::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.dc-tuner-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border-radius: 50%;
  border: 2px solid #1a130a;
  background: var(--accent, #c9a84c);
}

.dc-tuner-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #1a130a;
  background: var(--accent, #c9a84c);
}

.dc-tuner-currency {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 140px;
  padding: 4px 10px;
  border-radius: var(--radius-sm, 8px);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.1));
  background: rgba(0, 0, 0, 0.22);
}

.dc-tuner-currency-prefix {
  color: var(--text-2, #8a879e);
  font-size: 0.85rem;
}

.dc-tuner-currency-input {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-1, #f0eef8);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
}

/* Segmented control */
.dc-tuner-segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-md, 12px);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.06));
  background: rgba(0, 0, 0, 0.2);
}

.dc-tuner-seg-btn {
  min-height: 40px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm, 8px);
  background: transparent;
  color: var(--text-2, #8a879e);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.dc-tuner-seg-btn.is-selected {
  color: var(--accent-soft, #efd58b);
  border-color: rgba(201, 168, 76, 0.38);
  background: rgba(201, 168, 76, 0.14);
}

.dc-tuner-info-wrap {
  position: relative;
  display: inline-flex;
}

.dc-tuner-info {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.1));
  background: transparent;
  color: var(--text-2, #8a879e);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: help;
  line-height: 1;
}

.dc-tuner-tooltip {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 5;
  width: 230px;
  padding: 8px 10px;
  border-radius: var(--radius-sm, 8px);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.12));
  background: var(--surface, #111115);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
  color: var(--text-1, #f0eef8);
  font-size: 0.76rem;
  line-height: 1.45;
  font-weight: 400;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
}

.dc-tuner-info-wrap:hover .dc-tuner-tooltip,
.dc-tuner-info:focus-visible + .dc-tuner-tooltip,
.dc-tuner-info:focus + .dc-tuner-tooltip {
  opacity: 1;
  visibility: visible;
}

/* ---- Results / comparison ---- */
.dc-tuner-results {
  display: grid;
  gap: 12px;
  align-content: start;
}

.dc-tuner-recalc {
  justify-self: start;
  padding: 3px 10px;
  border-radius: var(--radius-pill, 999px);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-2, #8a879e);
  font-size: 0.74rem;
}

.dc-tuner-compare-toggle {
  display: none;
  padding: 8px 12px;
  border-radius: var(--radius-sm, 8px);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.1));
  background: transparent;
  color: var(--text-1, #f0eef8);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.dc-tuner-scenario-caption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: var(--muted, #aaa7a0);
  line-height: 1.4;
}

/* Informational (structural), not a warning or a value: neutral violet so it
   never competes with the gold audit accent. */
.dc-tuner-scenario-tag {
  flex: 0 0 auto;
  padding: 2px 9px;
  border: 1px solid rgba(150, 123, 224, 0.45);
  border-radius: 999px;
  background: rgba(150, 123, 224, 0.12);
  color: #c3b3f0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dc-tuner-compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.dc-tuner-compare-col {
  padding: 12px;
  border-radius: var(--radius-md, 12px);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.06));
  background: rgba(255, 255, 255, 0.015);
}

.dc-tuner-compare-col.is-proposed {
  border-color: rgba(201, 168, 76, 0.24);
}

.dc-tuner-compare-label {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2, #8a879e);
}

.dc-tuner-compare-list {
  margin: 0;
  display: grid;
  gap: 5px;
}

.dc-tuner-compare-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 6px;
  border-radius: 6px;
}

.dc-tuner-compare-row dt {
  font-size: 0.78rem;
  color: var(--text-2, #8a879e);
}

.dc-tuner-compare-row dd {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-1, #f0eef8);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Only changed proposed values are emphasized. */
.dc-tuner-compare-row.is-changed {
  background: rgba(255, 255, 255, 0.03);
}

.dc-tuner-compare-col:not(.is-proposed) .dc-tuner-compare-row.is-changed dd {
  color: var(--text-2, #8a879e);
  text-decoration: line-through;
  text-decoration-color: rgba(255, 255, 255, 0.28);
}

.dc-tuner-diff {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 5px;
}

.dc-tuner-diff-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--text-1, #f0eef8);
}

/* Tone markers use neutral status colors, never mana colors. */
.dc-tuner-tone {
  font-size: 0.7rem;
  line-height: 1;
}
.dc-tuner-tone-positive { color: #6fcf97; }
.dc-tuner-tone-negative { color: var(--red-text, #e87070); }
.dc-tuner-tone-neutral { color: var(--text-2, #8a879e); }

.dc-tuner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

/* Primary action matches the site's existing gold button treatment. */
.dc-tuner-apply {
  padding: 9px 16px;
  border-radius: var(--radius-pill, 999px);
  border: 1px solid rgba(201, 168, 76, 0.34);
  background: linear-gradient(135deg, #efd58b 0%, #c39532 100%);
  color: #1a130a;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}

.dc-tuner-apply:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.dc-tuner-apply:not(:disabled):hover {
  filter: brightness(1.05);
}

.dc-tuner-undo {
  padding: 9px 16px;
  border-radius: var(--radius-pill, 999px);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.12));
  background: transparent;
  color: var(--text-1, #f0eef8);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

.dc-tuner-undo:hover {
  background: rgba(255, 255, 255, 0.05);
}

.dc-tuner-applied-note {
  margin: 0;
  font-size: 0.76rem;
  color: var(--text-2, #8a879e);
}

/* ---- Card changes list ---- */
.dc-tuner-changes summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-soft, #efd58b);
  padding: 4px 0;
}

.dc-tuner-change-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.dc-tuner-change {
  padding: 8px 10px;
  border-radius: var(--radius-sm, 8px);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.06));
  border-left: 3px solid var(--text-3, #56536a);
  background: rgba(255, 255, 255, 0.015);
}

.dc-tuner-change.is-positive { border-left-color: #6fcf97; }
.dc-tuner-change.is-negative { border-left-color: var(--red-text, #e87070); }

.dc-tuner-change-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
}

.dc-tuner-change-action {
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-2, #8a879e);
}

.dc-tuner-change-action.action-remove { color: var(--red-text, #e87070); }
.dc-tuner-change-action.action-replace,
.dc-tuner-change-action.action-add { color: var(--accent-soft, #efd58b); }

.dc-tuner-change-name {
  font-weight: 700;
  font-size: 0.86rem;
}

.dc-tuner-change-arrow {
  font-size: 0.8rem;
  color: var(--text-2, #8a879e);
}

.dc-tuner-change-reason {
  margin: 4px 0 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-2, #8a879e);
}

/* ---- Color chart (mana colors as data) ---- */
.dc-tuner-colors {
  padding-top: 4px;
}

.dc-tuner-colors-title {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-1, #f0eef8);
}

.dc-tuner-color-chart {
  display: grid;
  gap: 7px;
}

.dc-tuner-color-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.dc-tuner-color-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-1, #f0eef8);
}

.dc-tuner-color-swatch {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 3px;
  background: var(--swatch, #999);
  border: 1px solid rgba(0, 0, 0, 0.35);
}

.dc-tuner-color-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.dc-tuner-color-fill {
  height: 100%;
  border-radius: 999px;
  min-width: 4px;
  /* A subtle diagonal hatch overlay keeps colors distinguishable without hue. */
  background-image: repeating-linear-gradient(
    45deg,
    rgba(0, 0, 0, 0.22) 0,
    rgba(0, 0, 0, 0.22) 2px,
    rgba(255, 255, 255, 0.14) 2px,
    rgba(255, 255, 255, 0.14) 4px
  );
  background-blend-mode: overlay;
}

.dc-tuner-color-value {
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-2, #8a879e);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dc-tuner-color-flag {
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(232, 112, 112, 0.16);
  color: var(--red-text, #e87070);
  font-size: 0.66rem;
  font-weight: 700;
}

.dc-tuner-color-alerts {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 5px;
}

.dc-tuner-color-alert {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-size: 0.78rem;
  color: var(--text-2, #8a879e);
}

.dc-tuner-color-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  transform: translateY(1px);
  border: 1px solid rgba(0, 0, 0, 0.35);
}

.dc-tuner-color-alert-label {
  font-weight: 700;
  color: var(--text-1, #f0eef8);
}

/* ---- Mobile ---- */
@media (max-width: 899px) {
  .dc-tuner-compare-toggle {
    display: block;
  }
  .dc-tuner-seg-btn {
    min-height: 44px;
  }
  .dc-tuner-color-row {
    grid-template-columns: 64px minmax(0, 1fr);
    grid-template-areas:
      "label track"
      "value value";
    row-gap: 3px;
  }
  .dc-tuner-color-label { grid-area: label; }
  .dc-tuner-color-track { grid-area: track; }
  .dc-tuner-color-value { grid-area: value; }
}

@media (prefers-reduced-motion: reduce) {
  .dc-tuner-reset,
  .dc-tuner-seg-btn,
  .dc-tuner-tooltip {
    transition: none;
  }
}
