/*
 * Achievement map. Colors come from /public/site.css tokens.
 */

.ach-body {
    margin: 0;
    box-sizing: border-box;
    font-family: var(--font-family, 'Roboto', system-ui, sans-serif);
    background: var(--neutral-primary);
    color: var(--text-primary);
}

.ach-body *,
.ach-body *::before,
.ach-body *::after {
    box-sizing: border-box;
}

.ach-body a {
    color: var(--brand-primary);
}

.ach-topbar {
    border-bottom: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.08));
    background: var(--neutral-light, #fff);
}

.ach-topbar__inner {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 1600px;
    margin: 0 auto;
    padding: 14px 24px;
}

.ach-back {
    text-decoration: none;
    font-weight: 600;
}

.ach-user {
    margin-left: auto;
    color: var(--text-secondary);
}

.ach-main {
    max-width: 1600px;
    margin: 0 auto;
    padding: 28px 24px 64px;
}

.ach-layout--history {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    column-gap: 24px;
    align-items: start;
    padding: 0 24px 64px;
}

.ach-layout--history .ach-main {
    max-width: none;
    margin: 0;
    padding: 28px 0 0;
}

.ach-body--history .ach-topbar__inner {
    max-width: none;
}

.ach-eyebrow {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.ach-main h1 {
    margin: 0 0 8px;
    font-size: 32px;
}

.ach-lead,
.ach-track p,
.ach-guest p {
    margin: 0;
    color: var(--text-secondary);
}

.ach-guest,
.ach-error,
.ach-track {
    margin-top: 20px;
    padding: 16px;
    border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.08));
    border-radius: 14px;
    background: var(--neutral-light, #fff);
}

.ach-btn,
.ach-holders__close {
    display: inline-flex;
    align-items: center;
    margin-top: 12px;
    padding: 8px 14px;
    border: 0;
    border-radius: 999px;
    background: var(--interactive-bg, #d6b56c);
    color: #1c1408;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.ach-group {
    margin-top: 28px;
}

.ach-group h2 {
    margin: 0 0 8px;
    font-size: 22px;
}

.ach-track__head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.ach-track h3 {
    margin: 0 0 4px;
    font-size: 18px;
}

.ach-track__count {
    margin: 0;
    font-weight: 700;
    color: var(--text-primary);
    text-align: right;
    white-space: nowrap;
}

.ach-track__bar {
    height: 10px;
    margin-top: 12px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.08);
}

.ach-track__bar span {
    display: block;
    height: 100%;
    background: var(--interactive-bg, #d6b56c);
}

.ach-track__next {
    margin-top: 8px;
}

.ach-slider {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
}

.ach-slider__nav {
    display: flex;
    flex: 0 0 auto;
    gap: 6px;
}

.ach-slider__viewport {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    container-type: inline-size;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
}

.ach-slider__viewport::-webkit-scrollbar {
    display: none;
}

.ach-slider__viewport:focus-visible {
    outline: 2px solid var(--interactive-bg, #d6b56c);
    outline-offset: 4px;
    border-radius: 12px;
}

.ach-slider.is-overflow .ach-slider__viewport {
    cursor: grab;
}

.ach-slider__viewport.is-dragging,
.ach-slider__viewport.is-dragging .ach-badge {
    cursor: grabbing;
    user-select: none;
}

.ach-slider__arrow {
    display: inline-flex;
    flex: 0 0 36px;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    background: var(--interactive-bg, #d6b56c);
    color: #1c1408;
    cursor: pointer;
}

.ach-slider__arrow:disabled {
    opacity: 0.35;
    cursor: default;
}

.ach-slider__arrow[hidden] {
    display: none;
}

.ach-badges {
    display: flex;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.ach-badges > li {
    flex: 1 1 148px;
    min-width: 148px;
    max-width: 200px;
    scroll-snap-align: start;
}

.ach-badge {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-width: 0;
    min-height: 132px;
    padding: 12px 8px;
    border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.08));
    border-radius: 12px;
    background: var(--surface-sunken, rgba(0, 0, 0, 0.03));
    color: inherit;
    text-align: center;
}

.ach-badge__hint {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 8px);
    z-index: 6;
    padding: 8px 10px;
    border-radius: 8px;
    background: #243044;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.35;
    text-align: left;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
}

.ach-badge__hint.is-floating {
    position: fixed;
    z-index: 30;
    width: 220px;
    max-width: calc(100vw - 16px);
    right: auto;
    bottom: auto;
    opacity: 1;
    transform: none;
}

.ach-slider.is-overflow .ach-badges {
    padding-right: 4px;
}

html:not([data-ach-layout="sections"]):not([data-ach-layout="grid"]) .ach-slider.is-overflow .ach-badges > li:not(.ach-break),
html[data-ach-layout="sections"] .ach-slider:not(.ach-slider--banded).is-overflow .ach-badges > li {
    flex: 0 0 148px;
    max-width: 148px;
}

.ach-slider.is-overflow .ach-badges > li:last-child {
    scroll-snap-align: end;
}

@container (max-width: 520px) {
    html:not([data-ach-layout="sections"]):not([data-ach-layout="grid"]) .ach-slider.is-overflow .ach-badges > li:not(.ach-break),
    html[data-ach-layout="sections"] .ach-slider:not(.ach-slider--banded).is-overflow .ach-badges > li {
        flex-basis: min(168px, calc(100cqw - 44px));
        max-width: min(200px, calc(100cqw - 44px));
        min-width: 0;
    }
}

.ach-layouts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
}

