/* ============================================================
   1. CUSTOM PROPERTIES
   ============================================================ */

:root {
  --brand: rgb(63, 92, 56);
  --brand-hex: #3F5C38;
  --coral: #EA9580;
  --cream: #F4EBD2;
  --butter: #F2D258;
  --slot-empty: #B5C2A8;
  --error-red: #C0392B;
  --gray: #D0D0D0;
  --gray-dark: #999;
  --white: #FFFFFF;
  --bg: #F4EBD2;
  --card-shadow: none;
  --card-border: 2px solid var(--brand);
  --radius: 12px;
  --radius-sm: 8px;
  --font-stack: 'Alef', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ============================================================
   2. RESET / BASE
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-stack);
  font-size: 16px;
  font-weight: 700;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg);
  color: var(--brand);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ============================================================
   3. LAYOUT
   ============================================================ */

.app-container {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: var(--white);
}

/* ============================================================
   4. HEADER / LOGO
   ============================================================ */

.header {
  width: calc(100% + 40px);
  margin: 0 -20px;
  padding: 12px 20px;
  background-color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-logo {
  max-width: 80%;
  height: auto;
  max-height: 96px;
  display: block;
  object-fit: contain;
}

/* ============================================================
   4b. TABS
   ============================================================ */

.tabs {
  width: 100%;
  display: flex;
  border-bottom: 1px solid rgba(63, 92, 56, 0.18);
  margin-top: 14px;
  margin-bottom: 8px;
}

.tab {
  flex: 1;
  padding: 14px 8px;
  border: none;
  background: transparent;
  font-family: var(--font-stack);
  font-size: 1rem;
  font-weight: 700;
  color: rgba(63, 92, 56, 0.5);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.tab:hover { color: rgba(63, 92, 56, 0.8); }

.tab--active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.tab-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ============================================================
   5. PUNCH CARD
   ============================================================ */

.card {
  width: 100%;
  background: var(--white);
  border-radius: var(--radius);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  padding: 20px 12px 16px;
  margin-top: 20px;
  margin-bottom: 20px;
}

.card-grid {
  width: 100%;
  display: flex;
  justify-content: center;
}

.card-svg {
  width: 100%;
  max-width: 340px;
  height: auto;
}

.card-progress {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--brand);
  margin-top: 12px;
  letter-spacing: 0.05em;
}

/* ============================================================
   6. SHAPE STATES (filled / empty)
   ============================================================ */

.slot-fill {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(0);
}

/* Static punched state — used on page load for existing punches */
.slot.punched .slot-fill {
  opacity: 1;
  transform: scale(1);
}

/* Animated punch — used when adding new punches */
.slot.punched.animating .slot-fill {
  animation: punch-fill 0.4s ease-out forwards;
}

/* ============================================================
   7. QUANTITY STEPPER
   ============================================================ */

.quantity-section {
  width: 100%;
  text-align: center;
  margin-bottom: 20px;
}

.quantity-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 10px;
}

.stepper {
  display: inline-flex;
  align-items: center;
  border: 2px solid var(--brand);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.stepper-btn {
  width: 48px;
  height: 48px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: var(--white);
  color: var(--brand);
  font-size: 1.4rem;
  font-family: var(--font-stack);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
  -webkit-user-select: none;
  user-select: none;
}

.stepper-btn:active:not(:disabled) {
  background-color: rgba(63, 92, 56, 0.08);
}

.stepper-btn:disabled {
  color: var(--gray);
  cursor: default;
  opacity: 0.5;
}

.stepper-minus {
  border-right: 1px solid rgba(63, 92, 56, 0.2);
}

.stepper-plus {
  border-left: 1px solid rgba(63, 92, 56, 0.2);
}

.stepper-value {
  min-width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--brand);
  -webkit-user-select: none;
  user-select: none;
}

/* ============================================================
   8. CODE INPUT AREA
   ============================================================ */

.code-section {
  width: 100%;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.code-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 2px solid rgba(63, 92, 56, 0.3);
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-family: var(--font-stack);
  color: var(--brand);
  background: var(--white);
  outline: none;
  transition: border-color 0.15s ease;
  text-align: center;
}

