/*──────────────────────────────
  Color & Design Variables
──────────────────────────────*/
:root {
  /* General Colors */
  --bg-primary: #ffffff;
  --bg-secondary: #ecebeb;
  --text-primary: #000000;
  --text-secondary: #5f5f5f;
  --text-tertiary: #888888;
  --border-color: #dddddd;

  --modal-bg: #3b3b3b69;

  /* Accent Colors (renamed) */
  --accent-1: #04942a;
  --accent-2: #044394;
  --accent-3: #cc9c35;
  --accent-4: #f44336;

  --text-white: #ffffff;

  --dropdown-hover: #f0f0f0;
  --card-bg: #f9f9f9;

  /* Danger Button Colors */
  --danger-bg: #ff4d4d;
  --danger-border: #ff0000;
  --danger-text: #ffffff;
  --danger-hover-bg: #ff1a1a;
  --danger-hover-border: #e60000;

  /* Table Hover Color */
  --table-hover: #eaeaea;
}

[data-theme="dark"] {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --text-primary: #ffffff;
  --text-secondary: #cccccc;
  --text-tertiary: #999999;
  --border-color: #404040;

  /* Accent Colors for dark mode */
  --accent-1: #38bb5b;
  --accent-2: #81afeb;
  --accent-3: #cc9c35;
  --accent-4: #bb3434;

  --dropdown-hover: #404040;
  --card-bg: #2d2d2d;
  --table-hover: #3a3a3a;
}

/*──────────────────────────────
  Global Styles
──────────────────────────────*/
body {
  margin: 0;
  font-family: Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color 0.3s, color 0.3s;
}

/*──────────────────────────────
  Header
──────────────────────────────*/
header {
  position: relative; /* Establish positioning context for h1 */
  display: flex;
  align-items: center;
  padding: 10px 20px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

/* Center the heading on wider screens */
header h1 {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
}

/* Header controls remain on the right */
.header-controls {
  margin-left: auto;
  display: flex;
  gap: 10px;
}

/*──────────────────────────────
  Icon Button Styles
──────────────────────────────*/
.icon-button {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 1.2em;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s;
}

.icon-button:hover {
  background-color: var(--bg-primary);
}

/*──────────────────────────────
  Theme Toggle Icons
──────────────────────────────*/
[data-theme="light"] .light-icon {
  display: none;
}
[data-theme="light"] .dark-icon {
  display: inline;
}
[data-theme="dark"] .dark-icon {
  display: none;
}
[data-theme="dark"] .light-icon {
  display: inline;
}

/*──────────────────────────────
  Custom Glowing Border for Help Button
──────────────────────────────*/
@keyframes glowBorder {
  0% {
    border-color: #b72a3e;
    box-shadow: 0 0 5px #b72a3e;
  }
  50% {
    border-color: #f17be5;
    box-shadow: 0 0 7px #f17be5;
  }
  100% {
    border-color: #b72a3e;
    box-shadow: 0 0 5px #b72a3e;
  }
}

.glow {
  animation: glowBorder 3s infinite;
}

/*──────────────────────────────
  Main Content
──────────────────────────────*/
main {
  padding: 20px;
  width: 80%;
  margin: 0 auto;
}

/*──────────────────────────────
  Intro Section (with highlighted tooltip text)
──────────────────────────────*/
.intro {
  padding: 10px 20px;
  margin-bottom: 20px;
}

.highlight {
  font-weight: bold;
  color: var(--accent-2); /* Example accent */
  position: relative;
  cursor: help;
  border-bottom: 1px dotted var(--text-secondary);
}

.highlight::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  padding: 5px 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  white-space: nowrap;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.highlight:hover::after {
  opacity: 1;
}

/*──────────────────────────────
  Cards Section
──────────────────────────────*/
.cards-section {
  margin-bottom: 40px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
}

.card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s;
}

.card:hover {
  transform: translateY(-5px);
}

/* Accent styles for cards that use the accent as the heading color */
.accent-heading-1 h3 {
  color: var(--accent-1);
}
.accent-heading-2 h3 {
  color: var(--accent-2);
}
.accent-heading-3 h3 {
  color: var(--accent-3);
}
.accent-heading-4 h3 {
  color: var(--accent-4);
}

/* Accent styles for cards that use the accent as the border color */
.accent-border-1 {
  border-color: var(--accent-1);
}
.accent-border-2 {
  border-color: var(--accent-2);
}
.accent-border-3 {
  border-color: var(--accent-3);
}
.accent-border-4 {
  border-color: var(--accent-4);
}

/*──────────────────────────────
  Buttons Section
──────────────────────────────*/
.buttons-section {
  margin-bottom: 40px;
  padding: 0 20px;
}

.button-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.button {
  padding: 0.5rem;
  font-size: 1em;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  cursor: pointer;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  transition: background-color 0.3s;
  width: fit-content;
}

