/* style.css */

/* Global Reset and Base Styles */
@import url('https://fonts.googleapis.com/css2?family=Russo+One&display=swap');

/*-----------------------------------
  Variables & Base (Mobile-First)
-----------------------------------*/
:root {
  --bg: #121212;
  --surface: #1e1e1e;
  --border: #333;
  --text: #e0e0e0;
  --accent: #c62828;
  --accent-hover: #e53935;
  --highlight: #ffeb3b;
  --radius: 6px;
  --gap: 10px;
  --font: 'Russo One', sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
}

img {
  display: block;
  max-width: 100%;
}

button,
input {
  font-family: inherit;
  font-size: 1rem;
}

/* Utility */
.hidden {
  display: none !important;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/*-----------------------------------
  Container & Layout
-----------------------------------*/
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: var(--gap);
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap);
  padding-bottom: var(--gap);
  border-bottom: 2px solid var(--border);
}
.header-logo {
  height: 42px;
  width: auto;
  margin-right: 12px;
}
/* Fluid, responsive header text */
.app-header h1 {
  font-size: clamp(1.2rem, 5vw, 2rem);
  line-height: 1.2;
  margin: 0;
}
/* Extra mobile tweak if needed */
@media (max-width: 500px) {
  .app-header h1 {
    font-size: 1rem;
  }
}

/* Deck Controls */
.deck-controls {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  margin-top: var(--gap);
}
.deck-name-group input {
  width: 100%;
  padding: 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.deck-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
}
.deck-btn-group button {
  flex: 1 1 auto;
  padding: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
}
.deck-btn-group button:hover {
  background: var(--accent-hover);
}
.deck-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  font-size: 0.9rem;
}
.deck-stats span {
  background: var(--surface);
  padding: 4px 8px;
  border-radius: var(--radius);
}

/* Deck Grid */
.deck-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: var(--gap);
}
.deck-slot {
  position: relative;
  aspect-ratio: 2/3;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.deck-slot.filled {
  border: none;
}
.deck-slot.over {
  outline: 3px dashed var(--highlight);
  outline-offset: -2px;
}
.deck-card {
  width: 100%;
  height: 100%;
  cursor: grab;
  transition: transform 0.2s, opacity 0.2s;
}
.deck-card:hover {
  transform: scale(1.03);
}
.deck-card.fade-out {
  opacity: 0;
  transform: scale(0.8);
}

/* Library */
.library {
  margin-top: var(--gap);
}
.library h2 {
  margin-bottom: var(--gap);
  font-size: 1.1rem;
  text-align: center;
}
.search-group {
  display: flex;
  gap: var(--gap);
  margin-bottom: var(--gap);
}
.search-group input[type="search"] {
  flex: 1;
  padding: 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.search-group button {
  padding: 8px 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
}
.search-group button:hover {
  background: var(--accent-hover);
}

/* Advanced Filters */
.advanced-panel {
  background: var(--surface);
  padding: var(--gap);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--gap);
}
.advanced-panel fieldset {
  border: none;
  margin-bottom: var(--gap);
}
.advanced-panel legend {
  font-weight: bold;
}
.advanced-panel label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: var(--gap);
}
#applyAdvSearchBtn {
  padding: 8px 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}
#applyAdvSearchBtn:hover {
  background: var(--accent-hover);
}

/* Library Grid */
.library-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-height: 400px;
  overflow-y: auto;
}
.library-card {
  position: relative;
  aspect-ratio: 2/3;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s;
}
.library-card:hover {
  transform: scale(1.03);
}

/* Footer */
.app-footer {
  margin-top: auto;
  padding: var(--gap);
  text-align: center;
  border-top: 2px solid var(--border);
  font-size: 0.8rem;
}

/*-----------------------------------
  Tablet & Desktop Tweaks
-----------------------------------*/
@media (min-width: 900px) {
  /* container centering */
  .app-container {
    max-width: 1200px;
    margin: 0 auto;
  }

  /* deck & library split */
  .main-content {
    display: flex;
    gap: var(--gap);
    align-items: flex-start;
  }
  .deck-area {
    flex: 0 0 40%;
    display: flex;
    flex-direction: column;
    gap: var(--gap);
  }
  .library {
    flex: 1;
  }

  .deck-grid {
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
  }
  .library-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
  }
}

.deck-grid-container {
  position: relative;
}

.deck-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  color: white;
  text-shadow:
    -3px -3px 0 black,
     3px -3px 0 black,
    -3px  3px 0 black,
     3px  3px 0 black;
  pointer-events: none;
  opacity: 0.5;
  text-align: center;
  z-index: 1;
}


/* Desktop layout split */
@media (min-width: 900px) {
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  background-color: #121212;
  color: #e0e0e0;
  font-family: 'Russo One', sans-serif;
  line-height: 1.6;
}
.container {
  width: 1400px;
  margin: 0 auto;
}

/* Header */
header {
  background-color: #1e1e1e;
  padding: 20px;
  border-bottom: 2px solid #333;
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-logo {
  width: 128px;
  height: 64px;
  object-fit: cover;
}
header h1 {
  flex: 1;
  text-align: center;
}

/* Deck Controls Area (inside deck section) */
.deck-controls-area {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  margin-bottom: 20px;
}
.deck-controls-area input[type="text"] {
  padding: 5px 10px;
  font-size: 16px;
  border: none;
  border-radius: 4px;
}
.deck-controls-area button {
  padding: 5px 10px;
  font-size: 16px;
  background-color: #c62828;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s;
}
.deck-controls-area button:hover {
  background-color: #e53935;
}
.hidden {
  display: none;
}

/* Main Layout */
main {
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  max-width: 1400px;
  margin: 20px auto;
  gap: 20px;
}
.divider {
  width: 2px;
  background-color: #444;
  margin-top: 30px;
  margin-bottom: 30px;
}

/* -------------------------
   DECK SECTION (LEFT SIDE)
------------------------- */
.deck-area {
  width: 100%;
}
#deckHeader {
  text-align: center;
  margin-bottom: 5px;
  font-size: 1.5em;
}
.deck-stats {
  display: flex;
  justify-content: space-evenly;
  margin-bottom: 10px;
  font-size: 14px;
}

