/* ==========================================================================
   Reset, document defaults, shared primitives, keyframes
   ========================================================================== */

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

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

body {
  margin: 0;
  background: var(--sky-void);
  color: var(--cream);
  font-family: var(--font-thai);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* The UA's `[hidden] { display: none }` loses to any author class selector
   (e.g. `.liftoff { display: flex }`), so restate it with priority. */
[hidden] { display: none !important; }

h1, h2, h3, p, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }

a { color: var(--gold); text-decoration: none; }
/* Text links go gold on hover. CAREFUL: `a:hover` is (0,1,1) and a plain class
   is (0,1,0), so this beats the colour any button-shaped <a> sets for itself —
   .welcome__cta and .pill--solid are gold-filled buttons whose dark label was
   being repainted pale gold on hover, dropping them from 11.8:1 to 1.10:1.
   Invisible, and on a phone iOS keeps :hover after a tap, so it stuck.

   Any filled <a> added later has to restate its colour in its OWN :hover rule,
   which is (0,2,0) and wins. */
a:hover { color: var(--gold-bright); }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
button:disabled { cursor: not-allowed; }

/* DOUBLE-TAP ZOOM OFF, everywhere something is tappable.
   Two quick taps on the same control is a zoom gesture on a phone, not two
   presses — so pressing + on the decorating page four times to grow a sticker
   zoomed the page instead of growing it much, and that page sets
   `overflow: hidden`, so once zoomed there was nothing left to scroll and it
   read as a freeze. Any repeat-press control has the same hazard.

   `manipulation` removes the double-tap gesture and the 300ms wait that comes
   with it. It does NOT remove pinch-to-zoom or scrolling, so nobody loses a way
   to magnify the page — which is why this is not `user-scalable=no` in the
   viewport tag, a thing iOS ignores anyway and that would take that away. */
button,
a,
label,
summary,
[role="button"],
[role="tab"] {
  touch-action: manipulation;
}

textarea, input { font-family: var(--font-thai); }
::placeholder { color: var(--ink-placeholder); opacity: 1; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 4px;
}

/* --- screen-reader only ---------------------------------------------------- */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --- ANRI wordmark -------------------------------------------------------- */
.brand__name {
  font: 500 19px/1 var(--font-en);
  letter-spacing: .42em;
  color: var(--cream-logo);
}
.brand__sub {
  font: 400 8.5px/1 var(--font-en);
  letter-spacing: .5em;
  color: var(--gold-a60);
  margin-top: 5px;
}
.brand--sm .brand__name { font-size: 17px; letter-spacing: .4em; }
.brand--sm .brand__sub  { font-size: 8px;  letter-spacing: .48em; }

/* The real lockup, where there is one. 30px tall is the height the two-line
   type lockup occupied (17px name + 5px gap + 8px sub), so swapping one for the
   other does not move anything underneath it. Width follows the artwork. */
.brand--logo { display: block; line-height: 0; }
.brand__mark {
  display: block;
  height: 30px;
  width: auto;
}

/* --- circular icon button ------------------------------------------------- */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--gold-a45);
  color: var(--gold);
  font: 400 15px/1 system-ui, sans-serif;
  transition: background-color .18s ease;
}
.icon-btn:hover { background: var(--gold-a12); }

/* --- outlined pill -------------------------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 26px;
  border: 1px solid var(--gold-a55);
  border-radius: var(--r-pill);
  color: var(--gold-pale);
  font: 400 13px/1 var(--font-thai);
  transition: background-color .18s ease, border-color .18s ease;
}
.pill:hover { background: var(--gold-a14); border-color: var(--gold); }

/* The filled variant, for the one primary action on a screen. results.css
   deliberately reverts it to an outline at >= 768px, where the mock has no
   filled button. */
