/* ============================================================
   Keyboard shortcuts cheatsheet (press "?")
   A grouped, keyboard-navigable reference of every shortcut. Shares the
   guest tokens and the command palette's overlay language so the two read
   as one system in both light and dark.
   ============================================================ */

/* ---------- Overlay ---------- */
.gks {
    position: fixed;
    inset: 0;
    z-index: 1081; /* one above the command palette */
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: clamp(2.5rem, 10vh, 7rem) 1rem 2rem;
}

.gks[hidden] { display: none; }

.gks__backdrop {
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--g-navy) 44%, transparent);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    animation: gks-fade .14s var(--g-ease);
}

.gks__dialog {
    position: relative;
    display: flex;
    width: min(36rem, 100%);
    max-height: min(40rem, 84vh);
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--g-border);
    border-radius: var(--g-r-lg);
    background: var(--g-surface);
    box-shadow: 0 32px 64px -28px color-mix(in srgb, var(--g-shadow-color) 34%, transparent);
    animation: gks-rise .16s var(--g-ease);
}

[data-guest-theme="dark"] .gks__dialog {
    box-shadow: 0 32px 64px -28px rgba(0, 0, 0, .62);
}

@keyframes gks-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes gks-rise {
    from { opacity: 0; transform: translateY(-6px) scale(.985); }
    to { opacity: 1; transform: none; }
}

/* ---------- Head ---------- */
.gks__head {
    display: flex;
    flex: none;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.15rem .85rem;
    border-bottom: 1px solid var(--g-border);
}

.gks__kicker {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    color: var(--g-accent-ink);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.gks__title {
    margin: .25rem 0 0;
    color: var(--g-text);
    font-size: 1.05rem;
    font-weight: 750;
    letter-spacing: -.02em;
}

.gks__close {
    display: grid;
    width: 30px;
    height: 30px;
    flex: none;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--g-text-faint);
    font-size: .8rem;
    cursor: pointer;
    transition: background-color .16s var(--g-ease), color .16s var(--g-ease);
}

.gks__close:hover { background: var(--g-surface-2); color: var(--g-text); }
.gks__close:focus-visible { outline: 2px solid var(--g-accent); outline-offset: 1px; }

/* ---------- Filter field ----------
   Mirrors the command palette's search field so the two read as one system. */
.gks__field {
    display: flex;
    flex: none;
    align-items: center;
    gap: .6rem;
    padding: .7rem 1.15rem;
    border-bottom: 1px solid var(--g-border);
}
.gks__field-icon {
    display: grid;
    flex: none;
    place-items: center;
    color: var(--g-text-faint);
    font-size: .9rem;
}
.gks__input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--g-text);
    font-family: inherit;
    font-size: .92rem;
    outline: 0;
}
.gks__input::placeholder { color: var(--g-text-faint); opacity: 1; }

/* Rows and sections hidden by the filter. */
.gks-row[hidden] { display: none; }
.gks__section[hidden] { display: none; }

.gks__empty {
    grid-column: 1 / -1;
    margin: 0;
    padding: 2rem 1rem;
    color: var(--g-text-muted);
    font-size: .85rem;
    text-align: center;
}
.gks__empty[hidden] { display: none; }

/* ---------- Body / sections ----------
   One column: sections of different lengths (and a filtered list) left the
   second column half empty, so every section stacks in reading order. */
.gks__body {
    flex: 1;
    min-height: 0;
    padding: .9rem 1.15rem 1.1rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: .4rem;
    align-content: start;
}

