/* profiles.css: Reduced motion, loading skeletons, misc utilities, account info grid, user profile, pronouns, avatar select, players list, avatar crop. */
/* ===== REDUCED MOTION ===== */
body.reduced-motion * {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
    scroll-behavior: auto !important;
}
/* OS-level floor: honour prefers-reduced-motion even before an account exists /
   the pref is toggled (first-time + anonymous visitors, e.g. the landing hero and
   hatch-pop). The account toggle above still forces it on for signed-in users who
   opt in regardless of OS setting. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001s !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001s !important;
        scroll-behavior: auto !important;
    }
}

/* ===== LOADING & SKELETONS =====
   (Reduced-motion is handled by the global rules above: the shimmer/spinner
   animations and the progress-bar transition all collapse to ~instant there.) */

/* Global HTMX top progress bar: element in base.html, driven by htmx-init.js.
   Delay-gated in JS so frequent fast polls never flash it. */
#htmx-progress {
    position: fixed;
    top: 0; left: 0;
    z-index: 9998;
    width: 100%;
    height: 3px;
    background: var(--gradient-primary);
    transform: scaleX(0);
    transform-origin: 0 50%;
    opacity: 0;
    pointer-events: none;
}
#htmx-progress.is-loading {
    opacity: 1;
    transform: scaleX(0.9);            /* crawl toward ~90% while in flight */
    transition: transform 6s cubic-bezier(0.1, 0.7, 0.1, 1), opacity 0.1s;
}
#htmx-progress.is-done {
    opacity: 0;
    transform: scaleX(1);              /* snap to 100% then fade */
    transition: transform 0.15s ease, opacity 0.25s ease 0.05s;
}

/* Button in-flight spinner: htmx adds .htmx-request to the request initiator.
   Covers a .btn that is itself the initiator and a submit .btn inside an
   initiating form. Pollers (notif bell, image status) aren't .btn, so no spin. */
.btn.htmx-request,
form.htmx-request button[type="submit"].btn {
    pointer-events: none;
    opacity: 0.85;
}
.btn.htmx-request::after,
form.htmx-request button[type="submit"].btn::after {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Reusable skeleton shimmer for placeholder / loading content. The pet-image
   pending placeholder reuses the same sweep. */
.skeleton,
.pet-card-image-pending { position: relative; overflow: hidden; }
.skeleton::after,
.pet-card-image-pending::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent,
        color-mix(in srgb, var(--text-primary) 8%, transparent), transparent);
    animation: skeleton-shimmer 1.3s ease-in-out infinite;
}
@keyframes skeleton-shimmer { to { transform: translateX(100%); } }

/* Barracks: dim the roster while a filter/sort/pagination swap is in flight, so
   the change registers even though the old grid stays until the response lands. */
#barracks-controls:has(.htmx-request) ~ #pet-grid,
#pet-grid:has(.page-link.htmx-request) {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity var(--dur) var(--ease);
}

/* ===== MISC UTILITY ===== */
.btn-sm { padding: 6px 12px; min-height: 30px; font-size: 0.85em; }
.btn-tertiary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
@media (hover: hover) { .btn-tertiary:hover { background: var(--bg-subtle); color: var(--text-primary); } }
.text-muted { color: var(--text-muted); }

