
:root {
  --ink: #28271f;
  --paper: #f7f4ed;
  --card: #fffefa;
  --gold: #a77b3d;
  --gold-light: #eadcc5;
  --line: #e9e3d7;
  --muted: #898274;
  --green: #526b50;
  --serif: "Playfair Display", Georgia, serif;
  --sans: "DM Sans", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.customer-app {
  width: 100%;
  max-width: 580px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 24px;
}

/* Loading */

.loading-view,
.error-view {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.loading-view p,
.error-view p {
  color: var(--muted);
  font-size: 14px;
}

.loader {
  width: 34px;
  height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.error-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: #f2e8dc;
  border-radius: 50%;
  color: #9a583b;
  font-size: 24px;
}

/* Brand */

.brand-header {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: white;
  border-radius: 50%;
  font-family: var(--serif);
  font-size: 23px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
}

.brand-header h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 600;
}

/* Authentication */

.auth-view {
  padding-top: 35px;
}

.auth-card {
  margin-top: 48px;
  padding: 30px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 12px 35px rgba(40, 39, 31, 0.04);
}

.auth-heading h2,
.welcome-section h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 32px;
  line-height: 1.2;
  font-weight: 600;
}

.auth-heading > p:last-child {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin: 28px 0 25px;
  padding: 5px;
  background: var(--paper);
  border-radius: 9px;
}

.auth-tab {
  padding: 11px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.auth-tab.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.form-group {
  margin-bottom: 19px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
}

.form-group input {
  width: 100%;
  height: 47px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  transition: border 0.2s;
}

.form-group input:focus {
  border-color: var(--gold);
}

.primary-btn {
  width: 100%;
  min-height: 48px;
  padding: 12px 18px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-size: 13px;
  font-weight: 600;
  transition: opacity 0.2s, transform 0.2s;
}

.primary-btn:hover {
  opacity: 0.9;
}

.primary-btn:active {
  transform: scale(0.99);
}

.primary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.message {
  min-height: 18px;
  margin: 14px 0 0;
  color: #a34f3c;
  font-size: 12px;
  line-height: 1.5;
}

.message.success {
  color: var(--green);
}

.auth-note {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
}

/* Customer dashboard */

.customer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
}

.text-btn {
  padding: 9px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.text-btn:hover {
  color: var(--ink);
}

.welcome-section {
  margin: 55px 0 30px;
}

.welcome-section h2 {
  font-size: 29px;
}

.welcome-section > p:last-child {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

/* Loyalty card */

.loyalty-card {
  padding: 27px;
  overflow: hidden;
  background: var(--ink);
  color: white;
  border-radius: 18px;
  box-shadow: 0 16px 35px rgba(40, 39, 31, 0.12);
}

.loyalty-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 15px;
}

.loyalty-card .eyebrow {
  color: #c5a16c;
}

.loyalty-card h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 500;
}

.card-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: #d7b47e;
  font-size: 20px;
}

.reward-description {
  margin: 12px 0 27px;
  color: #c3beb4;
  font-size: 12px;
  line-height: 1.6;
}

/* Stamp grid */

.stamp-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 15px;
  padding: 5px 0 25px;
}

.stamp-slot {
  aspect-ratio: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px dashed rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  color: #aaa397;
  font-size: 17px;
  font-weight: 600;
}

.stamp-slot.earned {
  border: 1px solid #c5a16c;
  background: #c5a16c;
  color: var(--ink);
}

.stamp-slot.reward-slot {
  border-color: #c5a16c;
  color: #d7b47e;
}

.progress-section {
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: #c3beb4;
  font-size: 11px;
}

.progress-label strong {
  color: white;
  font-size: 12px;
}

.progress-track {
  width: 100%;
  height: 6px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 20px;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: #c5a16c;
  border-radius: 20px;
  transition: width 0.4s ease;
}

.reward-status {
  margin-top: 19px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  color: #e1d2b9;
  font-size: 11px;
  line-height: 1.6;
}

/* Membership */

.membership-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.info-card {
  min-width: 0;
  padding: 17px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 11px;
}

.info-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
}

.info-card strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 600;
}

/* Footer */

.business-footer {
  margin-top: 35px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
  text-align: center;
}

.business-footer p {
  margin: 4px 0;
}

@media (max-width: 480px) {
  .customer-app {
    padding: 24px 17px;
  }

  .auth-card {
    margin-top: 35px;
    padding: 23px 19px;
  }

  .auth-heading h2 {
    font-size: 28px;
  }

  .welcome-section {
    margin-top: 42px;
  }

  .loyalty-card {
    padding: 22px 18px;
  }

  .stamp-grid {
    gap: 11px;
  }

  .stamp-slot {
    font-size: 15px;
  }

  .membership-info {
    grid-template-columns: 1fr;
  }
}

