/*
  Chrome Glass — premium dark-tech panel with edge-lit chrome borders.
  All 4 borders shine when mouse approaches — tracks proximity + position.

  Usage:
    <div class="chrome-glass">           — default panel
    <div class="chrome-glass strong">    — denser / more opaque

  Markup — add 4 edge elements inside:
    <span class="cg-edge cg-top"></span>
    <span class="cg-edge cg-bottom"></span>
    <span class="cg-edge cg-left"></span>
    <span class="cg-edge cg-right"></span>

  Wrap inner content in .cg-content to keep it above effect layers.
*/

/* ── Base panel ── */
.chrome-glass {
  position: relative;
  isolation: isolate;
  border-radius: inherit;

  /* Dark translucent glass — local color bleed */
  background:
    linear-gradient(
      180deg,
      rgba(18, 20, 28, 0.74) 0%,
      rgba(10, 12, 18, 0.78) 100%
    );

  /* Faint border all around at rest — hints where chrome lives */
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 2px 8px rgba(0, 0, 0, 0.3),
    0 8px 32px rgba(0, 0, 0, 0.25);

  /* Low blur — keeps behind-colors localized */
  backdrop-filter: blur(10px) saturate(130%) brightness(92%);
  -webkit-backdrop-filter: blur(10px) saturate(130%) brightness(92%);

  /* Custom properties driven by JS */
  --cg-top-x: 50%;
  --cg-top-opacity: 0;
  --cg-bottom-x: 50%;
  --cg-bottom-opacity: 0;
  --cg-left-y: 50%;
  --cg-left-opacity: 0;
  --cg-right-y: 50%;
  --cg-right-opacity: 0;
}

/* ── Shared edge setup ── */
.chrome-glass .cg-edge {
  position: absolute;
  pointer-events: none;
  z-index: 10;
  overflow: visible;
}

/* ── HORIZONTAL edges (top + bottom) ── */
.chrome-glass .cg-top,
.chrome-glass .cg-bottom {
  left: 0;
  right: 0;
  height: 1px;
}

.chrome-glass .cg-top    { top: -1px; }
.chrome-glass .cg-bottom { bottom: -1px; }

/* Sharp chrome line — horizontal */
.chrome-glass .cg-top::before,
.chrome-glass .cg-bottom::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  filter: brightness(1.5);
  -webkit-filter: brightness(1.5);
  transition: opacity 0.12s ease;
}

.chrome-glass .cg-top::before {
  top: 0;
  background: radial-gradient(
    ellipse 350px 1px at var(--cg-top-x) 50%,
    #fff,
    rgba(255, 255, 255, 1) 12%,
    rgba(255, 255, 255, 0.75) 25%,
    rgba(255, 255, 255, 0.4) 42%,
    rgba(255, 255, 255, 0.12) 62%,
    transparent 100%
  );
  opacity: var(--cg-top-opacity);
}

.chrome-glass .cg-bottom::before {
  bottom: 0;
  background: radial-gradient(
    ellipse 350px 1px at var(--cg-bottom-x) 50%,
    #fff,
    rgba(255, 255, 255, 1) 12%,
    rgba(255, 255, 255, 0.75) 25%,
    rgba(255, 255, 255, 0.4) 42%,
    rgba(255, 255, 255, 0.12) 62%,
    transparent 100%
  );
  opacity: var(--cg-bottom-opacity);
}

/* Soft glow — horizontal */
.chrome-glass .cg-top::after,
.chrome-glass .cg-bottom::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  filter: blur(1px);
  -webkit-filter: blur(1px);
  transition: opacity 0.12s ease;
}

.chrome-glass .cg-top::after {
  top: -1px;
  background: radial-gradient(
    ellipse 300px 3px at var(--cg-top-x) 100%,
    rgba(255, 255, 255, 0.35),
    rgba(255, 255, 255, 0.12) 35%,
    transparent 80%
  );
  opacity: var(--cg-top-opacity);
}