/* ===== ACCOUNT SETTINGS: INFO GRID ===== */
.info-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.info-row { display: flex; align-items: baseline; gap: 10px; }
.info-label {
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.66rem;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 120px;
}
.info-value { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.info-note { color: var(--text-muted); font-size: 12px; font-style: italic; }

/* ===== USER PROFILE ===== */
.profile-container {
    max-width: 960px;
    margin: 30px auto;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: var(--shadow-sm);
}

.profile-page { max-width: 960px; margin: 0 auto; }
.profile-header {
    display: flex;
    gap: 30px;
    align-items: center;
    flex-wrap: wrap;
}
.panel.profile-header--has-faction {
    border-left: 4px solid var(--faction-accent, var(--border-color));
}

/* Chained with .panel (not just the modifier class alone) so this reliably wins over
   .panel's own `background: var(--bg-surface)` shorthand. Frontier needs the higher-
   specificity variant too: its later `body.interface-frontier .panel` surface rule
   otherwise resets background-size/repeat/position, which tiles the vista art. */
.panel.profile-header--has-background,
body.interface-frontier .panel.profile-header--has-background {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* The vista art behind is user-chosen and arbitrary, so the name/meta/actions get their
   own near-opaque card rather than relying on a flat wash over the whole header: that
   guarantees readable text against any image, not just ones close to --bg-surface. */
.profile-header--has-background .profile-info {
    background: color-mix(in srgb, var(--bg-surface) 90%, transparent);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    box-shadow: var(--shadow-sm);
}

.profile-avatar { flex-shrink: 0; }

.profile-avatar img {
    width: 150px;
    height: 150px;
    border-radius: var(--radius-lg);
    object-fit: cover;
    border: 3px solid var(--border-color);
}

.default-avatar {
    width: 150px;
    height: 150px;
    border-radius: var(--radius-lg);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 60px;
    color: var(--text-inverse);
    font-weight: bold;
}

.profile-info { flex: 1 1 260px; min-width: 0; }
.profile-info h1 {
    margin: 6px 0 15px 0;
    font-family: var(--font-display);
    font-size: clamp(1.7rem, 1.2rem + 1.8vw, 2.1rem);
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.profile-meta { display: flex; flex-direction: column; gap: 8px; }
.meta-item { display: flex; gap: 10px; align-items: baseline; min-width: 0; }
.meta-label {
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.66rem;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 100px;
}
.meta-value { color: var(--text-primary); font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.profile-meta .state-chip { white-space: normal; overflow-wrap: anywhere; }

.profile-titled-companion {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    margin-top: 16px;
    padding: 10px 12px;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--color-primary) 55%, var(--border-color));
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--color-primary) 10%, var(--bg-surface)),
        var(--bg-subtle));
    color: inherit;
    text-decoration: none;
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--color-primary) 20%, transparent);
    transition: border-color .15s ease, background-color .15s ease, transform .15s ease;
}
.profile-titled-companion::after {
    content: '✦';
    position: absolute;
    right: 38px;
    top: 7px;
    color: var(--color-primary);
    font-size: .8rem;
    opacity: .35;
    pointer-events: none;
}
.profile-titled-companion:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; }
.profile-titled-companion__media {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 68px;
    height: 68px;
    flex: 0 0 auto;
    overflow: hidden;
    border: 2px solid var(--color-primary);
    border-radius: 50%;
    background: var(--bg-hover);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-primary) 12%, transparent);
    font-size: 1.8rem;
}
.profile-titled-companion__media img { width: 100%; height: 100%; object-fit: contain; }
.profile-titled-companion__copy { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.profile-titled-companion__label {
    color: var(--color-primary);
    font-family: var(--font-mono);
    font-size: .64rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.profile-titled-companion__name {
    overflow: hidden;
    color: var(--text-primary);
    font-family: var(--font-heading);
    font-size: 1rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.profile-titled-companion__rank { color: var(--text-secondary); font-size: .76rem; }
.profile-titled-companion__arrow { margin-left: auto; color: var(--color-primary); font-size: 1.15rem; }
@media (hover: hover) {
    .profile-titled-companion:hover {
        border-color: var(--color-primary);
        background: linear-gradient(135deg,
            color-mix(in srgb, var(--color-primary) 15%, var(--bg-surface)),
            var(--bg-hover));
        text-decoration: none;
        transform: translateY(-1px);
    }
}

/* A different companion holding the title is a real assignment, not an empty state.
   Keep the notice compact so the action below remains the visual focus. */
.pet-title-status {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 8px;
    margin: 12px 0 0;
    padding: 10px 12px;
    border: 1px solid var(--border-subtle);
    border-left: 3px solid var(--color-primary);
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font-size: .88rem;
}
.pet-title-status__label { color: var(--text-muted); font-family: var(--font-mono); font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.pet-title-status__holder { color: var(--text-primary); font-weight: 700; }
.pet-title-status__rank { color: var(--color-primary); font-family: var(--font-mono); font-size: .74rem; font-weight: 700; }
.pet-title-status--unassigned { border-left-color: var(--border-color); }

.profile-pronouns { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.pronoun-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
}

.profile-header-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.profile-showcase-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.profile-showcase-card { min-width: 0; }
.profile-level-readout { display: flex; align-items: center; gap: 12px; }
.profile-level-readout__value {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--bg-hover);
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
}
.profile-level-readout strong, .profile-level-readout small { display: block; }
.profile-level-readout small { margin-top: 4px; color: var(--text-muted); }
.profile-stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.profile-stat-grid div { padding: 10px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-subtle); }
.profile-stat-grid dt { color: var(--text-muted); font-size: .72rem; }
.profile-stat-grid dd { margin: 3px 0 0; color: var(--text-primary); font-size: 1.2rem; font-weight: 700; }
.profile-crew-showcase .panel__header { align-items: center; }
.profile-crew-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.profile-crew-card { display: flex; min-width: 0; flex-direction: column; gap: 5px; padding: 10px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-subtle); color: inherit; text-decoration: none; }
.profile-crew-card:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
@media (hover: hover) { .profile-crew-card:hover { border-color: var(--color-primary); text-decoration: none; } }
.profile-crew-card__media { display: flex; align-items: center; justify-content: center; aspect-ratio: 1; overflow: hidden; border-radius: var(--radius-sm); background: var(--bg-hover); font-size: 2rem; }
.profile-crew-card__media img { width: 100%; height: 100%; object-fit: contain; }
.profile-crew-card__name { overflow: hidden; color: var(--text-primary); font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.profile-crew-card__meta { color: var(--text-muted); font-size: .76rem; line-height: 1.35; }
.profile-crew-showcase__actions { display: flex; gap: 8px; flex-wrap: wrap; }
/* The featured-crew editor: a small reorderable strip (see reorderList in
   alpine-components.js) plus an add-select, both scoped under the swap target
   #profile-featured-crew but reading the "editing" toggle from an outer x-data the
   swap never replaces, same split petManage/_pet_detail_tabs.html already uses. */
.featured-crew-edit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-bottom: 10px; }
.featured-crew-edit-card { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-subtle); }
.featured-crew-edit-card__head { display: flex; align-items: center; gap: 6px; }
.featured-crew-edit-card__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; color: var(--text-primary); font-size: .85rem; }
.featured-crew-edit-card__meta { color: var(--text-muted); font-size: .72rem; }
@media (pointer: coarse) {
    .featured-crew-edit-card .reorder-nudge__btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }
}
/* Profile Wishlist panel: mirrors .profile-crew-grid/.profile-crew-card (read-only
   view) and .featured-crew-edit-grid/-card (owner editor) directly above, same
   "reuse the tokens, new names for a different panel" approach as the rest of this
   page's sections. */
