/* comprajá.pt — the category standard, at App Store / Revolut craft.
   Soft green-white ground, soft colour fields, white rounded cards with layered shadows,
   one brand gradient for the logo and the primary actions. */

@import url("/static/tokens.css?v=compraja-green-v1");

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; overflow-x: clip; scrollbar-color: #bdcec3 var(--ground); }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ground);
  color: var(--ink);
  font: 500 1rem/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  caret-color: var(--brand-a);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 var(--gutter) calc(var(--composer-h) + 66px + env(safe-area-inset-bottom));
}

::selection { background: rgb(0 155 104 / 0.18); }
:focus-visible { outline: 3px solid var(--brand-ink); outline-offset: 3px; border-radius: var(--r-md); }
a { color: inherit; text-underline-offset: 0.2em; }
svg { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Soft colour fields behind everything: the only large gradients on the page. */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(42rem 30rem at 10% -8%, rgb(0 155 104 / 0.16), transparent 70%),
    radial-gradient(36rem 28rem at 108% 10%, rgb(79 181 143 / 0.16), transparent 70%),
    radial-gradient(40rem 26rem at 50% 118%, rgb(131 185 146 / 0.14), transparent 70%);
}

/* ---- Brand ------------------------------------------------------------ */

.masthead { width: 100%; max-width: 44rem; }

.brand {
  view-transition-name: brand;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  border-radius: var(--r-lg);
}

.brand__logo { display: block; width: 210px; max-width: 100%; height: auto; }

.masthead__promise { margin: 0; color: var(--ink-2); font-size: 1.05rem; }

/* Home: the brand sits in the middle of the screen. */
.is-home { justify-content: center; }
.is-home .masthead { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; }
.is-home .brand { flex-direction: column; gap: 18px; }
.is-home .brand { width: min(420px, 100%); }
.is-home .brand__logo { width: 100%; }
.is-home .masthead__promise { max-width: 24ch; text-wrap: balance; }

/* Result: the brand moves to the header's left. */
.is-result .masthead { padding: 16px 0 8px; }
.is-result .masthead__promise { display: none; }

/* ---- Stage ------------------------------------------------------------ */

.stage { width: 100%; max-width: 44rem; }
.is-home .stage { margin-top: 28px; }
.is-result .stage { flex: 1; display: flex; flex-direction: column; justify-content: center; padding-top: 12px; }

.card {
  view-transition-name: card;
  position: relative;
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-card), var(--highlight);
  padding: 16px;
}

/* ---- Result ----------------------------------------------------------- */

/* Phone: photo left, name and total right; the sum and the action run full width below. */
.card--result {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  grid-template-areas:
    "thumb head"
    "lines lines"
    "btn   btn"
    "stamp stamp";
  column-gap: 16px;
  align-items: center;
}
.card--result .thumb { grid-area: thumb; }
.card--result .result__head { grid-area: head; }
.card--result .lines { grid-area: lines; }
.card--result .btn { grid-area: btn; }
.card--result .stamp { grid-area: stamp; }

.result { display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 16px; align-items: center; }

/* Product photos arrive with any background: a white tile with an inner hairline makes every one look placed. */
.thumb {
  margin: 0;
  aspect-ratio: 1;
  border-radius: var(--r-lg);
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
  --pad: 10px;
  padding: var(--pad);
}
/* Pinned to the padded box, so a tall photo is contained instead of overflowing the square. */
.thumb img { position: absolute; inset: var(--pad); width: calc(100% - 2 * var(--pad)); height: calc(100% - 2 * var(--pad)); object-fit: contain; border-radius: 6px; }
.thumb__fallback { display: none; width: 44%; height: 44%; color: var(--ink-3); stroke-width: 1.4; }
.thumb--empty { background: var(--surface-2); }
.thumb--empty .thumb__fallback { display: block; }

.result__head { min-width: 0; display: flex; flex-direction: column; gap: 6px; }

