/**
 * RPG MTG Deck Showcase - Undertale Theme
 *
 * Font: the local Undertale font throughout the page.
 * Pixel fonts are sized in multiples of their native 16px grid so they stay crisp.
 *
 * Palette: Undertale's battle screen is almost entirely pure black, pure white,
 * pure yellow, pure red, and one orange for the command buttons.
 * Values marked VERIFY are eyedropper-level approximations that could not be
 * confirmed against a published palette; sample a screenshot to lock them in.
 */

@font-face {
  font-family: 'Undertale';
  src: url('Undertale Font.ttf') format('truetype');
  font-display: swap;
}

:root {
  --ut-black:  #000000;
  --ut-white:  #FFFFFF;
  --ut-yellow: #FFFF00; /* selected text, HP fill, MERCY "spare" name */
  --ut-red:    #FF0000; /* SOUL, missing HP */
  --ut-orange: #FF7F27; /* FIGHT/ACT/ITEM/MERCY buttons - VERIFY */
  --ut-gray:   #808080; /* disabled options */

  --ut-border: 4px;    /* the thick white box border */
  --ut-font:   'Undertale', monospace;
  --ut-ui:     var(--ut-font);
  --ut-stat:   var(--ut-font);

  /* The red SOUL, drawn as a 7x6 pixel SVG (no glyphs, no emoji) */
  --ut-soul: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 6' shape-rendering='crispEdges'%3E%3Cpath fill='%23FF0000' d='M1 0h2v1h1V0h2v1h1v2h-1v1h-1v1h-1v1h-1v-1h-1v-1h-1v-1H0V1h1z'/%3E%3C/svg%3E");
}

/* ===== BASE ===== */
html, body {
  background: var(--ut-black);
  color: var(--ut-white);
  font-family: var(--ut-font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: unset;
  font-smooth: never;
}

button, input, select, textarea { font-family: inherit; }

/* Undertale has no background texture. Black is the background. */
body::before,
body::after { content: none; }

#content-wrapper {
  position: relative;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}

::selection { background: var(--ut-yellow); color: var(--ut-black); }

:focus-visible {
  outline: 2px solid var(--ut-yellow);
  outline-offset: 2px;
}

/* ===== WINDOW BAR ===== */
.window-top-bar {
  background: var(--ut-black);
  color: var(--ut-white);
  border-bottom: 2px solid var(--ut-white);
  box-shadow: none;
  font-family: var(--ut-ui);
  font-size: 16px;
}

.window-title {
  color: var(--ut-white);
  font-weight: normal;
  letter-spacing: 0;
}

.window-controls button {
  font-family: var(--ut-ui);
  font-size: 16px;
  color: var(--ut-white);
  background: var(--ut-black);
  border: 2px solid var(--ut-white);
  border-radius: 0;
  box-shadow: none;
}

.window-controls button:hover { color: var(--ut-yellow); border-color: var(--ut-yellow); }

.volume-slider { accent-color: var(--ut-yellow); }

/* ===== NAVIGATION: styled as the four battle command buttons ===== */
nav.game-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  background: var(--ut-black);
  border-bottom: none;
  box-shadow: none;
}

nav.game-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 6px 16px 6px 36px;
  font-family: var(--ut-ui);
  font-size: 16px;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ut-orange);
  background: var(--ut-black);
  border: 2px solid var(--ut-orange);
  border-radius: 0;
  box-shadow: none;
  transition: none;
}

/* Slot where the button icon sits. It is empty until selected. */
nav.game-nav a::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 50%;
  width: 14px;
  height: 12px;
  transform: translateY(-50%);
  background: no-repeat center / contain;
}

nav.game-nav a:hover,
nav.game-nav a:focus-visible,
nav.game-nav a.active {
  color: var(--ut-yellow);
  border-color: var(--ut-yellow);
  background: var(--ut-black);
  box-shadow: none;
  transform: none;
}

nav.game-nav a:hover::before,
nav.game-nav a:focus-visible::before,
nav.game-nav a.active::before { background-image: var(--ut-soul); }

/* ===== HERO: a dialogue box ===== */
header.page-header {
  background: var(--ut-black);
  border: var(--ut-border) solid var(--ut-white);
  border-radius: 0;
  box-shadow: none;
  margin: 32px 0;
  padding: 24px 32px;
}

header h1 {
  font-family: var(--ut-font);
  font-size: 48px;
  font-weight: normal;
  line-height: 1.1;
  letter-spacing: 0.04em;
  color: var(--ut-white);
  text-shadow: none;
  margin: 0 0 16px;
}

header .subtitle {
  font-family: var(--ut-font);
  font-size: 16px;
  color: var(--ut-white);
  margin: 0;
}

/* Every line of Undertale dialogue starts with an asterisk */
header .subtitle::before { content: '* '; }

/* Styled as the battle HUD stat line, e.g. "LV 11  HP" */
header .card-count {
  display: inline-block;
  margin-top: 16px;
  font-family: var(--ut-stat);
  font-size: 16px;
  color: var(--ut-white);
  text-transform: uppercase;
}

/* ===== CONTROLS ===== */
.controls-section {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 32px;
}

.search-box { flex: 1; min-width: 240px; }

.search-input {
  width: 100%;
  font-family: var(--ut-font);
  font-size: 16px;
  color: var(--ut-white);
  background: var(--ut-black);
  border: 2px solid var(--ut-white);
  border-radius: 0;
  padding: 8px 12px;
  box-shadow: none;
}

