/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design tokens ── */
:root {
    --bg:        #0d0d0d;
    --surface-1: #161616;
    --surface-2: #1e1e1e;
    --text:      #f0f0f0;
    --muted:     #888888;
    --border:    #2a2a2a;
    --radius:    12px;
    --radius-sm: 8px;
    --font:      'Inter', system-ui, sans-serif;
}

/* ── Base ── */
html, body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Generation navbar ── */
.gen-nav {
    position: sticky;
    top: 0;
    z-index: 300;
    background: var(--surface-1);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.gen-nav::-webkit-scrollbar { display: none; }

.gen-nav-label {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    margin-right: 0.5rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.gen-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--muted);
    font-family: var(--font);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.3rem 0.65rem;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.gen-btn:hover { color: var(--text); border-color: #444; }

.gen-btn--active {
    background: var(--surface-2);
    border-color: #555;
    color: var(--text);
}

/* ── Shell ── */
.app-shell {
    max-width: 860px;
    margin: 0 auto;
    padding: 3rem 1.25rem 4rem;
}

/* ── Search header ── */
.search-header {
    text-align: center;
    margin-bottom: 3rem;
}

.app-title {
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    margin-bottom: 1.75rem;
    color: var(--text);
}

.app-title span { color: var(--muted); }

.search-bar {
    display: flex;
    gap: 0.625rem;
    max-width: 480px;
    margin: 0 auto;
}

/* ── Autocomplete wrapper ── */
.search-input-wrap {
    flex: 1;
    position: relative;
}

.search-input-wrap .search-input {
    width: 100%;
}

/* Dropdown */
.search-suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.suggestion-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.6rem 1.1rem;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-family: var(--font);
    font-size: 0.85rem;
    text-transform: capitalize;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.suggestion-item:last-child { border-bottom: none; }

.suggestion-item:hover,
.suggestion-item--active {
    background: var(--surface-2);
    color: var(--text);
}

.suggestion-item mark {
    background: none;
    color: var(--text);
    font-weight: 700;
}

.search-input {
    flex: 1;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.875rem 1.25rem;
    font-family: var(--font);
    font-size: 1rem;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}

.search-input::placeholder { color: var(--muted); }
.search-input:focus { border-color: #444; }
.search-input:disabled { opacity: 0.5; }

.search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 1.25rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    flex-shrink: 0;
}

.search-btn:hover:not(:disabled) {
    background: var(--surface-2);
    border-color: #444;
}

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

/* ── Loading ── */
.loading-container {
    display: flex;
    justify-content: center;
    padding: 5rem 0;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 2px solid var(--border);
    border-top-color: var(--muted);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

.spinner-sm {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--muted);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

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

/* ── Error ── */
.error-message {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    font-size: 0.95rem;
}

.error-icon {
    display: block;
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

/* ── Card entrance animation ── */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Pokémon card ── */
.pokemon-card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    text-align: center;
    margin-bottom: 1.25rem;
    animation: fadeUp 0.4s ease-out both;
}

.pokemon-artwork {
    width: 220px;
    height: 220px;
    object-fit: contain;
}

/* HD artwork — smooth scaling */
.artwork-hd { image-rendering: auto; }

/* Pixel sprites — nearest-neighbour so they don't blur */
.artwork-pixel {
    image-rendering: pixelated;
    width: 160px;
    height: 160px;
}

/* Shrink card padding slightly for pixel sprites */
.pokemon-card--retro { padding: 1.75rem 2rem; }

.pokemon-number {
    font-size: 0.8rem;
    color: var(--muted);
    letter-spacing: 0.12em;
    margin-top: 0.5rem;
}

.pokemon-name {
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    text-transform: capitalize;
    margin: 0.25rem 0 1rem;
}

.pokemon-types {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* ── Type badges ── */
.type-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
    letter-spacing: 0.04em;
    color: #fff;
    border: 2px solid transparent;
}

.type-icon {
    width: 14px;
    height: 14px;
    filter: brightness(0) invert(1);
    flex-shrink: 0;
}

/* Retro badge — no icon, slightly different shape (Gen 1–5 era) */
.type-badge-retro {
    border-radius: 4px;
    letter-spacing: 0.08em;
    font-size: 0.68rem;
    padding: 0.25rem 0.55rem;
}

/* Electric / Ice / Ground / Steel have dark text — keep it for retro too */
.type-badge-retro.type-electric,
.type-badge-retro.type-ice,
.type-badge-retro.type-ground,
.type-badge-retro.type-steel { color: #333; }

/* Type colours */
.type-normal   { background: #A8A77A; }
.type-fire     { background: #EE8130; }
.type-water    { background: #6390F0; }
.type-electric { background: #F7D02C; color: #333; }
.type-grass    { background: #7AC74C; }
.type-ice      { background: #96D9D6; color: #333; }
.type-fighting { background: #C22E28; }
.type-poison   { background: #A33EA1; }
.type-ground   { background: #E2BF65; color: #333; }
.type-flying   { background: #A98FF3; }
.type-psychic  { background: #F95587; }
.type-bug      { background: #A6B91A; }
.type-rock     { background: #B6A136; }
.type-ghost    { background: #735797; }
.type-dragon   { background: #6F35FC; }
.type-dark     { background: #705746; }
.type-steel    { background: #B7B7CE; color: #333; }
.type-fairy    { background: #D685AD; }

/* Weakness badge variants */
.type-badge-weakness { border: 2px solid transparent; }
.weakness-x4   { border-color: #ef4444; }
.weakness-x2   { border-color: #f97316; }
.weakness-half { border-color: #3b82f6; }
.weakness-zero { opacity: 0.4; border-color: #555; }

/* ── Info sections ── */
.info-section {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    margin-bottom: 1.25rem;
    animation: fadeUp 0.4s ease-out both;
}

.section-title {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--muted);
    margin-bottom: 1.25rem;
}

/* ── Stat bars ── */
.stat-row {
    display: grid;
    grid-template-columns: 90px 38px 1fr;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.65rem;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--muted);
}

.stat-value {
    font-size: 0.82rem;
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.stat-bar-track {
    height: 5px;
    background: var(--surface-2);
    border-radius: 99px;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    border-radius: 99px;
    background: var(--bar-color, #f0f0f0);
    animation: barGrow 0.8s ease-out both;
}

@keyframes barGrow {
    from { width: 0; }
    to   { width: var(--w, 0%); }
}

/* ── Meta grid ── */
.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.meta-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
}

.meta-value {
    font-size: 0.9rem;
    font-weight: 500;
    text-transform: capitalize;
}

/* ── Weakness groups ── */
.weakness-group { margin-bottom: 1.1rem; }
.weakness-group:last-child { margin-bottom: 0; }

.weakness-group-title {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    margin-bottom: 0.6rem;
}

.weakness-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

/* ── Evolution chain ── */
.evo-chain {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.evo-stage { display: flex; flex-direction: column; align-items: center; }

.evo-options {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    align-items: center;
}

.evo-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
    min-width: 88px;
}

.evo-card:hover {
    border-color: #444;
    background: #242424;
}

.evo-sprite {
    width: 64px;
    height: 64px;
    object-fit: contain;
    image-rendering: pixelated;
}

.evo-name {
    font-size: 0.7rem;
    text-transform: capitalize;
    color: var(--muted);
    margin-top: 0.25rem;
}

.evo-arrow {
    font-size: 1.1rem;
    color: var(--border);
    padding: 0 0.25rem;
    align-self: center;
}

/* ── Team panel ── */
.team-panel {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.75rem;
    margin-bottom: 1.5rem;
}

.team-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.team-count {
    font-size: 0.72rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.team-slots {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
}

.team-slot {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    min-width: 0;
}

.team-slot--empty {
    border-style: dashed;
}

.team-empty-icon {
    font-size: 1.2rem;
    color: var(--border);
}

.team-slot--filled {
    background: var(--surface-2);
    cursor: default;
    padding: 0.25rem;
}

.team-sprite {
    width: 100%;
    max-width: 56px;
    height: auto;
    image-rendering: pixelated;
}

.team-slot-name {
    font-size: 0.55rem;
    color: var(--muted);
    text-transform: capitalize;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    padding: 0 2px;
}

.team-remove-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 0.65rem;
    cursor: pointer;
    padding: 1px 3px;
    line-height: 1;
    border-radius: 3px;
    transition: color 0.15s, background 0.15s;
}

.team-remove-btn:hover {
    color: #ef4444;
    background: rgba(239,68,68,0.1);
}

/* ── Add to team button ── */
.team-action-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 1.25rem;
}

.team-action-btn {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 500;
    padding: 0.5rem 1.25rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.team-action-btn:hover {
    background: var(--surface-2);
    border-color: #444;
}

.team-action-btn--in-team {
    border-color: #3b82f6;
    color: #3b82f6;
}

.team-action-btn--in-team:hover {
    background: rgba(59,130,246,0.08);
    border-color: #ef4444;
    color: #ef4444;
}

.team-action-full {
    font-size: 0.78rem;
    color: var(--muted);
    padding: 0.5rem 0;
}

/* ── Team matchup analysis ── */
.analysis-hint {
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 1rem;
}

.analysis-hint--neutral {
    font-style: italic;
}

.matchup-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.matchup-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    transition: border-color 0.15s;
}

.matchup-row--best {
    border-color: #f7d02c44;
}

.matchup-crown {
    color: #f7d02c;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.matchup-sprite {
    width: 40px;
    height: 40px;
    object-fit: contain;
    image-rendering: pixelated;
    flex-shrink: 0;
}

.matchup-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.matchup-name {
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: capitalize;
}

.matchup-type {
    font-size: 0.72rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.matchup-mult {
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.mult-x4   { background: rgba(239,68,68,0.15);  color: #ef4444; }
.mult-x2   { background: rgba(249,115,22,0.15); color: #f97316; }
.mult-x1   { background: var(--surface-1);      color: var(--muted); }
.mult-half { background: rgba(59,130,246,0.15); color: #3b82f6; }
.mult-zero { background: rgba(255,255,255,0.05); color: var(--border); }

/* ── Responsive team panel ── */
@media (max-width: 600px) {
    .team-slots { grid-template-columns: repeat(6, 1fr); gap: 0.3rem; }
    .team-sprite { max-width: 40px; }
    .team-slot-name { font-size: 0.45rem; }
}

/* ── Blazor error UI ── */
#blazor-error-ui {
    background: #1a0000;
    border-top: 1px solid #5a0000;
    color: #f0f0f0;
    font-size: 0.85rem;
    padding: 0.75rem 1rem;
    position: fixed;
    bottom: 0;
    width: 100%;
    display: none;
    z-index: 1000;
}

#blazor-error-ui .reload { color: #f97316; margin-left: 0.5rem; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* ── Responsive ── */
@media (max-width: 600px) {
    .pokemon-artwork { width: 160px; height: 160px; }
    .stat-row { grid-template-columns: 76px 34px 1fr; }
    .evo-chain { gap: 0.25rem; }
    .evo-card { min-width: 72px; padding: 0.5rem 0.6rem; }
    .evo-sprite { width: 52px; height: 52px; }
}
