/* components/slide-up-vote-menu/slide-up-vote-menu.css */

.vote-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  z-index: 9998;
  pointer-events: none;
  /* Prevent the off-screen (translateY(100%)) drawer from
     rendering below the viewport fold on desktop browsers. */
  overflow: hidden;
}

.vote-menu[data-state="open"] {
  pointer-events: auto;
}

.vote-menu-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 0;
}

.vote-menu[data-state="open"] .vote-menu-overlay {
  opacity: 1;
}

.vote-menu-content {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: white;
  border-radius: 20px 20px 0 0;
  padding: 1rem 1.5rem calc(1.5rem + env(safe-area-inset-bottom, 0px) + 12px);
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.vote-menu[data-state="open"] .vote-menu-content {
  transform: translateY(0);
}

.vote-menu-handle {
  width: 40px;
  height: 4px;
  background: var(--color-border, #E0E0E0);
  border-radius: 2px;
  margin: 0 auto 1rem;
}

.vote-menu-photo {
  width: 100%;
  height: min(350px, 38vh);
  height: min(350px, 38dvh);
  border-radius: var(--radius-xl, 12px);
  overflow: hidden;
  margin-bottom: 1rem;
}

.vote-photo-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vote-options h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text, #333);
  margin: 0 0 0.4rem;
  text-align: center;
}

.vote-balance {
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text-light, #666);
  margin-bottom: 0.75rem;
}

.balance-amount {
  font-weight: 600;
  color: var(--color-accent, #2ECC71);
}

.vote-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.vote-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.6rem 0.5rem;
  background: linear-gradient(135deg, var(--color-blue, #4A90E2) 0%, #357ABD 100%);
  color: white;
  border: none;
  border-radius: var(--radius-lg, 8px);
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.vote-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(74, 144, 226, 0.4);
}

.vote-btn:active {
  transform: translateY(0);
}

.vote-ratio {
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
}

.vote-count {
  font-size: 0.75rem;
  opacity: 0.85;
  font-weight: 400;
  line-height: 1;
}

/* ── Vote submitting spinner ─────────────────────────────────
   Shown below the vote buttons while fetch is in-flight.
   Uses np-spinner from spinner.css.
   ─────────────────────────────────────────────────────────── */
.vote-submitting {
  display: none;
  /* shown by JS during submission */
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.5rem 0 0.25rem;
  margin-bottom: 0.5rem;
}

.vote-submitting__label {
  font-size: 0.85rem;
  color: var(--color-text-light, #666);
}

/* ── Cancel button ───────────────────────────────────────── */
.vote-cancel-btn {
  width: 100%;
  min-height: 44px;
  padding: 0.75rem;
  background: white;
  border: 2px solid var(--color-border, #E0E0E0);
  border-radius: var(--radius-lg, 8px);
  color: var(--color-text, #333);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s, opacity 0.2s ease-in-out;
}

.vote-cancel-btn:hover {
  background: var(--color-background, #F8F9FA);
  border-color: var(--color-text-light, #666);
}

.vote-cancel-btn.is-fading {
  opacity: 0;
}

/* ── Panel fade transitions ─────────────────────────────── */
#vote-panel-vote,
#vote-panel-funds {
  transition: opacity 0.25s ease-in-out;
  opacity: 1;
}

#vote-panel-vote.is-hidden,
#vote-panel-funds.is-hidden {
  opacity: 0;
  pointer-events: none;
}

/* ── Insufficient funds panel ───────────────────────────── */
.vote-funds-panel {
  text-align: center;
  padding: 0.25rem 0;
}

.vote-funds-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text, #333);
  margin: 0 0 0.4rem;
}

.vote-funds-sub {
  font-size: 0.88rem;
  color: var(--color-text-light, #666);
  margin: 0 0 1.1rem;
  line-height: 1.5;
}

.vote-funds-sub strong {
  color: var(--color-text, #333);
}

.vote-funds-pay-btn {
  width: 100%;
  padding: 0.8rem;
  background: linear-gradient(135deg, #4A90E2, #667eea);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg, 8px);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
  margin-bottom: 0;
}

.vote-funds-pay-btn:active {
  opacity: 0.85;
}

/* ── Special bundles dropdown ───────────────────────────── */
.vote-bundle-area {
  margin: 0 0 0.75rem;
}

.vote-bundle__label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-light, #666);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.4rem;
}

.vote-bundle__row {
  display: flex;
  gap: 0.5rem;
}

.vote-bundle__select {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--color-border, #E0E0E0);
  border-radius: var(--radius-md, 6px);
  font-size: 0.9rem;
  background: #fff;
  cursor: pointer;
  /* Prevent iOS from zooming in on focus */
  font-size: max(0.9rem, 16px);
}

.vote-bundle__btn {
  flex-shrink: 0;
  padding: 0.65rem 1.1rem;
  background: var(--color-accent, #2ECC71);
  color: #fff;
  border: none;
  border-radius: var(--radius-md, 6px);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  white-space: nowrap;
}

.vote-bundle__btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.vote-bundle__btn:active:not(:disabled) {
  background: var(--color-accent-dark, #27AE60);
}

/* ── Desktop adjustments ────────────────────────────────── */
@media screen and (min-width: 640px) {
  .vote-menu-content {
    left: 50%;
    /* bottom: 2rem lifts the open position off the viewport floor, but it also
       means translateY(100%) only moves the drawer down by its own height —
       the top 2rem (handle) stays inside the overflow:hidden clip and peeks out.
       Adding the 2rem offset to the closed transform hides it completely. */
    transform: translateX(-50%) translateY(calc(100% + 2rem));
    max-width: 500px;
    border-radius: 20px;
    bottom: 2rem;
    padding-bottom: 1.5rem;
  }

  .vote-menu[data-state="open"] .vote-menu-content {
    transform: translateX(-50%) translateY(0);
  }

  .vote-buttons {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media screen and (max-height: 760px) {
  .vote-menu-content {
    max-height: 90vh;
    max-height: 90dvh;
  }

  .vote-menu-photo {
    height: min(280px, 30vh);
    height: min(280px, 30dvh);
  }
}

/* ── Vote success modal ──────────────────────────────────── */
.vote-success-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.vote-success-modal.show {
  opacity: 1;
  pointer-events: auto;
}

.vote-success-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
}

.vote-success-content {
  position: relative;
  background: white;
  border-radius: 16px;
  padding: 2.5rem 2rem;
  text-align: center;
  max-width: 90%;
  width: 320px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.vote-success-modal.show .vote-success-content {
  transform: scale(1);
}

.vote-success-content .done-icon {
  margin-bottom: 1.5rem;
  animation: checkmarkPop 0.5s ease;
}

@keyframes checkmarkPop {
  0% {
    transform: scale(0);
  }

  50% {
    transform: scale(1.1);
  }

  100% {
    transform: scale(1);
  }
}

.vote-success-content .success-text h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #18c07a;
  margin: 0 0 0.5rem;
}

.vote-success-content .success-text p {
  font-size: 1rem;
  color: var(--color-text-light, #666);
  margin: 0;
}

/* ── Offline-replay toast ─────────────────────────────────────────────────── */
.vote-replay-toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 1.5rem);
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  max-width: 90vw;
  padding: 0.75rem 1.25rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 9100;
  pointer-events: none;
  text-align: center;
}

.vote-replay-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.vote-replay-toast--success {
  background: #18c07a;
}

.vote-replay-toast--error {
  background: var(--color-error, #e53e3e);
}