/* ==========================================================================
   Team / staff grid block
   Flip cards: front = headshot + name/title/socials, back = bio + links + posts.
   Theme-aware (uses site CSS variables), responsive, no-fluff.
   ========================================================================== */

.team-grid-section {
    --team-accent: var(--accent-gold, var(--accent-color, #f5b335));
    --team-on-accent: var(--btn-primary-text, var(--heading-color));
    width: 100%;
}

.team-grid {
    display: grid;
    grid-template-columns: repeat(var(--team-cols, 4), minmax(0, 1fr));
    gap: 1.5rem;
}

.team-grid-cols-2 { --team-cols: 2; }
.team-grid-cols-3 { --team-cols: 3; }
.team-grid-cols-4 { --team-cols: 4; }
.team-grid-cols-5 { --team-cols: 5; }

@media (max-width: 1100px) {
    .team-grid-cols-4,
    .team-grid-cols-5 { --team-cols: 3; }
}

@media (max-width: 820px) {
    .team-grid { gap: 1rem; }
    .team-grid-cols-3,
    .team-grid-cols-4,
    .team-grid-cols-5 { --team-cols: 2; }
}

@media (max-width: 480px) {
    .team-grid-cols-2,
    .team-grid-cols-3,
    .team-grid-cols-4,
    .team-grid-cols-5 { --team-cols: 1; }
}

/* ----- Card shell / flip ------------------------------------------------- */

.team-card {
    perspective: 1400px;
}

.team-card-flippable {
    cursor: pointer;
}

.team-card-flippable:focus-visible {
    outline: 2px solid var(--team-accent);
    outline-offset: 4px;
    border-radius: 18px;
}

.team-card-flip {
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
    height: 100%;
}

.team-card-flip.is-flipped {
    transform: rotateY(180deg);
}

.team-card-face {
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.25));
    border-radius: 16px;
    background: var(--surface-bg, #fff);
    overflow: hidden;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

/* Front sits in normal flow and defines the card height. */
.team-card-front {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.team-card:not(.team-card-noflip):hover .team-card-front {
    box-shadow: 0 14px 30px color-mix(in srgb, var(--heading-color) 12%, transparent);
    border-color: color-mix(in srgb, var(--team-accent) 55%, var(--border-color));
    transform: translateY(-3px);
}

/* Back overlays the same footprint, rotated. */
.team-card-back {
    position: absolute;
    inset: 0;
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ----- Front: photo ----------------------------------------------------- */

.team-card-photo {
    position: relative;
    aspect-ratio: 4 / 5;
    background: linear-gradient(150deg,
        color-mix(in srgb, var(--team-accent) 18%, transparent),
        color-mix(in srgb, var(--team-accent) 4%, transparent));
    overflow: hidden;
}

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

.team-card-photo-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: color-mix(in srgb, var(--team-accent) 80%, var(--heading-color));
    background: color-mix(in srgb, var(--team-accent) 12%, var(--surface-bg));
}

.team-card-draft-badge {
    position: absolute;
    top: 0.6rem;
    left: 0.6rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.78);
    color: #fff;
}

/* ----- Front: body ------------------------------------------------------ */

.team-card-body {
    padding: 0.85rem 1rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1 1 auto;
}

.team-card-name {
    font-size: 1.12rem;
    font-weight: 700;
    line-height: 1.25;
    margin: 0;
    color: var(--heading-color);
}

.team-card-name a {
    color: inherit;
    text-decoration: none;
}

.team-card-name a:hover {
    color: var(--team-accent);
}

.team-card-title {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.35;
}

.team-card-hint {
    margin: 0.65rem 0 0;
    font-size: 0.78rem;
    font-weight: 600;
    color: color-mix(in srgb, var(--team-accent) 70%, var(--text-secondary));
}

.team-card-socials {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.55rem;
}

.team-card-social {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.3));
    color: var(--text-secondary, #64748b);
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.team-card-social svg {
    width: 15px;
    height: 15px;
}

.team-card-social:hover {
    background: var(--team-accent);
    border-color: var(--team-accent);
    color: var(--team-on-accent);
    transform: translateY(-1px);
}

/* ----- Back ------------------------------------------------------------- */

.team-card-back-head {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.85rem 1rem 0.65rem;
    border-bottom: 1px solid var(--border-color);
    flex: none;
}

.team-card-back-head .team-card-name {
    font-size: 1.05rem;
}

.team-card-back-scroll {
    padding: 0.85rem 1rem;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--team-accent) 45%, var(--border-color)) transparent;
}

