/* ==========================================================================
   ApexReach // High-Reach Jump Tracker Core CSS
   Design: Cyber-Athletic Dark Grid & Premium Glassmorphism
   ========================================================================== */

/* --- Custom Variables & Palette --- */
:root {
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Premium harmonious color palette */
  --bg-space: #050a17;
  --bg-card: rgba(11, 20, 44, 0.55);
  --bg-card-hover: rgba(16, 29, 64, 0.7);
  --border-color: rgba(0, 229, 255, 0.12);
  --border-color-pink: rgba(255, 0, 127, 0.15);
  
  --accent-cyan: #00f0ff;
  --accent-cyan-rgb: 0, 240, 255;
  --accent-pink: #ff007f;
  --accent-pink-rgb: 255, 0, 127;
  --accent-yellow: #ffe600;
  --accent-green: #00ff88;
  --text-primary: #f0f4ff;
  --text-secondary: #8da2cf;
  --glow-radius: 12px;
  
  --transition-speed: 0.3s;
}

/* --- Base Reset & Setup --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg-space);
  color: var(--text-primary);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

/* --- Cybernetic Grid & Visual Effects --- */
.grid-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(rgba(0, 240, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  background-position: center center;
  pointer-events: none;
  z-index: 1;
}

.grid-overlay::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 50%, transparent 20%, var(--bg-space) 85%);
  pointer-events: none;
}

/* --- Typography --- */
h1, h2, h3, .metric-display, .record-value {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* --- Header Section --- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  background: rgba(5, 10, 23, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  z-index: 10;
  position: relative;
}

.logo-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.robi3-logo {
  height: 42px;
  width: auto;
  object-fit: contain;
  background-color: #ffffff;
  border-radius: 8px;
  padding: 4px 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), 0 0 8px rgba(255, 255, 255, 0.15);
}

.title-sub-wrapper {
  display: flex;
  flex-direction: column;
}

.logo-wrapper h1 {
  font-size: 1.4rem;
  letter-spacing: 0.1em;
  background: linear-gradient(90deg, var(--text-primary) 60%, var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0;
  line-height: 1.1;
}

.logo-byline {
  font-size: 0.65rem;
  color: var(--accent-cyan);
  font-family: var(--font-body);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: none;
  margin-top: 1px;
}

.logo-version {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: var(--font-body);
  border: 1px solid rgba(141, 162, 207, 0.3);
  padding: 1px 6px;
  border-radius: 4px;
  align-self: flex-start;
  margin-top: 2px;
}

.privacy-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(0, 255, 136, 0.06);
  border: 1px solid rgba(0, 255, 136, 0.25);
  padding: 0.4rem 0.8rem;
  border-radius: 30px;
}

.shield-icon {
  font-size: 0.9rem;
}

.privacy-text {
  font-size: 0.75rem;
  color: var(--accent-green);
  font-weight: 600;
  letter-spacing: 0.05em;
}

/* --- Main Layout Grid --- */
.app-container {
  flex: 1;
  display: grid;
  grid-template-columns: 340px 1fr 340px;
  gap: 1.5rem;
  padding: 1.5rem;
  z-index: 5;
  position: relative;
  max-width: 1800px;
  width: 100%;
  margin: 0 auto;
}

/* --- Panel Layouts --- */
.panel {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  min-height: 0; /* allows grid scrolling container */
}

.panel-title {
  font-size: 0.85rem;
  color: var(--text-secondary);
  letter-spacing: 0.2em;
  padding-left: 0.5rem;
  position: relative;
  display: flex;
  align-items: center;
}

.panel-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 12px;
  background: var(--accent-cyan);
  margin-right: 0.5rem;
  box-shadow: 0 0 8px var(--accent-cyan);
}

.panel-right .panel-title::before {
  background: var(--accent-pink);
  box-shadow: 0 0 8px var(--accent-pink);
}

/* --- Premium Glass Cards --- */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.25rem;
  transition: all var(--transition-speed) cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(0, 240, 255, 0.25);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.card h3 {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  letter-spacing: 0.1em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.5rem;
}

/* --- Form Elements & Widgets --- */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.input-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.input-with-units {
  display: flex;
  background: rgba(5, 10, 23, 0.6);
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.input-with-units:focus-within {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.25);
}

.input-with-units input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.2rem;
  font-weight: bold;
  padding: 0.6rem 1rem;
  width: 100%;
  font-family: var(--font-display);
  outline: none;
}

/* Chrome/Safari up/down arrows removal */
.input-with-units input::-webkit-outer-spin-button,
.input-with-units input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Firefox removal */
.input-with-units input[type=number] {
  -moz-appearance: textfield;
}

.unit-toggle {
  display: flex;
  padding: 2px;
  background: rgba(255, 255, 255, 0.05);
  margin: 4px;
  border-radius: 6px;
}

