/* ============================================================
   LINUXQUEST - COMPONENTS.CSS
   Buttons, code blocks, stars, badges, pipe builder, matching
   Terminal/hacker aesthetic
   ============================================================ */

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-terminal);
  font-size: 10px;
  padding: 14px 24px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
  min-height: 48px;
  letter-spacing: 0.5px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.btn:active {
  transform: scale(0.97) !important;
}

.btn-primary {
  background: #00ff41;
  border-color: #00ff41;
  color: #000;
  box-shadow: 0 0 12px rgba(0, 255, 65, 0.4);
}

.btn-primary:hover {
  background: #39ff74;
  border-color: #39ff74;
  box-shadow: 0 0 24px rgba(0, 255, 65, 0.7);
  transform: translateY(-2px);
}

.btn-secondary {
  background: transparent;
  border-color: #00ff41;
  color: #00ff41;
  box-shadow: 0 0 6px rgba(0, 255, 65, 0.2);
}

.btn-secondary:hover {
  background: rgba(0, 255, 65, 0.1);
  box-shadow: 0 0 16px rgba(0, 255, 65, 0.4);
  transform: translateY(-2px);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
}

.btn-ghost:hover {
  border-color: var(--text-dim);
  color: var(--text);
  transform: translateY(-2px);
}

.btn-danger {
  background: transparent;
  border-color: #f85149;
  color: #f85149;
}

.btn-danger:hover {
  background: rgba(248, 81, 73, 0.1);
  box-shadow: 0 0 16px rgba(248, 81, 73, 0.3);
  transform: translateY(-2px);
}

.btn-hint {
  background: transparent;
  border-color: #eab308;
  color: #eab308;
  font-size: 9px;
}

.btn-hint:hover {
  background: rgba(234, 179, 8, 0.1);
  box-shadow: 0 0 12px rgba(234, 179, 8, 0.3);
  transform: translateY(-2px);
}

.btn.hidden { display: none; }

.btn-back {
  padding: 10px 16px;
  font-size: 9px;
}

/* Zone-colored primary buttons adapt to current zone */
.btn-zone-primary {
  background: var(--zone-color, var(--accent));
  border-color: var(--zone-color, var(--accent));
  color: #000;
  box-shadow: 0 0 12px rgba(var(--zone-color-rgb, 0, 255, 65), 0.4);
}

/* ============================================================
   OPTION BUTTONS (for terminal_oracle, corruption_scan)
   ============================================================ */

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.options-grid-single {
  grid-template-columns: 1fr;
}

@media (max-width: 480px) {
  .options-grid { grid-template-columns: 1fr; }
}

.option-btn {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s, transform 0.15s, box-shadow 0.15s;
  min-height: 60px;
}