.profile-wishlist .panel__header { align-items: center; }
.profile-wishlist__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.wishlist-edit-list { display: flex; flex-direction: column; gap: 6px; margin: 0 0 10px; padding: 0; list-style: none; }
.wishlist-edit-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-subtle); }
.wishlist-edit-row__art { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex: 0 0 auto; font-size: 1.2rem; }
.wishlist-edit-row__art img { width: 100%; height: 100%; object-fit: contain; }
.wishlist-edit-row__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; color: var(--text-primary); font-size: .85rem; }
.profile-wishlist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.profile-wishlist-card { display: flex; min-width: 0; flex-direction: column; align-items: center; gap: 6px; padding: 10px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-subtle); text-align: center; }
.profile-wishlist-card__media { display: flex; align-items: center; justify-content: center; width: 100%; aspect-ratio: 1; overflow: hidden; border-radius: var(--radius-sm); background: var(--bg-hover); font-size: 2rem; }
.profile-wishlist-card__media img { width: 100%; height: 100%; object-fit: contain; }
.profile-wishlist-card__name { overflow: hidden; width: 100%; color: var(--text-primary); font-weight: 700; font-size: .85rem; text-overflow: ellipsis; white-space: nowrap; }
.wishlist-gift-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border: 1px solid var(--color-primary);
    border-radius: 999px;
    background: var(--bg-hover);
    color: var(--color-primary);
    font-size: .74rem;
    font-weight: 700;
    text-decoration: none;
}
.wishlist-gift-pill:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
@media (hover: hover) { .wishlist-gift-pill:hover { background: var(--color-primary); color: var(--text-inverse); text-decoration: none; } }
.wishlist-gift-pill--muted { border-color: var(--border-subtle); color: var(--text-muted); cursor: default; pointer-events: none; }
.bio-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.bio-header h2 { margin: 0; font-family: var(--font-heading); font-size: 1.25rem; color: var(--text-primary); }
.bio-content { line-height: 1.6; color: var(--text-secondary); }
.bio-editor form { max-width: none; }
.bio-editor textarea {
    width: 100%;
    max-width: none;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    background: var(--bg-surface);
    color: var(--text-primary);
}
.bio-editor-actions { margin-top: 10px; display: flex; gap: 10px; }
.form-hint {
    display: block;
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 0.78rem;
}
@media (max-width: 768px) {
    .profile-showcase-grid { grid-template-columns: 1fr; }
    .profile-crew-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    .profile-crew-card { padding: 7px; }
    .profile-crew-card__meta { font-size: .68rem; }
    .profile-titled-companion { margin-top: 14px; }
    .profile-wishlist-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    .profile-wishlist-card { padding: 7px; }
}