.unit-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: bold;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
}

.unit-btn.active {
  background: var(--accent-cyan);
  color: #050a17;
  box-shadow: 0 2px 6px rgba(0, 240, 255, 0.4);
}

.mode-toggle {
  display: flex;
  padding: 2px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(0, 240, 255, 0.15);
}

.mode-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: bold;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mode-btn.active {
  background: var(--accent-cyan);
  color: #050a17;
  box-shadow: 0 2px 8px rgba(0, 240, 255, 0.4);
}


.setting-hint {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 0.75rem;
  line-height: 1.4;
}

/* --- Elite Action Buttons --- */
.btn {
  width: 100%;
  padding: 0.85rem 1.25rem;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--transition-speed) cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, #00b0ff, var(--accent-cyan));
  color: #050a17;
  border: none;
  box-shadow: 0 4px 15px rgba(0, 240, 255, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-cyan), #00ffcc);
  box-shadow: 0 6px 22px rgba(0, 240, 255, 0.5);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid rgba(255, 230, 0, 0.3);
  box-shadow: inset 0 0 10px rgba(255, 230, 0, 0.03);
}

.btn-secondary:hover {
  border-color: var(--accent-yellow);
  background: rgba(255, 230, 0, 0.08);
  box-shadow: 0 4px 14px rgba(255, 230, 0, 0.15);
}

.btn-tertiary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.8rem;
  padding: 0.5rem 1rem;
}

.btn-tertiary:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
}

/* --- Countdown Calibration HUD list --- */
.calibration-steps {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.2rem;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  transition: all 0.25s;
}

.step-item.active {
  border-color: var(--accent-cyan);
  background: rgba(0, 240, 255, 0.03);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.1);
}

.step-item.completed {
  border-color: var(--accent-green);
  background: rgba(0, 255, 136, 0.03);
}

.step-num {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.8rem;
  color: #050a17;
  background: var(--text-secondary);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s;
}

.step-item.active .step-num {
  background: var(--accent-cyan);
  color: #050a17;
  box-shadow: 0 0 6px var(--accent-cyan);
}

.step-item.completed .step-num {
  background: var(--accent-green);
  color: #050a17;
  box-shadow: 0 0 6px var(--accent-green);
}

.step-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.step-item.active .step-desc {
  color: var(--text-primary);
  font-weight: 600;
}

.card-instructions ol {
  padding-left: 1.1rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  line-height: 1.4;
}

.card-instructions li::marker {
  color: var(--accent-cyan);
  font-weight: bold;
}

/* --- CENTER PANEL: VIDEO HUD VIEWER --- */
.feed-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #02050b;
  border: 1.5px solid var(--border-color);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), inset 0 0 50px rgba(0, 240, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: center;
}

#canvas-hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
}

/* Countdown Overlay text */
#countdown-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 10, 23, 0.7);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  transition: opacity 0.3s;
}

#countdown-number {
  font-family: var(--font-display);
  font-size: 7rem;
  font-weight: 900;
  color: var(--accent-cyan);
  text-shadow: 0 0 30px rgba(0, 240, 255, 0.6), 0 0 60px rgba(0, 240, 255, 0.3);
  animation: pulseScale 1s infinite alternate;
}

@keyframes pulseScale {
  0% { transform: scale(0.9); opacity: 0.8; }
  100% { transform: scale(1.1); opacity: 1; }
}

.feed-badge {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 5;
  background: rgba(5, 10, 23, 0.8);
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  backdrop-filter: blur(10px);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-cyan);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-cyan);
  animation: pulseAlpha 1.2s infinite;
}

#hud-status-text {
  font-size: 0.7rem;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent-cyan);
}

@keyframes pulseAlpha {
  0% { opacity: 0.3; }
  50% { opacity: 1; }
  100% { opacity: 0.3; }
}

.hidden {
  opacity: 0 !important;
  pointer-events: none !important;
  display: none !important;
}

/* --- RIGHT PANEL: HIGH PERFORMANCE METRICS --- */
.card-main-stats {
  border-color: var(--border-color-pink);
  background: linear-gradient(180deg, var(--bg-card), rgba(255, 0, 127, 0.02));
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card-main-stats:hover {
  border-color: rgba(255, 0, 127, 0.3);
}

.metric-container {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--text-secondary);
}

.metric-display {
  font-size: 2.6rem;
  font-weight: 900;
  display: flex;
  align-items: baseline;
  line-height: 1.1;
  margin-top: 0.2rem;
}

.metric-unit-suffix {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-left: 0.3rem;
  text-shadow: none;
}

/* Neon Text Glow Classes */
.text-glow-cyan {
  color: var(--accent-cyan);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.4), 0 0 20px rgba(0, 240, 255, 0.2);
}

