/* Luiz Paglioni — the site is a conversation.
   One sun-yellow ground, ink, white bubbles. Gabarito throughout. */

:root {
  --sun: #FFD53D;
  --ink: #16130A;
  --paper: #FFFFFF;
  --muted: #4D4210;      /* small text on yellow, 7:1 */
  --hint: #6B6350;       /* placeholder on white, 5.6:1 */
  --spring: cubic-bezier(0.2, 0.8, 0.2, 1);
  --gutter: clamp(16px, 3.4vw, 48px);
  color-scheme: light;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--sun);
  color: var(--ink);
  font-family: 'Gabarito', 'Avenir Next', 'Trebuchet MS', system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

a { color: inherit; }
a:hover { color: #5A3F00; }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 6px; }

::selection { background: var(--ink); color: var(--sun); }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ---------- Page shell: header, thread, and a message box docked to the bottom ---------- */

.page {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px var(--gutter) 0;
  display: flex;
  flex-direction: column;
}

.top {
  margin-bottom: clamp(24px, 3.4vw, 44px);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px 24px;
}
.who { display: flex; align-items: center; gap: 14px; }
.avatar {
  flex: none;
  width: clamp(48px, 5vw, 56px); height: clamp(48px, 5vw, 56px);
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--ink);        /* shows while the photo loads */
  object-fit: cover;
}
.who-text { line-height: 1.2; }
.name { margin: 0; font-size: 19px; font-weight: 700; }
.status { margin: 0; min-height: 18px; font-size: 15px; color: var(--muted); }
.status.is-typing { font-style: italic; }

.links { display: flex; align-items: center; gap: 20px; font-size: 16px; font-weight: 600; }
.links a { display: inline-flex; align-items: center; min-height: 44px; }
.links .pill {
  padding: 0 20px; border: 2px solid var(--ink); border-radius: 999px; text-decoration: none;
  transition: background 0.2s, color 0.2s;
}
.links .pill:hover { background: var(--ink); color: var(--sun); }

.thread { padding-bottom: 28px; display: flex; flex-direction: column; }
.stamp { align-self: center; margin: 0 0 16px; font-size: 13px; color: var(--muted); }
.log { display: flex; flex-direction: column; align-items: flex-start; }

/* ---------- Bubbles ---------- */

.bubble { margin: 0; width: fit-content; }

/* Luiz */
.bubble.in {
  max-width: min(820px, 100%);
  margin-top: 6px;
  padding: clamp(14px, 1.8vw, 24px) clamp(20px, 2.6vw, 36px);
  background: var(--paper);
  border-radius: 30px 30px 30px 8px;
  font-size: clamp(21px, 2.4vw, 32px);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: pretty;
  transition: border-radius 0.3s ease;
}
.bubble.in strong { font-weight: 800; }
.bubble.in a { font-weight: 800; }

