/* ===========================================================================
   Life Achievement Unlocker - dark, game-like trophy screen.
   Mobile first: everything is designed at ~390px and centred on wider screens.
   =========================================================================== */

:root {
    --bg: #0E1020;
    --surface: #181B30;
    --surface-2: #22264A;
    --border: #2C3160;
    --text: #F2F3FA;
    --muted: #A3A8C8;
    --gold: #F5B83D;
    --gold-ink: #0E1020;
    --teal: #4FD1C5;

    --radius-card: 22px;
    --radius-tile: 18px;
    --radius-icon: 13px;
    --radius-pill: 20px;

    --shell: 430px;
    --nav-height: 76px;

    --font-head: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
    --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
}

h1, h2, h3, h4 {
    font-family: var(--font-head);
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.01em;
}

a { color: var(--gold); text-decoration: none; }

button {
    font-family: var(--font-body);
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

button:disabled { cursor: not-allowed; }

/* ---------------------------------------------------------------- shell -- */

.app-shell {
    max-width: var(--shell);
    margin: 0 auto;
    min-height: 100dvh;
    padding: 0 16px calc(var(--nav-height) + 28px);
    position: relative;
}

.app-shell--bare { padding-bottom: 28px; }

.screen-pad { padding-top: 22px; }

/* ----------------------------------------------------------------- bits -- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 18px;
}

.muted { color: var(--muted); }

.section-title {
    font-family: var(--font-head);
    font-size: 1.05rem;
    font-weight: 700;
    margin: 26px 0 12px;
}

.icon-square {
    width: 46px;
    height: 46px;
    min-width: 46px;
    border-radius: var(--radius-icon);
    background: var(--surface-2);
    display: grid;
    place-items: center;
    color: var(--gold);
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--radius-pill);
    padding: 6px 13px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.pill--gold { background: var(--gold); color: var(--gold-ink); }
.pill--teal { background: rgba(79, 209, 197, 0.14); color: var(--teal); }
.pill--ghost { background: var(--surface-2); color: var(--muted); }

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 52px;
    border-radius: var(--radius-pill);
    font-size: 1rem;
    font-weight: 600;
    transition: transform 0.12s ease, opacity 0.12s ease;
}

.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; }

.btn--gold { background: var(--gold); color: var(--gold-ink); }
.btn--ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }

.field { margin-bottom: 14px; }

.field label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 7px;
}

.field input {
    width: 100%;
    min-height: 52px;
    padding: 0 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 15px;
    color: var(--text);
    font-size: 1rem;
    font-family: var(--font-body);
}

.field input:focus {
    outline: none;
    border-color: var(--gold);
}

.form-error {
    background: rgba(245, 92, 92, 0.12);
    border: 1px solid rgba(245, 92, 92, 0.35);
    color: #FF9C9C;
    border-radius: 14px;
    padding: 11px 14px;
    font-size: 0.88rem;
    margin-bottom: 14px;
}

.empty {
    color: var(--muted);
    font-size: 0.9rem;
    text-align: center;
    padding: 26px 10px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-tile);
}

.spinner {
    width: 26px;
    height: 26px;
    border: 3px solid var(--surface-2);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 40px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------- top header -- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 0 6px;
}

.topbar__greeting { font-size: 0.85rem; color: var(--muted); }

.topbar__name {
    font-family: var(--font-head);
    font-size: 1.45rem;
    font-weight: 700;
}

.icon-button {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    color: var(--muted);
}

/* --------------------------------------------------------- profile card -- */

.profile {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-top: 16px;
}

.ring { position: relative; width: 104px; height: 104px; min-width: 104px; }
.ring svg { transform: rotate(-90deg); display: block; }
.ring__track { stroke: var(--surface-2); }
.ring__value { stroke: var(--gold); stroke-linecap: round; transition: stroke-dashoffset 0.6s ease; }

.ring__center {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    text-align: center;
}

.ring__label { font-size: 0.6rem; letter-spacing: 0.12em; color: var(--muted); text-transform: uppercase; }
.ring__level { font-family: var(--font-head); font-size: 1.9rem; font-weight: 700; line-height: 1; }

.profile__title { font-family: var(--font-head); font-size: 1.15rem; font-weight: 700; }
.profile__sub { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }
.profile__xp { margin-top: 10px; font-weight: 700; color: var(--gold); }

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 16px;
}