.shop {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  max-width: 100%;
  padding: 4px 10px 4px 8px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.shop svg { width: 15px; height: 15px; flex: none; }

.result__name {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.total { margin: 6px 0 0; display: flex; flex-direction: column; }
.total__label { font-size: 0.82rem; color: var(--ink-2); font-weight: 700; }
.total__value { font-size: clamp(2.1rem, 9.4vw, 3rem); font-weight: 800; letter-spacing: -0.04em; line-height: 1.05; }
.total__frac { font-size: 0.55em; letter-spacing: -0.02em; vertical-align: 0.62em; margin-left: 1px; }

/* The sum: the shop's own price (what the visitor will see there) plus shipping = the total above. */
.lines { margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--line); }
.sum {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  color: var(--ink-2);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.sum strong { color: var(--ink); font-weight: 800; }
.sum__op { color: var(--ink-3); font-weight: 700; }
.unit { margin: 8px 0 0; font-size: 0.88rem; color: var(--ink-3); font-weight: 600; }
.unit strong { color: var(--ink-2); font-weight: 800; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  margin-top: 14px;
  padding: 0 22px;
  border-radius: var(--r-control);
  font-weight: 700;
  font-size: 1.02rem;
  text-decoration: none;
  overflow-wrap: anywhere;
  text-align: center;
  transition: transform 180ms var(--ease), box-shadow 180ms var(--ease), filter 180ms var(--ease);
}
.btn svg { width: 20px; height: 20px; flex: none; stroke-width: 2.2; transition: transform 220ms var(--ease); }
.btn--primary {
  color: #fff;
  background: var(--brand);
  box-shadow: var(--shadow-brand), inset 0 1px 0 rgb(255 255 255 / 0.35);
}
.btn--primary:hover {
  transform: translateY(-1px);
  filter: saturate(1.1) brightness(1.04);
  box-shadow: 0 12px 26px -8px rgb(0 155 104 / 0.6), inset 0 1px 0 rgb(255 255 255 / 0.35);
}
.btn--primary:hover svg { transform: translate(2px, -2px); }
.btn--primary:active { transform: scale(0.98); }

.stamp { margin: 12px 0 2px; text-align: center; font-size: 0.8rem; color: var(--ink-3); text-wrap: balance; }

/* ---- Messages --------------------------------------------------------- */

.card--message { text-align: center; padding: 28px 22px; display: flex; flex-direction: column; align-items: center; }
.message__title { display: inline-flex; align-items: center; gap: 10px; margin: 0 0 6px; font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; text-wrap: balance; }
.message__title svg { width: 26px; height: 26px; flex: none; color: var(--ink-3); }
.card--message[role="alert"] .message__title svg { color: var(--alert); }
.message__text { margin: 0 0 12px; color: var(--ink-2); max-width: 34ch; text-wrap: pretty; }
.message__text:last-child { margin-bottom: 0; }

/* ---- Chips ------------------------------------------------------------ */

.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 4px 0 14px; }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 15px;
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 1px 2px rgb(20 45 37 / 0.06), inset 0 0 0 1px var(--line);
}
.chips--static .chip { background: var(--surface-2); box-shadow: none; min-height: 30px; font-size: 0.85rem; }
.chip--link { text-decoration: none; transition: transform 160ms var(--ease), box-shadow 160ms var(--ease), color 160ms var(--ease); }
.chip--link:hover {
  transform: translateY(-1px);
  color: var(--brand-ink);
  box-shadow: 0 6px 14px -8px rgb(0 155 104 / 0.5), inset 0 0 0 1px rgb(0 155 104 / 0.35);
}

/* ---- Loading ---------------------------------------------------------- */