.bubble.hero {
  padding: clamp(16px, 2.2vw, 30px) clamp(24px, 3.4vw, 48px) clamp(20px, 2.6vw, 36px);
  border-radius: clamp(28px, 4vw, 56px) clamp(28px, 4vw, 56px) clamp(28px, 4vw, 56px) 8px;
  font-size: clamp(48px, 7.6vw, 108px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}
.bubble.hook {
  font-size: clamp(26px, 3.1vw, 44px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.025em;
}

/* The tail belongs to the newest bubble in a run: older ones round off. */
.bubble.in:has(+ .bubble.in) { border-bottom-left-radius: 26px; }
.bubble.hero:has(+ .bubble.in) { border-bottom-left-radius: clamp(28px, 4vw, 56px); }

/* The visitor */
.bubble.out {
  max-width: min(640px, 100%);
  padding: 14px 24px;
  background: var(--ink);
  color: var(--sun);
  border-radius: 28px 28px 8px 28px;
  font-size: clamp(19px, 2vw, 26px);
  font-weight: 600;
  line-height: 1.25;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.sent {
  align-self: flex-end;
  margin-top: 22px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 5px;
  max-width: 100%;
}
.receipt { min-height: 18px; padding-right: 8px; font-size: 13px; line-height: 18px; color: var(--muted); }
.receipt.is-failed { color: #8A1C00; font-weight: 600; }

/* Typing dots: the same footprint the next message grows out of. */
.bubble.in.typing {
  width: 84px; height: 52px; padding: 0;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 26px 26px 26px 8px;
  transform-origin: bottom left;
}
.typing span { width: 9px; height: 9px; border-radius: 50%; background: var(--ink); }

/* Questions and answers as written (shown only when JavaScript is off). */
.qa { align-self: stretch; margin-top: 22px; display: flex; flex-direction: column; align-items: flex-start; }
.qa .bubble.out { align-self: flex-end; margin-bottom: 10px; }

.nojs { margin: 8px 0 32px; font-size: 20px; }
.nojs a { font-weight: 800; }

/* ---------- Dock: question chips and the message box ---------- */

.dock {
  position: sticky; bottom: 0; margin-top: auto;
  padding: 36px 0 max(20px, env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(255, 213, 61, 0), var(--sun) 32px);
  display: flex; flex-direction: column; gap: 12px;
}

.chips { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips:empty { display: none; }

.chip {
  flex: none;
  min-height: 48px; padding: 0 22px;
  border: 2px solid var(--ink); border-radius: 999px;
  background: transparent; color: var(--ink);
  font: inherit; font-size: 18px; font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s var(--spring), background 0.2s, color 0.2s;
}
.chip:active { transform: scale(0.96); }
@media (hover: hover) {
  .chip:hover { transform: translateY(-2px); background: var(--ink); color: var(--sun); }
}

.composer {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 8px 8px clamp(18px, 4vw, 26px);
  background: var(--paper);
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(22, 19, 10, 0.16);
  transition: box-shadow 0.2s;
}
.composer:focus-within { box-shadow: 0 0 0 3px var(--ink), 0 10px 30px rgba(22, 19, 10, 0.16); }
.composer input {
  flex: 1; min-width: 0; height: 48px; padding: 0;
  border: 0; outline: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: clamp(16px, 1.6vw, 21px);   /* 16px minimum: iOS zooms the page below that */
  text-overflow: ellipsis;
}
.composer input::placeholder { color: var(--hint); opacity: 1; text-overflow: ellipsis; }
.composer button {
  flex: none; width: 48px; height: 48px; padding: 0;
  border: 0; border-radius: 50%;
  background: var(--ink); color: var(--sun);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform 0.15s;
}
.composer button svg { transition: transform 0.25s var(--spring); }
.composer button:hover svg { transform: translateY(-3px); }
.composer button:active { transform: scale(0.92); }
.composer button:focus-visible { outline: 3px solid var(--sun); outline-offset: -6px; border-radius: 50%; }

/* ---------- With JavaScript: the thread starts empty and is played in ---------- */

html.js .log > [data-intro]:not(.is-live),
html.js .log > .qa { display: none; }
html:not(.js) .dock { display: none; }

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

/* A message grows out of the typing bubble's footprint, then its words fade up. */
@keyframes morph {
  from { clip-path: inset(0 calc(100% - 84px) calc(100% - 52px) 0 round 26px 26px 26px 8px); }
  to   { clip-path: inset(0 0 0 0 round 26px 26px 26px 8px); }
}
@keyframes ink {
  0%, 30% { opacity: 0; transform: translateY(5px); }
  100%    { opacity: 1; transform: none; }
}
@keyframes pop   { from { opacity: 0; transform: scale(0.4); } to { opacity: 1; transform: none; } }
@keyframes send  { from { opacity: 0; transform: translateY(36px) scale(0.86); } to { opacity: 1; transform: none; } }
@keyframes rise  { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes dot   { 0%, 60%, 100% { transform: translateY(0); opacity: 0.3; } 30% { transform: translateY(-5px); opacity: 1; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }

.bubble.in.arrive { animation: morph 0.45s cubic-bezier(0.2, 0.85, 0.25, 1); }
.bubble.in.arrive > .ink { display: block; animation: ink 0.45s ease both; }
.bubble.hero.arrive, .bubble.hero.arrive > .ink { animation-duration: 0.5s; }

.bubble.in.typing { animation: pop 0.26s cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }
.typing span { animation: dot 1s ease-in-out infinite; }
.typing span:nth-child(2) { animation-delay: 0.16s; }
.typing span:nth-child(3) { animation-delay: 0.32s; }

.sent .bubble.out { transform-origin: bottom right; animation: send 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.15) both; }
.receipt.is-fresh { animation: rise 0.3s ease both; }

.chip { animation: rise 0.4s ease both; }
.chip:nth-child(2) { animation-delay: 0.07s; }
.chip:nth-child(3) { animation-delay: 0.14s; }

.composer.shake { animation: shake 0.4s ease; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
