/*
Theme Name: Pokopia
Theme URI: https://pokopia.danielk.am
Description: Block theme for the Pokopia wiki — Pokémon, items, habitats, recipes, with cross-linked taxonomies. Shadcn-style design system.
Author: Daniel Kam
Version: 1.1.0
Requires at least: 6.5
Requires PHP: 8.0
Text Domain: pokopia
*/

/* ================================================================ *
 * Design tokens — Shadcn-inspired (light + dark via media query)    *
 * ================================================================ */
:root {
    --background: hsl(20 14.3% 99%);
    --foreground: hsl(20 14.3% 4.1%);
    --card: hsl(0 0% 100%);
    --card-foreground: hsl(20 14.3% 4.1%);
    --popover: hsl(0 0% 100%);
    --popover-foreground: hsl(20 14.3% 4.1%);
    --primary: hsl(346.8 77.2% 49.8%);
    --primary-foreground: hsl(355.7 100% 97.3%);
    --secondary: hsl(60 4.8% 95.9%);
    --secondary-foreground: hsl(24 9.8% 10%);
    --muted: hsl(60 4.8% 95.9%);
    --muted-foreground: hsl(25 5.3% 44.7%);
    --accent: hsl(60 4.8% 95.9%);
    --accent-foreground: hsl(24 9.8% 10%);
    --destructive: hsl(0 84.2% 60.2%);
    --destructive-foreground: hsl(60 9.1% 97.8%);
    --border: hsl(20 5.9% 90%);
    --input: hsl(20 5.9% 90%);
    --ring: hsl(346.8 77.2% 49.8%);
    --radius: 0.5rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --background: hsl(20 14.3% 4.1%);
        --foreground: hsl(60 9.1% 97.8%);
        --card: hsl(24 9.8% 10%);
        --card-foreground: hsl(60 9.1% 97.8%);
        --popover: hsl(20 14.3% 4.1%);
        --popover-foreground: hsl(60 9.1% 97.8%);
        --primary: hsl(346.8 77.2% 49.8%);
        --primary-foreground: hsl(355.7 100% 97.3%);
        --secondary: hsl(12 6.5% 15.1%);
        --secondary-foreground: hsl(60 9.1% 97.8%);
        --muted: hsl(12 6.5% 15.1%);
        --muted-foreground: hsl(24 5.4% 63.9%);
        --accent: hsl(12 6.5% 15.1%);
        --accent-foreground: hsl(60 9.1% 97.8%);
        --border: hsl(12 6.5% 15.1%);
        --input: hsl(12 6.5% 15.1%);
    }
}

/* ================================================================ *
 * Base                                                              *
 * ================================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
    background: var(--background);
    color: var(--foreground);
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    font-size: 15px;
    line-height: 1.6;
    margin: 0;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--primary); }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3, h4 { color: var(--foreground); font-weight: 600; line-height: 1.3; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.875rem; letter-spacing: -0.025em; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; }
ul, ol { padding-left: 1.25rem; }
input, button { font-family: inherit; }

/* ================================================================ *
 * Header                                                            *
 * ================================================================ */
