@import url('https://fonts.googleapis.com/css2?family=Sora:wght@600;700&display=swap');

/* Profile page + public profile view (/app/Profile and /profile/{token}).

   Design language: an editorial sheet, not a dashboard. Sections are divided
   by hairline rules instead of boxed cards, labels whisper in tracked caps,
   and the numbers — set in the timer's mono face — do the talking. The one
   loud moment is the hero: the cuber's best single, because that's how
   cubers introduce themselves. Every color derives from the MudBlazor
   palette vars so light and dark themes both work. */

/* ---------- account-page shell (ProfileLayout) ----------
   Bound the shell to the viewport so the body below the pinned topbar scrolls
   on its own — the app clips document-level overflow. These live here (not in
   ProfileLayout.razor.css) because .profile-main / .profile-main-container sit
   on MudBlazor component roots, which never receive the CSS-isolation scope
   attribute, so scoped rules silently don't match them. */

.profile-main {
    height: 100dvh;
    display: flex;
    flex-direction: column;
}

.profile-main-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.profile-topbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: 8px 12px 0;
}

.profile-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* ---------- page frame ---------- */

.profile-container {
    max-width: 1020px;
    margin: 0 auto;
    padding: 16px 24px 56px;
}

.profile-container .loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    width: 100%;
    min-height: calc(100dvh - 160px);
    color: var(--mud-palette-text-secondary);
}

/* ---------- hero: who this cuber is, and their headline time ---------- */

.profile-hero {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 20px 4px 28px;
}

.profile-hero .profile-avatar {
    width: 84px;
    height: 84px;
    font-size: 1.9rem;
    font-family: 'Sora', 'Inter', sans-serif;
    flex-shrink: 0;
    outline: 2px solid color-mix(in srgb, var(--mud-palette-primary) 40%, transparent);
    outline-offset: 3px;
}

.hero-id {
    flex: 1;
    min-width: 0;
}

.hero-name-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.hero-name {
    margin: 0;
    font-family: 'Sora', 'Inter', sans-serif;
    font-size: clamp(1.45rem, 2.6vw, 1.85rem);
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1.2;
    color: var(--mud-palette-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hero-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 0;
    margin-top: 5px;
    color: var(--mud-palette-text-secondary);
    font-size: 0.82rem;
}

.hero-meta span:not(:last-child)::after {
    content: '·';
    margin: 0 9px;
    opacity: 0.6;
}

/* link pills */

.link-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
}

.link-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid color-mix(in srgb, var(--mud-palette-text-primary) 14%, transparent);
    border-radius: 999px;
    padding: 3px 10px 3px 4px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--mud-palette-text-primary);
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.link-pill:hover,
.link-pill:focus-visible {
    border-color: color-mix(in srgb, var(--mud-palette-primary) 55%, transparent);
    background: color-mix(in srgb, var(--mud-palette-primary) 8%, transparent);
    outline: none;
}

.pill-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
    background: color-mix(in srgb, var(--mud-palette-primary) 16%, transparent);
    color: var(--mud-palette-primary);
    font-family: 'Roboto Mono', monospace;
    font-weight: 700;
    font-size: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.link-pill .pill-out {
    font-size: 0.8rem;
    color: var(--mud-palette-text-secondary);
}

.hero-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
}

/* the headline: main event's best single, set like a timer reading */

.hero-best {
    flex-shrink: 0;
    text-align: right;
}

.best-label {
    display: block;
    font-size: 0.64rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary);
    margin-bottom: 4px;
}

.best-time {
    display: block;
    font-family: 'Roboto Mono', monospace;
    font-size: clamp(2.3rem, 5vw, 3rem);
    font-weight: 500;
    line-height: 1;
    color: var(--mud-palette-primary);
    font-variant-numeric: tabular-nums;
}

/* sub-seconds smaller, like the timer itself renders them */
.best-time .time-separator,
.best-time .time-milliseconds {
    font-size: 0.55em;
    opacity: 0.8;
}

/* ---------- stat strip: the quiet three ---------- */

.stat-strip {
    display: flex;
    flex-wrap: wrap;
    row-gap: 16px;
    padding: 20px 4px 24px;
    border-top: 1px solid color-mix(in srgb, var(--mud-palette-text-primary) 10%, transparent);
}

.stat {
    padding: 0 36px;
    border-left: 1px solid color-mix(in srgb, var(--mud-palette-text-primary) 10%, transparent);
}

.stat:first-child {
    padding-left: 0;
    border-left: none;
}

.stat-value {
    display: block;
    font-family: 'Roboto Mono', monospace;
    font-size: 1.6rem;
    font-weight: 500;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    color: var(--mud-palette-text-primary);
}

.stat-label {
    display: block;
    margin-top: 5px;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary);
}

.stat-sub {
    display: block;
    margin-top: 3px;
    font-size: 0.72rem;
    color: color-mix(in srgb, var(--mud-palette-text-secondary) 75%, transparent);
}

/* ---------- sections: hairline-ruled, label + hint head ---------- */

.profile-section {
    border-top: 1px solid color-mix(in srgb, var(--mud-palette-text-primary) 10%, transparent);
    padding: 22px 4px 26px;
}

.profile-container > .profile-section:first-child {
    border-top: none;
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-bottom: 18px;
}

