/* =====================================================================
   CHCP Glossary — public index. Scoped under `.lexicon` so the admin and
   auth pages keep Varela Round; tokens and accents come from app.css.
   ===================================================================== */

.lexicon {
    /* font-family is restated below because descendants inherit <body>'s computed
       family, not the custom property. */
    --font-display: 'Hanken Grotesk', ui-sans-serif, system-ui, -apple-system, sans-serif;
    --font-body: 'Hanken Grotesk', ui-sans-serif, system-ui, -apple-system, sans-serif;
    font-family: var(--font-body);

    --ink: #161d3f;
}

.lexicon__body {
    padding-top: clamp(var(--space-6), 4vw, var(--space-8));
    padding-bottom: var(--space-7);
}

/* The global 96px footer margin leaves too big a gap under the list. */
.lexicon + .site-footer {
    margin-top: var(--space-8);
}

/* ---------------------------------------------------------------------
   Brand + title
   --------------------------------------------------------------------- */
.lex-head {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3) var(--space-5);
    padding-bottom: var(--space-5);
    margin-bottom: clamp(var(--space-6), 4vw, var(--space-8));
}

.lex-head::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    border-radius: 3px;
    background: var(--rainbow);
}

.lex-head__brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
}

.lex-head__logo {
    height: clamp(48px, 6vw, 64px);
    width: auto;
}

.lex-head__divider {
    width: 1px;
    height: clamp(24px, 3vw, 32px);
    background: var(--border-2);
}

.lex-head__title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(26px, 3.4vw, 36px);
    letter-spacing: -0.015em;
    line-height: 1;
    color: var(--ink);
    margin: 0;
}

/* ---------------------------------------------------------------------
   Sections
   --------------------------------------------------------------------- */
/* Spacing above comes from .lex-head's margin-bottom. */
.lexicon .section--filters .narrow {
    margin-top: var(--space-4);
}

.lexicon .section__foot {
    margin-top: var(--space-3);
}

.lexicon .link-action {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--fs-small);
    font-weight: 600;
    color: var(--text-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
}

.lexicon .link-action svg {
    width: 16px;
    height: 16px;
}

.lexicon .link-action:hover {
    color: var(--chcp-red);
    background: var(--chcp-red-50);
}

/* ---------------------------------------------------------------------
   Area chips
   --------------------------------------------------------------------- */
.area-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.area-chip {
    --area-accent: var(--ink);
    --area-soft: var(--bg-surface-2);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 8px 16px;
    font-weight: 600;
    font-size: var(--fs-small);
    color: var(--ink);
    background: var(--bg-surface);
    border: 1.5px solid var(--border-1);
    border-radius: var(--radius-pill);
}

.area-chip__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--area-accent);
    flex-shrink: 0;
}

.area-chip:hover {
    border-color: var(--area-accent);
    box-shadow: var(--shadow-sm);
}

.area-chip[aria-pressed='true'] {
    background: var(--area-soft);
    border-color: var(--area-accent);
    box-shadow: inset 0 0 0 1px var(--area-accent);
}

/* Hue by position, not area name, using the same WCAG-checked accents as
   the entry initials and tags. */
