/* gifgen · Sticker — the design since 2026-11-27 (Claude Design, direction A).
   Warm paper, heavy ink outlines, hard shadows, the GIF as a tilted sticker.
   Phone first: this is used mid-conversation. */
:root {
  --paper: #FFF3D1;
  --card: #FFFFFF;
  --ink: #1A1714;
  --muted: #5C5346;
  --accent: #FFB800;
  --error: #B3261E;
  --display: "Bricolage Grotesque", "Arial Black", system-ui, sans-serif;
  --body: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --line: 2.5px solid var(--ink);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1C1915;
    --card: #2A2620;
    --ink: #FFF3D1;
    --muted: #CDBFA6;
    --error: #FF8A80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* Author display rules would otherwise beat the UA's [hidden] style. */
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  /* One font, one size for everything but the logo. */
  font: 16px/1.5 var(--body);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, a { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 28px max(20px, env(safe-area-inset-right, 0px)) 32px max(20px, env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---- masthead ---- */
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.12em;
  margin: 0;
  font: 800 40px/1 var(--display);
  letter-spacing: -0.03em;
}
/* Both trimmed to their capitals, so the sticker centres on GIF's letters. */
.wordmark .wm-gif,
.wordmark .wm-me { text-box: trim-both cap alphabetic; }
/* ME on a sticker as tall as GIF's capitals (a touch taller), tilted clockwise
   so the E sits lower than the M, with the GIF box's hard shadow. */
.wordmark .wm-me {
  display: inline-block;
  font-size: 0.575em;
  letter-spacing: -0.01em;
  padding: 0.25em 0.3em;
  background: var(--accent);
  color: #1A1714;
  border: 0.11em solid var(--ink);
  border-radius: 0.28em;
  box-shadow: 0.12em 0.12em 0 var(--ink);
  transform: translateY(-0.04em) rotate(8deg);
}
.tagline { margin: 0; color: var(--muted); }

.note {
  margin: 0;
  padding: 12px 14px;
  background: var(--card);
  border: var(--line);
  border-radius: 14px;
  box-shadow: 3px 3px 0 var(--accent);
}

/* ---- composer: one box, like a chat app — attachment, prompt, tools ---- */
.composer { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.composer-label { }
/* The input box's title: plain text above the box, no frame of its own. */
.composer-title { font-weight: 600; }
.composer-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 10px 10px 12px;
  background: var(--card);
  border: var(--line);
  border-radius: 18px;
  box-shadow: 6px 6px 0 var(--accent);
  transition: box-shadow 0.12s, background 0.12s;
}
.composer.dragging .composer-box { border-style: dashed; }
.composer textarea {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 2px;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
}
.composer textarea::placeholder { color: var(--muted); opacity: 1; font-style: italic; }
.composer-bar { display: flex; align-items: center; gap: 8px; }
/* A bare plus, named "Add a photo" for screen readers; still a 44px target. */
.photo-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
.photo-add.busy { opacity: 0.5; cursor: progress; }
.paste-hint { display: none; color: var(--muted); }
@media (hover: hover) and (pointer: fine) {
  .photo-add:not([hidden]) + .paste-hint { display: inline; }
}
.make {
  margin-left: auto;
  height: 44px;
  padding: 0 18px;
  font-weight: 600;
  color: #1A1714;
  background: var(--accent);
  border: var(--line);
  border-radius: 14px;
  transition: transform 0.08s;
}
.make:active:not(:disabled) { transform: translate(1px, 1px); }
.make:disabled { opacity: 0.6; cursor: default; }

/* The attached photo, inside the box above the prompt. */
.attachment {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 10px;
  padding: 4px;
  background: #FFF3D1;
  color: #1A1714;
  border: 2px solid var(--ink);
  border-radius: 14px;
}
.attachment img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; }
.photo-label { }
.attachment button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: #FFFFFF;
  color: #1A1714;
  border: 2px solid #1A1714;
  border-radius: 50%;
}

