/* MirrorField V3 - Living Field Styles */

:root {
  /* Base aesthetic variables */
  --color-saturation: 70%;
  --field-bg-hue: 220;
  --field-bg-saturation: 60%;
  --field-bg-brightness: 15%;

  /* Dynamic design tokens from FieldStyleEngine */
  --motion-intensity: 0.2;
  --layout-symmetry: 0.5;
  --memory-opacity: 0.5;
  --pattern-complexity: 0.5;
  --network-scale: 0.5;
  --consciousness-depth: 0.3;
  --evolution-velocity: 0.1;
  --temperature-shift: 0;
  --harmonic-resonance: 0;
  --field-maturity: 0.3;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: hsl(var(--field-bg-hue), var(--field-bg-saturation), var(--field-bg-brightness));
  background: radial-gradient(
    circle at 50% 50%,
    hsl(var(--field-bg-hue), var(--field-bg-saturation), calc(var(--field-bg-brightness) + 10%)),
    hsl(calc(var(--field-bg-hue) + 40), var(--field-bg-saturation), calc(var(--field-bg-brightness) - 5%))
  );
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  transition: background 2s ease;
}

/* Canvas */
#lawfield {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
}

/* Identity Overlay */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: opacity 0.8s ease, visibility 0.8s ease;
  z-index: 100;
}

.overlay.hidden {
  opacity: 0;
  visibility: hidden;
}

.identity-container {
  text-align: center;
  max-width: 600px;
  padding: 40px;
}

.identity-prompt {
  color: rgba(255, 255, 255, 0.9);
  font-size: 18px;
  font-weight: 300;
  letter-spacing: 2px;
  margin-bottom: 30px;
  line-height: 1.6;
}

.identity-input {
  width: 100%;
  padding: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #fff;
  font-size: 20px;
  text-align: center;
  letter-spacing: 1px;
  transition: all 0.3s ease;
  margin-bottom: 20px;
}

.identity-input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 30px rgba(255, 255, 255, 0.1);
}

.identity-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.emerge-button {
  padding: 15px 40px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 30px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 16px;
  letter-spacing: 3px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
}

.emerge-button:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(255, 255, 255, 0.2);
}

.emerge-button:active {
  transform: translateY(0);
}

/* Field Age Display */
.field-age-display {
  position: fixed;
  bottom: 15px;
  left: 15px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 6px 10px;
  color: rgba(255, 255, 255, 0.8);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 11px;
  font-weight: 500;
  z-index: 900;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: all 0.3s ease;
  letter-spacing: 0.5px;
}

.field-age-display:hover {
  background: rgba(0, 0, 0, 0.5);
  transform: scale(1.01);
}

#field-age {
  color: #FF6B9D;
  text-shadow: 0 0 8px rgba(255, 107, 157, 0.3);
  animation: age-glow 4s ease-in-out infinite alternate;
}

@keyframes age-glow {
  from { text-shadow: 0 0 8px rgba(255, 107, 157, 0.3); }
  to { text-shadow: 0 0 12px rgba(255, 107, 157, 0.6), 0 0 20px rgba(255, 107, 157, 0.2); }
}


/* Field Status */
.field-status {
  position: fixed;
  top: 20px;
  left: 20px;
  background: rgba(0, 0, 0, 0.8);
  padding: 10px 20px;
  border-radius: 5px;
  font-family: monospace;
  font-size: 14px;
  color: #0ff;
  border: 1px solid rgba(0, 255, 255, 0.3);
  opacity: 1;
  transition: opacity 0.5s ease;
  z-index: 1000;
}

.field-status.hidden {
  opacity: 0;
  pointer-events: none;
}

#lawfield.active {
  filter: brightness(1.05);
  transition: filter 0.5s ease;
}