.search-input::placeholder { color: var(--ut-gray); }

.search-input:focus {
  outline: none;
  border-color: var(--ut-yellow);
  box-shadow: none;
}

/* ===== SECTIONS ===== */
.cards-container { display: flex; flex-direction: column; gap: 48px; }
.cards-section   { display: flex; flex-direction: column; gap: 16px; }

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: 0 0 8px;
  font-family: var(--ut-font);
  font-size: 32px;
  font-weight: normal;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ut-white);
  border-bottom: 2px solid var(--ut-white);
}

.section-header .count {
  font-family: var(--ut-stat);
  font-size: 16px;
  color: var(--ut-yellow);
  opacity: 1;
}

/* ===== CARD GRID ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 24px;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
}

/* Full card is always visible: fixed MTG ratio, contained image */
.card-item {
  position: relative;
  aspect-ratio: 63 / 88;
  padding: 0;
  background: var(--ut-black);
  border: 2px solid var(--ut-black);
  border-radius: 0;
  box-shadow: none;
  cursor: pointer;
  transition: border-color 80ms steps(1);
}

.card-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.card-item:hover,
.card-item:focus-visible {
  border-color: var(--ut-yellow);
  background: var(--ut-black);
  box-shadow: none;
  transform: none;
}

/* SOUL appears beside the hovered card, like a menu selection */
.card-item::after {
  content: '';
  position: absolute;
  left: -20px;
  top: 50%;
  width: 14px;
  height: 12px;
  transform: translateY(-50%);
  background: var(--ut-soul) no-repeat center / contain;
  visibility: hidden;
}
.card-item:hover::after,
.card-item:focus-visible::after { visibility: visible; }

.card-item.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
  font-family: var(--ut-font);
  font-size: 16px;
  color: var(--ut-gray);
  border: 2px solid var(--ut-gray);
  opacity: 1;
}
.card-item.placeholder::before { content: none; }

/* ===== MODAL: a large dialogue box ===== */
.card-modal .modal-content {
  background: var(--ut-black);
  border: var(--ut-border) solid var(--ut-white);
  border-radius: 0;
  box-shadow: none;
  padding: 24px;
  max-width: min(92vw, 560px);
  max-height: 92vh;
}

.card-modal .modal-image {
  display: block;
  width: 100%;
  max-height: 68vh;
  object-fit: contain;
  margin: 0 auto 16px;
  border: none;
  image-rendering: pixelated;
}

.card-modal .modal-info h3 {
  font-family: var(--ut-font);
  font-size: 32px;
  font-weight: normal;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ut-white);
  margin: 0 0 4px;
}

.card-modal .modal-info .series {
  font-family: var(--ut-font);
  font-size: 16px;
  color: var(--ut-white);
}
.card-modal .modal-info .series::before { content: '* '; }

.card-modal .modal-close {
  width: 36px;
  height: 36px;
  font-family: var(--ut-ui);
  font-size: 16px;
  color: var(--ut-white);
  background: var(--ut-black);
  border: 2px solid var(--ut-white);
  border-radius: 0;
}
.card-modal .modal-close:hover { color: var(--ut-yellow); border-color: var(--ut-yellow); box-shadow: none; transform: none; }

.card-modal .nav-buttons { display: flex; justify-content: center; gap: 16px; margin-top: 16px; }

.card-modal .nav-buttons button {
  font-family: var(--ut-ui);
  font-size: 16px;
  text-transform: uppercase;
  color: var(--ut-orange);
  background: var(--ut-black);
  border: 2px solid var(--ut-orange);
  border-radius: 0;
  padding: 6px 16px;
}
.card-modal .nav-buttons button:hover { color: var(--ut-yellow); border-color: var(--ut-yellow); box-shadow: none; }

/* ===== FOOTER ===== */
footer.page-footer {
  margin: 64px 0 32px;
  padding: 24px 32px;
  background: var(--ut-black);
  color: var(--ut-white);
  border: var(--ut-border) solid var(--ut-white);
  border-radius: 0;
  box-shadow: none;
}

footer h3 {
  font-family: var(--ut-font);
  font-size: 32px;
  font-weight: normal;
  text-transform: none;
  color: var(--ut-white);
  margin: 0 0 16px;
}

footer p {
  font-family: var(--ut-font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ut-white);
}

/* Styled as the selected MERCY option, the "kind" choice */
.cta-button {
  font-family: var(--ut-ui);
  font-size: 16px;
  text-transform: uppercase;
  color: var(--ut-orange);
  background: var(--ut-black);
  border: 2px solid var(--ut-orange);
  border-radius: 0;
  padding: 8px 24px;
  box-shadow: none;
  cursor: pointer;
}
.cta-button:hover,
.cta-button:focus-visible {
  color: var(--ut-yellow);
  border-color: var(--ut-yellow);
  background: var(--ut-black);
  box-shadow: none;
  transform: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  header.page-header { padding: 16px 20px; }
  header h1 { font-size: 32px; }
  .section-header { font-size: 24px; }
  .cards-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 16px; }
}

@media (max-width: 480px) {
  nav.game-nav { gap: 8px; padding: 12px 8px; }
  nav.game-nav a { padding: 4px 10px 4px 30px; }
  .cards-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .card-item::after { display: none; }
  footer.page-footer { padding: 16px 20px; }
}

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