/* Swarpeti — the Settings drawer, the keyboard guide, the start card and notices. */

/* ------------------------------------------------------------------ *
 * Drawer, dialog, overlay
 * ------------------------------------------------------------------ */

/* Not dimmed on purpose: while choosing colours the page must stay true-colour. */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: transparent;
}

.scrim[hidden] {
  display: none;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  width: min(390px, 100%);
  padding: 14px 20px 20px;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  background: var(--surface);
  transform: translateX(105%);
  transition: transform 0.25s ease;
}

.drawer.open {
  transform: none;
  box-shadow: -20px 0 50px rgba(0, 0, 0, 0.45);
}

.drawer-head,
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.drawer h2,
.dialog-head h2,
.overlay h2 {
  font: 600 1.3rem var(--font-display);
}

.drawer-section {
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.drawer-section:first-of-type {
  padding-top: 2px;
  border-top: 0;
}

.drawer-section h3,
#help h3 {
  margin-bottom: 7px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px 8px;
  padding-top: 8px; /* room for the first row's names */
}

/* Many themes: small frames with the name on the top border, like the colour
   frames below, and the theme's colours inside. The blurb stays for screen
   readers and as a tooltip. */
.theme-card {
  position: relative;
  display: flex;
  min-width: 0;
  padding: 12px 8px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s;
}

.theme-card[hidden] {
  display: none;
}

.theme-card:hover {
  border-color: var(--text-dim);
}

.theme-card[aria-pressed='true'] {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 12px var(--glow);
}

.theme-card[aria-pressed='true'] .theme-name {
  color: var(--accent-fg);
}

.swatches {
  display: flex;
  flex: 1;
  height: 16px;
  overflow: hidden;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.swatches i {
  flex: 1;
}

.theme-group {
  margin: 10px 0 5px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* The Light row has a heading for each of its two kinds of card. Headings are
   grid items, so "Yours" sits right above its card, like "Light" above its own. */
.theme-grid-light .theme-group {
  margin: 2px 0 -5px;
}

.theme-group-light {
  grid-column: 1 / -1;
}

.theme-grid-light.has-yours .theme-group-light {
  grid-column: 1 / span 2;
}

.theme-group-yours {
  grid-column: 3;
}

.theme-group[hidden] {
  display: none;
}

.theme-card-wide {
  grid-column: 1 / -1;
}

/* Cuts the border, like a fieldset legend: same background as the drawer. */
.theme-name,
.theme-card-wide .theme-blurb {
  position: absolute;
  top: 0;
  left: 4px;
  max-width: calc(100% - 8px);
  padding: 0 4px;
  overflow: hidden;
  background: var(--surface);
  font: 600 0.74rem var(--font-ui);
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform: translateY(-50%);
}

.theme-blurb {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Prahar has room, and its "Now: ..." line is useful to see: on the right of the border. */
.theme-card-wide .theme-blurb {
  left: auto;
  right: 6px;
  width: auto;
  height: auto;
  max-width: calc(100% - 90px);
  clip-path: none;
  font: 0.7rem var(--font-ui);
  color: var(--text-dim);
}

/* Two by two: Case and Accent, then Keys and Black keys. Each is a small
   frame with its name on the top border: the swatch on the left, the hex on the right. */
.color-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 10px;
  padding-top: 7px; /* room for the first row's names */
}

.color-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.color-row:hover {
  border-color: var(--text-dim);
}

/* Cuts the border, like a fieldset legend: same background as the drawer. */
.color-name {
  position: absolute;
  top: 0;
  left: 10px;
  padding: 0 6px;
  background: var(--surface);
  font-size: 0.78rem;
  line-height: 1;
  color: var(--text-dim);
  transform: translateY(-50%);
  white-space: nowrap;
}

.color-row code {
  font: 0.8rem ui-monospace, 'SF Mono', Menlo, monospace;
  color: var(--text);
  letter-spacing: 0.02em;
}

.color-row input[type='color'] {
  width: 40px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}

.warnings {
  list-style: none;
  padding: 0;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.76rem;
  color: var(--accent-fg);
}

.warnings:empty {
  display: none;
}

.warnings li::before {
  content: '⚠ ';
}

/* Settings > Instrument: a label and its switch per row, then the Drone tick. */
.panel-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

/* Settings > Instrument: plain checkboxes, tinted to the theme. */
.check {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  font-size: 0.88rem;
  cursor: pointer;
}

.check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.panel-option-hint {
  margin: -4px 0 10px;
}

.color-note {
  margin-top: 8px;
}

dialog {
  width: min(660px, calc(100% - 32px));
  max-height: calc(100% - 48px);
  overflow-y: auto;
  padding: 20px 22px 22px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
}

.steps {
  padding-left: 1.2em;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  color: var(--text-dim);
}

.steps strong {
  color: var(--text);
}

.map {
  display: grid;
  grid-template-columns: repeat(29, minmax(0, 1fr));
  gap: 6px 3px;
  min-width: 540px; /* a phone scrolls the guide sideways rather than crushing the keys */
  margin-bottom: 10px;
}

#help {
  overflow-x: auto;
}

.map-key {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
  padding: 5px 1px 4px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 0.8rem;
  line-height: 1.2;
}

.map-white {
  border-color: var(--key-white-edge);
  background: linear-gradient(180deg, var(--key-white-1), var(--key-white-2));
  color: var(--key-white-ink);
}

.map-black {
  border-color: var(--key-black-edge);
  background: linear-gradient(180deg, var(--key-black-1), var(--key-black-2));
  color: var(--key-black-ink);
}

.map-empty {
  justify-content: center;
  background: var(--well);
  opacity: 0.4;
}

.map-key kbd {
  padding: 0 4px;
  border-color: currentColor;
  background: transparent;
  font-size: 0.68rem;
  opacity: 0.75;
}

.map-name {
  margin: 3px 0;
  font-weight: 600;
}

.map-key small {
  font-size: 0.66rem;
  opacity: 0.7;
}

.map-legend {
  margin-bottom: 8px;
}

/* A short notice, e.g. after switching to Auto-air by itself. */
.notice {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 40;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 9px 18px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  font-size: 0.85rem;
  text-align: center;
  transform: translateX(-50%);
  animation: notice-in 0.25s ease;
}

@keyframes notice-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  padding: 20px;
  overflow-y: auto; /* zoomed in, the card can be taller than the window: scroll, never cut off */
  background: color-mix(in srgb, var(--bg-page) 82%, transparent);
  backdrop-filter: blur(8px);
}

.overlay[hidden] {
  display: none;
}

.overlay-card {
  margin: auto; /* centred, but starts at the top (never above it) once taller than the window */
  width: min(430px, 100%);
  padding: 30px 28px 24px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  text-align: center;
}

.overlay h2 {
  font-size: 1.9rem;
  letter-spacing: 0.03em;
}

.overlay-sub {
  margin: 4px 0 18px;
  color: var(--text-dim);
}

.overlay .steps {
  text-align: left;
  margin-bottom: 22px;
}

.start-wrap {
  position: relative;
  display: inline-flex;
  margin: 6px 0 4px;
}

.start-ring {
  position: absolute;
  pointer-events: none;
  overflow: visible;
}

.start-ring rect {
  fill: none;
  stroke-width: 3;
}

.start-ring .ring-track {
  stroke: color-mix(in srgb, var(--accent) 28%, transparent);
}

.start-ring .ring-fill {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 0 100;
}

.overlay-lid {
  margin-top: 14px;
  font-size: 0.76rem;
  color: var(--text-dim);
}
