/**
 * CounterMeasure theme engine controls.
 *
 * Import this stylesheet when rendering components from
 * @countermeasure-platform/web-components/components/theme.
 */

.preview-theme-switcher,
.preview-accent-switcher,
.preview-glass-slider,
.preview-density-switcher {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--text-2);
  font-family: var(--font-sans);
}

.preview-theme-switcher__label,
.preview-accent-switcher__label,
.preview-glass-slider__label,
.preview-density-switcher__label {
  font: 600 12px/1 var(--font-sans);
  color: var(--text-3);
}

.preview-theme-switcher__buttons,
.preview-accent-switcher__buttons,
.preview-density-switcher__buttons {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.preview-theme-switcher__btn,
.preview-accent-switcher__btn,
.preview-density-switcher__btn,
.theme-studio-preset,
.theme-studio-font-tile,
.theme-studio-icon-tile,
.theme-studio-icon-matrix__change,
.theme-studio-icon-matrix__reset,
.theme-studio-link,
.theme-studio-preview-tile__cta,
.theme-studio-tab {
  font-family: var(--font-sans);
}

.preview-theme-switcher__btn,
.preview-accent-switcher__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: var(--bg-card-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  cursor: pointer;
}

.preview-theme-switcher__btn--active,
.preview-accent-switcher__btn--active,
.preview-density-switcher__btn--active {
  border-color: var(--brand);
  outline: 1.5px solid var(--brand);
  outline-offset: 1px;
}

.preview-theme-swatch {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.preview-theme-swatch--light {
  background: linear-gradient(135deg, #fff, #d8dee9);
}

.preview-theme-swatch--dark {
  background: linear-gradient(135deg, #0b0f17, #172033);
}

.preview-theme-swatch--monokai {
  background: linear-gradient(135deg, #0a0a0a, #a6e22e);
}

.preview-theme-swatch--glass {
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.34), rgba(167, 139, 250, 0.28));
}

.preview-accent-swatch {
  width: 16px;
  height: 16px;
  border-radius: 9999px;
}

.preview-glass-slider {
  flex-wrap: nowrap;
}

.preview-glass-slider__row {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.preview-glass-slider__input,
.preview-radius-slider__input {
  --slider-pct: 0%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background:
    linear-gradient(90deg, var(--brand) 0 var(--slider-pct), var(--border-2) var(--slider-pct) 100%);
  border-radius: 9999px;
  cursor: pointer;
}

.preview-glass-slider__input {
  width: 132px;
}

.preview-glass-slider__input::-webkit-slider-thumb,
.preview-radius-slider__input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border: 2px solid var(--bg-card);
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.preview-glass-slider__input::-moz-range-thumb,
.preview-radius-slider__input::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 2px solid var(--bg-card);
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.preview-glass-slider__value,
.preview-radius-slider__value {
  min-width: 3ch;
  font: 500 11px/1 var(--font-mono);
  color: var(--text-3);
}

.preview-density-switcher__buttons {
  overflow: hidden;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
}

.preview-density-switcher__btn {
  border: 0;
  border-right: 1px solid var(--border-2);
  padding: 0.45rem 0.625rem;
  background: var(--bg-card-2);
  color: var(--text-2);
  font: 600 12px/1 var(--font-sans);
  cursor: pointer;
}

.preview-density-switcher__btn:last-child {
  border-right: 0;
}

.preview-density-switcher__btn:hover,
.preview-density-switcher__btn--active {
  background: var(--brand-soft);
  color: var(--brand);
}

.theme-studio-pane {
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 0 0.5rem 2rem;
}

.theme-studio-pane__header {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.theme-studio-pane__title {
  margin: 0;
  color: var(--text-1);
  font: var(--type-h2);
  letter-spacing: var(--letter-tight);
}

.theme-studio-pane__subtitle {
  max-width: 70ch;
  margin: 0;
  color: var(--text-2);
  font: var(--type-body);
}

.theme-studio-tabs {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 0.25rem;
  padding: 0 0.25rem;
  border-bottom: 1px solid var(--border-2);
}

.theme-studio-tab {
  padding: 0.625rem 0.125rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-3);
  font: 600 13px/1 var(--font-sans);
  cursor: pointer;
}

.theme-studio-tab:disabled {
  cursor: default;
  opacity: 0.7;
}

.theme-studio-tab.is-active {
  border-bottom-color: var(--brand);
  color: var(--text-1);
}

.theme-studio-section {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  padding: 1rem 1rem 1.125rem;
  background: var(--bg-card);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
}

.theme-studio-section__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.theme-studio-section__head--summary {
  cursor: pointer;
  list-style: none;
}

.theme-studio-section__head--summary::-webkit-details-marker {
  display: none;
}

.theme-studio-section__titles {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.theme-studio-section__title {
  margin: 0;
  color: var(--text-1);
  font: var(--type-h4);
}

.theme-studio-section__helper {
  color: var(--text-3);
  font: var(--type-body-sm);
}

.theme-studio-section__chev {
  color: var(--text-3);
  font: 600 11px/1 var(--font-sans);
  letter-spacing: var(--letter-label);
  text-transform: uppercase;
}

.theme-studio-link {
  padding: 0.25rem 0.375rem;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--brand);
  font: 600 12px/1 var(--font-sans);
  cursor: pointer;
}

.theme-studio-link:hover {
  background: var(--brand-soft);
}

.theme-studio-presets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

@media (max-width: 720px) {
  .theme-studio-presets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .theme-studio-tabs {
    flex-wrap: wrap;
    gap: 0.25rem 0.875rem;
  }

  .theme-studio-section__head {
    flex-direction: column;
    gap: 0.625rem;
  }

  .theme-studio-link {
    align-self: flex-start;
  }

  .theme-studio-presets {
    grid-template-columns: 1fr;
  }
}

.theme-studio-preset,
.theme-studio-font-tile,
.theme-studio-icon-tile {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.625rem;
  background: var(--bg-card-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  color: var(--text-2);
  text-align: left;
  cursor: pointer;
}

.theme-studio-preset:hover,
.theme-studio-font-tile:hover,
.theme-studio-icon-tile:hover {
  border-color: color-mix(in srgb, var(--border-2) 85%, var(--text-2));
}

.theme-studio-preset.is-active,
.theme-studio-font-tile.is-active,
.theme-studio-icon-tile.is-active {
  border-color: var(--brand);
  outline: 1.5px solid var(--brand);
  outline-offset: 1px;
}

.theme-studio-preset__art {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: 76px;
  padding: 0.375rem;
  border-radius: 6px;
  overflow: hidden;
}

.theme-studio-preset__art-bar {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  height: 14px;
  padding: 0 0.375rem;
  border: 1px solid;
  border-radius: 4px;
}

.theme-studio-preset__art-dot {
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.theme-studio-preset__art-line,
.theme-studio-preset__art-bars i {
  display: block;
  height: 3px;
  border-radius: 2px;
}

.theme-studio-preset__art-line {
  flex: 1 1 0;
  background: rgba(255, 255, 255, 0.18);
}

.theme-studio-preset__art-card {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.25rem;
  padding: 0.375rem;
  border: 1px solid;
  border-radius: 4px;
}

.theme-studio-preset__art-pill {
  align-self: flex-start;
  padding: 2px 6px;
  border: 1px solid;
  border-radius: 9999px;
  font: 600 9px/1 var(--font-sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.theme-studio-preset__art-bars {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.theme-studio-preset__name,
.theme-studio-font-tile__name,
.theme-studio-icon-tile__name {
  color: var(--text-1);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}

.theme-studio-preset__desc,
.theme-studio-font-tile__desc,
.theme-studio-icon-tile__desc {
  color: var(--text-3);
  font: var(--type-body-sm);
}

.theme-studio-preview-tile {
  display: flex;
  flex-direction: column;
  max-width: 480px;
  overflow: hidden;
  background: var(--bg-card-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  font-family: var(--font-display);
}

.theme-studio-preview-tile__head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-elev-1);
  border-bottom: 1px solid var(--border-2);
}

.theme-studio-preview-tile__mark,
.theme-studio-preview-tile__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-studio-preview-tile__mark {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  color: #fff;
}

.theme-studio-preview-tile__title {
  color: var(--text-1);
  font: 700 13px/1 var(--font-display);
  letter-spacing: var(--letter-tight);
}

.theme-studio-preview-tile__spacer {
  flex: 1;
}

.theme-studio-preview-tile__icon {
  color: var(--text-3);
}

.theme-studio-preview-tile__body,
.theme-studio-preview-tile__section {
  display: flex;
  flex-direction: column;
}

.theme-studio-preview-tile__body {
  gap: 0.625rem;
  padding: 0.75rem;
}

.theme-studio-preview-tile__section {
  gap: 0.375rem;
}

.theme-studio-preview-tile__eyebrow {
  color: var(--text-3);
  font: var(--type-label);
  letter-spacing: var(--letter-label);
  text-transform: uppercase;
}

.theme-studio-preview-tile__row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  background: var(--bg-glass);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font: 500 12px/1.3 var(--font-sans);
}

.theme-studio-preview-tile__row-label {
  flex: 1;
  overflow: hidden;
  color: var(--text-1);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-studio-preview-tile__pill {
  flex-shrink: 0;
  padding: 3px 7px;
  border-radius: 9999px;
  font: 600 10px/1 var(--font-mono);
}

.theme-studio-preview-tile__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  border: 0;
  border-radius: var(--radius-sm);
  color: #fff;
  font: 600 12px/1 var(--font-sans);
  cursor: pointer;
}

.theme-studio-fonts,
.theme-studio-iconsets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.625rem;
}

.theme-studio-font-tile {
  padding: 0.75rem;
}

.theme-studio-font-tile__sample {
  color: var(--text-1);
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: var(--letter-tight);
}

.theme-studio-font-tile__desc {
  font-family: var(--font-sans);
}

.theme-studio-icon-tile {
  position: relative;
  padding: 0.75rem;
}

.theme-studio-icon-tile__preview {
  display: flex;
  align-items: center;
  height: 28px;
}

.theme-studio-icon-tile__row {
  width: 100%;
  height: 24px;
}

.theme-studio-icon-tile__badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 6px;
  background: var(--brand-soft);
  border: 1px solid var(--brand);
  border-radius: 9999px;
  color: var(--brand);
  font: 600 9px/1 var(--font-sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.preview-glass-slider--expanded {
  flex-wrap: wrap;
}

.preview-glass-slider--expanded .preview-glass-slider__row {
  flex: 1;
  min-width: 240px;
  gap: 0.75rem;
}

.preview-glass-slider--expanded .preview-glass-slider__input {
  flex: 1;
  width: auto;
}

.preview-glass-slider__edge {
  color: var(--text-3);
  font: 500 11px/1 var(--font-sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.preview-radius-slider {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.preview-radius-slider__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.preview-radius-slider__label {
  color: var(--text-2);
  font: 600 12px/1 var(--font-sans);
}

.preview-radius-slider__input {
  width: 100%;
}

.theme-studio-brand-note__text {
  max-width: 70ch;
  margin: 0;
  color: var(--text-2);
  font: var(--type-body-sm);
}

.theme-studio-advanced {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-top: 0.5rem;
}

.theme-studio-advanced__row {
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--border-2);
}

.theme-studio-advanced__row:last-child {
  border-bottom: 0;
}

.theme-studio-advanced__matrix-head {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-top: 0.25rem;
}

.theme-studio-advanced__matrix-title {
  margin: 0;
  color: var(--text-1);
  font: 600 13px/1 var(--font-sans);
}

.theme-studio-advanced__matrix-helper {
  margin: 0;
  color: var(--text-3);
  font: var(--type-body-sm);
}

.theme-studio-icon-matrix {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-card-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
}

.theme-studio-icon-matrix__row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-2);
  font: 500 12px/1 var(--font-sans);
}

.theme-studio-icon-matrix__row:last-child {
  border-bottom: 0;
}

.theme-studio-icon-matrix__label {
  color: var(--text-2);
}

.theme-studio-icon-matrix__icon {
  justify-self: start;
  padding: 3px 6px;
  background: var(--bg-glass);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font: 500 11px/1 var(--font-mono);
}

.theme-studio-icon-matrix__actions {
  display: inline-flex;
  gap: 0.375rem;
}

.theme-studio-icon-matrix__change,
.theme-studio-icon-matrix__reset {
  padding: 0.25rem 0.5rem;
  background: transparent;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font: 600 11px/1 var(--font-sans);
  cursor: pointer;
}

.theme-studio-icon-matrix__change:hover,
.theme-studio-icon-matrix__reset:hover {
  border-color: var(--brand);
  color: var(--brand);
}
