/* SETTINGS PAGE */

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  margin: 0;
  padding: 0;
  border: none;
  min-width: 0;
}

.settings-section + .settings-section {
  border-top: 1px solid var(--color-border);
  padding-top: 3rem;
}

.settings-section-text {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0;
}

/* Legends ignore flex unless floated, this keeps the gap below them */
legend.settings-section-text {
  float: left;
  width: 100%;
  margin-bottom: 2rem;
}

legend.settings-section-text + * {
  clear: both;
}

.settings-section .content-primary {
  color: var(--color-text-primary);
}

.settings-section .content-secondary {
  color: var(--color-text-secondary);
}

/* THEME AND MODE OPTIONS */

.theme-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 340px));
  gap: 2rem;
}

.mode-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 220px));
  gap: 2rem;
}

@media (max-width: 768px) {
  .theme-options,
  .mode-options {
    grid-template-columns: 1fr;
  }
}

.theme-option,
.mode-option {
  border: 1px solid var(--color-border);
  border-radius: 1.5rem;
  background: var(--color-surface-secondary);
  cursor: pointer;
}

.theme-option:hover,
.mode-option:hover {
  background: var(--color-surface-tertiary);
}

.theme-option:has(.option-input:checked),
.mode-option:has(.option-input:checked) {
  border-color: var(--color-accent-text);
  box-shadow: 0 0 0 1px var(--color-accent-text);
}

.theme-option:has(.option-input:focus-visible),
.mode-option:has(.option-input:focus-visible) {
  outline: 2px solid var(--color-accent-text);
  outline-offset: 2px;
}

/* Hidden but still focusable and read by screen readers */
.option-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

/* THEME */

.theme-option {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 2rem;
}

.theme-option-text {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.theme-option-badge {
  visibility: hidden;
}

.theme-option:has(.option-input:checked) .theme-option-badge {
  visibility: visible;
}

.theme-swatches {
  display: flex;
}

.theme-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--color-surface-secondary);
  box-shadow: 0 0 0 1px var(--color-border);
}

.theme-swatch + .theme-swatch {
  margin-left: -8px;
}

/* MODE */

.mode-option {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem;
}

.mode-option-text {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* Mini window previews. These use the active theme's light and dark colours, so they look the same in either mode */
.mode-preview {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  border-radius: 1rem;
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.mode-preview-window {
  position: absolute;
  inset: 0;
  display: flex;
}

/* System shows light and dark split diagonally */
.mode-preview--system .mode-preview-window--dark {
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

.mode-preview-window--light { background: var(--light-surface-primary); }
.mode-preview-window--light .mode-preview-sidebar { background: var(--light-surface-secondary); }
.mode-preview-window--light .mode-preview-line { background: var(--light-surface-tertiary); }

.mode-preview-window--dark { background: var(--dark-surface-primary); }
.mode-preview-window--dark .mode-preview-sidebar { background: var(--dark-surface-secondary); }
.mode-preview-window--dark .mode-preview-line { background: var(--dark-surface-tertiary); }

.mode-preview-sidebar {
  width: 28%;
}

.mode-preview-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
}

.mode-preview-line {
  height: 1rem;
  border-radius: 999px;
}

.mode-preview-window--light .mode-preview-line--accent {
  width: 40%;
  background: var(--light-accent);
}

.mode-preview-window--dark .mode-preview-line--accent {
  width: 40%;
  background: var(--dark-accent);
}

.mode-preview-line--short {
  width: 60%;
}