/* ---- trending chips ---- */
.trending { display: flex; flex-direction: column; gap: 8px; }
.trending-label { margin: 0; font-weight: 600; }
/* Two rows that scroll sideways, edge to edge on a phone. */
.examples {
  display: grid;
  grid-template-rows: repeat(2, auto);
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  /* Snap to the page's margin, not the screen edge. */
  scroll-padding-inline: 20px;
  scrollbar-width: none;
  margin: 0 -20px;
  padding: 2px 20px 4px;
}
.examples::-webkit-scrollbar { display: none; }
/* Like the input box: its background and text colour, with a coloured line. */
.examples button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
  white-space: nowrap;
  scroll-snap-align: start;
  background: var(--card);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 14px;
}
.examples button:nth-child(5n+1) { border-color: #FFE08A; }
.examples button:nth-child(5n+2) { border-color: #FFC2D4; }
.examples button:nth-child(5n+3) { border-color: #BFF0D0; }
.examples button:nth-child(5n+4) { border-color: #C9DCFF; }
.examples button:nth-child(5n+5) { border-color: #FFD3B0; }

.error { margin: 0; color: var(--error); }
/* A nudge, not an error: e.g. "add your photo to star in this one". */
.error.nudge { color: var(--ink); }

/* ---- the GIF as a sticker ---- */
.stage { display: flex; flex-direction: column; align-items: stretch; gap: 14px; padding-top: 6px; }
.sticker {
  position: relative;
  align-self: center;
  width: min(100%, 340px);
  padding: 10px;
  background: var(--card);
  border: var(--line);
  border-radius: 22px;
  box-shadow: 6px 6px 0 var(--accent);
  transform: rotate(-1.5deg);
  transition: transform 0.35s ease-out;
}
.frame {
  position: relative;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background: repeating-linear-gradient(45deg, #FFE7A3 0 12px, #FFF3D1 12px 24px);
}
.frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.badge {
  position: absolute;
  top: -14px;
  right: -10px;
  padding: 5px 11px;
  background: var(--ink);
  color: var(--paper);
  border: 1.5px solid #000;
  border-radius: 999px;
  transform: rotate(6deg);
  display: none;
}
.stage[data-state="ready"] .badge { display: block; }
/* Once it's ready the sticker settles straight, lined up with the buttons. */
.stage[data-state="ready"] .sticker { transform: rotate(0deg); }

.spinner {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 5px solid #1A1714;
  border-right-color: var(--accent);
  animation: spin 0.9s linear infinite;
  display: none;
}
.stage[data-state="generating"] .spinner { display: block; }
.stage[data-state="generating"] .sticker { animation: wobble 1.6s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes wobble { 0%, 100% { transform: rotate(-1.5deg); } 50% { transform: rotate(1.5deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner, .stage[data-state="generating"] .sticker { animation: none; }
}

.status { margin: 0; text-align: center; min-height: 1.3em; }
.status:empty { display: none; }
/* Inside the square, under the loader. The square's stripes are pale yellow
   in both light and dark mode, so the text is always dark ink. */
.frame .status {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(50% + 42px);
  padding: 0 20px;
  color: #1A1714;
}

/* ---- actions: Share (shaped like Generate), then download and redo icons ---- */
.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.actions-row { display: flex; align-items: center; gap: 8px; }
.make.share { flex: 1 1 auto; margin-left: 0; }
.make.share:disabled { opacity: 0.55; cursor: default; }
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  text-decoration: none;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 14px;
}
.hint { margin: 0; text-align: center; color: var(--muted); }
.hint:empty { display: none; }

.foot { margin-top: 8px; text-align: center; color: var(--muted); }

/* ---- result first: once a GIF is being made, ready, or arrived by link,
   the GIF and Share come right under the logo, then the prompt box to edit
   and try again, then the trending prompts. */
:is(body[data-stage="generating"], body[data-stage="ready"], body[data-stage="arrival"]) .masthead { order: 0; }
:is(body[data-stage="generating"], body[data-stage="ready"], body[data-stage="arrival"]) .note { order: 1; }
:is(body[data-stage="generating"], body[data-stage="ready"], body[data-stage="arrival"]) .stage { order: 2; }
:is(body[data-stage="generating"], body[data-stage="ready"], body[data-stage="arrival"]) .composer { order: 3; }
:is(body[data-stage="generating"], body[data-stage="ready"], body[data-stage="arrival"]) .error { order: 4; }
:is(body[data-stage="generating"], body[data-stage="ready"], body[data-stage="arrival"]) .trending { order: 5; }
:is(body[data-stage="generating"], body[data-stage="ready"], body[data-stage="arrival"]) .foot { order: 6; }
.stage { scroll-margin-top: 24px; }  /* room for the "ready" badge above the GIF */

/* The attached GIF or video's thumbnail (design v3). */
.source-thumb { display: inline-flex; width: 44px; height: 44px; border-radius: 10px; overflow: hidden; }
.source-thumb img, .source-thumb video { width: 100%; height: 100%; object-fit: cover; }

/* A finished GIF keeps its own shape (a swapped meme is often wide): the
   frame stops being a square once there's a GIF in it. */
.stage[data-state="ready"] .frame, .stage[data-state="arrival"] .frame { aspect-ratio: auto; }
.stage[data-state="ready"] .frame img, .stage[data-state="arrival"] .frame img { height: auto; object-fit: contain; }