.thumb--skeleton, .skeleton {
  background: linear-gradient(100deg, var(--surface-2) 30%, #fff 50%, var(--surface-2) 70%) 0 0 / 300% 100%;
  animation: shimmer 1.3s linear infinite;
}
.thumb--skeleton { box-shadow: none; }
.skeleton { display: block; height: 16px; border-radius: var(--r-sm); width: 80%; }
.skeleton--sm { width: 40%; height: 22px; }
.skeleton--lg { width: 55%; height: 36px; border-radius: 8px; }
.loading__text { margin: 16px 0 2px; text-align: center; color: var(--ink-3); font-size: 0.9rem; font-weight: 600; }

@keyframes shimmer { to { background-position: -300% 0; } }

/* ---- Composer (search, pinned at the thumb) ---------------------------- */

.composer {
  view-transition-name: composer;
  position: fixed;
  left: 50%;
  bottom: calc(44px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 10;
  width: min(44rem, calc(100% - 2 * var(--gutter)));
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 7px 7px 20px;
  border-radius: var(--r-control);
  background: rgb(255 255 255 / 0.88);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  backdrop-filter: saturate(1.6) blur(18px);
  box-shadow: var(--shadow-float), inset 0 0 0 1px rgb(255 255 255 / 0.7);
  transition: box-shadow 200ms var(--ease);
}
.composer:focus-within {
  box-shadow: var(--shadow-float), 0 0 0 4px rgb(0 155 104 / 0.16), inset 0 0 0 1px rgb(0 155 104 / 0.4);
}

.composer input {
  flex: 1;
  min-width: 0;
  height: 48px;
  border: 0;
  background: transparent;
  font: 600 1.02rem/1 var(--font);
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}
.composer input::placeholder { color: var(--ink-3); font-weight: 500; }
.composer input::-webkit-search-cancel-button { display: none; }
.composer input:focus-visible { outline: none; }

.composer__send {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: var(--brand);
  box-shadow: var(--shadow-brand), inset 0 1px 0 rgb(255 255 255 / 0.4);
  cursor: pointer;
  transition: transform 160ms var(--ease), filter 160ms var(--ease);
}
.composer__send svg { width: 22px; height: 22px; stroke-width: 2.4; }
.composer__send:hover { transform: scale(1.05); filter: brightness(1.05); }
.composer__send:active { transform: scale(0.96); }
.composer__send:focus-visible { outline: 3px solid var(--brand-ink); outline-offset: 2px; border-radius: 10px; }
.composer__send:disabled { filter: grayscale(0.4) opacity(0.7); cursor: progress; }

/* ---- Fine print ------------------------------------------------------- */

/* One line under the composer, on every page. Phones get the short wording: the full sentence cannot fit one line
   there at a readable size. */
.fineprint {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: calc(100% - 2 * var(--gutter));
  margin: 0;
  text-align: center;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fineprint a { color: inherit; text-underline-offset: 2px; }
.fineprint a:hover { color: var(--ink-2); }
.fineprint__short { display: none; }

/* Terms and privacy: in the fineprint on wide screens; top right on phones, where the fineprint line is full. */
.masthead { position: relative; }
.legal-nav {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  display: none;
  gap: 14px;
  font-size: 0.78rem;
  font-weight: 600;
}
.is-home .legal-nav { position: fixed; top: calc(14px + env(safe-area-inset-top)); right: var(--gutter); transform: none; }
.legal-nav a { color: var(--ink-3); text-decoration: none; padding: 6px 0; }
.legal-nav a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 759px) { .legal-nav { display: flex; } }
.is-page .legal-nav { display: flex; }
@media (max-width: 759px) {
  .fineprint__long { display: none; }
  .fineprint__short { display: inline; }
}
@media (max-width: 389px) { .fineprint { font-size: 0.6875rem; letter-spacing: -0.01em; } }

/* ---- Motion ----------------------------------------------------------- */

@view-transition { navigation: auto; }

::view-transition-group(brand),
::view-transition-group(card) { animation-duration: 520ms; animation-timing-function: var(--ease); }
::view-transition-old(card) { animation: fade-out 160ms ease-out both; }
::view-transition-new(card) { animation: fade-in 220ms ease-out both; }
:root[data-vt="launch"]::view-transition-new(card) { animation: card-in 560ms var(--ease) both; transform-origin: 50% 100%; }

@keyframes card-in { from { opacity: 0; transform: translateY(32vh) scale(0.72); } 40% { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .thumb--skeleton, .skeleton { animation: none; }
  .btn, .chip--link, .composer__send { transition: none; }
}

/* ---- Wider screens: photo column left, everything else right ---------- */

@media (min-width: 640px) {
  .is-result .masthead { padding-top: 28px; }
  .card { padding: 24px; }
  .card--result {
    grid-template-columns: 220px minmax(0, 1fr);
    grid-template-areas:
      "thumb head"
      "thumb lines"
      "thumb btn"
      "thumb stamp";
    column-gap: 28px;
    align-items: start;
  }
  .card--result .thumb { align-self: start; --pad: 16px; }
  .result { grid-template-columns: 220px minmax(0, 1fr); gap: 28px; }
  .result__name { font-size: 1.2rem; }
  .stamp { text-align: left; }
}

/* ---- Very narrow phones ------------------------------------------------ */

@media (max-width: 359px) {
  .card--result, .result { grid-template-columns: 84px minmax(0, 1fr); column-gap: 12px; }
  .thumb { --pad: 6px; border-radius: var(--r-md); }
  .total__label { font-size: 0.78rem; }
}

/* ---- Text pages (e.g. /robo) ------------------------------------------ */

.is-page { padding-bottom: 48px; }
.stage--page { justify-content: flex-start; }
.prose { padding: 28px; }
.prose h1 { margin: 0 0 12px; font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; }
.prose h2 { margin: 24px 0 6px; font-size: 1rem; font-weight: 800; }
.prose p, .prose li { color: var(--ink-2); max-width: 68ch; }
.prose p { margin: 0 0 10px; }
.prose ul { margin: 0; padding-left: 20px; }
.prose li + li { margin-top: 6px; }
.prose code { font-family: var(--font); font-weight: 700; font-size: 0.8rem; color: var(--ink); background: var(--surface-2); padding: 2px 8px; border-radius: var(--r-sm); }
.prose pre { margin: 0 0 10px; padding: 12px 16px; border-radius: var(--r-md); background: var(--surface-2); color: var(--ink); font-weight: 700; font-size: 0.8rem; font-family: var(--font); white-space: pre; overflow-x: auto; }
.prose a { color: var(--brand-ink); font-weight: 700; }