.ach-layouts__label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
}

.ach-layouts__options {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ach-layouts__option {
    border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.08));
    border-radius: 999px;
    background: transparent;
    color: var(--text-primary);
    padding: 8px 14px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.ach-layouts__option[aria-checked="true"] {
    border-color: transparent;
    background: var(--interactive-bg, #d6b56c);
    color: #1c1408;
}

.ach-layouts__option:focus-visible {
    outline: 2px solid var(--interactive-bg, #d6b56c);
    outline-offset: 2px;
}

.ach-break {
    display: none;
    margin: 0;
    padding: 0;
    list-style: none;
    scroll-snap-align: none;
}

.ach-break__title {
    margin: 0;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

html[data-ach-layout="sections"] .ach-slider--banded .ach-slider__nav,
html[data-ach-layout="grid"] .ach-slider__nav {
    display: none;
}

html[data-ach-layout="sections"] .ach-slider--banded .ach-slider__viewport,
html[data-ach-layout="grid"] .ach-slider__viewport {
    overflow: visible;
    scroll-snap-type: none;
    cursor: auto;
}

html[data-ach-layout="sections"] .ach-slider--banded.is-overflow .ach-slider__viewport,
html[data-ach-layout="grid"] .ach-slider.is-overflow .ach-slider__viewport {
    cursor: auto;
}

html[data-ach-layout="sections"] .ach-slider--banded .ach-badges,
html[data-ach-layout="grid"] .ach-badges {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 200px));
    justify-content: start;
    gap: 12px;
}

html[data-ach-layout="sections"] .ach-slider--banded .ach-badges > li,
html[data-ach-layout="grid"] .ach-badges > li {
    min-width: 0;
    max-width: none;
    scroll-snap-align: none;
}

html[data-ach-layout="sections"] .ach-slider--banded .ach-break {
    display: block;
    grid-column: 1 / -1;
    padding-top: 4px;
}

html[data-ach-layout="sections"] .ach-slider--banded .ach-break:not(:first-child) {
    margin-top: 8px;
}

button.ach-badge {
    cursor: pointer;
}

button.ach-badge:hover,
button.ach-badge:focus-visible {
    border-color: var(--interactive-bg, #d6b56c);
    outline: none;
}

button.ach-badge--negative:hover,
button.ach-badge--negative:focus-visible {
    border-color: #b85c6a;
}

.ach-badge--locked {
    color: var(--text-secondary);
}

.ach-badge__icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid var(--interactive-bg, #d6b56c);
    background: var(--neutral-light, #fff);
    font-size: 22px;
    color: var(--interactive-bg, #d6b56c);
}

.ach-badge--negative:not(.ach-badge--locked) .ach-badge__icon {
    border-style: solid;
    border-color: #b85c6a;
    background: rgba(184, 92, 106, 0.16);
    color: #b85c6a;
}

.ach-badge--locked .ach-badge__icon,
.ach-badge--negative.ach-badge--locked .ach-badge__icon {
    border-style: dashed;
    border-color: var(--text-secondary);
    background: transparent;
    color: var(--text-secondary);
}

html[data-theme="dark"] .ach-badge--negative:not(.ach-badge--locked) .ach-badge__icon {
    border-color: #e7a8b2;
    background: rgba(231, 168, 178, 0.16);
    color: #e7a8b2;
}

html[data-theme="dark"] button.ach-badge--negative:hover,
html[data-theme="dark"] button.ach-badge--negative:focus-visible {
    border-color: #e7a8b2;
}

html[data-theme="dark"] .ach-badge--negative.ach-badge--locked .ach-badge__icon {
    border-color: var(--text-secondary);
    background: transparent;
    color: var(--text-secondary);
}

.ach-badge__name {
    font-weight: 700;
}

.ach-badge__threshold {
    font-size: 12px;
    color: var(--text-secondary);
}

.ach-holders[hidden] {
    display: none;
}

.ach-holders {
    position: fixed;
    inset: 0;
    z-index: 40;
}

.ach-holders__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.ach-holders__panel {
    position: relative;
    width: min(480px, calc(100% - 32px));
    max-height: min(70vh, 640px);
    margin: 10vh auto 0;
    padding: 16px;
    overflow: auto;
    border-radius: 16px;
    background: var(--neutral-light, #fff);
    color: var(--text-primary);
}

.ach-holders__head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.ach-holders__track {
    margin: 0;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.ach-holders__panel h2 {
    margin: 4px 0 0;
    font-size: 22px;
}

.ach-holders__list {
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.ach-holders__list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-top: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.08));
}

.ach-holders__list time {
    color: var(--text-secondary);
    white-space: nowrap;
}

html[data-theme="dark"] .ach-track__bar {
    background: rgba(255, 255, 255, 0.08);
}

.ach-history {
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 32px);
    margin-top: 28px;
    padding: 16px;
    overflow: auto;
    border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.08));
    border-radius: 14px;
    background: var(--neutral-light, #fff);
}

.ach-history h2 {
    margin: 0 0 12px;
    font-size: 18px;
}

.ach-history__empty {
    margin: 0;
    color: var(--text-secondary);
}

.ach-history__list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.ach-history__item {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    grid-template-areas:
        "icon name"
        "icon track"
        "icon cause"
        "icon date";
    column-gap: 10px;
    row-gap: 2px;
    padding: 10px 0;
    border-top: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.08));
}

