/* =============================================
   AniVerse shared components
   Progress rail, status dots, favourite corner, title card, page header,
   notices, segmented control, search field, labelled selects, states, skeletons.
   ============================================= */

/* --- Buttons (additions to base.css) --- */
.av-btn--ghost {
    border-color: transparent;
    color: var(--av-text-2);
}

.av-btn--ghost:hover {
    border-color: transparent;
}

.av-btn.is-active {
    background: var(--av-surface-2);
    border-color: var(--av-text-1);
}

.cyber-button .av-icon,
.cyber-button-small .av-icon,
.av-btn .av-icon {
    margin-left: -2px;
}

/* --- Page header --- */
.av-page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--av-space-4) var(--av-space-5);
}

.av-page-heading {
    min-width: 0;
}

.av-page-title {
    font-family: var(--av-font-serif);
    font-size: clamp(2.5rem, 2rem + 2.5vw, 3.5rem);
    font-weight: 400;
    line-height: 1.05;
    letter-spacing: -0.015em;
}

.av-page-subtitle {
    margin-top: 6px;
    color: var(--av-text-2);
    font-size: 14px;
}

.av-page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--av-space-2);
}

.av-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--av-space-4);
}

/* --- Notice (active special filter, informational) --- */
.av-notice {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--av-space-2) var(--av-space-3);
    padding: 10px 14px;
    border: 1px solid var(--av-line-strong);
    border-radius: var(--av-radius-control);
    color: var(--av-text-2);
    font-size: var(--av-fs-small);
}

.av-notice-text {
    flex: 1 1 auto;
}

.av-notice-action {
    color: var(--av-text-1);
    font-weight: 500;
}

/* --- Status dot (6 px) --- */
.av-status-dot {
    width: 6px;
    height: 6px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--av-status-planned);
}

.av-status-dot--active { background: var(--av-status-active); }
.av-status-dot--completed { background: var(--av-status-completed); }
.av-status-dot--onhold { background: var(--av-status-onhold); }
.av-status-dot--dropped { background: var(--av-status-dropped); }
.av-status-dot--repeat { background: var(--av-status-repeat); }
.av-status-dot--planned { background: var(--av-status-planned); }

/* --- Progression rail --- */
.av-rail {
    --av-rail-fill: var(--av-text-1);
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--av-rail-gap, 1px);
    width: 100%;
    height: var(--av-rail-h, 2px);
}

.av-rail--onhold { --av-rail-fill: var(--av-text-2); }

.av-rail--dropped {
    --av-rail-fill: var(--av-text-3);
    --av-track: rgba(237, 235, 230, 0.06);
}

.av-rail-seg {
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    background: var(--av-track);
}

.av-rail-seg.is-on {
    background: var(--av-rail-fill);
}

.av-rail-track {
    position: relative;
    flex: 1 1 auto;
    height: 100%;
    background: var(--av-track);
}

.av-rail-fill {
    display: block;
    height: 100%;
    background: var(--av-rail-fill);
    transition: width var(--av-dur-base) var(--av-ease-out);
}

.av-rail-grow {
    flex: 1 1 auto;
}

.av-rail-open {
    flex: 0 0 22px;
    height: 0;
    margin-left: 3px;
    border-top: var(--av-rail-h, 2px) dotted var(--av-track);
}

.av-rail-open.av-rail-grow {
    flex: 1 1 auto;
    margin-left: 0;
}

.av-rail-tick {
    position: absolute;
    right: 0;
    top: -3px;
    width: 2px;
    height: calc(var(--av-rail-h, 2px) + 6px);
    background: var(--av-text-1);
}

/* --- Favourite corner (vermilion folded corner, page-colour edge) --- */
.av-favorite-corner {
    position: absolute;
    top: 0;
    right: 0;
    width: 26px;
    height: 26px;
    background: var(--av-bg);
    clip-path: polygon(0 0, 100% 0, 100% 100%);
    pointer-events: none;
}