.button:disabled {
  cursor: not-allowed;
  background-color: var(--bg-primary);
  border: 1px solid var(--bg-secondary);
  color: var(--text-tertiary);
}

.button:hover :enabled {
  background-color: var(--bg-primary);
}

/* Pulsing Glow Keyframes for Accent Buttons */
@keyframes pulseAccent1 {
  0%,
  100% {
    box-shadow: 0 0 5px var(--accent-1);
  }
  50% {
    box-shadow: 0 0 15px var(--accent-1);
  }
}
@keyframes pulseAccent2 {
  0%,
  100% {
    box-shadow: 0 0 5px var(--accent-2);
  }
  50% {
    box-shadow: 0 0 15px var(--accent-2);
  }
}
@keyframes pulseAccent3 {
  0%,
  100% {
    box-shadow: 0 0 5px var(--accent-3);
  }
  50% {
    box-shadow: 0 0 15px var(--accent-3);
  }
}
@keyframes pulseAccent4 {
  0%,
  100% {
    box-shadow: 0 0 5px var(--accent-4);
  }
  50% {
    box-shadow: 0 0 15px var(--accent-4);
  }
}
@keyframes pulseRainbow {
  0% {
    box-shadow: 0 0 5px var(--accent-1);
  }
  25% {
    box-shadow: 0 0 5px var(--accent-2);
  }
  50% {
    box-shadow: 0 0 5px var(--accent-3);
  }
  75% {
    box-shadow: 0 0 5px var(--accent-4);
  }
  100% {
    box-shadow: 0 0 5px var(--accent-1);
  }
}

.pulse-accent-1 {
  animation: pulseAccent1 2s infinite;
}
.pulse-accent-2 {
  animation: pulseAccent2 2s infinite;
}
.pulse-accent-3 {
  animation: pulseAccent3 2s infinite;
}
.pulse-accent-4 {
  animation: pulseAccent4 2s infinite;
}
.pulse-rainbow {
  animation: pulseRainbow 2s infinite;
}

/* Style for disabled buttons */
.disabled-button {
  opacity: 0.5;
  cursor: not-allowed;
}

/*──────────────────────────────
  Table Section & Styling
──────────────────────────────*/
.table-section {
  margin-bottom: 40px;
}

.table-controls {
  margin-bottom: 10px;
}

/* Text Box Style (for table search and other inputs) */
.search-input,
#tableSearch {
  width: 50%;
  padding: 12px;
  font-size: 16px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  background-color: var(--bg-primary);
  color: var(--text-secondary);
}

.search-input:focus,
#tableSearch:focus {
  outline: none;
  border-color: #4a90e2;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

table th,
table td {
  border: 1px solid var(--border-color);
  padding: 10px;
  text-align: left;
  background-color: var(--accent-4);
  color: var(--text-white);
}

table th {
  cursor: pointer;
  background-color: var(--bg-secondary);
  font-weight: bold;
  position: relative;
  color: var(--text-primary);
}

table th[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  padding: 5px 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  white-space: nowrap;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

table th[data-tooltip]:hover::after {
  opacity: 1;
}

table tbody tr:nth-child(even) {
  background-color: var(--bg-secondary);
}

/* Hover effect for table rows */
table tbody tr:hover {
  background-color: var(--table-hover);
}

/*──────────────────────────────
  Modal Styles
──────────────────────────────*/
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: var(--modal-bg);
  justify-content: center;
  align-items: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  padding: 20px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  position: relative;
  min-width: 300px;
  max-height: 80vh; /* Maximum height is 80% of the viewport */
  overflow-y: auto; /* Adds a vertical scrollbar when needed */
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* Fix modal heading spacing */
.modal-content h2 {
  margin-top: 0;
}

.close-button {
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.close-button:hover {
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

.modal-section {
  margin-bottom: 15px;
}

/*──────────────────────────────
  Danger Button Styles
──────────────────────────────*/
.danger-button {
  background-color: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger-text);
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s, border-color 0.3s;
}

.danger-button:hover {
  background-color: var(--danger-hover-bg);
  border-color: var(--danger-hover-border);
}

/*──────────────────────────────
  Footer Styles
──────────────────────────────*/
footer {
  padding: 10px 20px;
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  text-align: center;
  border-top: 1px solid var(--border-color);
  font-size: 0.9em;
}

/*──────────────────────────────
  Responsive Adjustments
──────────────────────────────*/
/* On small screens (600px or less), remove the absolute centering of the header title */
@media (max-width: 600px) {
  header h1 {
    position: static;
    transform: none;
    margin: 0;
  }
}

/* ───── Fuzzy Move Search Styles ───── */
#search-container {
  position: relative;
  width: 100%;
  max-width: 800px;
  margin: 20px auto;
}

#search-container input[type="text"] {
  font-size: 1rem;
  padding: 0.5rem;
  width: 100%;
  box-sizing: border-box;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

#suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-top: none;
  z-index: 10;
  max-height: 300px;
  overflow-y: auto;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#suggestions.visible {
  opacity: 1;
  transform: translateY(0);
}

