/* =========================================================================
   Cabinhub News — command palette for the API account console.

   Shape: the console is a ledger on paper. The palette is the same ledger's
   index card: a hairline sheet on a dimmed ground, square-to-soft corners,
   the same ink and the same one accent. No glass, no blur, no gradient, no
   shadow — a scrim does the depth work and a rule does the separation, exactly
   as the page's own CSS does.

   Tokens only: colour, type, radius and timing come from css/tokens.css and
   the console's motion ramp. No hex, no literal font-size, no uppercase, no
   tracking on labels (type law + Hallmark gate 67).

   Trigger: compact on the desk (glyph + label + keycap). Below 600px the
   masthead has no room for a fourth control (measured: 12.8px of free space
   at 390 and 360), so the same button moves out of flow to a 44x44 floating
   control at the bottom-right, inside the thumb's reach and above the page's
   bottom padding. It is hidden whenever the signed-in shell is hidden.

   Motion: one 90ms opacity change on open, removed under
   prefers-reduced-motion. Closing is instant and never waits for a transition.
   ========================================================================= */

/* ------------------------------------------------------------- trigger -- */

.con .cmdk__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 0.55rem;
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font-ui);
  font-size: var(--fs-label);
  line-height: 1.2;
  cursor: pointer;
  transition: color var(--m-dur-1, 90ms) var(--ease),
    border-color var(--m-dur-1, 90ms) var(--ease),
    background var(--m-dur-1, 90ms) var(--ease);
}
.con .cmdk__trigger:hover { color: var(--ink); border-color: var(--ink-faint); }
.con .cmdk__trigger[hidden] { display: none; }

/* A drawn magnifier, not an icon font and not an emoji: a 12px ring and a
   1.5px handle. It inherits currentColor, so both themes and forced colours
   paint it without a second rule. */
.con .cmdk__glyph {
  position: relative;
  display: block;
  width: 0.75rem;
  height: 0.75rem;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  flex: 0 0 auto;
}
.con .cmdk__glyph::after {
  content: "";
  position: absolute;
  right: -0.24rem;
  bottom: -0.2rem;
  width: 1.5px;
  height: 0.34rem;
  background: currentColor;
  transform: rotate(-45deg);
}

.con .cmdk__label { white-space: nowrap; }

.con .cmdk__key {
  padding: 0.08rem 0.3rem;
  border: 1px solid var(--rule);
  border-radius: var(--r-xs);
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  line-height: 1.3;
}

/* -------------------------------------------------------------- overlay -- */

.con .cmdk__overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  align-items: start;
  justify-items: center;
  padding: clamp(1rem, 9vh, 6rem) var(--pad-r) calc(1rem + var(--pad-b)) var(--pad-l);
  overflow: auto;
  overscroll-behavior: contain;
  background: color-mix(in srgb, var(--ink) 34%, transparent);
  opacity: 0;
  transition: opacity var(--m-dur-1, 90ms) var(--ease);
}
.con .cmdk__overlay[hidden] { display: none; }
.con .cmdk__overlay--open { opacity: 1; }

/* ---------------------------------------------------------------- sheet -- */

.con .cmdk__sheet {
  width: min(34rem, 100%);
  max-height: min(70vh, 32rem);
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  overflow: hidden;
}

.con .cmdk__input {
  flex: 0 0 auto;
  width: 100%;
  min-height: calc(var(--tap) + 0.25rem);
  margin: 0;
  padding: 0 1rem;
  border: 0;
  border-bottom: 1px solid var(--rule-soft);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--fs-meta);
  line-height: 1.3;
  box-sizing: border-box;
}
.con .cmdk__input::placeholder { color: var(--ink-faint); opacity: 1; }
/* Chromium paints its own blue clear button on type=search. The palette has
   its own way out (Escape / Close) and the browser's control is neither in the
   design system nor keyboard-reachable, so it is removed; typing still edits,
   and selecting the text still replaces it. */
