@font-face {
  font-family: "MagicMedieval";
  src: url("../fonts/MagicMedieval.woff2") format("woff2"),
       url("../fonts/MagicMedieval.ttf") format("truetype");
  font-display: swap;
}

:root {
  --ink: #1a1206;
  --parchment: #e8dcc0;
  --panel: #f3ecd8;
  --bevel-light: #fffaf0;
  --bevel-dark: #8a7a52;
  --accent: #6b1f1f;
  --link: #00007f;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

* {
  cursor: url("../cursors/rat_normal.cur"), auto;
}

/* Anything clickable gets the pointing rat. */
a[href],
button,
summary,
select,
.btn,
[role="button"],
input[type="button"],
input[type="checkbox"],
input[type="radio"],
input[type="reset"],
input[type="submit"] {
  cursor: url("../cursors/rat_link.cur"), pointer;
}

/*
 * ...and so does anything sitting inside one.
 *
 * cursor is an inherited property, but the `*` rule above sets it on every
 * element, and an explicit value beats an inherited one -- so a child element
 * never inherits its link's rat. The image inside a card tile's anchor and the
 * two rats inside the banner's home button are both hit by this. Only elements
 * that can have children need the descendant rule; the inputs above cannot.
 */
a[href] *,
button *,
summary *,
select *,
.btn *,
[role="button"] * {
  cursor: url("../cursors/rat_link.cur"), pointer;
}

/* Disabled controls are not clickable, so they keep the plain rat. */
button:disabled,
button:disabled *,
select:disabled,
input:disabled,
.btn:disabled,
.btn:disabled * {
  cursor: url("../cursors/rat_normal.cur"), not-allowed;
}

body {
  margin: 0;
  padding: 1rem;
  background-color: var(--parchment);
  /* Uncomment once a tile is dropped in; see static/img/README.md. */
  /* background-image: url("../img/tile.gif"); */
  color: var(--ink);
  font-family: "MagicMedieval", "Times New Roman", serif;
  font-size: 18px;
  line-height: 1.4;
}

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

.page {
  max-width: 900px;
  margin: 0 auto;
}

/* --- banner ------------------------------------------------------------ */

.banner {
  text-align: center;
}

.banner__title {
  margin: 0;
  font-size: 3.5rem;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-shadow: 2px 2px 0 var(--bevel-light), 4px 4px 0 var(--bevel-dark);
}

/*
 * The title doubles as the way back to the configuration view. A real <button>
 * gets that for keyboard and screen readers for free; everything below is
 * undoing the chrome one arrives with, so it still reads as the heading.
 *
 * Flex so the rats center on the text's line box; `vertical-align: middle`
 * would tie them to the x-height instead, which rides high over a font this
 * large.
 */
.banner__home {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.1em;
  margin: 0 auto;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
}

.banner__tagline {
  margin: 0.25rem 0 0.75rem;
}

.rule {
  border: none;
  border-top: 2px groove var(--bevel-dark);
}

/* --- panels ------------------------------------------------------------ */

.panel {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--panel);
  border: 3px outset var(--bevel-light);
}

.panel__heading {
  margin-top: 0;
  font-size: 1.75rem;
  color: var(--accent);
}

.notice {
  padding: 0.75rem;
  border: 2px dashed var(--accent);
}

.notice--error {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  border-style: solid;
  background: #f7e3e3;
}

/* --- configuration form ------------------------------------------------ */

.config-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  margin: 0 0 0.5rem;
  padding: 0.5rem;
  border: 2px inset var(--bevel-dark);
}

.config-row__field {
  display: flex;
  flex-direction: column;
}

.config-row__field--grow {
  flex: 1;
}

.config-row__label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.config-row__qty {
  width: 4.5rem;
}

.config-row input,
.config-row select {
  padding: 0.25rem;
  font-family: inherit;
  font-size: 1rem;
  border: 2px inset var(--bevel-dark);
  background: #fff;
}

/*
 * The autocomplete dropdown. A native <datalist> would need no CSS, but it
 * can only carry a string per option -- no set code, no release year -- so
 * the list is ours.
 */
.set-search {
  position: relative;
}

.set-search .config-row__search {
  width: 100%;
}

.set-search__results {
  position: absolute;
  z-index: 10;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 14rem;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
  background: #fff;
  border: 2px outset var(--bevel-light);
}

