/* Product primitives shared by the web workspace and the recipient page: T024's map, sheet, history, facts and
   share controls, and T018's gift letter. Prefixed p- so they never collide with the landing's own classes. */

/* ---------- Progress: the extension's one device, an 8px bar and the caption under it ---------- */
.p-bar {
  display: block;
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--c-field);
  overflow: hidden;
}
.p-bar i {
  display: block;
  height: 100%;
  border-radius: var(--r-pill) 0 0 var(--r-pill);
  transition: width 0.32s var(--ease), background-color 0.32s var(--ease);
}
.p-bar i.full {
  border-radius: var(--r-pill);
}
.p-cap {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, auto);
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
  font-size: 10px;
  line-height: 16px;
  color: var(--c-muted);
}
.p-cap b {
  font-weight: 500;
  color: var(--c-ink);
  text-align: right;
}
.p-cap > * {
  min-width: 0;
  overflow-wrap: anywhere;
}
.p-cap > :only-child { grid-column: 1 / -1; }

/* ---------- Avatar: the parcel glyph or an emoji on the status colour ---------- */
.p-avatar {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--s-pending);
  position: relative;
}
.p-avatar .p-glyph {
  width: 30px;
  height: 30px;
}
.p-emoji {
  font-size: 26px;
  line-height: 1;
}
button.p-avatar::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: border-color 0.15s ease;
}
button.p-avatar:hover::after,
button.p-avatar[aria-expanded='true']::after {
  border-color: var(--c-action);
}