.pp-header {
    position: sticky; top: 0; z-index: 50;
    background: hsl(0 0% 100% / 0.85);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
}
@media (prefers-color-scheme: dark) {
    .pp-header { background: hsl(20 14.3% 4.1% / 0.85); }
}
.pp-header .pp-logo {
    display: flex; align-items: center; gap: 0.625rem;
    font-weight: 700; font-size: 1.0625rem;
    color: var(--foreground);
    letter-spacing: -0.01em;
}
.pp-header .pp-logo:hover { color: var(--primary); }
.pp-header .pp-logo img {
    width: 32px; height: 32px;
    border-radius: var(--radius); object-fit: contain;
}
.pp-header .wp-block-search {
    flex: 1; max-width: 320px; margin-left: auto;
}
.pp-header .wp-block-search input {
    width: 100%;
    height: 36px;
    padding: 0 0.875rem;
    border: 1px solid var(--input);
    border-radius: var(--radius);
    background: var(--background);
    color: var(--foreground);
    font-size: 0.875rem;
    transition: border-color 150ms, box-shadow 150ms;
}
.pp-header .wp-block-search input:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 3px hsl(346.8 77.2% 49.8% / 0.15);
}
.pp-header .pp-nav { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.pp-header .pp-nav a, .pp-header .wp-block-navigation a {
    color: var(--muted-foreground);
    padding: 0.375rem 0.75rem;
    border-radius: calc(var(--radius) - 2px);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 150ms, color 150ms;
}
.pp-header .pp-nav a:hover, .pp-header .wp-block-navigation a:hover,
.pp-header .pp-nav a.active {
    background: var(--accent);
    color: var(--accent-foreground);
}

/* ================================================================ *
 * Container & layout                                                *
 * ================================================================ */
.pp-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}
@media (max-width: 640px) {
    .pp-container { padding: 1rem; }
    .pp-header { padding: 0.625rem 1rem; }
}

/* ================================================================ *
 * Cards & grids                                                     *
 * ================================================================ */
.pokopia-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.875rem;
    margin: 0.5rem 0 1.5rem;
}
.pokopia-card {
    display: flex; flex-direction: column;
    background: var(--card);
    color: var(--card-foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.875rem;
    transition: transform 150ms, box-shadow 150ms, border-color 150ms;
    text-decoration: none;
}
.pokopia-card:hover {
    transform: translateY(-1px);
    border-color: hsl(20 5.9% 80%);
    box-shadow: 0 4px 12px -2px hsl(20 14.3% 4.1% / 0.08);
    color: var(--card-foreground);
}
.pokopia-card .pp-card-row {
    display: flex; align-items: center; gap: 0.75rem;
}
.pokopia-card .pp-card-img {
    width: 56px; height: 56px;
    object-fit: contain;
    background: var(--secondary);
    border-radius: calc(var(--radius) - 2px);
    padding: 4px;
    flex-shrink: 0;
}
.pokopia-card .pp-card-title {
    font-weight: 600; font-size: 0.9375rem;
    color: var(--card-foreground);
    line-height: 1.3;
}
.pokopia-card .pp-card-meta {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-top: 0.125rem;
    text-transform: capitalize;
}

/* ================================================================ *
 * Chips (taxonomy tags)                                             *
 * ================================================================ */
.pp-chips { display: flex; flex-wrap: wrap; gap: 0.375rem; margin: 0.5rem 0; }
.pp-chip {
    display: inline-flex; align-items: center;
    background: var(--secondary);
    color: var(--secondary-foreground);
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid transparent;
    text-decoration: none;
    transition: background 150ms, color 150ms;
    white-space: nowrap;
}
.pp-chip:hover { background: var(--primary); color: var(--primary-foreground); }

/* Type-tinted chips */
.pp-chip-fire     { background: hsl(0 86% 95%);   color: hsl(0 70% 35%); }
.pp-chip-water    { background: hsl(213 90% 95%); color: hsl(213 70% 35%); }
.pp-chip-grass    { background: hsl(140 60% 92%); color: hsl(140 65% 25%); }
.pp-chip-electric { background: hsl(48 96% 90%);  color: hsl(35 90% 30%); }
.pp-chip-ice      { background: hsl(195 95% 92%); color: hsl(200 80% 30%); }
.pp-chip-fairy    { background: hsl(330 80% 95%); color: hsl(330 70% 40%); }
.pp-chip-fighting { background: hsl(20 95% 92%);  color: hsl(15 75% 35%); }
.pp-chip-poison   { background: hsl(280 65% 93%); color: hsl(275 55% 35%); }
.pp-chip-ground   { background: hsl(35 60% 90%);  color: hsl(30 60% 30%); }
.pp-chip-flying   { background: hsl(225 75% 93%); color: hsl(230 60% 35%); }
.pp-chip-psychic  { background: hsl(320 80% 94%); color: hsl(330 70% 40%); }
.pp-chip-bug      { background: hsl(80 60% 90%);  color: hsl(80 65% 25%); }
.pp-chip-rock     { background: hsl(35 20% 88%);  color: hsl(30 25% 30%); }
.pp-chip-ghost    { background: hsl(265 50% 92%); color: hsl(270 50% 35%); }
.pp-chip-dragon   { background: hsl(265 60% 92%); color: hsl(270 65% 35%); }
.pp-chip-dark     { background: hsl(220 8% 88%);  color: hsl(220 15% 25%); }
.pp-chip-steel    { background: hsl(220 15% 90%); color: hsl(220 20% 30%); }
.pp-chip-normal   { background: hsl(35 12% 88%);  color: hsl(30 15% 30%); }

/* ================================================================ *
 * Single page hero                                                  *
 * ================================================================ */
.pp-hero {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 1.5rem;
    align-items: start;
    padding: 1rem 0 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}
@media (max-width: 640px) {
    .pp-hero { grid-template-columns: 1fr; gap: 1rem; }
}
.pp-hero img.pp-hero-img {
    width: 100%; aspect-ratio: 1 / 1; max-height: 200px;
    object-fit: contain;
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 2px);
    padding: 12px;
}
.pp-hero h1 { margin: 0 0 0.5rem 0; }
.pp-hero .pp-hero-meta { color: var(--muted-foreground); font-size: 0.9375rem; }