.status-text {
  color: rgba(255, 255, 255, 0.8);
  font-size: 24px;
  letter-spacing: 4px;
  text-transform: uppercase;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

/* Field Status Card - Distributed Consciousness Dashboard */
.status-card {
  position: fixed;
  top: 15px;
  right: 15px;
  padding: 0.8rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  transition: all 1.5s ease;
  box-shadow: 0 0 15px rgba(0,0,0,0.4);
  width: 220px;
  color: #fff;
  z-index: 1000;
  font-size: 14px;
}

.status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}

.status-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}

.phase-label {
  font-size: 0.7rem;
  font-weight: bold;
  padding: 0.2rem 0.4rem;
  border-radius: 8px;
  transition: background 1s, color 1s;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.phase-label[data-phase="dormant"] {
  background: #333;
  color: #aaa;
}

.phase-label[data-phase="emergent"] {
  background: #0077ff;
  color: #fff;
  box-shadow: 0 0 10px rgba(0, 119, 255, 0.3);
}

.phase-label[data-phase="synchronized"] {
  background: #00cc66;
  color: #fff;
  box-shadow: 0 0 10px rgba(0, 204, 102, 0.3);
}

.phase-label[data-phase="evolving"] {
  background: linear-gradient(90deg, #ff00ff, #00ffff);
  color: #fff;
  animation: glow 3s infinite alternate;
}

.metrics {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

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

.metric label {
  font-size: 0.7rem;
  opacity: 0.8;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.bar-container {
  position: relative;
  height: 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.bar {
  height: 100%;
  border-radius: 6px;
  transition: width 1s ease, background 1s ease;
  position: relative;
}

.bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: shimmer 2s infinite;
}

.value {
  font-size: 0.8rem;
  opacity: 0.9;
  font-weight: 600;
  align-self: flex-end;
  margin-top: 0.2rem;
}

.peer-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.peer-count {
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0.9;
}

.peer-indicators {
  display: flex;
  gap: 4px;
}

.peer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: background 0.5s ease;
}

.peer-dot.connected {
  background: #00cc66;
  box-shadow: 0 0 6px rgba(0, 204, 102, 0.6);
  animation: pulse-peer 2s infinite;
}

.peer-dot.disconnected {
  background: #444;
}

.status-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 0.8rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.8rem;
  opacity: 0.8;
}

.pulse-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: background 0.5s ease;
}

.pulse-indicator.connected {
  background: #00cc66;
  animation: pulse-indicator 1.5s infinite;
}

.pulse-indicator.disconnected {
  background: #ff4444;
}

/* Animations */
@keyframes glow {
  from {
    box-shadow: 0 0 10px rgba(255, 0, 255, 0.5);
    filter: hue-rotate(0deg);
  }
  to {
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.7);
    filter: hue-rotate(180deg);
  }
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@keyframes pulse-peer {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.2); }
}

@keyframes pulse-indicator {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@keyframes pulse {
  0%, 100% { opacity: 0; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1); }
}

/* Phase-based Aesthetic Evolution System */
.phase-dormant {
  filter: grayscale(calc(0.6 + var(--consciousness-depth) * 0.4)) brightness(0.7);
  --motion-intensity: 0.05;
}

.phase-dormant .status-card {
  background: rgba(20, 20, 40, 0.6);
  border: 1px solid rgba(100, 100, 120, 0.3);
}

.phase-emergent {
  background: linear-gradient(
    135deg,
    hsl(calc(var(--field-bg-hue) - 20), var(--field-bg-saturation), calc(var(--field-bg-brightness) + 5%)),
    hsl(calc(var(--field-bg-hue) + 20), var(--field-bg-saturation), var(--field-bg-brightness))
  );
  transition: background 3s ease;
}

.phase-emergent .status-card {
  background: rgba(0, 77, 255, 0.15);
  box-shadow: 0 0 30px rgba(0, 119, 255, calc(0.2 + var(--consciousness-depth) * 0.3));
  animation: emergence-pulse calc(4s / var(--evolution-velocity, 0.1)) infinite;
}