/* ===== PRONOUN SELECTOR (account settings) ===== */
.pronoun-tag-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.pronoun-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    border: 2px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}
.pronoun-tag input[type="checkbox"] { display: none; }
@media (hover: hover) { .pronoun-tag:hover { border-color: var(--color-primary); color: var(--text-primary); } }
.pronoun-tag:has(input:checked) {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: #fff;
}

/* ===== AVATAR SELECT ===== */
.avatar-select-container { max-width: 1200px; margin: 0 auto; }
.avatar-select-header { margin-bottom: 30px; }
.avatar-select-header h1 { font-family: var(--font-display); font-size: clamp(1.7rem, 1.2rem + 1.8vw, 2.1rem); letter-spacing: -0.02em; color: var(--text-primary); margin-bottom: 10px; }
.avatar-select-header .subtitle { color: var(--text-secondary); margin: 0; }

.avatar-filter-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
.avatar-filter-form { display: flex; gap: 15px; align-items: flex-end; flex-wrap: wrap; max-width: none; }
.avatar-filter-form .filter-group { display: flex; flex-direction: column; gap: 6px; }
.avatar-filter-form label { font-family: var(--font-mono); font-size: 0.66rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.avatar-filter-form input,
.avatar-filter-form select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
    color: var(--text-primary);
    font-size: 0.95rem;
    min-width: 150px;
}
.filter-actions { display: flex; gap: 8px; }
.results-info { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 15px; }