.code-input::placeholder {
  color: var(--gray-dark);
  opacity: 0.7;
  text-align: center;
}

.code-input:focus {
  border-color: var(--brand);
}

.punch-btn {
  width: 100%;
  height: 52px;
  min-height: 44px;
  border: none;
  border-radius: var(--radius-sm);
  background-color: var(--brand);
  color: var(--white);
  font-size: 1.2rem;
  font-weight: 700;
  font-family: var(--font-stack);
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.punch-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.punch-btn:active:not(:disabled) {
  opacity: 0.85;
}

.status-message {
  margin-top: 0;
  font-size: 0.9rem;
  min-height: 1.4em;
  text-align: center;
}

.status-message.error {
  color: var(--error-red);
}

.status-message.success {
  color: var(--success-green);
}

/* ============================================================
   8a. GIFT CARD
   ============================================================ */

/* Unloaded — gift code prompt */
.gift-unloaded {
  width: 100%;
  margin-top: 20px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gift-prompt {
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand);
  text-align: center;
  margin-bottom: 6px;
}

.gift-code-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 2px solid rgba(63, 92, 56, 0.3);
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-family: var(--font-stack);
  color: var(--brand);
  background: var(--white);
  outline: none;
  transition: border-color 0.15s ease;
  text-align: center;
}

.gift-code-input::placeholder {
  color: var(--gray-dark);
  opacity: 0.7;
}

.gift-code-input:focus { border-color: var(--brand); }

.gift-check-btn {
  width: 100%;
  height: 52px;
  min-height: 44px;
  border: none;
  border-radius: var(--radius-sm);
  background-color: var(--brand);
  color: var(--white);
  font-size: 1.2rem;
  font-weight: 700;
  font-family: var(--font-stack);
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.gift-check-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.gift-check-btn:active:not(:disabled) { opacity: 0.85; }

/* Loaded — balance + redeem inside a green-bordered card */
.gift-loaded {
  width: 100%;
  margin-top: 20px;
  margin-bottom: 20px;
}

.gift-card {
  width: 100%;
  background: var(--white);
  border: var(--card-border);
  border-radius: var(--radius);
  padding: 22px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gift-balance-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--brand);
  text-align: center;
  opacity: 0.75;
  letter-spacing: 0.04em;
}

.gift-balance-amount {
  font-size: 3.4rem;
  font-weight: 700;
  color: var(--brand);
  text-align: center;
  line-height: 1;
  margin-bottom: 6px;
}

.gift-redeem-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--brand);
  text-align: center;
}

.gift-amount-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 2px solid rgba(63, 92, 56, 0.3);
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-family: var(--font-stack);
  color: var(--brand);
  background: var(--white);
  outline: none;
  transition: border-color 0.15s ease;
  text-align: center;
}

.gift-amount-input::placeholder {
  color: var(--gray-dark);
  opacity: 0.7;
}

.gift-amount-input:focus { border-color: var(--brand); }

.gift-amount-input::-webkit-outer-spin-button,
.gift-amount-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.gift-amount-input { -moz-appearance: textfield; }