.stat {
    background: var(--surface-2);
    border-radius: var(--radius-tile);
    padding: 13px 10px;
    text-align: center;
}

.stat__value { font-family: var(--font-head); font-size: 1.4rem; font-weight: 700; }
.stat__value--teal { color: var(--teal); }
.stat__label { font-size: 0.7rem; color: var(--muted); margin-top: 2px; }

/* ------------------------------------------------------------ list rows -- */

.row {
    display: flex;
    align-items: center;
    gap: 13px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-tile);
    padding: 13px;
    margin-bottom: 10px;
}

.row__body { flex: 1; min-width: 0; }

.row__name {
    font-weight: 600;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row__desc {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 3px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.row__meta { font-size: 0.76rem; color: var(--muted); margin-top: 3px; }

.row--locked {
    border-style: dashed;
    background: transparent;
}

.row--locked .icon-square { color: var(--muted); }

.xp-gain { color: var(--gold); font-weight: 700; font-size: 0.9rem; white-space: nowrap; }

/* -------------------------------------------------------------- quests -- */

.quest { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-tile); padding: 14px; margin-bottom: 10px; }

.quest__head { display: flex; align-items: center; gap: 12px; }

.bar {
    height: 7px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 12px;
}

.bar__fill {
    height: 100%;
    background: var(--teal);
    border-radius: 999px;
    transition: width 0.5s ease;
}

.bar__fill--gold { background: var(--gold); }

/* --------------------------------------------------------------- chips -- */

.chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 0 4px;
    scrollbar-width: none;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
    border-radius: var(--radius-pill);
    padding: 9px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    white-space: nowrap;
    min-height: 44px;
}

.chip--active { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }

/* ---------------------------------------------------------- bottom nav -- */

.nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: var(--shell);
    height: var(--nav-height);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 40;
}

.nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: var(--muted);
    font-size: 0.66rem;
    font-weight: 600;
    min-height: 44px;
    justify-content: center;
}

.nav__item--active { color: var(--gold); }

.nav__claim {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--gold);
    color: var(--gold-ink);
    display: grid;
    place-items: center;
    justify-self: center;
    margin-top: -22px;
    box-shadow: 0 8px 22px rgba(245, 184, 61, 0.35);
}

/* ------------------------------------------------------- unlock screen -- */

.unlock {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 100;
    overflow-y: auto;
    animation: fade-in 0.25s ease;
}

