/* Characters page (characters.html). Builds on home-format.css and series.css
   for the navbar, inputs, pills, figure grid and page buttons. */

.ch-head h1 {
    margin: 0;
    font-size: 40px;
    font-weight: 800;
}

.ch-head p {
    margin: 6px 0 0;
    color: var(--ff-text-secondary);
}

.ch-head p a {
    color: var(--ff-gold);
    text-decoration: none;
}

.ch-head p a:hover {
    text-decoration: underline;
}

#ch-character .ch-head {
    margin-bottom: 24px;
}

/* ===== Search bar ===== */
.ch-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 190px 190px;
    gap: 12px;
    margin-top: 24px;
    padding: 16px;
    background: var(--ff-card);
    border-radius: 16px;
}

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

.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 ===== */
.ch-letters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 16px;
}

/* 44px so each letter is easy to tap */
.ch-letter {
    min-width: 44px;
    height: 44px;
    padding: 0 8px;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    color: var(--ff-text);
    background: var(--ff-track);
    border: 1px solid var(--ff-card-border);
    border-radius: 8px;
    cursor: pointer;
}

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

.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.4;
    cursor: default;
}

.ch-letter.is-active {
    color: #1a1a1a;
    background: var(--ff-gold);
    border-color: var(--ff-gold);
}

/* ===== Trending ===== */
.ch-trending-section[hidden] {
    display: none;
}

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

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

.ch-trend {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    color: var(--ff-text);
    text-decoration: none;
    background: var(--ff-card);
    border: 1px solid var(--ff-card-border);
    border-radius: 14px;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.ch-trend:hover,
.ch-trend:focus-visible {
    border-color: var(--ff-gold);
    transform: translateY(-2px);
    outline: none;
}

/* 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='%23D7DCEA' stroke-opacity='0.55' 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: 45%;
}

.ch-trend__avatar {
    flex: 0 0 64px;
    height: 64px;
    overflow: hidden;
    background-color: var(--ff-track);
    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: 3px;
    min-width: 0;
}

.ch-trend__name {
    font-family: "Montserrat", sans-serif;
    font-size: 16px;
    font-weight: 700;
}

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

/* ===== Character cards ===== */
.ch-count {
    font-size: 14px;
    color: var(--ff-text-secondary);
}

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

.ch-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: var(--ff-text);
    text-decoration: none;
    background: var(--ff-card);
    border: 1px solid var(--ff-card-border);
    border-radius: 12px;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.ch-card:hover,
.ch-card:focus-visible {
    transform: translateY(-4px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
    border-color: var(--ff-gold);
    outline: none;
}

.ch-card__media {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.22);
}

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

.ch-card:hover .ch-card__media img {
    transform: scale(1.06);
}

.ch-card__count {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 700;
    background: rgba(16, 17, 20, 0.78);
    border-radius: 999px;
}

.ch-card__body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 10px 12px 12px;
}

.ch-card__name {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
}

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

/* ===== Smaller screens ===== */
@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 h1 {
        font-size: 32px;
    }

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

@media (prefers-reduced-motion: reduce) {
    .ch-card,
    .ch-card__media img,
    .ch-trend {
        transition: none;
    }

    .ch-card:hover .ch-card__media img {
        transform: none;
    }
}
