/* Characters page (characters.html). Builds on home-format.css and series.css
   for the navbar, inputs, pills, figure grid and page buttons. Same ledger look as
   home: character cards are unboxed like figure cards, and lists sit on hairlines. */

.ch-head {
    padding: 24px 0 0;
}

.ch-head h1 {
    margin: 0;
    font-size: clamp(30px, 3.4vw, 40px);
    font-weight: 650;
    line-height: 1.08;
    letter-spacing: -0.03em;
}

.ch-head p {
    max-width: 60ch;
    margin: 8px 0 0;
    font-size: 15px;
    line-height: 1.55;
    color: var(--ff-text-secondary);
}

.ch-head p a {
    color: var(--ff-text);
    text-underline-offset: 3px;
}

#ch-character .ch-head {
    padding-top: 0;
    padding-bottom: 24px;
    margin-bottom: 28px;
    border-bottom: 1px solid var(--ff-line);
}

/* ===== Search bar ===== */
.ch-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 200px 200px;
    gap: 8px;
    margin-top: 24px;
}

.ch-search {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 40px;
    padding: 0 12px;
    color: var(--ff-text-secondary);
    background: var(--ff-track);
    border: 1px solid var(--ff-card-border);
    border-radius: 6px;
}

.ch-search:hover {
    border-color: var(--ff-text-secondary);
}

.ch-search:focus-within {
    border-color: var(--ff-gold);
}

.ch-search input {
    flex: 1;
    min-width: 0;
    height: 100%;
    font: inherit;
    font-size: 14px;
    color: var(--ff-text);
    background: transparent;
    border: none;
    outline: none;
}

.ch-search input::placeholder {
    color: var(--ff-text-secondary);
}

.ch-toolbar .an-input,
.ch-toolbar .an-select {
    width: 100%;
    min-width: 0;
}

/* ===== Letters: one ruled strip of plain letters, the chosen one underlined in gold ===== */
.ch-letters {
    display: flex;
    flex-wrap: wrap;
    margin-top: 16px;
    border-top: 1px solid var(--ff-line);
    border-bottom: 1px solid var(--ff-line);
}

/* 36px wide on a desktop; 44px on phones (below) so each letter is easy to tap */
.ch-letter {
    position: relative;
    min-width: 36px;
    height: 40px;
    padding: 0 6px;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--ff-text-secondary);
    background: none;
    border: none;
    cursor: pointer;
}

.ch-letter:hover:not([aria-disabled="true"]) {
    color: var(--ff-text);
}

.ch-letter:focus-visible {
    outline: 2px solid var(--ff-gold);
    outline-offset: -2px;
}

/* No characters start with this letter (under the current search and series) */
.ch-letter[aria-disabled="true"] {
    opacity: 0.35;
    cursor: default;
}

.ch-letter.is-active {
    font-weight: 600;
    color: var(--ff-text);
}

.ch-letter.is-active::after {
    content: "";
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: -1px;
    height: 2px;
    background: var(--ff-gold);
}

/* ===== Trending: ruled rows with a round picture ===== */
.ch-trending-section[hidden] {
    display: none;
}

.ch-trending-section {
    margin-top: 48px;
}

.ch-trending {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0 32px;
}

.ch-trend {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    color: var(--ff-text);
    text-decoration: none;
    border-bottom: 1px solid var(--ff-line);
}

.ch-trend:hover .ch-trend__name {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.ch-trend:focus-visible {
    outline: 2px solid var(--ff-gold);
    outline-offset: 2px;
}

/* Person silhouette behind every character picture: it shows through when a character
   has no photo (the img hides itself on error) and is covered when the photo loads */
.ch-trend__avatar,
.ch-card__media {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237A7F88' stroke-width='1.2'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21v-1c0-4 4-6 8-6s8 2 8 6v1'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 40%;
}

.ch-trend__avatar {
    flex: 0 0 52px;
    height: 52px;
    overflow: hidden;
    background-color: var(--ff-photo);
    border-radius: 50%;
}

.ch-trend__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 15%;
    display: block;
}

.ch-trend__body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
}

.ch-trend__name {
    font-size: 15px;
    font-weight: 600;
}

.ch-trend__series {
    max-width: 100%;
    font-size: 13px;
    color: var(--ff-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Character cards: photo tile, then name, series and average, like figure cards ===== */
.ch-count {
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    color: var(--ff-text-secondary);
}

.ch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
    gap: 28px 20px;
}

.ch-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: var(--ff-text);
    text-decoration: none;
}

.ch-card:focus-visible {
    outline: 2px solid var(--ff-gold);
    outline-offset: 4px;
    border-radius: 4px;
}

.ch-card__media {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background-color: var(--ff-photo);
    border-radius: 4px;
}

.ch-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 15%;
    display: block;
}

/* Hairline outline on hover instead of a lift */
.ch-card__media::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px transparent;
    transition: box-shadow 0.15s ease;
    pointer-events: none;
}

.ch-card:hover .ch-card__media::after {
    box-shadow: inset 0 0 0 1px var(--ff-text-secondary);
}

.ch-card:hover .ch-card__name {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.ch-card__count {
    position: absolute;
    z-index: 1;
    top: 8px;
    left: 8px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--ff-text);
    background: var(--ff-pill-bg);
    border-radius: 3px;
}

.ch-card__body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
}

.ch-card__name {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
}

.ch-card__series {
    max-width: 100%;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--ff-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Smaller screens ===== */
@media (max-width: 767px) {
    .ch-search {
        height: 44px;
    }

    /* One sideways-scrolling strip instead of four rows of letters */
    .ch-letters {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .ch-letter {
        flex-shrink: 0;
        min-width: 44px;
        height: 44px;
    }
}

@media (max-width: 700px) {
    .ch-toolbar {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .ch-search {
        grid-column: 1 / -1;
    }
}

@media (max-width: 600px) {
    .ch-head {
        padding-top: 8px;
    }

    .ch-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 24px 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ch-card__media::after {
        transition: none;
    }
}

/* "12 new figures" is a count, not a price */
.ch-trend .an-pill {
    font-weight: 500;
    color: var(--ff-text-secondary);
}
