/* SPDX-License-Identifier: MIT */
/* keeBLEr64 — Commodore-inspired theme overrides
 * Applied via body.c64-mode class, overrides CSS custom properties from style.css */

@font-face {
  font-family: 'C64';
  src: url('data:font/woff2;charset=utf-8;base64,') format('woff2');
  /* Fallback to system monospace — actual C64 font can be loaded externally */
}

body.c64-mode {
  --bg-primary: #40318d;
  --bg-secondary: #3b2d82;
  --bg-tertiary: #534b9e;
  --bg-panel: #352a78;
  --text-primary: #7b71d5;
  --text-secondary: #6a60c0;
  --accent: #7b71d5;
  --accent-hover: #a09ae0;
  --accent-active: #c0bcee;
  --success: #6ec56e;
  --warning: #d5c571;
  --error: #d57171;
  --border: #5a50a0;
  --dot-disconnected: #534b9e;
  --dot-connecting: #d5c571;
  --dot-connected: #6ec56e;
  --dot-error: #d57171;
}

body.c64-mode header {
  background: #40318d;
  border-bottom-color: #7b71d5;
}

body.c64-mode header h1 {
  font-family: var(--font-mono);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #7b71d5;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.4);
}

body.c64-mode header h1::before {
  content: '\2588 ';  /* Block character */
  animation: c64-cursor 1s step-end infinite;
}

@keyframes c64-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

body.c64-mode header .subtitle {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #6a60c0;
}

body.c64-mode footer {
  background: #3b2d82;
  border-top-color: #5a50a0;
  color: #6a60c0;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

body.c64-mode #video-section {
  border-color: #7b71d5;
  border-width: 2px;
}

/*
 * C64 mode button system — coherent palette:
 *
 *   Resting:  medium-purple bg, white text, light-purple border
 *   Hover:    white bg, dark-purple text (inverted — high contrast)
 *   Active:   dark bg, light text (pressed feel)
 *   Disabled: opacity fade (inherited)
 *
 *   Accent buttons (BLE, Serial, etc.) tint the border + text
 *   but share the same hover/active behavior.
 */

body.c64-mode button {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #534b9e;
  color: #e0dcff;
  border-color: #7b71d5;
}

body.c64-mode button:hover:not(:disabled) {
  background: #e0dcff;
  color: #40318d;
  border-color: #e0dcff;
}

body.c64-mode button:active:not(:disabled) {
  background: #352a78;
  color: #c0bcee;
  border-color: #7b71d5;
}

/* Accent-tinted buttons — unique resting color, shared hover/active */
body.c64-mode #btn-ble {
  color: #c0bcee;
  border-color: #a09ae0;
}

body.c64-mode #btn-serial {
  color: #d5c571;
  border-color: #d5c571;
}

body.c64-mode #btn-serial:hover:not(:disabled) {
  background: #d5c571;
  color: #40318d;
  border-color: #d5c571;
}

body.c64-mode #btn-disconnect {
  color: #e88;
  border-color: #e88;
}

body.c64-mode #btn-disconnect:hover:not(:disabled) {
  background: #e88;
  color: #40318d;
  border-color: #e88;
}

body.c64-mode #btn-loopback {
  color: #7d7;
  border-color: #7d7;
}

body.c64-mode #btn-loopback:hover:not(:disabled) {
  background: #7d7;
  color: #40318d;
  border-color: #7d7;
}

body.c64-mode select,
body.c64-mode input {
  font-family: var(--font-mono);
}

/* C64 Quick Bar — sits directly below the video in C64 mode */

#c64-quick-bar {
  display: none;  /* hidden by default, shown via c64-mode */
}

body.c64-mode #c64-quick-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  background: #352a78;
  border: 2px solid #7b71d5;
  border-top: none;
  border-radius: 0 0 8px 8px;
  /* Match video section width */
  width: 100%;
  max-width: 960px;
  margin: -8px auto 0;  /* overlap video bottom radius, center */
}

body.c64-mode #video-section.large ~ #c64-quick-bar {
  max-width: 100%;
}

/* Quick bar buttons inherit C64 button styles; just size them */
body.c64-mode #c64-quick-bar button {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  border-radius: 3px;
}

.c64-qb-sep {
  width: 1px;
  height: 1.2em;
  background: #5a50a0;
  margin: 0 0.2rem;
}

#c64-quick-status {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #6a60c0;
}

/* C64 mode: collapse video section border-radius at bottom when quick bar is visible */
body.c64-mode #video-section {
  border-radius: 8px 8px 0 0;
}

/* C64 mode: auto-open the file transfer panel and emphasize it */
body.c64-mode #c64-section {
  border-color: #7b71d5;
  border-width: 2px;
}

body.c64-mode #c64-details summary {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* C64 mode: restyle the drop zone with PETSCII-style border */
body.c64-mode #c64-drop-zone {
  border-style: solid;
  border-color: #7b71d5;
  font-family: var(--font-mono);
  text-transform: uppercase;
}