.av-favorite-corner::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 23px;
    height: 23px;
    background: var(--av-seal);
    clip-path: polygon(0 0, 100% 0, 100% 100%);
}

.av-favorite-corner--sm {
    width: 18px;
    height: 18px;
}

.av-favorite-corner--sm::after {
    width: 16px;
    height: 16px;
}

/* --- Title card --- */
.av-card {
    display: flex;
    flex-direction: column;
    gap: var(--av-space-2);
    min-width: 0;
    padding: 0;
    background: none;
    border: 0;
    border-radius: var(--av-radius-cover);
    color: var(--av-text-1);
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.av-card:hover {
    color: var(--av-text-1);
}

.av-card-cover {
    position: relative;
    display: block;
    aspect-ratio: 2 / 3;
    overflow: hidden;
    border-radius: var(--av-radius-cover);
    background: var(--av-surface-2);
    transition: transform var(--av-dur-base) var(--av-ease-out);
}

.av-card-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.av-card-hairline {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
    transition: box-shadow var(--av-dur-base) var(--av-ease-out);
    pointer-events: none;
}

.av-card:hover .av-card-cover {
    transform: translateY(-2px);
}

.av-card:hover .av-card-hairline {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.av-card:focus-visible {
    outline: none;
}

.av-card:focus-visible .av-card-cover,
.av-card.is-selected .av-card-cover {
    outline: 2px solid var(--av-text-1);
    outline-offset: 3px;
}

.av-card-nocover {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--av-surface-1);
}

.av-card-nocover-glyph {
    opacity: 0.14;
}

.av-card-nocover-type {
    font-family: var(--av-font-mono);
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--av-text-3);
}

.av-card-check {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--av-text-1);
    border-radius: 5px;
    background: rgba(12, 12, 14, 0.72);
    color: var(--av-on-paper);
}

.av-card.is-selected .av-card-check {
    background: var(--av-text-1);
}

.av-card-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    min-height: 34px;
    font-size: var(--av-fs-small);
    font-weight: 500;
    line-height: 17px;
}

.av-card-status {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    font-size: 12px;
    color: var(--av-text-2);
}

