:root {
    --primary: #ef5350;
    --primary-dark: #d32f2f;
    --bg: #fdfdfd;
    --card-bg: #ffffff;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --border: #eee;
    --accent: #4dabf7;
    --header-bg: linear-gradient(180deg, #fff, #f9f9f9);
    --font-main: 'Fira Sans', sans-serif;
    --font-mono: 'Fira Code', monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1a1a1a;
        --card-bg: #2d2d2d;
        --text: #e0e0e0;
        --text-light: #a0a0a0;
        --border: #3d3d3d;
        --accent: #74c0fc;
        --header-bg: linear-gradient(180deg, #2d2d2d, #1a1a1a);
    }
}

body {
    font-family: var(--font-main);
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}

/* Header/Search */
header {
    background: var(--primary);
    color: white;
    padding: 2rem 1rem;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

header h1 {
    margin: 0;
    font-weight: 700;
    font-size: 2.5rem;
    color: white;
}

header nav {
    font-size: 1rem;
}

header nav a {
    color: white;
    text-decoration: none;
    background: rgba(0,0,0,0.2);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    transition: background 0.2s;
}

header nav a:hover {
    background: rgba(0,0,0,0.4);
}

/* Language switch: top-right, overlays the header (0 layout height) and scrolls away */
.lang-switch {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    z-index: 1000;
}

/* Search box: stays at the top while scrolling */
.search-sticky {
    position: sticky;
    top: 0;
    z-index: 900;
    /* Pull the pill up over the red top bar (no padding trick: margin and
       offset inside the same box would cancel out). No background: when
       docked, the pill floats alone at the very top. */
    margin-top: -1.8rem;
    display: flex;
    justify-content: center;
}

.lang-switch a {
    display: inline-block;
    color: white;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9rem;
    background: rgba(0,0,0,0.35);
    padding: 0.55rem 1.1rem;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    transition: background 0.2s;
}

.lang-switch a:hover {
    background: rgba(0,0,0,0.5);
}

.search-box input {
    padding: 0.8rem 1.5rem;
    width: 300px;
    max-width: 80vw;
    border-radius: 25px;
    border: none;
    font-size: 1rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    background: white;
}

/* Index Grid */
#pokemon-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
    gap: 0.9rem;
    padding: 1.25rem;
    max-width: 1400px;
    margin: 0 auto;
}

.pokemon-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 0.8rem 0.5rem;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--border);
}

.pokemon-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
}

.pokemon-card a {
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.pokemon-card img {
    width: 78px;
    height: 78px;
    filter: drop-shadow(0 4px 4px rgba(0,0,0,0.1));
}

.pkmn-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
}

.pkmn-id {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-light);
}

/* Pokemon Detail Page */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}

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

.nav-btn {
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 700;
}

.nav-btn.disabled {
    background: #ccc;
    cursor: not-allowed;
}

.home-link {
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
}

.lang-link {
    text-decoration: none;
    color: var(--primary);
    font-size: 0.9rem;
}

.pkmn-header {
    position: relative;
    overflow: hidden;
    text-align: center;
    padding: 1.25rem 1rem;
    background: var(--header-bg);
}

