/* EN/DE two-language switch with flags for Grav (portfolio theme) */
.i18n-switch {
  --switch-height: 36px;
  --switch-padding: 4px;
  --switch-bg: #f1f1f5;
  --switch-border: #d8d8df;
  --switch-active: #2b6cb0;
  --switch-muted: #6b7280;

  position: relative;
  display: inline-block;
  height: var(--switch-height);
  padding: var(--switch-padding);
  border-radius: calc(var(--switch-height) / 2);
  background: var(--switch-bg);
  border: 1px solid var(--switch-border);
  box-sizing: border-box;
  user-select: none;
  font: inherit;
}

/* Visually hide the checkbox but keep it accessible */
.i18n-switch__checkbox {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
  border: 0;
  padding: 0;
  margin: -1px;
}

/* Track + labels */
.i18n-switch__label {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 0;
  height: calc(var(--switch-height) - var(--switch-padding) * 2);
  min-width: 128px; /* room for flags + codes */
  position: relative;
  cursor: pointer;
}

/* Options */
.i18n-switch__option {
  font-size: 0.9rem;
  line-height: 1;
  text-align: center;
  padding: 0 12px;
  z-index: 2;
  color: var(--switch-muted);
  transition: color 0.2s ease;
  white-space: nowrap;
}

/* Handle (thumb) */
.i18n-switch__handle {
  position: absolute;
  top: var(--switch-padding);
  bottom: var(--switch-padding);
  left: var(--switch-padding);
  width: calc(50% - var(--switch-padding));
  border-radius: calc(var(--switch-height) / 2);
  background: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  transition: transform 0.22s ease;
  z-index: 1;
}

/* Active text depending on position */
.i18n-switch__checkbox:not(:checked) ~ .i18n-switch__label .i18n-switch__option--en { color: var(--switch-active); }
.i18n-switch__checkbox:checked ~ .i18n-switch__label .i18n-switch__option--de { color: var(--switch-active); }

/* Move handle when checked (DE) */
.i18n-switch__checkbox:checked ~ .i18n-switch__label .i18n-switch__handle {
  transform: translateX(100%);
}

/* Focus styles */
.i18n-switch__checkbox:focus-visible ~ .i18n-switch__label,
.i18n-switch__label:focus-within {
  outline: 2px solid #5b9dd9;
  outline-offset: 2px;
  border-radius: calc(var(--switch-height) / 2);
}

@media (prefers-color-scheme: dark) {
  .i18n-switch {
    --switch-bg: #24262a;
    --switch-border: #34363b;
    --switch-muted: #a3a3a3;
    --switch-active: #7aa2f7;
  }
  .i18n-switch__handle {
    background: #2f3136;
  }
}