/* ================================================================ *
 * Section title                                                     *
 * ================================================================ */
.pp-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.075em;
    color: var(--muted-foreground);
    margin: 1.5rem 0 0.625rem;
}
.pp-section-title:first-child { margin-top: 0.5rem; }

/* ================================================================ *
 * Meta list                                                         *
 * ================================================================ */
.pp-meta-list {
    list-style: none; padding: 0; margin: 0.5rem 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.25rem 1rem;
}
.pp-meta-list li {
    display: grid;
    grid-template-columns: minmax(140px, 200px) 1fr;
    gap: 1rem;
    align-items: baseline;
    font-size: 0.875rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}
.pp-meta-list li:last-child { border-bottom: 0; }
.pp-meta-list .pp-label {
    font-weight: 500;
    color: var(--muted-foreground);
    text-transform: capitalize;
}
.pp-meta-list span:not(.pp-label) { color: var(--foreground); }
@media (max-width: 540px) {
    .pp-meta-list li { grid-template-columns: 1fr; gap: 0.125rem; padding: 0.5rem 0; }
}

/* Inline farm card (used on Pokemon page) */
.pp-farm-inline {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin: 0.5rem 0 0.875rem;
}
.pp-farm-inline-head {
    display: flex; align-items: baseline; gap: 0.625rem; flex-wrap: wrap;
    margin-bottom: 0.5rem;
}
.pp-farm-inline-head h4 {
    font-size: 1rem; font-weight: 600; margin: 0;
}
.pp-farm-inline-head h4 a { color: var(--foreground); }
.pp-farm-inline-head h4 a:hover { color: var(--primary); }
.pp-farm-inline-meta {
    color: var(--muted-foreground); font-size: 0.8125rem;
    margin: 0.25rem 0 0.5rem;
}
.pp-farm-inline-why {
    font-size: 0.875rem; line-height: 1.55;
    color: var(--foreground); margin: 0.375rem 0 0;
}
.pp-farm-inline-row {
    display: grid; grid-template-columns: 140px 1fr; gap: 1rem;
    font-size: 0.875rem; padding: 0.25rem 0;
}
.pp-farm-inline-row .pp-label {
    font-weight: 500; color: var(--muted-foreground); text-transform: capitalize;
}
@media (max-width: 540px) {
    .pp-farm-inline-row { grid-template-columns: 1fr; gap: 0.125rem; }
}