.header-blur {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.header-blur img {
    width: 55%;
    min-width: 280px;
    max-width: 560px;
    filter: blur(40px) saturate(2.3) contrast(1.05);
    opacity: 0.3;
    transform: scale(1.1);
}

/* Second, slowly orbiting copy for a subtle living backdrop */
.header-blur--orbit img {
    filter: blur(30px) saturate(2.4);
    animation: header-orbit 30s linear infinite;
    will-change: transform;
}

@keyframes header-orbit {
    0%, 100% { transform: scale(1.15) translate(58px, 0); }
    25%      { transform: scale(1.15) translate(0, 58px); }
    50%      { transform: scale(1.15) translate(-58px, 0); }
    75%      { transform: scale(1.15) translate(0, -58px); }
}

@media (prefers-reduced-motion: reduce) {
    .header-blur--orbit img { animation: none; }
}

@media (prefers-color-scheme: dark) {
    .header-blur img {
        opacity: 0.3;
        mix-blend-mode: screen;
        filter: blur(40px) saturate(2.1);
    }
}

.pkmn-header > *:not(.header-blur) {
    position: relative;
    z-index: 1;
}

.pkmn-title {
    font-size: 3rem;
    margin: 0;
    font-weight: 700;
    color: var(--text);
    text-align: center;
}

/* The localized name centers on its own width; the English annotation is
   absolutely positioned next to it (zero layout width, overflows to the right) */
.loc-name {
    position: relative;
    display: inline-block;
    white-space: nowrap;
}

.eng-name {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 0.55ch;
    white-space: nowrap;
    font-weight: 300;
    font-size: 1.4rem;
    color: var(--text-light);
}

@media (max-width: 620px) {
    .eng-name { display: none; }
}

.pkmn-desc {
    max-width: 600px;
    margin: 1rem auto;
    color: var(--text);
    font-style: italic;
}

/* Legendary / mythical badges and types, right-aligned in the stats row */
.stat-tail {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.pkmn-meta-badges {
    display: flex;
    gap: 0.4rem;
}

.badge {
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: white;
}

.badge.legendary { background: #f1c40f; color: #000; }
.badge.mythical { background: #9b59b6; }

.pkmn-header-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin-top: 1rem;
}

.cry-wrapper {
    display: flex;
    align-items: center;
}

.external-links {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.external-links a {
    text-decoration: none;
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 700;
}

.pkmn-images {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    margin: 2rem 0;
}

/* Explicit cry button (small hit target, safe for touch scrolling) */
.cry-btn {
    width: 2.6rem;
    height: 2.6rem;
    flex: 0 0 auto;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--card-bg);
    font-size: 1.05rem;
    cursor: pointer;
    transition: background 0.15s;
}

.cry-btn:hover {
    background: var(--primary-light);
}

.img-wrapper {
    position: relative;
    background: var(--card-bg);
    border-radius: 20px;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
}

.main-artwork {
    width: 200px;
    height: 200px;
}

.shiny-sprite {
    width: 200px;
    height: 200px;
}

.lang-switcher {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.img-wrapper.shiny {
    opacity: 0.8;
}

.img-wrapper .label {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-light);
}

.pkmn-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1rem 2rem;
}

.pkmn-summary {
    width: 100%;
    margin-bottom: 1.75rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    align-items: start;
}

.compact-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 1rem;
    background: var(--card-bg);
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
    font-family: var(--font-mono);
}

.stat {
    display: flex;
    gap: 0.4rem;
    font-size: 0.9rem;
    color: var(--text);
}

.stat span {
    color: var(--text-light);
}

.pkmn-types {
    display: flex;
    gap: 0.5rem;
}

.compact-stats .stat.total {
    margin-left: 0.75rem;
    padding-left: 0.9rem;
    border-left: 1px solid var(--border);
    color: var(--accent);
}

.type-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    text-shadow: none;
}

.type-icon {
    width: 14px;
    height: 14px;
}