/*
 * The row is clickable but is not one of the elements the global rule covers,
 * so it names its own descendants: the two spans below cover nearly all of it,
 * leaving only the padding and the flex gap to show the row's own cursor.
 */
.set-search__result,
.set-search__result * {
  cursor: url("../cursors/rat_link.cur"), pointer;
}

.set-search__result {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.2rem 0.4rem;
}

.set-search__result--active {
  color: var(--panel);
  background: var(--accent);
}

.set-search__meta {
  font-size: 0.8rem;
  opacity: 0.7;
}

.set-search__result--active .set-search__meta {
  opacity: 0.9;
}

.controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1rem;
}

.btn {
  padding: 0.4rem 1rem;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--parchment);
  border: 3px outset var(--bevel-light);
}

.btn:active {
  border-style: inset;
}

.btn--primary {
  color: var(--panel);
  background: var(--accent);
}

.btn--danger {
  padding: 0.2rem 0.6rem;
  color: var(--accent);
  font-weight: bold;
}

/* --- pool view --------------------------------------------------------- */

.pool__sort {
  margin: 0.75rem 0;
  padding: 0.4rem 0.75rem;
  border: 2px ridge var(--bevel-dark);
}

.pool__sort legend {
  padding: 0 0.35rem;
  font-weight: bold;
}

.pool__sort label {
  margin-right: 0.9rem;
}

.pool__images {
  margin-left: 0.5rem;
}

.pool__cards {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.25rem 1rem;
}

/* Images need a tile, not a text row: narrower columns and a real gap. */
.pool__cards--images {
  grid-template-columns: repeat(auto-fill, minmax(146px, 1fr));
  gap: 0.75rem;
}

.pool__export {
  margin: 1rem 0;
  padding: 0.4rem 0.75rem 0.75rem;
  border: 2px ridge var(--bevel-dark);
}

.pool__export legend {
  padding: 0 0.35rem;
  font-weight: bold;
}

.pool__export label {
  margin-right: 0.9rem;
}

.pool__export-text {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.35rem;
  font-family: "Courier New", monospace;
  font-size: 0.85rem;
  background: #fff;
  border: 2px inset var(--bevel-dark);
  resize: vertical;
}

.card {
  /* Anchors the hover preview, which is positioned against its own tile. */
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.15rem 0.35rem;
  border-left: 6px solid transparent;
}

/* The rarity edge stays in both modes; on a tile it wraps the whole card. */
.card--image {
  display: block;
  padding: 0;
  border-left-width: 4px;
  border-left-style: solid;
}

.card__image {
  display: block;
  width: 100%;
  height: auto;
}

.card--common { border-left-color: #4a4a4a; }
.card--uncommon { border-left-color: #7b8c94; }
.card--rare { border-left-color: #b08d2e; }
.card--mythic { border-left-color: #c1440e; }

.card__meta {
  font-size: 1rem;
  opacity: 0.7;
}

/*
 * Block, so the anchor does not leave the inline descender gap under the image
 * that would show as a stripe of parchment inside the rarity border.
 */
.card--image .card__link {
  display: block;
}

/* --- hover preview ------------------------------------------------------ */

/*
 * The preview is layered over the grid instead of sitting in the tile, so the
 * pool does not reflow under a moving pointer. It is centred on the tile it
 * belongs to, which keeps the card where the eye already is.
 */
.card__zoom {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 10;
  transform: translate(-50%, -50%);
  /* Transparent to the pointer: catching it would fire the tile's mouseleave. */
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease-out;
}

/* Held back until the crop decodes, so hovering never flashes an empty frame. */
.card__zoom--ready {
  opacity: 1;
}

.card__zoom-image {
  display: block;
  width: 300px;
  height: auto;
  border: 2px outset var(--bevel-light);
  box-shadow: 0 0.4rem 1rem rgba(0, 0, 0, 0.45);
}

/*
 * Past roughly two columns' worth of tiles the centred preview would hang off
 * the page edge and add a scrollbar, so narrow screens get it pinned to the
 * viewport instead.
 */
@media (max-width: 640px) {
  .card__zoom {
    position: fixed;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card__zoom {
    transition: none;
  }
}

/* --- footer ------------------------------------------------------------ */

.footer {
  text-align: center;
  font-size: 1rem;
}
