/* ============= Base ============= */
:root {
  --initial-loader-bg: #fff;
  /* พื้นหลังตอนโหลด */
  --initial-loader-color: #339933;
  /* สีวงแหวน/ไฮไลต์ */
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
}

/* ============= Loader BG ============= */
#loading-bg {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--initial-loader-bg, #fff);
  z-index: 9999;
}

/* ============= Logo box ============= */
.loading-logo {
  position: relative;
  width: 86px;
  /* = ความกว้างโลโก้ */
  height: 86px;
  /* ทำให้เป็นสี่เหลี่ยมจัตุรัส */
}

.loading-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  position: relative;
  z-index: 2;
}

/* ============= Ring around logo ============= */
.loading {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 120px;
  /* > 86px เพื่อโอบรอบโลโก้ */
  height: 120px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
}

.loading .effect-1,
.loading .effect-2,
.loading .effect-3 {
  position: absolute;
  inset: 0;
  border: 3px solid transparent;
  border-radius: 50%;
  /* ใช้เสี้ยววงกลมให้เห็นการหมุนชัด */
  border-left-color: var(--initial-loader-color, #339933);
}

.loading .effect-1 {
  animation: rotate 1s linear infinite;
}

.loading .effect-2 {
  animation: rotate-opacity 1s linear infinite .1s;
}

.loading .effect-3 {
  animation: rotate-opacity 1s linear infinite .2s;
}

/* Optional: จุดเล็ก ๆ โคจรรอบโลโก้ */
.loading-logo::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -18px;
  /* รัศมีโคจรเหนือโลโก้ */
  width: 8px;
  height: 8px;
  margin-left: -4px;
  background: var(--initial-loader-color, #339933);
  border-radius: 50%;
  transform-origin: 50% 62px;
  /* จุดหมุน (รัศมี) */
  animation: orbit 1.1s linear infinite;
  z-index: 1;
}

/* ============= Keyframes ============= */
@keyframes rotate {
  to {
    transform: rotate(360deg);
  }
}

@keyframes rotate-opacity {
  0% {
    opacity: .15;
    transform: rotate(0deg);
  }

  100% {
    opacity: 1;
    transform: rotate(360deg);
  }
}

@keyframes orbit {
  to {
    transform: rotate(360deg);
  }
}

/* ============= Responsive tuning (optional) ============= */
@media (max-width: 480px) {
  .loading-logo {
    width: 72px;
    height: 72px;
  }

  .loading {
    width: 104px;
    height: 104px;
  }
}
