/*
 * "Phone with a conversation" (js/smsPhonePreview.js): a smartphone that shows how an SMS reaches the subscriber.
 * Shared by the SendSMS cabinet and the public site sendsms.to (copied into the site build). Prefix "smsph-": touches nothing else.
 * Every size inside the phone is in cqw of .smsph-wrap, so the phone keeps the proportions of a real smartphone (screen 19.5:9) at any width.
 * The screen uses the colours of a real phone (light or dark mode, data-screen); only the caption under the phone follows the page tokens.
 */
.smsph { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; min-width: 0;
  --smsph-bg: #fff; --smsph-text: #000; --smsph-muted: #8e8e93; --smsph-bar: rgba(248, 248, 250, .94); --smsph-line: rgba(60, 60, 67, .16);
  --smsph-in: #e9e9eb; --smsph-in-text: #000; --smsph-link-in: #0a60d6; --smsph-out: #34c759; --smsph-out-text: #fff;
  --smsph-field-line: #d1d1d6; --smsph-field-text: #a3a3a8; --smsph-plus: #e9e9eb; --smsph-home: #000; --smsph-back: #007aff; --smsph-av: linear-gradient(180deg, #a5abb6, #858b96); }
.smsph[data-reply="blue"] { --smsph-out: #0a84ff; }
.smsph[data-screen="dark"] {
  --smsph-bg: #000; --smsph-text: #fff; --smsph-muted: #8d8d93; --smsph-bar: rgba(22, 22, 24, .94); --smsph-line: rgba(84, 84, 88, .55);
  --smsph-in: #26252a; --smsph-in-text: #fff; --smsph-link-in: #5aa8ff; --smsph-field-line: #3a3a3c; --smsph-field-text: #6b6b70; --smsph-plus: #26252a; --smsph-home: #fff; --smsph-back: #0a84ff;
  --smsph-av: linear-gradient(180deg, #6e737c, #50555d); }
:root[data-theme="dark"] .smsph[data-screen="auto"], body.dark .smsph[data-screen="auto"] {
  --smsph-bg: #000; --smsph-text: #fff; --smsph-muted: #8d8d93; --smsph-bar: rgba(22, 22, 24, .94); --smsph-line: rgba(84, 84, 88, .55);
  --smsph-in: #26252a; --smsph-in-text: #fff; --smsph-link-in: #5aa8ff; --smsph-field-line: #3a3a3c; --smsph-field-text: #6b6b70; --smsph-plus: #26252a; --smsph-home: #fff; --smsph-back: #0a84ff;
  --smsph-av: linear-gradient(180deg, #6e737c, #50555d); }

.smsph-wrap { container-type: inline-size; width: var(--smsph-w, 280px); max-width: 100%; }
.smsph-wrap *, .smsph-wrap *::before, .smsph-wrap *::after { box-sizing: border-box; }
/* titanium frame, black bezel, screen: proportions of a 6.1" phone (71.6 x 147.6 mm) */
.smsph-device { position: relative; margin-inline: 1.3cqw; aspect-ratio: 71.6 / 147.6; border-radius: 13.6cqw; padding: 1.05cqw;
  background: linear-gradient(145deg, #c9ccd1 0%, #8e9196 18%, #5b5e63 40%, #9a9da2 62%, #4a4d52 82%, #b4b7bc 100%);
  box-shadow: 0 1.5cqw 6cqw rgba(16, 24, 40, .18), 0 .4cqw 1.2cqw rgba(16, 24, 40, .12); }
:root[data-theme="dark"] .smsph-device, body.dark .smsph-device { background: linear-gradient(145deg, #8f9297 0%, #55585d 16%, #2f3135 38%, #5f6267 60%, #26282c 80%, #7d8085 100%);
  box-shadow: 0 1.5cqw 6cqw rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 255, 255, .06); }
.smsph-key { position: absolute; width: 1.15cqw; border-radius: .7cqw; background: linear-gradient(90deg, #6b6e73, #c9ccd1 45%, #75787d); }
.smsph-k1 { left: -.95cqw; top: 18.5%; height: 6%; } .smsph-k2 { left: -.95cqw; top: 27.5%; height: 9.5%; }
.smsph-k3 { left: -.95cqw; top: 39.5%; height: 9.5%; } .smsph-k4 { right: -.95cqw; top: 30%; height: 14%; }
.smsph-bezel { height: 100%; border-radius: 12.55cqw; padding: 2.4cqw; background: #050506; box-shadow: inset 0 0 0 .2cqw #1c1d20; }
.smsph-screen { position: relative; height: 100%; border-radius: 10.2cqw; overflow: hidden; background: var(--smsph-bg); color: var(--smsph-text);
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; text-align: left;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
.smsph-screen::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 8;
  background: linear-gradient(125deg, rgba(255, 255, 255, .14) 0%, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0) 74%, rgba(255, 255, 255, .05) 100%); }

/* status bar: 9:41, the island, signal, Wi-Fi, battery */
.smsph-status { height: 12.6cqw; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 5.2cqw 0 6cqw; font-size: 4cqw; font-weight: 600; letter-spacing: -.01em; background: var(--smsph-bar); }
.smsph-clock { justify-self: center; font-variant-numeric: tabular-nums; }
.smsph-island { width: 29cqw; height: 8.4cqw; border-radius: 99px; background: #000; }
.smsph-icons { justify-self: center; display: inline-flex; align-items: center; gap: 1.3cqw; }
.smsph-icons svg { display: block; height: 2.9cqw; fill: currentColor; }
.smsph-sig { width: 4.3cqw; } .smsph-wifi { width: 4cqw; } .smsph-bat { width: 6.2cqw; }

/* header: back arrow, avatar, sender name */
.smsph-head { display: grid; grid-template-columns: 11cqw minmax(0, 1fr) 11cqw; align-items: start; padding: .4cqw 3cqw 2.4cqw; background: var(--smsph-bar); border-bottom: 1px solid var(--smsph-line); position: relative; z-index: 2; }
.smsph-back { color: var(--smsph-back); padding: 3.8cqw 0 0 1.4cqw; } .smsph-back svg { display: block; width: 2.7cqw; height: 4.8cqw; }
.smsph-who { display: flex; flex-direction: column; align-items: center; gap: 1.1cqw; min-width: 0; }
.smsph-av { width: 12.4cqw; height: 12.4cqw; border-radius: 50%; display: grid; place-items: center; background: var(--smsph-av); color: #fff; font-size: 4.8cqw; font-weight: 600; letter-spacing: .02em; line-height: 1; }
.smsph-av svg { width: 7.4cqw; height: 7.4cqw; fill: #fff; margin-top: 1.4cqw; }
.smsph-name { display: inline-flex; align-items: center; gap: .9cqw; max-width: 100%; font-size: 3.2cqw; line-height: 1.2; color: var(--smsph-text); }
.smsph-name-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.smsph-name svg { flex: none; width: 1.6cqw; height: 2.6cqw; color: #b0b0b6; }

/* conversation: starts at the top; a long one shows its last messages, like a phone scrolled to the end */
.smsph-feed { min-height: 0; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; }
.smsph-thread { flex: none; min-height: 100%; display: flex; flex-direction: column; padding: 2.4cqw 4.4cqw 3cqw; }
.smsph-stamp { text-align: center; color: var(--smsph-muted); font-size: 2.9cqw; line-height: 1.3; margin: 1cqw 0 3.2cqw; }
.smsph-stamp b { font-weight: 600; }
.smsph-row { position: relative; display: flex; margin-top: .6cqw; }
.smsph-row.smsph-first { margin-top: 2.6cqw; }
.smsph-stamp + .smsph-row { margin-top: 0; }
.smsph-out { justify-content: flex-end; }
.smsph-b { position: relative; z-index: 0; max-width: 76%; padding: 1.9cqw 3.3cqw 2cqw; border-radius: 4.8cqw; font-size: 4.25cqw; line-height: 1.3; letter-spacing: -.005em;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal; }
.smsph-in .smsph-b { margin-left: 1.6cqw; background: var(--smsph-in); color: var(--smsph-in-text); }
.smsph-out .smsph-b { margin-right: 1.6cqw; background: var(--smsph-out); color: var(--smsph-out-text); }
.smsph-b.smsph-empty { color: var(--smsph-muted); font-style: italic; }
/* the tail of the last bubble of a group */
.smsph-last .smsph-b::before, .smsph-last .smsph-b::after { content: ""; position: absolute; bottom: 0; height: 4.6cqw; z-index: -1; }
.smsph-in.smsph-last .smsph-b::before { left: -1.9cqw; width: 5.2cqw; background: var(--smsph-in); border-bottom-right-radius: 4.2cqw 3.8cqw; }
.smsph-in.smsph-last .smsph-b::after { left: -6.6cqw; width: 6.6cqw; background: var(--smsph-bg); border-bottom-right-radius: 2.6cqw; }
.smsph-out.smsph-last .smsph-b::before { right: -1.9cqw; width: 5.2cqw; background: var(--smsph-out); border-bottom-left-radius: 4.2cqw 3.8cqw; }
.smsph-out.smsph-last .smsph-b::after { right: -6.6cqw; width: 6.6cqw; background: var(--smsph-bg); border-bottom-left-radius: 2.6cqw; }
.smsph-delivered { align-self: flex-end; margin: .8cqw 2.4cqw 0 0; font-size: 2.9cqw; line-height: 1.2; color: var(--smsph-muted); }
.smsph-link { color: var(--smsph-link-in); text-decoration: underline; text-decoration-thickness: .2cqw; text-underline-offset: .5cqw; }
.smsph-out .smsph-link { color: inherit; }

/* "typing…": three dots in a bubble, shown only while the appearance plays */
.smsph-typing { position: absolute; left: 1.6cqw; top: 0; display: inline-flex; gap: 1cqw; padding: 3cqw 3.6cqw; border-radius: 4.8cqw; background: var(--smsph-in); opacity: 0; visibility: hidden; }
.smsph-typing i { width: 1.9cqw; height: 1.9cqw; border-radius: 50%; background: var(--smsph-muted); }

/* compose field and the home indicator */
.smsph-compose { display: flex; align-items: center; gap: 2cqw; padding: 1.8cqw 3.2cqw 7.6cqw; background: var(--smsph-bg); }
.smsph-plus { flex: none; width: 8.6cqw; height: 8.6cqw; border-radius: 50%; background: var(--smsph-plus); color: var(--smsph-muted); display: grid; place-items: center; font-size: 6.2cqw; font-weight: 300; line-height: 1; }
.smsph-field { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 2cqw; min-height: 8.6cqw; padding: 0 2.6cqw 0 3.4cqw; border: 1px solid var(--smsph-field-line); border-radius: 99px;
  font-size: 3.9cqw; color: var(--smsph-field-text); white-space: nowrap; overflow: hidden; }
.smsph-mic svg { display: block; width: 2.6cqw; height: 3.8cqw; fill: currentColor; }
.smsph-homebar { position: absolute; left: 50%; bottom: 2cqw; width: 34cqw; height: 1.3cqw; border-radius: 99px; background: var(--smsph-home); transform: translateX(-50%); z-index: 7; }

/* cropped phone (default): the visible part follows the conversation - frame, island, header, messages and ~1–2 lines of screen
   below the last one; the bottom of the phone goes past the edge (clipped). A long conversation is capped at the height of the whole
   screen and shows its last messages. 'fade' softens the cut, 'edge' is a clean cut for a card edge. */
.smsph:not([data-crop="off"]) .smsph-wrap { overflow: hidden; }
.smsph[data-crop="fade"] .smsph-device { -webkit-mask-image: linear-gradient(#000 calc(100% - 33cqw), transparent calc(100% - 27.5cqw)); mask-image: linear-gradient(#000 calc(100% - 33cqw), transparent calc(100% - 27.5cqw)); }
.smsph:not([data-crop="off"]) .smsph-device { aspect-ratio: auto; margin-top: 1cqw; margin-bottom: -27.5cqw; }
/* cqw resolve inside .smsph-wrap only (on the wrap itself they would mean the page), so the fade sits on the device, ending at the cut */
.smsph:not([data-crop="off"]) .smsph-bezel, .smsph:not([data-crop="off"]) .smsph-screen { height: auto; }
.smsph:not([data-crop="off"]) .smsph-screen { grid-template-rows: auto auto auto; padding-bottom: 35cqw; }
.smsph:not([data-crop="off"]) .smsph-feed { max-height: 140cqw; }
.smsph:not([data-crop="off"]) .smsph-thread { min-height: 0; }
.smsph:not([data-crop="off"]) .smsph-compose, .smsph:not([data-crop="off"]) .smsph-homebar { display: none; }

/* caption under the phone (page colours) */
.smsph-cap { display: flex; flex-direction: column; align-items: center; gap: 2px; max-width: var(--smsph-w, 280px); font-size: 13px; line-height: 1.4; text-align: center; color: var(--text-secondary, var(--muted, #5b6478)); }
.smsph-cap[hidden] { display: none; }
.smsph-count { font-variant-numeric: tabular-nums; }
.smsph-note { font-size: 12px; color: var(--text-tertiary, var(--muted, #7b8497)); }

/* armed (JS, before the phone is in view): the phone and the messages wait for their turn */
.smsph.is-armed:not(.is-play) .smsph-device { opacity: 0; transform: translateY(26cqw); }
.smsph.is-armed:not(.is-play) .smsph-b, .smsph.is-armed:not(.is-play) .smsph-delivered { opacity: 0; }

/* appearance: messages one by one, "typing…" before a company message (only while .is-play; never with reduced motion) */
@media (prefers-reduced-motion: no-preference) {
  .smsph.is-play .smsph-device { animation: smsph-rise .8s cubic-bezier(.2, .8, .2, 1) both; }
  .smsph.is-play .smsph-b { animation: smsph-pop .45s cubic-bezier(.2, .9, .3, 1.12) both; animation-delay: var(--smsph-d, 0ms); }
  .smsph.is-play .smsph-in .smsph-b { transform-origin: 0 100%; }
  .smsph.is-play .smsph-out .smsph-b { transform-origin: 100% 100%; }
  .smsph.is-play .smsph-delivered { animation: smsph-fade .35s ease-out both; animation-delay: var(--smsph-d, 0ms); }
  .smsph.is-play .smsph-typing { animation: smsph-typing var(--smsph-tl, 850ms) linear both; animation-delay: var(--smsph-t, 0ms); }
  .smsph.is-play .smsph-typing i { animation: smsph-dot 1s ease-in-out infinite; }
  .smsph.is-play .smsph-typing i:nth-child(2) { animation-delay: .16s; }
  .smsph.is-play .smsph-typing i:nth-child(3) { animation-delay: .32s; }
}
@keyframes smsph-rise { from { opacity: 0; transform: translateY(26cqw); } to { opacity: 1; transform: none; } }
@keyframes smsph-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes smsph-pop { from { opacity: 0; transform: translateY(2.4cqw) scale(.86); } 70% { opacity: 1; } to { opacity: 1; transform: none; } }
@keyframes smsph-typing { 0% { opacity: 0; visibility: visible; transform: scale(.8); } 12% { opacity: 1; transform: none; } 88% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }
@keyframes smsph-dot { 0%, 60%, 100% { opacity: .35; transform: none; } 30% { opacity: 1; transform: translateY(-.7cqw); } }
