/* style.css: layout and colors for the search page */

:root {
  --background: #16181d;
  --surface: #1f232b;
  --border: #323844;
  --text: #e6e8ec;
  --muted: #9aa3b2;
  --accent: #e3350d;
  --error: #ff6b6b;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--background);
}

body {
  margin: 0;
}

header {
  padding: 1.5rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  text-align: center;
}

h1 {
  margin: 0 0 1rem;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  letter-spacing: 0.05em;
}

h1 a {
  color: var(--text);
  text-decoration: none;
}

/* The ASCII title shrinks on narrow screens so it never wraps or scrolls */
.ascii-title {
  display: inline-block;
  margin: 0;
  font-size: clamp(0.45rem, 1.6vw, 1rem);
  line-height: 1.15;
  font-weight: 400;
  text-align: left;
  color: var(--accent);
}

/* The search bar in the header */
#search-form {
  display: flex;
  gap: 0.5rem;
  max-width: 48rem;
  margin: 0 auto;
}

#search-input {
  flex: 1;
  padding: 0.7rem 0.9rem;
  font: 1rem ui-monospace, "Cascadia Mono", Consolas, monospace;
  color: var(--text);
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 6px;
}

#search-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  padding: 0 1.2rem;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

main {
  max-width: 64rem;
  margin: 0 auto;
  padding: 1rem;
}

/* The search that was run, shown above the results */
#status {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color: var(--muted);
}

#status.error {
  color: var(--error);
}

/* Lets the results table scroll sideways on narrow screens */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  color: var(--muted);
  font-weight: 600;
}

tbody tr:hover {
  background: var(--surface);
}

td.num {
  color: var(--muted);
}

/* Right-align the stat columns (4th onward) so numbers line up with their headers */
td.stat,
#results th:nth-child(n + 4) {
  text-align: right;
}

td.total {
  font-weight: 700;
}

/* Type badges */
.type {
  display: inline-block;
  min-width: 4.5rem;
  margin-right: 0.3rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
}

