/* Sending a flower: the Send panel and the Download menu (the editor's dark
   glass), and the recipient's message card. The card is frosted white over
   light backdrops and dark glass over the rest (gift.js picks), so the note
   reads on any backdrop. Loads after app.css and reuses its buttons, switches
   and popover header. */

/* ── Send panel and Download menu ────────────────────────────────────────── */
/* Fixed, hung under their buttons by gift.js. */
.gift-pop,
.export-pop {
  position: fixed;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(340px, calc(100vw - 2 * var(--m)));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 14px 14px;
  border-radius: 18px;
  font-size: 13px;
  /* Over pale backdrops the bars' thin glass is too faint for form text. */
  background: rgba(17, 16, 21, max(var(--glass-a, .46), .66));
  animation: gift-pop-in .14s ease;
}
.export-pop { width: min(316px, calc(100vw - 2 * var(--m))); }
.gift-pop[hidden], .export-pop[hidden] { display: none; }
#app.ui-hidden .gift-pop, #app.ui-hidden .export-pop { display: none; }
/* The panel itself takes focus on touch screens; it needs no ring. */
.gift-pop:focus-visible, .export-pop:focus-visible {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .09), inset 0 1px 0 rgba(255, 255, 255, .08), 0 16px 48px rgba(0, 0, 0, .32);
}
.gift-pop .pop-head b, .export-pop .pop-head b { font: 600 14px var(--display); letter-spacing: -.005em; }
.gift-pop .gift-hint { margin: -8px 0 0; }

