/* The reference pages: help files for now (templates/helps.html,
   help_detail.html and help_edit.html), with items, tomes and socials to
   follow. Classes start with rf- so they never collide with site CSS. Every
   color comes from the scheme tokens. */
.rf {
    /* Secondary text that stays at AA on the page and panel grounds. */
    --meta: color-mix(in srgb, var(--text) 40%, var(--text-dim));
    --wash: color-mix(in srgb, var(--highlight) 12%, transparent);
    width: 100%;
    max-width: 980px;
}
.rf [hidden] { display: none !important; }
.rf :focus-visible { outline: 2px solid var(--highlight); outline-offset: 2px; }
.rf h2 { margin: 0; padding: 0; border: 0; letter-spacing: -.01em; color: var(--text-bright); }
.rf p { margin: 0; }
.rf-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* page head */
.rf-back { display: inline-block; margin: 0 0 8px; font-size: 13px; color: var(--meta); text-decoration: none; }
.rf-back:hover { color: var(--highlight); }
.rf-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin: 0 0 22px; }
.rf .rf-head h1 { margin: 0; font-size: 28px; line-height: 1.2; letter-spacing: -.02em; color: var(--text-bright); overflow-wrap: anywhere; }
.rf .rf-deck { margin: 6px 0 0; max-width: 64ch; font-size: 14.5px; line-height: 1.6; color: var(--meta); text-wrap: pretty; }
.rf-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.rf-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* who can read a help, as the game decides it */
.rf-tag {
    display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--bg-active);
    font-size: 11.5px; font-weight: 600; line-height: 1.45; color: var(--text); white-space: nowrap;
}
.rf-tag.is-imm { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.rf-tag.is-kind { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.rf-tag.is-level { background: var(--wash); color: var(--highlight); }

/* search: one line on a wide screen, wrapping on a phone */
.rf-search {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 18px; padding: 12px;
    border: 1px solid var(--border); border-radius: 8px; background: var(--bg-secondary);
}
.rf .rf-search input[type=search] { flex: 1 1 260px; min-width: 0; height: 36px; margin: 0; font-size: 14px; }
.rf .rf-search select { flex: 0 1 200px; min-width: 0; height: 36px; margin: 0; font-size: 13.5px; }
.rf .rf-search .btn { height: 36px; margin: 0; }
.rf-clear { padding: 0 4px; font-size: 13px; color: var(--meta); text-decoration: none; }
.rf-clear:hover { color: var(--highlight); }

.rf-count { margin: 0 0 10px; font-size: 13px; color: var(--meta); }
.rf-count b { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.rf .rf-empty { padding: 26px 20px; border: 1px dashed var(--border); border-radius: 8px; font-size: 14px; text-align: center; color: var(--meta); }

/* the list of helps: keyword, badge and the first line of the text */
.rf-list { margin: 0; padding: 0; list-style: none; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-secondary); overflow: hidden; }
.rf-list li { margin: 0; padding: 0; border-top: 1px solid var(--border); }
.rf-list li:first-child { border-top: 0; }
.rf-row {
    display: grid; grid-template-columns: minmax(140px, 15rem) 8.5rem minmax(0, 1fr); align-items: center; gap: 4px 16px;
    padding: 11px 16px; color: var(--text); text-decoration: none;
}
.rf-row:hover { background: var(--bg-hover); }
.rf-key { font-weight: 600; color: var(--text-bright); overflow-wrap: anywhere; }
.rf-row:hover .rf-key { color: var(--highlight); }
.rf-row .rf-tag { justify-self: start; }
.rf-preview { min-width: 0; overflow: hidden; font-size: 13.5px; color: var(--meta); white-space: nowrap; text-overflow: ellipsis; }
.rf .pagination { margin-top: 18px; }

/* one help, in the game's own text */
.rf-text {
    max-width: calc(80ch + 44px); margin: 0; padding: 18px 22px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg-secondary); font-family: var(--font-mono); font-size: 13.5px; line-height: 1.6;
    color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; overflow-x: auto;
}
/* A help page takes the width of its text, so the Edit button sits at the
   panel's edge rather than across an empty column. */
.rf.rf-one { width: fit-content; min-width: min(100%, 560px); }
.rf .hiw-section { margin: 16px 0 0; }

/* the editor */
.rf-form { padding: 20px 22px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-secondary); }
.rf-field { margin: 0 0 16px; }
.rf-field > label, .rf-fields label { display: block; margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--text); }
.rf .rf-field input[type=text], .rf .rf-field textarea, .rf .rf-fields select, .rf .rf-fields input { width: 100%; max-width: none; margin: 0; }
.rf-fields { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 16px; margin: 0; }
.rf-fields > div { flex: 1 1 220px; max-width: 320px; }
.rf-fields > .rf-num { flex: 0 0 110px; }
.rf-note { margin: 6px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--meta); }
.rf .rf-mono { font-family: var(--font-mono); }
.rf .rf-form textarea { min-height: 420px; font-family: var(--font-mono); font-size: 13px; line-height: 1.55; white-space: pre; overflow-wrap: normal; overflow-x: auto; }
.rf-acts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rf-sec { margin: 28px 0 0; }
.rf .rf-sec-head { margin: 0 0 4px; font-size: 16px; font-weight: 700; }
.rf .rf-sub { margin: 0 0 12px; max-width: 78ch; font-size: 13px; line-height: 1.55; color: var(--meta); }
.rf-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.rf table.rf-table { width: 100%; margin: 0 0 12px; border-collapse: collapse; border: 0; font-size: 14px; }
.rf-table th {
    padding: 8px 10px; border: 0; border-bottom: 1px solid var(--border); background: none;
    font-family: inherit; font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; text-align: left; color: var(--meta);
}
.rf-table td { padding: 8px 10px; border: 0; border-top: 1px solid var(--border); vertical-align: middle; }
.rf-table tbody tr:first-child td { border-top: 0; }
.rf .rf-table input { width: 100%; margin: 0; }
.rf .rf-table input[type=number] { width: 72px; }
.rf-table .rf-acts { justify-content: flex-end; flex-wrap: nowrap; }
.rf-add { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) 72px auto; align-items: end; gap: 10px; }
.rf .rf-add input { width: 100%; margin: 0; }
.rf-add label { display: block; margin: 0 0 6px; font-size: 12.5px; font-weight: 600; color: var(--text); }
.rf-danger { margin: 28px 0 0; padding: 16px 0 0; border-top: 1px solid var(--border); }

@media (max-width: 700px) {
    .rf .rf-head h1 { font-size: 24px; }
    .rf-row { grid-template-columns: minmax(0, 1fr) auto; padding: 11px 14px; }
    .rf-preview { grid-column: 1 / -1; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
    .rf-row .rf-tag { justify-self: end; }
    .rf-text { padding: 14px 14px; font-size: 12.5px; }
    .rf-form { padding: 16px 14px; }
    .rf-add { grid-template-columns: minmax(0, 1fr) 72px; }
    .rf-add > div:first-child, .rf-add > div:nth-child(2) { grid-column: 1 / -1; }
}
