/* DOSE OF SPIRIT: intake overlay (colours come only from the :root variables) */
.ix {
  position: fixed; inset: 0; z-index: 92;
  background: var(--wall); color: var(--ink);
  overflow-x: hidden; overflow-y: auto;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  opacity: 0; visibility: hidden;
  transition: opacity .45s var(--ease), visibility 0s linear .45s;
}
.ix.on { opacity: 1; visibility: visible; transition: opacity .45s var(--ease), visibility 0s; }
.ix-wrap {
  min-height: 100%; width: 100%; max-width: 760px; margin: 0 auto;
  padding: 0 16px calc(48px + env(safe-area-inset-bottom));
  transform: translateY(18px); transition: transform .7s var(--ease);
}
.ix.on .ix-wrap { transform: none; }

/* top bar */
.ix-bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 64px; margin: 0 -16px; padding: env(safe-area-inset-top) 16px 0;
  background: linear-gradient(var(--wall) 72%, transparent);
}
.ix-brand { font-family: var(--f-mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--mute); }
.ix-tools { display: flex; align-items: center; gap: 10px; }
.ix-lang { display: flex; gap: 2px; padding: 3px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line); }
.ix-lang button { min-width: 38px; height: 30px; padding: 0 10px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--mute); transition: background .25s, color .25s; }
.ix-lang button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.ix-x {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line);
  transition: transform .25s var(--ease);
}
.ix-x:hover { transform: rotate(90deg); }

/* views */
.ix-view { padding-top: clamp(8px, 4vh, 40px); }
.ix:not(.ix-gsap) .ix-view > * { animation: ix-rise .7s var(--ease) both; }
.ix:not(.ix-gsap) .ix-view > :nth-child(2) { animation-delay: .06s; }
.ix:not(.ix-gsap) .ix-view > :nth-child(3) { animation-delay: .12s; }
.ix:not(.ix-gsap) .ix-view > :nth-child(4) { animation-delay: .18s; }
.ix:not(.ix-gsap) .ix-view > :nth-child(5) { animation-delay: .24s; }
.ix:not(.ix-gsap) .ix-view > :nth-child(n+6) { animation-delay: .3s; }
@keyframes ix-rise { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }

.ix-title { font-size: clamp(32px, 5vw, 60px); font-weight: 800; letter-spacing: -.035em; line-height: 1.04; margin: 0 0 14px; outline: none; }
html[data-lang="th"] .ix-title { line-height: 1.2; letter-spacing: -.02em; }
.ix-title-sm { font-size: clamp(28px, 4.4vw, 44px); }
.ix-sub { font-size: clamp(16px, 2vw, 19px); line-height: 1.55; color: var(--ink-2); margin: 0 0 28px; max-width: 54ch; }
.ix-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* form */
.ix-field { position: relative; }
.ix-text {
  display: block; width: 100%; min-height: 152px; resize: vertical;
  padding: 20px 20px 40px; border: 0; border-radius: 20px;
  font: inherit; font-size: 18px; line-height: 1.55;
  background: var(--paper); color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow .25s;
}
.ix-text::placeholder { color: var(--mute); }
.ix-text:focus { outline: none; box-shadow: inset 0 0 0 2px var(--ink); }
.ix-meta { position: absolute; left: 20px; right: 20px; bottom: 12px; display: flex; justify-content: space-between; gap: 12px; font-family: var(--f-mono); font-size: 12px; color: var(--mute); pointer-events: none; }
.ix-hint { color: var(--ink); font-family: var(--f-sans); font-weight: 600; }
html[data-lang="th"] .ix-hint { font-family: var(--f-th); }
.ix-count.flash { animation: ix-flash .6s; }
@keyframes ix-flash { 0%, 100% { color: var(--mute); } 40% { color: var(--ink); font-weight: 700; } }
.ix-field.nudge .ix-text { animation: ix-shake .45s var(--ease); }
@keyframes ix-shake { 20% { transform: translateX(-6px); } 45% { transform: translateX(5px); } 70% { transform: translateX(-3px); } }

.ix-chips-l { margin: 20px 0 10px; font-family: var(--f-mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--mute); }
.ix-chips { margin-bottom: 30px; }
.ix-chips .chip { height: 40px; padding: 0 16px; font-size: 15px; flex: none; }
/* examples drift in from the right in one endless line; two equal sets, so -50% loops without a seam */
.ix-marquee {
  overflow: hidden; margin-inline: -4px; padding: 4px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 28px, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 28px, #000 calc(100% - 28px), transparent);
}
.ix-mq-track { display: flex; width: max-content; animation: ixMarquee 42s linear infinite; }
.ix-mq-set { display: flex; gap: 8px; padding-right: 8px; flex: none; }
.ix-marquee:hover .ix-mq-track, .ix-marquee:focus-within .ix-mq-track, .ix-marquee.held .ix-mq-track { animation-play-state: paused; }
@keyframes ixMarquee { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(-50%, 0, 0); } }
@media (prefers-reduced-motion: reduce) {
  .ix-marquee { overflow-x: auto; -webkit-mask-image: none; mask-image: none; scrollbar-width: none; }
  .ix-marquee::-webkit-scrollbar { display: none; }
  .ix-mq-track { animation: none; }
  .ix-mq-dup { display: none; }
}

