/* ============================================================
   How Many Camels Are You Worth — design system
   ============================================================ */

:root {
    --sand-50: #fdf9f2;
    --sand-100: #f8efdd;
    --sand-200: #f0dfbd;
    --sand-300: #e3c68f;
    --dune: #c98a2b;
    --dune-deep: #a76a14;
    --oasis: #0e7c66;
    --night: #241a0e;
    --night-soft: #4a3b26;
    --danger: #c0392b;
    --card-bg: rgba(255, 255, 255, 0.82);
    --card-border: rgba(201, 138, 43, 0.25);
    --shadow-lg: 0 24px 60px -24px rgba(36, 26, 14, 0.45);
    --shadow-sm: 0 6px 18px -8px rgba(36, 26, 14, 0.35);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-pill: 999px;
    --font-display: "Fraunces", Georgia, serif;
    --font-body: "Inter", system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100vh;
}

body {
    font-family: var(--font-body);
    color: var(--night);
    background:
        radial-gradient(1200px 600px at 85% -10%, rgba(201, 138, 43, 0.28), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(14, 124, 102, 0.18), transparent 55%),
        linear-gradient(160deg, var(--sand-50) 0%, var(--sand-100) 55%, var(--sand-200) 100%);
    background-attachment: fixed;
}

h1, h2, h3 {
    font-family: var(--font-display);
    letter-spacing: -0.02em;
    margin: 0 0 0.5rem;
}

a {
    color: var(--dune-deep);
    font-weight: 600;
}

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

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem clamp(1rem, 4vw, 2.5rem);
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(14px);
    background: rgba(253, 249, 242, 0.75);
    border-bottom: 1px solid var(--card-border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--night);
}

.brand-emoji {
    font-size: 1.7rem;
}

.brand-name {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.2rem;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-pill {
    padding: 0.5rem 1.1rem;
    border-radius: var(--radius-pill);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--night-soft);
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    font-family: var(--font-body);
    transition: all 0.18s ease;
}

.nav-pill:hover {
    background: rgba(201, 138, 43, 0.12);
    color: var(--night);
}

.nav-pill.active {
    background: var(--night);
    color: var(--sand-50);
}

.nav-pill-ghost {
    border-color: var(--card-border);
}

.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: clamp(1rem, 4vw, 2.5rem);
}

.footer {
    text-align: center;
    padding: 1.25rem;
    font-size: 0.78rem;
    color: var(--night-soft);
    opacity: 0.8;
}

/* ---------- Buttons & forms ---------- */

.btn {
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 1rem;
    border: none;
    border-radius: var(--radius-pill);
    padding: 0.85rem 1.6rem;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn:not(:disabled):hover {
    transform: translateY(-1px);
}

.btn:not(:disabled):active {
    transform: translateY(1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--dune) 0%, var(--dune-deep) 100%);
    color: #fff;
    box-shadow: 0 10px 24px -10px rgba(167, 106, 20, 0.7);
}

.btn-ghost {
    background: transparent;
    border: 2px solid var(--card-border);
    color: var(--night-soft);
}

.btn-ghost:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.btn-apple {
    background: #000;
    color: #fff;
}

.btn-block {
    display: block;
    width: 100%;
}

.field {
    margin-bottom: 1.1rem;
    text-align: left;
}

.field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--night-soft);
}

.field input {
    width: 100%;
    padding: 0.8rem 1rem;
    font-size: 1rem;
    font-family: var(--font-body);
    border: 1.5px solid var(--card-border);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.9);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
    outline: none;
    border-color: var(--dune);
    box-shadow: 0 0 0 4px rgba(201, 138, 43, 0.15);
}

.validation-message {
    display: block;
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: 0.3rem;
}

.alert {
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: rgba(192, 57, 43, 0.1);
    border: 1px solid rgba(192, 57, 43, 0.35);
    color: var(--danger);
}

/* ---------- Auth pages ---------- */

.auth-page {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 1rem 0 2rem;
}

.auth-card {
    width: min(420px, 92vw);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: clamp(1.5rem, 5vw, 2.5rem);
    backdrop-filter: blur(10px);
    text-align: center;
}