.pill--solid {
  background: linear-gradient(180deg, var(--gold-lantern-1), var(--gold-lantern-2));
  border-color: transparent;
  color: var(--ink-moon);
  font-weight: 500;
}
/* colour restated on purpose — see the note on a:hover above. */
.pill--solid:hover {
  background: linear-gradient(180deg, #f7e4ab, #e8bf62);
  color: var(--ink-moon);
}

/* --- share buttons (results + summary) ------------------------------------ */
.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--gold-a35);
  color: var(--gold);
  transition: background-color .18s ease;
}
.share-btn:hover { background: var(--gold-a14); }
.share-btn[data-share="line"] span { font: 500 9px/1 system-ui, sans-serif; }
.share-btn[data-share="fb"]   span { font: 500 15px/1 Georgia, serif; }
.share-btn[data-share="x"]    span { font: 500 14px/1 system-ui, sans-serif; }

/* --- the primary send button (write.html) --------------------------------- */
.submit__btn {
  width: 100%;
  padding: 19px 0;
  border-radius: var(--r-pill);
  background: linear-gradient(180deg, var(--cta-1), var(--cta-2));
  color: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  box-shadow: var(--sh-cta);
  transition: background .18s ease, opacity .18s ease;
}
.submit__btn:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--cta-1-hover), var(--cta-2-hover));
}
.submit__btn:disabled { opacity: .62; }

.submit__label { font: 500 17px/1 var(--font-thai); }
.submit__star  { font: 400 13px/1 system-ui, sans-serif; color: var(--gold); }

.submit__spinner {
  display: none;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(246, 239, 223, .3);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.submit__btn.is-busy .submit__spinner { display: block; }
.submit__btn.is-busy .submit__star { display: none; }

/* --- section divider rule ------------------------------------------------- */
.rule {
  width: 44px; height: 1px;
  background: var(--gold-a50);
  border: 0;
}

/* --- starfield ------------------------------------------------------------ */
/* Two layers at different opacities and periods so the twinkle never looks
   like one synchronised blink. */
.stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1.6px 1.6px at 12% 12%, rgba(255,255,255,.75), transparent),
    radial-gradient(1.3px 1.3px at 28% 30%, rgba(255,255,255,.50), transparent),
    radial-gradient(1.5px 1.5px at 46%  8%, rgba(255,255,255,.60), transparent),
    radial-gradient(1.2px 1.2px at 68% 20%, rgba(255,255,255,.45), transparent),
    radial-gradient(1.7px 1.7px at 88% 10%, rgba(255,255,255,.70), transparent),
    radial-gradient(1.2px 1.2px at 94% 34%, rgba(255,255,255,.40), transparent),
    radial-gradient(1.4px 1.4px at  8% 52%, rgba(255,255,255,.45), transparent),
    radial-gradient(1.2px 1.2px at 76% 62%, rgba(255,255,255,.35), transparent),
    radial-gradient(1.5px 1.5px at 36% 76%, rgba(255,255,255,.40), transparent);
  animation: twinkle 7s ease-in-out infinite;
}
.stars--alt {
  background-image:
    radial-gradient(1.4px 1.4px at 18% 22%, rgba(255,255,255,.70), transparent),
    radial-gradient(1.2px 1.2px at 64% 14%, rgba(255,255,255,.50), transparent),
    radial-gradient(1.6px 1.6px at 84% 46%, rgba(255,255,255,.45), transparent),
    radial-gradient(1.2px 1.2px at 34% 62%, rgba(255,255,255,.40), transparent),
    radial-gradient(1.1px 1.1px at  8% 74%, rgba(255,255,255,.35), transparent);
  animation-duration: 6s;
}

/* --- ดาวตก ---------------------------------------------------------------
   A host marked data-shooting; assets/js/shooting.js drops one <i> in every
   240-620ms and removes each when its animation ends, so nothing accumulates —
   measured at ~3.4 alive on average and never more than 6.

   The streak is one element, not a head plus a tail: the gradient IS the tail,
   fading backwards from a bright point, and ::after is the small bloom at that
   point. transform-origin sits at the leading end so rotate() aims the whole
   thing along its own direction and translateX moves it that way. */
