:root {
  --split: 50%;
  --bg: #0b0f14;
  --accent: #29f1c3;
  --muted: rgba(255, 255, 255, 0.6);
}

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

html,
body {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
  /* Prevent horizontal scrolling */
  position: fixed;
  top: 0;
  left: 0;
  touch-action: manipulation;
  /* Optimize drag handling */
}

body {
  font-family: "Space Grotesk", system-ui, sans-serif;
  background: var(--bg);
  color: white;
  overflow: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* Prevent overscroll effects */
}

.split {
  position: relative;
  width: 100%;
  height: 100%;
  touch-action: none;
  /* Prevent drag issues */
  overscroll-behavior: contain;
  /* Prevent layout shifts */
}

.layer {
  position: absolute;
  inset: 0;
}

.layer iframe {
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: auto;
}

.layer.top {
  clip-path: inset(0 calc(100% - var(--split)) 0 0);
  transition: clip-path 0.35s ease;
}

.handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--split);
  transform: translateX(-50%);
  width: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 20px;
  pointer-events: auto;
  /* Ensure handle works during drag */
  transition: left 0.35s ease, transform 0.35s ease;
  /* Smooth transition */
  cursor: ew-resize;
  max-width: 100%;
  /* Prevent handle overflow on mobile */
  z-index: 50;
  /* Ensure handle is always visible */
}

.line {
  width: 2px;
  background: linear-gradient(180deg, transparent, var(--accent), transparent);
  flex: 1;
  margin: 0 auto;
}

.grip {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.2rem;
  text-transform: uppercase;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(41, 241, 195, 0.6);
  background: rgba(10, 16, 24, 0.8);
  color: var(--accent);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.2rem;
  color: #0b0f14;
  background: rgba(41, 241, 195, 0.9);
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(41, 241, 195, 0.6);
  box-shadow: 0 8px 20px rgba(5, 10, 18, 0.35);
  white-space: nowrap;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.label.top {
  top: 0.4rem;
}

.label.bottom {
  bottom: 0.4rem;
}

/* Drag state transitions */
.dragging .layer.top,
.dragging .handle {
  transition: none;
}

.dragging .layer iframe {
  pointer-events: none;
}

body.dragging,
body.dragging * {
  user-select: none;
}

/* Visual effects during drag */
.dragging .layer.base iframe,
.dragging .layer.top iframe {
  filter: brightness(0.88) blur(0.5px);
  transition: filter 0.2s ease;
}

.layer iframe {
  transition: filter 0.3s ease;
}

/* Handle micro-interactions */
.grip {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(41, 241, 195, 0.3);
}

.grip:hover {
  transform: translate(-50%, -50%) scale(1.08);
  box-shadow: 0 6px 20px rgba(41, 241, 195, 0.5);
  border-color: var(--accent);
  background: rgba(10, 16, 24, 0.95);
}

.grip:active,
.dragging .grip {
  transform: translate(-50%, -50%) scale(0.96);
  box-shadow: 0 2px 8px rgba(41, 241, 195, 0.4);
}

.handle:hover .line {
  background: linear-gradient(180deg, transparent, var(--accent) 30%, var(--accent) 70%, transparent);
  box-shadow: 0 0 12px rgba(41, 241, 195, 0.4);
}

/* Percentage indicator */
.percentage-indicator {
  position: absolute;
  top: 50%;
  left: var(--split);
  transform: translate(-50%, calc(-50% - 60px));
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(10, 16, 24, 0.92);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(41, 241, 195, 0.4);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(5, 10, 18, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, left 0.35s ease, transform 0.35s ease;
  z-index: 100;
}

.dragging .percentage-indicator {
  opacity: 1;
}

.percentage-indicator::before {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid rgba(41, 241, 195, 0.4);
}

/* Label animations */
.label {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.handle:hover .label {
  transform: translateX(-50%) scale(1.05);
  box-shadow: 0 10px 28px rgba(5, 10, 18, 0.45);
}

.dragging .label {
  transform: translateX(-50%) scale(0.95);
  opacity: 0.8;
}

.dragging .handle {
  transition: none;
  /* No transition during drag */
  transform: translateX(-50%);
}

@media (max-width: 768px) {
  .line {
    max-width: 24%;
  }

  .label {
    font-size: 0.6rem;
    letter-spacing: 0.08rem;
  }

  .grip {
    padding: 0.8rem 1.2rem;
    font-size: 0.75rem;
    cursor: grab;
  }

  body.dragging .grip {
    cursor: grabbing;
  }

  .handle {
    width: 60px;
    margin-left: -30px;
    padding: 1.2rem 30px;
    max-width: 80%;
    /* Mobilde handle genişliğini sınırla */
    cursor: grab;
    /* Mobilde sürükleme işaretçisi */
  }

  .split {
    touch-action: pan-y;
    /* Mobilde dikey kaydırmayı etkinleştir */
    overscroll-behavior: contain;
    /* Mobilde taşmayı engelle */
  }

  /* Mobile percentage indicator */
  .percentage-indicator {
    font-size: 0.75rem;
    padding: 0.4rem 0.8rem;
    transform: translate(-50%, calc(-50% - 70px));
  }

  .percentage-indicator::before {
    border-left-width: 5px;
    border-right-width: 5px;
    border-top-width: 5px;
  }
}

/* Mobile Toggle Styles */
.mobile-toggle {
  display: none;
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  gap: 1rem;
  z-index: 200;
  width: 90%;
  max-width: 320px;
}

.toggle-btn {
  flex: 1;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(41, 241, 195, 0.5);
  background: rgba(20, 30, 42, 0.95);
  color: rgba(255, 255, 255, 0.85);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  box-shadow: 0 0 10px rgba(41, 241, 195, 0.15);
}

.toggle-btn:hover {
  border-color: rgba(41, 241, 195, 0.7);
  background: rgba(25, 35, 50, 0.98);
  color: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 15px rgba(41, 241, 195, 0.25);
  transform: translateY(-1px);
}

.toggle-btn.active {
  background: rgba(41, 241, 195, 0.25);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 25px rgba(41, 241, 195, 0.5), 0 0 10px rgba(41, 241, 195, 0.3) inset;
  font-weight: 700;
}

.user-btn.active {
  background: rgba(14, 165, 233, 0.25);
  /* Fallback */
  background: #0ea5e9;
  /* Solid Sky Blue */
  border-color: #38bdf8;
  color: #ffffff;
  /* White text for better contrast on solid bg */
  box-shadow: 0 0 25px rgba(56, 189, 248, 0.4), 0 0 10px rgba(56, 189, 248, 0.2) inset;
}

@media (max-width: 768px) {
  .handle {
    display: none;
  }

  .mobile-toggle {
    display: flex;
  }

  .percentage-indicator {
    display: none;
  }

  /* Reset clip-path transition for instant toggle */
  .layer.top {
    transition: clip-path 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  }
}