/*
 * Player profile.
 *
 * Follows the tour-player-card reference: a dark hero holding the identity,
 * a two-row figure table and the section tabs, with the portrait bled off the
 * right edge, and the sections beneath it on the same dark canvas.
 *
 * Colours are the board's, not the reference's navy — the site navbar is red
 * and the board is already dark, so reusing those tokens makes the pages read
 * as one site instead of three designs.
 */

/*
 * Dark, matching the match card and the board. The hero was already dark and
 * the sections beneath it were white panels; carrying the canvas down the page
 * makes the profile one surface rather than two.
 *
 * Same values as match-card.css — the card declares its own copies because it
 * is also used on /biewbad/matches, where .pf is not present.
 */
.pf {
    --canvas: #0b0d10;
    --band: #e02424;
    --accent: #ff5c5c;
    /* Lifted clear of the canvas — see the note in match-card.css; the two
     * files have to agree or the cards would sit on a different surface from
     * the sections around them. */
    --surface: #1e2632;
    --raised: #283143;
    --ink: #e8edf5;
    --muted: #9aa4b5;
    --faint: #8894a6;
    --line: #38445a;
    --rule: #2a3446;
    --wash: #283143;
    --win: #35c97e;
    --loss: #f5827b;
    --gold: #f5c542;
    --info: #5aa9e6;

    /* The navbar is fixed-top and 60px tall. This has to be re-stated in every
     * media query below — a padding shorthand there would silently reset it. */
    --nav-clearance: 60px;

    padding-top: var(--nav-clearance);
    color: var(--ink);
}

/* ---------- Hero ---------- */

.pf-hero {
    position: relative;
    overflow: hidden;
    background: linear-gradient(115deg, #0b0d10 0%, #12161d 46%, #1b2530 100%);
    color: #fff;
}

/* Sits over the portrait so the name stays legible on a light photo. */
.pf-hero__wash {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(11, 13, 16, 0.97) 0%, rgba(11, 13, 16, 0.86) 46%, rgba(11, 13, 16, 0) 100%);
    z-index: 1;
}

.pf-hero__portrait {
    position: absolute;
    right: 0;
    bottom: 0;
    height: 100%;
    width: auto;
    object-fit: cover;
    object-position: top center;
    z-index: 0;
}

.pf-hero__inner {
    position: relative;
    z-index: 2;
    max-width: 1180px;
    margin: 0 auto;
    padding: 28px 20px 0;
}

.pf-hero__name {
    margin: 0;
    font-size: 38px;
    font-weight: 800;
    line-height: 1.1;
    text-transform: uppercase;
    color: #fff;
}

.pf-hero__meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0 20px;
}

.pf-hero__alias {
    font-size: 15px;
    font-weight: 300;
    color: #c9d2de;
}

.pf-level {
    display: inline-block;
    padding: 3px 11px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.14);
    font-size: 13px;
    font-weight: 700;
    color: #e8edf5;
}

/* ---------- Figure table ---------- */

.pf-stats {
    max-width: 780px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.04);
}

.pf-stats__row {
    display: flex;
    align-items: stretch;
}

.pf-stats__row + .pf-stats__row {
    border-top: 1px solid rgba(255, 255, 255, 0.16);
}

/* The row label, in its own tinted column as on the reference card. It holds
 * the season picker, so the row is labelled by the season it is showing. */
.pf-stats__key {
    flex: 0 0 148px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
    padding: 9px 10px;
    border-right: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.06);
    font-size: 13px;
    font-weight: 800;
}

.pf-season__label {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--faint);
}

.pf-season {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 6px;
    background: rgba(11, 13, 16, 0.55);
    font-size: 13px;
    font-weight: 800;
    color: #fff;
    cursor: pointer;
}

.pf-season:focus-visible { outline: 2px solid var(--band); outline-offset: 1px; }

/* The list itself renders in the OS palette, so it needs readable colours of
 * its own rather than inheriting the white-on-dark of the closed control. */
