/* ==========================================================================
   Kind switch (templates/components/kind_switch.html)

   The split bar, the career legend and the All / Couple / Solo / ... segments
   that scope a profile to one participant kind. Colours are the --kind-*
   tokens (design-system/tokens.css), shared with the tag-<kind> badges.

   Layout rule (owner, 2026-09-24): wrap before slide. Segments wrap onto more
   rows and never scroll sideways. Sizing follows the component's own width
   (container queries), because the profile column is narrow on a laptop and
   wide on a phone in landscape.
   ========================================================================== */

.kind-switch {
    container-type: inline-size;
    container-name: kind-switch;
    display: grid;
    gap: 10px;
    margin: 0 0 14px;
    padding: 12px 14px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: var(--ds-radius, 14px);
    background: var(--surface, #ffffff);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

/* ── Split bar + career legend ── */
.kind-switch__overview {
    display: grid;
    gap: 6px;
    /* A 4K-wide column would stretch the bar into a line with no meaning. */
    max-width: 960px;
}

.kind-switch__bar {
    display: block;
    width: 100%;
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--hover, #f1f5f9);
}

.kind-switch__part {
    transition: opacity 0.15s ease;
}

.kind-switch__part.is-dimmed {
    opacity: 0.28;
}

.kind-switch__bar a:hover .kind-switch__part,
.kind-switch__bar a:focus-visible .kind-switch__part {
    opacity: 1;
    filter: brightness(1.08);
}

.kind-switch__bar a:focus-visible {
    outline: none;
}

.kind-switch__bar a:focus-visible .kind-switch__part {
    stroke: var(--text, #0f172a);
    stroke-width: 1.5;
    vector-effect: non-scaling-stroke;
}

.kind-switch__career {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    margin: 0;
    color: var(--text-secondary, #475569);
    font-size: 0.8rem;
    line-height: 1.35;
}

.kind-switch__era {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.kind-switch__years {
    color: var(--text-muted, #5f6f85);
    font-variant-numeric: tabular-nums;
}

/* ── Colour dot (legend + segments) ── */
.kind-switch__dot {
    flex: 0 0 auto;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--kind-unclassified);
}

/* ── Segments ── */
.kind-switch__segments,
.kind-switch__mods {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.kind-switch__seg,
.kind-switch__mod {
    --kind-tone: var(--primary, #5b5eee);
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 40px;
    padding: 6px 12px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 999px;
    background: var(--surface, #ffffff);
    color: var(--text-secondary, #475569);
    font-size: 0.86rem;
    font-weight: 650;
    line-height: 1.15;
    text-decoration: none;
    white-space: nowrap;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.kind-switch__seg:hover,
.kind-switch__mod:hover {
    border-color: var(--kind-tone);
    background: color-mix(in srgb, var(--kind-tone) 8%, var(--surface, #ffffff));
    color: var(--text, #0f172a);
}

.kind-switch__seg:focus-visible,
.kind-switch__mod:focus-visible {
    outline: 2px solid var(--kind-tone);
    outline-offset: 2px;
}

.kind-switch__seg.is-active,
.kind-switch__mod.is-active {
    border-color: var(--kind-tone);
    background: color-mix(in srgb, var(--kind-tone) 15%, var(--surface, #ffffff));
    box-shadow: inset 0 0 0 1px var(--kind-tone);
    color: var(--text, #0f172a);
}

/* "All" is the neutral segment: when active it is the solid primary pill the
   rest of the profile uses for the current tab. */
.kind-switch__seg--all.is-active {
    border-color: var(--primary, #5b5eee);
    background: var(--primary, #5b5eee);
    box-shadow: none;
    /* The dark theme's primary is a light blue that needs dark text. */
    color: var(--primary-contrast, #ffffff);
}

.kind-switch__label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.kind-switch__icon {
    font-size: 1rem;
    line-height: 1;
}

.kind-switch__role {
    font-weight: 500;
    color: var(--text-muted, #5f6f85);
}

.kind-switch__count {
    padding: 1px 8px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.07);
    font-size: 0.74rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.kind-switch__seg--all.is-active .kind-switch__count {
    background: rgba(0, 0, 0, 0.22);
}

.kind-switch__out,
.kind-switch__clear {
    font-size: 1rem;
    line-height: 1;
    opacity: 0.7;
}

/* Pro-Am leaves the page for its own profile: a dashed edge says "elsewhere". */
.kind-switch__seg--external {
    border-style: dashed;
}

.kind-switch__mods {
    padding-top: 8px;
    border-top: 1px dashed var(--border, #e2e8f0);
}

.kind-switch__mod {
    --kind-tone: var(--kind-para);
    min-height: 34px;
    padding: 4px 10px;
    font-size: 0.8rem;
}

.kind-switch__mod[data-modifier="equality"] {
    --kind-tone: var(--kind-equality);
}

/* ── Kind tones: one rule per kind, used by dot, bar part and segment ── */
.kind-dot--couple, .kind-fill--couple { background: var(--kind-couple); fill: var(--kind-couple); }
.kind-dot--solo, .kind-fill--solo { background: var(--kind-solo); fill: var(--kind-solo); }
.kind-dot--duo, .kind-fill--duo { background: var(--kind-duo); fill: var(--kind-duo); }
.kind-dot--synchro, .kind-fill--synchro { background: var(--kind-synchro); fill: var(--kind-synchro); }
.kind-dot--showdance, .kind-fill--showdance { background: var(--kind-showdance); fill: var(--kind-showdance); }
.kind-dot--formation, .kind-fill--formation { background: var(--kind-formation); fill: var(--kind-formation); }
.kind-dot--team_match, .kind-fill--team_match { background: var(--kind-team-match); fill: var(--kind-team-match); }
.kind-dot--pro_am, .kind-fill--pro_am { background: var(--kind-pro-am); fill: var(--kind-pro-am); }
.kind-dot--unclassified, .kind-fill--unclassified { background: var(--kind-unclassified); fill: var(--kind-unclassified); }
.kind-dot--para { background: var(--kind-para); }
.kind-dot--equality { background: var(--kind-equality); }

.kind-switch__seg--couple { --kind-tone: var(--kind-couple); }
.kind-switch__seg--solo { --kind-tone: var(--kind-solo); }
.kind-switch__seg--duo { --kind-tone: var(--kind-duo); }
.kind-switch__seg--synchro { --kind-tone: var(--kind-synchro); }
.kind-switch__seg--showdance { --kind-tone: var(--kind-showdance); }
.kind-switch__seg--formation { --kind-tone: var(--kind-formation); }
.kind-switch__seg--team_match { --kind-tone: var(--kind-team-match); }
.kind-switch__seg--pro_am { --kind-tone: var(--kind-pro-am); }

/* ── Dark theme ── */
[data-theme="dark"] .kind-switch {
    box-shadow: none;
}

[data-theme="dark"] .kind-switch__bar {
    background: rgba(148, 163, 184, 0.18);
}

[data-theme="dark"] .kind-switch__count {
    background: rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .kind-switch__seg--all.is-active .kind-switch__count {
    background: rgba(0, 0, 0, 0.3);
}

/* ── Touch: 44 px targets ── */
@media (pointer: coarse) {
    .kind-switch__seg {
        min-height: 44px;
    }

    .kind-switch__mod {
        min-height: 40px;
    }
}

/* ── Narrow column (phones): the segments become a row of equal tiles, the
   name on top and its count below, so three kinds still fit side by side at
   360 px. The colour dot goes (the legend above carries it); the emoji stays. ── */
@container kind-switch (max-width: 460px) {
    .kind-switch__segments {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
    }

    .kind-switch__seg {
        flex-direction: column;
        justify-content: center;
        gap: 3px;
        min-height: 54px;
        padding: 7px 6px;
        border-radius: 14px;
        font-size: 0.84rem;
        text-align: center;
        white-space: normal;
    }

    .kind-switch__seg .kind-switch__dot,
    .kind-switch__out,
    .kind-switch__role {
        display: none;
    }

    .kind-switch__label {
        max-width: 100%;
        gap: 4px;
    }

    .kind-switch__name {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .kind-switch__career {
        font-size: 0.76rem;
    }
}

/* ── Wide column (1440p, 4K): a little more air, same proportions ── */
@container kind-switch (min-width: 1100px) {
    .kind-switch__bar {
        height: 14px;
    }

    .kind-switch__seg {
        min-height: 42px;
        padding: 7px 16px;
        font-size: 0.92rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .kind-switch__part,
    .kind-switch__seg,
    .kind-switch__mod {
        transition: none;
    }
}

@media (forced-colors: active) {
    .kind-switch__seg.is-active,
    .kind-switch__mod.is-active {
        border-width: 2px;
    }
}

/* The active kind / modifier named beside the results heading. */
.kind-heading-tag {
    margin-left: 6px;
    vertical-align: middle;
    font-size: 0.78rem;
}

/* The solo career listed beside the partners on the Overview: same row as a
   partner, marked with the solo tone so it reads as "a career of its own". */
.partner-item--solo {
    margin-bottom: 12px;
    border-left: 4px solid var(--kind-solo);
}

/* On the athlete card: names the kind the key numbers below describe. */
.pc-scope {
    margin: 12px 0 -6px;
    line-height: 1;
}

.pc-scope .tag {
    font-size: 0.72rem;
    font-weight: 700;
}

/* ==========================================================================
   Standalone kind segments (templates/components/kind_segments.html)

   The same row of segments on a page that is not a dancer profile (rankings,
   statistics). The wrapper is the container the narrow-column rules above
   measure, so the tiles, the wrapping and the 44 px touch targets are the
   profile's.
   ========================================================================== */
.kind-segments {
    container-type: inline-size;
    container-name: kind-switch;
    margin: 0 0 14px;
}

/* ==========================================================================
   Kinds on this site (templates/dashboard/_stats_kinds.html)

   A stacked bar of the competitions by participant kind, then one row per kind
   with its numbers. Widths are SVG attributes (no inline style); colours are the
   --kind-* tokens. Rows are a fixed-layout table, so a 360 px phone wraps the
   headings instead of scrolling sideways.
   ========================================================================== */
.kind-share {
    container-type: inline-size;
    container-name: kind-share;
    display: grid;
    gap: 12px;
    margin: 0 0 25px;
    padding: 14px 16px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: var(--ds-radius, 14px);
    background: var(--surface, #ffffff);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.kind-share__hint {
    margin: 0;
    color: var(--text-secondary, #475569);
    font-size: 0.82rem;
    line-height: 1.4;
}

.kind-share__bar {
    display: block;
    width: 100%;
    max-width: 960px;
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--hover, #f1f5f9);
}

.kind-share__table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 0.86rem;
    font-variant-numeric: tabular-nums;
}

.kind-share__table caption {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
}

.kind-share__table th,
.kind-share__table td {
    padding: 7px 6px;
    border-bottom: 1px solid var(--border, #e2e8f0);
    text-align: right;
    overflow-wrap: anywhere;
}

.kind-share__table thead th {
    color: var(--text-muted, #5f6f85);
    font-size: 0.74rem;
    font-weight: 650;
    vertical-align: bottom;
    /* A column name is one word in every locale: never split it mid-word
       ("Tanecnik-u" on a 360 px phone); the numbers below set the width. */
    overflow-wrap: normal;
    hyphens: none;
}

.kind-share__table tbody th {
    width: 38%;
    text-align: left;
    font-weight: 650;
    color: var(--text, #0f172a);
}

.kind-share__table thead th:first-child {
    width: 38%;
    text-align: left;
}

.kind-share__table tr.kind-share__mod th,
.kind-share__table tr.kind-share__mod td {
    color: var(--text-secondary, #475569);
}

.kind-share__name {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.kind-share__name a {
    color: inherit;
    text-decoration: none;
}

.kind-share__name a:hover,
.kind-share__name a:focus-visible {
    text-decoration: underline;
}

.kind-share__none {
    color: var(--text-muted, #5f6f85);
}

[data-theme="dark"] .kind-share {
    box-shadow: none;
}

[data-theme="dark"] .kind-share__bar {
    background: rgba(148, 163, 184, 0.18);
}

@container kind-share (max-width: 460px) {
    .kind-share__table {
        font-size: 0.8rem;
    }

    .kind-share__table th,
    .kind-share__table td {
        padding: 6px 3px;
    }

    .kind-share__table tbody th,
    .kind-share__table thead th:first-child {
        width: 34%;
    }
}

@container kind-share (min-width: 1100px) {
    .kind-share__bar {
        height: 14px;
    }
}