.avatar-pet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 30px; }
.avatar-pet-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.pet-image-wrapper {
    width: 100%;
    height: 200px;
    background: var(--bg-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.pet-thumbnail { width: 100%; height: 100%; object-fit: contain; }
.avatar-pet-card .pet-info { padding: 15px; }
.avatar-pet-card .pet-info h3 { margin: 0 0 5px 0; font-family: var(--font-heading); color: var(--text-primary); font-size: 1rem; font-weight: 600; }
.avatar-pet-card .species { margin: 0 0 3px 0; color: var(--text-secondary); font-size: 0.8rem; text-transform: capitalize; }
.avatar-pet-card .level-info { margin: 0 0 12px 0; color: var(--text-secondary); font-size: 0.8rem; }
.avatar-pet-card .btn { width: 100%; text-align: center; padding: 8px; }

.pagination-container { display: flex; justify-content: center; margin-top: 30px; margin-bottom: 30px; }
.pagination { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.page-link,
.page-number {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 13px;
}
@media (hover: hover) {
    .page-link:hover,
    .page-number:hover { background: var(--bg-subtle); border-color: var(--color-primary); color: var(--color-primary); }
}
.page-number.active { background: var(--color-primary); color: var(--text-inverse); border-color: var(--color-primary); }
/* Staff/mod list pagination reuses the same link chrome as the main .pagination
   system so every paginator across the site looks the same (login activity,
   celery history, mod lookup). */
.staff-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}
.staff-pagination a {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
}
@media (hover: hover) { .staff-pagination a:hover { background: var(--bg-subtle); border-color: var(--color-primary); color: var(--color-primary); text-decoration: none; } }

/* Touch tap targets: the WCAG/UX floor is 44px, but only on touch pointers; 
   mouse users keep the denser controls. Covers the small interactive elements
   that fall under 44px at their base size. */
@media (pointer: coarse) {
    .page-link, .page-number, .staff-pagination a,
    .pet-group-tab, .pet-group-tab-menu-btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
    .pet-group-tab-menu-btn { min-width: 44px; }

    /* Crew and squad controls use deliberately compact mouse styles below. Keep their
       touch path explicit here, after those component rules, so the 44px floor cannot be
       overridden by .btn-xs or the 22px reorder nudges. */
    #barracks-filters input[type="search"],
    #barracks-filters select,
    #barracks-filters .btn,
    .pet-card__foot .btn,
    .btn-sm,
    .btn-xs { min-height: 44px; }
}

/* Text-entry floor on touch: iOS Safari zooms the viewport whenever a focused field
   computes under 16px, and it does NOT zoom back out. Tapping the barracks search box
   therefore left the roster you were filtering off-screen. Measured offenders were the
   barracks toolbar (0.95rem search + 6 selects), marketplace and notification filters,
   the trade/gift/delivery note textareas (13px), .input-sm selects, and the incursion
   room-lock slot pickers.

   `!important` is deliberate and matches this file's existing use of it for rules that
   must not lose (x-cloak, reduced-motion, drawer hiding): the floor has to beat every
   class-scoped component rule, including ones not written yet, and a component author
   should not be able to reintroduce the zoom by being more specific. Checkboxes, radios
   and buttons are excluded: they take no text entry, so they never trigger the zoom. */
@media (pointer: coarse) {
    input[type="text"], input[type="password"], input[type="email"],
    input[type="number"], input[type="search"], input[type="tel"],
    input[type="url"], input[type="date"], input[type="datetime-local"],
    input:not([type]), select, textarea { font-size: 16px !important; }
}
.page-numbers { display: flex; gap: 4px; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}
.empty-state p { color: var(--text-secondary); margin-bottom: 20px; }

@media (max-width: 1024px) { .avatar-pet-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) {
    .avatar-pet-grid { grid-template-columns: 1fr; }
    .avatar-filter-form { flex-direction: column; }
    .avatar-filter-form .filter-group { width: 100%; }
    .avatar-filter-form input,
    .avatar-filter-form select { width: 100%; }
    .filter-actions { width: 100%; }
    .filter-actions .btn { flex: 1; }
}

/* ===== PLAYERS LIST (Comms Array) ===== */
.players-page {
    width: 100%;
    max-width: 1040px;
    min-width: 0;
    margin: 0 auto;
}
.players-page .avatar-filter-panel { width: 100%; box-sizing: border-box; }
.players-page .avatar-filter-form { width: 100%; }
.players-page .avatar-filter-form .filter-group { width: min(100%, 420px); }
.players-page .avatar-filter-form input { width: 100%; min-width: 0; box-sizing: border-box; }
.players-page #player-results { min-width: 0; }
.player-table {
    display: table;
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    table-layout: fixed;
    overflow: visible;
}
.player-table th:nth-child(1),
.player-table td:nth-child(1) { width: 44%; }
.player-table th:nth-child(2),
.player-table td:nth-child(2) { width: 18%; }
.player-table th:nth-child(3),
.player-table td:nth-child(3) { width: 20%; }
.player-table th:nth-child(4),
.player-table td:nth-child(4) { width: 18%; }
.player-table td:first-child,
.player-table th:first-child { padding-right: 16px; }
.player-table td:first-child { padding-right: 16px; white-space: normal; }
.player-row-user {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    max-width: 100%;
    color: var(--text-primary);
    font-weight: 600;
    text-decoration: none;
}
@media (hover: hover) { .player-row-user:hover { color: var(--color-primary); text-decoration: none; } }
.player-avatar-thumb {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.player-avatar-thumb.default-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary);
    color: var(--text-inverse);
    font-size: 22px;
    font-weight: bold;
}
.online-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

@media (max-width: 1024px) {
    .player-table,
    .player-table thead,
    .player-table tbody,
    .player-table tr,
    .player-table td { display: block; }
    .player-table { max-width: none; border: 0; overflow: visible; }
    .player-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
    .player-table tbody { display: grid; gap: 10px; }
    .player-table tr {
        padding: 12px;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        background: var(--bg-surface);
    }
    .player-table td {
        display: grid;
        grid-template-columns: minmax(6.2rem, 0.35fr) minmax(0, 1fr);
        align-items: center;
        gap: 10px;
        padding: 7px 0;
        border: 0;
        white-space: normal;
    }
    .player-table td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-family: var(--font-mono);
        font-size: 0.68rem;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
    }
    .player-table td:first-child { padding-right: 0; }
    .player-row-user { min-width: 0; gap: 9px; }
    .player-row-user .player-avatar-thumb { width: 42px; height: 42px; }
}
.online-dot.is-online { background: var(--color-success); }
.online-dot.is-offline { background: var(--text-secondary); opacity: 0.5; }
.status-text { vertical-align: middle; }
.status-text.is-online { color: var(--color-success); font-weight: 600; }
.status-text.is-offline { color: var(--text-secondary); }
.status-text.is-hidden { color: var(--text-muted); font-style: italic; }

