/* ===== Packet — 실사 약봉지 스타일 ===== */

/* ── Packet card ── */
.packet {
  position: relative;
  width: 85%;
  margin: 0 auto;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.12));
}

.packet__body {
  position: relative;
  overflow: hidden;
  background-color: transparent;
  background-image: url('../paper.png');
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
  padding: 106px 13% 80px 21%;
  overflow: hidden;
  min-height: 442px;
}

.packet + .packet {
  margin-top: -125px;
}

.packet + .packet .packet__body {
  padding-top: 126px;
}


/* 첫 번째 약봉지: 아래쪽 지그재그만 */
.packet:first-child .packet__body {
  clip-path: polygon(
    0% 0%, 100% 0%,
    100% 97%,
    92.0% 97%,
    90.2% 99%, 88.5% 97%,
    86.8% 99%, 85.0% 97%,
    83.2% 99%, 81.5% 97%,
    79.8% 99%, 78.0% 97%,
    76.2% 99%, 74.5% 97%,
    72.8% 99%, 71.0% 97%,
    69.2% 99%, 67.5% 97%,
    65.8% 99%, 64.0% 97%,
    62.2% 99%, 60.5% 97%,
    58.8% 99%, 57.0% 97%,
    55.2% 99%, 53.5% 97%,
    51.8% 99%, 50.0% 97%,
    48.2% 99%, 46.5% 97%,
    44.8% 99%, 43.0% 97%,
    41.2% 99%, 39.5% 97%,
    37.8% 99%, 36.0% 97%,
    34.2% 99%, 32.5% 97%,
    30.8% 99%, 29.0% 97%,
    27.2% 99%, 25.5% 97%,
    23.8% 99%, 22.0% 97%,
    20.2% 99%, 18.5% 97%,
    16.8% 99%, 15.0% 97%,
    13.2% 99%, 11.5% 97%,
    9.8% 99%, 8% 97%,
    0% 97%
  );
}

/* 두 번째 이후 약봉지: 위+아래 지그재그 */
.packet + .packet .packet__body {
  clip-path: polygon(
    0% 19%,
    8% 19%,
    9.8% 17.5%, 11.5% 19%,
    13.2% 17.5%, 15.0% 19%,
    16.8% 17.5%, 18.5% 19%,
    20.2% 17.5%, 22.0% 19%,
    23.8% 17.5%, 25.5% 19%,
    27.2% 17.5%, 29.0% 19%,
    30.8% 17.5%, 32.5% 19%,
    34.2% 17.5%, 36.0% 19%,
    37.8% 17.5%, 39.5% 19%,
    41.2% 17.5%, 43.0% 19%,
    44.8% 17.5%, 46.5% 19%,
    48.2% 17.5%, 50.0% 19%,
    51.8% 17.5%, 53.5% 19%,
    55.2% 17.5%, 57.0% 19%,
    58.8% 17.5%, 60.5% 19%,
    62.2% 17.5%, 64.0% 19%,
    65.8% 17.5%, 67.5% 19%,
    69.2% 17.5%, 71.0% 19%,
    72.8% 17.5%, 74.5% 19%,
    76.2% 17.5%, 78.0% 19%,
    79.8% 17.5%, 81.5% 19%,
    83.2% 17.5%, 85.0% 19%,
    86.8% 17.5%, 88.5% 19%,
    90.2% 17.5%, 92.0% 19%,
    100% 19%,
    100% 97%,
    92.0% 97%,
    90.2% 99%, 88.5% 97%,
    86.8% 99%, 85.0% 97%,
    83.2% 99%, 81.5% 97%,
    79.8% 99%, 78.0% 97%,
    76.2% 99%, 74.5% 97%,
    72.8% 99%, 71.0% 97%,
    69.2% 99%, 67.5% 97%,
    65.8% 99%, 64.0% 97%,
    62.2% 99%, 60.5% 97%,
    58.8% 99%, 57.0% 97%,
    55.2% 99%, 53.5% 97%,
    51.8% 99%, 50.0% 97%,
    48.2% 99%, 46.5% 97%,
    44.8% 99%, 43.0% 97%,
    41.2% 99%, 39.5% 97%,
    37.8% 99%, 36.0% 97%,
    34.2% 99%, 32.5% 97%,
    30.8% 99%, 29.0% 97%,
    27.2% 99%, 25.5% 97%,
    23.8% 99%, 22.0% 97%,
    20.2% 99%, 18.5% 97%,
    16.8% 99%, 15.0% 97%,
    13.2% 99%, 11.5% 97%,
    9.8% 99%, 8% 97%,
    0% 97%
  );
}