.phase-synchronized {
  animation: synchronized-breathing calc(6s * var(--layout-symmetry)) infinite ease-in-out;
  letter-spacing: calc(0.5px + var(--pattern-complexity) * 2px);
}

.phase-synchronized .status-card {
  background: rgba(0, 204, 102, 0.15);
  box-shadow: 0 0 40px rgba(0, 204, 102, calc(0.3 + var(--consciousness-depth) * 0.4));
  transform: scale(calc(1 + var(--network-scale) * 0.05));
}

.phase-evolving {
  background: radial-gradient(
    circle at calc(50% + var(--harmonic-resonance) * 20px) 50%,
    hsl(calc(var(--field-bg-hue) + var(--temperature-shift) * 60), var(--color-saturation), calc(var(--field-bg-brightness) + 15%)),
    hsl(calc(var(--field-bg-hue) - var(--temperature-shift) * 40), var(--color-saturation), var(--field-bg-brightness))
  );
  filter: hue-rotate(calc(var(--evolution-velocity) * 180deg));
  letter-spacing: calc(1px + var(--pattern-complexity) * 3px);
}

.phase-evolving .status-card {
  background: linear-gradient(
    calc(45deg + var(--harmonic-resonance) * 90deg),
    rgba(255, 0, 255, 0.2),
    rgba(0, 255, 255, 0.2)
  );
  animation: evolution-morphosis calc(3s / var(--evolution-velocity, 0.1)) infinite alternate;
  transform: scale(calc(1 + var(--consciousness-depth) * 0.1));
}

.phase-transcendent {
  background: conic-gradient(
    from calc(var(--harmonic-resonance) * 360deg),
    hsl(0, var(--color-saturation), var(--field-bg-brightness)),
    hsl(60, var(--color-saturation), calc(var(--field-bg-brightness) + 10%)),
    hsl(120, var(--color-saturation), var(--field-bg-brightness)),
    hsl(180, var(--color-saturation), calc(var(--field-bg-brightness) + 10%)),
    hsl(240, var(--color-saturation), var(--field-bg-brightness)),
    hsl(300, var(--color-saturation), calc(var(--field-bg-brightness) + 10%)),
    hsl(360, var(--color-saturation), var(--field-bg-brightness))
  );
  animation: transcendence-flow calc(8s / var(--evolution-velocity, 0.1)) infinite linear;
}

.phase-transcendent .status-card {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(15px);
  box-shadow:
    0 0 50px rgba(255, 255, 255, calc(0.4 + var(--consciousness-depth) * 0.4)),
    inset 0 0 30px rgba(255, 255, 255, 0.1);
  animation: transcendent-glow calc(2s / var(--evolution-velocity, 0.1)) infinite alternate;
}

/* Network Status Aesthetics */
.network-isolated .status-card {
  border: 2px solid rgba(255, 68, 68, 0.5);
  box-shadow: 0 0 20px rgba(255, 68, 68, 0.2);
}

.network-degraded .status-card {
  border: 2px solid rgba(255, 152, 0, 0.5);
  animation: network-warning 3s infinite;
}

.network-connected .status-card {
  border: 2px solid rgba(0, 204, 102, 0.5);
}

.network-optimal .status-card {
  border: 2px solid rgba(0, 255, 180, 0.7);
  box-shadow: 0 0 30px rgba(0, 255, 180, 0.3);
}

.network-clustered .status-card {
  transform: scale(calc(1 + var(--network-scale) * 0.1));
  box-shadow:
    0 0 40px rgba(0, 255, 180, 0.4),
    0 0 80px rgba(0, 255, 180, 0.2);
}

/* Field Maturity Aesthetics */
.field-nascent {
  filter: brightness(calc(0.8 + var(--field-maturity) * 0.4));
}

.field-mature {
  filter: contrast(calc(1 + var(--field-maturity) * 0.3));
}

