/**
 * RPG MTG Deck Showcase - Base Shared Styles
 * Layout, grid, modal, navigation structure
 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
  scrollbar-width: none;
}

html::-webkit-scrollbar, body::-webkit-scrollbar { display: none; }

/* ===== NAVIGATION ===== */
nav.game-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  display: flex;
  gap: 1rem;
  padding: 0.75rem 1rem;
  flex-wrap: wrap;
  align-items: center;
}

body nav.game-nav {
  margin: 16px;
  top: 38px;
}

@media (max-width: 600px) {
  body nav.game-nav { top: 68px; }
}

nav.game-nav a {
  padding: 0.5rem 1rem;
  text-decoration: none;
  font-weight: bold;
  text-transform: uppercase;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  border-radius: 4px;
  position: relative;
  display: inline-block;
  letter-spacing: 0.05em;
}

nav.game-nav a.active {
  box-shadow: 0 0 10px currentColor;
  transform: scale(1.05);
}

nav.game-nav a:hover {
  transform: translateY(-2px);
}

/* ===== WINDOW TOP BAR (SHARED FROM SITE) ===== */
.window-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  backdrop-filter: blur(12px);
  border-bottom: 1px solid;
  box-shadow: 0 2px 6px rgba(0,0,0,0.6);
  min-height: 40px;
  flex-wrap: wrap;
  gap: 8px;
}

.window-title {
  flex: 1;
  font-size: 0.9rem;
  min-width: 150px;
  text-align: left;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

.window-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.window-controls button {
  padding: 4px 8px;
  min-width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  border-radius: 2px;
  transition: all 0.2s ease;
}

.window-controls button.mute {
  background: transparent;
  border: none;
  font-size: 1rem;
}

.volume-slider {
  width: 60px;
  height: 20px;
  cursor: pointer;
}

.music-tooltip {
  position: fixed;
  z-index: 10001;
  max-width: min(250px, calc(100vw - 20px));
  padding: 8px 12px;
  border: 1px solid #f8f8f8;
  background: #000;
  color: #f8f8f8;
  font-size: 14px;
  text-align: center;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.music-tooltip .tooltip-title { font-weight: bold; }
.music-tooltip .tooltip-artist { font-size: 12px; }

/* ===== MAIN WRAPPER ===== */
#content-wrapper {
  min-height: calc(100vh - 50px - 40px); /* Subtract nav + window bar heights */
  display: flex;
  flex-direction: column;
  position: relative;
  padding: 2rem 1rem;
}

/* ===== HEADER SECTION ===== */
header.page-header {
  text-align: center;
  margin-bottom: 3rem;
  padding: 2rem 1rem;
  border-radius: 8px;
  position: relative;
  z-index: 1;
}

header h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  letter-spacing: 0.05em;
}

.game-logo {
  display: block;
  width: auto;
  height: auto;
  max-width: min(100%, 400px);
  max-height: 100px;
  margin: 0 auto;
  object-fit: contain;
}

.page-header.game-header {
  padding: 10px 12px;
}

.game-header h1 {
  margin: 0 0 4px;
  line-height: 0;
}

.game-header .game-logo {
  max-width: min(100%, 560px);
  max-height: 125px;
}

.game-header .subtitle {
  margin: 0;
  font-size: clamp(18px, 1.7vw, 22px);
  line-height: 1.25;
}

.game-header .card-count {
  margin: 6px 0 0;
  font-size: clamp(18px, 1.7vw, 22px);
  line-height: 1.2;
}

header .subtitle {
  font-size: 1.1rem;
  opacity: 0.9;
  margin-bottom: 0.5rem;
}

header .card-count {
  font-size: 0.9rem;
  opacity: 0.75;
  font-style: italic;
}

/* ===== SEARCH & FILTER ===== */
.controls-section {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.search-box {
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  border: 2px solid currentColor;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.search-input:focus {
  outline: none;
  box-shadow: 0 0 15px currentColor;
}

.search-input::placeholder {
  opacity: 0.6;
}

/* ===== CARD GRID ===== */
.cards-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  margin-bottom: 3rem;
}

.cards-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.section-header {
  font-size: 1.3rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.section-header .count {
  font-size: 0.8rem;
  opacity: 0.8;
  font-weight: normal;
  font-style: italic;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  padding: 1rem;
  border-radius: 8px;
}

.card-entry { min-width: 0; }

/* ===== CARD ITEM ===== */
.card-item {
  position: relative;
  cursor: pointer;
  border-radius: 6px;
  overflow: visible;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 63 / 88;
  background: rgba(0,0,0,0.3);
  border: 2px solid;
  padding: 4px;
}

.card-item:hover {
  transform: translateY(-8px) scale(1.05);
}

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

.card-face-badge {
  position: absolute;
  right: 0.3rem;
  bottom: 0.3rem;
  padding: 0.15rem 0.35rem;
  background: #202020;
  color: #f8f8f8;
  font-size: 0.7rem;
  line-height: 1.2;
  pointer-events: none;
}

.card-item.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  text-align: center;
  font-size: 0.75rem;
  opacity: 0.6;
}

.card-item.placeholder::before {
  content: "?";
  font-size: 2rem;
  opacity: 0.5;
}

.card-item.placeholder .card-name {
  word-break: break-word;
}

body .card-item.placeholder {
  border: none;
  box-shadow: none;
}

body .card-item:not(.placeholder) {
  border: 2px solid #000;
  border-radius: 8px;
  padding: 4px;
  background: #000;
  box-shadow: none;
}

body .card-item:hover,
body .card-item:focus-visible {
  box-shadow: none;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.7));
}

