/* ----------------------------------------------------------------- hero */

.hero {
  position: relative;
  margin-bottom: var(--space-5);
  text-align: center;
}

.hero-theme {
  position: absolute;
  top: 0;
  right: 0;
}

.hero h1 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-2);
}

.hero-sub {
  max-width: 30rem;
  margin: 0 auto;
  font-size: var(--text-sm);
}

/* ---------------------------------------------------------- code input */

.redeem-panel {
  margin-bottom: var(--space-4);
}

.code-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

.code-label-row label {
  margin-bottom: var(--space-2);
}

.code-progress {
  color: var(--text-faint);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  transition: color var(--speed-fast) var(--ease);
}

.code-progress.complete {
  color: var(--ok-text);
}

.code-input {
  min-height: 52px;
  font-size: var(--text-md);
  letter-spacing: 0.14em;
  text-align: center;
  text-transform: uppercase;
}

.code-input::placeholder {
  font-size: var(--text-base);
  letter-spacing: 0.08em;
  text-transform: none;
}

/* Four pills mirroring how many groups are complete. */
.code-groups {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.group-pill {
  flex: 1;
  height: 3px;
  border-radius: var(--radius-pill);
  background: var(--line);
  transition: background var(--speed) var(--ease);
}

.group-pill.partial {
  background: var(--accent-ring);
}

.group-pill.filled {
  background: var(--accent);
}

/* ------------------------------------------------------------- actions */

.actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.submit-btn {
  flex: 1 1 auto;
  min-height: 44px;
  font-size: var(--text-base);
}

.actions .ghost {
  flex: 0 0 auto;
  min-height: 44px;
}

/* Spinner lives inside the submit button, swapped in while busy. */
.spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.submit-btn.busy .spinner {
  display: block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.message {
  margin-top: var(--space-4);
}

/* ------------------------------------------------------------ skeleton */

.skel-title {
  height: 20px;
  width: 36%;
  margin-bottom: var(--space-3);
}

.skel-meta {
  height: 13px;
  width: 62%;
  margin-bottom: var(--space-5);
}

.skel-card {
  height: 76px;
  margin-bottom: var(--space-3);
}

.skel-card:last-child {
  margin-bottom: 0;
}

/* -------------------------------------------------------------- result */

.result-panel {
  animation: rise var(--speed) var(--ease);
}

.result-panel:focus {
  outline: none;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.result-headline {
  min-width: 0;
}

.result-head h2 {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-md);
  margin-bottom: var(--space-1);
}

.result-meta {
  font-size: var(--text-xs);
}

.result-actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* ------------------------------------------------------------- receipt */

.receipt-note {
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-5);
  background: var(--accent-wash);
  border: 1px solid var(--accent-ring);
  border-radius: var(--radius);
}

.receipt-text {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
}

.receipt-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.receipt-link {
  flex: 1 1 auto;
  min-width: 0;
  padding: var(--space-2) var(--space-3);
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.receipt-link::-webkit-scrollbar {
  display: none;
}

.receipt-row button {
  flex-shrink: 0;
}

/* --------------------------------------------------------------- items */

.items-heading {
  margin-bottom: var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.items {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.item {
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.item-index {
  color: var(--text-faint);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
}

.item-actions {
  display: flex;
  gap: var(--space-2);
}

/* Key/value view for flat objects. */
.kv {
  display: grid;
  grid-template-columns: minmax(5.5rem, max-content) 1fr;
  font-size: var(--text-sm);
}

.kv > div {
  min-width: 0;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
}

.kv > div:nth-child(odd) {
  color: var(--text-dim);
  background: var(--overlay);
  font-size: var(--text-xs);
}

.kv > div:nth-child(even) {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  word-break: break-all;
}

.kv > div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.item pre {
  border: 0;
  border-radius: 0;
  background: transparent;
  max-height: 24rem;
  overflow: auto;
}

.foot {
  margin-top: var(--space-6);
  text-align: center;
  font-size: var(--text-xs);
}

/* -------------------------------------------------------------- mobile */

@media (max-width: 36rem) {
  .wrap {
    padding: var(--space-5) var(--space-3) var(--space-6);
  }

  .hero {
    text-align: left;
    padding-right: 44px;
  }

  .hero h1 {
    font-size: var(--text-lg);
  }

  .hero-sub {
    margin: 0;
  }

  .panel {
    padding: var(--space-4);
  }

  .code-input {
    font-size: var(--text-base);
    letter-spacing: 0.1em;
    text-align: left;
  }

  .code-input::placeholder {
    font-size: var(--text-sm);
  }

  /* Stack the buttons so both stay full-width and thumb-friendly. */
  .actions {
    flex-direction: column;
  }

  .result-head {
    flex-direction: column;
    gap: var(--space-3);
  }

  .result-actions {
    width: 100%;
  }

  .result-actions > * {
    flex: 1;
  }

  .receipt-row {
    flex-direction: column;
    align-items: stretch;
  }

  .receipt-row button {
    width: 100%;
  }

  /* Labels above values reads better than a cramped two-column grid. */
  .kv {
    grid-template-columns: 1fr;
  }

  .kv > div:nth-child(odd) {
    padding-bottom: 0;
    background: transparent;
    border-bottom: 0;
  }

  .kv > div:nth-child(even) {
    padding-top: var(--space-1);
  }

  .item-head {
    flex-wrap: wrap;
  }
}