.packet__body > * {
  position: relative;
  z-index: 1;
}

/* pointer-events: none이 .packet에서 상속되므로,
   클릭 가능한 요소들에 명시적으로 pointer-events: auto 부여 */
.packet__delete-btn,
.packet__add-task,
.packet__time-big,
.packet__day-label,
.task,
.task__name {
  pointer-events: auto;
}

/* ── Rx Label ── */
.packet__rx {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-xs);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: var(--fw-medium);
}

.packet__rx-label {
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

.packet .packet__body > .packet__delete-btn {
  position: absolute;
  top: 16px;
  right: 6px;
  z-index: 10;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  cursor: pointer;
  border-radius: 50%;
  transition: all var(--transition-fast);
  opacity: 0.7;
}

.packet + .packet .packet__body > .packet__delete-btn {
  top: calc(19% + 10px);
}

.packet__delete-btn:hover {
  opacity: 0.7;
  background: rgba(0, 0, 0, 0.06);
}

.packet__delete-btn svg path {
  stroke: #000;
  pointer-events: none;
}
.packet__delete-btn svg {
  pointer-events: none;
}

/* ── 큰 시간 타이포 ── */
.packet__time-row {
  display: flex;
  align-items: center;
}

.packet__time-display {
  margin-bottom: 2px;
}

/* ── 알림 토글 버튼 ── */
.packet__alarm-btn {
  pointer-events: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: #999;
  padding: 4px;
  transition: color 0.2s;
  flex-shrink: 0;
  margin-left: 8px;
}

.packet__alarm-btn--on {
  color: #1a1a1a;
}

.packet__alarm-btn .alarm-icon-on {
  display: none;
}
.packet__alarm-btn .alarm-icon-off {
  display: block;
}
.packet__alarm-btn--on .alarm-icon-on {
  display: block;
}
.packet__alarm-btn--on .alarm-icon-off {
  display: none;
}

.packet__time-big {
  font-size: 2.8rem;
  font-weight: var(--fw-black);
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1;
}

.packet__time-period {
  font-size: var(--fs-lg);
  font-weight: var(--fw-extrabold);
  color: var(--text-primary);
  margin-left: 4px;
  letter-spacing: -0.02em;
}

.packet__day-label {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-black);
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.1;
  cursor: text;
}

.packet__date-sub {
  font-size: var(--fs-sm);
  color: #000;
  font-weight: var(--fw-medium);
  margin-top: 2px;
  margin-bottom: 20px;
}

/* ── 할 일 리스트 ── */
.packet__tasks {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: -10px;
  margin-bottom: var(--space-sm);
}

.task {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 2px var(--space-xs);
  padding-right: 52px;
  border-radius: var(--radius-sm);
  position: relative;
}

.task:hover {
  background: rgba(0, 0, 0, 0.015);
}