.shooting {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

/* --th (thickness), --hd (head) and --b (peak opacity) all come off one
   magnitude roll in shooting.js. A faint meteor is not a dimmed copy of a
   bright one — it is thinner and its head is smaller — and a sky where every
   streak is equally bright is the giveaway that they came from one template. */
.shoot {
  position: absolute;
  /* --x is where the HEAD starts, which is the end that matters — it is the
     bright point the eye tracks, and it is what the placement in JS reasons
     about. The element is drawn tail-first from `left`, so the tail's whole
     length has to come off it; without this every star sat one tail-length
     right of where it was meant to be, and the longest ones were placed off
     the frame entirely. */
  left: calc(var(--x, 20%) - var(--len, 90px));
  top: var(--y, 20%);
  width: var(--len, 70px);
  height: var(--th, 1.5px);
  border-radius: 2px;
  transform-origin: 100% 50%;
  background: linear-gradient(90deg,
    rgba(255, 246, 214, 0) 0%,
    rgba(255, 246, 214, .28) 55%,
    rgba(255, 250, 232, .92) 100%);
  opacity: 0;
  /* TWO animations, not one, and they are split on purpose.
     A timing function is applied between EVERY PAIR of keyframes, not across
     the whole run — so a fall with brightness stops at 22% and 68% written into
     it would ease-in-out four separate times and visibly stall twice on the way
     down. Keeping the movement to a bare 0%/100% pair is what lets it carry one
     unbroken curve, and the fade rides alongside on its own linear clock.

     ease-in-out is the same curve the pampas grass sways on. It also puts the
     slow ends of the motion exactly where the star is fading in and out, so
     what you actually watch is the even middle. */
  animation:
    shootFall var(--dur, 3000ms) ease-in-out forwards,
    shootFade var(--dur, 3000ms) linear forwards;
  will-change: transform, opacity;
}
/* The head. Small and only just brighter than the tail's end — a large glowing
   dot turns a shooting star into a comet. */
.shoot::after {
  content: "";
  position: absolute;
  right: -1px;
  top: 50%;
  width: var(--hd, 3.2px);
  height: var(--hd, 3.2px);
  border-radius: 50%;
  background: #fffaf0;
  transform: translateY(-50%);
  box-shadow: 0 0 6px 1px rgba(255, 244, 206, .85);
}

/* No scaleX. The trail used to grow from a quarter length to full across the
   whole flight, which had two problems: the growth was slower than any real
   trail reaches its length, and — because the head is a child of the scaled
   element — it squashed the round head into an ellipse a quarter as wide for
   the first half of every streak. The tail length is settled in JS from the
   speed, and the star is born above the frame, so what reveals the line is the
   top edge itself: the head slides into view first and the tail follows it in. */
@keyframes shootFall {
  from { transform: rotate(var(--a, 66deg)) translateX(0); }
  to   { transform: rotate(var(--a, 66deg)) translateX(var(--travel, 300px)); }
}

/* Long, soft ends. A quick fade suits a meteor that is gone in half a second;
   at three seconds it reads as a light being switched, so the star spends the
   first fifth arriving and the last third leaving. */
@keyframes shootFade {
  0%   { opacity: 0; }
  22%  { opacity: var(--b, .9); }
  68%  { opacity: var(--b, .9); }
  100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .shooting { display: none; }
}

/* --- keyframes (names kept from the mock) --------------------------------- */
@keyframes floatUp {
  0%   { opacity: 0; transform: translate(-50%, calc(-50% + 26px)) scale(.7); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-7px); }
}
@keyframes twinkle {
  0%, 100% { opacity: .35; }
  50%      { opacity: .9; }
}
@keyframes glow {
  0%, 100% { opacity: .5; }
  50%      { opacity: .85; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes riseIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