.team-card-back-scroll::-webkit-scrollbar {
    width: 6px;
}

.team-card-back-scroll::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--team-accent) 45%, var(--border-color));
    border-radius: 999px;
}

.team-card-bio {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.team-card-bio p { margin: 0 0 0.5rem; }
.team-card-bio p:last-child { margin-bottom: 0; }

.team-card-links {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.team-card-link {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.45rem 0.6rem;
    border-radius: 9px;
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.25));
    color: var(--text-primary, #334155);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.team-card-link:hover {
    border-color: var(--team-accent);
    background: color-mix(in srgb, var(--team-accent) 8%, transparent);
    color: var(--heading-color, #0f172a);
}

.team-card-link-icon {
    display: inline-flex;
    color: var(--team-accent);
    flex: 0 0 auto;
}

.team-card-link-icon svg { width: 16px; height: 16px; }

.team-card-link-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ----- Recent posts (always visible when present) -------------------------
   When a card has posts, bio + links share the top half of the back face and
   posts fill the bottom half — each band scrolls independently. */

.team-card-back:has(.team-card-posts) .team-card-back-scroll,
.team-card-back:has(.team-card-posts) .team-card-posts {
    flex: 1 1 0;
    min-height: 0;
}

.team-card-back:has(.team-card-posts) .team-card-back-scroll {
    border-bottom: 1px solid var(--border-color);
}

.team-card-posts {
    display: flex;
    flex-direction: column;
    margin: 0 1rem 0.35rem;
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.25));
    border-radius: 9px;
    overflow: hidden;
    min-height: 0;
}

.team-card-posts-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.65rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--heading-color, #0f172a);
    background: color-mix(in srgb, var(--team-accent) 6%, transparent);
    flex: 0 0 auto;
    border-bottom: 1px solid var(--border-color, rgba(148, 163, 184, 0.2));
}

.team-card-posts-count {
    margin-left: auto;
    margin-right: 0.4rem;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--team-accent);
    color: var(--team-on-accent);
}

.team-card-back-footer {
    flex: none;
    margin-top: auto;
    padding: 0.65rem 1rem 0.85rem;
    border-top: 1px solid var(--border-color);
    background: color-mix(in srgb, var(--team-accent) 5%, var(--surface-bg));
}

.team-card-back-footer .team-card-socials {
    margin-top: 0;
    justify-content: center;
}

.team-card-posts-list {
    list-style: none;
    margin: 0;
    padding: 0.25rem;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--team-accent) 45%, var(--border-color)) transparent;
}

.team-card-posts-list::-webkit-scrollbar {
    width: 5px;
}

.team-card-posts-list::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--team-accent) 45%, var(--border-color));
    border-radius: 999px;
}

