/**
 * Overlay Editor Styles
 * Two-layer architecture: transparent input + syntax-highlighted background
 */

:root {
  --editor-padding-top: 8px;
  --editor-padding-left: 16px;
  --editor-padding-bottom: 8px;
  --editor-padding-right: 16px;
}

.overlay-editor-container {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

/* Background layer - syntax highlighted, read-only */
.highlight-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
  padding: var(--editor-padding-top) var(--editor-padding-right) var(--editor-padding-bottom)
    var(--editor-padding-left);
  white-space: pre;
  word-wrap: break-word;
  user-select: none;
  color: var(--color-text, var(--text, #d4d4d4));
}

/* Foreground layer - transparent text, visible caret */
.input-layer {
  position: absolute;
  inset: 0;
  overflow: auto;
  z-index: 2;
  padding: var(--editor-padding-top) var(--editor-padding-right) var(--editor-padding-bottom)
    var(--editor-padding-left);
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: transparent;
  caret-color: var(--text, #d4d4d4);
  white-space: pre;
  word-wrap: break-word;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  tab-size: inherit;

  scroll-behavior: auto;
  scrollbar-gutter: stable;
}

@supports not selector(::-webkit-scrollbar) {
  .input-layer {
    scrollbar-color: var(--app-scrollbar-thumb, rgba(128, 128, 128, 0.42)) transparent;
    scrollbar-width: thin;
  }
}

/* Keep passive layers visually clean */
.highlight-layer::-webkit-scrollbar {
  display: none;
}

.highlight-layer {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.input-layer::-webkit-scrollbar {
  -webkit-appearance: none !important;
  width: var(--app-scrollbar-size, 11px) !important;
  height: var(--app-scrollbar-size, 11px) !important;
  background-color: transparent !important;
}

.input-layer::-webkit-scrollbar-track {
  -webkit-appearance: none !important;
  background-color: transparent !important;
}

.input-layer::-webkit-scrollbar-thumb {
  -webkit-appearance: none !important;
  background-color: rgba(128, 128, 128, 0.42) !important;
  background-color: var(--app-scrollbar-thumb, rgba(128, 128, 128, 0.42)) !important;
  border: var(--app-scrollbar-thumb-border, 3px solid transparent) !important;
  border-radius: var(--app-scrollbar-radius, 999px) !important;
  background-clip: content-box !important;
  transition: background-color 0.18s ease;
}

.input-layer:hover::-webkit-scrollbar-thumb,
.input-layer:focus::-webkit-scrollbar-thumb,
.input-layer:focus-within::-webkit-scrollbar-thumb {
  background-color: rgba(128, 128, 128, 0.58) !important;
  background-color: var(--app-scrollbar-thumb-hover, rgba(128, 128, 128, 0.58)) !important;
  border: 2px solid transparent !important;
  background-clip: content-box !important;
}

.input-layer::-webkit-scrollbar-thumb:hover {
  background-color: rgba(160, 160, 160, 0.7) !important;
  background-color: var(--app-scrollbar-thumb-hover, rgba(160, 160, 160, 0.7)) !important;
  border: 2px solid transparent !important;
  background-clip: content-box !important;
}

.input-layer::-webkit-scrollbar-corner {
  background-color: transparent !important;
}

/* Native selection styling for wrapped mode */
.input-layer.native-selection::selection {
  background: rgba(106, 155, 204, 0.42);
  background: color-mix(in srgb, var(--accent, #6a9bcc) 44%, transparent);
  color: transparent;
}

.input-layer.native-selection::-moz-selection {
  background: rgba(106, 155, 204, 0.42);
  background: color-mix(in srgb, var(--accent, #6a9bcc) 44%, transparent);
  color: transparent;
}

.input-layer.selection-transparent::selection,
textarea.input-layer.selection-transparent::selection {
  background: transparent !important;
  color: transparent !important;
}

.input-layer.selection-transparent::-moz-selection,
textarea.input-layer.selection-transparent::-moz-selection {
  background: transparent !important;
  color: transparent !important;
}

/* Line structure in highlight layer */
.highlight-layer-line {
  display: block;
  min-height: 1em;
  line-height: inherit;
  box-sizing: border-box;
}

.inlay-hint {
  display: inline-flex;
  align-items: center;
  margin: 0 2px;
  padding: 0 3px;
  max-height: 1.45em;
  border: 1px solid color-mix(in srgb, var(--color-border, #8a8f98) 42%, transparent);
  border-radius: 4px;
  background: color-mix(in srgb, var(--color-primary-bg, #ffffff) 94%, transparent);
  color: var(--color-text-lighter, #8a8f98);
  font-size: 0.85em;
  line-height: 1.25;
  vertical-align: 0.08em;
  box-shadow: 0 1px 3px color-mix(in srgb, #000 12%, transparent);
}

.editor-selection-box {
  background-color: rgba(106, 155, 204, 0.42);
  background-color: color-mix(in srgb, var(--accent, #6a9bcc) 44%, transparent);
  border-radius: 4px;
}

@supports not (background-color: color-mix(in srgb, #6a9bcc 44%, transparent)) {
  .editor-selection-box {
    background-color: rgba(106, 155, 204, 0.42);
  }
}

/* Multi-cursor layer */
.multi-cursor-layer {
  padding: var(--editor-padding-top) var(--editor-padding-right) var(--editor-padding-bottom)
    var(--editor-padding-left);
}

/* Git blame layer */
.git-blame-layer {
  padding: var(--editor-padding-top) var(--editor-padding-right) var(--editor-padding-bottom)
    var(--editor-padding-left);
}

/* Cursor blink animation */
@keyframes blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

.animate-blink {
  animation: blink 1s step-end infinite;
}
