/* --------------------------------------------------
   Vetra Bespoke Cursor System (Fine Pointers Only)
-------------------------------------------------- */
@media (hover: hover) and (pointer: fine) {
  html.custom-cursor-enabled,
  html.custom-cursor-enabled *,
  html.custom-cursor-enabled flutter-view,
  html.custom-cursor-enabled flt-glass-pane {
    cursor: none !important;
  }

  :root {
    --accent: #166044;
    --accent-hover: #104e37;
    --accent-soft: rgba(22, 96, 68, 0.08);
    --accent-border: rgba(22, 96, 68, 0.18);
    --glow: rgba(22, 96, 68, 0.12);

    /* Backwards compatibility aliases */
    --vetra-cursor-accent: var(--accent);
    --vetra-cursor-glow: var(--glow);
    --vetra-cursor-soft: var(--accent-soft);
    --vetra-cursor-border: var(--accent-border);
  }

  @media (prefers-color-scheme: dark) {
    :root {
      --accent: #6ee7ad;
      --accent-hover: #8cf0c0;
      --accent-soft: rgba(110, 231, 173, 0.12);
      --accent-border: rgba(110, 231, 173, 0.28);
      --glow: rgba(110, 231, 173, 0.14);
    }
  }

  :root[data-theme='dark'] {
    --accent: #6ee7ad;
    --accent-hover: #8cf0c0;
    --accent-soft: rgba(110, 231, 173, 0.12);
    --accent-border: rgba(110, 231, 173, 0.28);
    --glow: rgba(110, 231, 173, 0.14);
  }

  .custom-cursor-dot,
  .custom-cursor-ring,
  .custom-cursor-ring * {
    box-sizing: border-box !important;
  }

  .custom-cursor-dot,
  .custom-cursor-ring {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    z-index: 2147483647;
    border-radius: 50%;
    opacity: 0;
    visibility: hidden;
    transform: translate3d(-100px, -100px, 0);
    will-change: transform, opacity, width, height;
    transition: opacity 0.25s ease, visibility 0.25s ease;
  }

  .custom-cursor-dot.is-active,
  .custom-cursor-ring.is-active {
    opacity: 1;
    visibility: visible;
  }

  /* Precision Gem Core */
  .custom-cursor-dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border: 1.5px solid rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2), 0 0 10px var(--glow);
    transition: opacity 0.2s ease, width 0.2s ease, height 0.2s ease;
  }

  :root[data-theme='dark'] .custom-cursor-dot {
    border-color: rgba(255, 255, 255, 0.85);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45), 0 0 12px var(--glow);
  }

  /* Hovering Interactive Element (buttons, links, tabs) */
  .custom-cursor-dot.is-hovering {
    opacity: 0.5;
    width: 5px;
    height: 5px;
  }

  /* Precision I-Beam for Text Input Fields */
  .custom-cursor-dot.is-text {
    width: 2px;
    height: 18px;
    border-radius: 1px;
    border: none;
    background: var(--accent);
    box-shadow: 0 0 6px var(--glow);
  }

  /* Magnetic Luminous Lens */
  .custom-cursor-ring {
    width: 36px;
    height: 36px;
    border: 1.5px solid var(--accent);
    box-shadow: 0 0 14px -2px var(--glow), inset 0 0 8px -2px var(--glow);
    background: rgba(22, 96, 68, 0.03);
    transition:
      width 0.28s cubic-bezier(0.16, 1, 0.3, 1),
      height 0.28s cubic-bezier(0.16, 1, 0.3, 1),
      border-radius 0.28s cubic-bezier(0.16, 1, 0.3, 1),
      background-color 0.25s ease,
      border-color 0.25s ease,
      box-shadow 0.25s ease,
      opacity 0.25s ease;
  }

  .custom-cursor-ring.is-hovering {
    width: 54px;
    height: 54px;
    background: var(--accent-soft);
    border-color: var(--accent);
    border-width: 1px;
    box-shadow: 0 0 24px -2px var(--glow), 0 6px 20px -4px rgba(0, 0, 0, 0.08);
  }

  :root[data-theme='dark'] .custom-cursor-ring {
    background: rgba(110, 231, 173, 0.04);
  }

  :root[data-theme='dark'] .custom-cursor-ring.is-hovering {
    background: rgba(110, 231, 173, 0.14);
    box-shadow: 0 0 28px -2px var(--glow);
  }

  /* Text mode: hide outer ring for distraction-free typing */
  .custom-cursor-ring.is-text {
    opacity: 0 !important;
    width: 14px;
    height: 24px;
  }

  /* Tactile Click Compression */
  .custom-cursor-ring.is-pressed {
    width: 26px;
    height: 26px;
    border-width: 2px;
    background: var(--accent-border);
  }

  /* Grab & Drag State (Horizontal capsule with micro-chevrons) */
  .custom-cursor-ring.is-grab {
    width: 66px;
    height: 36px;
    border-radius: 999px;
    background: rgba(22, 96, 68, 0.06);
    border: 1.5px solid var(--accent);
    box-shadow: 0 0 18px -2px var(--glow), 0 4px 14px -2px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }

  :root[data-theme='dark'] .custom-cursor-ring.is-grab {
    background: rgba(110, 231, 173, 0.09);
    border-color: rgba(110, 231, 173, 0.85);
    box-shadow: 0 0 22px -2px var(--glow), 0 4px 18px -2px rgba(0, 0, 0, 0.5);
  }

  .custom-cursor-ring.is-grab::before,
  .custom-cursor-ring.is-grab::after {
    content: '';
    box-sizing: border-box !important;
    position: absolute;
    top: 50%;
    width: 6px;
    height: 6px;
    border-style: solid;
    border-color: var(--accent);
    opacity: 0.9;
    pointer-events: none;
    transition:
      transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
      opacity 0.2s ease,
      border-color 0.2s ease;
  }

  :root[data-theme='dark'] .custom-cursor-ring.is-grab::before,
  :root[data-theme='dark'] .custom-cursor-ring.is-grab::after {
    border-color: rgba(110, 231, 173, 0.95);
    filter: drop-shadow(0 0 4px var(--glow));
  }

  /* Left Micro-Chevron: ‹ */
  .custom-cursor-ring.is-grab::before {
    left: 11px;
    border-width: 1.5px 0 0 1.5px;
    transform: translateY(-50%) rotate(-45deg);
  }

  /* Right Micro-Chevron: › */
  .custom-cursor-ring.is-grab::after {
    right: 11px;
    border-width: 1.5px 1.5px 0 0;
    transform: translateY(-50%) rotate(45deg);
  }

  .custom-cursor-dot.is-grab {
    width: 5px;
    height: 5px;
    opacity: 0.95;
  }

  .custom-cursor-ring.is-hovering::before,
  .custom-cursor-ring.is-hovering::after {
    opacity: 0 !important;
    display: none !important;
  }

  /* Active Dragging */
  .custom-cursor-ring.is-dragging {
    width: 28px !important;
    height: 28px !important;
    border-radius: 50% !important;
    background: var(--accent) !important;
    border-color: rgba(255, 255, 255, 0.92) !important;
    border-width: 2px !important;
    box-shadow: 0 0 24px 2px var(--glow), 0 4px 16px rgba(0, 0, 0, 0.3) !important;
  }

  :root[data-theme='dark'] .custom-cursor-ring.is-dragging {
    border-color: #ffffff !important;
    box-shadow: 0 0 28px 2px var(--glow), 0 4px 18px rgba(0, 0, 0, 0.6) !important;
  }

  .custom-cursor-dot.is-dragging {
    width: 6px !important;
    height: 6px !important;
    background: #ffffff !important;
    border-color: var(--accent) !important;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.95) !important;
    opacity: 1 !important;
  }
}

@media (hover: none), (pointer: coarse), (prefers-reduced-motion: reduce) {
  .custom-cursor-dot,
  .custom-cursor-ring {
    display: none !important;
  }
}