.team-card-posts-list a {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.4rem 0.5rem;
    border-radius: 7px;
    text-decoration: none;
    color: var(--text-primary, #334155);
}

.team-card-posts-list a:hover {
    background: color-mix(in srgb, var(--team-accent) 8%, transparent);
}

.team-card-post-title {
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--heading-color, #0f172a);
}

.team-card-post-date {
    font-size: 0.7rem;
    color: var(--text-secondary, #94a3b8);
}

/* ----- Empty state (studio only) ---------------------------------------- */

.team-grid-empty {
    border: 1px dashed var(--border-color, rgba(148, 163, 184, 0.5));
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    color: var(--text-secondary, #64748b);
    background: color-mix(in srgb, var(--team-accent) 4%, transparent);
}

/* Reduced motion: skip the 3D flip animation. */
@media (prefers-reduced-motion: reduce) {
    .team-card-flip { transition: none; }
}

/* ----- Admin: /admin/employees ------------------------------------------ */

.emp-thumb {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    overflow: hidden;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-bg, #e2e8f0);
    color: var(--text-secondary, #64748b);
    font-weight: 700;
    font-size: 0.85rem;
}

.emp-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.emp-link-row {
    display: grid;
    grid-template-columns: 9rem 1fr 1.4fr auto;
    gap: 0.4rem;
    align-items: center;
}

@media (max-width: 575px) {
    .emp-link-row {
        grid-template-columns: 1fr 1fr;
    }
}

.admin-subsection > summary {
    cursor: pointer;
    list-style: revert;
}

/* Team admin: independently scrollable columns that fill the viewport height.
   The exact height is set per-column by bhisFitHeight() in team-grid.js so the
   page itself never scrolls; these are the styling/fallback bits. */
.emp-admin-lead {
    max-width: 46rem;
}

.emp-admin-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-color: color-mix(in srgb, var(--border-color, #d4d4d8) 85%, transparent);
    box-shadow: none;
    background: var(--surface-bg, #fff);
}

.emp-admin-list-card {
    overflow: hidden;
}

.emp-admin-list-head {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem 1rem 0.75rem;
    border-bottom: 1px solid color-mix(in srgb, var(--border-color, #d4d4d8) 70%, transparent);
    background: color-mix(in srgb, var(--surface-bg, #fff) 92%, var(--page-bg, #f4f4f5));
}

.emp-admin-list-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted, #71717a);
}

.emp-admin-dot {
    opacity: 0.55;
}

.emp-admin-search {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.emp-admin-search .debounced-search-icon,
.emp-admin-search-icon {
    position: absolute;
    left: 0.7rem;
    width: 1rem;
    height: 1rem;
    color: var(--text-muted, #71717a);
    pointer-events: none;
    z-index: 1;
}

.emp-admin-search-input {
    padding-left: 2.15rem;
    padding-right: 3.5rem;
    border-radius: 0.55rem;
    width: 100%;
}

.emp-admin-search .debounced-search-clear,
.emp-admin-search-clear {
    position: absolute;
    right: 0.35rem;
    text-decoration: none;
    z-index: 1;
}

.emp-admin-search-status {
    font-size: 0.85rem;
    color: var(--text-muted, #71717a);
}

.emp-admin-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem 0.85rem;
    border-bottom: none;
    margin: 0;
}

.emp-admin-tabs .nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 0.35rem 0.05rem 0.5rem;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-muted, #71717a);
    background: transparent;
}

.emp-admin-tabs .nav-link:hover {
    color: var(--heading-color, #18181b);
}

.emp-admin-tabs .nav-link.active {
    color: var(--heading-color, #18181b);
    border-bottom-color: var(--accent-gold, #f5b335);
}

.emp-admin-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    background: color-mix(in srgb, var(--accent-gold, #f5b335) 14%, var(--surface-bg, #fff));
    color: color-mix(in srgb, var(--accent-gold, #f5b335) 75%, var(--heading-color, #18181b));
}

.emp-admin-tabs .nav-link.active .emp-admin-tab-count {
    background: var(--accent-gold, #f5b335);
    color: var(--btn-primary-text, #1a1a1a);
}

.emp-admin-list-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.emp-admin-empty {
    padding: 1.5rem 1rem;
    color: var(--text-muted, #71717a);
    font-size: 0.92rem;
}

.emp-admin-list .list-group-item {
    border-color: color-mix(in srgb, var(--border-color, #d4d4d8) 55%, transparent);
}

.emp-admin-row-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
}

.emp-admin-row-copy {
    flex: 1 1 auto;
    min-width: 0;
}

.emp-admin-row-name {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    font-weight: 600;
    color: var(--heading-color, #18181b);
}

.emp-admin-row-title {
    font-size: 0.85rem;
    color: var(--text-muted, #71717a);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.emp-admin-row-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
}

@media (min-width: 992px) {
    .emp-admin-row {
        align-items: stretch;
    }

    .emp-admin-col {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .emp-admin-col > .emp-admin-card {
        flex: 1 1 auto;
    }

    .emp-admin-col > .card:not(.emp-admin-list-card) {
        overflow-y: auto;
        scrollbar-gutter: stable;
    }
}