/* Quick tips card */
.pp-quick-tips {
    background: var(--primary-foreground, #fff5f7);
    border: 1px solid hsl(346.8 77.2% 49.8% / 0.2);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin: 0.75rem 0 1rem;
}
.pp-quick-tips-head {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.075em;
    color: var(--primary);
    margin-bottom: 0.5rem;
}
.pp-quick-tips .pp-meta-list {
    border: 0; padding: 0; background: transparent;
}
.pp-quick-tips .pp-meta-list li {
    border-bottom: 1px dashed hsl(346.8 77.2% 49.8% / 0.15);
    padding: 0.375rem 0;
}
.pp-quick-tips .pp-meta-list li:last-child { border-bottom: 0; }

/* Grouped sections (loved items by category, items archive) */
.pp-grouped-section {
    margin: 1rem 0;
}
.pp-grouped-section h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 1rem 0 0.5rem;
    color: var(--foreground);
    display: flex; align-items: baseline; gap: 0.5rem;
}
.pp-grouped-section h4 .pp-count {
    color: var(--muted-foreground);
    font-weight: 400;
    font-size: 0.75rem;
}

/* ================================================================ *
 * Native WP elements                                                *
 * ================================================================ */
.wp-block-post-title { margin: 0; }
.wp-block-query-title { margin-bottom: 0.5rem; }
.wp-block-query-pagination {
    display: flex; gap: 0.5rem; justify-content: center;
    margin: 1.5rem 0;
}
.wp-block-query-pagination a, .wp-block-query-pagination span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; height: 36px;
    padding: 0 0.625rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
    color: var(--foreground);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 150ms, border-color 150ms;
}
.wp-block-query-pagination a:hover {
    background: var(--accent);
    border-color: var(--ring);
}
.wp-block-query-pagination .current { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }

/* Hide page admin bar on mobile */
@media (max-width: 640px) {
    #wpadminbar { position: fixed; }
}

/* ================================================================ *
 * Front-page sections                                               *
 * ================================================================ */
.pp-front-hero {
    text-align: center;
    padding: 2.5rem 1rem 1.5rem;
}
.pp-front-hero h1 {
    font-size: 2.25rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--foreground), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.pp-front-hero p {
    color: var(--muted-foreground);
    font-size: 1rem;
    max-width: 560px;
    margin: 0 auto;
}
.pp-front-section-header {
    display: flex; align-items: baseline; justify-content: space-between;
    margin: 2rem 0 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}
.pp-front-section-header h2 {
    font-size: 1.25rem;
    margin: 0;
}
.pp-front-section-header a {
    color: var(--primary);
    font-size: 0.8125rem;
    font-weight: 500;
}
.pp-front-section-header a:hover { text-decoration: underline; }

/* ================================================================ *
 * Footer                                                            *
 * ================================================================ */
.pp-footer {
    border-top: 1px solid var(--border);
    padding: 2rem 1.5rem;
    text-align: center;
    color: var(--muted-foreground);
    font-size: 0.8125rem;
    margin-top: 3rem;
}

/* ================================================================ *
 * Tables (used in mechanics pages)                                  *
 * ================================================================ */
.wp-block-table table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 0.875rem;
}
.wp-block-table th, .wp-block-table td {
    padding: 0.625rem 0.875rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.wp-block-table th {
    background: var(--secondary);
    font-weight: 600;
    color: var(--secondary-foreground);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.wp-block-table tr:last-child td { border-bottom: none; }

/* ================================================================ *
 * Prose for mechanics / page content                                *
 * ================================================================ */
.pp-container .wp-block-paragraph,
.pp-container > p {
    line-height: 1.65;
    color: var(--foreground);
    margin-bottom: 1rem;
}
.pp-container .wp-block-list, .pp-container ul, .pp-container ol {
    margin-bottom: 1rem;
}
.pp-container li { margin-bottom: 0.25rem; }

/* ================================================================ *
 * Misc                                                              *
 * ================================================================ */
.has-muted-color { color: var(--muted-foreground) !important; }
.has-primary-soft-background-color { background: var(--secondary) !important; }