/* ===== AVATAR CROP ===== */
.avatar-crop-container { padding: 20px; max-width: 1400px; margin: 0 auto; }
.avatar-crop-container h1 { font-family: var(--font-display); font-size: clamp(1.7rem, 1.2rem + 1.8vw, 2.1rem); letter-spacing: -0.02em; color: var(--text-primary); margin-bottom: 10px; }
.avatar-crop-container .subtitle { color: var(--text-secondary); margin-bottom: 30px; }

.crop-layout { display: grid; grid-template-columns: 1fr 350px; gap: 30px; margin-top: 20px; }
.crop-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 15px;
    box-shadow: var(--shadow-sm);
}
.image-container {
    width: 100%;
    max-height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-subtle);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.cropper-image { max-width: 100%; max-height: 600px; display: block; }

.preview-panel { display: flex; flex-direction: column; gap: 20px; }
.preview-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}
.preview-section h3 { color: var(--text-muted); margin: 0 0 15px 0; font-family: var(--font-mono); font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.avatar-preview {
    width: 200px;
    height: 200px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    overflow: hidden;
}
.avatar-preview canvas { width: 200px; height: 200px; display: block; }
.preview-hint { color: var(--text-secondary); font-size: 0.78rem; text-align: center; margin: 0; }

.controls-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.controls-section .btn { width: 100%; text-align: center; padding: 10px 15px; font-size: 0.95rem; }

.status-message { padding: 12px 15px; border-radius: var(--radius-sm); font-size: 0.85rem; text-align: center; display: none; }
.status-message.info { background: var(--color-info-bg); color: var(--color-info-text); display: block; }
.status-message.success { background: var(--color-success-bg); color: var(--color-success-text); display: block; }
.status-message.error { background: var(--color-error-bg); color: var(--color-error-text); display: block; }

.cropper-canvas, .cropper-drag-box { background: var(--bg-subtle); }
.cropper-crop-box { border: 2px dashed var(--border-color); }
.cropper-face { background: rgba(0, 0, 0, 0.1); }
.cropper-line { background: var(--color-info-bg); }
.cropper-point { background: var(--color-info-bg); box-shadow: 0 0 4px rgba(0, 0, 0, 0.3); }

@media (max-width: 768px) {
    .crop-layout { grid-template-columns: 1fr; gap: 20px; }
    .image-container { max-height: 400px; }
    .cropper-image { max-height: 400px; }
    .preview-panel { order: -1; }
    .controls-section .btn { width: 100%; }
}


/* Titles panel: earned list and the own-profile picker. */
.profile-title { margin: 2px 0 8px; font-weight: 600; color: var(--text-muted); }
.profile-title-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.profile-title-list li { display: flex; flex-direction: column; gap: 2px; }
.profile-title-projects { font-size: 0.9rem; }
.profile-title-picker { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.profile-title-picker select { min-width: 0; max-width: 100%; }
@media (pointer: coarse) {
    .profile-title-picker select, .profile-title-picker .btn { min-height: 44px; font-size: 16px; }
}
