/*
 * Build guides (TQ\Guides): the listing, one guide and the writing form.
 * Loaded on the section's screens only. The editor's own chrome comes from
 * forum-editor.css, which TQ\Forum\BlockEditor enqueues wherever it mounts.
 */

/* ============ Back link ============ */
/*
 * Its own block, not the trade board's: trade.css is loaded on the trade
 * screens only, and the same markup here came out as a bare arrow stacked
 * above the words (base.css gives every svg `display: block`).
 */
.guides-back {
    margin: 0 0 var(--space-s);
    font-size: var(--text-xs);
}

.guides-back__link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3xs);
    color: var(--color-text-muted);
}

/* The arrow icon points right; "back" points left. */
.guides-back__link .icon {
    transform: scaleX(-1);
}

/* ============ Listing ============ */
.guides-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-xs) var(--space-s);
    margin-bottom: var(--space-m);
}

.guides-games {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2xs);
}

.guides-games__item {
    display: inline-block;
    padding: var(--space-3xs) var(--space-s);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-s);
    color: var(--color-text-muted);
    font-size: var(--text-s);
}

.guides-games__item--on {
    border-color: var(--color-border-accent);
    background: var(--color-surface-raised);
    color: var(--color-heading);
}

.guides-bar__new {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3xs);
}

.guides-empty {
    color: var(--color-text-muted);
    font-size: var(--text-s);
}

/* ============ One guide ============ */
/* The review badge, on the author's own copy of a guide nobody else can see. */
.guide-page__state {
    display: inline-block;
    padding: 0 var(--space-2xs);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-s);
    color: var(--color-text-muted);
    font-size: var(--text-xs);
}

.guide-page__edit {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3xs);
}

/* ============ Form ============ */
/*
 * The form page keeps the ordinary container width (no `--container-narrow`
 * as on the trade board): the editor's canvas is where a whole guide is
 * written, and a narrow column made it the width of a comment box.
 */
.guides-form {
    display: grid;
    /* The editor's canvas can push a grid track wider than the panel; this
       keeps every row inside it, as the forum's own form does. */
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-m);
    padding: var(--space-l) var(--space-xl);
    background: var(--color-surface);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-l);
}

@media (max-width: 40rem) {
    .guides-form {
        padding: var(--space-m) var(--space-s);
    }
}

.guides-form__group {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-2xs);
    margin: 0;
    padding: 0;
    border: 0;
}

/*
 * A legend is not a grid item - the browser lays it out in the fieldset's
 * border box - so the group's `gap` never reached it and the game buttons sat
 * against the word above them. The group is a plain block here and the legend
 * carries the spacing itself.
 */
.guides-form__group--radio {
    display: block;
}

.guides-form__legend {
    margin: 0 0 var(--space-2xs);
    padding: 0;
}

.guides-form__switch {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2xs);
}

.guides-form__option {
    position: relative;
    cursor: pointer;
}

/* The radio stays for keyboards and screen readers; the label is the button. */
.guides-form__radio {
    position: absolute;
    opacity: 0;
}

.guides-form__option-text {
    display: inline-block;
    padding: var(--space-2xs) var(--space-s);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-s);
    color: var(--color-text-muted);
}

.guides-form__radio:checked + .guides-form__option-text {
    border-color: var(--color-border-accent);
    background: var(--color-surface-raised);
    color: var(--color-heading);
}

.guides-form__radio:focus-visible + .guides-form__option-text {
    outline: var(--border-thin) solid var(--color-border-accent);
    outline-offset: 2px;
}

.guides-form__actions {
    margin: 0;
}

/*
 * The writing area. The forum's canvas is 16rem because it sits at the foot of
 * a topic that is already scrolling; here the form is the whole page and a
 * guide is an article, so it gets twice that on a desktop. The upper bound
 * keeps the Submit button within reach of the window.
 */
@media (min-width: 48rem) {
    .guides-form .forum-editor__canvas {
        height: clamp(32rem, 70vh, 48rem);
    }
}
