/* ============================================================
   깨알도구
   온라인 제비뽑기

   공통 페이지 / 패널 / 버튼 / 결과 / 가이드는
   tool-common.css 사용
   ============================================================ */

/* ============================================================
   PAGE
   ============================================================ */

.lot-page {
  --tool-page-max-width: 920px;
}

/* ============================================================
   TEXTAREA
   ============================================================ */

.lot-textarea {
  display: block;

  width: 100%;
  min-height: 152px;

  padding: 12px 13px;

  resize: vertical;

  border: 1px solid var(--line);
  border-radius: var(--tool-input-radius);

  background: #ffffff;

  color: var(--text);

  outline: none;

  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.65;

  box-sizing: border-box;

  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    opacity 0.15s ease;
}

.lot-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 164, 65, 0.1);
}

.lot-textarea:disabled {
  opacity: 0.58;
  background: var(--surface-soft);
  cursor: not-allowed;
}

/* ============================================================
   CHECK
   ============================================================ */

.lot-check {
  display: flex;
  align-items: center;
  gap: 10px;

  min-height: 62px;

  padding: 10px 11px;

  border: 1px solid var(--line);
  border-radius: 11px;

  background: var(--surface-soft);

  cursor: pointer;
}

.lot-check input {
  position: absolute;

  width: 1px;
  height: 1px;

  opacity: 0;
  pointer-events: none;
}

.lot-check-ui {
  position: relative;

  width: 38px;
  height: 21px;

  flex: 0 0 38px;

  border-radius: 999px;

  background: #d7d7d1;

  transition: background 0.18s ease;
}

.lot-check-ui::after {
  content: '';

  position: absolute;

  top: 3px;
  left: 3px;

  width: 15px;
  height: 15px;

  border-radius: 50%;

  background: #ffffff;

  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14);

  transition: left 0.18s ease;
}

.lot-check input:checked + .lot-check-ui {
  background: var(--brand);
}

.lot-check input:checked + .lot-check-ui::after {
  left: 20px;
}

.lot-check input:focus-visible + .lot-check-ui {
  box-shadow: 0 0 0 3px rgba(217, 164, 65, 0.14);
}

.lot-check-text {
  min-width: 0;
}

.lot-check-text strong {
  display: block;

  color: var(--text);

  font-size: 12px;
  font-weight: 800;
}

.lot-check-text small {
  display: block;

  margin-top: 2px;

  color: var(--text-soft);

  font-size: 12px;
  line-height: 1.45;
}

/* ============================================================
   COUNT SUMMARY
   ============================================================ */

.lot-count-summary {
  margin-top: 15px;

  padding: 10px 11px;

  border-radius: 9px;

  background: var(--surface-soft);

  color: var(--text-soft);

  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;

  text-align: center;
}

.lot-count-summary.is-ready {
  background: #f2f8ef;
  color: #4e7444;
}

.lot-count-summary.is-error {
  background: #fff3ef;
  color: #9e4d3d;
}

/* ============================================================
   RESULT PANEL
   ============================================================ */

.lot-result-panel {
  min-height: 0;
  justify-content: flex-start;
}

/* ============================================================
   STATUS
   ============================================================ */

.lot-status {
  width: 100%;
  min-height: 36px;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 8px 10px;

  border-radius: 9px;

  background: var(--surface-soft);

  color: var(--text-soft);

  font-size: 12px;
  font-weight: 750;
  line-height: 1.45;

  text-align: center;

  box-sizing: border-box;
}

.lot-status.is-error {
  background: #fff3ef;
  color: #9e4d3d;
}

.lot-status.is-success {
  background: #f2f8ef;
  color: #4f7546;
}

/* ============================================================
   PROGRESS
   ============================================================ */

.lot-progress-row {
  width: 100%;

  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 9px;

  margin-top: 10px;
}

.lot-progress-row > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 5px;

  white-space: nowrap;
}

.lot-progress-row span {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 800;
}

.lot-progress-row strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.lot-progress-track {
  height: 7px;

  overflow: hidden;

  border-radius: 999px;

  background: var(--surface-soft);
}

