/* Sanity Vouchers - warm, soft, tired-parent friendly */

:root {
  color-scheme: light dark;

  --bg: #fff4ea;
  --bg-glow: #ffe1cf;
  --surface: #ffffff;
  --surface-2: #fff8f1;
  --text: #3b2a26;
  --muted: #8a6d65;
  --line: #f2d6c6;
  --coral: #ff6f61;
  --coral-deep: #dc4a3c;
  --coral-ink: #c9402f;
  --peach: #ffc49b;
  --peach-soft: #ffe9db;
  --on-coral: #ffffff;
  --shadow: rgba(186, 88, 58, 0.18);
  --backdrop: rgba(70, 32, 22, 0.45);
  --danger: #c0392b;
  --track: #fbe0d2;

  --radius: 22px;
  --stub: 60px;
  --notch: 11px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f1614;
    --bg-glow: #3a221c;
    --surface: #2d201d;
    --surface-2: #372723;
    --text: #fcebe3;
    --muted: #cba99d;
    --line: #533a32;
    --coral: #ff8a7a;
    --coral-deep: #e25a4b;
    --coral-ink: #ffa595;
    --peach: #b9714f;
    --peach-soft: #46302a;
    --on-coral: #ffffff;
    --shadow: rgba(0, 0, 0, 0.45);
    --backdrop: rgba(0, 0, 0, 0.6);
    --danger: #ff9d90;
    --track: #4a342d;
  }
}

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

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: radial-gradient(120% 60% at 50% -10%, var(--bg-glow), transparent 70%) no-repeat, var(--bg);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

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

.noscript {
  padding: 24px;
  text-align: center;
}

/* ---------- Loading ---------- */

.loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
}

.loading-ticket {
  font-size: 56px;
  animation: bob 1.2s ease-in-out infinite;
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0) rotate(-8deg);
  }
  50% {
    transform: translateY(-10px) rotate(6deg);
  }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
  white-space: nowrap;
  transition: transform 0.12s ease, filter 0.12s ease, opacity 0.12s ease;
}

.btn:active {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

.btn-primary {
  color: var(--on-coral);
  background: linear-gradient(135deg, #ee6152, #dc4a3c);
  box-shadow: 0 6px 16px var(--shadow);
}

.btn-soft {
  color: var(--coral-ink);
  background: var(--peach-soft);
}

.btn-ghost {
  color: var(--muted);
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--line);
}

.btn-small {
  min-height: 38px;
  padding: 0 16px;
  font-size: 14px;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  width: 40px;
  height: 40px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--peach-soft);
  color: var(--coral-ink);
  font-size: 16px;
  font-weight: 700;
}

/* ---------- Cards & fields ---------- */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px var(--shadow);
  padding: 20px;
}

.field {
  display: block;
  margin: 16px 0 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.field-label {
  display: block;
  margin: 16px 0 8px;
  padding: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.field > .field-label {
  margin-top: 0;
}

.hint {
  font-weight: 500;
  opacity: 0.85;
}

input[type="text"],
input[type="password"],
input[type="number"],
textarea {
  display: block;
  width: 100%;
  min-height: 50px;
  padding: 12px 16px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: var(--surface-2);
  font-size: 16px; /* 16px stops iOS zooming in on focus */
  appearance: none;
  -webkit-appearance: none;
}

textarea {
  resize: none;
  min-height: 72px;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--coral);
  box-shadow: 0 0 0 3px var(--peach-soft);
}

::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.form-error {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--peach-soft);
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
}

/* ---------- Login ---------- */

.login {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(28px + env(safe-area-inset-top)) calc(20px + env(safe-area-inset-right))
    calc(28px + env(safe-area-inset-bottom)) calc(20px + env(safe-area-inset-left));
}

