/* 05 / CSV to campaign: a client export is dropped into a zone, checked for consent and duplicates,
   and split into three segments; the first message for a segment is previewed with its merge
   fields filled in. Every rule is scoped under #csv. */

/* ---------- Layout: drop zone (left, about 56%) and preview (right) ---------- */

#csv .ra-csv-in {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  align-items: start;
  column-gap: 28px;
  row-gap: 16px;
  padding: 28px;
}

#csv .ra-csv-drop,
#csv .ra-csv-prev {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

#csv .ra-csv-head,
#csv .ra-csv-prev-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 12px;
  min-height: 28px;
}

#csv .ra-csv-hr {
  margin-left: auto;
  text-align: right;
}

/* ---------- Drop zone ---------- */

#csv .ra-csv-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 400px;
  padding: 16px;
  border: 1.5px dashed var(--line);
  border-radius: var(--r-lg);
  transition: border-color 0.4s var(--ease-std), background-color 0.4s var(--ease-std);
}

#csv .ra-csv-zone.is-over {
  border-color: var(--accent);
  background-color: rgb(255 255 255 / 0.04);
}

#csv .ra-csv-hint {
  position: absolute;
  inset: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  pointer-events: none;
  transition: opacity 0.4s var(--ease-std);
}

#csv .ra-csv-hint.is-gone {
  opacity: 0;
}

#csv .ra-csv-hint > svg {
  width: 28px;
  height: 28px;
  color: var(--ash);
}

#csv .ra-csv-hint-t {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.4;
  color: var(--ash);
}

#csv .ra-csv-hint-m {
  font-size: 12px;
}

/* ---------- File row (03's source row anatomy) ---------- */

#csv .ra-csv-file {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  grid-template-areas: "ic main st";
  align-items: center;
  gap: 4px 14px;
  padding: 12px 14px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1), transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

#csv .ra-csv-file.is-enter {
  opacity: 0;
  transform: translate(-28px, -18px) scale(0.96);
}

#csv .ra-csv-ic {
  grid-area: ic;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--elev);
  color: var(--accent);
  transition: color 0.4s var(--ease-std);
}

#csv .ra-csv-svg {
  display: block;
  width: 18px;
  height: 18px;
}

#csv .ra-csv-tag {
  font-size: 9px;
  line-height: 1;
  letter-spacing: 0.02em;
}

#csv .ra-csv-main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

#csv .ra-csv-name {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.005em;
  color: var(--bone);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The source line wraps on phones instead of ending in an ellipsis */
#csv .ra-csv-meta {
  font-size: 12px;
  letter-spacing: 0.04em;
  white-space: normal;
  overflow-wrap: anywhere;
}

#csv .ra-csv-st {
  grid-area: st;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  line-height: 1.4;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ash);
  white-space: nowrap;
}

#csv .ra-csv-check {
  flex: none;
  width: 14px;
  height: 14px;
}

#csv .ra-csv-file.is-done .ra-csv-ic {
  color: var(--bone);
}

#csv .ra-csv-file.is-done .ra-csv-st {
  color: var(--ok);
}

/* 2px gold progress bar along the foot of the row while the file is checked */
#csv .ra-csv-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  pointer-events: none;
  transition: opacity 0.4s var(--ease-std);
}

#csv .ra-csv-bar i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
}

#csv .ra-csv-file.is-done .ra-csv-bar {
  opacity: 0;
}

/* ---------- Result line: three spans, 250 ms apart ---------- */

#csv .ra-csv-res {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  min-height: 34px;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--ash);
}

#csv .ra-csv-rp {
  color: var(--ash);
  opacity: 0;
  transition: opacity 0.25s var(--ease-std);
}

#csv .ra-csv-rp.is-first {
  color: var(--bone);
}

#csv .ra-csv-rp.is-on {
  opacity: 1;
}

#csv .ra-csv-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--danger);
  vertical-align: middle;
}

/* ---------- Segment rows (buttons) ---------- */