.gift-field { display: flex; flex-direction: column; gap: 6px; }
.gift-field[hidden] { display: none; }
.gift-label { display: flex; justify-content: space-between; align-items: baseline; color: var(--text-2); font-size: 12px; }
.gift-count { color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.gift-count.near { color: var(--text); }
.gift-input {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 0;
  border-radius: 11px;
  background: var(--well);
  box-shadow: inset 0 0 0 1px var(--hair);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition: background .12s, box-shadow .12s;
}
.gift-input::placeholder { color: var(--faint); }
.gift-input:hover { background: rgba(0, 0, 0, .28); }
.gift-input:focus { box-shadow: inset 0 0 0 1px var(--hair), var(--focus); }
.gift-textarea {
  height: auto;
  min-height: 96px;
  max-height: 34vh;
  padding: 9px 11px;
  line-height: 1.45;
  resize: none;
  field-sizing: content;   /* grows with the message where supported */
}
.gift-link { color: var(--text-2); font-size: 12px; }

.gift-privacy { display: flex; align-items: flex-start; gap: 8px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; text-wrap: pretty; }
.gift-privacy-icon { flex: none; padding-top: 1px; }
.gift-privacy-icon svg { width: 15px; height: 15px; }

/* Buttons share the row equally, as in the editor's popovers. */
.gift-row { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: 6px; }
.gift-row .btn { height: 36px; padding: 0 8px; border-radius: 11px; }
.gift-pop .btn:disabled, .export-pop .btn:disabled { opacity: .6; cursor: default; transform: none; }

/* Size tiles: a little frame of each shape, its name and pixel size. */
.export-sizes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.export-size {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 11px 4px 9px;
  border-radius: 12px;
  background: var(--wash);
  color: var(--muted);
  transition: background .12s, color .12s, box-shadow .12s;
}
.export-size:hover { background: var(--wash-2); color: var(--text); }
.export-size[aria-pressed="true"] { background: rgba(255, 255, 255, .2); color: var(--text); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .3); }
.export-glyph-box { display: grid; place-items: center; height: 26px; margin-bottom: 2px; }
.export-glyph { display: block; border-radius: 3px; box-shadow: inset 0 0 0 1.5px currentColor; }
.export-name { font-weight: 600; font-size: 12.5px; }
.export-dims { color: var(--faint); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.export-size[aria-pressed="true"] .export-dims { color: var(--muted); }
.export-note.disabled { opacity: .5; cursor: default; }
.export-note.disabled .switch { cursor: default; }
.export-hint { margin: -7px 0 0 49px; color: var(--muted); font-size: 11.5px; }
.export-hint[hidden] { display: none; }
.export-spin {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(20, 18, 23, .2);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes gift-pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ── recipient view ──────────────────────────────────────────────────────── */
/* Covers the window without taking pointer events, so the flower can still be
   turned everywhere except on the card and buttons. --gift-card and
   --gift-actions (0..1) are set by setProgress(). */
.gift-view {
  --gift-card: 0;
  --gift-actions: 0;
  --g-bg: rgba(17, 16, 21, .5);
  --g-solid: rgba(24, 23, 29, .96);
  --g-text: #f4f2ee;
  --g-text-2: rgba(244, 242, 238, .86);
  --g-muted: rgba(244, 242, 238, .6);
  --g-edge: rgba(255, 255, 255, .1);
  --g-hi: rgba(255, 255, 255, .08);
  --g-shadow: rgba(0, 0, 0, .3);
  --g-outline: transparent;
  --g-btn: rgba(255, 255, 255, .11);
  --g-primary: #f4f2ee;
  --g-primary-hover: #fff;
  --g-primary-text: #141217;
  --g-focus: 0 0 0 2px rgba(244, 242, 238, .6);
  position: fixed;
  inset: 0;
  z-index: 40;
  color: var(--g-text);
  font: 13px/1.4 var(--font);
  pointer-events: none;
}
.gift-view[data-tone="light"] {
  --g-bg: rgba(252, 251, 249, .58);
  --g-solid: rgba(250, 249, 247, .97);
  --g-text: #17151b;
  --g-text-2: rgba(23, 21, 27, .84);
  --g-muted: rgba(23, 21, 27, .56);
  --g-edge: rgba(255, 255, 255, .55);
  --g-hi: rgba(255, 255, 255, .75);
  --g-shadow: rgba(48, 34, 58, .14);
  --g-outline: rgba(48, 34, 58, .07);   /* keeps the card's edge on near-white backdrops */
  --g-btn: rgba(23, 21, 27, .07);
  --g-primary: #17151b;
  --g-primary-hover: #000;
  --g-primary-text: #f7f5f2;
  --g-focus: 0 0 0 2px rgba(23, 21, 27, .5);
}
.gift-view[hidden] { display: none; }

.gift-card, .gift-actions, .gift-bar {
  background: var(--g-bg);
  -webkit-backdrop-filter: blur(28px) saturate(170%);
  backdrop-filter: blur(28px) saturate(170%);
  box-shadow: inset 0 0 0 1px var(--g-edge), inset 0 1px 0 var(--g-hi), 0 0 0 1px var(--g-outline), 0 18px 48px -10px var(--g-shadow);
}

/* Card and buttons sit low and centered, clear of the bloom. */
.gift-stack {
  position: absolute;
  left: 50%;
  bottom: max(var(--m), env(safe-area-inset-bottom, 0px));
  translate: -50% 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(440px, calc(100% - 2 * var(--m)));
}
.gift-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: min(260px, 100%);
  max-width: 100%;
  padding: 17px 28px 16px;
  border-radius: 22px;
  text-align: center;
  opacity: var(--gift-card);
  transform: translateY(calc((1 - var(--gift-card)) * 10px));
  pointer-events: none;
  user-select: text;
}
.gift-card.shown { pointer-events: auto; }
.gift-card[hidden] { display: none; }
.gift-to { margin: 0; font: 400 21px/1.25 var(--display); letter-spacing: -.012em; overflow-wrap: anywhere; text-wrap: balance; }
.gift-for { color: var(--g-muted); }
.gift-name { color: var(--g-text); font-weight: 600; }
.gift-msg { color: var(--g-text-2); font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.gift-msg p { margin: 0; text-wrap: pretty; }
.gift-msg .gift-gap { height: .55em; }
.gift-from { margin: 2px 0 0; color: var(--g-muted); font-size: 13.5px; overflow-wrap: anywhere; }

.gift-actions {
  display: flex;
  gap: 4px;
  padding: 5px;
  border-radius: 24px;
  opacity: var(--gift-actions);
  transform: translateY(calc((1 - var(--gift-actions)) * 6px));
  pointer-events: auto;
}
.gift-view .btn { height: 36px; padding: 0 15px 0 13px; border-radius: 18px; background: var(--g-btn); color: var(--g-text); }
.gift-view .btn svg { width: 16px; height: 16px; }
.gift-actions .btn:not(.primary) { background: transparent; }
.gift-view .btn:not(.primary):hover { background: var(--g-btn); }
.gift-view .btn.primary { background: var(--g-primary); color: var(--g-primary-text); }
.gift-view .btn.primary:hover { background: var(--g-primary-hover); }
.gift-view :focus-visible { box-shadow: var(--g-focus); }

/* Preview only: a quiet bar at the top that leads back to the editor. */
.gift-bar {
  position: absolute;
  top: max(var(--m), env(safe-area-inset-top, 0px));
  left: 50%;
  translate: -50% 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 5px 5px 16px;
  border-radius: 24px;
  white-space: nowrap;
  pointer-events: auto;
  animation: gift-pop-in .2s ease;
}
.gift-bar[hidden] { display: none; }
.gift-bar-label { color: var(--g-text-2); font-size: 12.5px; }
.gift-bar .btn { height: 34px; padding: 0 14px; border-radius: 17px; }

/* ── phones ──────────────────────────────────────────────────────────────── */
@media (max-width: 720px), (max-width: 900px) and (orientation: portrait) {
  .gift-pop, .export-pop { width: calc(100vw - 2 * var(--m)); }
  /* Below 16px, iOS zooms the page when a field is focused. */
  .gift-input { font-size: 16px; }
  .gift-textarea { min-height: 100px; }
  .gift-stack { gap: 8px; }
  .gift-card { gap: 7px; padding: 15px 22px 14px; border-radius: 20px; }
  .gift-to { font-size: 19px; }
  .gift-msg { font-size: 14.5px; line-height: 1.48; }
  .gift-from { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .gift-card, .gift-actions { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .gift-pop, .export-pop { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(22, 21, 26, .96); }
  .gift-card, .gift-actions, .gift-bar { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--g-solid); }
}