.ix-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 24px; }
.ix-actions .btn { height: 52px; padding: 0 28px; font-size: 16px; }
.ix-link {
  padding: 12px 2px; font-size: 15px; font-weight: 600; color: var(--ink-2);
  text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 5px;
  transition: color .25s, text-decoration-color .25s;
}
.ix-link:hover { color: var(--ink); text-decoration-color: currentColor; }
.ix-note { max-width: 58ch; margin: 30px 0 0; padding-top: 18px; border-top: 1px dashed var(--line); font-size: 13px; line-height: 1.7; color: var(--mute); }
.ix-note a { color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* thinking */
.ix-think { min-height: 58vh; display: grid; place-content: center; justify-items: center; gap: 26px; text-align: center; }
.ix-pot { position: relative; width: 84px; }
.ix-pot .vial { width: 100%; }
.ix-bub {
  position: absolute; left: var(--x); bottom: 20%; width: var(--s); height: var(--s);
  border-radius: 50%; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line);
  opacity: 0; animation: ix-bub 2.1s var(--d) infinite ease-in;
}
@keyframes ix-bub { 0% { opacity: 0; transform: translateY(0) scale(.5); } 20% { opacity: .85; } 100% { opacity: 0; transform: translateY(-78px) scale(1); } }
.ix-think-t { margin: 0; font-size: clamp(20px, 3vw, 26px); font-weight: 700; letter-spacing: -.02em; animation: ix-pulse 1.6s ease-in-out infinite; }
@keyframes ix-pulse { 50% { opacity: .45; } }

/* result */
.ix-res { display: grid; grid-template-columns: minmax(140px, 200px) minmax(0, 1fr); gap: clamp(20px, 5vw, 56px); align-items: center; }
.ix-stage .vial { width: min(150px, 100%); margin: 0 auto; }
.ix-label { margin: 0 0 8px; font-family: var(--f-mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--mute); }
.ix-name { margin: 0; font-size: clamp(34px, 5.6vw, 60px); font-weight: 800; letter-spacing: -.035em; line-height: 1; outline: none; overflow-wrap: anywhere; }
html[data-lang="th"] .ix-name { line-height: 1.18; letter-spacing: -.02em; }
.ix-alt { margin: 6px 0 18px; color: var(--mute); font-weight: 500; }
.ix-reason { margin: 0 0 14px; padding-left: 14px; border-left: 2px solid var(--ink); font-size: 18px; line-height: 1.55; color: var(--ink-2); }
.ix-label .ix-no { margin-left: .7em; }
.ix-res-actions .ix-price { margin-left: .6em; }
.ix-res-actions .ix-price { opacity: .72; }

/* pharmacy label */
.ix-meds { margin: 0; font-size: 15px; line-height: 1.55; }
.ix-med { display: grid; grid-template-columns: 9.5em minmax(0, 1fr); gap: 4px 14px; padding: 9px 0; border-top: 1px dashed var(--line); }
.ix-med:last-child { border-bottom: 1px dashed var(--line); }
.ix-med dt { font-weight: 700; color: var(--ink); }
.ix-med dd { margin: 0; color: var(--ink-2); overflow-wrap: anywhere; }

/* pharmacist's note */
.ix-pnote {
  position: relative; margin: 20px 0 0; padding: 16px 18px 16px 20px; max-width: 52ch;
  background: var(--paper); color: var(--ink); border-radius: 6px 14px 10px 14px;
  box-shadow: inset 0 0 0 1px var(--line), 3px 4px 0 var(--line);
  transform: rotate(-.6deg);
}
.ix-pnote-in { animation: ix-note-in .9s .55s var(--ease) both; }
@keyframes ix-note-in { from { opacity: 0; transform: translateY(12px) rotate(-2.2deg) scale(.97); } to { opacity: 1; transform: rotate(-.6deg); } }
.ix-pnote-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin: 0 0 8px; }
.ix-pnote-h span { padding: 2px 8px; border: 1.5px solid var(--ink); border-radius: 4px; font-size: 12px; font-weight: 700; letter-spacing: .04em; transform: rotate(-1.2deg); }
.ix-pnote-q { margin: 0; font-size: 17px; font-style: italic; line-height: 1.6; color: var(--ink); overflow-wrap: anywhere; }
html[data-lang="th"] .ix-pnote-q { font-style: normal; }
.ix-res-actions { margin-top: 22px; gap: 8px; }
.ix-res-actions .btn { height: 46px; padding: 0 20px; font-size: 15px; }

.ix-alts { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 36px; padding-top: 22px; border-top: 1px dashed var(--line); }
.ix-alts .ix-label { margin: 0 6px 0 0; }
.ix-alt-card {
  display: flex; align-items: center; gap: 12px; padding: 8px 18px 8px 12px; border-radius: 14px;
  background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); text-align: left;
  transition: transform .3s var(--ease), box-shadow .3s;
}
.ix-alt-card:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 1px var(--ink); }
.ix-alt-card .vial { width: 28px; flex: none; }
.ix-alt-card span { font-size: 15px; font-weight: 600; line-height: 1.25; }
.ix-alt-card small { display: block; font-size: 13px; font-weight: 500; color: var(--mute); }
.ix-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 20px; margin-top: 26px; }
.ix-engine { margin: 0; font-family: var(--f-mono); font-size: 12px; letter-spacing: .02em; color: var(--mute); }

/* care */
.ix-care { max-width: 620px; }
.ix-care-card { margin: 0 0 28px; padding: 22px 24px; border-radius: 20px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); }
.ix-care-card .ix-label { margin-bottom: 4px; }
.ix-hotline { display: inline-block; font-size: clamp(44px, 9vw, 72px); font-weight: 800; letter-spacing: -.04em; line-height: 1.1; }

@media (max-width: 620px) {
  .ix-res { grid-template-columns: 1fr; gap: 18px; }
  .ix-stage .vial { width: 104px; }
  .ix-res-actions .btn:first-child { flex: 1 1 100%; }
  .ix-alt-card { flex: 1 1 100%; }
  .ix-med { grid-template-columns: 1fr; gap: 2px; }
  .ix-v-form .ix-actions .btn { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .ix, .ix-wrap, .ix * { animation: none !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
  .ix-wrap { transform: none; }
}