.suggestion-item.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.suggestion-item {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background-color 0.2s ease;
  color: var(--text-primary);
  display: flex;
  align-items: center;
}

.suggestion-item:hover {
  background-color: var(--dropdown-hover);
}

/* For unlocked mode */
.suggestion-item span.char {
  display: inline-block;
  width: 120px;
  margin-right: 0.5rem;
  font-weight: normal;
}

/* For locked mode */
.suggestion-item span.locked-char {
  display: inline-block;
  margin-right: 0.5rem;
  font-weight: bold;
  background-color: var(--bg-primary);
  padding: 2px 4px;
  border-radius: 3px;
}

/* Command column */
.suggestion-item span.command {
  display: inline-block;
  width: 110px;
  margin-right: 1rem;
}

/* Move name column */
.suggestion-item span.move-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Highlight matching table cells */
.match {
  background-color: var(--accent-1);
  color: var(--text-white);
  font-weight: bold;
}

/* Highlight partially matching table cells */
.partial-match {
  background-color: var(--accent-3);
  color: var(--text-white);
  font-weight: bold;
}

.no-match {
  background-color: var(--accent-4);
  color: var(--text-white);
  font-weight: bold;
}

/* Data table styling for moves */
.data-table {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;
  word-wrap: break-word;
  margin-bottom: 20px;
}

.data-table th,
.data-table td {
  border: 1px solid var(--border-color);
  padding: 8px;
  text-align: left;
}

.data-table th {
  background-color: var(--bg-primary);
  font-weight: bold;
}

.data-table tr:nth-child(even) {
  background-color: var(--bg-secondary);
}

.data-table tr:hover {
  background-color: var(--table-hover);
}

.data-table th[data-tooltip] {
  border-bottom: 1px dotted var(--border-color);
  position: relative; /* Ensure tooltip positioning works correctly */
}

/* Special effects box */
.effect-box {
  display: inline-block;
  padding: 4px 6px;
  margin: 1px 2px 2px 0;
  border-radius: 4px;
  /* font-size: 0.8rem; */
  font-weight: bold;
}

.plus-indicator {
  /* color: var(--accent-4); */
  color: var(--text-white);
  font-weight: bold;
  margin-left: 4px;
}

.minus-indicator {
  /* color: var(--accent-1); */
  color: var(--text-white);
  font-weight: bold;
  margin-left: 4px;
}

/* Responsive adjustments for small screens */
@media (max-width: 500px) {
  .suggestion-item span.char {
    width: 80px;
    margin-right: 0.3rem;
  }
  .suggestion-item span.command {
    width: 80px;
    margin-right: 0.5rem;
  }
}
/* End screen container styling */
#result-display {
  max-width: 500px;
  margin: 40px auto;
  padding: 20px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background-color: var(--bg-secondary);
  text-align: center;
}

/* Styling for paragraphs within the result display */
#result-display p {
  font-size: 1.2em;
  margin: 15px 0;
}

/* Style all buttons inside #result-display as block elements to force separate lines */
#revealButton {
  display: block;
  width: 200px;
  padding: 10px;
  margin: 10px auto;
  font-size: 1em;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background-color: var(--accent-2);
  color: #fff;
}

/* Ensure the correct move display has the same width as the buttons */
#result-display .correct-move {
  display: block;
  width: 200px;
  padding: 10px;
  margin: 10px auto;
  font-size: 1em;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--card-bg);
}

@media (max-width: 1080px) {
  html,
  body,
  main {
    overflow-x: hidden;
    margin: 0;
    padding: 0;
    width: 100%;
  }
}

/* Mobile Adjustments for Screens 600px or Less */
@media (max-width: 600px) {
  html,
  body,
  main {
    overflow-x: hidden;
    margin: 0;
    padding: 0;
    width: 100%;
  }

  table th,
  table td {
    max-width: 7vw;
  }

  /* Search container remains full-width */
  #search-container {
    width: 100%;
    margin: 10px auto;
  }
  #search-container input[type="text"] {
    width: 100%;
    padding: 0.75rem;
  }

  /* Make the table container flush with the viewport */
  .table-section {
    /* overflow-x: auto; */
    /* -webkit-overflow-scrolling: touch; */
    width: 100%;
    padding: 0;
    margin: 0;
  }

  /* The data table will be wider than the viewport and scrollable */
  .data-table {
    display: block;
    /* overflow-x: auto; */
    /* -webkit-overflow-scrolling: touch; */
    width: 100%; /* Adjust based on content */
    margin: 0px; /* Remove any offset */
    padding: 0px;
    font-size: 0.45rem;
  }
}
