/*
 * WhatsApp link generator.
 *
 * Layer: per-tool. Prefix: .wal-  (see .claude/rules/css.md)
 * Load order: css/style.css -> css/components/tool-shell.css -> this file
 *
 * The form controls themselves are shared (.tool-form, .tool-input, ...);
 * this file only lays out what is particular to this tool: the country and
 * number side by side, and the result card.
 */

/* --- country + number --------------------------------------------------- */

/* Two fields that read as one answer. The country column is capped so the
   number gets the room; minmax(0, …) lets a long country name shrink rather
   than push the row wider than the form. */
.wal-phone-row {
  display: grid;
  grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
  gap: var(--space-3, 0.75rem);
  align-items: start;
}

/* `display: grid` outranks the UA's [hidden] rule. */
.wal-phone-row[hidden] {
  display: none;
}

/* The hint and error belong to the number but read better under both. */
.wal-phone-notes {
  grid-column: 1 / -1;
  display: grid;
  gap: var(--space-1, 0.25rem);
}

@media (max-width: 479px) {
  .wal-phone-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* --- message preview ---------------------------------------------------- */

/* A picture of the chat, so the message can be judged the way it will be
   read. It lives in the result card and is always shown: an empty chat when
   there is no message, so the first keystroke moves nothing.
   The colours are WhatsApp's own light theme; they are literals because none
   of them is a site token and none should follow one. */
.wal-preview {
  display: grid;
  gap: var(--space-2, 0.5rem);
}

.wal-preview-label {
  font-size: clamp(14px, 3.8vw, 15px);
  font-weight: 500;
  color: var(--text-light, #4A5568);
}

.wal-chat {
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: var(--border-radius, 8px);
}

.wal-chat-bar {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  font-size: 15px;
  font-weight: 500;
  color: #fff;
  background: #008069;
}

.wal-chat-avatar {
  flex: none;
  display: grid;
  place-items: end center;
  width: 32px;
  height: 32px;
  overflow: hidden;
  border-radius: 50%;
  background: #DFE5E7;
}

.wal-chat-avatar svg {
  width: 26px;
  height: 26px;
  fill: #fff;
}

.wal-chat-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* min-height holds room for a three-line message, so most messages grow the
   bubble inside the chat without growing the card. */
.wal-chat-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 10rem;
  padding: 0.625rem 1rem 0.875rem;
  background: #EFEAE2;
}

/* The date chip every chat opens with. It also keeps an empty chat looking
   like a chat, not like a missing image. */
.wal-chat-day {
  align-self: center;
  padding: 0.25rem 0.75rem;
  font-size: 12px;
  line-height: 1.4;
  color: #54656F;
  background: #fff;
  border-radius: 7.5px;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}

/* An outgoing message sits at the inline END: right on the English page,
   left on the Hebrew one, exactly as WhatsApp mirrors it. */
.wal-bubble {
  position: relative;
  min-width: 0;
  max-inline-size: 85%;
  align-self: flex-end;
  padding: 0.375rem 0.5625rem 0.25rem;
  font-size: 15px;
  line-height: 1.35;
  color: #111B21;
  background: #D9FDD3;
  border-radius: 7.5px;
  border-start-end-radius: 0;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}

/* The tail. A clipped box rather than the border trick, which would need
   physical left/right borders. */
.wal-bubble::after {
  content: '';
  position: absolute;
  inset-block-start: 0;
  inset-inline-end: -8px;
  width: 8px;
  height: 13px;
  background: inherit;
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

/* clip-path has no logical form, so the triangle is mirrored by hand. */
[dir="rtl"] .wal-bubble::after {
  clip-path: polygon(100% 0, 0 0, 100% 100%);
}

/* dir="auto" on the element decides the direction per message, so Hebrew
   reads right-to-left inside an English page and the reverse. */
.wal-bubble-text {
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-align: start;
}

.wal-bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.2rem;
  margin-block-start: 0.125rem;
  font-size: 11px;
  color: #667781;
}

.wal-bubble-ticks {
  width: 16px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- result ------------------------------------------------------------- */

.wal-result {
  display: grid;
  gap: var(--space-3, 0.75rem);
  max-inline-size: 40rem;
  margin-block: var(--space-4, 1rem) var(--space-5, 1.5rem);
  padding: clamp(1rem, 4vw, 1.5rem);
  background: var(--white-color, #fff);
  border: 1px solid rgba(0, 91, 149, 0.25);
  border-radius: var(--border-radius, 8px);
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.08));
}

.wal-result-title {
  font-size: clamp(18px, 4.6vw, 21px);
  line-height: 1.3;
  color: var(--secondary-color, #005B95);
}

/* A URL is always left-to-right, and a long ?text= must scroll inside the
   field rather than widen the page (body clips horizontal overflow). */
.wal-link {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: max(16px, 0.9375rem);
}

/* min-height reserves the line so the confirmation cannot shift the buttons. */
.wal-number {
  min-height: 1.6em;
  font-size: clamp(14px, 3.8vw, 15px);
  line-height: 1.6;
  color: var(--text-light, #4A5568);
}

.wal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2, 0.5rem);
}

/* --- about -------------------------------------------------------------- */

.wal-about p + p {
  margin-block-start: var(--space-3, 0.75rem);
}