/* ===== CARD MODAL ===== */
.card-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.3s ease;
}

.card-modal.active {
  display: flex;
}

.card-modal .backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  cursor: pointer;
}

.card-modal .modal-content {
  position: relative;
  z-index: 1001;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
  border-radius: 8px;
  animation: slideUp 0.4s ease;
  overflow-y: auto;
}

.card-modal .modal-image {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border-radius: 4px;
}

.card-modal .modal-info {
  text-align: center;
}

.card-modal .modal-info h3 {
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-modal .modal-info .series {
  font-size: 0.9rem;
  opacity: 0.8;
  font-style: italic;
}

body .card-modal .modal-content {
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  grid-template-areas: "image info" "image nav";
  align-items: center;
  gap: 0.75rem 1.25rem;
  width: min(94vw, 780px);
  max-width: 94vw;
}

body .card-modal .modal-image,
.card-modal .modal-placeholder {
  grid-area: image;
  width: 100%;
  max-height: 70vh;
  margin: 0;
}

body .card-modal .modal-image {
  justify-self: center;
  width: auto;
  max-width: 100%;
  padding: 6px;
  border: 0;
  border-radius: 8px;
  background: #000;
}

.card-modal .modal-image[hidden],
.card-modal .modal-placeholder[hidden],
.card-modal .modal-original[hidden],
.card-modal .modal-face-button[hidden] {
  display: none;
}

.card-modal .modal-placeholder {
  display: grid;
  place-items: center;
  aspect-ratio: 63 / 88;
  border: 1px solid currentColor;
  padding: 1rem;
  text-align: center;
}

.card-modal .modal-info {
  grid-area: info;
  align-self: end;
  text-align: left;
  min-width: 0;
}

.card-modal .modal-commander {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  font-weight: bold;
}

.card-modal .modal-kind {
  margin: 1rem 0 0.2rem;
  font-size: 0.85rem;
}

.card-modal .modal-original-name {
  margin: 0 0 0.25rem;
  font-size: 1.2em;
  overflow-wrap: anywhere;
}

.card-modal .modal-original,
.card-modal .modal-face-button {
  display: block;
  color: inherit;
  font: inherit;
  overflow-wrap: anywhere;
}

.card-modal .modal-original { text-decoration: underline; text-underline-offset: 0.2em; }
.card-modal .modal-face-button {
  margin-top: 1rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid currentColor;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

body .card-modal .nav-buttons {
  grid-area: nav;
  align-self: start;
  justify-content: flex-start;
  gap: 1rem;
  margin: 0;
}

@media (max-width: 600px) {
  body .card-modal .modal-content {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "image" "info" "nav";
    gap: 0.5rem;
    padding: 1rem;
  }
  body .card-modal .modal-image { max-height: 42vh; }
  .card-modal .modal-placeholder { max-height: 42vh; width: auto; margin: auto; }
  .card-modal .modal-kind { margin-top: 0.4rem; }
  .card-modal .modal-face-button { margin-top: 0.4rem; }
}

.card-modal .modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: all 0.2s ease;
  z-index: 1002;
}

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

.card-modal .nav-buttons button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s ease;
}

/* ===== FOOTER ===== */
footer.page-footer {
  margin-top: auto;
  padding: 2rem 1rem;
  border-radius: 8px;
  text-align: center;
  position: relative;
  z-index: 1;
}

footer h3 {
  font-size: 1.3rem;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

footer p {
  margin-bottom: 1rem;
  line-height: 1.8;
  opacity: 0.9;
}

.cta-button {
  display: inline-block;
  padding: 0.75rem 2rem;
  font-size: 1rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  margin-top: 1rem;
}

.cta-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ===== PAGE TRANSITIONS ===== */
.page-transition {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 999;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  #content-wrapper {
    padding: 1rem 0.75rem;
  }

  header.page-header {
    margin-bottom: 2rem;
    padding: 1.5rem 0.75rem;
  }

  header h1 {
    font-size: 1.8rem;
  }

  header .subtitle {
    font-size: 0.95rem;
  }

  .controls-section {
    gap: 0.75rem;
    margin-bottom: 1.5rem;
  }

  .search-box {
    min-width: 150px;
  }

  .cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.75rem;
    padding: 0.75rem;
  }

  .section-header {
    font-size: 1.1rem;
  }
}

@media (max-width: 480px) {
  #content-wrapper {
    padding: 0.75rem;
  }

  header.page-header {
    margin-bottom: 1.5rem;
    padding: 1rem 0.5rem;
  }

  header h1 {
    font-size: 1.3rem;
  }

  header .subtitle {
    font-size: 0.85rem;
  }

  .controls-section {
    flex-direction: column;
    gap: 0.5rem;
  }

  .search-box {
    width: 100%;
    min-width: unset;
  }

  .cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.5rem;
    padding: 0.5rem;
  }

  .card-item {
    border-width: 1px;
  }

  .section-header {
    font-size: 0.95rem;
  }

  footer.page-footer {
    padding: 1.5rem 0.75rem;
  }

  footer h3 {
    font-size: 1.1rem;
  }

  footer p {
    font-size: 0.9rem;
  }

  .cta-button {
    padding: 0.6rem 1.5rem;
    font-size: 0.9rem;
  }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .card-item:hover {
    transform: none;
  }

  .cta-button:hover {
    transform: none;
  }
}

/* ===== UTILITY CLASSES ===== */
.hidden {
  display: none !important;
}

.no-scroll {
  overflow: hidden;
}

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