/* 체크박스 토글 */
.task__toggle {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.task__check-on { display: none; }
.task__check-off { display: block; }
.task--completed .task__check-on { display: block; }
.task--completed .task__check-off { display: none; }

.task__quantity {
  display: none;
}

.task__info {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.task__name {
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
  cursor: text;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task__desc {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  line-height: 1.3;
  margin-top: 1px;
}

.task__name-input {
  width: 100%;
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
  background: transparent;
  border: none;
  border-bottom: 1px solid #000;
  outline: none;
  padding: 0;
  font-family: inherit;
}

.packet__day-label .task__name-input {
  width: 60%;
  font-size: var(--fs-2xl);
  font-weight: var(--fw-black);
}

.packet__time-big .task__name-input {
  width: 50%;
}

/* 시간 인라인 편집 */
.time-edit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.time-edit__ampm {
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  background: transparent;
  border: 1px solid #000;
  border-radius: 4px;
  padding: 2px 4px;
  font-family: inherit;
  cursor: pointer;
}

.time-edit__hour,
.time-edit__min {
  width: 2.2ch;
  font-size: 2rem;
  font-weight: var(--fw-black);
  background: transparent;
  border: none;
  border-bottom: 2px solid #000;
  text-align: center;
  font-family: inherit;
  padding: 0;
  -moz-appearance: textfield;
}

.time-edit__hour::-webkit-inner-spin-button,
.time-edit__min::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.time-edit__colon {
  font-size: 2rem;
  font-weight: var(--fw-black);
  line-height: 1;
}

.task__duration {
  display: none;
}

/* 완료 상태 */
.task--completed .task__name {
  text-decoration: line-through;
  text-decoration-color: #000;
}

.task--completed .task__desc {
  text-decoration: line-through;
  text-decoration-color: var(--text-muted);
}

/* 액션 버튼 */
.task__edit-btn,
.task__delete-btn {
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full);
  color: #000;
  opacity: 0;
  transition: all var(--transition-fast);
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.task__edit-btn {
  right: 26px;
}

.task__delete-btn {
  right: 2px;
}

.task:hover .task__edit-btn,
.task:hover .task__delete-btn { opacity: 1; }
.task__edit-btn:hover,
.task__delete-btn:hover { opacity: 1 !important; background: rgba(0,0,0,0.05); }
.task__delete-btn:hover { color: var(--pill-red); }

/* ── 할 일 추가 ── */
.packet__add-task {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 4px var(--space-xs);
  font-size: var(--fs-base);
  color: #000;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  width: 100%;
}

.packet__add-task:hover {
  color: var(--text-secondary);
  background: rgba(0,0,0,0.02);
}

.packet__add-task-icon {
  width: 18px; height: 18px;
  border-radius: var(--radius-full);
  border: 1.5px dashed currentColor;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
}

/* ── Footer ── */
.packet__footer {
  display: none;
}

/* ── Pills Row (할 일 개수만큼 알약) ── */
.packet__pills-row {
  position: absolute;
  bottom: 50px;
  right: 35px;
  width: 180px;
  height: 160px;
  pointer-events: none;
  z-index: 0;
}

.packet__pill-item {
  position: absolute;
  width: 85px;
  height: auto;
  opacity: 0.45;
  filter: blur(1.5px);
}

.packet__pill-item:nth-child(1) { bottom: 0;    left: 0;     transform: rotate(-8deg); }
.packet__pill-item:nth-child(2) { bottom: 3px;  left: 70px;  transform: rotate(12deg); }
.packet__pill-item:nth-child(3) { bottom: 34px; left: 78px;  transform: rotate(-3deg); }
.packet__pill-item:nth-child(4) { bottom: 3px;  left: -70px; transform: rotate(7deg); }
.packet__pill-item:nth-child(5) { bottom: 34px; left: 0;      transform: rotate(-10deg); }
.packet__pill-item:nth-child(6) { bottom: 5px;  left: -70px; transform: rotate(5deg); }
.packet__pill-item:nth-child(7) { bottom: 72px;  left: 78px;  transform: rotate(-12deg); }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-xl);
}

.empty-state__icon {
  font-size: 48px;
  margin-bottom: var(--space-base);
  opacity: 0.4;
}

.empty-state__title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.empty-state__subtitle {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}


/* ── Mobile touch ── */
@media (hover: none) and (pointer: coarse) {
  .packet__delete-btn, .packet__move-btn { opacity: 0.7; }
  .task__edit-btn, .task__delete-btn {
    opacity: 0;
    width: 28px;
    height: 28px;
  }
  .task--touched .task__edit-btn,
  .task--touched .task__delete-btn {
    opacity: 0.5;
  }
  .task__edit-btn svg,
  .task__delete-btn svg {
    width: 14px;
    height: 14px;
  }
}

/* ── 모바일 반응형 (480px 이하) ── */
@media (max-width: 480px) {
  .packet {
    width: 92%;
  }

  .packet__body {
    padding: 80px 10% 60px 21%;
    min-height: 380px;
  }

  .packet + .packet .packet__body {
    padding-top: 106px;
  }

  .packet__time-big {
    font-size: 2.4rem;
  }

  .packet__day-label {
    font-size: var(--fs-xl);
  }

  .packet__date-sub {
    margin-bottom: 16px;
  }

  .packet + .packet {
    margin-top: -105px;
  }
}

/* ── 아주 작은 모바일 (360px 이하) ── */
@media (max-width: 360px) {
  .packet {
    width: 96%;
  }

  .packet__body {
    padding: 70px 7% 50px 18%;
    min-height: 340px;
  }

  .packet + .packet .packet__body {
    padding-top: 96px;
  }

  .packet__time-big {
    font-size: 2rem;
  }

  .packet__time-period {
    font-size: var(--fs-md);
  }

  .packet__day-label {
    font-size: var(--fs-lg);
  }

  .packet + .packet {
    margin-top: -90px;
  }
}