.gks__section-title {
    margin: .4rem 0 .35rem;
    padding: 0 .2rem;
    color: var(--g-text-faint);
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.gks__list {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* No sibling-fade: the active row is marked purely by its own highlight
   (.gks-row.is-active below). An opacity dim on the other rows read as a jerk
   as the selection moved, so it was removed — matching the command palette. */
@media (prefers-reduced-motion: reduce) {
    .gks-row,
    .gks-row__icon { transition: none; }
}

/* ---------- Row ---------- */
.gks-row {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .5rem .55rem;
    border-radius: 9px;
    color: var(--g-text);
    cursor: pointer;
    outline: 0;
    /* Match the .28s opacity settle so the row highlight and the sibling fade
       move together as the selection roves. */
    transition: background-color .28s cubic-bezier(.33, 0, .2, 1);
}

.gks-row--static { cursor: default; }
.gks-row--static:not([data-gks-action]) { cursor: default; }
.gks-row[data-gks-action] { cursor: pointer; }

/* The filter field keeps focus, so the active row is marked with a class
   (the roving highlight) rather than real focus — the same single indicator
   the command palette uses. A soft neutral wash, a touch darker than
   surface-2, with the label at full-strength text so it stands out. Hover
   adopts the same highlight. */
.gks-row:hover,
.gks-row.is-active {
    /* Soft neutral wash, a touch darker than --g-surface-2 (mixed toward the
       border) so the row highlight reads a little more clearly, matching the
       command palette's darkened hover. */
    background: color-mix(in srgb, var(--g-surface-2) 78%, var(--g-border));
    color: var(--g-text);
}

.gks-row__icon {
    display: grid;
    width: 30px;
    height: 30px;
    flex: none;
    place-items: center;
    border-radius: 8px;
    background: var(--g-surface-2);
    color: var(--g-text-muted);
    font-size: .82rem;
    /* Settle with the row (.28s) so the tile background does not pop ahead of
       the highlight as the selection moves. */
    transition: background-color .28s cubic-bezier(.33, 0, .2, 1), color .28s cubic-bezier(.33, 0, .2, 1);
}

.gks-row:hover .gks-row__icon,
.gks-row.is-active .gks-row__icon {
    /* Icon tile steps one neutral stronger than the row wash. */
    background: var(--g-border);
    color: var(--g-text);
}

.gks-row__text {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    gap: .05rem;
}

.gks-row__label {
    overflow: hidden;
    font-size: .86rem;
    font-weight: 600;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gks-row__hint {
    overflow: hidden;
    color: var(--g-text-faint);
    font-size: .74rem;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gks-row:hover .gks-row__hint,
.gks-row.is-active .gks-row__hint { color: var(--g-text-muted); }

/* ---------- Key badges ---------- */
.gks-row__keys {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: .25rem;
}

.gks-row__keys kbd {
    min-width: 20px;
    padding: .12rem .35rem;
    border: 1px solid var(--g-border);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: var(--g-surface);
    color: var(--g-text-muted);
    font-family: inherit;
    font-size: .72rem;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
}

.gks-row:hover .gks-row__keys kbd,
.gks-row.is-active .gks-row__keys kbd {
    border-color: var(--g-border-strong);
    color: var(--g-text);
}

/* Full-strength label colour on the active/hovered row so it stands out —
   colour only, not weight: bumping the weight reflowed the text width and
   caused a visible jerk on hover. */
.gks-row:hover .gks-row__label,
.gks-row.is-active .gks-row__label { color: var(--g-text); }

.gks-row__then,
.gks-row__or {
    color: var(--g-text-faint);
    font-size: .68rem;
    font-style: italic;
}

/* ---------- Foot ---------- */
.gks__foot {
    display: flex;
    flex: none;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .6rem 1rem;
    border-top: 1px solid var(--g-border);
    background: color-mix(in srgb, var(--g-surface-2) 45%, var(--g-surface));
    color: var(--g-text-faint);
    font-size: .7rem;
}

.gks__foot kbd {
    min-width: 17px;
    padding: .05rem .25rem;
    border: 1px solid var(--g-border);
    border-radius: 4px;
    background: var(--g-surface);
    color: var(--g-text-muted);
    font-family: inherit;
    font-size: .66rem;
    line-height: 1.4;
    text-align: center;
}

.gks__foot-note kbd { font-weight: 600; }

/* Lock background scroll while open; pad by the measured scrollbar width so
   the page does not shift right. */
body.gks-open { overflow: hidden; padding-right: var(--gks-sbw, 0px); }

/* ---------- Responsive ---------- */
@media (max-width: 639.98px) {
    .gks { padding-top: 1.25rem; }
    .gks__dialog { max-height: 88vh; }
    .gks__foot-note { display: none; }
}