.unlock__inner {
    max-width: var(--shell);
    margin: 0 auto;
    padding: 20px 24px 40px;
    text-align: center;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.unlock__close { align-self: flex-start; }

.unlock__kicker {
    font-family: var(--font-head);
    color: var(--gold);
    letter-spacing: 0.18em;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-top: 10px;
    animation: rise 0.45s ease both;
}

.badge-ring {
    width: 212px;
    height: 212px;
    margin: 22px auto 4px;
    border: 2px dashed var(--border);
    border-radius: 50%;
    display: grid;
    place-items: center;
    position: relative;
    animation: pop 0.5s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}

.badge {
    width: 132px;
    height: 132px;
    border-radius: 34px;
    background: linear-gradient(145deg, #FFD36E, var(--gold));
    color: var(--gold-ink);
    display: grid;
    place-items: center;
    transform: rotate(-9deg);
    box-shadow: 0 16px 40px rgba(245, 184, 61, 0.32);
}

.confetti { position: absolute; width: 7px; height: 7px; border-radius: 2px; animation: twinkle 1.6s ease-in-out infinite; }

.unlock__name {
    font-family: var(--font-head);
    font-size: 1.85rem;
    font-weight: 700;
    margin-top: 16px;
    animation: rise 0.5s ease 0.1s both;
}

.unlock__desc { color: var(--muted); font-size: 0.93rem; margin-top: 8px; animation: rise 0.5s ease 0.15s both; }

.unlock__pills { display: flex; gap: 9px; justify-content: center; margin-top: 16px; animation: rise 0.5s ease 0.2s both; }

.unlock__levelup {
    margin-top: 18px;
    background: rgba(245, 184, 61, 0.12);
    border: 1px solid rgba(245, 184, 61, 0.4);
    border-radius: var(--radius-tile);
    padding: 13px;
    animation: rise 0.5s ease 0.25s both;
}

.unlock__levelup strong { color: var(--gold); font-family: var(--font-head); }

.unlock__progress { margin-top: 20px; text-align: left; animation: rise 0.5s ease 0.3s both; }

.unlock__progress-head { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--muted); }

.unlock__bonus { margin-top: 20px; text-align: left; animation: rise 0.5s ease 0.35s both; }

.unlock__actions { margin-top: auto; padding-top: 26px; display: flex; flex-direction: column; gap: 10px; animation: rise 0.5s ease 0.4s both; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { opacity: 0; transform: scale(0.65); } 100% { opacity: 1; transform: scale(1); } }
@keyframes twinkle { 0%, 100% { opacity: 0.25; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.15); } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ----------------------------------------------------------- auth pages -- */

.auth {
    max-width: var(--shell);
    margin: 0 auto;
    padding: 56px 24px 32px;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.auth__logo {
    width: 62px;
    height: 62px;
    border-radius: 19px;
    background: var(--gold);
    color: var(--gold-ink);
    display: grid;
    place-items: center;
    margin-bottom: 22px;
}

.auth__title { font-family: var(--font-head); font-size: 1.85rem; font-weight: 700; }
.auth__sub { color: var(--muted); font-size: 0.93rem; margin: 8px 0 26px; }
.auth__switch { text-align: center; margin-top: 20px; font-size: 0.9rem; color: var(--muted); }

/* --------------------------------------------------------- blazor bits -- */

#blazor-error-ui {
    background: var(--surface);
    color: var(--text);
    border-top: 1px solid var(--border);
    bottom: 0;
    display: none;
    left: 0;
    padding: 14px 18px;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 16px; top: 12px; }

.loading-progress { display: block; margin: 42vh auto 0; width: 54px; height: 54px; }
.loading-progress circle { fill: none; stroke: var(--surface-2); stroke-width: 0.6rem; transform-origin: 50% 50%; transform: rotate(-90deg); }
.loading-progress circle:last-child { stroke: var(--gold); stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%; transition: stroke-dasharray 0.05s ease-in-out; }
.loading-progress-text { text-align: center; color: var(--muted); font-family: var(--font-body); margin-top: 14px; }
.loading-progress-text:after { content: "Loading your achievements..."; }

/* ------------------------------------------------------------ progress -- */

.progress-row { margin-top: 10px; }

.progress-row__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.76rem;
    color: var(--muted);
    margin-bottom: 7px;
}

.progress-row__count { color: var(--teal); font-weight: 700; }
.progress-row__count--done { color: var(--gold); }

.log-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 15px;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--teal);
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}

.log-button:active:not(:disabled) { transform: scale(0.97); }
.log-button:disabled { opacity: 0.5; }

/* ---------------------------------------------------------- note field -- */

.note { margin-top: 20px; text-align: left; animation: rise 0.5s ease 0.35s both; }

.note__label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 8px;
    display: block;
}

.note textarea {
    width: 100%;
    min-height: 80px;
    padding: 13px 15px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 15px;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.93rem;
    resize: vertical;
}

.note textarea:focus { outline: none; border-color: var(--gold); }

.note__foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 0.76rem;
    color: var(--muted);
}

.note__saved { color: var(--teal); font-weight: 600; }

.row__note {
    font-size: 0.8rem;
    color: var(--text);
    margin-top: 5px;
    padding-left: 9px;
    border-left: 2px solid var(--border);
    font-style: italic;
    opacity: 0.85;
}

/* ======================================================= Phase 2: social == */

/* --------------------------------------------------------------- podium -- */

.podium {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr;
    align-items: end;
    gap: 9px;
    margin-top: 16px;
}

.podium__slot { text-align: center; }

