/*
 * EduGames - Interactive Learning Games
 * (c) 2025-2026 Prof. N. All rights reserved.
 *
 * File:    styles/components/control-panel.css
 * Updated: 2026-10-04 13:01
 * Purpose: The control panel of a game page (scripts/components/control-panel.js): the box, the button grid, the
 *          options row, the volume widget, and the .action-button look shared with the selector buttons.
 */

/* The box. Its width is set by the game page layout (styles/core/layout.css). */
#controlPanel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-sizing: border-box;
  padding: 8px 10px;
  background: var(--bg-panel);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 15px var(--shadow-color);
  transition: background-color 0.3s, border-color 0.3s;
}

.control-panel-error {
  padding: 10px;
  color: var(--text-danger);
}

/*
 * Button grid. Control positions come from the catalog (inline grid-column/grid-row set by ControlPanel).
 * The two columns of text buttons are narrow and the two columns of symbol buttons half as wide, so the panel is
 * about as wide as the scoreboard; the last column holds the volume widget.
 */
.control-panel {
  display: grid;
  grid-template-columns: 62px 62px 31px 31px 25px;
  grid-template-rows: auto auto auto;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px;
}

/* Volume slider: spans the two button rows of the last column; the mute button sits under it */
.vertical-slider {
  grid-column: -2 / -1;
  grid-row: 1 / span 2;
  justify-self: center;
  writing-mode: vertical-lr;
  direction: rtl; /* the top is the maximum */
  appearance: auto;
  width: 20px;
  height: 64px;
  margin: 0;
  cursor: pointer;
}

.cp-mute {
  grid-column: -2 / -1;
  grid-row: 3;
  justify-self: center;
  margin-top: 4px;
  padding: 0;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
}

.cp-mute.is-muted {
  opacity: 0.5;
}

/* Options row: dropdowns and checkboxes declared by the game, on one line under the buttons */
.control-panel-options {
  display: flex;
  align-items: center;
  flex-wrap: wrap; /* three options do not fit one row on a phone */
  justify-content: space-around;
  gap: 4px;
  grid-column: 1 / -2;
  grid-row: 3;
  margin-top: 4px;
  padding-top: 5px;
  border-top: 1px solid var(--border-color);
}

.option-select,
.option-checkbox {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* a label of up to two lines with its control to its right; one-line labels stay narrow, longer ones wrap at 52px */
.option-select label,
.option-checkbox label {
  width: max-content;
  max-width: 52px;
  margin: 0;
  font-size: 0.66rem;
  font-weight: bold;
  line-height: 1.1;
  text-align: left;
  color: var(--text-secondary);
}

.option-select select {
  box-sizing: border-box;
  min-width: 36px;
  height: 24px;
  padding: 1px 0;
  font-size: 0.7rem;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.option-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0 0 0 2px;
  cursor: pointer;
}

/* Buttons (also used by the selector: Load, Random) */
.action-button {
  display: block;
  width: 100%;
  padding: 6px 5px;
  font-size: 0.8rem;
  font-weight: bold;
  text-align: center;
  white-space: nowrap; /* a label never wraps */
  overflow: hidden;
  text-overflow: ellipsis;
  background-color: var(--color-primary);
  color: var(--on-primary);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.action-button:hover {
  background-color: color-mix(in srgb, var(--color-primary) 85%, #000);
}

/* compact buttons of the panel */
.control-panel .action-button {
  height: 30px;
  padding: 2px 0;
  font-size: 0.8rem;
  border-radius: 4px;
}

.control-panel .action-button.small-button,
.control-panel .action-button.icon-control {
  font-size: 1rem;
}

.control-panel .action-button.icon-control {
  font-size: 1.15rem;
  font-weight: bold;
  line-height: 1;
}

.action-button:disabled {
  background-color: var(--bg-disabled);
  color: var(--text-disabled);
  box-shadow: none;
  cursor: not-allowed;
  pointer-events: none; /* no clicks */
}

/* Controls this game does not use: grayed out but still hoverable so the tooltip shows */
.control-panel .action-button.inactive-control {
  opacity: 0.4;
  cursor: not-allowed;
}

/* phones: easier to tap */
@media (max-width: 768px) {
  .control-panel .action-button {
    height: 36px;
  }
}