/* Type colors */
.type-badge[data-type="normal"] { background-color: #A8A77A; }
.type-badge[data-type="fire"] { background-color: #EE8130; }
.type-badge[data-type="water"] { background-color: #6390F0; }
.type-badge[data-type="grass"] { background-color: #7AC74C; }
.type-badge[data-type="electric"] { background-color: #F7D02C; color: #333; }
.type-badge[data-type="ice"] { background-color: #96D9D6; }
.type-badge[data-type="fighting"] { background-color: #C22E28; }
.type-badge[data-type="poison"] { background-color: #A33EA1; }
.type-badge[data-type="ground"] { background-color: #E2BF65; }
.type-badge[data-type="flying"] { background-color: #A98FF3; }
.type-badge[data-type="psychic"] { background-color: #F95587; }
.type-badge[data-type="bug"] { background-color: #A6B91A; }
.type-badge[data-type="rock"] { background-color: #B6A136; }
.type-badge[data-type="ghost"] { background-color: #735797; }
.type-badge[data-type="dragon"] { background-color: #6830CF; }
.type-badge[data-type="dark"] { background-color: #705746; }
.type-badge[data-type="steel"] { background-color: #B7B7CE; }
.type-badge[data-type="fairy"] { background-color: #EC8FE6; }

/* Damage multiplier table */
.type-matchups {
    background: var(--card-bg);
    padding: 0.9rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
    margin-bottom: 1.75rem;
}

.matchup-title {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    color: var(--text);
}

.matchup-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.35rem;
}

@media (max-width: 760px) {
    .matchup-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 440px) {
    .matchup-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.matchup-col {
    border-radius: 8px;
    padding: 0.3rem 0.4rem;
}

.matchup-colhead {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.matchup-types {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    align-items: center;
}

.mini-type {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.05rem 0.35rem;
    border-radius: 5px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text);
}

.mini-type .type-icon {
    width: 11px;
    height: 11px;
}

.matchup-empty {
    color: var(--text-light);
    opacity: 0.6;
}

.matchup-col.strong  { background: rgba(192,27,27,0.22);  }
.matchup-col.strong .matchup-colhead { color: #c01b1b; }
.matchup-col.weak    { background: rgba(238,121,48,0.16); }
.matchup-col.weak .matchup-colhead   { color: #e2711d; }
.matchup-col.resist  { background: rgba(56,142,60,0.14);  }
.matchup-col.resist .matchup-colhead { color: #388e3c; }
.matchup-col.low     { background: rgba(27,94,32,0.16);   }
.matchup-col.low .matchup-colhead    { color: #1b5e20; }
.matchup-col.neutral { background: rgba(127,140,141,0.10); opacity: 0.75; }
.matchup-col.immune  { background: rgba(70,130,180,0.14); border: 1px dashed var(--accent); }
.matchup-col.immune .matchup-colhead { color: var(--accent); }

.info-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem 1.5rem;
    background: var(--card-bg);
    padding: 0.9rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
}

.info-item {
    font-size: 0.95rem;
    color: var(--text);
    min-width: 0;
}

.variety-link,
.variety-link:link,
.variety-link:visited {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

.variety-link:hover {
    text-decoration: underline;
}

.ability-tag {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    margin-right: 0.3rem;
    background: var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text);
}

.ability-tag.hidden {
    opacity: 0.6;
    font-style: italic;
}

/* Evolution Line */
.evolution-section {
    margin-bottom: 1.75rem;
}

.section-title {
    text-align: center;
    margin-bottom: 1rem;
    color: var(--text);
}

.evolution-section {
    margin-bottom: 1.75rem;
}

.evolution-chain {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 0.6rem 0 0.3rem;
}

.evo-node {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}

.evo-children {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.evo-label {
    display: inline-block;
    padding: 0.4rem 0.9rem;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 10px;
    transition: all 0.2s;
}

.evo-node.is-current > .evo-label,
.evo-node.is-current > .evo-label .evo-link {
    font-weight: 800;
}

.evo-link {
    text-decoration: none;
    color: var(--text);
    font-weight: 400;
}

.evo-arrow {
    font-weight: 700;
    color: var(--text-light);
    font-size: 1.15rem;
}

/* Moves Table */
.move-section {
    --tc1: transparent;
    --tc2: transparent;
    background: var(--card-bg);
    padding: 1rem 1.25rem 1.15rem;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
}

/* Type colors (shared with type badges) – used for a subtle table tint */
.move-section[data-prim-type="normal"]         { --tc1: #A8A77A; }
.move-section[data-prim-type="fire"]           { --tc1: #EE8130; }
.move-section[data-prim-type="water"]          { --tc1: #6390F0; }
.move-section[data-prim-type="grass"]          { --tc1: #7AC74C; }
.move-section[data-prim-type="electric"]       { --tc1: #F7D02C; }
.move-section[data-prim-type="ice"]            { --tc1: #96D9D6; }
.move-section[data-prim-type="fighting"]       { --tc1: #C22E28; }
.move-section[data-prim-type="poison"]         { --tc1: #A33EA1; }
.move-section[data-prim-type="ground"]         { --tc1: #E2BF65; }
.move-section[data-prim-type="flying"]         { --tc1: #A98FF3; }
.move-section[data-prim-type="psychic"]        { --tc1: #F95587; }
.move-section[data-prim-type="bug"]            { --tc1: #A6B91A; }
.move-section[data-prim-type="rock"]           { --tc1: #B6A136; }
.move-section[data-prim-type="ghost"]          { --tc1: #735797; }
.move-section[data-prim-type="dragon"]         { --tc1: #6830CF; }
.move-section[data-prim-type="dark"]           { --tc1: #705746; }
.move-section[data-prim-type="steel"]          { --tc1: #B7B7CE; }
.move-section[data-prim-type="fairy"]          { --tc1: #EC8FE6; }
.move-section[data-sec-type="normal"]          { --tc2: #A8A77A; }
.move-section[data-sec-type="fire"]            { --tc2: #EE8130; }
.move-section[data-sec-type="water"]           { --tc2: #6390F0; }
.move-section[data-sec-type="grass"]           { --tc2: #7AC74C; }
.move-section[data-sec-type="electric"]        { --tc2: #F7D02C; }
.move-section[data-sec-type="ice"]             { --tc2: #96D9D6; }
.move-section[data-sec-type="fighting"]        { --tc2: #C22E28; }
.move-section[data-sec-type="poison"]          { --tc2: #A33EA1; }
.move-section[data-sec-type="ground"]          { --tc2: #E2BF65; }
.move-section[data-sec-type="flying"]          { --tc2: #A98FF3; }
.move-section[data-sec-type="psychic"]         { --tc2: #F95587; }
.move-section[data-sec-type="bug"]             { --tc2: #A6B91A; }
.move-section[data-sec-type="rock"]            { --tc2: #B6A136; }
.move-section[data-sec-type="ghost"]           { --tc2: #735797; }
.move-section[data-sec-type="dragon"]          { --tc2: #6830CF; }
.move-section[data-sec-type="dark"]            { --tc2: #705746; }
.move-section[data-sec-type="steel"]           { --tc2: #B7B7CE; }
.move-section[data-sec-type="fairy"]           { --tc2: #EC8FE6; }

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem 2rem;
    margin-bottom: 0.85rem;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    gap: 1rem;
    background: var(--bg);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.filter-group label {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
}

.stat-group {
    display: flex;
    gap: 1rem;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    color: var(--text);
}

.control-group input {
    width: 60px;
    padding: 0.4rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: var(--font-mono);
    background: var(--bg);
    color: var(--text);
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th {
    text-align: left;
    padding: 0.5rem 0.9rem;
    color: var(--text-light);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.05rem;
}

td {
    padding: 0.5rem 0.9rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.move-row:hover {
    background-color: color-mix(in srgb, var(--tc1) 6%, transparent);
}

/* STAB moves: bold + stronger type tint */
.move-row.stab {
    background-color: color-mix(in srgb, var(--tc1) 10%, transparent);
}

.move-row.stab:hover {
    background-color: color-mix(in srgb, var(--tc1) 14%, transparent);
}

.move-row.stab .move-name {
    font-weight: 700;
}

.move-name {
    font-weight: 400;
}

.var-dmg {
    font-weight: 700;
    color: var(--accent);
    cursor: help;
}

.mt-icon {
    font-size: 0.9em;
    margin-left: 0.3rem;
    cursor: help;
}

.move-name a {
    color: var(--accent);
    text-decoration: none;
}

.move-name a:hover {
    text-decoration: underline;
}

.dpt-value {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--primary);
    font-size: 1.1rem;
}

footer {
    text-align: center;
    padding: 1.2rem 1rem 1.6rem;
    color: var(--text-light);
    font-size: 0.9rem;
}

footer .build-info {
    margin-top: 0.4rem;
    font-size: 0.75rem;
    opacity: 0.8;
}

footer a {
    color: inherit;
}

footer .disclaimer {
    margin-top: 0.8rem;
    font-size: 0.7rem;
    opacity: 0.7;
    max-width: 40rem;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 600px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }
    .pkmn-images {
        flex-direction: column;
        align-items: center;
    }
    .info-col {
        grid-template-columns: 1fr;
    }
    .controls {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }
}