.gift-redeem-btn {
  width: 100%;
  height: 52px;
  min-height: 44px;
  border: none;
  border-radius: var(--radius-sm);
  background-color: var(--brand);
  color: var(--white);
  font-size: 1.2rem;
  font-weight: 700;
  font-family: var(--font-stack);
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.gift-redeem-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.gift-redeem-btn:active:not(:disabled) { opacity: 0.85; }

/* ============================================================
   8b. SOCIAL HUB
   ============================================================ */

.social-separator {
  width: 100%;
  height: 1px;
  background: rgba(63, 92, 56, 0.18);
  border: none;
  margin: 4px 0 18px;
}

.social-hub {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 22px;
  padding-bottom: 8px;
}

.social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  text-decoration: none;
  background: transparent;
  border: none;
  opacity: 0.85;
  transition: opacity 0.15s ease, transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.social-link svg {
  width: 28px;
  height: 28px;
  display: block;
}

.social-link:hover,
.social-link:focus-visible { opacity: 1; }

.social-link:active { transform: scale(0.92); }

.social-link--facebook  { color: #1877F2; }
.social-link--instagram { color: #E1306C; }
.social-link--maps      { color: #EA4335; }
.social-link--phone     { color: var(--brand); }

/* ─── action pills (pay with bit, jobs) ─── */

.pill-row {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
  padding-bottom: 4px;
}

.pill-row--secondary {
  margin-top: 12px;
  padding-bottom: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  min-width: 72px;
  padding: 6px 22px;
  border: none;
  border-radius: 999px;
  font-family: var(--font-stack);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.pill:hover,
.pill:focus-visible { opacity: 0.88; }

.pill:active { transform: scale(0.94); }

.pill--bit,
.pill--paybox { min-width: 120px; }

.pill--bit    { background: #06061B; color: #3DD4BC; }
.pill--paybox { background: #33B5E5; color: #FFFFFF; }

.pill--jobs {
  background: #D1D5DB;
  color: #111827;
  font-weight: 400;
  font-size: 0.9rem;
  min-height: 28px;
  min-width: 60px;
  padding: 4px 14px;
}

/* ============================================================
   9. FOOTER
   ============================================================ */

.footer {
  width: 100%;
  padding: 0 0 24px;
  margin-top: auto;
}

/* ============================================================
   10. TOAST
   ============================================================ */

.toast {
  position: fixed;
  top: 33%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  background-color: var(--brand);
  color: var(--white);
  font-size: 1rem;
  font-weight: 600;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  white-space: nowrap;
}

.toast.visible {
  opacity: 1;
}

/* ============================================================
   11. CELEBRATION OVERLAY
   ============================================================ */

.celebration-overlay {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  background: rgba(63, 92, 56, 0.95);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.celebration-overlay.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Pause confetti when overlay is not visible to save CPU */
.celebration-overlay:not(.visible) .confetti {
  animation-play-state: paused;
}

.celebration-content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 20px;
  color: var(--white);
}

.celebration-line1 {
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 40px;
}

.celebration-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 56px;
  border: 2.5px solid var(--white);
  border-radius: var(--radius);
  background: transparent;
  color: var(--white);
  font-family: var(--font-stack);
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
  transition: background-color 0.15s ease;
}

.celebration-close-btn:active {
  background-color: rgba(255, 255, 255, 0.15);
}

/* ============================================================
   12. CONFETTI
   ============================================================ */

.confetti-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 1;
  pointer-events: none;
}

.confetti {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 12px;
  will-change: transform;
  animation-name: confetti-fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  animation-duration: 3s;
  animation-delay: 0s;
}

/* Shape definitions via clip-path */
.confetti-diamond {
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.confetti-circle {
  border-radius: 50%;
  clip-path: none;
}

.confetti-hexagon {
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

.confetti-triangle {
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
}

.confetti-square {
  clip-path: none;
  border-radius: 2px;
}

/* Colors: odd = cream, even = butter yellow (drawn from logo palette) */
.confetti:nth-child(odd) {
  background: rgba(244, 235, 210, 0.9);
}

.confetti:nth-child(even) {
  background: rgba(242, 210, 88, 0.85);
}

/* Horizontal positions — spread across viewport */
.confetti:nth-child(1)  { left: 3%; }
.confetti:nth-child(2)  { left: 10%; }
.confetti:nth-child(3)  { left: 16%; }
.confetti:nth-child(4)  { left: 22%; }
.confetti:nth-child(5)  { left: 28%; }
.confetti:nth-child(6)  { left: 34%; }
.confetti:nth-child(7)  { left: 40%; }
.confetti:nth-child(8)  { left: 46%; }
.confetti:nth-child(9)  { left: 52%; }
.confetti:nth-child(10) { left: 58%; }
.confetti:nth-child(11) { left: 64%; }
.confetti:nth-child(12) { left: 70%; }
.confetti:nth-child(13) { left: 76%; }
.confetti:nth-child(14) { left: 82%; }
.confetti:nth-child(15) { left: 88%; }
.confetti:nth-child(16) { left: 5%; }
.confetti:nth-child(17) { left: 13%; }
.confetti:nth-child(18) { left: 21%; }
.confetti:nth-child(19) { left: 30%; }
.confetti:nth-child(20) { left: 38%; }
.confetti:nth-child(21) { left: 47%; }
.confetti:nth-child(22) { left: 55%; }
.confetti:nth-child(23) { left: 63%; }
.confetti:nth-child(24) { left: 72%; }
.confetti:nth-child(25) { left: 80%; }
.confetti:nth-child(26) { left: 91%; }
.confetti:nth-child(27) { left: 95%; }
.confetti:nth-child(28) { left: 8%; }
.confetti:nth-child(29) { left: 44%; }
.confetti:nth-child(30) { left: 85%; }

/* Sizes: vary between 8px and 16px */
.confetti:nth-child(5n+1) { width: 10px; height: 10px; }
.confetti:nth-child(5n+2) { width: 14px; height: 14px; }
.confetti:nth-child(5n+3) { width: 8px;  height: 8px; }
.confetti:nth-child(5n+4) { width: 12px; height: 12px; }
.confetti:nth-child(5n+5) { width: 16px; height: 16px; }

/* Animation durations & delays — stagger for natural look */
.confetti:nth-child(6n+1) { animation-duration: 2.8s; animation-delay: -0.3s; }
.confetti:nth-child(6n+2) { animation-duration: 3.5s; animation-delay: -1.8s; }
.confetti:nth-child(6n+3) { animation-duration: 4.2s; animation-delay: -3.1s; }
.confetti:nth-child(6n+4) { animation-duration: 2.5s; animation-delay: -0.9s; }
.confetti:nth-child(6n+5) { animation-duration: 3.8s; animation-delay: -2.5s; }
.confetti:nth-child(6n+6) { animation-duration: 3.1s; animation-delay: -4.2s; }

/* ============================================================
   13. KEYFRAMES
   ============================================================ */

/* Punch fill: scale from 0 to full with bounce */
@keyframes punch-fill {
  0%   { transform: scale(0); opacity: 0; }
  50%  { transform: scale(1.15); opacity: 1; }
  70%  { transform: scale(0.95); }
  100% { transform: scale(1); opacity: 1; }
}

/* Shake: horizontal oscillation for wrong code */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-8px); }
  40%      { transform: translateX(8px); }
  60%      { transform: translateX(-6px); }
  80%      { transform: translateX(4px); }
}

/* Confetti fall */
@keyframes confetti-fall {
  0% {
    transform: translateY(-20px) translateX(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(110vh) translateX(25px) rotate(360deg);
    opacity: 0.6;
  }
}

/* Alternate rotation direction for even confetti */
.confetti:nth-child(even) {
  animation-name: confetti-fall-reverse;
}

@keyframes confetti-fall-reverse {
  0% {
    transform: translateY(-20px) translateX(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(110vh) translateX(-20px) rotate(-360deg);
    opacity: 0.6;
  }
}

/* ============================================================
   14. INTERACTIVE STATES (touch-action, focus-visible)
   ============================================================ */

button {
  touch-action: manipulation;
}

.code-input {
  touch-action: manipulation;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Remove default outlines in favor of focus-visible */
:focus:not(:focus-visible) {
  outline: none;
}

/* ============================================================
   15. REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  .slot.punched .slot-fill,
  .slot.punched.animating .slot-fill {
    /* Instant appearance, no animation */
    animation: none;
    transition: none;
    opacity: 1;
    transform: scale(1);
  }

  .code-input.shake {
    animation: none;
  }

  .toast {
    transition: none;
  }

  .celebration-overlay {
    transition: none;
  }

  .confetti {
    display: none;
  }
}

/* ============================================================
   16. UTILITY CLASSES
   ============================================================ */

.hidden {
  display: none !important;
}

.shake {
  animation: shake 0.3s ease;
}

/* Body overflow lock when celebration is showing */
body.celebration-active {
  overflow: hidden;
}

/* ============================================================
   17. STORAGE ERROR
   ============================================================ */

.storage-error {
  width: 100%;
  max-width: 480px;
  padding: 40px 20px;
  text-align: center;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--white);
}

.storage-error-he {
  font-size: 1.1rem;
  color: var(--brand);
  margin-bottom: 12px;
  line-height: 1.5;
}

.storage-error-en {
  font-size: 0.9rem;
  color: var(--gray-dark);
  line-height: 1.5;
}