.lot-progress-track > span {
  display: block;

  width: 0%;
  height: 100%;

  border-radius: inherit;

  background: linear-gradient(90deg, #f0b85b, #df8a70);

  transition: width 0.3s ease;
}

/* ============================================================
   LOT STAGE
   ============================================================ */

.lot-stage {
  position: relative;

  width: min(100%, 390px);
  min-height: 330px;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  margin: 12px auto 0;
  padding: 18px 14px 14px;

  overflow: hidden;

  border: 1px solid var(--line);
  border-radius: 18px;

  background:
    radial-gradient(
      circle at 50% 32%,
      rgba(255, 245, 213, 0.9),
      rgba(255, 255, 255, 0) 44%
    ),
    linear-gradient(180deg, #fffdf8 0%, #f7f4ec 100%);

  box-sizing: border-box;
}

.lot-stage::before,
.lot-stage::after {
  content: '';

  position: absolute;

  width: 120px;
  height: 120px;

  border-radius: 50%;

  background: rgba(217, 164, 65, 0.055);

  pointer-events: none;
}

.lot-stage::before {
  top: -54px;
  left: -40px;
}

.lot-stage::after {
  right: -44px;
  bottom: -58px;
}

/* ============================================================
   PLAYER CARD
   ============================================================ */

.lot-player-card {
  position: relative;
  z-index: 2;

  min-width: 150px;
  max-width: 90%;

  padding: 7px 13px;

  border: 1px solid rgba(217, 164, 65, 0.22);
  border-radius: 999px;

  background: rgba(255, 255, 255, 0.78);

  text-align: center;

  backdrop-filter: blur(4px);
}

.lot-player-card span {
  display: block;

  color: var(--accent);

  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1px;
}

.lot-player-card strong {
  display: block;

  margin-top: 1px;

  color: var(--text);

  font-size: 13px;
  font-weight: 900;

  overflow-wrap: anywhere;
}

/* ============================================================
   ENVELOPE
   ============================================================ */

.lot-envelope {
  position: relative;
  z-index: 3;

  width: 208px;
  height: 142px;

  margin-top: 23px;

  border: 0;
  padding: 0;

  background: transparent;

  cursor: pointer;

  perspective: 800px;

  transition:
    transform 0.18s ease,
    opacity 0.18s ease;
}

.lot-envelope:hover:not(:disabled) {
  transform: translateY(-3px) rotate(-1deg);
}

.lot-envelope:disabled {
  cursor: default;
}

.lot-envelope-back {
  position: absolute;

  inset: 20px 0 0;

  border-radius: 11px;

  background: #e7b15c;

  box-shadow: 0 14px 24px rgba(115, 80, 29, 0.16);
}

.lot-envelope-paper {
  position: absolute;

  z-index: 2;

  left: 18px;
  right: 18px;
  bottom: 17px;

  height: 92px;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  padding: 8px 12px;

  border-radius: 8px;

  background: #ffffff;

  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.09);

  transform: translateY(20px);

  transition:
    transform 0.55s cubic-bezier(0.19, 1, 0.22, 1),
    box-shadow 0.4s ease;

  box-sizing: border-box;
}

.lot-envelope-paper small {
  display: block;

  color: var(--text-soft);

  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1px;
}

.lot-envelope-paper strong {
  display: block;

  max-width: 100%;

  margin-top: 5px;

  color: var(--brand);

  font-size: 19px;
  font-weight: 900;
  line-height: 1.15;

  text-align: center;
  overflow-wrap: anywhere;
}

.lot-envelope-front {
  position: absolute;

  z-index: 4;

  left: 0;
  right: 0;
  bottom: 0;

  height: 112px;

  overflow: hidden;

  border-radius: 0 0 11px 11px;

  background:
    linear-gradient(150deg, transparent 49.5%, #f0bf6e 50%) left bottom / 50%
      100% no-repeat,
    linear-gradient(210deg, transparent 49.5%, #f0bf6e 50%) right bottom / 50%
      100% no-repeat;
}

.lot-envelope-front::after {
  content: '';

  position: absolute;

  left: 0;
  right: 0;
  bottom: 0;

  height: 56%;

  background: #efbd69;

  clip-path: polygon(0 100%, 50% 0, 100% 100%);
}

.lot-envelope-flap {
  position: absolute;

  z-index: 5;

  top: 20px;
  left: 0;

  width: 100%;
  height: 92px;

  background: #f5ca80;

  clip-path: polygon(0 0, 100% 0, 50% 100%);

  transform-origin: top center;

  transition:
    transform 0.48s cubic-bezier(0.22, 0.61, 0.36, 1),
    z-index 0s linear 0.23s;
}

.lot-envelope-seal {
  position: absolute;

  z-index: 7;

  top: 70px;
  left: 50%;

  width: 34px;
  height: 34px;

  display: flex;
  align-items: center;
  justify-content: center;

  transform: translateX(-50%);

  border: 3px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;

  background: #b85e4b;

  color: #ffffff;

  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.14);

  font-size: 12px;
  font-weight: 900;

  transition:
    opacity 0.18s ease,
    transform 0.22s ease;
}

/* ============================================================
   ENVELOPE STATES
   ============================================================ */

.lot-envelope.is-shuffling {
  animation: lot-envelope-shake 0.55s ease-in-out infinite;
}

.lot-envelope.is-revealed .lot-envelope-flap {
  z-index: 1;
  transform: rotateX(180deg);
}

.lot-envelope.is-revealed .lot-envelope-paper {
  transform: translateY(-43px);
  box-shadow: 0 9px 18px rgba(0, 0, 0, 0.13);
}

.lot-envelope.is-revealed .lot-envelope-seal {
  opacity: 0;
  transform: translateX(-50%) scale(0.4);
}

@keyframes lot-envelope-shake {
  0%,
  100% {
    transform: translateX(0) rotate(0deg);
  }

  25% {
    transform: translateX(-5px) rotate(-2deg);
  }

  50% {
    transform: translateX(4px) rotate(2deg);
  }

  75% {
    transform: translateX(-2px) rotate(-1deg);
  }
}

/* ============================================================
   DRAW HINT
   ============================================================ */

.lot-draw-hint {
  position: relative;
  z-index: 2;

  min-height: 17px;

  margin-top: 17px;

  color: var(--text-soft);

  font-size: 12px;
  font-weight: 650;

  text-align: center;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.lot-draw-button {
  margin-top: 13px;
}

.lot-draw-button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
}

.lot-secondary-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;

  width: 100%;

  margin-top: 8px;
}

.lot-secondary-actions .tool-result-action {
  width: 100%;
}

/* ============================================================
   HISTORY
   ============================================================ */

.lot-history {
  width: 100%;

  margin-top: 16px;
  padding-top: 15px;

  border-top: 1px solid var(--line);
}

.lot-history[hidden] {
  display: none;
}

.lot-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.lot-history-head > div span {
  display: block;

  color: var(--accent);

  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1px;
}

.lot-history-head > div strong {
  display: block;

  margin-top: 1px;

  color: var(--text);

  font-size: 12px;
  font-weight: 900;
}

.lot-history-head button {
  flex: 0 0 auto;

  min-height: 31px;

  padding: 0 9px;

  border: 1px solid var(--line);
  border-radius: 8px;

  background: var(--surface-soft);

  color: var(--text-soft);

  font-size: 12px;
  font-weight: 800;

  cursor: pointer;
}

.lot-history-head button:hover {
  color: var(--text);
}

.lot-history-list {
  display: grid;
  gap: 6px;

  margin-top: 10px;
}

.lot-history-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 20px minmax(0, 1fr);
  align-items: center;
  gap: 7px;

  min-width: 0;

  padding: 8px 9px;

  border-radius: 9px;

  background: var(--surface-soft);

  animation: lot-history-in 0.28s ease both;
}