.text-glow-pink {
  color: var(--accent-pink);
  text-shadow: 0 0 10px rgba(255, 0, 127, 0.4), 0 0 20px rgba(255, 0, 127, 0.2);
}

.text-glow-yellow {
  color: var(--accent-yellow);
  text-shadow: 0 0 10px rgba(255, 230, 0, 0.3);
}

.text-glow-green {
  color: var(--accent-green);
  text-shadow: 0 0 10px rgba(0, 255, 136, 0.4);
}

/* Sub-Metrics details */
.card-sub-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
}

.sub-metric {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sub-label {
  font-size: 0.65rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sub-value {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Peak Records */
.card-records {
  border-color: rgba(255, 230, 0, 0.1);
}

.record-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.record-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.record-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.record-icon {
  font-size: 1rem;
}

.record-value-wrapper {
  display: flex;
  align-items: baseline;
}

.record-value {
  font-size: 1.3rem;
  font-weight: 800;
}

.record-unit {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-left: 0.15rem;
}

.card-system-ops {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.03);
}

/* --- Flash Screen & Burst Animations --- */
.screen-flash-cyan {
  animation: flashCyanEffect 0.6s ease-out;
}

.screen-flash-pink {
  animation: flashPinkEffect 0.6s ease-out;
}

@keyframes flashCyanEffect {
  0% { box-shadow: inset 0 0 100px rgba(0, 240, 255, 0.6); }
  100% { box-shadow: inset 0 0 0 rgba(0, 240, 255, 0); }
}

@keyframes flashPinkEffect {
  0% { box-shadow: inset 0 0 100px rgba(255, 0, 127, 0.6); }
  100% { box-shadow: inset 0 0 0 rgba(255, 0, 127, 0); }
}

/* --- Footer --- */
.app-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.7rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-color);
  background: rgba(5, 10, 23, 0.9);
  z-index: 10;
  position: relative;
  margin-top: auto;
}

.app-footer p {
  letter-spacing: 0.05em;
}

.app-footer p strong {
  color: var(--accent-cyan);
}

/* --- Session History Table & Leaderboard Scrollbar --- */
.card-history {
  border-color: rgba(0, 240, 255, 0.15);
}

.history-table-wrapper::-webkit-scrollbar {
  width: 5px;
}

.history-table-wrapper::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 4px;
}

.history-table-wrapper::-webkit-scrollbar-thumb {
  background: rgba(0, 240, 255, 0.25);
  border-radius: 4px;
}

.history-table-wrapper::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 240, 255, 0.55);
}

#session-log-table tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: background-color 0.2s;
}

#session-log-table tr:hover {
  background: rgba(0, 240, 255, 0.02);
}

#session-log-table td {
  padding: 0.6rem 0.25rem;
  font-family: var(--font-body);
}

#session-log-table tbody tr.new-jump-row {
  animation: row-flash-neon 1s ease-out;
}

@keyframes row-flash-neon {
  0% { background: rgba(0, 240, 255, 0.3); }
  100% { background: transparent; }
}

/* --- Jump Gameplay Pulse Buttons --- */
.card-game {
  border-color: rgba(255, 0, 127, 0.15) !important;
}

.pulse-button {
  animation: button-pulse-glow 1.5s infinite alternate;
  box-shadow: 0 0 15px rgba(255, 51, 85, 0.5) !important;
}

@keyframes button-pulse-glow {
  0% { transform: scale(1.0); box-shadow: 0 0 10px rgba(255, 51, 85, 0.4); }
  100% { transform: scale(1.02); box-shadow: 0 0 25px rgba(255, 51, 85, 0.8); }
}

/* --- Collapsible Calibration Card --- */
#calibration-card-body {
  max-height: 800px;
  opacity: 1;
  transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease-out, margin 0.35s ease-out, padding 0.35s ease-out;
  overflow: hidden;
}

#calibration-card-body.collapsed {
  max-height: 0;
  opacity: 0;
  margin: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  pointer-events: none;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 1100px) {
  .app-container {
    grid-template-columns: 1fr;
    max-height: none;
    overflow-y: auto;
    gap: 1.2rem;
    padding: 1rem;
  }
  
  .panel-left, .panel-right {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }
  
  .panel-left h2, .panel-right h2 {
    grid-column: span 2;
  }
  
  .card-system-ops {
    grid-column: span 2;
    flex-direction: row;
  }
}

@media (max-width: 650px) {
  .panel-left, .panel-right {
    grid-template-columns: 1fr;
  }
  
  .panel-left h2, .panel-right h2, .card-system-ops {
    grid-column: span 1;
  }
  
  .card-system-ops {
    flex-direction: column;
  }
  
  .app-header {
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
  }
  
  .logo-wrapper h1 {
    font-size: 1.3rem;
  }
}