.con .cmdk__input::-webkit-search-cancel-button,
.con .cmdk__input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
/* The sheet clips its children, so the shared 2px-offset ring would be cut on
   the first and last rows. Draw the same 2px ring inside the control instead:
   still a real focus indicator, still forced-colors-safe (outline, not shadow). */
.con .cmdk__input:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

.con .cmdk__list {
  flex: 1 1 auto;
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  overflow: auto;
  overscroll-behavior: contain;
}
.con .cmdk__list[hidden] { display: none; }

.con .cmdk__group {
  padding: 0.55rem 1rem 0.25rem;
  color: var(--ink-faint);
  font-family: var(--font-ui);
  font-size: var(--fs-micro);
  font-weight: 600;
  line-height: 1.3;
}

.con .cmdk__option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 0.75rem;
  row-gap: 0.1rem;
  align-items: center;
  min-height: var(--tap);
  padding: 0.55rem 1rem;
  border-left: 2px solid transparent;
  color: var(--ink);
  cursor: pointer;
}
.con .cmdk__option-label {
  grid-column: 1;
  font-family: var(--font-ui);
  font-size: var(--fs-small);
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.con .cmdk__option-hint {
  grid-column: 1;
  color: var(--ink-faint);
  font-family: var(--font-ui);
  font-size: var(--fs-label);
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.con .cmdk__option-current {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: start;
  margin-top: 0.1rem;
  padding: 0 0.35rem;
  border: 1px solid var(--rule);
  border-radius: var(--r-xs);
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: var(--fs-micro);
  line-height: 1.5;
  white-space: nowrap;
}
.con .cmdk__option.is-active {
  background: var(--paper-2);
  border-left-color: var(--accent);
}

.con .cmdk__empty {
  margin: 0;
  padding: 1.5rem 1rem;
  color: var(--ink-soft);
  font-family: var(--font-ui);
  font-size: var(--fs-meta);
  line-height: 1.5;
}
.con .cmdk__empty[hidden] { display: none; }

.con .cmdk__footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem 0.5rem 1rem;
  border-top: 1px solid var(--rule-soft);
  color: var(--ink-faint);
  font-family: var(--font-ui);
  font-size: var(--fs-micro);
  line-height: 1.35;
}
.con .cmdk__footer-hint { min-width: 0; }

.con .cmdk__close {
  flex: 0 0 auto;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 0.75rem;
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font-ui);
  font-size: var(--fs-label);
  line-height: 1.2;
  cursor: pointer;
}
.con .cmdk__close:hover { color: var(--ink); border-color: var(--ink-faint); }

/* ------------------------------------------------------------ phone ---- */

/* Measured on the unchanged tree at 390 and 360: the masthead has 12.8px of
   free space between the wordmark and the controls, so a fourth control would
   overflow the document. The same button leaves the row below 600px and
   becomes the one floating control, 44x44, clear of the safe areas. Being
   position:fixed it contributes no width to .mast__controls. */
@media (max-width: 599px) {
  .con .cmdk__trigger {
    position: fixed;
    right: calc(1rem + env(safe-area-inset-right, 0px));
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    z-index: 70;
    padding: 0;
    background: var(--canvas);
    border-color: var(--rule-strong);
  }
  .con .cmdk__label,
  .con .cmdk__key { display: none; }
  .con .cmdk__sheet { max-height: min(72vh, 34rem); }
}

/* --------------------------------------------------------- reduced motion -- */

@media (prefers-reduced-motion: reduce) {
  .con .cmdk__overlay,
  .con .cmdk__trigger { transition: none; }
  .con .cmdk__overlay { opacity: 1; }
}

/* --------------------------------------------------------- forced colours -- */

@media (forced-colors: active) {
  .con .cmdk__overlay { background: Canvas; }
  .con .cmdk__sheet { border: 1px solid CanvasText; }
  .con .cmdk__trigger,
  .con .cmdk__close,
  .con .cmdk__option-current {
    border: 1px solid ButtonBorder;
    background: ButtonFace;
    color: ButtonText;
  }
  .con .cmdk__option.is-active {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }
  .con .cmdk__option,
  .con .cmdk__input,
  .con .cmdk__footer { border-color: CanvasText; }
}