.lot-history-number {
  width: 24px;
  height: 24px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;

  background: #ffffff;

  color: var(--text-soft);

  font-size: 12px;
  font-weight: 900;
}

.lot-history-person,
.lot-history-result {
  min-width: 0;

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lot-history-person {
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.lot-history-arrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.lot-history-result {
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
}

@keyframes lot-history-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   CONFETTI
   ============================================================ */

.lot-confetti {
  position: absolute;

  inset: 0;

  z-index: 8;

  overflow: hidden;

  pointer-events: none;
}

.lot-confetti i {
  position: absolute;

  top: -16px;

  width: 8px;
  height: 14px;

  border-radius: 2px;

  animation: lot-confetti-fall 1.25s ease-in forwards;
}

@keyframes lot-confetti-fall {
  0% {
    opacity: 1;
    transform: translateY(-10px) rotate(0deg);
  }

  100% {
    opacity: 0;
    transform: translateY(360px) rotate(540deg);
  }
}

/* ============================================================
   TABLET
   ============================================================ */

@media (max-width: 760px) {
  .lot-result-panel {
    order: -1;
  }

  .lot-stage {
    width: min(100%, 410px);
  }
}

/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 520px) {
  .lot-textarea {
    min-height: 135px;
    font-size: 12px;
  }

  .lot-stage {
    min-height: 305px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .lot-envelope {
    width: 184px;
    height: 129px;
  }

  .lot-envelope-paper {
    left: 15px;
    right: 15px;
    height: 83px;
  }

  .lot-envelope-paper strong {
    font-size: 17px;
  }

  .lot-envelope-front {
    height: 102px;
  }

  .lot-envelope-flap {
    height: 83px;
  }

  .lot-envelope-seal {
    top: 66px;
    width: 31px;
    height: 31px;
  }

  .lot-history-item {
    grid-template-columns: 24px minmax(0, 1fr) 14px minmax(0, 1fr);
    gap: 5px;
    padding: 7px;
  }

  .lot-secondary-actions {
    grid-template-columns: 1fr;
  }
}