.option-btn:hover {
  border-color: #00ff41;
  background: rgba(0, 255, 65, 0.05);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.option-btn.correct {
  border-color: #00ff41;
  background: rgba(0, 255, 65, 0.1);
}

.option-btn.wrong {
  border-color: #f85149;
  background: rgba(248, 81, 73, 0.1);
}

.option-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.option-label {
  font-family: var(--font-terminal);
  font-size: 9px;
  color: var(--accent);
  min-width: 20px;
  flex-shrink: 0;
  padding-top: 2px;
}

.option-text {
  flex: 1;
  line-height: 1.5;
}

/* ============================================================
   PIPE BUILDER
   ============================================================ */

.pipe-goal {
  background: rgba(0, 255, 65, 0.05);
  border-left: 3px solid #00ff41;
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: 0 6px 6px 0;
}

.pipe-goal-label {
  font-family: var(--font-code);
  color: #00ff41;
  margin-right: 8px;
  font-size: 12px;
}

.pipe-goal-text {
  color: #c9d1d9;
  font-size: 14px;
}

.pipe-option {
  width: 100%;
  text-align: left;
}

.pipe-option pre,
.pipe-option-code {
  font-family: var(--font-code);
  font-size: 13px;
  color: #c9d1d9;
  white-space: pre-wrap;
  text-align: left;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow-x: auto;
}

/* ============================================================
   CODE BLOCKS
   ============================================================ */

.code-block-wrapper {
  position: relative;
  margin: 12px 0;
}

.code-block {
  display: block;
  background: #0a0c10;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  font-family: var(--font-code);
  font-size: 13px;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre;
  color: #c9d1d9;
  direction: ltr;
  text-align: left;
  tab-size: 4;
  -webkit-overflow-scrolling: touch;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0d0f14;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 8px 14px;
}

.code-block-header + .code-block {
  border-radius: 0 0 8px 8px;
  border-top: none;
}

.code-block-dots {
  display: flex;
  gap: 6px;
}

.code-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.code-dot-red    { background: #ff5f56; }
.code-dot-yellow { background: #ffbd2e; }
.code-dot-green  { background: #27c93f; }

.code-block-label {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-code);
}

/* Bash syntax highlight colors */
.code-block .kw      { color: #ff7b72; font-weight: 600; }   /* if for do done while */
.code-block .str     { color: #a5d6ff; }                      /* strings */
.code-block .num     { color: #f2cc60; }                      /* numbers */
.code-block .cmt     { color: #6e7681; font-style: italic; }  /* comments */
.code-block .fn      { color: #d2a8ff; }                      /* function names */
.code-block .builtin { color: #79c0ff; }                      /* ls grep chmod etc */
.code-block .var     { color: #ffa657; }                      /* $VAR */
.code-block .flag    { color: #d2a8ff; }                      /* -la --help */
.code-block .op      { color: #ff7b72; }                      /* pipe | && || */
.code-block .redir   { color: #ffa657; }                      /* > >> */
.code-block .shebang { color: #8b949e; font-style: italic; }  /* #!/bin/bash */

/* Code with blanks (command_forge fill-in) */
.code-blank-input {
  display: inline-block;
  background: rgba(0, 255, 65, 0.1);
  border: 1px solid #00ff41;
  border-radius: 4px;
  padding: 1px 8px;
  font-family: var(--font-code);
  font-size: 13px;
  color: #00ff41;
  min-width: 80px;
  max-width: 200px;
  vertical-align: middle;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  direction: ltr;
}

.code-blank-input:focus {
  border-color: #39ff74;
  box-shadow: 0 0 8px rgba(0, 255, 65, 0.4);
}

.code-blank-input.correct {
  border-color: #00ff41;
  background: rgba(0, 255, 65, 0.1);
  color: #00ff41;
}

.code-blank-input.wrong {
  border-color: #f85149;
  background: rgba(248, 81, 73, 0.1);
  color: #f85149;
}

/* Spell/command submit area */
.spell-submit-area {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  align-items: center;
}

/* ============================================================
   NAME BINDING (Matching)
   ============================================================ */

.name-binding-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

@media (max-width: 480px) {
  .name-binding-container {
    grid-template-columns: 1fr;
  }
}

.binding-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.binding-column-label {
  font-family: var(--font-terminal);
  font-size: 8px;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.binding-item {
  padding: 12px 16px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
  user-select: none;
  min-height: 48px;
  display: flex;
  align-items: center;
}

.binding-item:hover:not(.paired):not(.disabled) {
  border-color: #00ff41;
  background: rgba(0, 255, 65, 0.06);
  transform: translateX(2px);
}

.binding-item.selected {
  border-color: #00ff41;
  background: rgba(0, 255, 65, 0.12);
  box-shadow: 0 0 10px rgba(0, 255, 65, 0.3);
}

.binding-item.paired {
  border-color: #00ff41;
  background: rgba(0, 255, 65, 0.08);
  color: #00ff41;
  cursor: default;
}

.binding-item.wrong-pair {
  border-color: #f85149;
  background: rgba(248, 81, 73, 0.08);
}

.binding-item.correct-reveal {
  border-color: #00ff41;
  background: rgba(0, 255, 65, 0.12);
  color: #00ff41;
}

.binding-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.binding-pair-indicator {
  font-size: 10px;
  margin-right: 8px;
  color: #00ff41;
}

.binding-submit-area {
  margin-top: 16px;
  display: flex;
  justify-content: center;
}

/* ============================================================
   TERMINAL TEXT UTILITY
   ============================================================ */

.term-text {
  font-family: var(--font-code);
  direction: ltr;
}

/* ============================================================
   STARS
   ============================================================ */

.star-filled  { color: #eab308; }
.star-empty   { color: #30363d; }
.star-large   { font-size: 40px; }
.star-small   { font-size: 16px; }

/* ============================================================
   CHALLENGE TYPE BADGES
   ============================================================ */

.badge-terminal_oracle { color: #00ff41;  border-color: #00ff41  !important; }
.badge-command_forge   { color: #79c0ff;  border-color: #79c0ff  !important; }
.badge-script_debug    { color: #f85149;  border-color: #f85149  !important; }
.badge-flag_map        { color: #a5d6ff;  border-color: #a5d6ff  !important; }
.badge-pipe_builder    { color: #ffa657;  border-color: #ffa657  !important; }

/* ============================================================
   RESULT OVERLAY ON OPTION BUTTONS (correct/wrong markers)
   ============================================================ */

.result-icon {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 16px;
}

/* ============================================================
   CHALLENGE QUESTION TYPE LABELS
   ============================================================ */

.challenge-type-title {
  font-family: var(--font-terminal);
  font-size: 9px;
  margin-bottom: 12px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

/* ============================================================
   SCROLLBAR STYLING
   ============================================================ */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--surface);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #484f58;
}

/* ============================================================
   HP DANGER STATE
   ============================================================ */

.hp-fill.danger {
  background: linear-gradient(90deg, #7f1d1d, #f85149);
  animation: danger-pulse 1s ease-in-out infinite;
}

@keyframes danger-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.hp-fill.critical {
  background: linear-gradient(90deg, #450a0a, #f85149);
  animation: danger-pulse 0.5s ease-in-out infinite;
}

/* ============================================================
   LOADING / TRANSITION STATES
   ============================================================ */

.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   ENCOUNTER STATUS INDICATORS
   ============================================================ */

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.status-dot.complete  { background: #00ff41; }
.status-dot.available { background: var(--accent); animation: node-pulse 2s infinite; }
.status-dot.locked    { background: var(--border); }

/* ============================================================
   REVEAL SCREEN SPECIFIC
   ============================================================ */

.reveal-wrong-was {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

.reveal-continue-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.reveal-flavor-text {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* ============================================================
   WORLD MAP ENCOUNTER STARS ON ZONE CARD
   ============================================================ */

.zone-node-enc-stars {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.enc-star-row {
  display: flex;
  gap: 3px;
  align-items: center;
}

.enc-star-row-label {
  font-size: 9px;
  color: var(--text-muted);
  margin-right: 4px;
}