/* ---------- Map ---------- */
.p-map {
  position: relative;
  background: #e8eef4;
  overflow: hidden;
}
.p-map-canvas {
  position: absolute;
  inset: 0;
}
.p-map-svg {
  display: block;
  width: 100%;
  height: 100%;
}
.p-scanchip {
  position: absolute;
  left: 16px;
  top: 16px;
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  background: var(--c-surface);
  font-size: 13px;
  line-height: 20px;
  box-shadow: 0 4px 14px rgba(16, 26, 34, 0.16);
}
.p-scanchip i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--s-out);
}
.p-scanchip.is-empty i {
  background: var(--s-pending);
}
.p-askdest {
  position: absolute;
  right: 16px;
  bottom: 36px;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  background: var(--c-action);
  color: var(--c-on-action);
  font: 500 13px/20px var(--font);
  box-shadow: 0 4px 14px rgba(16, 26, 34, 0.18);
}
.p-askdest:hover {
  background: var(--c-action-active);
}
/* No resolved places yet: an honest empty map, not the demonstration basemap. */
.p-map-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(60% 70% at 50% 45%, #f4f8fb 0, transparent 70%),
    repeating-linear-gradient(135deg, #e3eaf1 0 1px, transparent 1px 18px),
    #e8eef4;
}
.p-map-empty span {
  font-size: 13px;
  color: var(--c-muted);
  background: var(--c-surface);
  padding: 7px 14px;
  border-radius: var(--r-pill);
  box-shadow: 0 4px 14px rgba(16, 26, 34, 0.1);
}
/* Apple's map in its frame on the map-only origin (map.js). While it loads, the bare map ground; once drawn, the
   frame; if it fails or stays silent, the unavailable state above. */
.p-map-frame {
  position: absolute;
  inset: 0;
}
.p-map-iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.p-map-frame[data-state='drawn'] .p-map-iframe {
  opacity: 1;
}
.p-map-frame:not([data-state='failed']) .p-map-empty {
  display: none;
}

/* ---------- The detail sheet: it overlaps the map, as in T024 ---------- */
.p-sheet {
  position: relative;
  z-index: 1;
  background: var(--c-surface);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -6px 24px rgba(16, 26, 34, 0.1);
  padding: 14px 0 20px;
}
.p-head {
  position: relative;
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
}
.p-head > .p-title-row {
  flex: 1;
  min-width: 0;
}
.p-title-row {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-radius: var(--r-field);
  background: var(--c-field);
  cursor: text;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.p-title-row:hover {
  background: var(--c-field-focus);
}
.p-title-row:focus-within {
  background: var(--c-field-focus);
  box-shadow: inset 0 0 0 2px var(--c-action);
}
.p-title-edit {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  padding: 0;
  font: 700 18px/24px var(--font);
  color: var(--c-ink);
  text-transform: uppercase;
  letter-spacing: 0.2px;
}
.p-title-edit::placeholder {
  color: var(--c-muted);
  text-transform: none;
  font-weight: 400;
  letter-spacing: 0;
}
.p-title-edit:focus {
  outline: 0;
}
.p-icon-pop {
  position: absolute;
  left: 20px;
  top: 76px;
  z-index: 3;
  display: flex;
  gap: 8px;
  padding: 8px;
  background: var(--c-surface);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(16, 26, 34, 0.18), 0 0 0 1px rgba(52, 58, 64, 0.06);
}
.p-icon-pop button,
.p-icons button {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 2px solid transparent;
  background: var(--c-field);
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
}
.p-icon-pop button[aria-checked='true'],
.p-icons input:checked + span {
  background: #d9f6f7;
  border-color: var(--s-out);
}
.p-icon-pop .p-glyph,
.p-icons .p-glyph {
  width: 22px;
  height: 22px;
}
.p-progress {
  padding: 0 20px;
}
.p-rule {
  height: 1px;
  background: var(--c-separator);
  margin: 16px 20px 0;
}
.p-hist {
  width: 100%;
  text-align: left;
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.p-hist:hover {
  background: #f7f9fc;
}
.p-hist-main {
  flex: 1;
}
.p-hist-main b {
  display: block;
  font-weight: 500;
}
.p-hist-main small {
  color: var(--c-muted);
  font-size: 13px;
}
.p-chev {
  flex: none;
  color: var(--c-muted);
  transition: transform 0.28s var(--ease);
}
.p-hist[aria-expanded='true'] .p-chev {
  transform: rotate(180deg);
}
.p-events {
  overflow: hidden;
  transition: height 0.3s var(--ease);
}
.p-events ol {
  list-style: none;
  margin: 0;
  padding: 0 20px 8px;
}
.p-events li {
  display: flex;
  gap: 16px;
  padding-bottom: 18px;
  position: relative;
}
.p-events li::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 16px;
  bottom: 0;
  width: 1px;
  background: var(--hair);
}
.p-events li:last-child::before {
  display: none;
}
.p-events i {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-top: 6px;
  position: relative;
  z-index: 1;
}
.p-events b {
  display: block;
  font-weight: 400;
}
.p-events small {
  display: block;
  color: var(--c-muted);
  font-size: 12px;
}
.p-events-empty {
  padding: 0 20px 12px;
  color: var(--c-muted);
}
.p-facts {
  padding: 16px 20px 0;
}
.p-fact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  min-height: 44px;
}
.p-fact dt {
  color: var(--c-muted);
  flex: none;
}
.p-fact dd {
  text-align: right;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.p-mini {
  background: var(--c-field);
  border-radius: 8px;
  font: 500 12px/16px var(--font);
  color: var(--c-action);
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
}
.p-mini:hover {
  background: var(--c-field-focus);
}
.p-mini.done {
  color: #2e9e45;
}
.p-mini.carrier {
  color: var(--c-link);
}
.p-dest-edit {
  border: 0;
  background: none;
  padding: 6px 8px;
  margin-right: -8px;
  font: inherit;
  color: var(--c-ink);
  text-align: right;
  border-radius: 6px;
  width: 170px;
  min-height: 36px;
}
.p-dest-edit:hover {
  background: var(--c-field);
}
.p-dest-edit:focus {
  outline: 0;
  background: var(--c-field-focus);
}
.p-dest-edit::placeholder {
  color: var(--c-action);
}
.p-linkrow {
  width: 100%;
  text-align: left;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.p-linkrow:hover {
  background: #f7f9fc;
}
.p-linkrow > span:first-child {
  flex: 1;
}
.p-linkrow b {
  display: block;
  color: var(--c-action);
  font-weight: 500;
}
.p-linkrow small {
  color: var(--c-muted);
  font-size: 12px;
}
.p-danger {
  display: block;
  width: calc(100% - 40px);
  margin: 24px 20px 0;
  padding: 13px;
  border-radius: var(--r-pill);
  border: 1px solid rgba(195, 23, 4, 0.3);
  color: var(--c-danger);
  font: 500 14px/20px var(--font);
}
.p-danger:hover {
  background: rgba(195, 23, 4, 0.05);
}

/* ---------- Switches: T024's sharing controls ---------- */
.p-toggle {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--c-separator);
}
.p-toggle > span:first-child {
  flex: 1;
}
.p-toggle b {
  display: block;
  font-weight: 400;
}
.p-toggle small {
  display: block;
  color: var(--c-muted);
  font-size: 12px;
  line-height: 18px;
}
.p-switch {
  flex: none;
  width: 46px;
  height: 28px;
  border-radius: var(--r-pill);
  background: #d8dee6;
  position: relative;
  transition: background 0.2s ease;
}
.p-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.22s var(--ease);
}
.p-switch[aria-checked='true'] {
  background: var(--s-delivered);
}
.p-switch[aria-checked='true']::after {
  transform: translateX(18px);
}

/* ---------- The recipient's postcard (T071: Figma 98:1527 without a map, 98:1641 with one) ----------
   One card in one column, as wide as its page allows up to 560px: 20px corners and padding, the soft blue-gray
   shadow, its height its content's. The state's colour (data-state) fills the artwork and the progress. */
.p-card {
  --state: var(--s-transit);
  /* Small text reads at 4.5:1 or more on white (Codex, PR #43 comment 6079121890), a deliberate difference from Figma's
     lighter greens and grays (4.10 down to 2.30). The state palette stays for the artwork and the progress. */
  --card-quiet: #66786e;
  --card-muted: #6e7488;
  --card-arrow: #607a6d;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 20px 18px;
  background: var(--c-surface);
  border-radius: 20px;
  box-shadow: 0 18px 50px rgba(48, 74, 109, 0.12);
  overflow: hidden;
  text-align: center;
  color: var(--c-ink);
}
.p-card[data-state='pending'] {
  --state: var(--s-pending);
}
.p-card[data-state='out'] {
  --state: var(--s-out);
}
.p-card[data-state='late'] {
  --state: var(--s-problem);
}
.p-card[data-state='delivered'] {
  --state: var(--s-delivered);
}

/* A shared route's map is the card's top, flush with its edges; the card's corners round it. */
.p-card-map {
  position: relative;
  margin: -20px -20px 18px;
  height: 280px;
  background: #e8eef4;
  overflow: hidden;
}
.p-card.is-compact .p-card-map {
  height: 180px;
}
.p-card-map > .p-map-canvas {
  position: absolute;
  inset: 0;
}
/* While the map loads, and when it can't draw, the chosen artwork stays in view on the map ground. */
.p-card-map-art {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.p-card-map:has(.p-map-frame[data-state='drawn']) .p-card-map-art {
  display: none;
}
.p-card-map .p-map-empty {
  align-items: end;
  padding-bottom: 18px;
}

/* The artwork: 72px on the state's colour; an emoji keeps its colours, the parcel glyph is light. */
.p-card-art,
.p-card-map-art {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--state);
  display: grid;
  place-items: center;
}
.p-card-art {
  margin: 18px auto 0;
}
.p-card-art .p-emoji,
.p-card-map-art .p-emoji {
  font-size: 38px;
}
.p-card-art .p-glyph,
.p-card-map-art .p-glyph {
  width: 44px;
  height: 44px;
}
.p-card-demo {
  align-self: center;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  background: var(--demo-ground);
  color: var(--demo-ink);
  font: 500 11px/16px var(--font);
}

/* From, then the title: 14px above, 6px between (Figma's personal heading). */
.p-card-heading {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 14px;
}
.p-card-heading > :only-child {
  margin-top: 6px;
}
.p-card-from {
  font: 400 14px/18px var(--font);
  color: var(--card-muted);
  overflow-wrap: anywhere;
}
.p-card-title {
  font: 700 26px/29.38px var(--font);
  letter-spacing: -1.04px;
  color: var(--ink);
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.p-card-bar {
  margin-top: 20px;
  background: var(--c-field-focus);
}
.p-card-bar i {
  background: var(--state);
}
.p-card-status {
  /* Natural widths when they fit; balanced columns when crowded, preserving a short side's full width. */
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, auto);
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-top: 10px;
  font: 400 0.875rem/1.285714 var(--font);
  color: var(--card-quiet);
  text-align: left;
}
.p-card-status b {
  font-weight: 500;
  color: #365c4e;
  text-align: right;
}
.p-card-status > * {
  min-width: 0;
  overflow-wrap: anywhere;
}
.p-card-status > :only-child { grid-column: 1 / -1; }
.p-card-quiet {
  margin-top: 8px;
  font: 400 13px/18px var(--font);
  color: var(--card-muted);
  text-align: left;
}

/* Each later part sits under a hairline: the shared facts, the note, the sign-off. */
.p-card-facts,
.p-card-note,
.p-card-identity,
.p-card-foot {
  margin-top: 22px;
  border-top: 1px solid #e5eee9;
}
.p-card-facts {
  display: grid;
  gap: 14px;
  padding-top: 18px;
}
.p-card-route {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 12px;
  font: 500 16px/20px var(--font);
}
.p-card-route span {
  min-width: 0;
  overflow-wrap: anywhere;
}
.p-card-route i {
  font-style: normal;
  font-weight: 400;
  color: var(--card-arrow);
}
.p-card-route small {
  width: 100%;
  font: 400 13px/18px var(--font);
  color: var(--card-quiet);
  margin-top: 4px;
}
.p-card-identity {
  display: grid;
  justify-items: center;
  padding-top: 18px;
  gap: 4px;
}
.p-card-number-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 10px;
}
.p-card-carrier {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  font: 400 13px/18px var(--font);
  color: var(--c-action);
  text-decoration: none;
}
.p-card-carrier:hover { text-decoration: underline; }
.p-card-carrier span { font-size: 12px; }
.p-card-number {
  font: 400 13px/18px var(--font);
  color: var(--card-quiet);
  overflow-wrap: anywhere;
}
.p-card-digits {
  user-select: all;
}
/* Copy: a small pill whose touch area reaches 44px (brief: no clipped copy targets). */
.p-copy {
  position: relative;
  padding: 3px 12px;
  border-radius: var(--r-pill);
  background: var(--c-action);
  color: var(--c-on-action);
  font: 500 12px/18px var(--font);
}
.p-copy::after {
  content: '';
  position: absolute;
  inset: -10px -6px;
}
.p-copy:hover {
  background: var(--c-action-active);
}
.p-card-history {
  list-style: none;
  margin: 0;
  padding: 0;
  text-align: left;
}
.p-card-history li {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  position: relative;
  padding-bottom: 14px;
  font-size: 13px;
}
.p-card-history li:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 8px;
  bottom: -8px;
  width: 1px;
  background: #dce8e1;
}
.p-card-history li > i {
  position: relative;
  z-index: 1;
  background: #a7cbb9;
  border-radius: 50%;
  width: 7px;
  height: 7px;
  flex: none;
  margin-top: 7px;
}
.p-card-history small {
  display: block;
  font-size: 11px;
  color: var(--card-quiet);
  line-height: 1.5;
  margin-top: 2px;
}
.p-card-history li:last-child {
  padding-bottom: 0;
}
/* The note as the sender wrote it: their line breaks, no quotation marks they didn't type. */
.p-card-note {
  padding-top: 20px;
  font: 400 16px/25.6px var(--font);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
/* The editor's compact summary clamps a long note; Open full preview shows all of it. */
.p-card.is-compact .p-card-note {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
}
.p-card-foot {
  display: grid;
  gap: 6px;
  padding-top: 16px;
}
.p-card-signoff {
  font: 400 12px/15px var(--font);
  color: var(--card-quiet);
}
.p-card-expiry {
  font: 400 11px/14px var(--font);
  color: var(--card-quiet);
}

/* A slow or interrupted MapKit load can be retried without losing the gift draft. */
.p-map-retry { position:absolute; top:12px; right:12px; z-index:2; padding:10px 14px; border:0; border-radius:20px; background:#fff; color:#2365d6; font:inherit; font-size:14px; cursor:pointer; box-shadow:0 2px 8px #0001; }
.p-map-retry:focus-visible { outline:3px solid #2365d6; outline-offset:2px; }

/* A current delivery issue changes only the existing status treatment, never the card composition. */
.p-card.has-delivery-issue .p-card-state { color: var(--s-problem); }