.login-hero {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo {
  display: block;
  margin: 0 auto 14px;
  border-radius: 22px;
  filter: drop-shadow(0 10px 18px var(--shadow));
  animation: float 4s ease-in-out infinite;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

.login h1 {
  font-size: 30px;
  letter-spacing: -0.02em;
}

.tagline {
  margin-top: 4px;
  color: var(--muted);
  font-style: italic;
}

.login-question {
  text-align: center;
  font-weight: 700;
  margin-bottom: 14px;
}

.who {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.who-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 16px 8px 14px;
  border: 2px solid var(--line);
  border-radius: 20px;
  background: var(--surface-2);
  font-weight: 700;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.who-btn.selected {
  border-color: var(--coral);
  background: var(--peach-soft);
  transform: translateY(-2px);
}

.avatar {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  color: #fff;
  font-size: 30px;
  font-weight: 800;
  box-shadow: 0 6px 14px var(--shadow);
}

.avatar-nathan {
  background: linear-gradient(135deg, #ffa55c, #f0625a);
}

.avatar-meaghan {
  background: linear-gradient(135deg, #ff8fa3, #e2557f);
}

.login-card .btn-block {
  margin-top: 18px;
}

.login-foot {
  margin-top: 22px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- App shell ---------- */

.app {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 6px;
}

.topbar-text {
  min-width: 0;
}

.brand {
  font-size: 22px;
  letter-spacing: -0.02em;
}

.greeting {
  color: var(--muted);
  font-size: 14px;
}

.content {
  padding: 8px 16px calc(120px + env(safe-area-inset-bottom));
}

.section {
  margin-top: 22px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 0 4px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.count {
  color: var(--muted);
  font-weight: 600;
}

.list {
  display: grid;
  gap: 14px;
}

.history > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  -webkit-user-select: none;
}

.history > summary::-webkit-details-marker {
  display: none;
}

.history > summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.history[open] > summary::after {
  transform: rotate(180deg);
}

/* ---------- Notification card ---------- */

.notify {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding: 14px 16px;
  font-size: 14px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1.5px var(--line);
}

.notify-text {
  flex: 1 1 200px;
  min-width: 0;
}

.notify-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.notify-on {
  padding: 8px 8px 8px 16px;
  color: var(--muted);
  background: transparent;
}

/* ---------- Tickets ---------- */

.ticket-wrap {
  min-width: 0;
  filter: drop-shadow(0 6px 12px var(--shadow));
  animation: rise 0.3s ease both;
}

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

/* a bundle of identical vouchers: more tickets peeking out underneath */
.is-stack {
  position: relative;
  isolation: isolate;
  margin-bottom: 11px;
}
.is-stack-deep {
  margin-bottom: 21px;
}
.is-stack::before,
.is-stack-deep::after {
  content: "";
  position: absolute;
  z-index: -1;
  height: 44px;
  border-radius: 0 0 20px 20px;
  border: 1px solid var(--line);
  border-top: 0;
}
.is-stack::before {
  left: 12px;
  right: 12px;
  bottom: -11px;
  background: color-mix(in srgb, var(--surface) 72%, var(--peach));
}
.is-stack-deep::after {
  left: 26px;
  right: 26px;
  bottom: -21px;
  z-index: -2;
  background: color-mix(in srgb, var(--surface) 50%, var(--peach));
}

.stack-count {
  flex: none;
  align-self: flex-start;
  padding: 4px 11px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ee6152, #dc4a3c);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.ticket {
  background: var(--surface);
  border-radius: 20px;
  /* two half-width masks, each biting a circular notch out of its outer edge */
  -webkit-mask:
    radial-gradient(circle at 0 calc(100% - var(--stub)), transparent calc(var(--notch) - 0.5px), #000 var(--notch)) left / 51% 100% no-repeat,
    radial-gradient(circle at 100% calc(100% - var(--stub)), transparent calc(var(--notch) - 0.5px), #000 var(--notch)) right / 51% 100% no-repeat;
  mask:
    radial-gradient(circle at 0 calc(100% - var(--stub)), transparent calc(var(--notch) - 0.5px), #000 var(--notch)) left / 51% 100% no-repeat,
    radial-gradient(circle at 100% calc(100% - var(--stub)), transparent calc(var(--notch) - 0.5px), #000 var(--notch)) right / 51% 100% no-repeat;
}

.is-active .ticket {
  background: linear-gradient(165deg, var(--peach-soft), var(--surface) 65%);
}

.is-history {
  filter: none;
  opacity: 0.85;
}

.is-history .ticket {
  background: var(--surface-2);
}

.ticket-main {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 18px 18px 16px;
}

.ticket-emoji {
  flex: none;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--peach-soft);
  font-size: 28px;
  line-height: 1;
}

.ticket-info {
  flex: 1;
  min-width: 0;
}

.ticket-title {
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.ticket-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin-top: 6px;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ee6152, #dc4a3c);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-soft {
  background: var(--peach-soft);
  color: var(--coral-ink);
}

.ticket-from {
  font-size: 13px;
  font-style: italic;
  color: var(--muted);
}

.ticket-note {
  margin-top: 8px;
  font-size: 14px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.ticket-stub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: var(--stub);
  padding: 0 20px;
  border-top: 2px dashed var(--line);
}

.stub-text {
  min-width: 0;
  font-size: 13px;
  line-height: 1.3;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ticket-stub .btn {
  flex: none;
}

/* countdown */

.countdown {
  margin-top: 12px;
}

.countdown-time {
  font-size: 34px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--coral-ink);
}

.progress {
  height: 10px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--peach), var(--coral));
  transition: width 1s linear;
}

.countdown-caption {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

/* empty states */

.empty {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border: 2px dashed var(--line);
  border-radius: 20px;
  color: var(--muted);
  font-size: 14px;
}

.empty-emoji {
  flex: none;
  font-size: 26px;
}

/* ---------- Floating "gift" button ---------- */

.fab-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  padding: 28px 16px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 45%, transparent);
  pointer-events: none;
}

.fab {
  pointer-events: auto;
  min-height: 56px;
  padding: 0 30px;
  font-size: 17px;
  box-shadow: 0 10px 24px var(--shadow);
}

/* ---------- Dialogs ---------- */

.dialog {
  width: calc(100% - 40px);
  max-width: 400px;
  max-height: calc(100dvh - 40px);
  padding: 0;
  border: 0;
  border-radius: 26px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.dialog::backdrop {
  background: var(--backdrop);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.dialog[open] {
  animation: pop 0.2s ease-out;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
}

.dialog-body {
  padding: 24px 22px 22px;
}

#confirm-dialog .dialog-body {
  text-align: center;
}

.dialog-emoji {
  font-size: 46px;
  line-height: 1.1;
  margin-bottom: 6px;
}

.dialog h2 {
  font-size: 21px;
  letter-spacing: -0.01em;
}

.dialog-voucher {
  display: inline-block;
  max-width: 100%;
  margin: 10px 0 2px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--peach-soft);
  color: var(--coral-ink);
  font-weight: 700;
  font-size: 14px;
  overflow-wrap: anywhere;
}

#confirm-text {
  margin-top: 10px;
  color: var(--muted);
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

.dialog-actions .btn {
  padding: 0 10px;
  min-width: 0;
}

/* bottom sheet */

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  max-height: 92dvh;
  margin: auto auto 0;
  border-radius: 28px 28px 0 0;
}

.sheet[open] {
  animation: slide-up 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes slide-up {
  from {
    transform: translateY(100%);
  }
}

.sheet .dialog-body {
  padding: 10px calc(20px + env(safe-area-inset-right)) calc(22px + env(safe-area-inset-bottom))
    calc(20px + env(safe-area-inset-left));
}

.sheet-handle {
  width: 44px;
  height: 5px;
  margin: 0 auto 10px;
  border-radius: 999px;
  background: var(--line);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sheet-sub {
  margin-top: 2px;
  font-size: 14px;
  color: var(--muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  max-width: 100%;
  padding: 8px 13px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
}

.chip.selected {
  border-color: var(--coral);
  background: var(--peach-soft);
  color: var(--coral-ink);
}

.chip-time {
  color: var(--muted);
  font-weight: 700;
}

.emoji-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.emoji-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 14px;
  background: var(--surface-2);
  font-size: 22px;
  line-height: 1;
}

.emoji-btn.selected {
  border-color: var(--coral);
  background: var(--peach-soft);
  transform: scale(1.06);
}

.duration-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.duration-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 14px;
  color: var(--muted);
}

.duration-field input {
  min-width: 0;
  text-align: center;
  font-weight: 700;
}

#gift-submit {
  margin-top: 20px;
}

/* ---------- Toast & confetti ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 50;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 18px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transform: translateX(-50%);
  pointer-events: none;
}

.toast-in {
  animation: toast-in 0.25s ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 12px);
  }
}

.confetti {
  position: fixed;
  inset: 0;
  z-index: 60;
  overflow: hidden;
  pointer-events: none;
}

.confetti-bit {
  position: absolute;
  left: 50%;
  top: 45%;
  font-size: var(--size, 22px);
  line-height: 1;
  opacity: 0;
  animation: burst 1.5s cubic-bezier(0.15, 0.7, 0.3, 1) var(--delay, 0ms) forwards;
  will-change: transform, opacity;
}

@keyframes burst {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.3);
  }
  65% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px) + 140px)) rotate(var(--rot, 0deg)) scale(1);
  }
}

@media (min-width: 600px) {
  .sheet {
    margin: auto;
    border-radius: 28px;
  }

  .sheet-handle {
    visibility: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