.chrome-glass .cg-bottom::after {
  bottom: -1px;
  background: radial-gradient(
    ellipse 300px 3px at var(--cg-bottom-x) 0%,
    rgba(255, 255, 255, 0.35),
    rgba(255, 255, 255, 0.12) 35%,
    transparent 80%
  );
  opacity: var(--cg-bottom-opacity);
}


/* ── VERTICAL edges (left + right) ── */
.chrome-glass .cg-left,
.chrome-glass .cg-right {
  top: 0;
  bottom: 0;
  width: 1px;
}

.chrome-glass .cg-left  { left: -1px; }
.chrome-glass .cg-right { right: -1px; }

/* Sharp chrome line — vertical */
.chrome-glass .cg-left::before,
.chrome-glass .cg-right::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  filter: brightness(1.5);
  -webkit-filter: brightness(1.5);
  transition: opacity 0.12s ease;
}

.chrome-glass .cg-left::before {
  left: 0;
  background: radial-gradient(
    ellipse 1px 350px at 50% var(--cg-left-y),
    #fff,
    rgba(255, 255, 255, 1) 12%,
    rgba(255, 255, 255, 0.75) 25%,
    rgba(255, 255, 255, 0.4) 42%,
    rgba(255, 255, 255, 0.12) 62%,
    transparent 100%
  );
  opacity: var(--cg-left-opacity);
}

.chrome-glass .cg-right::before {
  right: 0;
  background: radial-gradient(
    ellipse 1px 350px at 50% var(--cg-right-y),
    #fff,
    rgba(255, 255, 255, 1) 12%,
    rgba(255, 255, 255, 0.75) 25%,
    rgba(255, 255, 255, 0.4) 42%,
    rgba(255, 255, 255, 0.12) 62%,
    transparent 100%
  );
  opacity: var(--cg-right-opacity);
}

/* Soft glow — vertical */
.chrome-glass .cg-left::after,
.chrome-glass .cg-right::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  filter: blur(1px);
  -webkit-filter: blur(1px);
  transition: opacity 0.12s ease;
}

.chrome-glass .cg-left::after {
  left: -1px;
  background: radial-gradient(
    ellipse 3px 300px at 100% var(--cg-left-y),
    rgba(255, 255, 255, 0.35),
    rgba(255, 255, 255, 0.12) 35%,
    transparent 80%
  );
  opacity: var(--cg-left-opacity);
}

.chrome-glass .cg-right::after {
  right: -1px;
  background: radial-gradient(
    ellipse 3px 300px at 0% var(--cg-right-y),
    rgba(255, 255, 255, 0.35),
    rgba(255, 255, 255, 0.12) 35%,
    transparent 80%
  );
  opacity: var(--cg-right-opacity);
}


/* ── Premium top sheen — subtle gloss catch ── */
.chrome-glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.055) 0%,
      rgba(255, 255, 255, 0.015) 20%,
      transparent 50%
    );
  pointer-events: none;
  z-index: 1;
}

/* ── Ambient depth layer ── */
.chrome-glass::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow:
    inset 0 -8px 20px rgba(0, 0, 0, 0.15),
    inset 0 4px 12px rgba(0, 0, 0, 0.08);
  pointer-events: none;
  z-index: 0;
}

/* Keep inner content above the layers */
.chrome-glass .cg-content {
  position: relative;
  z-index: 2;
}

/* ── Stronger variant ── */
.chrome-glass.strong {
  background:
    linear-gradient(
      180deg,
      rgba(14, 16, 24, 0.88) 0%,
      rgba(6, 8, 14, 0.92) 100%
    );
  backdrop-filter: blur(16px) saturate(130%) brightness(88%);
  -webkit-backdrop-filter: blur(16px) saturate(130%) brightness(88%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 3px 12px rgba(0, 0, 0, 0.35),
    0 10px 40px rgba(0, 0, 0, 0.3);
}

/* Fallback */
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .chrome-glass {
    background: rgba(12, 14, 20, 0.95);
  }
}