body.c64-mode #c64-drop-zone.dragover {
  border-color: #a09ae0;
  background: rgba(123, 113, 213, 0.15);
}

/* C64 mode: monospace everything in log */
body.c64-mode .log-entry {
  font-family: var(--font-mono);
}

/* C64 mode: section headers */
body.c64-mode h3 {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #7b71d5;
}

/* C64 mode: system details accordion */
body.c64-mode #system-details > details > summary {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* C64 mode: reorder sections — file transfer above mouse, mouse at bottom */

body.c64-mode main {
  display: flex;
  flex-direction: column;
}

body.c64-mode #video-section   { order: 1; }
body.c64-mode #c64-quick-bar   { order: 2; }
body.c64-mode #controls        { order: 3; }
body.c64-mode #c64-section     { order: 4; }
body.c64-mode #wifi-section    { order: 5; }
body.c64-mode #system-details  { order: 6; }
body.c64-mode #mouse-area      { order: 7; }

/* 1541 disk drive progress indicator */
#c64-transfer-progress {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
}

#c64-transfer-progress.active {
  display: flex;
}

.c64-drive-icon {
  width: 40px;
  height: 24px;
  background: #534b9e;
  border: 2px solid #7b71d5;
  border-radius: 3px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.c64-drive-led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4a4;
  position: absolute;
  top: 3px;
  right: 3px;
}

.c64-drive-led.active {
  background: #f44;
  animation: c64-led-flicker 0.15s infinite alternate;
}

@keyframes c64-led-flicker {
  from { opacity: 1; }
  to { opacity: 0.3; }
}

.c64-progress-bar {
  flex: 1;
  height: 8px;
  background: #352a78;
  border: 1px solid #7b71d5;
  border-radius: 2px;
  overflow: hidden;
}

.c64-progress-fill {
  height: 100%;
  background: #7b71d5;
  width: 0%;
  transition: width 0.1s linear;
}

.c64-progress-text {
  min-width: 5em;
  text-align: right;
  color: #a09ae0;
}

/* WiFi proxy section */
body.c64-mode #wifi-section {
  border-color: #7b71d5;
  border-width: 2px;
}

body.c64-mode #wifi-details summary {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

#wifi-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

#wifi-status-bar {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

#wifi-status-text {
  color: var(--text-secondary);
}

/* Info tooltip */
.info-tooltip {
  position: relative;
  display: inline-block;
  cursor: help;
  color: var(--accent);
  font-size: 1.1em;
  vertical-align: middle;
  margin-left: 0.3em;
}

.tooltip-content {
  display: none;
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  background: #352a78;
  color: #e0dcff;
  border: 1px solid #7b71d5;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-size: 0.78rem;
  line-height: 1.6;
  width: 300px;
  z-index: 100;
  text-transform: none;
  letter-spacing: normal;
  font-weight: normal;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.tooltip-content::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #7b71d5;
}

.info-tooltip:hover .tooltip-content,
.info-tooltip:focus .tooltip-content {
  display: block;
}

/* WiFi/BLE status icons — inline in the summary header */
.wifi-icon {
  display: inline-block;
  font-size: 0.9em;
  margin-left: 0.5em;
  vertical-align: middle;
}

/* Icon states via CSS content + color */
.wifi-icon::after {
  content: '\1F4F6';  /* antenna bars — 📶 */
}

.wifi-icon.disconnected { opacity: 0.3; filter: grayscale(1); }
.wifi-icon.sta-connected { opacity: 1; filter: none; }
.wifi-icon.sta-connecting { opacity: 0.7; filter: hue-rotate(30deg); }
.wifi-icon.ap-active::after { content: '\1F4E1'; }  /* satellite — 📡 */
.wifi-icon.ap-active { opacity: 1; filter: none; }

/* BLE status icon */
.ble-icon {
  display: inline-block;
  font-size: 0.9em;
  vertical-align: middle;
}

.ble-icon::after {
  content: '\1F91C';  /* Bluetooth-ish — using 🤜 as placeholder, replaced by text below */
}

/* Use text-based BLE symbol since there's no good unicode BLE icon */
.ble-icon::after {
  content: 'BLE';
  font-family: var(--font-mono);
  font-size: 0.65em;
  font-weight: bold;
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid;
}

.ble-icon.disconnected::after {
  color: #888;
  border-color: #666;
  background: transparent;
}

.ble-icon.connecting::after {
  color: #e8a020;
  border-color: #e8a020;
  background: rgba(232, 160, 32, 0.1);
  animation: ble-pulse 1s ease-in-out infinite;
}

.ble-icon.connected::after {
  color: #4488ff;
  border-color: #4488ff;
  background: rgba(68, 136, 255, 0.15);
}

@keyframes ble-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