/* Deck grid: 8 columns */
.deck-grid {
  display: grid;
  grid-template-columns: repeat(8, auto);
  gap: 2px;    /* reduced horizontal gap between cards in the same row */
  row-gap: 5px; /* vertical gap between rows */
}
.deck-slot {
  width: 90px;
  aspect-ratio: 2 / 3;
  background-color: #1e1e1e;
  border: 2px dashed #333;
  border-radius: 8px;
  position: relative;
  cursor: pointer;
  transition: border-color 0.3s;
}
.deck-slot:hover {
  border-color: #e53935;
}
.deck-slot.filled {
  border: none;
  background-color: #2e2e2e;
}
.deck-slot.over {
  outline: 3.5px dashed #ffeb3b;
  outline-offset: -2px;
}
.deck-card {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  overflow: hidden;
  cursor: grab;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.deck-card:hover {
  transform: scale(1.05);
}
.deck-card.dragging {
  transform: scale(1.08);
  z-index: 999;
}
.deck-card.fade-out {
  opacity: 0;
  transform: scale(0.7);
}
.deck-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* The card-info container is now placed beneath the image */
.card-info {
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  text-align: center;
  font-size: 12px;
  padding: 4px 2px;
  overflow: hidden;
  display: -webkit-box;
  -line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* -------------------------
   LIBRARY SECTION (RIGHT)
------------------------- */
.library-area {
  width: 40%;
}
.library-area h2 {
  text-align: center;
  margin-bottom: 10px;
}
.search-bar {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-bottom: 10px;
}
.search-bar input[type="text"] {
  padding: 5px 10px;
  font-size: 16px;
  border: none;
  border-radius: 4px;
}
.search-bar button {
  padding: 5px 10px;
  font-size: 16px;
  background-color: #c62828;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s;
}
.search-bar button:hover {
  background-color: #e53935;
}
/* Advanced Search Panel */
.adv-search {
  background-color: #1e1e1e;
  padding: 10px;
  margin-bottom: 10px;
  border: 2px solid #333;
  border-radius: 8px;
}
.adv-search h3 {
  margin-bottom: 10px;
  text-align: center;
}
.adv-search .checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 10px;
}
/* Library Grid: 5 columns */
.library-grid {
  display: grid;
  grid-template-columns: repeat(5, auto);
  gap: 2px;
  row-gap: 5px;
  max-height: 650px;
  overflow-y: auto;
  padding-right: 5px;
}
.library-card {
  width: 90px;
  aspect-ratio: 2 / 3;
  background-color: #2e2e2e;
  border-radius: 8px;
  cursor: default; /* disable grab cursor */
  overflow: hidden;
  transition: transform 0.2s;
  position: relative;
}
.library-card:hover {
  transform: scale(1.05);
}
.library-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Scrollbar styling for library grid */
.library-grid::-webkit-scrollbar {
  width: 8px;
}
.library-grid::-webkit-scrollbar-track {
  background: #1e1e1e;
}
.library-grid::-webkit-scrollbar-thumb {
  background-color: #333;
  border-radius: 4px;
}

/* Footer */
footer {
  text-align: center;
  padding: 20px;
  background-color: #1e1e1e;
  border-top: 2px solid #333;
  font-size: 14px;
  margin-top: 20px;
}
 /* 3) Make sure the 'Apply' button has a red style class */
  /* If you want it always to be red, add .btn-red or similar. 
     If you can't edit HTML, you can target #applyAdvSearchBtn directly: */
  #applyAdvSearchBtn {
    background-color: #c62828;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 5px 10px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
  }
  #applyAdvSearchBtn:hover {
    background-color: #e53935;
  }

/* ------------------------------------------------- */
/* Responsive Adjustments for Mobile Devices */
/* ------------------------------------------------- */
@media (max-width: 768px) {
  /* Make container fluid */
  .container {
    width: 100%;
    padding: 0 10px;
  }
  
  /* Stack header elements vertically */
  header {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }
  header h1 {
    font-size: 1.5em;
    text-align: center;
  }
  
  /* Stack main content vertically */
  main {
    flex-direction: column;
    gap: 20px;
  }
  
  /* Make sections full width */
  .deck-area, .library-area {
    width: 100%;
    padding: 10px;
  }
  
  /* Example: For a deck grid that used to be two columns, adjust to one column or fewer columns */
  .deck-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(80px, 1fr));
    gap: 5px;
  }
  
  /* Ensure cards scale down appropriately */
  .deck-slot,
  .library-card {
    width: 80px; /* Adjusted for mobile */
    aspect-ratio: 2 / 3;
  }
  
  /* Adjust interactive elements for touch: Larger tap targets, simpler hover effects */
  button {
    padding: 8px 12px;
    font-size: 1em;
  }
  
  /* Ensure navigation or control areas stack well */
  .deck-controls-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }
  
  /* If you have a row of buttons, force them into one row if possible */
  .deck-buttons-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 5px;
    justify-content: center;
  }
  
}
}