.type-normal { background: #9fa19f; }
.type-fire { background: #e62829; }
.type-water { background: #2980ef; }
.type-electric { background: #fac000; }
.type-grass { background: #3fa129; }
.type-ice { background: #3dcef3; }
.type-fighting { background: #ff8000; }
.type-poison { background: #9141cb; }
.type-ground { background: #915121; }
.type-flying { background: #81b9ef; }
.type-psychic { background: #ef4179; }
.type-bug { background: #91a119; }
.type-rock { background: #afa981; }
.type-ghost { background: #704170; }
.type-dragon { background: #5060e1; }
.type-dark { background: #624d4e; }
.type-steel { background: #60a1b8; }
.type-fairy { background: #ef70ef; }

/* Links in the results table */
td a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

td a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.type-stellar { background: linear-gradient(90deg, #40b5a5, #e8a838, #d24a8a); }

/* ===== Pokemon page ===== */

.pokemon-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin: 0.5rem 0 1.5rem;
}

.pokemon-header .num,
.pokemon-header .weight {
  color: var(--muted);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

.pokemon-name {
  margin: 0;
  font-size: 2rem;
}

.panel {
  margin-bottom: 1.25rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.abilities,
.legality {
  margin: 0;
  padding: 0;
  list-style: none;
}

.abilities li {
  padding: 0.2rem 0;
}

.note {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Stats table: compact, not full width */
.stats-table {
  width: auto;
  min-width: 20rem;
}

.stats-table th {
  text-align: left;
}

.stats-table th:nth-child(n + 2) {
  text-align: right;
}

td.muted {
  color: var(--muted);
}

.total-row th,
.total-row td {
  font-weight: 700;
}

/* Weakness grid: type badges with multipliers below, wrapping onto more rows when narrow */
.weakness-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.75rem, 1fr));
  gap: 0.3rem;
}

.weakness-cell {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.weakness-cell .type {
  min-width: 0;
  margin: 0;
  padding: 0.1rem 0;
  font-size: 0.62rem;
}

.multiplier {
  padding: 0.15rem 0;
  border-radius: 4px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.85rem;
}

.mult-4 { background: #8b1a1a; color: #fff; }
.mult-2 { background: #c0502a; color: #fff; }
.mult-1 { color: var(--muted); font-weight: 400; }
.mult-half { background: #2d6a3a; color: #fff; }
.mult-quarter { background: #1d4a28; color: #fff; }
.mult-immune { background: #3a3f4b; color: #fff; }

/* Legality badges, like Scryfall's format panel */
.legality {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 0.5rem;
}

.legality li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.legal-badge {
  min-width: 6rem;
  padding: 0.25rem 0;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
  color: #fff;
}

.legal-badge.legal { background: #5a8f5a; }
.legal-badge.not-legal { background: #6b6f78; }

/* Moves table */
.moves-table td.move-name {
  font-weight: 600;
  white-space: nowrap;
}

.moves-table td.effect {
  color: var(--muted);
  font-size: 0.85rem;
  min-width: 16rem;
}

.moves-table th:nth-child(n + 4):nth-child(-n + 6) {
  text-align: right;
}

/* ===== Site navigation under the search bar ===== */

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.site-nav a {
  padding: 0.3rem 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.site-nav a:hover {
  color: var(--text);
  border-color: var(--muted);
}

/* The link for the page you're on */
.site-nav a[aria-current="page"] {
  color: var(--text);
  border-color: var(--accent);
}

/* ===== Coming soon pages ===== */

.coming-soon {
  max-width: 36rem;
  padding-top: 3rem;
  text-align: center;
}

.coming-soon h2 {
  margin-bottom: 0.25rem;
}

/* ===== Syntax guide ===== */

.prose {
  max-width: 52rem;
  line-height: 1.6;
}

.prose h1 {
  margin-top: 0.5rem;
}

.prose h2 {
  margin-top: 2rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

.prose h3 {
  margin-top: 1.5rem;
}

.prose code {
  padding: 0.1rem 0.35rem;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.9em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.prose table {
  width: auto;
  margin: 0.75rem 0 1.25rem;
}

.prose th,
.prose td {
  text-align: left;
}

/* ===== Footer on every page ===== */

footer {
  max-width: 64rem;
  margin: 3rem auto 0;
  padding: 1.25rem 1rem 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  line-height: 1.5;
  text-align: center;
  color: var(--muted);
}

footer p {
  margin: 0.3rem 0;
}

footer a,
.prose a {
  color: var(--text);
}

footer a:hover,
.prose a:hover {
  color: var(--accent);
}

/* ===== Advanced search ===== */

.advanced {
  max-width: 48rem;
}

/* The search text the form builds */
.query-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem;
  margin: 1rem 0 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

#query-preview {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color: var(--text);
  word-break: break-word;
}

#query-preview.empty {
  color: var(--muted);
}

/* One row per category: label on the left, fields on the right */
.adv-row {
  display: grid;
  grid-template-columns: 9rem 1fr;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.adv-label {
  font-weight: 600;
}

.adv-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem;
}

.adv-fields select,
.adv-fields input {
  padding: 0.45rem 0.6rem;
  font: inherit;
  color: var(--text);
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.adv-fields input {
  flex: 1;
  min-width: 10rem;
}

/* Number inputs only need room for a few digits */
.adv-fields input.narrow {
  flex: 0 1 7rem;
  min-width: 5rem;
}

.adv-fields select:focus,
.adv-fields input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#advanced-submit {
  margin-top: 1.25rem;
  padding: 0.6rem 1.5rem;
}

/* On narrow screens, put the label above the fields */
@media (max-width: 34rem) {
  .adv-row {
    grid-template-columns: 1fr;
  }
}

/* Type picker: the colored type badges as buttons. Unpicked ones are dimmed. */
.type-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex-basis: 100%;
}

.type-choice {
  margin: 0;
  padding: 0.3rem 0.55rem;
  border: 2px solid transparent;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 0.45;
  cursor: pointer;
}

.type-choice:hover {
  opacity: 0.8;
}

/* With "is exactly" and two types picked, the others can't be clicked */
.type-choice:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

/* Included: full color with a white outline */
.type-choice[data-state="include"] {
  opacity: 1;
  border-color: var(--text);
}

/* Excluded: crossed out with a red outline */
.type-choice[data-state="exclude"] {
  opacity: 0.9;
  border-color: var(--accent);
  border-style: dashed;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

/* Four move boxes in a 2 by 2 grid, or one column on narrow screens */
.move-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  flex: 1;
}

.move-inputs .suggest {
  min-width: 0;
}

@media (max-width: 34rem) {
  .move-inputs {
    grid-template-columns: 1fr;
  }
}

/* Suggestion list under an input, styled like the rest of the site */
.suggest {
  position: relative;
  flex: 1;
  min-width: 10rem;
}

.suggest input {
  width: 100%;
  box-sizing: border-box;
}

.suggest-list {
  position: absolute;
  z-index: 10;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 16rem;
  margin: 0;
  padding: 0.25rem;
  overflow-y: auto;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.suggest-list li {
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
}

/* The suggestion under the mouse or picked with the arrow keys */
.suggest-list li:hover,
.suggest-list li.active {
  background: var(--background);
  color: var(--accent);
}

/* Hide the browser's up and down arrows in number boxes, since they're drawn by the browser and don't match the site */
.adv-fields input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.adv-fields input[type="number"]::-webkit-inner-spin-button,
.adv-fields input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}