.podium__avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--surface-2);
    border: 2px solid var(--border);
    display: grid;
    place-items: center;
    margin: 0 auto 7px;
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--muted);
}

.podium__slot--first .podium__avatar {
    width: 62px;
    height: 62px;
    border-color: var(--gold);
    color: var(--gold);
    font-size: 1.3rem;
}

.podium__name {
    font-size: 0.78rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.podium__xp { font-size: 0.72rem; color: var(--gold); font-weight: 700; margin-top: 2px; }

.podium__block {
    margin-top: 8px;
    border-radius: 12px 12px 0 0;
    background: var(--surface-2);
    display: grid;
    place-items: center;
    font-family: var(--font-head);
    font-weight: 700;
    color: var(--muted);
}

.podium__slot--first .podium__block { height: 68px; background: var(--gold); color: var(--gold-ink); }
.podium__slot--second .podium__block { height: 50px; }
.podium__slot--third .podium__block { height: 38px; }

/* ------------------------------------------------------------ rank rows -- */

.rank {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 13px;
    border-radius: var(--radius-tile);
    background: var(--surface);
    border: 1px solid var(--border);
    margin-bottom: 8px;
}

.rank--me { border-color: var(--gold); }

.rank__number {
    width: 26px;
    font-family: var(--font-head);
    font-weight: 700;
    color: var(--muted);
    text-align: center;
}

.rank--me .rank__number { color: var(--gold); }
.rank__body { flex: 1; min-width: 0; }
.rank__name { font-weight: 600; font-size: 0.92rem; }
.rank__meta { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.rank__xp { color: var(--gold); font-weight: 700; font-size: 0.9rem; white-space: nowrap; }

/* ----------------------------------------------------------------- feed -- */

.feed-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-tile);
    padding: 14px;
    margin-bottom: 10px;
}

.feed-item__head { display: flex; align-items: center; gap: 12px; }
.feed-item__who { flex: 1; min-width: 0; }
.feed-item__name { font-weight: 600; font-size: 0.92rem; }
.feed-item__name span { color: var(--muted); font-weight: 400; }
.feed-item__time { font-size: 0.74rem; color: var(--muted); margin-top: 2px; }

.feed-item__actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 11px;
    border-top: 1px solid var(--border);
}

.react {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 14px;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
}

.react:active:not(:disabled) { transform: scale(0.97); }
.react--on { color: var(--gold); border-color: var(--gold); }
.react--respect.react--on { color: var(--teal); border-color: var(--teal); }
.react:disabled { opacity: 0.45; }

/* --------------------------------------------------------------- verify -- */

.verify {
    background: var(--surface);
    border: 1px solid var(--gold);
    border-radius: var(--radius-tile);
    padding: 14px;
    margin-bottom: 10px;
}

.verify__actions { display: flex; gap: 9px; margin-top: 12px; }

.verify__actions .btn { min-height: 46px; font-size: 0.9rem; }

/* ------------------------------------------------------------- add form -- */

.add-friend { display: flex; gap: 8px; margin-top: 14px; }

.add-friend input {
    flex: 1;
    min-height: 48px;
    padding: 0 15px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 15px;
    color: var(--text);
    font-size: 0.92rem;
    font-family: var(--font-body);
    min-width: 0;
}

.add-friend input:focus { outline: none; border-color: var(--gold); }

.add-friend button {
    min-height: 48px;
    padding: 0 18px;
    border-radius: 15px;
    background: var(--gold);
    color: var(--gold-ink);
    font-weight: 600;
    white-space: nowrap;
}

.add-friend button:disabled { opacity: 0.55; }

.tabs { display: flex; gap: 8px; margin-top: 16px; }

.tab {
    flex: 1;
    min-height: 44px;
    border-radius: var(--radius-pill);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.tab--active { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }

.badge-count {
    display: inline-grid;
    place-items: center;
    min-width: 19px;
    height: 19px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--gold);
    color: var(--gold-ink);
    font-size: 0.68rem;
    font-weight: 700;
    margin-left: 5px;
}

.tab--active .badge-count { background: var(--gold-ink); color: var(--gold); }
