/* Pokemon League Tools — shared design system
   Playful TCG-inspired look. No official Pokemon art/branding used —
   accent colors are generic elemental hues, not game icons/symbols. */

:root {
  --color-bg: #f4f1ea;
  --color-surface: #ffffff;
  --color-text: #1f2430;
  --color-text-muted: #62687a;
  --color-border: #e1dccf;
  --color-primary: #4a3f9e;
  --color-primary-dark: #382f79;
  --color-primary-contrast: #ffffff;
  --color-secondary: #b5482f;
  --color-link: #4a3f9e;

  /* Status colors are used as TEXT on their -bg tints, so they're chosen to
     hit WCAG AA (4.5:1) there, not as bright "brand" hues. -danger-solid is
     the filled-button face (white text); -control-border is the boundary of
     form fields/switches, which needs 3:1 (WCAG 1.4.11) unlike the decorative
     card --color-border. */
  --color-success: #1e7a43;
  --color-success-bg: #e5f6ec;
  --color-warning: #8a5a00;
  --color-warning-bg: #fbf0dc;
  --color-danger: #b42d2d;
  --color-danger-bg: #fbe6e6;
  --color-danger-solid: #b42d2d;
  --color-control-border: #7b8190;

  --color-fire: #e8562c;
  --color-water: #3b82c4;
  --color-grass: #4caf6b;
  --color-lightning: #e0b400;
  --color-psychic: #9b59b6;
  --color-fighting: #8d5b3a;
  --color-colorless: #9aa0a6;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow-card: 0 2px 4px rgba(20, 16, 8, 0.06), 0 8px 20px rgba(20, 16, 8, 0.08);
  --shadow-card-hover: 0 4px 8px rgba(20, 16, 8, 0.08), 0 14px 28px rgba(20, 16, 8, 0.12);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #16151d;
    --color-surface: #211f2b;
    --color-text: #f0eef7;
    --color-text-muted: #a5a1b8;
    --color-border: #34324420;
    --color-border: #34324a;
    --color-primary: #8b7ef0;
    --color-primary-dark: #a89bff;
    --color-primary-contrast: #16151d;
    --color-secondary: #e08a6f;
    --color-link: #8b7ef0;

    --color-success: #4cc27e;
    --color-success-bg: #143024;
    --color-warning: #d99a1f;
    --color-warning-bg: #332508;
    --color-danger: #ff8080;
    --color-danger-bg: #351616;
    --color-control-border: #8c89a3;
    --shadow-card: 0 2px 4px rgba(0, 0, 0, 0.3), 0 8px 20px rgba(0, 0, 0, 0.35);
    --shadow-card-hover: 0 4px 8px rgba(0, 0, 0, 0.35), 0 14px 28px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  min-height: 100%;
}

body {
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

h1, h2, h3 {
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

h1 { font-size: clamp(1.6rem, 2.5vw, 2.2rem); margin: 0 0 6px; }
h2 { font-size: 1.3rem; margin: 0 0 12px; }
h3 { font-size: 1.05rem; margin: 0 0 8px; }

p.subtitle {
  color: var(--color-text-muted);
  margin: 0 0 24px;
}

a { color: var(--color-link); }

/* ---------- Nav ---------- */

.site-nav {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-nav__inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 20px;
  flex-wrap: wrap;
}

.site-nav__brand {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--color-text);
  text-decoration: none;
  margin-right: 12px;
  white-space: nowrap;
}

.site-nav__brand span {
  color: var(--color-link);
}

.site-nav__links {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

.site-nav__links a {
  text-decoration: none;
  color: var(--color-text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.site-nav__links a:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.site-nav__links a.active {
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  box-shadow: inset 0 -3px 0 var(--color-primary-contrast);
}

.site-nav__dropdown {
  position: relative;
}

.site-nav__dropdown-toggle {
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-text-muted);
  background: none;
  border: 0;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}

.site-nav__dropdown-toggle:hover,
.site-nav__dropdown.open .site-nav__dropdown-toggle {
  background: var(--color-bg);
  color: var(--color-text);
}

.site-nav__dropdown-toggle.active {
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  box-shadow: inset 0 -3px 0 var(--color-primary-contrast);
}

.site-nav__caret {
  font-size: 0.7em;
}

.site-nav__dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 100%;
  margin-top: 4px;
  padding: 4px;
  flex-direction: column;
  gap: 2px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
}

.site-nav__dropdown.open .site-nav__dropdown-menu {
  display: flex;
}

/* ---------- Accessibility helpers ---------- */

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -48px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  font-weight: 700;
  border-radius: var(--radius-sm);
  text-decoration: none;
}
.skip-link:focus { top: 8px; }

.heading-sm { font-size: 1.05rem; margin: 0 0 8px; }

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

/* ---------- Footer ---------- */

.site-footer {
  text-align: center;
  padding: 12px 20px 20px;
  font-size: 0.72rem;
}

.site-footer a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.site-footer a:hover,
.site-footer a.active {
  text-decoration: underline;
}

/* ---------- Card panel ---------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px;
}

.card + .card { margin-top: 16px; }

.card--accent-top {
  border-top: 5px solid var(--accent, var(--color-primary));
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}

/* ---------- Buttons ---------- */

button, .btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 10px 18px;
  cursor: pointer;
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  transition: transform 0.05s ease, box-shadow 0.15s ease;
}

button:hover, .btn:hover { box-shadow: var(--shadow-card-hover); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.btn--ghost {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-control-border);
}

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

.btn--danger { background: var(--color-danger-solid); color: #fff; }
.btn--sm { padding: 6px 12px; font-size: 0.8rem; }

/* ---------- Forms ---------- */

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

input[type="text"], input[type="number"], input[type="email"],
input[type="password"], input[type="search"], select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-control-border);
  background: var(--color-bg);
  color: var(--color-text);
}

a:focus-visible, button:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--color-link);
  outline-offset: 2px;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--color-link);
  outline-offset: 1px;
}

.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 160px; }

/* ---------- Badges / status ---------- */

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 9px;
  border-radius: 999px;
}

.badge--success { background: var(--color-success-bg); color: var(--color-success); }
.badge--warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge--danger  { background: var(--color-danger-bg); color: var(--color-danger); }

.tag-fire       { color: var(--color-fire); }
.tag-water      { color: var(--color-water); }
.tag-grass      { color: var(--color-grass); }
.tag-lightning  { color: var(--color-lightning); }
.tag-psychic    { color: var(--color-psychic); }
.tag-fighting   { color: var(--color-fighting); }
.tag-colorless  { color: var(--color-colorless); }

/* ---------- Utility ---------- */

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.muted { color: var(--color-text-muted); }
.text-center { text-align: center; }
.hidden { display: none !important; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--color-border); font-size: 0.9rem; }
.table-scroll { overflow-x: auto; }

@media (max-width: 480px) {
  th, td { padding: 8px 6px; font-size: 0.82rem; }
}

th { color: var(--color-text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }

.th-sort-btn {
  background: none; border: none; padding: 0; margin: 0; cursor: pointer;
  color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit;
  white-space: nowrap;
}
.th-sort-btn:hover { color: var(--color-text); }
.th-sort-btn.active { color: var(--color-link); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-muted);
}