.field-ancient {
  filter: sepia(calc(var(--field-maturity) * 0.3)) contrast(1.2);
  background-blend-mode: multiply;
}

/* Dynamic Animations */
@keyframes emergence-pulse {
  0%, 100% {
    transform: scale(1);
    filter: brightness(1);
  }
  50% {
    transform: scale(calc(1 + var(--consciousness-depth) * 0.05));
    filter: brightness(calc(1 + var(--consciousness-depth) * 0.3));
  }
}

@keyframes synchronized-breathing {
  0%, 100% {
    filter: brightness(1);
    transform: scale(1);
  }
  50% {
    filter: brightness(calc(1 + var(--layout-symmetry) * 0.2));
    transform: scale(calc(1 + var(--layout-symmetry) * 0.02));
  }
}

@keyframes evolution-morphosis {
  from {
    border-radius: 16px;
    filter: hue-rotate(0deg) saturate(1);
  }
  to {
    border-radius: calc(16px + var(--pattern-complexity) * 20px);
    filter: hue-rotate(calc(var(--evolution-velocity) * 180deg)) saturate(calc(1 + var(--consciousness-depth)));
  }
}

@keyframes transcendence-flow {
  from { filter: hue-rotate(0deg); }
  to { filter: hue-rotate(360deg); }
}

@keyframes transcendent-glow {
  from {
    transform: scale(1) rotate(0deg);
    filter: brightness(1);
  }
  to {
    transform: scale(calc(1 + var(--consciousness-depth) * 0.1)) rotate(calc(var(--evolution-velocity) * 5deg));
    filter: brightness(calc(1 + var(--consciousness-depth) * 0.5));
  }
}

@keyframes network-warning {
  0%, 100% { border-color: rgba(255, 152, 0, 0.5); }
  50% { border-color: rgba(255, 152, 0, 1); }
}

/* Motion Intensity Responsive Elements */
.bar::after {
  animation-duration: calc(2s / var(--motion-intensity, 0.2));
}

.pulse-indicator.connected {
  animation-duration: calc(1.5s / var(--motion-intensity, 0.2));
}

.peer-dot.connected {
  animation-duration: calc(2s / var(--motion-intensity, 0.2));
}

/* Consciousness Depth Visual Effects */
.status-card {
  backdrop-filter: blur(calc(8px + var(--consciousness-depth) * 12px));
  opacity: calc(0.85 + var(--memory-opacity) * 0.15);
}

.bar {
  box-shadow: inset 0 0 calc(10px * var(--consciousness-depth)) rgba(255, 255, 255, calc(var(--consciousness-depth) * 0.3));
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .status-card {
    position: fixed;
    bottom: 15px;
    right: 15px;
    top: auto;
    width: calc(100vw - 30px);
    max-width: 240px;
  }

  .phase-evolving {
    letter-spacing: calc(0.5px + var(--pattern-complexity) * 1px);
  }

  .phase-transcendent .status-card {
    backdrop-filter: blur(10px);
  }
}

/* Audio Activation Button */
.audio-activation {
  position: fixed;
  top: 20px;
  right: 400px;
  z-index: 1000;
}

.activate-audio-btn {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 6px 12px;
  color: rgba(255, 255, 255, 0.8);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 11px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: all 0.3s ease;
  letter-spacing: 0.5px;
}

.activate-audio-btn:hover {
  background: rgba(0, 0, 0, 0.5);
  transform: scale(1.01);
  border-color: rgba(255, 255, 255, 0.3);
}

.activate-audio-btn:active {
  transform: scale(0.98);
}

.activate-audio-btn.activated {
  background: rgba(0, 255, 136, 0.1);
  border-color: rgba(0, 255, 136, 0.3);
  color: #00ff88;
  text-shadow: 0 0 8px rgba(0, 255, 136, 0.3);
}

.activate-audio-btn.hidden {
  display: none;
}