#csv .ra-csv-segs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#csv .ra-seg {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  align-items: center;
  gap: 4px 14px;
  width: 100%;
  min-height: 56px;
  margin: 0;
  padding: 12px 14px;
  text-align: left;
  font: inherit;
  color: var(--bone);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  cursor: default;
  transition: opacity 0.4s var(--ease-std), transform 0.4s var(--ease-std), border-color 0.2s, background-color 0.2s;
}

#csv .ra-seg.is-enter {
  opacity: 0;
  transform: translateY(8px);
}

#csv .ra-seg.is-ready {
  cursor: pointer;
}

#csv .ra-seg.is-ready:hover {
  border-color: rgb(255 255 255 / 0.4);
}

#csv .ra-seg[aria-pressed="true"] {
  border-color: rgb(255 255 255 / 0.55);
  background-color: rgb(255 255 255 / 0.05);
}

#csv .ra-seg:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#csv .ra-seg-key {
  justify-self: start;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11.5px;
  line-height: 1;
  letter-spacing: 0.1em;
  color: var(--ash);
  white-space: nowrap;
}

#csv .ra-seg-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

#csv .ra-seg-title {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.3;
  color: var(--bone);
}

#csv .ra-seg-meta {
  font-size: 12.5px;
  letter-spacing: 0.08em;
  color: var(--ash);
  overflow-wrap: anywhere;
}

#csv .ra-seg-track {
  grid-column: 1 / -1;
  position: relative;
  height: 2px;
  margin-top: 4px;
  background: var(--line);
  overflow: hidden;
}

#csv .ra-seg-track i {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: hsl(42 30% 94% / 0.3);
}

#csv .ra-seg[aria-pressed="true"] .ra-seg-track i {
  background: var(--accent);
}

/* ---------- Footer, once all three segments are in ---------- */

#csv .ra-csv-foot {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.5s var(--ease-soft), transform 0.5s var(--ease-soft);
}

#csv .ra-csv-foot.is-on {
  opacity: 1;
  transform: none;
}

#csv .ra-csv-foot-l {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--bone);
}

#csv .ra-csv-foot-r {
  white-space: nowrap;
  color: var(--ash);
}

/* ---------- Preview card ---------- */

#csv .ra-csv-in {
  align-items: stretch;
}

#csv .ra-csv-prev {
  min-width: 0;
}

#csv .ra-prev {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 300px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

#csv .ra-prev-ph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 18px;
  text-align: center;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ash);
  transition: opacity 0.3s var(--ease-std);
}

#csv .ra-prev.is-live .ra-prev-ph {
  opacity: 0;
  pointer-events: none;
}

#csv .ra-prev-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  opacity: 0;
  transition: opacity 0.3s var(--ease-std);
}

#csv .ra-prev.is-live .ra-prev-body {
  opacity: 1;
}

#csv .ra-prev.is-live .ra-prev-body.is-swap {
  opacity: 0;
}

#csv .ra-prev-client {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

#csv .ra-prev-av {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--elev);
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--bone);
}

#csv .ra-prev-who {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

#csv .ra-prev-name {
  font-family: var(--font-display);
  font-size: 16.5px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--bone);
}

#csv .ra-prev-cmeta {
  font-size: 12px;
  color: var(--ash);
  overflow-wrap: anywhere;
}

#csv .ra-prev-seg {
  align-self: flex-start;
  padding: 4px 8px;
  border: 1px solid rgb(255 255 255 / 0.5);
  border-radius: 999px;
  font-size: 11.5px;
  line-height: 1;
  color: var(--bone);
}

/* The iOS incoming bubble: the palette is defined on the bubble only */
#csv .ra-prev-bubble {
  --ios-bg: #000000;
  --ios-bar: #121214;
  --ios-in: #262629;
  --ios-out: #2fbf58;
  --ios-text: #f5f5f7;
  --ios-muted: #8e8e93;
  --ios-blue: #0a84ff;
  --ios-line: rgba(255, 255, 255, 0.1);
  --ios-field: #1c1c1e;
  --ks-brand: #b85c38;
  --ks-brand-2: #7f3b20;
  align-self: flex-start;
  max-width: 100%;
  margin: 0;
  padding: 10px 14px;
  background: var(--ios-in);
  color: var(--ios-text);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  border-radius: 18px 18px 18px 6px;
  overflow-wrap: anywhere;
}