.pf-season option { background: #12161d; color: #fff; }

.pf-figure {
    flex: 1 1 0;
    min-width: 0;
    padding: 11px 8px;
    text-align: center;
}

.pf-figure__value {
    display: block;
    font-size: 21px;
    font-weight: 800;
    line-height: 1.2;
    color: #fff;
}

.pf-figure__label {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    font-weight: 600;
    color: var(--faint);
}

/* ---------- Tabs ---------- */

.pf-tabs {
    display: flex;
    gap: 4px;
    margin-top: 22px;
    overflow-x: auto;
    scrollbar-width: none;
}

.pf-tabs::-webkit-scrollbar { display: none; }

.pf-tab {
    padding: 11px 18px;
    border-radius: 8px 8px 0 0;
    background: rgba(255, 255, 255, 0.07);
    font-size: 14px;
    font-weight: 700;
    color: #cbd4e0;
    text-decoration: none;
    white-space: nowrap;
}

.pf-tab:hover { background: rgba(255, 255, 255, 0.13); color: #fff; }

.pf-tab.is-active {
    background: var(--surface);
    color: var(--accent);
}

/* ---------- Sections ---------- */

.pf-section {
    max-width: 1180px;
    margin: 0 auto;
    padding: 30px 20px 6px;
    /* Tab links jump here; keep the heading clear of the fixed navbar. */
    scroll-margin-top: calc(var(--nav-clearance) + 12px);
}

.pf-section__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.pf-section__title {
    margin: 0 0 16px;
    font-size: 21px;
    font-weight: 800;
    color: var(--ink);
}

.pf-section__head .pf-section__title { margin-bottom: 0; }

.pf-sort {
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    font-size: 13px;
    color: var(--ink);
}

/* ---------- Personal details ---------- */

.pf-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 10px 24px;
}

.pf-detail {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 16px;
    border-radius: 8px;
    background: var(--wash);
}

.pf-detail__key { font-size: 14px; color: var(--muted); }
.pf-detail__value { font-size: 14px; font-weight: 700; color: var(--ink); }

/* ---------- Chart ---------- */

.pf-chart {
    position: relative;
    height: 320px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    /* Chart.js sizes the canvas in pixels. If it is ever left holding a width
     * from a wider viewport, this stops it widening the whole document. */
    overflow: hidden;
}

/* ---------- Partner and opponent cards ---------- */

/*
 * One row that scrolls sideways rather than a wrapping grid — fifteen cards
 * wrapped ran to several screens of vertical scroll on a phone.
 *
 * The scroller is the only thing on the page allowed to overflow sideways;
 * .pf-section constrains it, so the document itself never scrolls across.
 */
.pf-people {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    padding-bottom: 10px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}

.pf-person {
    /* Fixed basis: cards must not shrink to fit, or the row would never
     * overflow and there would be nothing to scroll. */
    flex: 0 0 196px;
    scroll-snap-align: start;

    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    text-align: center;
}

/* A visible but quiet track, so the row reads as scrollable. */
.pf-people::-webkit-scrollbar { height: 8px; }
.pf-people::-webkit-scrollbar-track { background: var(--wash); border-radius: 999px; }
.pf-people::-webkit-scrollbar-thumb { background: #2b333f; border-radius: 999px; }
.pf-people::-webkit-scrollbar-thumb:hover { background: #3a4351; }

.pf-people { scrollbar-width: thin; scrollbar-color: #2b333f var(--wash); }

.pf-person__avatar {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--wash);
}

.pf-person__name {
    margin-top: 9px;
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
    text-decoration: none;
}

.pf-person__name:hover { color: var(--band); }

/* The level sits inline before the name, as it did on the old card. */
.pf-person__level {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--wash);
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
}

.pf-person__total {
    margin-top: 6px;
    font-size: 13px;
    color: var(--muted);
}

.pf-person__total strong {
    font-size: 19px;
    font-weight: 800;
    color: var(--ink);
}

/* Win / draw / loss, each figure over its own word. */
.pf-person__record {
    display: flex;
    gap: 4px;
    width: 100%;
    margin-top: 9px;
}

.pf-tally {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    padding: 5px 2px;
    border-radius: 6px;
    background: var(--wash);
    font-size: 10.5px;
    color: var(--muted);
}

.pf-tally b { font-size: 14px; font-weight: 800; }

.pf-tally--won b  { color: var(--win); }
.pf-tally--draw b { color: var(--gold); }
.pf-tally--lost b { color: var(--loss); }

.pf-person__rate {
    margin-top: 9px;
    line-height: 1.35;
}

.pf-person__rate-label {
    display: block;
    font-size: 10.5px;
    color: var(--muted);
}

.pf-person__rate-value {
    display: block;
    font-size: 16px;
    font-weight: 800;
}

/* Above, below and exactly even, as the old card coloured them. */
.pf-person__rate-value.is-up    { color: var(--win); }
.pf-person__rate-value.is-down  { color: var(--loss); }
.pf-person__rate-value.is-level { color: var(--info); }

.pf-person__more {
    width: 100%;
    margin-top: 11px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    font-size: 12.5px;
    font-weight: 700;
    color: var(--ink);
    cursor: pointer;
}

.pf-person__more:hover {
    border-color: var(--band);
    background: var(--band);
    color: #fff;
}

/* ---------- Pairing detail modal ---------- */

/*
 * Bootstrap's .modal-content paints its own white sheet, so it has to be
 * overridden rather than left to inherit — otherwise the dark --ink title
 * lands on white at barely 1.2:1.
 *
 * The modal is a child of .pf here, so it reads the tokens directly; the score
 * dialog in match-card.css is appended to <body> and has to redeclare them.
 */
.pf-pair .modal-content {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
}

.pf-pair .modal-header { border-bottom: 1px solid var(--line); }
.pf-pair .modal-title { font-weight: 800; color: var(--ink); }

/* Bootstrap's close glyph is a dark SVG; invert it to show on the panel. */
.pf-pair .btn-close { filter: invert(1) grayscale(1) brightness(1.8); }

.pf-pair__head {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.pf-pair__face { text-align: center; min-width: 0; }

.pf-pair__avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--wash);
}

.pf-pair__name {
    display: block;
    margin-top: 7px;
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
    text-decoration: none;
}

.pf-pair__name:hover { color: var(--band); }

.pf-pair__vs {
    padding: 5px 13px;
    border-radius: 999px;
    background: var(--wash);
    font-size: 13px;
    font-weight: 800;
    color: var(--muted);
    white-space: nowrap;
}

/* Average strength of each side across the matches they shared. */
.pf-pair__strength {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 16px 0 12px;
}

.pf-pair__avg {
    padding: 11px 10px;
    border-radius: 9px;
    background: var(--wash);
    text-align: center;
}

.pf-pair__avg-label { display: block; font-size: 11.5px; color: var(--muted); }

.pf-pair__avg-value {
    display: block;
    margin-top: 2px;
    font-size: 20px;
    font-weight: 800;
}

.pf-pair__avg-value.is-up   { color: var(--win); }
.pf-pair__avg-value.is-down { color: var(--loss); }

.pf-pair__avg-sub { display: block; font-size: 11.5px; color: var(--muted); }

.pf-pair__note {
    margin: 0 0 16px;
    padding: 11px 13px;
    border-radius: 9px;
    background: rgba(33, 114, 184, 0.07);
    font-size: 13px;
    line-height: 1.6;
    color: #bcd8ef;
    text-align: center;
}

.pf-pair__note-sub { display: block; font-size: 11.5px; color: var(--muted); }

.pf-pair__count {
    margin-bottom: 9px;
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
}

/* The match card lives in match-card.css — shared with /biewbad/matches. */


/* ---------- Pagination ---------- */

.pf-pagination {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 18px 0 40px;
}

.pf-page {
    min-width: 36px;
    padding: 7px 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
    cursor: pointer;
}

.pf-page:hover { border-color: var(--accent); }

.pf-page.is-active {
    border-color: var(--band);
    background: var(--band);
    color: #fff;
}

/* ---------- Empty and error states ---------- */

.pf-empty {
    max-width: 1180px;
    margin: 0 auto;
    padding: 64px 20px;
    text-align: center;
}

.pf-empty__title { margin: 0 0 8px; font-size: 26px; font-weight: 800; }
.pf-empty__note { margin: 0 0 18px; color: var(--muted); }

.pf-empty__link {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 8px;
    background: var(--band);
    font-weight: 700;
    color: #fff;
    text-decoration: none;
}

/* .pf-loading and .pf-none are styled in match-card.css, which both pages load. */

/* ---------- Narrow ---------- */

@media (max-width: 900px) {
    /* Re-state the clearance: a padding shorthand here would drop it. */
    .pf { padding-top: var(--nav-clearance); }

    .pf-hero__name { font-size: 28px; }

    /* The portrait would crowd the figures long before it runs out of room. */
    .pf-hero__portrait { opacity: 0.22; }

    .pf-hero__wash {
        background: linear-gradient(90deg, rgba(11, 13, 16, 0.96) 0%, rgba(11, 13, 16, 0.82) 100%);
    }

    /* Still has to hold the season picker, so it narrows less than the rest. */
    .pf-stats__key { flex-basis: 126px; font-size: 12px; }
    .pf-season { font-size: 12px; }
    .pf-figure__value { font-size: 17px; }
    .pf-figure__label { font-size: 10px; }
}

@media (max-width: 620px) {
    .pf { padding-top: var(--nav-clearance); }

    .pf-hero__inner { padding: 20px 14px 0; }
    .pf-section { padding: 24px 14px 6px; }

    /* Five figures will not fit a phone: the label column goes full width and
     * the figures wrap beneath it in a grid. */
    .pf-stats__row { flex-wrap: wrap; }

    /* Full width, and the picker sits beside its label rather than under it. */
    .pf-stats__key {
        flex: 1 0 100%;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        padding: 7px 12px;
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.16);
    }

    .pf-season { width: auto; flex: 1 1 auto; max-width: 220px; }

    .pf-figure { flex: 1 0 33.333%; }

    /* The match card carries its own narrow rules in match-card.css. */

    /* Sized as a share of the viewport rather than a fixed width, so two cards
     * plus a clear slice of the third always land on screen — that slice is
     * what tells you the row scrolls. A fixed 158px left only a 7px sliver on
     * a 375px phone, which reads as a rendering fault rather than an
     * invitation to swipe. */
    .pf-person { flex-basis: 42%; padding: 14px 8px 12px; }
    .pf-person__rate-label { font-size: 10px; }
    .pf-tally { font-size: 10px; }

    /* Portraits and the divider stack once there is no room for three across. */
    .pf-pair__head { grid-template-columns: 1fr; gap: 6px; }
    .pf-pair__vs { justify-self: center; }
    .pf-pair__strength { grid-template-columns: 1fr; }
}