.section-title {
    margin: 0;
    font-family: 'Inter', sans-serif;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--mud-palette-text-primary);
}

.section-hint {
    font-size: 0.72rem;
    color: var(--mud-palette-text-secondary);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 120px;
    gap: 8px;
    /* The dimming lives on the children (globals.css) so a today-scope hint stays readable. */
}

/* ---------- records by event ---------- */

.record-list {
    display: flex;
    flex-direction: column;
}

.record-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 6px 12px 12px;
    transition: background-color 0.15s ease;
}

.record-row + .record-row {
    border-top: 1px solid color-mix(in srgb, var(--mud-palette-text-primary) 6%, transparent);
}

.record-row:hover {
    background: color-mix(in srgb, var(--mud-palette-text-primary) 3%, transparent);
}

/* main event: a single accent bar and a faint wash — no louder than that */
.record-row.main {
    box-shadow: inset 2px 0 0 var(--mud-palette-primary);
    background: color-mix(in srgb, var(--mud-palette-primary) 5%, transparent);
}

.record-name {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    overflow: hidden;
    white-space: nowrap;
}

.main-chip {
    font-size: 0.54rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--mud-palette-primary);
    border: 1px solid color-mix(in srgb, var(--mud-palette-primary) 35%, transparent);
    border-radius: 4px;
    padding: 2px 5px;
    white-space: nowrap;
}

.record-stats {
    display: flex;
    gap: 28px;
}

.rstat {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 60px;
}

.rstat i {
    font-style: normal;
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary);
}

.rstat b {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.95rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.record-count {
    font-size: 0.72rem;
    color: var(--mud-palette-text-secondary);
    min-width: 72px;
    text-align: right;
}

.record-row .event-star {
    color: color-mix(in srgb, var(--mud-palette-text-primary) 25%, transparent);
    padding: 2px;
    margin-right: -4px;
}

.record-row .event-star.on {
    color: var(--mud-palette-primary);
}

/* ---------- practice heatmap (fluid: always spans the full section) ---------- */

.heatmap-months {
    display: flex;
    font-size: 0.65rem;
    color: var(--mud-palette-text-secondary);
    margin-bottom: 6px;
    overflow: hidden;
}

.heatmap-months span {
    flex-basis: 0;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
}

.profile-heatmap {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(7, auto);
    grid-auto-columns: 1fr;
    gap: 3px;
}

.profile-heatmap .hm-cell {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
}

.hm-cell {
    border-radius: 2px;
    box-sizing: border-box;
}

.hm-cell.level-0 {
    background: color-mix(in srgb, var(--mud-palette-text-primary) 7%, transparent);
}

.hm-cell.level-1 {
    background: color-mix(in srgb, var(--mud-palette-primary) 30%, transparent);
}

.hm-cell.level-2 {
    background: color-mix(in srgb, var(--mud-palette-primary) 55%, transparent);
}

.hm-cell.level-3 {
    background: color-mix(in srgb, var(--mud-palette-primary) 80%, transparent);
}

.hm-cell.level-4 {
    background: var(--mud-palette-primary);
}

.heatmap-legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
    padding-top: 8px;
    font-size: 0.66rem;
    color: var(--mud-palette-text-secondary);
}

.heatmap-legend .hm-cell {
    width: 12px;
    height: 12px;
}

.heatmap-legend span {
    margin: 0 4px;
}

/* ---------- public profile footer ---------- */

.public-profile-footer {
    text-align: center;
    padding: 20px 0 24px;
    border-top: 1px solid color-mix(in srgb, var(--mud-palette-text-primary) 10%, transparent);
    font-size: 0.78rem;
    color: var(--mud-palette-text-secondary);
}

.public-profile-footer a {
    color: var(--mud-palette-primary);
    text-decoration: none;
}

/* ---------- load-in: one quiet rise, staggered per block ---------- */

@media (prefers-reduced-motion: no-preference) {
    .profile-container > * {
        animation: profile-rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
    }

    .profile-container > *:nth-child(2) { animation-delay: 0.06s; }
    .profile-container > *:nth-child(3) { animation-delay: 0.12s; }
    .profile-container > *:nth-child(4) { animation-delay: 0.18s; }
    .profile-container > *:nth-child(n+5) { animation-delay: 0.24s; }
}

@keyframes profile-rise {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

/* ---------- responsive ---------- */

@media (max-width: 700px) {
    .profile-container {
        padding: 12px 18px 48px;
    }

    .profile-hero {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 14px;
        padding-top: 8px;
    }

    .hero-name-row,
    .hero-meta,
    .link-pills,
    .hero-actions {
        justify-content: center;
    }

    .hero-name {
        white-space: normal;
    }

    .hero-best {
        text-align: center;
        margin-top: 2px;
    }

    /* three equal columns so the strip never wraps into a lopsided 2+1 */
    .stat-strip {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
    }

    .stat {
        text-align: center;
        padding: 0 6px;
    }

    .record-row {
        flex-wrap: wrap;
        row-gap: 8px;
    }

    /* stats drop to their own line, aligned under the event name */
    .record-stats {
        width: 100%;
        order: 4;
        justify-content: flex-start;
        gap: 24px;
        padding-left: 42px;
    }

    .rstat {
        align-items: flex-start;
        min-width: 0;
    }

    .record-count {
        min-width: 0;
    }
}