#csv .ra-tok {
  display: inline;
  padding: 0 3px;
  border-radius: 4px;
  color: var(--ios-muted);
  background: rgba(255, 255, 255, 0.08);
  transition: color 0.3s var(--ease-std), background-color 0.3s var(--ease-std), box-shadow 0.3s var(--ease-std);
}

#csv .ra-tok.is-on {
  color: var(--ios-text);
  background: rgb(255 255 255 / 0.22);
  box-shadow: inset 0 -1px 0 var(--accent);
}

#csv .ra-prev-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#csv .ra-prev-chip {
  padding: 4px 6px;
  border: 1px solid var(--line);
  font-size: 11px;
  line-height: 1.3;
  letter-spacing: 0.08em;
  color: var(--ash);
  transition: border-color 0.3s var(--ease-std), color 0.3s var(--ease-std);
}

#csv .ra-prev-chip.is-on {
  border-color: rgb(255 255 255 / 0.55);
  color: var(--bone);
}

#csv .ra-prev-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 12px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

#csv .ra-prev-send {
  color: var(--ash);
}

#csv .ra-prev-consent {
  color: var(--info);
}

#csv .ra-prev-next {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 12px;
  color: var(--ash);
}

#csv .ra-prev-next svg {
  flex: none;
  width: 12px;
  height: 12px;
  color: var(--accent);
}

/* ---------- Replay: bottom right of the stage, hidden (but keeps its row) until the sequence ends ---------- */

#csv .ra-csv-replay {
  grid-column: 1 / -1;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  color: var(--bone);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

#csv .ra-csv-replay[hidden] {
  display: inline-flex;
  visibility: hidden;
  pointer-events: none;
}

#csv .ra-csv-replay:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#csv .ra-csv-replay:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#csv .ra-csv-replay svg {
  width: 14px;
  height: 14px;
}

/* Static and reduced motion: no Replay at all, so its row goes too */
#csv .ra-csv-in.is-final .ra-csv-replay {
  display: none;
}

/* Under the stage: centred on desktop, left-aligned below */

#csv .ra-csv-line {
  max-width: 44rem;
  margin: 24px 0 0;
  text-align: left;
}

#csv .sec-title .gold-i {
  display: inline-block;
}

/* ---------- Desktop: the zone is at least as tall as the drop area needs ---------- */

@media (min-width: 1024px) {
  #csv .ra-csv-line {
    margin: 24px auto 0;
    text-align: center;
  }
}

/* Wide enough for each result part on one line; narrower screens let the parts wrap inside */
@media (min-width: 521px) {
  #csv .ra-csv-rp {
    white-space: nowrap;
  }
}

/* ---------- One column below 1024px: drop zone, then preview ---------- */

@media (max-width: 1023px) {
  #csv .ra-csv-in {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 24px;
    padding: 18px;
  }

  #csv .ra-csv-zone {
    min-height: 320px;
  }
}

/* Phones: file status drops under the name; segment pill sits above its title */
@media (max-width: 520px) {
  #csv .ra-csv-zone {
    min-height: 280px;
    padding: 14px;
  }

  #csv .ra-csv-file {
    grid-template-columns: 36px minmax(0, 1fr);
    grid-template-areas:
      "ic main"
      "ic st";
    gap: 4px 12px;
  }

  #csv .ra-csv-st {
    justify-self: start;
    min-width: 0;
    white-space: normal;
    letter-spacing: 0.08em;
  }

  #csv .ra-seg {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  #csv .ra-seg-key {
    justify-self: start;
  }

  #csv .ra-prev {
    min-height: 240px;
    padding: 16px;
  }
}