.area-chip-row .area-chip:nth-child(7n+1) { --area-accent: #a40058; --area-soft: var(--chcp-pink-50); }
.area-chip-row .area-chip:nth-child(7n+2) { --area-accent: #006b91; --area-soft: var(--chcp-blue-50); }
.area-chip-row .area-chip:nth-child(7n+3) { --area-accent: #006c68; --area-soft: var(--chcp-teal-50); }
.area-chip-row .area-chip:nth-child(7n+4) { --area-accent: #5b8a22; --area-soft: var(--chcp-green-50); }
.area-chip-row .area-chip:nth-child(7n+5) { --area-accent: #b85f00; --area-soft: var(--chcp-orange-50); }
.area-chip-row .area-chip:nth-child(7n+6) { --area-accent: #7a1f66; --area-soft: var(--chcp-purple-50); }
.area-chip-row .area-chip:nth-child(7n+7) { --area-accent: #97121a; --area-soft: var(--chcp-red-50); }

/* ---------------------------------------------------------------------
   Search
   --------------------------------------------------------------------- */
.narrow {
    display: grid;
    gap: var(--space-3);
}

.hunt {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-surface);
    border: 1.5px solid var(--border-2);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
}

.hunt:focus-within {
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(22, 29, 63, 0.12);
}

.hunt__icon {
    position: absolute;
    left: 16px;
    width: 18px;
    height: 18px;
    color: var(--text-3);
    pointer-events: none;
}

.hunt__input {
    width: 100%;
    border: none;
    background: transparent;
    padding: 13px 16px 13px 46px;
    font-family: var(--font-body);
    font-size: var(--fs-body);
    color: var(--ink);
    border-radius: var(--radius-md);
}

.hunt__input::placeholder {
    color: var(--text-4);
}

.hunt__input:focus {
    outline: none;
}

.hunt__kbd {
    position: absolute;
    right: 12px;
    display: inline-flex;
    gap: 2px;
    align-items: center;
}

/* ---------------------------------------------------------------------
   Entries
   --------------------------------------------------------------------- */
.section--entries {
    margin-top: var(--space-6);
    scroll-margin-top: var(--space-6);
}

.lexicon .entries-header {
    margin: 0 0 var(--space-3);
    min-height: 1.2em;
}

.lexicon .entries-count {
    font-size: var(--fs-small);
    color: var(--text-3);
}

.lexicon .entries-count strong {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--ink);
}

.lexicon .entries-list {
    background: var(--bg-surface);
    border: 1px solid var(--border-1);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.lexicon .entries-more {
    margin-top: var(--space-6);
}

.lexicon .entry {
    grid-template-columns: 60px 1fr;
    gap: var(--space-2) var(--space-5);
    padding: var(--space-6);
}

.lexicon .entry:hover {
    background: var(--bg-surface-2);
}

/* Colour comes from the nth-of-type rules in app.css. */
.lexicon .entry__letter {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 34px;
    line-height: 0.9;
    letter-spacing: -0.02em;
    opacity: 1;
}

.lexicon .entry__head {
    align-items: baseline;
    gap: var(--space-2) var(--space-3);
    margin-bottom: 0;
}

.lexicon .entry__term {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 21px;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.lexicon .entry__def {
    max-width: 72ch;
    margin-top: var(--space-2);
    font-size: var(--fs-body);
    line-height: var(--lh-loose);
    color: var(--text-2);
}

/* Terms that differ from another only by case, e.g. "PR" and "Pr". */
.lexicon .entry__caution {
    max-width: 72ch;
    margin-top: var(--space-2);
    padding: var(--space-2) var(--space-3);
    font-size: var(--fs-small);
    line-height: var(--lh-loose);
    color: var(--ink);
    background: var(--chcp-orange-50);
    border-left: 3px solid var(--chcp-orange);
    border-radius: var(--radius-sm);
}

.lexicon .entry__caution-term {
    font-family: var(--font-display);
}

.lexicon .entry__tags {
    margin-top: var(--space-3);
    padding-top: var(--space-3);
}

.lexicon .tag {
    padding: 2px 9px;
    font-size: 10px;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

/* ---------------------------------------------------------------------
   Empty / opening state
   --------------------------------------------------------------------- */
.lexicon .empty {
    background: var(--bg-surface);
    border: 1px solid var(--border-1);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: clamp(var(--space-8), 6vw, var(--space-10)) var(--space-6);
}

/* The .empty__icon loading rule lives in app.css. */
.lexicon .empty__icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--space-4);
    color: var(--primary);
    background: var(--primary-soft);
}

.lexicon .empty__icon svg {
    width: 28px;
    height: 28px;
}

.lexicon .empty__title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--fs-h3);
    color: var(--ink);
    margin-bottom: var(--space-2);
}

.lexicon .empty__msg {
    color: var(--text-3);
    max-width: 46ch;
    margin: 0 auto var(--space-5);
}

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */
@media (max-width: 720px) {
    .lexicon .entry {
        grid-template-columns: 36px 1fr;
        gap: var(--space-1) var(--space-3);
        padding: var(--space-5);
    }

    .lexicon .entry__letter {
        font-size: 28px;
    }
}

/* No physical keyboard: hide the Ctrl/⌘ K hint. */
@media (hover: none) and (pointer: coarse) {
    .hunt__kbd {
        display: none;
    }

    .hunt__input {
        padding-right: 16px;
    }
}

/* ---------------------------------------------------------------------
   Print
   --------------------------------------------------------------------- */
@media print {
    .narrow,
    .area-chip-row,
    .lex-head::after {
        display: none !important;
    }
}