.av-card-status-label {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.av-card-progress {
    font-family: var(--av-font-mono);
    font-variant-numeric: tabular-nums;
    font-size: var(--av-fs-label);
    white-space: nowrap;
}

.av-card-meta {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
    font-family: var(--av-font-mono);
    font-variant-numeric: tabular-nums;
    font-size: var(--av-fs-label);
    color: var(--av-text-3);
}

.av-card-meta-type {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.av-card-score {
    color: var(--av-text-1);
    font-size: 12px;
}

/* --- Segmented control --- */
.av-segmented {
    display: flex;
    gap: 2px;
    max-width: 100%;
    padding: 3px;
    overflow-x: auto;
    border: 1px solid rgba(237, 235, 230, 0.12);
    border-radius: 8px;
    scrollbar-width: none;
}

.av-segmented::-webkit-scrollbar {
    display: none;
}

.av-segmented-item {
    flex-shrink: 0;
    height: 30px;
    padding: 0 12px;
    background: transparent;
    border: 0;
    border-radius: 5px;
    color: var(--av-text-2);
    font-size: var(--av-fs-small);
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--av-dur-fast) var(--av-ease-out), color var(--av-dur-fast) var(--av-ease-out);
}

.av-segmented-item:hover {
    color: var(--av-text-1);
}

.av-segmented-item.is-active {
    background: var(--av-surface-3);
    color: var(--av-text-1);
    font-weight: 500;
}

.av-segmented-item:focus-visible {
    outline-offset: -2px;
}

/* --- Search field --- */
.av-search {
    display: flex;
    align-items: center;
    gap: var(--av-space-2);
    width: 280px;
    max-width: 100%;
    height: var(--av-control-h);
    padding: 0 12px;
    border: 1px solid rgba(237, 235, 230, 0.12);
    border-radius: var(--av-radius-control);
    color: var(--av-text-3);
    transition: border-color var(--av-dur-fast) var(--av-ease-out);
}

.av-search:hover {
    border-color: var(--av-line-hover);
}

.av-search:focus-within {
    border-color: var(--av-text-2);
}

.av-search:has(input:focus-visible) {
    outline: var(--av-focus-ring);
    outline-offset: 2px;
}

.av-search input {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    min-height: 0;
    padding: 0;
    background: transparent;
    border: 0;
    color: var(--av-text-1);
    font-size: var(--av-fs-small);
    -webkit-appearance: none;
    appearance: none;
}

.av-search input:focus,
.av-search input:focus-visible {
    outline: none;
}

.av-search input::-webkit-search-cancel-button {
    filter: grayscale(1) brightness(1.6);
    cursor: pointer;
}

/* --- Labelled select ("Status · All") --- */
.av-select {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: var(--av-space-2);
    height: var(--av-control-h-sm);
    padding-left: 10px;
    border: 1px solid var(--av-line-strong);
    border-radius: var(--av-radius-control);
    color: var(--av-text-1);
    font-size: var(--av-fs-small);
    transition: border-color var(--av-dur-fast) var(--av-ease-out), background-color var(--av-dur-fast) var(--av-ease-out);
}

.av-select:hover {
    background: var(--av-surface-2);
    border-color: var(--av-line-hover);
}

.av-select:has(select:focus-visible) {
    outline: var(--av-focus-ring);
    outline-offset: 2px;
}

.av-select-label {
    color: var(--av-text-3);
    white-space: nowrap;
}

.av-select select {
    height: calc(var(--av-control-h-sm) - 2px);
    min-height: 0;
    padding: 0 28px 0 0;
    background-color: transparent;
    background-position: right 8px center;
    border: 0;
    color: var(--av-text-1);
    font-size: var(--av-fs-small);
}

.av-select select:focus,
.av-select select:focus-visible,
.av-select select:hover {
    outline: none;
    border: 0;
}

.av-select--compact {
    padding-left: 0;
}

.av-select--compact select {
    padding-left: 10px;
}

/* --- Empty / error states --- */
.av-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--av-space-3);
    padding: var(--av-space-8) var(--av-space-5);
    border: 1px solid var(--av-line);
    border-radius: var(--av-radius-widget);
    text-align: center;
}

.av-state-icon {
    color: var(--av-text-3);
}

.av-state-icon--error {
    color: var(--av-danger);
}

.av-state-title {
    font-family: var(--av-font-serif);
    font-size: var(--av-fs-display-m);
    font-weight: 400;
    line-height: 1.15;
}

.av-state-text {
    max-width: 46ch;
    color: var(--av-text-2);
    font-size: 14px;
}

.av-state .cyber-button,
.av-state .av-btn {
    margin-top: var(--av-space-2);
}

/* --- Skeletons --- */
.av-card-skeleton {
    display: flex;
    flex-direction: column;
    gap: var(--av-space-2);
}

.av-skel {
    display: block;
    background: var(--av-surface-1);
    border-radius: 2px;
}

.av-skel-cover {
    aspect-ratio: 2 / 3;
    border-radius: var(--av-radius-cover);
    box-shadow: inset 0 0 0 1px var(--av-line);
}

.av-skel-rail {
    height: 2px;
    background: var(--av-surface-2);
}

.av-skel-line {
    height: 10px;
    width: 80%;
    background: var(--av-surface-2);
}

.av-skel-line--short {
    width: 50%;
    background: var(--av-surface-1);
}

/* --- Chips (genres, tags shown read-only) --- */
.av-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.av-chip {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 10px;
    border: 1px solid rgba(237, 235, 230, 0.14);
    border-radius: var(--av-radius-pill);
    color: var(--av-text-2);
    font-size: 12px;
}