.auth-hero {
    margin-bottom: 1.75rem;
}

.auth-emoji {
    font-size: 3rem;
    display: inline-block;
    margin-bottom: 0.5rem;
}

.auth-hero h1 {
    font-size: clamp(1.6rem, 5vw, 2rem);
    line-height: 1.15;
}

.auth-hero h1 em {
    color: var(--dune-deep);
    font-style: italic;
}

.auth-hero p {
    color: var(--night-soft);
    margin: 0.4rem 0 0;
    font-size: 0.95rem;
}

.divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.4rem 0;
    color: var(--night-soft);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--card-border);
}

.social-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

.social-buttons > div {
    display: flex;
    justify-content: center;
}

.auth-switch {
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--night-soft);
}

/* ---------- Rate page ---------- */

.rate-page {
    width: min(460px, 94vw);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.rate-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    backdrop-filter: blur(10px);
    animation: card-in 0.35s ease;
}

@keyframes card-in {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.rate-photo-frame {
    position: relative;
    aspect-ratio: 4 / 5;
    background: linear-gradient(160deg, var(--sand-200), var(--sand-300));
}

.rate-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.rate-name-plate {
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    padding: 2.5rem 1.4rem 1rem;
    background: linear-gradient(transparent, rgba(20, 14, 5, 0.75));
}

.rate-name-plate h2 {
    color: #fff;
    font-size: 1.7rem;
    margin: 0;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

.photo-dots {
    position: absolute;
    top: 0.9rem;
    inset-inline: 0;
    display: flex;
    justify-content: center;
    gap: 0.4rem;
}

.photo-dot {
    width: 2rem;
    height: 4px;
    border: none;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.45);
    cursor: pointer;
    padding: 0;
}

.photo-dot.active {
    background: #fff;
}

.photo-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    border: none;
    background: rgba(20, 14, 5, 0.4);
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

.photo-nav-prev { left: 0.75rem; }
.photo-nav-next { right: 0.75rem; }

.rate-controls {
    padding: 1.4rem clamp(1.2rem, 4vw, 1.8rem) 1.6rem;
    text-align: center;
}

.camel-readout {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.camel-count {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 3rem;
    line-height: 1;
    color: var(--dune-deep);
    font-variant-numeric: tabular-nums;
}

.camel-label {
    font-size: 1.1rem;
    color: var(--night-soft);
    font-weight: 600;
}

.camel-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 10px;
    border-radius: var(--radius-pill);
    background: linear-gradient(90deg, var(--sand-300), var(--dune), var(--dune-deep));
    outline: none;
    cursor: pointer;
    margin: 0.4rem 0 0.9rem;
}

.camel-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--dune-deep);
    box-shadow: var(--shadow-sm);
    cursor: grab;
    transition: transform 0.12s ease;
}

.camel-slider::-webkit-slider-thumb:hover {
    transform: scale(1.12);
}

.camel-slider::-moz-range-thumb {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--dune-deep);
    box-shadow: var(--shadow-sm);
    cursor: grab;
}

.equivalence {
    min-height: 2.6em;
    font-size: 0.98rem;
    color: var(--oasis);
    font-weight: 600;
    font-style: italic;
    margin: 0 0 1rem;
}

.rate-actions {
    display: flex;
    gap: 0.75rem;
}

.rate-actions .btn {
    flex: 1;
}

.toast {
    background: var(--night);
    color: var(--sand-100);
    border-radius: var(--radius-md);
    padding: 0.85rem 1.2rem;
    font-size: 0.9rem;
    box-shadow: var(--shadow-sm);
    animation: card-in 0.3s ease;
}

/* ---------- Profile page ---------- */

