/*
 * Bubble level: a round vial when the phone lies flat, a straight one when it
 * stands on an edge (.is-edge). The bubble turns green when level (.is-aligned).
 * Shared controls are in /css/tool-ui.css.
 */

.level-vial {
  position: relative;
  width: min(280px, 78vw);
  height: min(280px, 78vw);
  margin: 0 auto 4px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #fefcf3 0%, #f3efd5 70%, #e7e1bd 100%);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12), inset 0 0 0 3px rgba(45, 55, 72, 0.25);
  overflow: hidden;
  transition: height 0.25s ease, border-radius 0.25s ease;
}

.level.is-edge .level-vial {
  height: 72px;
  border-radius: 36px;
}

.level-cross::before,
.level-cross::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: rgba(45, 55, 72, 0.18);
  transform: translate(-50%, -50%);
}

.level-cross::before {
  width: 100%;
  height: 1px;
}

.level-cross::after {
  width: 1px;
  height: 100%;
}

/* The ring the bubble has to sit in: about LEVEL (0.5°) of the 10° full scale, plus the bubble. */
.level-target {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  border: 2px solid rgba(45, 55, 72, 0.45);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.level.is-edge .level-target {
  width: 58px;
  height: 100%;
  border-radius: 0;
  border-top: 0;
  border-bottom: 0;
}

.level-bubble {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffffff 0%, #c6f6d5 35%, #9ae6b4 100%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  transform: translate(-50%, -50%);
  transition: transform 0.08s linear, background 0.2s ease;
}

.level.is-aligned .level-bubble {
  background: radial-gradient(circle at 35% 35%, #ffffff 0%, #68d391 40%, #2f855a 100%);
}

.level .level-readout {
  font-size: 22px;
}

@media (prefers-reduced-motion: reduce) {
  .level-vial,
  .level-bubble {
    transition: none;
  }
}