.ach-history__icon {
    grid-area: icon;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    align-self: center;
    border: 2px solid var(--interactive-bg, #d6b56c);
    border-radius: 50%;
    background: var(--neutral-light, #fff);
    color: var(--interactive-bg, #d6b56c);
    font-size: 14px;
}

.ach-history__icon--negative {
    border-color: #b85c6a;
    background: rgba(184, 92, 106, 0.16);
    color: #b85c6a;
}

.ach-history__copy {
    display: contents;
}

.ach-history__name {
    grid-area: name;
    font-weight: 700;
    line-height: 1.3;
}

.ach-history__track,
.ach-history__date,
.ach-history__cause {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.3;
}

.ach-history__cause {
    grid-area: cause;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ach-history__cause:hover,
.ach-history__cause:focus-visible {
    color: var(--text-primary, inherit);
}

.ach-history__track {
    grid-area: track;
}

.ach-history__date {
    grid-area: date;
}

html[data-theme="dark"] .ach-history__icon--negative {
    border-color: #e7a8b2;
    background: rgba(231, 168, 178, 0.16);
    color: #e7a8b2;
}

.ach-public {
    margin-top: 8px;
}

.ach-public__self {
    margin-bottom: 8px;
}

.ach-public__track {
    margin-top: 24px;
}

.ach-public__track h2 {
    margin: 0 0 12px;
    font-size: 18px;
}

.ach-public__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.ach-public__item {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    grid-template-areas:
        "icon name"
        "icon date";
    column-gap: 10px;
    row-gap: 2px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.08));
    border-radius: 12px;
    background: var(--neutral-light, #fff);
}

.ach-public__icon {
    grid-area: icon;
}

.ach-public__name {
    grid-area: name;
    font-weight: 700;
    line-height: 1.3;
}

.ach-public__date {
    grid-area: date;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.3;
}

@media (max-width: 1100px) {
    .ach-layout--history {
        grid-template-columns: minmax(0, 1fr);
    }

    .ach-history {
        position: static;
        max-height: none;
    }
}