.profile-page {
    width: min(640px, 94vw);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.score-card {
    background: linear-gradient(135deg, var(--night) 0%, #3d2c12 100%);
    color: var(--sand-100);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: clamp(1.5rem, 5vw, 2.25rem);
    text-align: center;
}

.score-card h1 {
    color: #fff;
    font-size: clamp(1.6rem, 5vw, 2.1rem);
}

.score-card .equivalence {
    color: var(--sand-300);
    min-height: 0;
}

.score-figures {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin: 1.25rem 0 1rem;
}

.score-figure {
    display: flex;
    flex-direction: column;
}

.score-number {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 2.6rem;
    color: var(--dune);
    font-variant-numeric: tabular-nums;
}

.score-caption {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.75;
}

.gallery-section {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: clamp(1.25rem, 4vw, 1.75rem);
    backdrop-filter: blur(10px);
}

.gallery-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.gallery-count {
    font-weight: 700;
    color: var(--dune-deep);
    font-variant-numeric: tabular-nums;
}

.gallery-hint {
    color: var(--night-soft);
    font-size: 0.88rem;
    margin-top: 0.2rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.9rem;
    margin-top: 1rem;
}

.gallery-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-delete {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    border: none;
    background: rgba(20, 14, 5, 0.6);
    color: #fff;
    cursor: pointer;
    font-size: 0.85rem;
    backdrop-filter: blur(4px);
    transition: background 0.15s ease;
}

.gallery-delete:hover {
    background: var(--danger);
}

.gallery-add {
    aspect-ratio: 1;
    border: 2px dashed var(--card-border);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    cursor: pointer;
    color: var(--night-soft);
    font-weight: 600;
    font-size: 0.88rem;
    transition: all 0.18s ease;
    text-align: center;
    padding: 0.5rem;
}

.gallery-add:hover {
    border-color: var(--dune);
    color: var(--dune-deep);
    background: rgba(201, 138, 43, 0.06);
}

.gallery-add.disabled {
    opacity: 0.55;
    pointer-events: none;
}

.gallery-add input[type="file"] {
    display: none;
}

.gallery-add-icon {
    font-size: 1.8rem;
    line-height: 1;
}

/* ---------- Leaderboard ---------- */

.leaderboard-page {
    width: min(640px, 94vw);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.standing-card h1 {
    color: #fff;
}

.board-section {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: clamp(1rem, 3vw, 1.5rem);
    backdrop-filter: blur(10px);
}

.board-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.board-row {
    display: grid;
    grid-template-columns: 3rem 1fr auto auto;
    align-items: center;
    gap: 0.9rem;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid transparent;
}

.board-row.is-champion {
    background: linear-gradient(135deg, #fff5d6 0%, #ffe29a 100%);
    border-color: rgba(201, 138, 43, 0.55);
    box-shadow: 0 8px 22px -12px rgba(167, 106, 20, 0.65);
}

.board-row.is-you {
    border-color: var(--oasis);
    background: rgba(14, 124, 102, 0.08);
}

.board-rank {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.2rem;
    text-align: center;
    color: var(--night-soft);
}

.board-name {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.you-tag {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #fff;
    background: var(--oasis);
    border-radius: var(--radius-pill);
    padding: 0.15rem 0.55rem;
}

.board-count {
    font-size: 0.8rem;
    color: var(--night-soft);
    white-space: nowrap;
}

.board-camels {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--dune-deep);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

@media (max-width: 520px) {
    .board-count { display: none; }
    .board-row { grid-template-columns: 2.4rem 1fr auto; }
}

/* ---------- Empty states & splash ---------- */

.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--night-soft);
}

.empty-state-emoji {
    font-size: 3.5rem;
    display: block;
    margin-bottom: 0.75rem;
}

.boot-splash {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: var(--night-soft);
    font-family: var(--font-body);
}

.boot-camel {
    font-size: 4rem;
    animation: sway 1.6s ease-in-out infinite;
}

@keyframes sway {
    0%, 100% { transform: rotate(-8deg); }
    50% { transform: rotate(8deg); }
}

/* ---------- Blazor error UI ---------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    inset-inline: 0;
    background: var(--danger);
    color: #fff;
    padding: 0.8rem 1.2rem;
    z-index: 1000;
    font-family: var(--font-body);
}

#blazor-error-ui .reload {
    color: #fff;
    margin-left: 0.5rem;
}

#blazor-error-ui .dismiss {
    position: absolute;
    right: 1rem;
    cursor: pointer;
    color: #fff;
    text-decoration: none;
}

@media (max-width: 520px) {
    .brand-name { display: none; }
    .score-figures { gap: 2rem; }
}