/* =========================================
   FINAL RESPONSIVE & ACCESSIBILITY PATCH
========================================= */

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.auth-tab:focus-visible,
.text-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 4px;
  border-radius: 5px;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

input {
  min-width: 0;
}

.brand-header,
.customer-header,
.loyalty-card-top {
  min-width: 0;
}

.brand-header > div,
.loyalty-card-top > div {
  min-width: 0;
}

.brand-header h1,
.loyalty-card h2,
.welcome-section h2 {
  overflow-wrap: anywhere;
}

.stamp-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stamp-slot {
  min-width: 0;
}

.progress-label span {
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 360px) {
  .customer-app {
    padding: 20px 13px;
  }

  .auth-card {
    padding: 21px 16px;
  }

  .loyalty-card {
    padding: 20px 15px;
  }

  .stamp-grid {
    gap: 9px;
  }

  .stamp-slot {
    font-size: 13px;
  }

  .membership-info {
    gap: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}


/* =========================================
   LOYALTY REWARD — GIFT BOX REVEAL
========================================= */

.gift-reveal {
  position: relative;
  overflow: hidden;
  margin-top: 22px;
  padding: 30px 22px;
  border: 1px solid var(--gold-light);
  border-radius: 18px;
  background: var(--card);
  text-align: center;
  animation: gift-section-enter .65s ease both;
}

.gift-reveal > .eyebrow {
  position: relative;
  z-index: 2;
}

.gift-illustration {
  position: relative;
  width: 170px;
  height: 155px;
  margin: 22px auto 18px;
  animation: gift-float 3s ease-in-out infinite;
}

.gift-base {
  position: absolute;
  left: 28px;
  bottom: 12px;
  width: 114px;
  height: 83px;
  border-radius: 5px 5px 12px 12px;
  background: linear-gradient(135deg, #c69b5b, #9b6d32);
  box-shadow: 0 12px 22px rgba(40, 39, 31, .16);
  animation: gift-pop .7s .2s ease both;
}

.gift-ribbon {
  position: absolute;
  left: 46px;
  top: 0;
  width: 22px;
  height: 100%;
  background: #f4e4c6;
}

.gift-lid {
  position: absolute;
  z-index: 2;
  left: 20px;
  top: 43px;
  width: 130px;
  height: 25px;
  border-radius: 5px;
  background: #d7b47e;
  box-shadow: 0 5px 10px rgba(40, 39, 31, .12);
  transform-origin: 15% 100%;
  animation: gift-lid-open .9s .65s ease forwards;
}

.gift-lid-ribbon {
  position: absolute;
  left: 54px;
  top: 0;
  width: 22px;
  height: 100%;
  background: #fff0d5;
}

.gift-bow {
  position: absolute;
  top: -17px;
  width: 27px;
  height: 22px;
  border: 6px solid #a77b3d;
  border-radius: 50% 50% 5px 50%;
}

.bow-left {
  left: 47px;
  transform: rotate(25deg);
}

.bow-right {
  left: 69px;
  transform: scaleX(-1) rotate(25deg);
}

.gift-spark {
  position: absolute;
  z-index: 3;
  color: var(--gold);
  font-size: 23px;
  opacity: 0;
  animation: gift-sparkle 1.5s 1.1s ease forwards;
}

.spark-one {
  top: 15px;
  left: 13px;
}

.spark-two {
  top: 45px;
  right: 7px;
  animation-delay: 1.35s;
}

.spark-three {
  top: 0;
  right: 35px;
  animation-delay: 1.6s;
}

.gift-reveal h2 {
  margin: 8px 0 10px;
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 600;
  color: var(--ink);
}

.gift-reveal-message {
  max-width: 340px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.gift-reward-details {
  margin-top: 22px;
  padding: 18px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--paper);
}

.gift-reward-details > span {
  display: block;
  color: var(--gold);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
}

.gift-reward-details strong {
  display: block;
  margin-top: 9px;
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
}

.gift-reward-details p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.gift-redeem-note {
  margin: 20px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

@keyframes gift-section-enter {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes gift-pop {
  from {
    opacity: 0;
    transform: scale(.75);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes gift-lid-open {
  from {
    transform: rotate(0);
  }
  to {
    transform: translate(-8px, -28px) rotate(-25deg);
  }
}

@keyframes gift-float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

@keyframes gift-sparkle {
  0% {
    opacity: 0;
    transform: scale(.4);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
  100% {
    opacity: .8;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .gift-reveal,
  .gift-illustration,
  .gift-base,
  .gift-lid,
  .gift-spark {
    animation: none !important;
  }

  .gift-lid {
    transform: translate(-8px, -28px) rotate(-25deg);
  }
}
