/*
 * The appearance switcher (E2-11): a toggle button and a popover menu with the scheme,
 * palette and style. Every site renders the same markup with its own strings; /shared/prefs.js
 * handles the buttons. This file is copied to the portfolio by `npm run sync:shared`.
 *
 * Set --prefs-top on the page to place the menu under its header.
 *
 * The language button (E2-12) sits next to the toggle and shows the other language's code.
 */

.prefs {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.lang-toggle {
  display: grid;
  place-items: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.45rem;
  flex: none;
  font: 600 0.72rem/1 var(--font-mono);
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    color var(--duration) var(--ease),
    border-color var(--duration) var(--ease);
}

.lang-toggle:hover,
.lang-toggle:focus-visible {
  color: var(--accent-text);
  border-color: var(--accent-text);
}

.lang-toggle:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

.prefs-toggle {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  flex: none;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    color var(--duration) var(--ease),
    border-color var(--duration) var(--ease);
}

.prefs-toggle:hover,
.prefs-toggle:focus-visible {
  color: var(--accent-text);
  border-color: var(--accent-text);
}

.prefs-toggle:focus-visible,
.prefs-option:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

.prefs-toggle svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* The browser hides a closed popover; only style the open one. */
.prefs-menu:popover-open {
  position: fixed;
  inset: auto;
  top: var(--prefs-top, 4rem);
  right: var(--prefs-right, 1rem);
  display: grid;
  gap: 1rem;
  width: min(19rem, calc(100vw - 2rem));
  margin: 0;
  padding: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-family: var(--font-sans);
}

.prefs-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.prefs-group legend {
  margin-bottom: 0.5rem;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.prefs-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
}

.prefs-options--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.prefs-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.25rem;
  padding: 0.45rem 0.6rem;
  font: 500 0.85rem/1.1 var(--font-sans);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--duration) var(--ease);
}

.prefs-option:hover {
  border-color: var(--text-muted);
}

.prefs-option[aria-pressed="true"] {
  border-color: var(--accent-text);
  box-shadow: inset 0 0 0 1px var(--accent-text);
}

.prefs-swatch {
  width: 0.8rem;
  height: 0.8rem;
  flex: none;
  border-radius: 50%;
  background: var(--swatch);
}
